Skip to contentSkip to conversation

ceph: Fix incorrect flush end position calculation

PATCH In review David Howells 3 participants 5 messages Mar 12, 2025 – Mar 13, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: Fix incorrect flush end position calculation

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")
cc Viacheslav Dubeyko <[email protected]>
cc Alex Markuze <[email protected]>
cc Xiubo Li <[email protected]>
cc Ilya Dryomov <[email protected]>
---
 fs/ceph/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/inode.c +1 -1
index ab63c7ebce5b..ec9b80fec7be 100644
@@ -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);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · David Howells

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")
cc Viacheslav Dubeyko <[email protected]>
cc Alex Markuze <[email protected]>
cc Xiubo Li <[email protected]>
cc Ilya Dryomov <[email protected]>
---
 fs/ceph/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/inode.c +0 -0
index ab63c7ebce5b..ec9b80fec7be 100644

fs/ceph/inode.c static int fill_fscrypt_truncate(struct inode *inode, · line 2369

Quoted 8 lines
fs/ceph/inode.c +1 -1
@@ -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.

Do we know easy way to reproduce the issue?

Thanks,
Slava.

#2 lore raw
Quoted 1 line · Viacheslav Dubeyko

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

maintainer
#4 lore raw

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

Quoted 6 lines · David Howells

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

David