Commit 1065da21 authored by Xiubo Li's avatar Xiubo Li Committed by Ilya Dryomov

ceph: stop copying to iter at EOF on sync reads

If EOF is encountered, ceph_sync_read() return value is adjusted down
according to i_size, but the "to" iter is advanced by the actual number
of bytes read.  Then, when retrying, the remainder of the range may be
skipped incorrectly.

Ensure that the "to" iter is advanced only until EOF.

[ idryomov: changelog ]

Fixes: c3d8e0b5 ("ceph: return the real size read when it hits EOF")
Reported-by: default avatarFrank Hsiao <frankhsiao@qnap.com>
Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
Tested-by: default avatarFrank Hsiao <frankhsiao@qnap.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent a8922f79
......@@ -1138,7 +1138,12 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
}
idx = 0;
left = ret > 0 ? ret : 0;
if (ret <= 0)
left = 0;
else if (off + ret > i_size)
left = i_size - off;
else
left = ret;
while (left > 0) {
size_t plen, copied;
......@@ -1167,7 +1172,6 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
}
if (ret > 0) {
if (off > *ki_pos) {
if (off >= i_size) {
*retry_op = CHECK_EOF;
ret = i_size - *ki_pos;
......@@ -1176,7 +1180,6 @@ ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
ret = off - *ki_pos;
*ki_pos = off;
}
}
if (last_objver)
*last_objver = objver;
......
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