Re: [PATCH 3/4] xfs_spaceman: embed struct xfs_fd in struct fileio

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

 



On Mon, Aug 26, 2019 at 02:20:38PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> 
> Replace the open-coded fd and geometry fields of struct fileio with a
> single xfs_fd, which will enable us to use it natively throughout
> xfs_spaceman in upcoming patches.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> ---
>  spaceman/file.c     |   27 +++++++++++++--------------
>  spaceman/freesp.c   |   30 +++++++++++++++++-------------
>  spaceman/info.c     |   18 ++----------------
>  spaceman/init.c     |   11 +++++++----
>  spaceman/prealloc.c |   15 ++++++++-------
>  spaceman/space.h    |    9 +++++----
>  spaceman/trim.c     |   40 +++++++++++++++++++++-------------------
>  7 files changed, 73 insertions(+), 77 deletions(-)
> 
> 
> diff --git a/spaceman/file.c b/spaceman/file.c
> index 5665da7d..9d550274 100644
> --- a/spaceman/file.c
> +++ b/spaceman/file.c
> @@ -45,26 +45,27 @@ print_f(
>  int
>  openfile(
>  	char		*path,
> -	struct xfs_fsop_geom *geom,
> +	struct xfs_fd	*xfd,
>  	struct fs_path	*fs_path)
>  {
>  	struct fs_path	*fsp;
> -	int		fd;
> +	int		ret;
>  
> -	fd = open(path, 0);
> -	if (fd < 0) {
> +	xfd->fd = open(path, 0);
> +	if (xfd->fd < 0) {
>  		perror(path);
>  		return -1;
>  	}
>  
> -	if (xfrog_geometry(fd, geom) < 0) {
> +	ret = xfrog_prepare_geometry(xfd);
> +	if (ret < 0) {
>  		if (errno == ENOTTY)
>  			fprintf(stderr,
>  _("%s: Not on a mounted XFS filesystem.\n"),
>  					path);
>  		else
>  			perror("XFS_IOC_FSGEOMETRY");
> -		close(fd);
> +		xfrog_close(xfd);
>  		return -1;
>  	}

There's that xfd_open() pattern again :P

> --- a/spaceman/init.c
> +++ b/spaceman/init.c
> @@ -5,6 +5,7 @@
>   */
>  
>  #include "libxfs.h"
> +#include "xfrog.h"
>  #include "command.h"
>  #include "input.h"
>  #include "init.h"
> @@ -60,7 +61,7 @@ init(
>  	char		**argv)
>  {
>  	int		c;
> -	struct xfs_fsop_geom geometry = { 0 };
> +	struct xfs_fd	xfd = XFS_FD_INIT(-1);

XFS_FD_INIT_EMPTY()

Otherwise looks good.

-- 
Dave Chinner
david@xxxxxxxxxxxxx



[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