From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org,
"Gustavo A . R . Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH 5/7] xfs: add a xfs_efi_item_sizeof helper
Date: Tue, 20 Apr 2021 10:11:36 -0700 [thread overview]
Message-ID: <20210420171136.GK3122264@magnolia> (raw)
In-Reply-To: <20210419082804.2076124-6-hch@lst.de>
On Mon, Apr 19, 2021 at 10:28:02AM +0200, Christoph Hellwig wrote:
> Add a helper to calculate the size of an xfs_efi_log_item structure
> the specified number of extents.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Function name questions notwithstanding, this is a nice cleanup.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_extfree_item.c | 10 +++-------
> fs/xfs/xfs_extfree_item.h | 6 ++++++
> fs/xfs/xfs_super.c | 6 ++----
> 3 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index f15d6cfca6e2f1..afd568d426c1f1 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -153,17 +153,13 @@ xfs_efi_init(
>
> {
> struct xfs_efi_log_item *efip;
> - uint size;
>
> ASSERT(nextents > 0);
> - if (nextents > XFS_EFI_MAX_FAST_EXTENTS) {
> - size = (uint)(sizeof(struct xfs_efi_log_item) +
> - ((nextents - 1) * sizeof(struct xfs_extent)));
> - efip = kmem_zalloc(size, 0);
> - } else {
> + if (nextents > XFS_EFI_MAX_FAST_EXTENTS)
> + efip = kmem_zalloc(xfs_efi_item_sizeof(nextents), 0);
> + else
> efip = kmem_cache_zalloc(xfs_efi_zone,
> GFP_KERNEL | __GFP_NOFAIL);
> - }
>
> xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops);
> efip->efi_format.efi_nextents = nextents;
> diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
> index e09afd0f63ff59..d2577d872de771 100644
> --- a/fs/xfs/xfs_extfree_item.h
> +++ b/fs/xfs/xfs_extfree_item.h
> @@ -52,6 +52,12 @@ struct xfs_efi_log_item {
> struct xfs_efi_log_format efi_format;
> };
>
> +static inline int xfs_efi_item_sizeof(unsigned int nextents)
> +{
> + return sizeof(struct xfs_efi_log_item) +
> + (nextents - 1) * sizeof(struct xfs_extent);
> +}
> +
> /*
> * This is the "extent free done" log item. It is used to log
> * the fact that some extents earlier mentioned in an efi item
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index a2dab05332ac27..c93710cb5ce3f0 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1961,10 +1961,8 @@ xfs_init_zones(void)
> goto out_destroy_buf_item_zone;
>
> xfs_efi_zone = kmem_cache_create("xfs_efi_item",
> - (sizeof(struct xfs_efi_log_item) +
> - (XFS_EFI_MAX_FAST_EXTENTS - 1) *
> - sizeof(struct xfs_extent)),
> - 0, 0, NULL);
> + xfs_efi_item_sizeof(XFS_EFI_MAX_FAST_EXTENTS),
> + 0, 0, NULL);
> if (!xfs_efi_zone)
> goto out_destroy_efd_zone;
>
> --
> 2.30.1
>
next prev parent reply other threads:[~2021-04-20 17:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-19 8:27 cleanup the EFI/EFD definitions Christoph Hellwig
2021-04-19 8:27 ` [PATCH 1/7] xfs: remove the EFD size asserts in xlog_recover_efd_commit_pass2 Christoph Hellwig
2021-04-20 16:26 ` Darrick J. Wong
2021-04-19 8:27 ` [PATCH 2/7] xfs: clean up the EFI and EFD log format handling Christoph Hellwig
2021-04-20 17:05 ` Darrick J. Wong
2021-04-21 5:55 ` Christoph Hellwig
2021-04-22 0:19 ` Darrick J. Wong
2021-04-19 8:28 ` [PATCH 3/7] xfs: pass a xfs_efi_log_item to xfs_efi_item_sizeof Christoph Hellwig
2021-04-20 17:09 ` Darrick J. Wong
2021-04-21 5:56 ` Christoph Hellwig
2021-04-22 0:29 ` Darrick J. Wong
2021-04-19 8:28 ` [PATCH 4/7] xfs: pass a xfs_efd_log_item to xfs_efd_item_sizeof Christoph Hellwig
2021-04-20 17:10 ` Darrick J. Wong
2021-04-19 8:28 ` [PATCH 5/7] xfs: add a xfs_efi_item_sizeof helper Christoph Hellwig
2021-04-20 17:11 ` Darrick J. Wong [this message]
2021-04-19 8:28 ` [PATCH 6/7] xfs: add a xfs_efd_item_sizeof helper Christoph Hellwig
2021-04-20 17:12 ` Darrick J. Wong
2021-04-19 8:28 ` [PATCH 7/7] xfs: Replace one-element arrays with flexible-array members Christoph Hellwig
2021-04-20 17:15 ` Darrick J. Wong
2021-04-20 22:16 ` Gustavo A. R. Silva
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=20210420171136.GK3122264@magnolia \
--to=djwong@kernel.org \
--cc=gustavoars@kernel.org \
--cc=hch@lst.de \
--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