From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/6] xfs: refactor all the EFI/EFD log item sizeof logic
Date: Wed, 26 Oct 2022 09:22:40 +1100 [thread overview]
Message-ID: <20221025222240.GH3600936@dread.disaster.area> (raw)
In-Reply-To: <Y1heWlHlPLaxmDQe@magnolia>
On Tue, Oct 25, 2022 at 03:08:26PM -0700, Darrick J. Wong wrote:
> On Wed, Oct 26, 2022 at 09:05:43AM +1100, Dave Chinner wrote:
> > On Mon, Oct 24, 2022 at 02:33:05PM -0700, Darrick J. Wong wrote:
> > > From: Darrick J. Wong <djwong@kernel.org>
> > >
> > > Refactor all the open-coded sizeof logic for EFI/EFD log item and log
> > > format structures into common helper functions whose names reflect the
> > > struct names.
> > >
> > > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > > ---
> > > fs/xfs/libxfs/xfs_log_format.h | 48 ++++++++++++++++++++++++++++
> > > fs/xfs/xfs_extfree_item.c | 69 ++++++++++++----------------------------
> > > fs/xfs/xfs_extfree_item.h | 16 +++++++++
> > > fs/xfs/xfs_super.c | 12 ++-----
> > > 4 files changed, 88 insertions(+), 57 deletions(-)
> > >
> > >
> > > diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
> > > index 2f41fa8477c9..f13e0809dc63 100644
> > > --- a/fs/xfs/libxfs/xfs_log_format.h
> > > +++ b/fs/xfs/libxfs/xfs_log_format.h
> > > @@ -616,6 +616,14 @@ typedef struct xfs_efi_log_format {
> > > xfs_extent_t efi_extents[]; /* array of extents to free */
> > > } xfs_efi_log_format_t;
> > >
> > > +static inline size_t
> > > +xfs_efi_log_format_sizeof(
> > > + unsigned int nr)
> > > +{
> > > + return sizeof(struct xfs_efi_log_format) +
> > > + nr * sizeof(struct xfs_extent);
> > > +}
> >
> > FWIW, I'm not really a fan of placing inline code in the on-disk
> > format definition headers because combining code and type
> > definitions eventually leads to dependency hell.
> >
> > I'm going to say it's OK for these functions to be placed here
> > because they have no external dependencies and are directly related
> > to the on-disk structures, but I think we need to be careful about
> > how much code we include into this header as opposed to the type
> > specific header files (such as fs/xfs/xfs_extfree_item.h)...
> >
> > > @@ -345,9 +318,8 @@ xfs_trans_get_efd(
> > > ASSERT(nextents > 0);
> > >
> > > if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
> > > - efdp = kmem_zalloc(sizeof(struct xfs_efd_log_item) +
> > > - nextents * sizeof(struct xfs_extent),
> > > - 0);
> > > + efdp = kmem_zalloc(xfs_efd_log_item_sizeof(nextents),
> > > + GFP_KERNEL | __GFP_NOFAIL);
> >
> > That looks like a broken kmem->kmalloc conversion. Did you mean to
> > convert this to allocation to use kzalloc() at the same time?
>
> Oops, yeah.
FWIW, I just went back an looked at the efip allocation and you did
the same thing there, I just didn't notice it on the first pass....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
prev parent reply other threads:[~2022-10-25 22:22 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 21:32 [PATCHSET 0/6] xfs: fix various problems with log intent item recovery Darrick J. Wong
2022-10-24 21:32 ` [PATCH 1/6] xfs: fix validation in attr log " Darrick J. Wong
2022-10-25 18:50 ` Kees Cook
2022-10-25 20:42 ` Allison Henderson
2022-10-25 21:19 ` Dave Chinner
2022-10-25 22:05 ` Darrick J. Wong
2022-10-24 21:32 ` [PATCH 2/6] xfs: fix memcpy fortify errors in BUI log format copying Darrick J. Wong
2022-10-25 18:52 ` Kees Cook
2022-10-25 20:47 ` Allison Henderson
2022-10-25 21:34 ` Dave Chinner
2022-10-24 21:32 ` [PATCH 3/6] xfs: fix memcpy fortify errors in CUI " Darrick J. Wong
2022-10-25 20:47 ` Allison Henderson
2022-10-25 21:36 ` Dave Chinner
2022-10-24 21:32 ` [PATCH 4/6] xfs: fix memcpy fortify errors in RUI " Darrick J. Wong
2022-10-25 20:49 ` Allison Henderson
2022-10-25 21:37 ` Dave Chinner
2022-10-24 21:32 ` [PATCH 5/6] xfs: fix memcpy fortify errors in EFI " Darrick J. Wong
2022-10-25 19:08 ` Kees Cook
2022-10-25 20:54 ` Allison Henderson
2022-10-25 21:17 ` Darrick J. Wong
2022-10-25 21:47 ` Dave Chinner
2022-10-24 21:33 ` [PATCH 6/6] xfs: refactor all the EFI/EFD log item sizeof logic Darrick J. Wong
2022-10-25 19:14 ` Kees Cook
2022-10-25 20:56 ` Allison Henderson
2022-10-25 22:05 ` Dave Chinner
2022-10-25 22:08 ` Darrick J. Wong
2022-10-25 22:22 ` Dave Chinner [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=20221025222240.GH3600936@dread.disaster.area \
--to=david@fromorbit.com \
--cc=djwong@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