summaryrefslogtreecommitdiff
path: root/fs/bcachefs/time_stats.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-08-19 15:33:38 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-09-09 09:41:49 -0400
commitfdbc9c390ade238383f5a24e4b32e49550dc90e4 (patch)
treea6a9d97fa3fc8826cde5ed5611b3e1ea7ba06e4f /fs/bcachefs/time_stats.c
parentb36f679c99889bbe9c48e09f7c175d1058823ae8 (diff)
bcachefs: bch2_time_stats_reset()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/time_stats.c')
-rw-r--r--fs/bcachefs/time_stats.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/bcachefs/time_stats.c b/fs/bcachefs/time_stats.c
index 4508e9dcbee2..3fe82757f93a 100644
--- a/fs/bcachefs/time_stats.c
+++ b/fs/bcachefs/time_stats.c
@@ -151,6 +151,20 @@ void __bch2_time_stats_update(struct bch2_time_stats *stats, u64 start, u64 end)
}
}
+void bch2_time_stats_reset(struct bch2_time_stats *stats)
+{
+ spin_lock_irq(&stats->lock);
+ unsigned offset = offsetof(struct bch2_time_stats, min_duration);
+ memset((void *) stats + offset, 0, sizeof(*stats) - offset);
+
+ if (stats->buffer) {
+ int cpu;
+ for_each_possible_cpu(cpu)
+ per_cpu_ptr(stats->buffer, cpu)->nr = 0;
+ }
+ spin_unlock_irq(&stats->lock);
+}
+
void bch2_time_stats_exit(struct bch2_time_stats *stats)
{
free_percpu(stats->buffer);