diff options
author | Dennis Zhou <dennis@kernel.org> | 2020-01-02 22:26:40 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-01-20 16:41:00 +0100 |
commit | 5cb0724e1b4653629c508906ca6098bae77d2f95 (patch) | |
tree | 455bdaaea5d27255726977fd7d8beefc8897d0db /fs/btrfs/discard.c | |
parent | btrfs: have multiple discard lists (diff) | |
download | linux-5cb0724e1b4653629c508906ca6098bae77d2f95.tar.xz linux-5cb0724e1b4653629c508906ca6098bae77d2f95.zip |
btrfs: only keep track of data extents for async discard
As mentioned earlier, discarding data can be done either by issuing an
explicit discard or implicitly by reusing the LBA. Metadata block_groups
see much more frequent reuse due to well it being metadata. So instead
of explicitly discarding metadata block_groups, just leave them be and
let the latter implicit discarding be done for them.
For mixed block_groups, block_groups which contain both metadata and
data, we let them be as higher fragmentation is expected.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/discard.c')
-rw-r--r-- | fs/btrfs/discard.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/btrfs/discard.c b/fs/btrfs/discard.c index 0299981d0c62..5af42e0317b7 100644 --- a/fs/btrfs/discard.c +++ b/fs/btrfs/discard.c @@ -57,6 +57,9 @@ static void __add_to_discard_list(struct btrfs_discard_ctl *discard_ctl, static void add_to_discard_list(struct btrfs_discard_ctl *discard_ctl, struct btrfs_block_group *block_group) { + if (!btrfs_is_block_group_data_only(block_group)) + return; + spin_lock(&discard_ctl->lock); __add_to_discard_list(discard_ctl, block_group); spin_unlock(&discard_ctl->lock); @@ -169,7 +172,10 @@ again: if (block_group && now > block_group->discard_eligible_time) { if (block_group->discard_index == BTRFS_DISCARD_INDEX_UNUSED && block_group->used != 0) { - __add_to_discard_list(discard_ctl, block_group); + if (btrfs_is_block_group_data_only(block_group)) + __add_to_discard_list(discard_ctl, block_group); + else + list_del_init(&block_group->discard_list); goto again; } if (block_group->discard_state == BTRFS_DISCARD_RESET_CURSOR) { @@ -507,7 +513,9 @@ void btrfs_discard_update_discardable(struct btrfs_block_group *block_group, s32 extents_delta; s64 bytes_delta; - if (!block_group || !btrfs_test_opt(block_group->fs_info, DISCARD_ASYNC)) + if (!block_group || + !btrfs_test_opt(block_group->fs_info, DISCARD_ASYNC) || + !btrfs_is_block_group_data_only(block_group)) return; discard_ctl = &block_group->fs_info->discard_ctl; |