]> git.hungrycats.org Git - linux/commitdiff
btrfs: relocation: Output current relocation stage at btrfs_relocate_block_group()
authorQu Wenruo <wqu@suse.com>
Fri, 29 Nov 2019 04:40:59 +0000 (12:40 +0800)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 9 Dec 2019 16:14:12 +0000 (11:14 -0500)
There are several reports of hanging relocation, populating the dmesg
with things like:
  BTRFS info (device dm-5): found 1 extents

The investigation is still on going, but will never hurt to output a
little more info.

This patch will also output the current relocation stage, making that
output something like:

  BTRFS info (device dm-5): balance: start -d -m -s
  BTRFS info (device dm-5): relocating block group 30408704 flags metadata|dup
  BTRFS info (device dm-5): found 2 extents, stage: move data extents
  BTRFS info (device dm-5): relocating block group 22020096 flags system|dup
  BTRFS info (device dm-5): found 1 extents, stage: move data extents
  BTRFS info (device dm-5): relocating block group 13631488 flags data
  BTRFS info (device dm-5): found 1 extents, stage: move data extents
  BTRFS info (device dm-5): found 1 extents, stage: update data pointers
  BTRFS info (device dm-5): balance: ended with status: 0

This patch will not increase the number of lines, but with extra info
for us to debug the reported problem.
(Although it's very likely the bug is sticking at "update data pointers"
stage, even without the patch)

Signed-off-by: Qu Wenruo <wqu@suse.com>
(cherry picked from commit b04bb3a0ee5916885cb989f904d0168ac181e649)
(cherry picked from commit e798a685ada7aecb72c54a3b94a08853aa2be8cb)
(cherry picked from commit 34374b860dfd86ead6cf12062b83ba431abaddd5)
(cherry picked from commit eb8b21df208d8f2f69123a341e371b2ec4897182)

fs/btrfs/relocation.c

index 0395b8233c905d214db3f538ad25fa1e6911f409..f3faa9fc1078ca8583aaf180a4d2b1c6ff3c9381 100644 (file)
@@ -4194,6 +4194,15 @@ static void describe_relocation(struct btrfs_fs_info *fs_info,
                   block_group->key.objectid, buf);
 }
 
+static const char *stage_to_string(int stage)
+{
+       if (stage == MOVE_DATA_EXTENTS)
+               return "move data extents";
+       if (stage == UPDATE_DATA_PTRS)
+       return "update data pointers";
+       return "unknown";
+}
+
 /*
  * function to relocate all extents in a block group.
  */
@@ -4268,6 +4277,8 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
                                 rc->block_group->key.offset);
 
        while (1) {
+               int finishes_stage;
+
                mutex_lock(&fs_info->cleaner_mutex);
                ret = relocate_block_group(rc);
                mutex_unlock(&fs_info->cleaner_mutex);
@@ -4283,6 +4294,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
                 * properly so we don't trip over this problem, and then break
                 * out of the loop if we hit an error.
                 */
+               finishes_stage = rc->stage;
                if (rc->stage == MOVE_DATA_EXTENTS && rc->found_file_extent) {
                        ret = btrfs_wait_ordered_range(rc->data_inode, 0,
                                                       (u64)-1);
@@ -4299,8 +4311,8 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
                if (rc->extents_found == 0)
                        break;
 
-               btrfs_info(fs_info, "found %llu extents", rc->extents_found);
-
+               btrfs_info(fs_info, "found %llu extents, stage: %s",
+                          rc->extents_found, stage_to_string(finishes_stage));
        }
 
        WARN_ON(rc->block_group->pinned > 0);