Re: [PATCH 08/14] xfsprogs: free resources in libxfs_alloc_file_space error paths

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

 



On Tue, Apr 08, 2014 at 06:24:58PM -0500, Eric Sandeen wrote:
> The bmap freelist & transaction pointer weren't
> being freed in libxfs_alloc_file_space error paths;
> more or less copy the error handling that exists
> in kernelspace to resolve this.
> 
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> ---
>  libxfs/util.c |   20 +++++++++++++++++---
>  1 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/libxfs/util.c b/libxfs/util.c
> index 1b05540..f1aa4c6 100644
> --- a/libxfs/util.c
> +++ b/libxfs/util.c
> @@ -582,8 +582,17 @@ libxfs_alloc_file_space(
>  		resblks = (uint)XFS_DIOSTRAT_SPACE_RES(mp, datablocks);
>  		error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
>  					  resblks, 0);
> -		if (error)
> +		/*
> +		 * Check for running out of space
> +		 */
> +		if (error) {
> +			/*
> +			 * Free the transaction structure.
> +			 */
> +			ASSERT(error == ENOSPC); /* XXX ERS? */

XXX ?

> +			xfs_trans_cancel(tp, 0);
>  			break;
> +		}
>  		xfs_trans_ijoin(tp, ip, 0);
>  		xfs_trans_ihold(tp, ip);
>  
> @@ -593,12 +602,12 @@ libxfs_alloc_file_space(
>  				&reccount, &free_list);
>  
>  		if (error)
> -			break;
> +			goto error0;
>  
>  		/* complete the transaction */
>  		error = xfs_bmap_finish(&tp, &free_list, &committed);
>  		if (error)
> -			break;
> +			goto error0;
>  
>  		error = xfs_trans_commit(tp, 0);
>  		if (error)
> @@ -612,6 +621,11 @@ libxfs_alloc_file_space(
>  		allocatesize_fsb -= allocated_fsb;
>  	}
>  	return error;
> +
> +error0:	/* Cancel bmap, unlock inode, cancel trans */

Nit, but since it appears we don't lock the inode, the comment is wrong.

Brian

> +	xfs_bmap_cancel(&free_list);
> +	xfs_trans_cancel(tp, 0);
> +	return error;
>  }
>  
>  unsigned int
> -- 
> 1.7.1
> 
> _______________________________________________
> xfs mailing list
> xfs@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux