diff options
author | Dennis Zhou <dennis@kernel.org> | 2019-12-13 16:22:21 -0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-01-20 16:40:59 +0100 |
commit | 5dc7c10b87474c98116d3438739743cd77263e9f (patch) | |
tree | 3636b859f5228c8df8d777b2b5a4ec9559510978 /fs/btrfs/discard.c | |
parent | dfb79ddb130e0a239e3e90aaf5f5b908555f52bb (diff) |
btrfs: keep track of discardable_bytes for async discard
Keep track of this metric so that we can understand how ahead or behind
we are in discarding rate. This uses the same accounting method as
discardable_extents, deltas between previous/current values and
propagating them up.
Signed-off-by: Dennis Zhou <dennis@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/discard.c')
-rw-r--r-- | fs/btrfs/discard.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/discard.c b/fs/btrfs/discard.c index 99663641abf4..62298a438fa5 100644 --- a/fs/btrfs/discard.c +++ b/fs/btrfs/discard.c @@ -356,6 +356,7 @@ void btrfs_discard_update_discardable(struct btrfs_block_group *block_group, { struct btrfs_discard_ctl *discard_ctl; s32 extents_delta; + s64 bytes_delta; if (!block_group || !btrfs_test_opt(block_group->fs_info, DISCARD_ASYNC)) return; @@ -369,6 +370,14 @@ void btrfs_discard_update_discardable(struct btrfs_block_group *block_group, ctl->discardable_extents[BTRFS_STAT_PREV] = ctl->discardable_extents[BTRFS_STAT_CURR]; } + + bytes_delta = ctl->discardable_bytes[BTRFS_STAT_CURR] - + ctl->discardable_bytes[BTRFS_STAT_PREV]; + if (bytes_delta) { + atomic64_add(bytes_delta, &discard_ctl->discardable_bytes); + ctl->discardable_bytes[BTRFS_STAT_PREV] = + ctl->discardable_bytes[BTRFS_STAT_CURR]; + } } /** @@ -454,6 +463,7 @@ void btrfs_discard_init(struct btrfs_fs_info *fs_info) INIT_LIST_HEAD(&discard_ctl->discard_list[i]); atomic_set(&discard_ctl->discardable_extents, 0); + atomic64_set(&discard_ctl->discardable_bytes, 0); } void btrfs_discard_cleanup(struct btrfs_fs_info *fs_info) |