From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: Re: [PATCH v2 1/4] btrfs: output human readable space info flag
Date: Tue, 19 Jul 2022 16:38:33 -0400 [thread overview]
Message-ID: <c88649d5-dc14-6278-26fa-1821a8caed50@dorminy.me> (raw)
In-Reply-To: <79cbc7064028a2f214a60abbb702f0d174b630a5.1658207325.git.wqu@suse.com>
On 7/19/22 01:11, Qu Wenruo wrote:
> For btrfs_space_info, its flags has only 4 possible values:
> - BTRFS_BLOCK_GROUP_SYSTEM
> - BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA
> - BTRFS_BLOCK_GROUP_METADATA
> - BTRFS_BLOCK_GROUP_DATA
>
> Thus do debuggers a favor by output a human readable flags in
> __btrfs_dump_space_info().
>
> Now the summary line of __btrfs_dump_space_info() looks like:
>
> BTRFS info (device dm-1: state A): space_info META has 251494400 free, is not full
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/btrfs/space-info.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index 62d25112310d..36b466525318 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -450,14 +450,29 @@ do { \
> spin_unlock(&__rsv->lock); \
> } while (0)
>
> +static const char *space_info_flag_to_str(struct btrfs_space_info *space_info)
> +{
> + if (space_info->flags == BTRFS_BLOCK_GROUP_SYSTEM)
> + return "SYS";
> +
> + /* Handle mixed data+metadata first. */
> + if (space_info->flags == (BTRFS_BLOCK_GROUP_METADATA |
> + BTRFS_BLOCK_GROUP_DATA))
> + return "DATA+META";
> + if (space_info->flags == BTRFS_BLOCK_GROUP_DATA)
> + return "DATA";
> + return "META";
> +}
I think this would be more elegant as a switch statement; and would
prefer the default to be "UNKNOWN" just in case there were a flag
bitflip. +
> static void __btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
> struct btrfs_space_info *info)
> {
> + const char *flag_str = space_info_flag_to_str(info);
> lockdep_assert_held(&info->lock);
>
> /* The free space could be negative in case of overcommit */
> - btrfs_info(fs_info, "space_info %llu has %lld free, is %sfull",
> - info->flags,
> + btrfs_info(fs_info, "space_info %s has %lld free, is %sfull",
> + flag_str,
> (s64)(info->total_bytes - btrfs_space_info_used(info, true)),
> info->full ? "" : "not ");
> btrfs_info(fs_info,
next prev parent reply other threads:[~2022-07-19 20:38 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 5:11 [PATCH v2 0/4] btrfs: output more info for -ENOSPC caused transaction abort and other enhancement Qu Wenruo
2022-07-19 5:11 ` [PATCH v2 1/4] btrfs: output human readable space info flag Qu Wenruo
2022-07-19 20:38 ` Sweet Tea Dorminy [this message]
2022-07-19 5:11 ` [PATCH v2 2/4] btrfs: make __btrfs_dump_space_info() output better formatted Qu Wenruo
2022-07-19 20:56 ` Sweet Tea Dorminy
2022-07-19 21:38 ` David Sterba
2022-07-19 22:58 ` Qu Wenruo
2022-07-26 18:13 ` David Sterba
2022-07-26 20:53 ` Boris Burkov
2022-07-26 21:39 ` David Sterba
2022-07-26 23:21 ` Boris Burkov
2022-07-27 1:21 ` Sweet Tea Dorminy
2022-07-27 1:44 ` Qu Wenruo
2022-07-27 15:09 ` Sweet Tea Dorminy
2022-07-19 5:11 ` [PATCH v2 3/4] btrfs: make DUMP_BLOCK_RSV() to have better output Qu Wenruo
2022-07-19 5:11 ` [PATCH v2 4/4] btrfs: dump all space infos if we abort transaction due to ENOSPC Qu Wenruo
2022-07-20 0:42 ` Sweet Tea Dorminy
2022-07-20 1:03 ` Qu Wenruo
2022-07-20 1:43 ` Sweet Tea Dorminy
2022-07-20 1:57 ` Qu Wenruo
2022-07-26 18:20 ` David Sterba
2022-07-26 18:38 ` Sweet Tea Dorminy
2022-08-24 15:53 ` [PATCH v2 0/4] btrfs: output more info for -ENOSPC caused transaction abort and other enhancement David Sterba
2022-08-25 3:04 ` Qu Wenruo
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=c88649d5-dc14-6278-26fa-1821a8caed50@dorminy.me \
--to=sweettea-kernel@dorminy.me \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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).