Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] btrfs-progs: print-tree: handle all supported flags
Date: Sat, 8 Jun 2024 14:37:56 +0930	[thread overview]
Message-ID: <4af5f2ab-8c9d-4303-b663-840d2dbb31eb@suse.com> (raw)
In-Reply-To: <9a1201c209c72e332ab9d25f5036edc847547550.1717819918.git.wqu@suse.com>



在 2024/6/8 13:43, Qu Wenruo 写道:
> Although we already have a pretty good array defined for all
> super/compat_ro/incompat flags, we still rely on hand defined mask to do
> the print.
> 
> This can lead to easy de-sync between the definition and the flags.
> 
> Change it to automatically iterate through the array to calculate the
> flags, and add the remaining super flags.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>   kernel-shared/print-tree.c | 35 +++++++++++++++++++----------------
>   1 file changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
> index a7018cb724fd..23cd225a9a50 100644
> --- a/kernel-shared/print-tree.c
> +++ b/kernel-shared/print-tree.c
> @@ -1950,18 +1950,13 @@ static struct readable_flag_entry super_flags_array[] = {
>   	DEF_SUPER_FLAG_ENTRY(CHANGING_FSID_V2),
>   	DEF_SUPER_FLAG_ENTRY(SEEDING),
>   	DEF_SUPER_FLAG_ENTRY(METADUMP),
> -	DEF_SUPER_FLAG_ENTRY(METADUMP_V2)
> +	DEF_SUPER_FLAG_ENTRY(METADUMP_V2),
> +	DEF_SUPER_FLAG_ENTRY(CHANGING_BG_TREE),
> +	DEF_SUPER_FLAG_ENTRY(CHANGING_DATA_CSUM),
> +	DEF_SUPER_FLAG_ENTRY(CHANGING_META_CSUM),
>   };
>   static const int super_flags_num = ARRAY_SIZE(super_flags_array);
>   
> -#define BTRFS_SUPER_FLAG_SUPP	(BTRFS_HEADER_FLAG_WRITTEN |\
> -				 BTRFS_HEADER_FLAG_RELOC |\
> -				 BTRFS_SUPER_FLAG_CHANGING_FSID |\
> -				 BTRFS_SUPER_FLAG_CHANGING_FSID_V2 |\
> -				 BTRFS_SUPER_FLAG_SEEDING |\
> -				 BTRFS_SUPER_FLAG_METADUMP |\
> -				 BTRFS_SUPER_FLAG_METADUMP_V2)
> -
>   static void __print_readable_flag(u64 flag, struct readable_flag_entry *array,
>   				  int array_size, u64 supported_flags)
>   {
> @@ -1995,26 +1990,34 @@ static void __print_readable_flag(u64 flag, struct readable_flag_entry *array,
>   
>   static void print_readable_compat_ro_flag(u64 flag)
>   {
> -	/*
> -	 * We know about the FREE_SPACE_TREE{,_VALID} bits, but we don't
> -	 * actually support them yet.
> -	 */
> +	u64 print_flags = 0;
> +
> +	for (int i = 0; i < compat_ro_flags_num; i++)
> +		print_flags |= compat_ro_flags_array[i].bit;
>   	return __print_readable_flag(flag, compat_ro_flags_array,
>   				     compat_ro_flags_num,
> -				     BTRFS_FEATURE_COMPAT_RO_SUPP);
> +				     print_flags);
>   }
>   
>   static void print_readable_incompat_flag(u64 flag)
>   {
> +	u64 print_flags = 0;
> +
> +	for (int i = 0; i < incompat_flags_num; i++)
> +		print_flags |= incompat_flags_array[i].bit;
>   	return __print_readable_flag(flag, incompat_flags_array,
>   				     incompat_flags_num,
> -				     BTRFS_FEATURE_INCOMPAT_SUPP);
> +				     print_flags);
>   }
>   
>   static void print_readable_super_flag(u64 flag)
>   {
> +	int print_flags = 0;

This line should be using u64, or it can not handle flags beyond u32.

Fixed in github.

Thanks,
Qu
> +
> +	for (int i = 0; i < super_flags_num; i++)
> +		print_flags |= super_flags_array[i].bit;
>   	return __print_readable_flag(flag, super_flags_array,
> -				     super_flags_num, BTRFS_SUPER_FLAG_SUPP);
> +				     super_flags_num, print_flags);
>   }
>   
>   static void print_sys_chunk_array(struct btrfs_super_block *sb)

      reply	other threads:[~2024-06-08  5:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-08  4:13 [PATCH 0/2] btrfs-progs: fix the conflicting super flags Qu Wenruo
2024-06-08  4:13 ` [PATCH 1/2] " Qu Wenruo
2024-06-08  4:13 ` [PATCH 2/2] btrfs-progs: print-tree: handle all supported flags Qu Wenruo
2024-06-08  5:07   ` Qu Wenruo [this message]

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=4af5f2ab-8c9d-4303-b663-840d2dbb31eb@suse.com \
    --to=wqu@suse.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