Commit afd48513 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David Sterba

btrfs: use monotonic time for transaction handling

The transaction times were changed to ktime_get_real_seconds to avoid
the y2038 overflow, but they still have a minor problem when they go
backwards or jump due to settimeofday() or leap seconds.

This changes the transaction handling to instead use ktime_get_seconds(),
which returns a CLOCK_MONOTONIC timestamp that has neither of those
problems.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent e41ca589
...@@ -1805,7 +1805,7 @@ static int transaction_kthread(void *arg) ...@@ -1805,7 +1805,7 @@ static int transaction_kthread(void *arg)
goto sleep; goto sleep;
} }
now = ktime_get_real_seconds(); now = ktime_get_seconds();
if (cur->state < TRANS_STATE_BLOCKED && if (cur->state < TRANS_STATE_BLOCKED &&
!test_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags) && !test_bit(BTRFS_FS_NEED_ASYNC_COMMIT, &fs_info->flags) &&
(now < cur->start_time || (now < cur->start_time ||
......
...@@ -241,7 +241,7 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info, ...@@ -241,7 +241,7 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info,
refcount_set(&cur_trans->use_count, 2); refcount_set(&cur_trans->use_count, 2);
atomic_set(&cur_trans->pending_ordered, 0); atomic_set(&cur_trans->pending_ordered, 0);
cur_trans->flags = 0; cur_trans->flags = 0;
cur_trans->start_time = ktime_get_real_seconds(); cur_trans->start_time = ktime_get_seconds();
memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs)); memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs));
......
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