From patchwork Fri Nov 4 07:26:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 9412015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8D9AB60585 for ; Fri, 4 Nov 2016 07:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E2A82AED9 for ; Fri, 4 Nov 2016 07:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 728F62AF0A; Fri, 4 Nov 2016 07:27:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C09352AED9 for ; Fri, 4 Nov 2016 07:27:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754256AbcKDH1N (ORCPT ); Fri, 4 Nov 2016 03:27:13 -0400 Received: from tartarus.angband.pl ([89.206.35.136]:53087 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752433AbcKDH1N (ORCPT ); Fri, 4 Nov 2016 03:27:13 -0400 Received: from umbar.angband.pl ([2001:6a0:118::6]) by tartarus.angband.pl with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1c2Yts-0000qF-QL; Fri, 04 Nov 2016 08:26:59 +0100 Received: from kilobyte by umbar.angband.pl with local (Exim 4.87) (envelope-from ) id 1c2Yts-0003V3-DO; Fri, 04 Nov 2016 08:26:56 +0100 From: Adam Borowski To: Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Cc: Adam Borowski Date: Fri, 4 Nov 2016 08:26:54 +0100 Message-Id: <20161104072654.13411-1-kilobyte@angband.pl> X-Mailer: git-send-email 2.10.2 X-SA-Exim-Connect-IP: 2001:6a0:118::6 X-SA-Exim-Mail-From: kilobyte@angband.pl Subject: [PATCH] btrfs: make block group flags in balance printks human-readable X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on tartarus.angband.pl) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Holger Hoffstätte --- fs/btrfs/relocation.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 0ec8ffa..388216f 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4326,6 +4326,34 @@ static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info) } /* + * explain bit flags, prefixed by a '|' that'll be dropped + */ +static void describe_block_group_flags(char *buf, u64 flags) +{ + if (!flags) + *buf += sprintf(buf, "|NONE"); + else { +#define DESCRIBE_FLAG(f, d) \ + if (flags & BTRFS_BLOCK_GROUP_##f) { \ + buf += sprintf(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 (flags) + buf += sprintf(buf, "|0x%llx", flags); + } + *buf = 0; +} + +/* * function to relocate all extents in a block group. */ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) @@ -4337,6 +4365,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) int ret; int rw = 0; int err = 0; + char flags_str[128]; rc = alloc_reloc_control(fs_info); if (!rc) @@ -4381,9 +4410,10 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) goto out; } + describe_block_group_flags(flags_str, rc->block_group->flags); btrfs_info(extent_root->fs_info, - "relocating block group %llu flags %llu", - rc->block_group->key.objectid, rc->block_group->flags); + "relocating block group %llu flags %s", + rc->block_group->key.objectid, flags_str+1); btrfs_wait_block_group_reservations(rc->block_group); btrfs_wait_nocow_writers(rc->block_group);