Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	David Sterba <dsterba@suse.cz>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl
Date: Wed, 24 Jun 2020 19:03:08 +0800	[thread overview]
Message-ID: <8add89b8-c581-26c3-31df-e5e056449dc2@gmx.com> (raw)
In-Reply-To: <20200624102136.12495-1-johannes.thumshirn@wdc.com>


[-- Attachment #1.1: Type: text/plain, Size: 2686 bytes --]



On 2020/6/24 下午6:21, Johannes Thumshirn wrote:
> With the recent addition of filesystem checksum types other than CRC32c,
> it is not anymore hard-coded which checksum type a btrfs filesystem uses.
> 
> Up to now there is no good way to read the filesystem checksum, apart from
> reading the filesystem UUID and then query sysfs for the checksum type.
> 
> Add a new csum_type field to the BTRFS_IOC_FS_INFO ioctl command which
> usually is used to query filesystem features. Also add a flags member
> indicating that the kernel responded with a set csum_type field.
> 
> Fixes: 3951e7f050ac ("btrfs: add xxhash64 to checksumming algorithms")
> Fixes: 3831bf0094ab ("btrfs: add sha256 to checksumming algorithm")

I don't think the fixes tags are needed.
You're just adding a new interface for IOC_FS_INFO to grab the algorithm.

Overall looks good.

> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/ioctl.c           |  3 +++
>  include/uapi/linux/btrfs.h | 13 ++++++++++++-
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index b3e4c632d80c..16062720f5f3 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3217,6 +3217,9 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
>  	fi_args->nodesize = fs_info->nodesize;
>  	fi_args->sectorsize = fs_info->sectorsize;
>  	fi_args->clone_alignment = fs_info->sectorsize;
> +	fi_args->csum_type =
> +			le16_to_cpu(btrfs_super_csum_type(fs_info->super_copy));
> +	fi_args->flags |= BTRFS_FS_INFO_FLAG_CSUM_TYPE;
>  
>  	if (copy_to_user(arg, fi_args, sizeof(*fi_args)))
>  		ret = -EFAULT;
> diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
> index e6b6cb0f8bc6..161d9100c2a6 100644
> --- a/include/uapi/linux/btrfs.h
> +++ b/include/uapi/linux/btrfs.h
> @@ -250,10 +250,21 @@ struct btrfs_ioctl_fs_info_args {
>  	__u32 nodesize;				/* out */
>  	__u32 sectorsize;			/* out */
>  	__u32 clone_alignment;			/* out */
> +	__u32 flags;				/* out */

The flags looks a little too generic.
What about extra_members or things like that?

This flag really indicates what extra info the ioctl args can provide,
so a better name would be easier to understand.

Thanks,
Qu

> +	__u16 csum_type;
> +	__u16 reserved16;
>  	__u32 reserved32;
> -	__u64 reserved[122];			/* pad to 1k */
> +	__u64 reserved[121];			/* pad to 1k */
>  };
>  
> +/*
> + * fs_info ioctl flags
> + *
> + * Used by:
> + * struct btrfs_ioctl_fs_info_args
> + */
> +#define BTRFS_FS_INFO_FLAG_CSUM_TYPE			(1 << 0)
> +
>  /*
>   * feature flags
>   *
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-06-24 11:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 10:21 [PATCH] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl Johannes Thumshirn
2020-06-24 11:03 ` Qu Wenruo [this message]
2020-06-24 11:41   ` Johannes Thumshirn
2020-06-24 11:55     ` Qu Wenruo
2020-06-24 12:14       ` Hans van Kranenburg
2020-06-24 12:17         ` Johannes Thumshirn
2020-06-24 12:21           ` Nikolay Borisov
2020-06-24 13:01             ` Johannes Thumshirn
2020-06-24 15:36               ` David Sterba
2020-06-24 12:00   ` Nikolay Borisov
2020-06-24 12:16 ` Hans van Kranenburg
2020-06-24 12:18   ` Johannes Thumshirn
2020-06-24 14:15 ` kernel test robot
2020-06-24 15:40   ` David Sterba
2020-06-25  7:48     ` Johannes Thumshirn
2020-06-24 15:31 ` David Sterba
2020-06-25  2:26   ` Hans van Kranenburg

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=8add89b8-c581-26c3-31df-e5e056449dc2@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.cz \
    --cc=johannes.thumshirn@wdc.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