diff options
author | Jeff Mahoney <jeffm@suse.com> | 2015-06-15 09:41:19 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-07-29 11:15:29 -0400 |
commit | e33e17ee1098d8d751552ac11c111e1c1a3db014 (patch) | |
tree | 49b4c9b5c4123db86d9256a5b9122da73275d730 /fs/btrfs/transaction.c | |
parent | e44163e177960ee60e32a73bffdd53c3a5827406 (diff) |
btrfs: add missing discards when unpinning extents with -o discard
When we clear the dirty bits in btrfs_delete_unused_bgs for extents
in the empty block group, it results in btrfs_finish_extent_commit being
unable to discard the freed extents.
The block group removal patch added an alternate path to forget extents
other than btrfs_finish_extent_commit. As a result, any extents that
would be freed when the block group is removed aren't discarded. In my
test run, with a large copy of mixed sized files followed by removal, it
left nearly 2/3 of extents undiscarded.
To clean up the block groups, we add the removed block group onto a list
that will be discarded after transaction commit.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Tested-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r-- | fs/btrfs/transaction.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index f5021fcb154e..44da9299a25b 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -258,6 +258,8 @@ loop: | |||
258 | mutex_init(&cur_trans->cache_write_mutex); | 258 | mutex_init(&cur_trans->cache_write_mutex); |
259 | cur_trans->num_dirty_bgs = 0; | 259 | cur_trans->num_dirty_bgs = 0; |
260 | spin_lock_init(&cur_trans->dirty_bgs_lock); | 260 | spin_lock_init(&cur_trans->dirty_bgs_lock); |
261 | INIT_LIST_HEAD(&cur_trans->deleted_bgs); | ||
262 | spin_lock_init(&cur_trans->deleted_bgs_lock); | ||
261 | list_add_tail(&cur_trans->list, &fs_info->trans_list); | 263 | list_add_tail(&cur_trans->list, &fs_info->trans_list); |
262 | extent_io_tree_init(&cur_trans->dirty_pages, | 264 | extent_io_tree_init(&cur_trans->dirty_pages, |
263 | fs_info->btree_inode->i_mapping); | 265 | fs_info->btree_inode->i_mapping); |