]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ceph: Fix incorrect flush end position calculation
authorDavid Howells <dhowells@redhat.com>
Wed, 12 Mar 2025 10:47:11 +0000 (10:47 +0000)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 3 Apr 2025 19:35:32 +0000 (21:35 +0200)
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>
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/inode.c

index 7dd6c2275085b9cd116683453d34aae9baf62045..e3ab07797c85087b12bac4c900579468fbd922b9 100644 (file)
@@ -2362,7 +2362,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);