Thanks Ilya for pointing this out. I've tested the new patch and it looks good. Reviewed-by: Frank Hsiao 蕭法宣 <frankhsiao@xxxxxxxx> Tested-by: Frank Hsiao 蕭法宣 <frankhsiao@xxxxxxxx> ________________________________________ 寄件者: xiubli@xxxxxxxxxx <xiubli@xxxxxxxxxx> 寄件日期: 2024年3月19日 上午 08:29 收件者: ceph-devel@xxxxxxxxxxxxxxx 副本: idryomov@xxxxxxxxx; jlayton@xxxxxxxxxx; vshankar@xxxxxxxxxx; mchangir@xxxxxxxxxx; Frank Hsiao 蕭法宣; Xiubo Li 主旨: [PATCH v3 1/2] ceph: skip copying the data extends the file EOF From: Xiubo Li <xiubli@xxxxxxxxxx> If hits the EOF it will revise the return value to the i_size instead of the real length read, but it will advance the offset of iovc, then for the next try it may be incorrectly skipped. This will just skip advancing the iovc's offset more than i_size. URL: https://patchwork.kernel.org/project/ceph-devel/list/?series=819323 Reported-by: Frank Hsiao 蕭法宣 <frankhsiao@xxxxxxxx> Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx> Tested-by: Frank Hsiao 蕭法宣 <frankhsiao@xxxxxxxx> --- fs/ceph/file.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 24a003eaa5e0..c35878427985 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1200,7 +1200,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; @@ -1229,15 +1234,13 @@ 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; - *ki_pos = i_size; - } else { - ret = off - *ki_pos; - *ki_pos = off; - } + if (off >= i_size) { + *retry_op = CHECK_EOF; + ret = i_size - *ki_pos; + *ki_pos = i_size; + } else { + ret = off - *ki_pos; + *ki_pos = off; } if (last_objver) -- 2.43.0