Re: [PATCH 1/3] btrfs: rst: remove encoding field from stripe_extent

From: David Sterba
Date: Thu Jun 13 2024 - 17:24:02 EST


On Tue, Jun 11, 2024 at 04:33:19PM +0000, Johannes Thumshirn wrote:
> On 11.06.24 16:37, David Sterba wrote:
> > On Mon, Jun 10, 2024 at 10:40:25AM +0200, Johannes Thumshirn wrote:
> >> -#define BTRFS_STRIPE_RAID5 5
> >> -#define BTRFS_STRIPE_RAID6 6
> >> -#define BTRFS_STRIPE_RAID1C3 7
> >> -#define BTRFS_STRIPE_RAID1C4 8
> >> -
> >> struct btrfs_stripe_extent {
> >> - __u8 encoding;
> >> - __u8 reserved[7];
> >> /* An array of raid strides this stripe is composed of. */
> >> - struct btrfs_raid_stride strides[];
> >> + __DECLARE_FLEX_ARRAY(struct btrfs_raid_stride, strides);
> >
> > Is there a reason to use the __ underscore macro? I see no difference
> > between that and DECLARE_FLEX_ARRAY and underscore usually means that
> > it's special in some way.
> >
>
> Yes, the __ version is for UAPI, like __u8 or __le32 and so on.

I see, though I'd rather keep the on-disk definitions free of wrappers
that hide the types. We use the __ int types but that's all and quite
clear what it means.

There already are flexible members (btrfs_leaf, btrfs_node,
btrfs_inode_extref), using the empty[] syntax. The macro wraps the
distinction that c++ needs but so far the existing declarations have't
been problematic. So I'd rather keep the declarations consistent.