diff mbox series

回覆: [PATCH v2 1/2] ceph: skip copying the data extends the file EOF

Message ID SEZPR04MB69729D8E7073F9C85D919A94B75A2@SEZPR04MB6972.apcprd04.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series 回覆: [PATCH v2 1/2] ceph: skip copying the data extends the file EOF | expand

Commit Message

Frank Hsiao 蕭法宣 Feb. 26, 2024, 3:45 a.m. UTC
Tested-by: Frank Hsiao 蕭法宣 <frankhsiao@qnap.com>
diff mbox series

Patch

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 71d29571712d..2b2b07a0a61b 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1195,7 +1195,7 @@  ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
                }

                idx = 0;
-               left = ret > 0 ? ret : 0;
+               left = ret > 0 ? umin(ret, i_size) : 0;
                while (left > 0) {
                        size_t plen, copied;

@@ -1224,15 +1224,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)