Skip to content

Commit d31d07b

Browse files
Luis Henriquesidryomov
authored andcommitted
ceph: fix end offset in truncate_inode_pages_range call
Commit e450f4d ("ceph: pass inclusive lend parameter to filemap_write_and_wait_range()") fixed the end offset parameter used to call filemap_write_and_wait_range and invalidate_inode_pages2_range. Unfortunately it missed truncate_inode_pages_range, introducing a regression that is easily detected by xfstest generic/130. The problem is that when doing direct IO it is possible that an extra page is truncated from the page cache when the end offset is page aligned. This can cause data loss if that page hasn't been sync'ed to the OSDs. While there, change code to use PAGE_ALIGN macro instead. Cc: [email protected] Fixes: e450f4d ("ceph: pass inclusive lend parameter to filemap_write_and_wait_range()") Signed-off-by: Luis Henriques <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 52dd0f1 commit d31d07b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ceph/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
10111011
* may block.
10121012
*/
10131013
truncate_inode_pages_range(inode->i_mapping, pos,
1014-
(pos+len) | (PAGE_SIZE - 1));
1014+
PAGE_ALIGN(pos + len) - 1);
10151015

10161016
req->r_mtime = mtime;
10171017
}

0 commit comments

Comments
 (0)