Btrfs: don't wait for unrelated IO to finish before relocation

Before the relocation process of a block group starts, it sets the block
group to readonly mode, then flushes all delalloc writes and then finally
it waits for all ordered extents to complete. This last step includes
waiting for ordered extents destinated at extents allocated in other block
groups, making us waste unecessary time.

So improve this by waiting only for ordered extents that fall into the
block group's range.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
This commit is contained in:
Filipe Manana
2016-04-26 15:36:38 +01:00
parent 3f9749f6e9
commit 578def7c50
8 changed files with 38 additions and 19 deletions

View File

@@ -4141,7 +4141,7 @@ commit_trans:
if (need_commit > 0) {
btrfs_start_delalloc_roots(fs_info, 0, -1);
btrfs_wait_ordered_roots(fs_info, -1);
btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1);
}
trans = btrfs_join_transaction(root);
@@ -4583,7 +4583,8 @@ static void btrfs_writeback_inodes_sb_nr(struct btrfs_root *root,
*/
btrfs_start_delalloc_roots(root->fs_info, 0, nr_items);
if (!current->journal_info)
btrfs_wait_ordered_roots(root->fs_info, nr_items);
btrfs_wait_ordered_roots(root->fs_info, nr_items,
0, (u64)-1);
}
}
@@ -4632,7 +4633,8 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig,
if (trans)
return;
if (wait_ordered)
btrfs_wait_ordered_roots(root->fs_info, items);
btrfs_wait_ordered_roots(root->fs_info, items,
0, (u64)-1);
return;
}
@@ -4671,7 +4673,8 @@ skip_async:
loops++;
if (wait_ordered && !trans) {
btrfs_wait_ordered_roots(root->fs_info, items);
btrfs_wait_ordered_roots(root->fs_info, items,
0, (u64)-1);
} else {
time_left = schedule_timeout_killable(1);
if (time_left)