Re: [PATCH 6/7] xfs: add a xfs_efd_item_sizeof helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 19, 2021 at 10:28:03AM +0200, Christoph Hellwig wrote:
> Add a helper to calculate the size of an xfs_efd_log_item structure
> the specified number of extents.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Questions about function names notwithstanding,

Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx>

--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 afd568d426c1f1..a2abdfd3d076bf 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -268,15 +268,11 @@ xfs_trans_get_efd(
>  	struct xfs_efd_log_item		*efdp;
>  
>  	ASSERT(nextents > 0);
> -
> -	if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
> -		efdp = kmem_zalloc(sizeof(struct xfs_efd_log_item) +
> -				(nextents - 1) * sizeof(struct xfs_extent),
> -				0);
> -	} else {
> +	if (nextents > XFS_EFD_MAX_FAST_EXTENTS)
> +		efdp = kmem_zalloc(xfs_efd_item_sizeof(nextents), 0);
> +	else
>  		efdp = kmem_cache_zalloc(xfs_efd_zone,
>  					GFP_KERNEL | __GFP_NOFAIL);
> -	}
>  
>  	xfs_log_item_init(tp->t_mountp, &efdp->efd_item, XFS_LI_EFD,
>  			  &xfs_efd_item_ops);
> diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
> index d2577d872de771..3bb62ef525f2e0 100644
> --- a/fs/xfs/xfs_extfree_item.h
> +++ b/fs/xfs/xfs_extfree_item.h
> @@ -70,6 +70,12 @@ struct xfs_efd_log_item {
>  	struct xfs_efd_log_format efd_format;
>  };
>  
> +static inline int xfs_efd_item_sizeof(unsigned int nextents)
> +{
> +	return sizeof(struct xfs_efd_log_item) +
> +		(nextents - 1) * sizeof(struct xfs_extent);
> +}
> +
>  /*
>   * Max number of extents in fast allocation path.
>   */
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index c93710cb5ce3f0..f7f70438d98703 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1953,10 +1953,8 @@ xfs_init_zones(void)
>  		goto out_destroy_trans_zone;
>  
>  	xfs_efd_zone = kmem_cache_create("xfs_efd_item",
> -					(sizeof(struct xfs_efd_log_item) +
> -					(XFS_EFD_MAX_FAST_EXTENTS - 1) *
> -					sizeof(struct xfs_extent)),
> -					0, 0, NULL);
> +			xfs_efd_item_sizeof(XFS_EFD_MAX_FAST_EXTENTS),
> +			0, 0, NULL);
>  	if (!xfs_efd_zone)
>  		goto out_destroy_buf_item_zone;
>  
> -- 
> 2.30.1
> 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux