All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ecryptfs: use filemap_dirty_folio for address space operations
@ 2026-07-03  9:00 Aditya Prakash Srivastava
  2026-07-14  5:00 ` Tyler Hicks
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Prakash Srivastava @ 2026-07-03  9:00 UTC (permalink / raw)
  To: Tyler Hicks
  Cc: Christian Brauner, ecryptfs, linux-kernel,
	Aditya Prakash Srivastava

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.

Signed-off-by: Aditya Prakash Srivastava <aditya.ansh182@gmail.com>
---
 fs/ecryptfs/mmap.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 2c2b12fedeae..a057472b409c 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -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,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ecryptfs: use filemap_dirty_folio for address space operations
  2026-07-03  9:00 [PATCH] ecryptfs: use filemap_dirty_folio for address space operations Aditya Prakash Srivastava
@ 2026-07-14  5:00 ` Tyler Hicks
  2026-07-14  5:18   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Tyler Hicks @ 2026-07-14  5:00 UTC (permalink / raw)
  To: Aditya Prakash Srivastava, Christoph Hellwig
  Cc: Christian Brauner, ecryptfs, linux-kernel

On 2026-07-03 09:00:44, Aditya Prakash Srivastava wrote:
> 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.
> 
> Signed-off-by: Aditya Prakash Srivastava <aditya.ansh182@gmail.com>

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

> ---
>  fs/ecryptfs/mmap.c | 15 +--------------
>  1 file changed, 1 insertion(+), 14 deletions(-)
> 
> diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
> index 2c2b12fedeae..a057472b409c 100644
> --- a/fs/ecryptfs/mmap.c
> +++ b/fs/ecryptfs/mmap.c
> @@ -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,
> -- 
> 2.47.3
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ecryptfs: use filemap_dirty_folio for address space operations
  2026-07-14  5:00 ` Tyler Hicks
@ 2026-07-14  5:18   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-07-14  5:18 UTC (permalink / raw)
  To: Tyler Hicks
  Cc: Aditya Prakash Srivastava, Christoph Hellwig, Christian Brauner,
	ecryptfs, linux-kernel

On Tue, Jul 14, 2026 at 12:00:59AM -0500, Tyler Hicks wrote:
> 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:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-14  5:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03  9:00 [PATCH] ecryptfs: use filemap_dirty_folio for address space operations Aditya Prakash Srivastava
2026-07-14  5:00 ` Tyler Hicks
2026-07-14  5:18   ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.