Re: [PATCH 08/43] xfs: reflow xfs_dec_freecounter

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

 



On Thu, Feb 06, 2025 at 07:44:24AM +0100, Christoph Hellwig wrote:
> Let the successful allocation be the main path through the function
> with exception handling in branches to make the code easier to
> follow.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Looks ok,
Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>

--D

> ---
>  fs/xfs/xfs_mount.c | 37 +++++++++++++++++++------------------
>  1 file changed, 19 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 26793d4f2707..65123f4ffc2a 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -1329,28 +1329,29 @@ xfs_dec_freecounter(
>  	set_aside = xfs_freecounter_unavailable(mp, ctr);
>  	percpu_counter_add_batch(counter, -((int64_t)delta), batch);
>  	if (__percpu_counter_compare(counter, set_aside,
> -				     XFS_FDBLOCKS_BATCH) >= 0) {
> -		/* we had space! */
> -		return 0;
> -	}
> -
> -	/*
> -	 * lock up the sb for dipping into reserves before releasing the space
> -	 * that took us to ENOSPC.
> -	 */
> -	spin_lock(&mp->m_sb_lock);
> -	percpu_counter_add(counter, delta);
> -	if (!rsvd)
> -		goto fdblocks_enospc;
> +			XFS_FDBLOCKS_BATCH) < 0) {
> +		/*
> +		 * Lock up the sb for dipping into reserves before releasing the
> +		 * space that took us to ENOSPC.
> +		 */
> +		spin_lock(&mp->m_sb_lock);
> +		percpu_counter_add(counter, delta);
> +		if (!rsvd)
> +			goto fdblocks_enospc;
> +
> +		lcounter = (long long)mp->m_resblks[ctr].avail - delta;
> +		if (lcounter < 0) {
> +			xfs_warn_once(mp,
> +"Reserve blocks depleted! Consider increasing reserve pool size.");
> +			goto fdblocks_enospc;
> +		}
>  
> -	lcounter = (long long)mp->m_resblks[ctr].avail - delta;
> -	if (lcounter >= 0) {
>  		mp->m_resblks[ctr].avail = lcounter;
>  		spin_unlock(&mp->m_sb_lock);
> -		return 0;
>  	}
> -	xfs_warn_once(mp,
> -"Reserve blocks depleted! Consider increasing reserve pool size.");
> +
> +	/* we had space! */
> +	return 0;
>  
>  fdblocks_enospc:
>  	spin_unlock(&mp->m_sb_lock);
> -- 
> 2.45.2
> 
> 




[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