summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2018-11-09 05:43:08 -0500
committerDavid Sterba <dsterba@suse.com>2018-12-17 08:51:31 -0500
commit59b0713a8a6c0f72ab468507dcd6b866869b900a (patch)
tree820947c4c6f93f6261100f75d02bf9a7cf1bbd01 /fs/btrfs/tree-log.c
parent46cc775e29c55d6ae9f4dbb733ec066ff56d3922 (diff)
Btrfs: simpler and more efficient cleanup of a log tree's extent io tree
We currently are in a loop finding each range (corresponding to a btree node/leaf) in a log root's extent io tree and then clean it up. This is a waste of time since we are traversing the extent io tree's rb_tree more times then needed (one for a range lookup and another for cleaning it up) without any good reason. We free the log trees when we are in the critical section of a transaction commit (the transaction state is set to TRANS_STATE_COMMIT_DOING), so it's of great convenience to do everything as fast as possible in order to reduce the time we block other tasks from starting a new transaction. So fix this by traversing the extent io tree once and cleaning up all its records in one go while traversing it. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index aa4bc4845ef0..013d0abcd46b 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3201,8 +3201,6 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
3201 struct btrfs_root *log) 3201 struct btrfs_root *log)
3202{ 3202{
3203 int ret; 3203 int ret;
3204 u64 start;
3205 u64 end;
3206 struct walk_control wc = { 3204 struct walk_control wc = {
3207 .free = 1, 3205 .free = 1,
3208 .process_func = process_one_buffer 3206 .process_func = process_one_buffer
@@ -3216,18 +3214,8 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
3216 btrfs_handle_fs_error(log->fs_info, ret, NULL); 3214 btrfs_handle_fs_error(log->fs_info, ret, NULL);
3217 } 3215 }
3218 3216
3219 while (1) { 3217 clear_extent_bits(&log->dirty_log_pages, 0, (u64)-1,
3220 ret = find_first_extent_bit(&log->dirty_log_pages, 3218 EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT);
3221 0, &start, &end,
3222 EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT,
3223 NULL);
3224 if (ret)
3225 break;
3226
3227 clear_extent_bits(&log->dirty_log_pages, start, end,
3228 EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT);
3229 }
3230
3231 free_extent_buffer(log->node); 3219 free_extent_buffer(log->node);
3232 kfree(log); 3220 kfree(log);
3233} 3221}