Commit e450f4d1 authored by zhengbin's avatar zhengbin Committed by Ilya Dryomov

ceph: pass inclusive lend parameter to filemap_write_and_wait_range()

The 'lend' parameter of filemap_write_and_wait_range is required to be
inclusive, so follow the rule. Same for invalidate_inode_pages2_range.
Signed-off-by: default avatarzhengbin <zhengbin13@huawei.com>
Reviewed-by: default avatar"Yan, Zheng" <zyan@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 0c93e1b7
...@@ -590,7 +590,8 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to, ...@@ -590,7 +590,8 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
* but it will at least behave sensibly when they are * but it will at least behave sensibly when they are
* in sequence. * in sequence.
*/ */
ret = filemap_write_and_wait_range(inode->i_mapping, off, off + len); ret = filemap_write_and_wait_range(inode->i_mapping,
off, off + len - 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -929,14 +930,15 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter, ...@@ -929,14 +930,15 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
(write ? "write" : "read"), file, pos, (unsigned)count, (write ? "write" : "read"), file, pos, (unsigned)count,
snapc, snapc->seq); snapc, snapc->seq);
ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + count); ret = filemap_write_and_wait_range(inode->i_mapping,
pos, pos + count - 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (write) { if (write) {
int ret2 = invalidate_inode_pages2_range(inode->i_mapping, int ret2 = invalidate_inode_pages2_range(inode->i_mapping,
pos >> PAGE_SHIFT, pos >> PAGE_SHIFT,
(pos + count) >> PAGE_SHIFT); (pos + count - 1) >> PAGE_SHIFT);
if (ret2 < 0) if (ret2 < 0)
dout("invalidate_inode_pages2_range returned %d\n", ret2); dout("invalidate_inode_pages2_range returned %d\n", ret2);
...@@ -1132,13 +1134,14 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos, ...@@ -1132,13 +1134,14 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
dout("sync_write on file %p %lld~%u snapc %p seq %lld\n", dout("sync_write on file %p %lld~%u snapc %p seq %lld\n",
file, pos, (unsigned)count, snapc, snapc->seq); file, pos, (unsigned)count, snapc, snapc->seq);
ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + count); ret = filemap_write_and_wait_range(inode->i_mapping,
pos, pos + count - 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = invalidate_inode_pages2_range(inode->i_mapping, ret = invalidate_inode_pages2_range(inode->i_mapping,
pos >> PAGE_SHIFT, pos >> PAGE_SHIFT,
(pos + count) >> PAGE_SHIFT); (pos + count - 1) >> PAGE_SHIFT);
if (ret < 0) if (ret < 0)
dout("invalidate_inode_pages2_range returned %d\n", ret); dout("invalidate_inode_pages2_range returned %d\n", ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment