ecryptfs: use filemap_dirty_folio for address space operations
PATCH 1/1 ecryptfs: use filemap_dirty_folio for address space operations
ecryptfs does not use buffer_heads. The legacy block_dirty_folio and block_invalidate_folio mapping operations were only added as a temporary compatibility fallback under CONFIG_BLOCK.
Since ecryptfs does not attach private metadata (such as buffer_heads) to its folios, block_dirty_folio is unnecessary.
Modernize ecryptfs to use filemap_dirty_folio for its dirty_folio address space operation. This allows removing the block_dirty_folio and block_invalidate_folio fallbacks, removing the buffer_head header include, and removing the CONFIG_BLOCK dependency inside ecryptfs_aops.
--- fs/ecryptfs/mmap.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
fs/ecryptfs/mmap.c +1 -14
@@ -510,21 +510,8 @@ static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block)return block; } -#include <linux/buffer_head.h> -const struct address_space_operations ecryptfs_aops = { -/* -* XXX: This is pretty broken for multiple reasons: ecryptfs does not -* actually use buffer_heads, and ecryptfs will crash without -* CONFIG_BLOCK. But it matches the behavior before the default for -* address_space_operations without the ->dirty_folio method was -* cleaned up, so this is the best we can do without maintainer -* feedback. -*/ -#ifdef CONFIG_BLOCK - .dirty_folio = block_dirty_folio, - .invalidate_folio = block_invalidate_folio, -#endif + .dirty_folio = filemap_dirty_folio, .writepages = ecryptfs_writepages, .read_folio = ecryptfs_read_folio, .write_begin = ecryptfs_write_begin,
Signature · 1 line
2.47.3
Tyler Hicks
maintainerQuoted 7 lines · Aditya Prakash Srivastava
ecryptfs does not use
buffer_heads. The legacyblock_dirty_folioandblock_invalidate_foliomapping operations were only added as a temporary compatibility fallback underCONFIG_BLOCK.Since ecryptfs does not attach private metadata (such as
buffer_heads) to its folios,block_dirty_foliois unnecessary.
Quoted 6 lines
Modernize ecryptfs to use
filemap_dirty_foliofor itsdirty_folioaddress space operation. This allows removing theblock_dirty_folioandblock_invalidate_foliofallbacks, removing thebuffer_headheader include, and removing theCONFIG_BLOCKdependency insideecryptfs_aops.Signed-off-by Aditya Prakash Srivastava <[email protected]>
This looks correct to me and I've successfully ran the kernel tests in the ecryptfs-utils test suite with the patch applied.
Adding Christoph for comment since this addresses the concern he documented in the code comment below.
Tyler
Quoted 34 lines
--- fs/ecryptfs/mmap.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)fs/ecryptfs/mmap.c +1
-14@@ -510,21 +510,8 @@ static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block)return block; } -#include <linux/buffer_head.h> -const struct address_space_operations ecryptfs_aops = { -/* -* XXX: This is pretty broken for multiple reasons: ecryptfs does not -* actually use buffer_heads, and ecryptfs will crash without -* CONFIG_BLOCK. But it matches the behavior before the default for -* address_space_operations without the ->dirty_folio method was -* cleaned up, so this is the best we can do without maintainer -* feedback. -*/ -#ifdef CONFIG_BLOCK - .dirty_folio = block_dirty_folio, - .invalidate_folio = block_invalidate_folio, -#endif + .dirty_folio = filemap_dirty_folio, .writepages = ecryptfs_writepages, .read_folio = ecryptfs_read_folio, .write_begin = ecryptfs_write_begin,Signature · 1 line
2.47.3
Christoph Hellwig
Reviewed-byQuoted 5 lines · Tyler Hicks
This looks correct to me and I've successfully ran the kernel tests in the ecryptfs-utils test suite with the patch applied.
Adding Christoph for comment since this addresses the concern he documented in the code comment below.
Looks good to me:
Tyler Hicks
maintainerQuoted 8 lines · Aditya Prakash Srivastava
ecryptfs does not use
buffer_heads. The legacyblock_dirty_folioandblock_invalidate_foliomapping operations were only added as a temporary compatibility fallback underCONFIG_BLOCK.Since ecryptfs does not attach private metadata (such as
buffer_heads) to its folios,block_dirty_foliois unnecessary.[...]
Thank you! This has been applied to the next branch of the tyhicks/ecryptfs.git tree.
You can find a direct link below but please be aware that the commit hash is unstable and, therefore, the URL may not be valid in the future.
[1/1] ecryptfs: use filemap_dirty_folio for address space operations
https://git.kernel.org/tyhicks/ecryptfs/c/21a6287ae2489426d23979e2213033dd204aa9fa
Tyler