From: Adam Borowski <kilobyte@angband.pl>
To: "Holger Hoffstätte" <holger@applied-asynchrony.com>,
"David Sterba" <dsterba@suse.cz>,
linux-btrfs@vger.kernel.org
Cc: Adam Borowski <kilobyte@angband.pl>
Subject: [PATCH v3-onstack] btrfs: make block group flags in balance printks human-readable
Date: Sat, 12 Nov 2016 00:59:59 +0100 [thread overview]
Message-ID: <20161111235959.8102-1-kilobyte@angband.pl> (raw)
In-Reply-To: <5821D634.4070204@applied-asynchrony.com>
They're not even documented anywhere, letting users with no recourse but
to RTFS. It's no big burden to output the bitfield as words.
Also, display unknown flags as hex.
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
---
fs/btrfs/relocation.c | 41 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 38 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index c4af0cd..57d867d 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4333,6 +4333,43 @@ static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)
}
/*
+ * printk the block group being relocated
+ */
+static void describe_relocation(struct btrfs_fs_info *fs_info,
+ struct btrfs_block_group_cache *block_group)
+{
+ char buf[128]; // prefixed by a '|' that'll be dropped
+ u64 flags = block_group->flags;
+
+ if (unlikely(!flags)) // shouldn't happen
+ strcpy(buf, "|NONE");
+ else {
+ char *bp = buf;
+#define DESCRIBE_FLAG(f, d) \
+ if (flags & BTRFS_BLOCK_GROUP_##f) { \
+ bp += snprintf(bp, buf - bp + sizeof(buf), "|%s", d); \
+ flags &= ~BTRFS_BLOCK_GROUP_##f; \
+ }
+ DESCRIBE_FLAG(DATA, "data");
+ DESCRIBE_FLAG(SYSTEM, "system");
+ DESCRIBE_FLAG(METADATA, "metadata");
+ DESCRIBE_FLAG(RAID0, "raid0");
+ DESCRIBE_FLAG(RAID1, "raid1");
+ DESCRIBE_FLAG(DUP, "dup");
+ DESCRIBE_FLAG(RAID10, "raid10");
+ DESCRIBE_FLAG(RAID5, "raid5");
+ DESCRIBE_FLAG(RAID6, "raid6");
+ if (unlikely(flags))
+ snprintf(buf, buf - bp + sizeof(buf), "|0x%llx", flags);
+#undef DESCRIBE_FLAG
+ }
+
+ btrfs_info(fs_info,
+ "relocating block group %llu flags %s",
+ block_group->key.objectid, buf+1);
+}
+
+/*
* function to relocate all extents in a block group.
*/
int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
@@ -4388,9 +4425,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
goto out;
}
- btrfs_info(extent_root->fs_info,
- "relocating block group %llu flags %llu",
- rc->block_group->key.objectid, rc->block_group->flags);
+ describe_relocation(extent_root->fs_info, rc->block_group);
btrfs_wait_block_group_reservations(rc->block_group);
btrfs_wait_nocow_writers(rc->block_group);
--
2.10.2
This is a version that uses a temp buffer on the stack, but does it in a
separate function so it doesn't cost us anything when deep call chains are
involved. While balance that can trigger deep call chain, it's not called
deeply itself.
This approach is simpler than mucking with allocs and avoids code
duplication that would be needed for handling failed alloc.
next prev parent reply other threads:[~2016-11-12 0:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-04 7:26 [PATCH] btrfs: make block group flags in balance printks human-readable Adam Borowski
2016-11-07 14:11 ` Holger Hoffstätte
2016-11-07 16:58 ` David Sterba
2016-11-07 21:38 ` Adam Borowski
2016-11-07 21:40 ` [PATCH v2] " Adam Borowski
2016-11-08 13:42 ` Holger Hoffstätte
2016-11-11 23:59 ` Adam Borowski [this message]
2016-11-14 16:37 ` [PATCH v3-onstack] " David Sterba
2016-11-14 17:44 ` [PATCH v4] " Adam Borowski
2016-11-14 18:24 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161111235959.8102-1-kilobyte@angband.pl \
--to=kilobyte@angband.pl \
--cc=dsterba@suse.cz \
--cc=holger@applied-asynchrony.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).