Re: [PATCH 13/20] xfs: merge xfs_efd_init into xfs_trans_get_efd

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

 




On 17.05.19 г. 10:31 ч., Christoph Hellwig wrote:
> There is no good reason to keep these two functions separate.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
>  fs/xfs/xfs_extfree_item.c  | 27 +++++++++++++++------------
>  fs/xfs/xfs_extfree_item.h  |  2 --
>  fs/xfs/xfs_trans_extfree.c | 26 --------------------------
>  3 files changed, 15 insertions(+), 40 deletions(-)
> 
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index bb0b1e942d00..ccf95cb8234c 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -312,32 +312,35 @@ static const struct xfs_item_ops xfs_efd_item_ops = {
>  };
>  
>  /*
> - * Allocate and initialize an efd item with the given number of extents.
> + * Allocate an "extent free done" log item that will hold nextents worth of
> + * extents.  The caller must use all nextents extents, because we are not
> + * flexible about this at all.
>   */
>  struct xfs_efd_log_item *
> -xfs_efd_init(
> -	struct xfs_mount	*mp,
> -	struct xfs_efi_log_item	*efip,
> -	uint			nextents)
> -
> +xfs_trans_get_efd(
> +	struct xfs_trans		*tp,
> +	struct xfs_efi_log_item		*efip,
> +	unsigned int			nextents)
>  {
> -	struct xfs_efd_log_item	*efdp;
> -	uint			size;
> +	struct xfs_efd_log_item		*efdp;
>  
>  	ASSERT(nextents > 0);
> +
>  	if (nextents > XFS_EFD_MAX_FAST_EXTENTS) {
> -		size = (uint)(sizeof(xfs_efd_log_item_t) +
> -			((nextents - 1) * sizeof(xfs_extent_t)));
> -		efdp = kmem_zalloc(size, KM_SLEEP);
> +		efdp = kmem_zalloc(sizeof(struct xfs_efd_log_item) +
> +				(nextents - 1) * sizeof(struct xfs_extent),
> +				KM_SLEEP);

xfs_efd_log is really a struct which ends with an array. I think it will
make it slightly more obvious if you use the newly introduced
struct_size like so:

kmem_zalloc(struct_size(efdp, efd_format.efd_extents, nextents -1),
KM_SLEEP)


<snip>



[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