diff mbox series

btrfs: cleanup ktime_t usage

Message ID 20250214102323.3882919-1-dmantipov@yandex.ru (mailing list archive)
State New
Headers show
Series btrfs: cleanup ktime_t usage | expand

Commit Message

Dmitry Antipov Feb. 14, 2025, 10:23 a.m. UTC
In 'update_commit_stats()' and 'btrfs_commit_transaction()', do
not assume that 'ktime_t' is a scalar type which may be implicitly
converted to (unsigned) 64-bit value but use 'ktime_sub()' and
'ktime_to_ns()' helpers where appropriate. Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 fs/btrfs/transaction.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index aca83a98b75a..452320ce3516 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2151,7 +2151,7 @@  static void add_pending_snapshot(struct btrfs_trans_handle *trans)
 	list_add(&trans->pending_snapshot->list, &cur_trans->pending_snapshots);
 }
 
-static void update_commit_stats(struct btrfs_fs_info *fs_info, ktime_t interval)
+static void update_commit_stats(struct btrfs_fs_info *fs_info, u64 interval)
 {
 	fs_info->commit_stats.commit_count++;
 	fs_info->commit_stats.last_commit_dur = interval;
@@ -2301,7 +2301,7 @@  int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
 	 * Get the time spent on the work done by the commit thread and not
 	 * the time spent waiting on a previous commit
 	 */
-	start_time = ktime_get_ns();
+	start_time = ktime_get();
 
 	extwriter_counter_dec(cur_trans, trans->type);
 
@@ -2568,7 +2568,7 @@  int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
 
 	trace_btrfs_transaction_commit(fs_info);
 
-	interval = ktime_get_ns() - start_time;
+	interval = ktime_sub(ktime_get(), start_time);
 
 	btrfs_scrub_continue(fs_info);
 
@@ -2577,7 +2577,7 @@  int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
 
 	kmem_cache_free(btrfs_trans_handle_cachep, trans);
 
-	update_commit_stats(fs_info, interval);
+	update_commit_stats(fs_info, ktime_to_ns(interval));
 
 	return ret;