]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: fix timeout precision of f2fs_io_schedule_timeout_killable()
authorChao Yu <chao@kernel.org>
Sun, 4 Jan 2026 02:07:26 +0000 (10:07 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 7 Jan 2026 03:17:07 +0000 (03:17 +0000)
Sometimes, f2fs_io_schedule_timeout_killable(HZ) may delay for about 2
seconds, this is because __f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT)
may delay for about 2 * DEFAULT_SCHEDULE_TIMEOUT due to its precision, but
we only account the delay as DEFAULT_SCHEDULE_TIMEOUT as below, fix it.

f2fs_io_schedule_timeout_killable()
..
timeout -= DEFAULT_SCHEDULE_TIMEOUT;

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h

index a2b5439e7f08cecfd26af73e365e5f5984282878..95b7a8e3669cf16672291899ba347f93a8f9b811 100644 (file)
@@ -4985,13 +4985,12 @@ static inline void __f2fs_schedule_timeout(long timeout, bool io)
 
 static inline void f2fs_io_schedule_timeout_killable(long timeout)
 {
-       while (timeout) {
+       unsigned long last_time = jiffies + timeout;
+
+       while (jiffies < last_time) {
                if (fatal_signal_pending(current))
                        return;
                __f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT, true);
-               if (timeout <= DEFAULT_SCHEDULE_TIMEOUT)
-                       return;
-               timeout -= DEFAULT_SCHEDULE_TIMEOUT;
        }
 }