mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ceph: Fix incorrect flush end position calculation
@ 2025-03-12 10:47 David Howells
  2025-03-12 18:43 ` Viacheslav Dubeyko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: David Howells @ 2025-03-12 10:47 UTC (permalink / raw)
  To: Viacheslav Dubeyko
  Cc: dhowells, Alex Markuze, Xiubo Li, Ilya Dryomov,
	Christian Brauner, ceph-devel, linux-fsdevel, linux-kernel

In ceph, in fill_fscrypt_truncate(), the end flush position is calculated
by:

                loff_t lend = orig_pos + CEPH_FSCRYPT_BLOCK_SHIFT - 1;

but that's using the block shift not the block size.

Fix this to use the block size instead.

Fixes: 5c64737d2536 ("ceph: add truncate size handling support for fscrypt")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Viacheslav Dubeyko <slava@dubeyko.com>
cc: Alex Markuze <amarkuze@redhat.com>
cc: Xiubo Li <xiubli@redhat.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: ceph-devel@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
 fs/ceph/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index ab63c7ebce5b..ec9b80fec7be 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2363,7 +2363,7 @@ static int fill_fscrypt_truncate(struct inode *inode,
 
 	/* Try to writeback the dirty pagecaches */
 	if (issued & (CEPH_CAP_FILE_BUFFER)) {
-		loff_t lend = orig_pos + CEPH_FSCRYPT_BLOCK_SHIFT - 1;
+		loff_t lend = orig_pos + CEPH_FSCRYPT_BLOCK_SIZE - 1;
 
 		ret = filemap_write_and_wait_range(inode->i_mapping,
 						   orig_pos, lend);


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

* Re:  [PATCH] ceph: Fix incorrect flush end position calculation
  2025-03-12 10:47 [PATCH] ceph: Fix incorrect flush end position calculation David Howells
@ 2025-03-12 18:43 ` Viacheslav Dubeyko
  2025-03-13  8:25 ` David Howells
  2025-03-13  9:00 ` David Howells
  2 siblings, 0 replies; 5+ messages in thread
From: Viacheslav Dubeyko @ 2025-03-12 18:43 UTC (permalink / raw)
  To: slava, David Howells
  Cc: ceph-devel, Alex Markuze, Xiubo Li, brauner, idryomov,
	linux-fsdevel, linux-kernel

On Wed, 2025-03-12 at 10:47 +0000, David Howells wrote:
> In ceph, in fill_fscrypt_truncate(), the end flush position is calculated
> by:
> 
>                 loff_t lend = orig_pos + CEPH_FSCRYPT_BLOCK_SHIFT - 1;
> 
> but that's using the block shift not the block size.
> 
> Fix this to use the block size instead.
> 
> Fixes: 5c64737d2536 ("ceph: add truncate size handling support for fscrypt")
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Viacheslav Dubeyko <slava@dubeyko.com>
> cc: Alex Markuze <amarkuze@redhat.com>
> cc: Xiubo Li <xiubli@redhat.com>
> cc: Ilya Dryomov <idryomov@gmail.com>
> cc: ceph-devel@vger.kernel.org
> cc: linux-fsdevel@vger.kernel.org
> ---
>  fs/ceph/inode.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index ab63c7ebce5b..ec9b80fec7be 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2363,7 +2363,7 @@ static int fill_fscrypt_truncate(struct inode *inode,
>  
>  	/* Try to writeback the dirty pagecaches */
>  	if (issued & (CEPH_CAP_FILE_BUFFER)) {
> -		loff_t lend = orig_pos + CEPH_FSCRYPT_BLOCK_SHIFT - 1;
> +		loff_t lend = orig_pos + CEPH_FSCRYPT_BLOCK_SIZE - 1;
>  
>  		ret = filemap_write_and_wait_range(inode->i_mapping,
>  						   orig_pos, lend);
> 
> 

Looks good.

Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>

Do we know easy way to reproduce the issue?

Thanks,
Slava.


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

* Re: [PATCH] ceph: Fix incorrect flush end position calculation
  2025-03-12 10:47 [PATCH] ceph: Fix incorrect flush end position calculation David Howells
  2025-03-12 18:43 ` Viacheslav Dubeyko
@ 2025-03-13  8:25 ` David Howells
  2025-03-13  9:00 ` David Howells
  2 siblings, 0 replies; 5+ messages in thread
From: David Howells @ 2025-03-13  8:25 UTC (permalink / raw)
  To: Viacheslav Dubeyko
  Cc: dhowells, slava, ceph-devel, Alex Markuze, Xiubo Li, brauner,
	idryomov, linux-fsdevel, linux-kernel

Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> wrote:

> Do we know easy way to reproduce the issue?

I found it by inspection of the code.  Quite possibly the issue will never
arise in actuality because whilst the code only specifies a flush of at least
a few bytes of the tail page, it will be rounded up to the full page/eof.

David


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

* Re: [PATCH] ceph: Fix incorrect flush end position calculation
  2025-03-12 10:47 [PATCH] ceph: Fix incorrect flush end position calculation David Howells
  2025-03-12 18:43 ` Viacheslav Dubeyko
  2025-03-13  8:25 ` David Howells
@ 2025-03-13  9:00 ` David Howells
  2025-03-13 11:26   ` Alex Markuze
  2 siblings, 1 reply; 5+ messages in thread
From: David Howells @ 2025-03-13  9:00 UTC (permalink / raw)
  To: Viacheslav Dubeyko
  Cc: dhowells, slava, ceph-devel, Alex Markuze, Xiubo Li, brauner,
	idryomov, linux-fsdevel, linux-kernel

Shall I ask Christian to stick this in the vfs tree?  Or did you want to take
it through the ceph tree?

David


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

* Re: [PATCH] ceph: Fix incorrect flush end position calculation
  2025-03-13  9:00 ` David Howells
@ 2025-03-13 11:26   ` Alex Markuze
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Markuze @ 2025-03-13 11:26 UTC (permalink / raw)
  To: David Howells
  Cc: Viacheslav Dubeyko, slava, ceph-devel, Xiubo Li, brauner,
	idryomov, linux-fsdevel, linux-kernel

I'm sure @Ilya Dryomov will pick this up, this doesn't look urgent.

On Thu, Mar 13, 2025 at 11:00 AM David Howells <dhowells@redhat.com> wrote:
>
> Shall I ask Christian to stick this in the vfs tree?  Or did you want to take
> it through the ceph tree?
>
> David
>


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

end of thread, other threads:[~2025-03-13 11:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-12 10:47 [PATCH] ceph: Fix incorrect flush end position calculation David Howells
2025-03-12 18:43 ` Viacheslav Dubeyko
2025-03-13  8:25 ` David Howells
2025-03-13  9:00 ` David Howells
2025-03-13 11:26   ` Alex Markuze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®