ceph: Fix incorrect flush end position calculation
Subsystems (2)
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.
--- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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);
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")Signed-off-by David Howells <[email protected]>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
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.
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
Shall I ask Christian to stick this in the vfs tree? Or did you want to take it through the ceph tree?
David
Alex Markuze
maintainerI'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