]> git.hungrycats.org Git - linux/commitdiff
btrfs: relocation: Check cancel request after each data page read
authorQu Wenruo <wqu@suse.com>
Tue, 3 Dec 2019 06:42:52 +0000 (14:42 +0800)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Dec 2019 03:18:36 +0000 (22:18 -0500)
When relocating a data extents with large large data extents, we spend
most of our time in relocate_file_extent_cluster() at stage "moving data
extents":
 1)               |  btrfs_relocate_block_group [btrfs]() {
 1)               |    relocate_file_extent_cluster [btrfs]() {
 1) $ 6586769 us  |    }
 1) + 18.260 us   |    relocate_file_extent_cluster [btrfs]();
 1) + 15.770 us   |    relocate_file_extent_cluster [btrfs]();
 1) $ 8916340 us  |  }
 1)               |  btrfs_relocate_block_group [btrfs]() {
 1)               |    relocate_file_extent_cluster [btrfs]() {
 1) $ 11611586 us |    }
 1) + 16.930 us   |    relocate_file_extent_cluster [btrfs]();
 1) + 15.870 us   |    relocate_file_extent_cluster [btrfs]();
 1) $ 14986130 us |  }

So to make data relocation cancelling quicker, here add extra balance
cancelling check after each page read in relocate_file_extent_cluster().

Signed-off-by: Qu Wenruo <wqu@suse.com>
(cherry picked from commit 34bb874930d1d6fecec7927101041884fe695aa7)

fs/btrfs/relocation.c

index d4887a1e43d3b14bedee957b1657502bdab73fff..8aede6eab5fd66505dd84536a284f34d273601c2 100644 (file)
@@ -3256,6 +3256,10 @@ static int relocate_file_extent_cluster(struct inode *inode,
                                               false);
                balance_dirty_pages_ratelimited(inode->i_mapping);
                btrfs_throttle(fs_info);
+               if (should_cancel_balance(fs_info)) {
+                       ret = -ECANCELED;
+                       goto out;
+               }
        }
        WARN_ON(nr != cluster->nr);
 out: