All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Cc: linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org,
	Ritesh Harjani <ritesh.list@gmail.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Andrey Albershteyn <aalbersh@kernel.org>,
	Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH v2 2/3] xfs_io: allow foreign FSes to show FS_IOC_FSGETXATTR details
Date: Thu, 19 Dec 2024 07:56:52 -0800	[thread overview]
Message-ID: <20241219155652.GG6174@frogsfrogsfrogs> (raw)
In-Reply-To: <0d572efaadc1ed7726a79c0f8cc074914f45d320.1734611784.git.ojaswin@linux.ibm.com>

On Thu, Dec 19, 2024 at 06:09:14PM +0530, Ojaswin Mujoo wrote:
> Currently with stat we only show FS_IOC_FSGETXATTR details if the
> filesystem is XFS. With extsize support also coming to ext4 and possibly
> other filesystems, make sure to allow foreign FSes to display these details
> when "stat" or "statx" is used.
> 
> (Thanks to Dave for suggesting implementation of print_extended_info())
> 
> Suggested-by: Dave Chinner <david@fromorbit.com>
> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>

Looks good to me now,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  io/stat.c | 63 +++++++++++++++++++++++++++++++------------------------
>  1 file changed, 36 insertions(+), 27 deletions(-)
> 
> diff --git a/io/stat.c b/io/stat.c
> index 326f2822e276..3ce3308d0562 100644
> --- a/io/stat.c
> +++ b/io/stat.c
> @@ -98,30 +98,45 @@ print_file_info(void)
>  }
>  
>  static void
> -print_xfs_info(int verbose)
> +print_extended_info(int verbose)
>  {
> -	struct dioattr	dio;
> -	struct fsxattr	fsx, fsxa;
> -
> -	if ((xfsctl(file->name, file->fd, FS_IOC_FSGETXATTR, &fsx)) < 0 ||
> -	    (xfsctl(file->name, file->fd, XFS_IOC_FSGETXATTRA, &fsxa)) < 0) {
> -		perror("FS_IOC_FSGETXATTR");
> -	} else {
> -		printf(_("fsxattr.xflags = 0x%x "), fsx.fsx_xflags);
> -		printxattr(fsx.fsx_xflags, verbose, 0, file->name, 1, 1);
> -		printf(_("fsxattr.projid = %u\n"), fsx.fsx_projid);
> -		printf(_("fsxattr.extsize = %u\n"), fsx.fsx_extsize);
> -		printf(_("fsxattr.cowextsize = %u\n"), fsx.fsx_cowextsize);
> -		printf(_("fsxattr.nextents = %u\n"), fsx.fsx_nextents);
> -		printf(_("fsxattr.naextents = %u\n"), fsxa.fsx_nextents);
> +	struct dioattr dio = {};
> +	struct fsxattr fsx = {}, fsxa = {};
> +
> +	if ((ioctl(file->fd, FS_IOC_FSGETXATTR, &fsx)) < 0) {
> +		perror("FS_IOC_GETXATTR");
> +		exitcode = 1;
> +		return;
>  	}
> +
> +	printf(_("fsxattr.xflags = 0x%x "), fsx.fsx_xflags);
> +	printxattr(fsx.fsx_xflags, verbose, 0, file->name, 1, 1);
> +	printf(_("fsxattr.projid = %u\n"), fsx.fsx_projid);
> +	printf(_("fsxattr.extsize = %u\n"), fsx.fsx_extsize);
> +	printf(_("fsxattr.cowextsize = %u\n"), fsx.fsx_cowextsize);
> +	printf(_("fsxattr.nextents = %u\n"), fsx.fsx_nextents);
> +
> +	/* Only XFS supports FS_IOC_FSGETXATTRA and XFS_IOC_DIOINFO */
> +	if (file->flags & IO_FOREIGN)
> +		return;
> +
> +	if ((ioctl(file->fd, XFS_IOC_FSGETXATTRA, &fsxa)) < 0) {
> +		perror("XFS_IOC_GETXATTRA");
> +		exitcode = 1;
> +		return;
> +	}
> +
> +	printf(_("fsxattr.naextents = %u\n"), fsxa.fsx_nextents);
> +
>  	if ((xfsctl(file->name, file->fd, XFS_IOC_DIOINFO, &dio)) < 0) {
>  		perror("XFS_IOC_DIOINFO");
> -	} else {
> -		printf(_("dioattr.mem = 0x%x\n"), dio.d_mem);
> -		printf(_("dioattr.miniosz = %u\n"), dio.d_miniosz);
> -		printf(_("dioattr.maxiosz = %u\n"), dio.d_maxiosz);
> +		exitcode = 1;
> +		return;
>  	}
> +
> +	printf(_("dioattr.mem = 0x%x\n"), dio.d_mem);
> +	printf(_("dioattr.miniosz = %u\n"), dio.d_miniosz);
> +	printf(_("dioattr.maxiosz = %u\n"), dio.d_maxiosz);
>  }
>  
>  int
> @@ -167,10 +182,7 @@ stat_f(
>  		printf(_("stat.ctime = %s"), ctime(&st.st_ctime));
>  	}
>  
> -	if (file->flags & IO_FOREIGN)
> -		return 0;
> -
> -	print_xfs_info(verbose);
> +	print_extended_info(verbose);
>  
>  	return 0;
>  }
> @@ -440,10 +452,7 @@ statx_f(
>  				ctime((time_t *)&stx.stx_btime.tv_sec));
>  	}
>  
> -	if (file->flags & IO_FOREIGN)
> -		return 0;
> -
> -	print_xfs_info(verbose);
> +	print_extended_info(verbose);
>  
>  	return 0;
>  }
> -- 
> 2.43.5
> 
> 

  reply	other threads:[~2024-12-19 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-19 12:39 [PATCH v2 0/3] xfs_io: enable extsize and stat -v support for ext4 Ojaswin Mujoo
2024-12-19 12:39 ` [PATCH v2 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC Ojaswin Mujoo
2024-12-19 15:55   ` Darrick J. Wong
2024-12-19 12:39 ` [PATCH v2 2/3] xfs_io: allow foreign FSes to show FS_IOC_FSGETXATTR details Ojaswin Mujoo
2024-12-19 15:56   ` Darrick J. Wong [this message]
2024-12-19 12:39 ` [PATCH v2 3/3] xfs_io: add extsize command support Ojaswin Mujoo
2024-12-19 15:57   ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241219155652.GG6174@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@kernel.org \
    --cc=david@fromorbit.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.