From: Nikolay Borisov Date: Tue, 20 Oct 2020 09:44:17 +0000 (+0300) Subject: btrfs: calculate more accurate remaining time to sleep in transaction_kthread X-Git-Tag: accepted/tizen/unified/20230118.172025~7911^2~221 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb8a7e941b1b4c1c2fa79b305d4c3fc41ad9bbda;p=platform%2Fkernel%2Flinux-rpi.git btrfs: calculate more accurate remaining time to sleep in transaction_kthread If transaction_kthread is woken up before btrfs_fs_info::commit_interval seconds have elapsed it will sleep for a fixed period of 5 seconds. This is not a problem per-se but is not accurate. Instead the code should sleep for an interval which guarantees on next wakeup commit_interval would have passed. Since time tracking is not precise subtract 1 second from delta to ensure the delay we end up waiting will be longer than than the wake up period. Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 813d1d5..e3caf18 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1794,7 +1794,9 @@ static int transaction_kthread(void *arg) if (cur->state < TRANS_STATE_COMMIT_START && delta < fs_info->commit_interval) { spin_unlock(&fs_info->trans_lock); - delay = msecs_to_jiffies(5000); + delay -= msecs_to_jiffies((delta - 1) * 1000); + delay = min(delay, + msecs_to_jiffies(fs_info->commit_interval * 1000)); goto sleep; } transid = cur->transid;