On Fri, Jun 26, 2020 at 04:30:19PM +0900, 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.
>
> To simplify further additions to the ioctl, also switch the padding to a
> u8 array. Pahole was used to verify the result of this switch:
>
> pahole -C btrfs_ioctl_fs_info_args fs/btrfs/btrfs.ko
> struct btrfs_ioctl_fs_info_args {
> __u64 max_id; /* 0 8 */
> __u64 num_devices; /* 8 8 */
> __u8 fsid[16]; /* 16 16 */
> __u32 nodesize; /* 32 4 */
> __u32 sectorsize; /* 36 4 */
> __u32 clone_alignment; /* 40 4 */
> __u32 flags; /* 44 4 */
> __u16 csum_type; /* 48 2 */
This leaves 2 bytes (one u16) unaligned to the next 4 bytes, which
shouldn't be a problem, but I think having the csum_size would be a good
and also getting rid of the gap.
> __u8 reserved[974]; /* 50 974 */
>
> /* size: 1024, cachelines: 16, members: 9 */
> };