Re: [PATCH 13/23] libxfs: merge the file vs device cases in libxfs_init

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

 



On Mon, Dec 11, 2023 at 05:37:32PM +0100, Christoph Hellwig wrote:
> The only special handling for an XFS device on a regular file is that
> we skip the checks in check_open.  Simplify perform those conditionally
> instead of duplicating the entire sequence.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Reviewed-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx>

> ---
>  libxfs/init.c | 74 ++++++++++++++++-----------------------------------
>  1 file changed, 23 insertions(+), 51 deletions(-)
> 
> diff --git a/libxfs/init.c b/libxfs/init.c
> index 14962b9fa..86b810bfe 100644
> --- a/libxfs/init.c
> +++ b/libxfs/init.c
> @@ -313,59 +313,31 @@ libxfs_init(struct libxfs_init *a)
>  	radix_tree_init();
> 
>  	if (dname) {
> -		if (a->disfile) {
> -			a->ddev= libxfs_device_open(dname, a->dcreat, flags,
> -						    a->setblksize);
> -			a->dfd = libxfs_device_to_fd(a->ddev);
> -			platform_findsizes(dname, a->dfd, &a->dsize,
> -					   &a->dbsize);
> -		} else {
> -			if (!check_open(dname, flags))
> -				goto done;
> -			a->ddev = libxfs_device_open(dname,
> -					a->dcreat, flags, a->setblksize);
> -			a->dfd = libxfs_device_to_fd(a->ddev);
> -			platform_findsizes(dname, a->dfd,
> -					   &a->dsize, &a->dbsize);
> -		}
> -	} else
> -		a->dsize = 0;
> +		if (!a->disfile && !check_open(dname, flags))
> +			goto done;
> +		a->ddev = libxfs_device_open(dname, a->dcreat, flags,
> +				a->setblksize);
> +		a->dfd = libxfs_device_to_fd(a->ddev);
> +		platform_findsizes(dname, a->dfd, &a->dsize, &a->dbsize);
> +	}
>  	if (logname) {
> -		if (a->lisfile) {
> -			a->logdev = libxfs_device_open(logname,
> -					a->lcreat, flags, a->setblksize);
> -			a->logfd = libxfs_device_to_fd(a->logdev);
> -			platform_findsizes(dname, a->logfd, &a->logBBsize,
> -					   &a->lbsize);
> -		} else {
> -			if (!check_open(logname, flags))
> -				goto done;
> -			a->logdev = libxfs_device_open(logname,
> -					a->lcreat, flags, a->setblksize);
> -			a->logfd = libxfs_device_to_fd(a->logdev);
> -			platform_findsizes(logname, a->logfd,
> -					   &a->logBBsize, &a->lbsize);
> -		}
> -	} else
> -		a->logBBsize = 0;
> +		if (!a->lisfile && !check_open(logname, flags))
> +			goto done;
> +		a->logdev = libxfs_device_open(logname, a->lcreat, flags,
> +				a->setblksize);
> +		a->logfd = libxfs_device_to_fd(a->logdev);
> +		platform_findsizes(logname, a->logfd, &a->logBBsize,
> +				&a->lbsize);
> +	}
>  	if (rtname) {
> -		if (a->risfile) {
> -			a->rtdev = libxfs_device_open(rtname,
> -					a->rcreat, flags, a->setblksize);
> -			a->rtfd = libxfs_device_to_fd(a->rtdev);
> -			platform_findsizes(dname, a->rtfd, &a->rtsize,
> -					   &a->rtbsize);
> -		} else {
> -			if (!check_open(rtname, flags))
> -				goto done;
> -			a->rtdev = libxfs_device_open(rtname,
> -					a->rcreat, flags, a->setblksize);
> -			a->rtfd = libxfs_device_to_fd(a->rtdev);
> -			platform_findsizes(rtname, a->rtfd,
> -					   &a->rtsize, &a->rtbsize);
> -		}
> -	} else
> -		a->rtsize = 0;
> +		if (a->risfile && !check_open(rtname, flags))
> +			goto done;
> +		a->rtdev = libxfs_device_open(rtname, a->rcreat, flags,
> +				a->setblksize);
> +		a->rtfd = libxfs_device_to_fd(a->rtdev);
> +		platform_findsizes(dname, a->rtfd, &a->rtsize, &a->rtbsize);
> +	}
> +
>  	if (a->dsize < 0) {
>  		fprintf(stderr, _("%s: can't get size for data subvolume\n"),
>  			progname);
> --
> 2.39.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