From: Christoph Hellwig <hch@infradead.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH v4][next] xfs: Replace one-element arrays with flexible-array members
Date: Tue, 13 Apr 2021 17:53:13 +0100 [thread overview]
Message-ID: <20210413165313.GA1430582@infradead.org> (raw)
In-Reply-To: <20210412154808.GA1670408@magnolia>
On Mon, Apr 12, 2021 at 08:48:08AM -0700, Darrick J. Wong wrote:
> A couple of revisions ago I specifically asked Gustavo to create these
> 'silly' sizeof helpers to clean up...
>
> > > - (sizeof(struct xfs_efd_log_item) +
> > > - (XFS_EFD_MAX_FAST_EXTENTS - 1) *
> > > - sizeof(struct xfs_extent)),
> > > - 0, 0, NULL);
> > > + struct_size((struct xfs_efd_log_item *)0,
> > > + efd_format.efd_extents,
> > > + XFS_EFD_MAX_FAST_EXTENTS),
>
> ...these even uglier multiline statements. I was also going to ask for
> these kmem cache users to get cleaned up. I'd much rather look at:
>
> xfs_efi_zone = kmem_cache_create("xfs_efi_item",
> sizeof_xfs_efi(XFS_EFI_MAX_FAST_EXTENTS), 0);
> if (!xfs_efi_zone)
> goto the_drop_zone;
>
> even if it means another static inline.
Which doesn't really work with struct_size or rather leads to a mess
like the above as struct_size really wants a variable and not just a
type. Making it really nasty for both allocations and creating slab
caches. I tried to find a workaround for that, but that makes the
compiler unhappy based its inlining heuristics.
Anyway, a lot of the helpers are pretty silly as they duplicate stuff
without cleaning up the underlying mess. I tried to sort much of this
out here, still WIP:
http://git.infradead.org/users/hch/xfs.git/shortlog/refs/heads/xfs-array-size
next prev parent reply other threads:[~2021-04-13 16:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 13:56 [PATCH v4][next] xfs: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
2021-04-12 15:29 ` Christoph Hellwig
2021-04-12 15:36 ` Gustavo A. R. Silva
2021-04-12 15:48 ` Darrick J. Wong
2021-04-12 15:57 ` Gustavo A. R. Silva
2021-04-13 16:53 ` Christoph Hellwig [this message]
2021-07-14 9:27 ` Chen, Rong A
2021-07-15 5:33 ` Christoph Hellwig
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=20210413165313.GA1430582@infradead.org \
--to=hch@infradead.org \
--cc=djwong@kernel.org \
--cc=gustavoars@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@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;
as well as URLs for NNTP newsgroup(s).