public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] xfs_io: enable extsize and stat -v support for ext4
@ 2024-12-15  9:17 Ojaswin Mujoo
  2024-12-15  9:17 ` [PATCH 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC Ojaswin Mujoo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ojaswin Mujoo @ 2024-12-15  9:17 UTC (permalink / raw)
  To: linux-ext4, linux-xfs
  Cc: Ritesh Harjani, linux-kernel, linux-fsdevel, Andrey Albershteyn,
	Darrick J . Wong, John Garry

Changes since rfc [1]

 * Patch 1: Don't add ext4 specific checks
 * Patch 2: Rather than adding a check for ext4, allow FS_IOC_GETXATTR
   to be called by any FS that supports it.

[1]
https://lore.kernel.org/linux-ext4/cover.1733902742.git.ojaswin@linux.ibm.com/T/#t

** Original Cover **

With ext4 extsize hints support being worked on, enable extsize 
command to be run on FSes other than xfs so ext4 can utilize it.
Also extend stat -v to perform FS_IOC_FSGETXATTR ioctl on ext4.

No funtional changes are intended for XFS.

Ojaswin Mujoo (3):
  include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC
  xfs_io: allow foreign FSes to show FS_IOC_FSGETXATTR details
  xfs_io: add extsize command support

 include/linux.h |  3 ++-
 io/open.c       |  2 +-
 io/stat.c       | 63 ++++++++++++++++++++++++++++---------------------
 3 files changed, 39 insertions(+), 29 deletions(-)

-- 
2.43.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC
  2024-12-15  9:17 [PATCH 0/3] xfs_io: enable extsize and stat -v support for ext4 Ojaswin Mujoo
@ 2024-12-15  9:17 ` Ojaswin Mujoo
  2024-12-16  8:28   ` Christoph Hellwig
  2024-12-15  9:17 ` [PATCH 2/3] xfs_io: allow foreign FSes to show FS_IOC_FSGETXATTR details Ojaswin Mujoo
  2024-12-15  9:17 ` [PATCH 3/3] xfs_io: add extsize command support Ojaswin Mujoo
  2 siblings, 1 reply; 6+ messages in thread
From: Ojaswin Mujoo @ 2024-12-15  9:17 UTC (permalink / raw)
  To: linux-ext4, linux-xfs
  Cc: Ritesh Harjani, linux-kernel, linux-fsdevel, Andrey Albershteyn,
	Darrick J . Wong, John Garry

This avoids open coding the magic number

Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---
 include/linux.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux.h b/include/linux.h
index e9eb7bfb26a1..306a31e092a7 100644
--- a/include/linux.h
+++ b/include/linux.h
@@ -37,6 +37,7 @@
 #endif
 #include <unistd.h>
 #include <assert.h>
+#include <linux/magic.h> /* super block magic numbers */
 
 static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
 {
@@ -60,7 +61,7 @@ static __inline__ int platform_test_xfs_fd(int fd)
 		return 0;
 	if (!S_ISREG(statbuf.st_mode) && !S_ISDIR(statbuf.st_mode))
 		return 0;
-	return (statfsbuf.f_type == 0x58465342);	/* XFSB */
+	return (statfsbuf.f_type == XFS_SUPER_MAGIC);
 }
 
 static __inline__ int platform_test_xfs_path(const char *path)
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] xfs_io: allow foreign FSes to show FS_IOC_FSGETXATTR details
  2024-12-15  9:17 [PATCH 0/3] xfs_io: enable extsize and stat -v support for ext4 Ojaswin Mujoo
  2024-12-15  9:17 ` [PATCH 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC Ojaswin Mujoo
@ 2024-12-15  9:17 ` Ojaswin Mujoo
  2024-12-15  9:17 ` [PATCH 3/3] xfs_io: add extsize command support Ojaswin Mujoo
  2 siblings, 0 replies; 6+ messages in thread
From: Ojaswin Mujoo @ 2024-12-15  9:17 UTC (permalink / raw)
  To: linux-ext4, linux-xfs
  Cc: Ritesh Harjani, linux-kernel, linux-fsdevel, Andrey Albershteyn,
	Darrick J . Wong, John Garry, Dave Chinner

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>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] xfs_io: add extsize command support
  2024-12-15  9:17 [PATCH 0/3] xfs_io: enable extsize and stat -v support for ext4 Ojaswin Mujoo
  2024-12-15  9:17 ` [PATCH 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC Ojaswin Mujoo
  2024-12-15  9:17 ` [PATCH 2/3] xfs_io: allow foreign FSes to show FS_IOC_FSGETXATTR details Ojaswin Mujoo
@ 2024-12-15  9:17 ` Ojaswin Mujoo
  2 siblings, 0 replies; 6+ messages in thread
From: Ojaswin Mujoo @ 2024-12-15  9:17 UTC (permalink / raw)
  To: linux-ext4, linux-xfs
  Cc: Ritesh Harjani, linux-kernel, linux-fsdevel, Andrey Albershteyn,
	Darrick J . Wong, John Garry

extsize command is currently only supported with XFS filesystem.
Lift this restriction now that ext4 is also supporting extsize hints.

Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---
 io/open.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/io/open.c b/io/open.c
index a30dd89a1fd5..2582ff9b862e 100644
--- a/io/open.c
+++ b/io/open.c
@@ -997,7 +997,7 @@ open_init(void)
 	extsize_cmd.args = _("[-D | -R] [extsize]");
 	extsize_cmd.argmin = 0;
 	extsize_cmd.argmax = -1;
-	extsize_cmd.flags = CMD_NOMAP_OK;
+	extsize_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
 	extsize_cmd.oneline =
 		_("get/set preferred extent size (in bytes) for the open file");
 	extsize_cmd.help = extsize_help;
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC
  2024-12-15  9:17 ` [PATCH 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC Ojaswin Mujoo
@ 2024-12-16  8:28   ` Christoph Hellwig
  2024-12-17  5:39     ` Ojaswin Mujoo
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2024-12-16  8:28 UTC (permalink / raw)
  To: Ojaswin Mujoo
  Cc: linux-ext4, linux-xfs, Ritesh Harjani, linux-kernel,
	linux-fsdevel, Andrey Albershteyn, Darrick J . Wong, John Garry

On Sun, Dec 15, 2024 at 02:47:15PM +0530, Ojaswin Mujoo wrote:
> -	return (statfsbuf.f_type == 0x58465342);	/* XFSB */
> +	return (statfsbuf.f_type == XFS_SUPER_MAGIC);

Might be worth dropping the superfluous braces here while you're at it.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC
  2024-12-16  8:28   ` Christoph Hellwig
@ 2024-12-17  5:39     ` Ojaswin Mujoo
  0 siblings, 0 replies; 6+ messages in thread
From: Ojaswin Mujoo @ 2024-12-17  5:39 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-ext4, linux-xfs, Ritesh Harjani, linux-kernel,
	linux-fsdevel, Andrey Albershteyn, Darrick J . Wong, John Garry

On Mon, Dec 16, 2024 at 12:28:00AM -0800, Christoph Hellwig wrote:
> On Sun, Dec 15, 2024 at 02:47:15PM +0530, Ojaswin Mujoo wrote:
> > -	return (statfsbuf.f_type == 0x58465342);	/* XFSB */
> > +	return (statfsbuf.f_type == XFS_SUPER_MAGIC);
> 
> Might be worth dropping the superfluous braces here while you're at it.

Thanks for the review Christoph, I will fix the braces here.

regards,
ojaswin
> 
> Otherwise looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-17  5:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-15  9:17 [PATCH 0/3] xfs_io: enable extsize and stat -v support for ext4 Ojaswin Mujoo
2024-12-15  9:17 ` [PATCH 1/3] include/linux.h: use linux/magic.h to get XFS_SUPER_MAGIC Ojaswin Mujoo
2024-12-16  8:28   ` Christoph Hellwig
2024-12-17  5:39     ` Ojaswin Mujoo
2024-12-15  9:17 ` [PATCH 2/3] xfs_io: allow foreign FSes to show FS_IOC_FSGETXATTR details Ojaswin Mujoo
2024-12-15  9:17 ` [PATCH 3/3] xfs_io: add extsize command support Ojaswin Mujoo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox