aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorIoannis Angelakopoulos <iangelak@fb.com>2022-06-14 15:22:32 -0700
committerDavid Sterba <dsterba@suse.com>2022-07-25 17:45:37 +0200
commite55958c8a0e4d12a5f1bc9942c52dd793dd2e8dd (patch)
treed75a9f1023629ed1337c3bdf45d2a38118c5302d /fs/btrfs/ctree.h
parentbtrfs: remove extent writepage address space operation (diff)
downloadwireguard-linux-e55958c8a0e4d12a5f1bc9942c52dd793dd2e8dd.tar.xz
wireguard-linux-e55958c8a0e4d12a5f1bc9942c52dd793dd2e8dd.zip
btrfs: collect commit stats, count, duration
Track several stats about transaction commit, to be later exported via sysfs: - number of commits so far - duration of the last commit in ns - maximum commit duration seen so far in ns - total duration for all commits so far in ns The update of the commit stats occurs after the commit thread has gone through all the logic that checks if there is another thread committing at the same time. This means that we only account for actual commit work in the commit stats we report and not the time the thread spends waiting until it is ready to do the commit work. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Ioannis Angelakopoulos <iangelak@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 6d9f81d4e99c..64c65d0f7d06 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -667,6 +667,18 @@ enum btrfs_exclusive_operation {
BTRFS_EXCLOP_SWAP_ACTIVATE,
};
+/* Store data about transaction commits, exported via sysfs. */
+struct btrfs_commit_stats {
+ /* Total number of commits */
+ u64 commit_count;
+ /* The maximum commit duration so far in ns */
+ u64 max_commit_dur;
+ /* The last commit duration in ns */
+ u64 last_commit_dur;
+ /* The total commit duration in ns */
+ u64 total_commit_dur;
+};
+
struct btrfs_fs_info {
u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
unsigned long flags;
@@ -1075,6 +1087,9 @@ struct btrfs_fs_info {
spinlock_t zone_active_bgs_lock;
struct list_head zone_active_bgs;
+ /* Updates are not protected by any lock */
+ struct btrfs_commit_stats commit_stats;
+
#ifdef CONFIG_BTRFS_FS_REF_VERIFY
spinlock_t ref_verify_lock;
struct rb_root block_tree;