Skip to contentSkip to conversation

xfsprogs-4.17: geometry refactoring

PATCH In review Darrick J. Wong 3 participants 34 messages Apr 18, 2018 – May 23, 2018

lore
Share & tools
lore
#0 lore raw

cover xfsprogs-4.17: geometry refactoring

Hi all,

This series refactors geometry reporting in xfsprogs. First we move the platform support code to libfrog where it belongs. Next we hoist the fsgeometry generation function to libxfs, then add some libfrog functions to print fsgeometry structures. Next we add a command to xfs_db to print the geometry information of the loaded filesystem. Finally, we move online geometry reporting from growfs to spaceman and refactor xfs_info to call spaceman or db depending on the passed in command line argument. This series is largely unchanged from the previous posting for 4.16.

This probably won't eat your data, and the branch[2] should apply against for-next.

--D

[1] https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=djwong-devel

#1 lore raw

PATCH 1/9 libfrog: move platform specific runtime support code out of libxfs

From: Darrick J. Wong <[email protected]>

Move the platform support code to libfrog, which should remove the final dependency of libfrog on libxfs. libfrog is the runtime support library, and these files provide platform support.

---
 libfrog/Makefile  |    4 +
 libfrog/darwin.c  |  148 ++++++++++++++++++++++++++++++
 libfrog/freebsd.c |  205 +++++++++++++++++++++++++++++++++++++++++
 libfrog/irix.c    |  115 +++++++++++++++++++++++
 libfrog/linux.c   |  265 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 libxfs/Makefile   |    3 -
 libxfs/darwin.c   |  148 ------------------------------
 libxfs/freebsd.c  |  205 -----------------------------------------
 libxfs/irix.c     |  115 -----------------------
 libxfs/linux.c    |  265 -----------------------------------------------------
 10 files changed, 737 insertions(+), 736 deletions(-)
 create mode 100644 libfrog/darwin.c
 create mode 100644 libfrog/freebsd.c
 create mode 100644 libfrog/irix.c
 create mode 100644 libfrog/linux.c
 delete mode 100644 libxfs/darwin.c
 delete mode 100644 libxfs/freebsd.c
 delete mode 100644 libxfs/irix.c
 delete mode 100644 libxfs/linux.c
libfrog/Makefile +4 -0
index 230b08f..21bb5b7 100644
@@ -22,6 +22,10 @@ topology.c \
 util.c \
 workqueue.c
 
+CFILES += $(PKG_PLATFORM).c
+PCFILES = darwin.c freebsd.c irix.c linux.c
+LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
+
 ifeq ($(HAVE_GETMNTENT),yes)
 LCFLAGS += -DHAVE_GETMNTENT
 endif
libfrog/darwin.c new file +148 -0

148 lines not on this page · raw message

libfrog/freebsd.c new file +205 -0

205 lines not on this page · raw message

libfrog/irix.c new file +115 -0

115 lines not on this page · raw message

libfrog/linux.c new file +265 -0

265 lines not on this page · raw message

libxfs/Makefile +0 -3
index 0470f5f..7cde18d 100644
@@ -97,9 +97,6 @@ CFILES = cache.c \
 	xfs_symlink_remote.c \
 	xfs_trans_resv.c
 
-CFILES += $(PKG_PLATFORM).c
-PCFILES = darwin.c freebsd.c irix.c linux.c
-LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
 LSRCFILES += gen_crc32table.c
 
 #
libxfs/darwin.c deleted +0 -148

148 lines not on this page · raw message

libxfs/freebsd.c deleted +0 -205

205 lines not on this page · raw message

libxfs/irix.c deleted +0 -115

115 lines not on this page · raw message

libxfs/linux.c deleted +0 -265

265 lines not on this page · raw message

Reviewed-by on v1 1/9
#2 lore raw

Re: [PATCH 1/9] libfrog: move platform specific runtime support code out of libxfs

Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move the platform support code to libfrog, which should remove the final dependency of libfrog on libxfs. libfrog is the runtime support library, and these files provide platform support.

#3 lore raw

PATCH 2/9 libfrog: refactor fs geometry printing function

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move the fs geometry printing function to libfrog so that mkfs and others can share.

---
 include/fsgeom.h |   24 ++++++++++++++++
 libfrog/Makefile |    1 +
 libfrog/fsgeom.c |   82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+)
 create mode 100644 include/fsgeom.h
 create mode 100644 libfrog/fsgeom.c
include/fsgeom.h new file +24 -0
new file mode 100644
index 0000000..acf11bf
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+#ifndef _LIBFROG_FSGEOM_H_
+#define _LIBFROG_FSGEOM_H_
+
+void xfs_report_geom(struct xfs_fsop_geom *geo, const char *mntpoint,
+		const char *logname, const char *rtname);
+
+#endif /* _LIBFROG_FSGEOM_H_ */
libfrog/Makefile +1 -0
index 21bb5b7..f682829 100644
@@ -13,6 +13,7 @@ LT_AGE = 0
 CFILES = \
 avl64.c \
 convert.c \
+fsgeom.c \
 list_sort.c \
 paths.c \
 projects.c \
libfrog/fsgeom.c new file +82 -0

82 lines not on this page · raw message

#5 lore raw

Re: [PATCH 2/9] libfrog: refactor fs geometry printing function

In reply to Darrick J. Wong
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move the fs geometry printing function to libfrog so that mkfs and others can share.

libfrog/fsgeom.c new file +1 -0
+	printf(_(

libfrog/fsgeom.c line 67

Quoted 10 lines
libfrog/fsgeom.c new file +10 -0
+"meta-data=%-22s isize=%-6d agcount=%u, agsize=%u blks\n"
+"         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
+"         =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u\n"
+"         =%-22s reflink=%u\n"
+"data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
+"         =%-22s sunit=%-6u swidth=%u blks\n"
+"naming   =version %-14u bsize=%-6u ascii-ci=%d, ftype=%d\n"
+"log      =%-22s bsize=%-6d blocks=%u, version=%d\n"
+"         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
+"realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),

Actually, I'd like to put a whitespace break here as there was in old code, as this is a giant, dense blob of code that's pretty hard to grok visually.

Any objection? :)

-Eric

Quoted 21 lines
libfrog/fsgeom.c new file +15 -1
+		mntpoint, geo->inodesize, geo->agcount, geo->agblocks,
+		"", geo->sectsize, attrversion, projid32bit,
+		"", crcs_enabled, finobt_enabled, spinodes, rmapbt_enabled,
+		"", reflink_enabled,
+		"", geo->blocksize, (unsigned long long)geo->datablocks,
+			geo->imaxpct,
+		"", geo->sunit, geo->swidth,
+		dirversion, geo->dirblocksize, cimode, ftype_enabled,
+		isint ? _("internal log") : logname ? logname : _("external"),
+			geo->blocksize, geo->logblocks, logversion,
+		"", geo->logsectsize, geo->logsunit / geo->blocksize, lazycount,
+		!geo->rtblocks ? _("none") : rtname ? rtname : _("external"),
+		geo->rtextsize * geo->blocksize, (unsigned long long)geo->rtblocks,
+			(unsigned long long)geo->rtextents);
+}
 
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

Re: [PATCH 2/9] libfrog: refactor fs geometry printing function

Quoted 24 lines · Eric Sandeen
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move the fs geometry printing function to libfrog so that mkfs and others can share.

libfrog/fsgeom.c new file +1 -0
+	printf(_(

libfrog/fsgeom.c line 67

Quoted 10 lines
libfrog/fsgeom.c new file +10 -0
+"meta-data=%-22s isize=%-6d agcount=%u, agsize=%u blks\n"
+"         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
+"         =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u\n"
+"         =%-22s reflink=%u\n"
+"data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
+"         =%-22s sunit=%-6u swidth=%u blks\n"
+"naming   =version %-14u bsize=%-6u ascii-ci=%d, ftype=%d\n"
+"log      =%-22s bsize=%-6d blocks=%u, version=%d\n"
+"         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
+"realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),

Actually, I'd like to put a whitespace break here as there was in old code, as this is a giant, dense blob of code that's pretty hard to grok visually.

Quoted 1 line

Any objection? :)

None here.

--D

Quoted 27 lines

-Eric

Quoted 17 lines
libfrog/fsgeom.c new file +15 -1
+		mntpoint, geo->inodesize, geo->agcount, geo->agblocks,
+		"", geo->sectsize, attrversion, projid32bit,
+		"", crcs_enabled, finobt_enabled, spinodes, rmapbt_enabled,
+		"", reflink_enabled,
+		"", geo->blocksize, (unsigned long long)geo->datablocks,
+			geo->imaxpct,
+		"", geo->sunit, geo->swidth,
+		dirversion, geo->dirblocksize, cimode, ftype_enabled,
+		isint ? _("internal log") : logname ? logname : _("external"),
+			geo->blocksize, geo->logblocks, logversion,
+		"", geo->logsectsize, geo->logsunit / geo->blocksize, lazycount,
+		!geo->rtblocks ? _("none") : rtname ? rtname : _("external"),
+		geo->rtextsize * geo->blocksize, (unsigned long long)geo->rtblocks,
+			(unsigned long long)geo->rtextents);
+}
 
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

PATCH 3/9 mkfs: use geometry generation / helper functions

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Since libxfs now has a function to fill out the geometry structure and libfrog has a function to pretty-print the geometry, have mkfs use the two helpers instead of open-coding it.

---
 libxfs/libxfs_api_defs.h |    1 +
 mkfs/xfs_mkfs.c          |   54 ++++++++++++++--------------------------------
 2 files changed, 18 insertions(+), 37 deletions(-)
libxfs/libxfs_api_defs.h +1 -0
index 78daca0..09f1428 100644
@@ -152,5 +152,6 @@
 #define xfs_rmap_compare		libxfs_rmap_compare
 #define xfs_dir_get_ops			libxfs_dir_get_ops
 #define xfs_default_ifork_ops		libxfs_default_ifork_ops
+#define xfs_fs_geometry			libxfs_fs_geometry
 
 #endif /* __LIBXFS_API_DEFS_H__ */
mkfs/xfs_mkfs.c +17 -37

76 lines not on this page · raw message

Reviewed-by on v1 3/9
#8 lore raw

Re: [PATCH 3/9] mkfs: use geometry generation / helper functions

Quoted 7 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Since libxfs now has a function to fill out the geometry structure and libfrog has a function to pretty-print the geometry, have mkfs use the two helpers instead of open-coding it.

We should make (lib)xfs_fs_geometry a void and get rid of the pointless error handling, but that's a patch for another day.

#9 lore raw

PATCH 4/9 xfs_db: add a superblock info command

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---
 db/Makefile       |    2 +
 db/command.c      |    1 +
 db/command.h      |    1 +
 db/info.c         |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/xfs_db.8 |    6 ++++
 5 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 db/info.c
db/Makefile +1 -1
index 6caa634..c73d7f2 100644
@@ -14,7 +14,7 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \
 	io.h logformat.h malloc.h metadump.h output.h print.h quit.h sb.h \
 	sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h \
 	fuzz.h
-CFILES = $(HFILES:.h=.c) btdump.c
+CFILES = $(HFILES:.h=.c) btdump.c info.c
 LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
 
 LLDLIBS	= $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD)
db/command.c +1 -0
index 12ae5b7..087955e 100644
@@ -136,6 +136,7 @@ init_commands(void)
 	fsmap_init();
 	help_init();
 	hash_init();
+	info_init();
 	inode_init();
 	input_init();
 	logres_init();
db/command.h +1 -0
index 9b4ed2d..84cd0b1 100644
@@ -41,3 +41,4 @@ extern const cmdinfo_t	*find_command(const char *cmd);
 extern void		init_commands(void);
 
 extern void		btdump_init(void);
+extern void		info_init(void);
db/info.c new file +74 -0

74 lines not on this page · raw message

man/man8/xfs_db.8 +6 -0
index 524b1ef..e29821e 100644
@@ -670,6 +670,12 @@ using the hash function of the XFS directory and attribute implementation.
 .BI "help [" command ]
 Print help for one or all commands.
 .TP
+.B info
+Displays selected geometry information about the filesystem.
+The output will have the same format that
+.BR "mkfs.xfs" "(8)"
+prints when creating a filesystem.
+.TP
 .BI "inode [" inode# ]
 Set the current inode number. If no
 .I inode#
#10 lore raw

Re: [PATCH 4/9] xfs_db: add a superblock info command

Quoted 3 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

This seems ... fine, it's a bit out of xfs_db's charter but ... I see where you're going with this ... ;)

A little nitpicky below though.

db/info.c line 32

Quoted 7 lines
db/info.c new file +7 -0
+static void
+info_help(void)
+{
+	dbprintf(_(
+"\n"
+" Pretty-prints the filesystem geometry as derived from the superblock.\n"
+" The output has the same format as mkfs.\n"

mkfs.xfs, xfs_info, and other utilities. ?

Quoted 24 lines

+"\n"

db/info.c new file +23 -0
+));
+
+}
+
+static int
+info_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	geo;
+	int			error;
+
+	error = -libxfs_fs_geometry(&mp->m_sb, &geo,
+			XFS_FS_GEOM_MAX_STRUCT_VER);
+	if (error) {
+		dbprintf(_("could not obtain geometry\n"));
+		exitcode = 1;
+		return 0;
+	}
+
+	xfs_report_geom(&geo, fsdevice, x.logname, x.rtname);
+	return 0;
+}

db/info.c line 66

Quoted 10 lines
db/info.c new file +10 -0
+
+static const struct cmdinfo info_cmd = {
+	.name =		"info",
+	.altname =	"i",
+	.cfunc =	info_f,
+	.argmin =	0,
+	.argmax =	0,
+	.canpush =	0,
+	.args =		NULL,
+	.oneline =	N_("dump superblock info"),

"pretty-print superblock geometry info" ?

Quoted 13 lines
db/info.c new file +8 -0
+	.help =		info_help,
+};
+
+void
+info_init(void)
+{
+	add_command(&info_cmd);
+}
man/man8/xfs_db.8 +0 -0
index 524b1ef..e29821e 100644

man/man8/xfs_db.8 using the hash function of the XFS directory and attribute implementation. · line 677

Quoted 8 lines
man/man8/xfs_db.8 +5 -0
@@ -670,6 +670,12 @@ using the hash function of the XFS directory and attribute implementation.
 .BI "help [" command ]
 Print help for one or all commands.
 .TP
+.B info
+Displays selected geometry information about the filesystem.
+The output will have the same format that
+.BR "mkfs.xfs" "(8)"
+prints when creating a filesystem.

Again adding xfs_info here might be nice too?

Just seems a little odd to single out one utility, not a huge deal tho.

I could just add these if you agree. Or drop it if not ;)

Quoted 4 lines
man/man8/xfs_db.8 +1 -0
+.TP
 .BI "inode [" inode# ]
 Set the current inode number. If no
 .I inode#
#11 lore raw

Re: [PATCH 4/9] xfs_db: add a superblock info command

Quoted 10 lines · Eric Sandeen
Quoted 3 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

This seems ... fine, it's a bit out of xfs_db's charter but ... I see where you're going with this ... ;)

A little nitpicky below though.

Quoted 9 lines

db/info.c line 32

Quoted 7 lines
db/info.c new file +7 -0
+static void
+info_help(void)
+{
+	dbprintf(_(
+"\n"
+" Pretty-prints the filesystem geometry as derived from the superblock.\n"
+" The output has the same format as mkfs.\n"

mkfs.xfs, xfs_info, and other utilities. ?

Ok. It seems a little ouroborousy for one of the (future) xfs_info backends to say that it behaves like xfs_info but eh that's fine. :)

Quoted 28 lines
Quoted 28 lines

+"\n"

db/info.c new file +27 -0
+));
+
+}
+
+static int
+info_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	geo;
+	int			error;
+
+	error = -libxfs_fs_geometry(&mp->m_sb, &geo,
+			XFS_FS_GEOM_MAX_STRUCT_VER);
+	if (error) {
+		dbprintf(_("could not obtain geometry\n"));
+		exitcode = 1;
+		return 0;
+	}
+
+	xfs_report_geom(&geo, fsdevice, x.logname, x.rtname);
+	return 0;
+}
+
+static const struct cmdinfo info_cmd = {
+	.name =		"info",
+	.altname =	"i",
Quoted 8 lines

db/info.c line 66

Quoted 6 lines
db/info.c new file +6 -0
+	.cfunc =	info_f,
+	.argmin =	0,
+	.argmax =	0,
+	.canpush =	0,
+	.args =		NULL,
+	.oneline =	N_("dump superblock info"),

"pretty-print superblock geometry info" ?

Ok.

Quoted 24 lines
Quoted 13 lines
db/info.c new file +8 -0
+	.help =		info_help,
+};
+
+void
+info_init(void)
+{
+	add_command(&info_cmd);
+}
man/man8/xfs_db.8 +0 -0
index 524b1ef..e29821e 100644

man/man8/xfs_db.8 using the hash function of the XFS directory and attribute implementation. · line 677

Quoted 8 lines
man/man8/xfs_db.8 +5 -0
@@ -670,6 +670,12 @@ using the hash function of the XFS directory and attribute implementation.
 .BI "help [" command ]
 Print help for one or all commands.
 .TP
+.B info
+Displays selected geometry information about the filesystem.
+The output will have the same format that
+.BR "mkfs.xfs" "(8)"
+prints when creating a filesystem.

Again adding xfs_info here might be nice too?

Quoted 3 lines

Just seems a little odd to single out one utility, not a huge deal tho.

I could just add these if you agree. Or drop it if not ;)

Sure, it's fine by me.

--D

Quoted 9 lines

man/man8/xfs_db.8 using the hash function of the XFS directory and attribute implementation. · line 681

Quoted 4 lines
man/man8/xfs_db.8 +1 -0
+.TP
 .BI "inode [" inode# ]
 Set the current inode number. If no
 .I inode#

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

PATCH v2 4/9 xfs_db: add a superblock info command

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---
 db/Makefile       |    2 +
 db/command.c      |    1 +
 db/command.h      |    1 +
 db/info.c         |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/xfs_db.8 |    8 ++++++
 5 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 db/info.c
db/Makefile +1 -1
index 6caa6348..c73d7f25 100644
@@ -14,7 +14,7 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \
 	io.h logformat.h malloc.h metadump.h output.h print.h quit.h sb.h \
 	sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h \
 	fuzz.h
-CFILES = $(HFILES:.h=.c) btdump.c
+CFILES = $(HFILES:.h=.c) btdump.c info.c
 LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
 
 LLDLIBS	= $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD)
db/command.c +1 -0
index 12ae5b78..087955e0 100644
@@ -136,6 +136,7 @@ init_commands(void)
 	fsmap_init();
 	help_init();
 	hash_init();
+	info_init();
 	inode_init();
 	input_init();
 	logres_init();
db/command.h +1 -0
index 9b4ed2d7..84cd0b10 100644
@@ -41,3 +41,4 @@ extern const cmdinfo_t	*find_command(const char *cmd);
 extern void		init_commands(void);
 
 extern void		btdump_init(void);
+extern void		info_init(void);
db/info.c new file +74 -0

74 lines not on this page · raw message

man/man8/xfs_db.8 +8 -0
index 524b1ef6..10f2beb9 100644
@@ -670,6 +670,14 @@ using the hash function of the XFS directory and attribute implementation.
 .BI "help [" command ]
 Print help for one or all commands.
 .TP
+.B info
+Displays selected geometry information about the filesystem.
+The output will have the same format that
+.BR "mkfs.xfs" "(8)"
+prints when creating a filesystem or
+.BR "xfs_info" "(8)"
+prints when querying a filesystem.
+.TP
 .BI "inode [" inode# ]
 Set the current inode number. If no
 .I inode#
#13 lore raw

Re: [PATCH v2 4/9] xfs_db: add a superblock info command

Alrighty, looks ok.

Reviewed by: Allison Henderson <[email protected]>

Quoted 152 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---
  db/Makefile       |    2 +
  db/command.c      |    1 +
  db/command.h      |    1 +
  db/info.c         |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
  man/man8/xfs_db.8 |    8 ++++++
  5 files changed, 85 insertions(+), 1 deletion(-)

create mode 100644 db/info.c

db/Makefile +1 -1
index 6caa6348..c73d7f25 100644
@@ -14,7 +14,7 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \
  	io.h logformat.h malloc.h metadump.h output.h print.h quit.h sb.h \
  	sig.h strvec.h text.h type.h write.h attrset.h symlink.h fsmap.h \
  	fuzz.h
-CFILES = $(HFILES:.h=.c) btdump.c
+CFILES = $(HFILES:.h=.c) btdump.c info.c
  LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
 
  LLDLIBS	= $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD)
db/command.c +1 -0
index 12ae5b78..087955e0 100644
@@ -136,6 +136,7 @@ init_commands(void)
  	fsmap_init();
  	help_init();
  	hash_init();
+	info_init();
  	inode_init();
  	input_init();
  	logres_init();
db/command.h +1 -0
index 9b4ed2d7..84cd0b10 100644
@@ -41,3 +41,4 @@ extern const cmdinfo_t	*find_command(const char *cmd);
  extern void		init_commands(void);
 
  extern void		btdump_init(void);
+extern void		info_init(void);
db/info.c new file +74 -0
new file mode 100644
index 00000000..05b3c1f0
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 Oracle.  All Rights Reserved.
+ *
+ * Author: Darrick J. Wong <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+#include "libxfs.h"
+#include "command.h"
+#include "init.h"
+#include "output.h"
+#include "fsgeom.h"
+
+static void
+info_help(void)
+{
+	dbprintf(_(
+"\n"
+" Pretty-prints the filesystem geometry as derived from the superblock.\n"
+" The output has the same format as mkfs.xfs, xfs_info, and other utilities.\n"
+"\n"
+));
+
+}
+
+static int
+info_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	geo;
+	int			error;
+
+	error = -libxfs_fs_geometry(&mp->m_sb, &geo,
+			XFS_FS_GEOM_MAX_STRUCT_VER);
+	if (error) {
+		dbprintf(_("could not obtain geometry\n"));
+		exitcode = 1;
+		return 0;
+	}
+
+	xfs_report_geom(&geo, fsdevice, x.logname, x.rtname);
+	return 0;
+}
+
+static const struct cmdinfo info_cmd = {
+	.name =		"info",
+	.altname =	"i",
+	.cfunc =	info_f,
+	.argmin =	0,
+	.argmax =	0,
+	.canpush =	0,
+	.args =		NULL,
+	.oneline =	N_("pretty-print superblock info"),
+	.help =		info_help,
+};
+
+void
+info_init(void)
+{
+	add_command(&info_cmd);
+}
man/man8/xfs_db.8 +8 -1
index 524b1ef6..10f2beb9 100644
@@ -670,6 +670,14 @@ using the hash function of the XFS directory and attribute implementation.
  .BI "help [" command ]
  Print help for one or all commands.
  .TP
+.B info
+Displays selected geometry information about the filesystem.
+The output will have the same format that
+.BR "mkfs.xfs" "(8)"
+prints when creating a filesystem or
+.BR "xfs_info" "(8)"
+prints when querying a filesystem.
+.TP
  .BI "inode [" inode# ]
  Set the current inode number. If no
  .I inode#
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DwIBAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=LHZQ8fHvy6wDKXGTWcm97burZH5sQKHRDMaY1UthQxc&m=C4CGnxIhMfo-ZhlFRisC8dnLAsedNv4JxrtRdRDlaZ4&s=-VqBB1V3hpBVGR47wcYi0laLhS-aFZIqDbn6xsx5IUM&e=

#14 lore raw

PATCH 5/9 xfs_spaceman: print a nicer message when the file path isn't on an xfs

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the file path passed in is not something on an xfs filesystem, print a nice message about that instead of yelling about ioctls.

---
 spaceman/file.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
spaceman/file.c +2 -1
index 4c13b4a..4f9f66c 100644
@@ -69,7 +69,8 @@ openfile(
 	}
 
 	if (ioctl(fd, XFS_IOC_FSGEOMETRY, geom) < 0) {
-		perror("XFS_IOC_FSGEOMETRY");
+		fprintf(stderr, _("%s: Not on a mounted XFS filesystem.\n"),
+				path);
 		close(fd);
 		return -1;
 	}
#15 lore raw

Re: [PATCH 5/9] xfs_spaceman: print a nicer message when the file path isn't on an xfs

Quoted 4 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the file path passed in is not something on an xfs filesystem, print a nice message about that instead of yelling about ioctls.

Assumes that -ENOTTY is the only possible error though...

Maybe:

if (errno == ENOTTY)
printf("nice thing")
else

	perror("XFS_IOC_FSGEOMETRY");

?

Not a lot else that should go wrong today (EFAULT?) but assuming only one thing could go wrong seems wrong.

Quoted 26 lines
---
 spaceman/file.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
spaceman/file.c +2 -2
index 4c13b4a..4f9f66c 100644
@@ -69,7 +69,8 @@ openfile(
 	}
 
 	if (ioctl(fd, XFS_IOC_FSGEOMETRY, geom) < 0) {
-		perror("XFS_IOC_FSGEOMETRY");
+		fprintf(stderr, _("%s: Not on a mounted XFS filesystem.\n"),
+				path);
 		close(fd);
 		return -1;
 	}
 
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw

PATCH v2 5/9 xfs_spaceman: print a nicer message when the file path isn't on an xfs

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the file path passed in is not something on an xfs filesystem, print a nice message about that instead of yelling about ioctls.

---
 spaceman/file.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
spaceman/file.c +6 -1
index 4c13b4a8..23f8be1c 100644
@@ -69,7 +69,12 @@ openfile(
 	}
 
 	if (ioctl(fd, XFS_IOC_FSGEOMETRY, geom) < 0) {
-		perror("XFS_IOC_FSGEOMETRY");
+		if (errno == ENOTTY)
+			fprintf(stderr,
+_("%s: Not on a mounted XFS filesystem.\n"),
+					path);
+		else
+			perror("XFS_IOC_FSGEOMETRY");
 		close(fd);
 		return -1;
 	}
#17 lore raw

Re: [PATCH v2 5/9] xfs_spaceman: print a nicer message when the file path isn't on an xfs

Ok, looks good. Thx!

Reviewed by: Allison Henderson <[email protected]>

Quoted 33 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the file path passed in is not something on an xfs filesystem, print a nice message about that instead of yelling about ioctls.

---
  spaceman/file.c |    7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
spaceman/file.c +6 -2
index 4c13b4a8..23f8be1c 100644
@@ -69,7 +69,12 @@ openfile(
  	}
 
  	if (ioctl(fd, XFS_IOC_FSGEOMETRY, geom) < 0) {
-		perror("XFS_IOC_FSGEOMETRY");
+		if (errno == ENOTTY)
+			fprintf(stderr,
+_("%s: Not on a mounted XFS filesystem.\n"),
+					path);
+		else
+			perror("XFS_IOC_FSGEOMETRY");
  		close(fd);
  		return -1;
  	}
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DwIBAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=LHZQ8fHvy6wDKXGTWcm97burZH5sQKHRDMaY1UthQxc&m=c2CCB3K_iIfSsLpTfhw0rxFL87ZYlPnPvGWzEfJ_t2E&s=KTX7FsHojy6HKAINeB5zGTNlqQlJ037Cw09OFK9tBhY&e=

#18 lore raw

PATCH 6/9 xfs_spaceman: add a superblock info command

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---
 man/man8/xfs_spaceman.8 |    7 +++
 spaceman/Makefile       |    2 -
 spaceman/file.c         |    2 +
 spaceman/info.c         |   96 +++++++++++++++++++++++++++++++++++++++++++++++
 spaceman/init.c         |    1 
 spaceman/space.h        |    1 
 6 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 spaceman/info.c
man/man8/xfs_spaceman.8 +7 -0
index e4a9137..12dd04e 100644
@@ -84,6 +84,13 @@ Display a summary of the free space information found.
 .PD
 .RE
 .TP
+.B info
+Displays selected geometry information about the filesystem.
+The opened file must be a mount point of a XFS filesystem.
+The output will have the same format that
+.BR "xfs_info" "(8)"
+prints when querying a filesystem.
+.TP
 .BR "help [ " command " ]"
 Display a brief description of one or all commands.
 .TP
spaceman/Makefile +1 -1
index 8b31030..c1d903b 100644
@@ -7,7 +7,7 @@ include $(TOPDIR)/include/builddefs
 
 LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
-CFILES = init.c file.c prealloc.c trim.c
+CFILES = info.c init.c file.c prealloc.c trim.c
 
 LLDLIBS = $(LIBXCMD) $(LIBFROG)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
spaceman/file.c +2 -0
index 4f9f66c..6adb4f5 100644
@@ -84,6 +84,8 @@ openfile(
 			return -1;
 		}
 		memcpy(fs_path, fsp, sizeof(struct fs_path));
+	} else {
+		memset(fs_path, 0, sizeof(struct fs_path));
 	}
 	return fd;
 }
spaceman/info.c new file +96 -0

96 lines not on this page · raw message

spaceman/init.c +1 -0
index b3eface..895504f 100644
@@ -40,6 +40,7 @@ init_commands(void)
 {
 	print_init();
 	help_init();
+	info_init();
 	prealloc_init();
 	quit_init();
 	trim_init();
spaceman/space.h +1 -0
index 5f4a8a0..d2a2543 100644
@@ -42,5 +42,6 @@ extern void	freesp_init(void);
 #else
 # define freesp_init()	do { } while (0)
 #endif
+extern void	info_init(void);
 
 #endif /* XFS_SPACEMAN_SPACE_H_ */
#19 lore raw

Re: [PATCH 6/9] xfs_spaceman: add a superblock info command

spaceman/file.c openfile(

Quoted 14 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---

spaceman/file.c +0 -0
index 4f9f66c..6adb4f5 100644
@@ -84,6 +84,8 @@ openfile(

char *path,
xfs_fsop_geom_t *geom,
struct fs_path *fs_path)
{
..

        if (fs_path) {

...

spaceman/file.c openfile( · line 89

Quoted 6 lines
spaceman/file.c +2 -0
 			return -1;
 		}
 		memcpy(fs_path, fsp, sizeof(struct fs_path));
+	} else {
+		memset(fs_path, 0, sizeof(struct fs_path));
 	}

so if fs_path == NULL memset(NULL, 0) ?

Not sure what's going on here.

(or maybe I've forgotten how C works)

Quoted 31 lines
spaceman/file.c +0 -0
 	return fd;
 }
spaceman/info.c new file +23 -0
new file mode 100644
index 0000000..b8b8133
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2018 Oracle.  All Rights Reserved.
+ *
+ * Author: Darrick J. Wong <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+#include "libxfs.h"
+#include "command.h"
+#include "init.h"
+#include "path.h"

spaceman/info.c line 33

Quoted 10 lines
spaceman/info.c new file +10 -0
+#include "space.h"
+#include "fsgeom.h"
+
+static void
+info_help(void)
+{
+	printf(_(
+"\n"
+" Pretty-prints the filesystem geometry as derived from the superblock.\n"
+" The output has the same format as mkfs.  The opened file must be a XFS\n"

"an XFS?"

Quoted 20 lines
spaceman/info.c new file +20 -0
+" mount point.\n"
+"\n"
+));
+
+}
+
+static int
+info_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	geo;
+	int			error;
+
+	if (fs_table_lookup_mount(file->name) == NULL) {
+		fprintf(stderr, _("%s: Not a XFS mount point.\n"), file->name);
+		return 1;
+	}
+
+	/* get the current filesystem size & geometry */

spaceman/info.c line 63

Quoted 10 lines
spaceman/info.c new file +10 -0
+	error = ioctl(file->fd, XFS_IOC_FSGEOMETRY, &geo);
+	if (error) {
+		/*
+		 * OK, new xfsctl barfed - back off and try earlier version
+		 * as we're probably running an older kernel version.
+		 * Only field added in the v2 geometry xfsctl is "logsunit"
+		 * so we'll zero that out for later display (as zero).
+		 */
+		geo.logsunit = 0;
+		error = ioctl(file->fd, XFS_IOC_FSGEOMETRY_V1, &geo);

We're certain that it won't fill in logsunit with junk, right? Would it be any safer to set logsunit after or is that presupposing too much about the interface? I guess it's fine.

Quoted 15 lines
spaceman/info.c new file +15 -0
+		if (error) {
+			fprintf(stderr, _(
+				"%s: cannot determine geometry of filesystem"
+				" mounted at %s: %s\n"),
+				progname, file->name, strerror(errno));
+			exitcode = 1;
+			return 0;
+		}
+	}
+
+	xfs_report_geom(&geo, file->fs_path.fs_name, file->fs_path.fs_log,
+			file->fs_path.fs_rt);
+	return 0;
+}
+

spaceman/info.c line 88

Quoted 10 lines
spaceman/info.c new file +10 -0
+static const struct cmdinfo info_cmd = {
+	.name =		"info",
+	.altname =	"i",
+	.cfunc =	info_f,
+	.argmin =	0,
+	.argmax =	0,
+	.canpush =	0,
+	.args =		NULL,
+	.flags =	CMD_FLAG_ONESHOT,
+	.oneline =	N_("dump superblock info"),

"print geometry superblock info"

Quoted 37 lines
spaceman/info.c new file +8 -0
+	.help =		info_help,
+};
+
+void
+info_init(void)
+{
+	add_command(&info_cmd);
+}
spaceman/init.c +1 -0
index b3eface..895504f 100644
@@ -40,6 +40,7 @@ init_commands(void)
 {
 	print_init();
 	help_init();
+	info_init();
 	prealloc_init();
 	quit_init();
 	trim_init();
spaceman/space.h +1 -1
index 5f4a8a0..d2a2543 100644
@@ -42,5 +42,6 @@ extern void	freesp_init(void);
 #else
 # define freesp_init()	do { } while (0)
 #endif
+extern void	info_init(void);
 
 #endif /* XFS_SPACEMAN_SPACE_H_ */
 
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw

Re: [PATCH 6/9] xfs_spaceman: add a superblock info command

Quoted 33 lines · Eric Sandeen

spaceman/file.c openfile(

Quoted 14 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---

spaceman/file.c +0 -0
index 4f9f66c..6adb4f5 100644
@@ -84,6 +84,8 @@ openfile(

char *path,
xfs_fsop_geom_t *geom,
struct fs_path *fs_path)
{
..

        if (fs_path) {

...

spaceman/file.c openfile( · line 89

Quoted 6 lines
spaceman/file.c +2 -0
 			return -1;
 		}
 		memcpy(fs_path, fsp, sizeof(struct fs_path));
+	} else {
+		memset(fs_path, 0, sizeof(struct fs_path));
 	}

so if fs_path == NULL memset(NULL, 0) ?

Quoted 3 lines

Not sure what's going on here.

(or maybe I've forgotten how C works)

Not sure either. The only caller of openfile() always passes in fs_path so the else clause can go away. Bad xfs_io copy pasta, sorry. :(

--D

Quoted 148 lines
Quoted 31 lines
spaceman/file.c +0 -0
 	return fd;
 }
spaceman/info.c new file +23 -0
new file mode 100644
index 0000000..b8b8133
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2018 Oracle.  All Rights Reserved.
+ *
+ * Author: Darrick J. Wong <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+#include "libxfs.h"
+#include "command.h"
+#include "init.h"
+#include "path.h"

spaceman/info.c line 33

Quoted 10 lines
spaceman/info.c new file +10 -0
+#include "space.h"
+#include "fsgeom.h"
+
+static void
+info_help(void)
+{
+	printf(_(
+"\n"
+" Pretty-prints the filesystem geometry as derived from the superblock.\n"
+" The output has the same format as mkfs.  The opened file must be a XFS\n"

"an XFS?"

Quoted 20 lines
spaceman/info.c new file +20 -0
+" mount point.\n"
+"\n"
+));
+
+}
+
+static int
+info_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	geo;
+	int			error;
+
+	if (fs_table_lookup_mount(file->name) == NULL) {
+		fprintf(stderr, _("%s: Not a XFS mount point.\n"), file->name);
+		return 1;
+	}
+
+	/* get the current filesystem size & geometry */

spaceman/info.c line 63

Quoted 10 lines
spaceman/info.c new file +10 -0
+	error = ioctl(file->fd, XFS_IOC_FSGEOMETRY, &geo);
+	if (error) {
+		/*
+		 * OK, new xfsctl barfed - back off and try earlier version
+		 * as we're probably running an older kernel version.
+		 * Only field added in the v2 geometry xfsctl is "logsunit"
+		 * so we'll zero that out for later display (as zero).
+		 */
+		geo.logsunit = 0;
+		error = ioctl(file->fd, XFS_IOC_FSGEOMETRY_V1, &geo);

We're certain that it won't fill in logsunit with junk, right? Would it be any safer to set logsunit after or is that presupposing too much about the interface? I guess it's fine.

Quoted 15 lines
spaceman/info.c new file +15 -0
+		if (error) {
+			fprintf(stderr, _(
+				"%s: cannot determine geometry of filesystem"
+				" mounted at %s: %s\n"),
+				progname, file->name, strerror(errno));
+			exitcode = 1;
+			return 0;
+		}
+	}
+
+	xfs_report_geom(&geo, file->fs_path.fs_name, file->fs_path.fs_log,
+			file->fs_path.fs_rt);
+	return 0;
+}
+

spaceman/info.c line 88

Quoted 10 lines
spaceman/info.c new file +10 -0
+static const struct cmdinfo info_cmd = {
+	.name =		"info",
+	.altname =	"i",
+	.cfunc =	info_f,
+	.argmin =	0,
+	.argmax =	0,
+	.canpush =	0,
+	.args =		NULL,
+	.flags =	CMD_FLAG_ONESHOT,
+	.oneline =	N_("dump superblock info"),

"print geometry superblock info"

Quoted 33 lines
spaceman/info.c new file +8 -0
+	.help =		info_help,
+};
+
+void
+info_init(void)
+{
+	add_command(&info_cmd);
+}
spaceman/init.c +1 -0
index b3eface..895504f 100644
@@ -40,6 +40,7 @@ init_commands(void)
 {
 	print_init();
 	help_init();
+	info_init();
 	prealloc_init();
 	quit_init();
 	trim_init();
spaceman/space.h +1 -1
index 5f4a8a0..d2a2543 100644
@@ -42,5 +42,6 @@ extern void	freesp_init(void);
 #else
 # define freesp_init()	do { } while (0)
 #endif
+extern void	info_init(void);
 
 #endif /* XFS_SPACEMAN_SPACE_H_ */
 
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#21 lore raw

Re: [PATCH 6/9] xfs_spaceman: add a superblock info command

Quoted 34 lines · Darrick J. Wong
Quoted 33 lines · Eric Sandeen

spaceman/file.c openfile(

Quoted 14 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---

spaceman/file.c +0 -0
index 4f9f66c..6adb4f5 100644
@@ -84,6 +84,8 @@ openfile(

char *path,
xfs_fsop_geom_t *geom,
struct fs_path *fs_path)
{
..

        if (fs_path) {

...

spaceman/file.c openfile( · line 89

Quoted 6 lines
spaceman/file.c +2 -0
 			return -1;
 		}
 		memcpy(fs_path, fsp, sizeof(struct fs_path));
+	} else {
+		memset(fs_path, 0, sizeof(struct fs_path));
 	}

so if fs_path == NULL memset(NULL, 0) ?

Quoted 8 lines
Quoted 3 lines

Not sure what's going on here.

(or maybe I've forgotten how C works)

Not sure either. The only caller of openfile() always passes in fs_path so the else clause can go away. Bad xfs_io copy pasta, sorry. :(

--D

Dangit, I missed some comments.

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
spaceman/file.c +0 -0
 	return fd;
 }
spaceman/info.c new file +27 -0
new file mode 100644
index 0000000..b8b8133
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2018 Oracle.  All Rights Reserved.
+ *
+ * Author: Darrick J. Wong <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+#include "libxfs.h"
+#include "command.h"
+#include "init.h"
+#include "path.h"
+#include "space.h"
+#include "fsgeom.h"
+
+static void
Quoted 8 lines
Quoted 8 lines

spaceman/info.c line 33

Quoted 6 lines
spaceman/info.c new file +6 -0
+info_help(void)
+{
+	printf(_(
+"\n"
+" Pretty-prints the filesystem geometry as derived from the superblock.\n"
+" The output has the same format as mkfs.  The opened file must be a XFS\n"

"an XFS?"

Sure.

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
spaceman/info.c new file +26 -0
+" mount point.\n"
+"\n"
+));
+
+}
+
+static int
+info_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	geo;
+	int			error;
+
+	if (fs_table_lookup_mount(file->name) == NULL) {
+		fprintf(stderr, _("%s: Not a XFS mount point.\n"), file->name);
+		return 1;
+	}
+
+	/* get the current filesystem size & geometry */
+	error = ioctl(file->fd, XFS_IOC_FSGEOMETRY, &geo);
+	if (error) {
+		/*
+		 * OK, new xfsctl barfed - back off and try earlier version
+		 * as we're probably running an older kernel version.
+		 * Only field added in the v2 geometry xfsctl is "logsunit"
Quoted 8 lines
Quoted 8 lines

spaceman/info.c line 63

Quoted 4 lines
spaceman/info.c new file +4 -0
+		 * so we'll zero that out for later display (as zero).
+		 */
+		geo.logsunit = 0;
+		error = ioctl(file->fd, XFS_IOC_FSGEOMETRY_V1, &geo);

We're certain that it won't fill in logsunit with junk, right? Would it be any safer to set logsunit after or is that presupposing too much about the interface? I guess it's fine.

The kernel had better not fill logsunit with anything, since it copies the v1 structure back to userspace and the v1 structure isn't long enough to overlay logsunit.

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
spaceman/info.c new file +19 -0
+		if (error) {
+			fprintf(stderr, _(
+				"%s: cannot determine geometry of filesystem"
+				" mounted at %s: %s\n"),
+				progname, file->name, strerror(errno));
+			exitcode = 1;
+			return 0;
+		}
+	}
+
+	xfs_report_geom(&geo, file->fs_path.fs_name, file->fs_path.fs_log,
+			file->fs_path.fs_rt);
+	return 0;
+}
+
+static const struct cmdinfo info_cmd = {
+	.name =		"info",
+	.altname =	"i",
+	.cfunc =	info_f,
Quoted 8 lines
Quoted 8 lines

spaceman/info.c line 88

Quoted 6 lines
spaceman/info.c new file +6 -0
+	.argmin =	0,
+	.argmax =	0,
+	.canpush =	0,
+	.args =		NULL,
+	.flags =	CMD_FLAG_ONESHOT,
+	.oneline =	N_("dump superblock info"),

"print geometry superblock info"

"pretty-print superblock geometry info" ?

--D

Quoted 45 lines
Quoted 32 lines
Quoted 32 lines
spaceman/info.c new file +8 -0
+	.help =		info_help,
+};
+
+void
+info_init(void)
+{
+	add_command(&info_cmd);
+}
spaceman/init.c +1 -0
index b3eface..895504f 100644
@@ -40,6 +40,7 @@ init_commands(void)
 {
 	print_init();
 	help_init();
+	info_init();
 	prealloc_init();
 	quit_init();
 	trim_init();
spaceman/space.h +1 -0
index 5f4a8a0..d2a2543 100644
@@ -42,5 +42,6 @@ extern void	freesp_init(void);
 #else
 # define freesp_init()	do { } while (0)
 #endif
+extern void	info_init(void);
 
 #endif /* XFS_SPACEMAN_SPACE_H_ */
Quoted 9 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#22 lore raw

PATCH v2 6/9 xfs_spaceman: add a superblock info command

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---
 man/man8/xfs_spaceman.8 |    7 +++
 spaceman/Makefile       |    2 -
 spaceman/info.c         |   96 +++++++++++++++++++++++++++++++++++++++++++++++
 spaceman/init.c         |    1 
 spaceman/space.h        |    1 
 6 files changed, 111 insertions(+), 6 deletions(-)
 create mode 100644 spaceman/info.c
man/man8/xfs_spaceman.8 +7 -0
index e4a9137f..12dd04e4 100644
@@ -84,6 +84,13 @@ Display a summary of the free space information found.
 .PD
 .RE
 .TP
+.B info
+Displays selected geometry information about the filesystem.
+The opened file must be a mount point of a XFS filesystem.
+The output will have the same format that
+.BR "xfs_info" "(8)"
+prints when querying a filesystem.
+.TP
 .BR "help [ " command " ]"
 Display a brief description of one or all commands.
 .TP
spaceman/Makefile +1 -1
index 8b310309..c1d903ba 100644
@@ -7,7 +7,7 @@ include $(TOPDIR)/include/builddefs
 
 LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
-CFILES = init.c file.c prealloc.c trim.c
+CFILES = info.c init.c file.c prealloc.c trim.c
 
 LLDLIBS = $(LIBXCMD) $(LIBFROG)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
spaceman/info.c new file +96 -0

96 lines not on this page · raw message

spaceman/init.c +1 -0
index b3efacef..895504f3 100644
@@ -40,6 +40,7 @@ init_commands(void)
 {
 	print_init();
 	help_init();
+	info_init();
 	prealloc_init();
 	quit_init();
 	trim_init();
spaceman/space.h +1 -0
index 5f4a8a0b..d2a25432 100644
@@ -42,5 +42,6 @@ extern void	freesp_init(void);
 #else
 # define freesp_init()	do { } while (0)
 #endif
+extern void	info_init(void);
 
 #endif /* XFS_SPACEMAN_SPACE_H_ */
#23 lore raw

Re: [PATCH v2 6/9] xfs_spaceman: add a superblock info command

OK, you can add my review:
Reviewed by: Allison Henderson <[email protected]>

Quoted 175 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Add an 'info' command to pretty-print the superblock geometry.

---
  man/man8/xfs_spaceman.8 |    7 +++
  spaceman/Makefile       |    2 -
  spaceman/info.c         |   96 +++++++++++++++++++++++++++++++++++++++++++++++
  spaceman/init.c         |    1
  spaceman/space.h        |    1
  6 files changed, 111 insertions(+), 6 deletions(-)

create mode 100644 spaceman/info.c

man/man8/xfs_spaceman.8 +7 -0
index e4a9137f..12dd04e4 100644
@@ -84,6 +84,13 @@ Display a summary of the free space information found.
  .PD
  .RE
  .TP
+.B info
+Displays selected geometry information about the filesystem.
+The opened file must be a mount point of a XFS filesystem.
+The output will have the same format that
+.BR "xfs_info" "(8)"
+prints when querying a filesystem.
+.TP
  .BR "help [ " command " ]"
  Display a brief description of one or all commands.
  .TP
spaceman/Makefile +1 -1
index 8b310309..c1d903ba 100644
@@ -7,7 +7,7 @@ include $(TOPDIR)/include/builddefs
 
  LTCOMMAND = xfs_spaceman
  HFILES = init.h space.h
-CFILES = init.c file.c prealloc.c trim.c
+CFILES = info.c init.c file.c prealloc.c trim.c
 
  LLDLIBS = $(LIBXCMD) $(LIBFROG)
  LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
spaceman/info.c new file +96 -0
new file mode 100644
index 00000000..8889346b
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2018 Oracle.  All Rights Reserved.
+ *
+ * Author: Darrick J. Wong <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+#include "libxfs.h"
+#include "command.h"
+#include "init.h"
+#include "path.h"
+#include "space.h"
+#include "fsgeom.h"
+
+static void
+info_help(void)
+{
+	printf(_(
+"\n"
+" Pretty-prints the filesystem geometry as derived from the superblock.\n"
+" The output has the same format as mkfs.xfs, xfs_info, and other utilities.\n"
+" The opened file must be an XFS mount point.\n"
+"\n"
+));
+
+}
+
+static int
+info_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	geo;
+	int			error;
+
+	if (fs_table_lookup_mount(file->name) == NULL) {
+		fprintf(stderr, _("%s: Not a XFS mount point.\n"), file->name);
+		return 1;
+	}
+
+	/* get the current filesystem size & geometry */
+	error = ioctl(file->fd, XFS_IOC_FSGEOMETRY, &geo);
+	if (error) {
+		/*
+		 * OK, new xfsctl barfed - back off and try earlier version
+		 * as we're probably running an older kernel version.
+		 * Only field added in the v2 geometry xfsctl is "logsunit"
+		 * so we'll zero that out for later display (as zero).
+		 */
+		geo.logsunit = 0;
+		error = ioctl(file->fd, XFS_IOC_FSGEOMETRY_V1, &geo);
+		if (error) {
+			fprintf(stderr, _(
+				"%s: cannot determine geometry of filesystem"
+				" mounted at %s: %s\n"),
+				progname, file->name, strerror(errno));
+			exitcode = 1;
+			return 0;
+		}
+	}
+
+	xfs_report_geom(&geo, file->fs_path.fs_name, file->fs_path.fs_log,
+			file->fs_path.fs_rt);
+	return 0;
+}
+
+static const struct cmdinfo info_cmd = {
+	.name =		"info",
+	.altname =	"i",
+	.cfunc =	info_f,
+	.argmin =	0,
+	.argmax =	0,
+	.canpush =	0,
+	.args =		NULL,
+	.flags =	CMD_FLAG_ONESHOT,
+	.oneline =	N_("pretty-print superblock geometry info"),
+	.help =		info_help,
+};
+
+void
+info_init(void)
+{
+	add_command(&info_cmd);
+}
spaceman/init.c +1 -0
index b3efacef..895504f3 100644
@@ -40,6 +40,7 @@ init_commands(void)
  {
  	print_init();
  	help_init();
+	info_init();
  	prealloc_init();
  	quit_init();
  	trim_init();
spaceman/space.h +1 -1
index 5f4a8a0b..d2a25432 100644
@@ -42,5 +42,6 @@ extern void	freesp_init(void);
  #else
  # define freesp_init()	do { } while (0)
  #endif
+extern void	info_init(void);
 
  #endif /* XFS_SPACEMAN_SPACE_H_ */
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DwIBAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=LHZQ8fHvy6wDKXGTWcm97burZH5sQKHRDMaY1UthQxc&m=lKIJYVcivj2fVCdM5vPO_yQc-0radDye1heAQzr95K0&s=1Qksl8JMsIe6vJnzGPFX_G2ewgIRy-CwoaWCBQSHH2o&e=

#24 lore raw

PATCH 7/9 xfs_info: move to xfs_spaceman

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move xfs_info to be under spaceman so that we can remove growfs -N.

---
 growfs/Makefile      |    2 --
 growfs/xfs_info.sh   |   32 --------------------------------
 spaceman/Makefile    |    2 ++
 spaceman/init.c      |    5 ++++-
 spaceman/xfs_info.sh |   32 ++++++++++++++++++++++++++++++++
 5 files changed, 38 insertions(+), 35 deletions(-)
 delete mode 100755 growfs/xfs_info.sh
 create mode 100755 spaceman/xfs_info.sh
growfs/Makefile +0 -2
index f0190e4..adcd84b 100644
@@ -20,7 +20,6 @@ endif
 
 LTDEPENDENCIES = $(LIBXFS) $(LIBXCMD) $(LIBFROG)
 LLDFLAGS = -static-libtool-libs
-LSRCFILES = xfs_info.sh
 
 default: depend $(LTCOMMAND)
 
@@ -29,7 +28,6 @@ include $(BUILDRULES)
 install: default
 	$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
 	$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
-	$(INSTALL) -m 755 xfs_info.sh $(PKG_SBIN_DIR)/xfs_info
 install-dev:
 
 -include .dep
growfs/xfs_info.sh deleted +0 -32
deleted file mode 100755
index b85f120..0000000
@@ -1,32 +0,0 @@
-#!/bin/sh -f
-#
-# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
-#
-
-OPTS=""
-USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
-
-while getopts "t:V" c
-do
-	case $c in
-	t)	OPTS="-t $OPTARG" ;;
-	V)	xfs_growfs -p xfs_info -V
-		status=$?
-		exit $status
-		;;
-	*)	echo $USAGE 1>&2
-		exit 2
-		;;
-	esac
-done
-set -- extra "$@"
-shift $OPTIND
-case $# in
-	1)	xfs_growfs -p xfs_info -n $OPTS "$1"
-		status=$?
-		;;
-	*)	echo $USAGE 1>&2
-		exit 2
-		;;
-esac
-exit $status
spaceman/Makefile +2 -0
index c1d903b..0d5ae2d 100644
@@ -8,6 +8,7 @@ include $(TOPDIR)/include/builddefs
 LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = info.c init.c file.c prealloc.c trim.c
+LSRCFILES = xfs_info.sh
 
 LLDLIBS = $(LIBXCMD) $(LIBFROG)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
@@ -35,6 +36,7 @@ include $(BUILDRULES)
 install: default
 	$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
 	$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
+	$(INSTALL) -m 755 xfs_info.sh $(PKG_SBIN_DIR)/xfs_info
 install-dev:
 
 -include .dep
spaceman/init.c +4 -1
index 895504f..91c773f 100644
@@ -81,11 +81,14 @@ init(
 	textdomain(PACKAGE);
 
 	fs_table_initialise(0, NULL, 0, NULL);
-	while ((c = getopt(argc, argv, "c:V")) != EOF) {
+	while ((c = getopt(argc, argv, "c:p:V")) != EOF) {
 		switch (c) {
 		case 'c':
 			add_user_command(optarg);
 			break;
+		case 'p':
+			progname = optarg;
+			break;
 		case 'V':
 			printf(_("%s version %s\n"), progname, VERSION);
 			exit(0);
spaceman/xfs_info.sh new file +32 -0
new file mode 100755
index 0000000..5df0a26
@@ -0,0 +1,32 @@
+#!/bin/sh -f
+#
+# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+#
+
+OPTS=""
+USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
+
+while getopts "t:V" c
+do
+	case $c in
+	t)	OPTS="-t $OPTARG" ;;
+	V)	xfs_spaceman -p xfs_info -V
+		status=$?
+		exit $status
+		;;
+	*)	echo $USAGE 1>&2
+		exit 2
+		;;
+	esac
+done
+set -- extra "$@"
+shift $OPTIND
+case $# in
+	1)	xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
+		status=$?
+		;;
+	*)	echo $USAGE 1>&2
+		exit 2
+		;;
+esac
+exit $status
Reviewed-by on v1 7/9
#25 lore raw

Re: [PATCH 7/9] xfs_info: move to xfs_spaceman

Quoted 3 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move xfs_info to be under spaceman so that we can remove growfs -N.

Seems ok in general, though how will this work with Dave's upcoming special subvol-files-no-they're-devices-no-they're-files?

Do we worry about all that later? I guess?

(I guess we don't document -p as it's for internal use)

Modulo that concern,

-Eric

Quoted 154 lines
---
 growfs/Makefile      |    2 --
 growfs/xfs_info.sh   |   32 --------------------------------
 spaceman/Makefile    |    2 ++
 spaceman/init.c      |    5 ++++-
 spaceman/xfs_info.sh |   32 ++++++++++++++++++++++++++++++++
 5 files changed, 38 insertions(+), 35 deletions(-)
 delete mode 100755 growfs/xfs_info.sh
 create mode 100755 spaceman/xfs_info.sh
growfs/Makefile +0 -2
index f0190e4..adcd84b 100644
@@ -20,7 +20,6 @@ endif
 
 LTDEPENDENCIES = $(LIBXFS) $(LIBXCMD) $(LIBFROG)
 LLDFLAGS = -static-libtool-libs
-LSRCFILES = xfs_info.sh
 
 default: depend $(LTCOMMAND)
 
@@ -29,7 +28,6 @@ include $(BUILDRULES)
 install: default
 	$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
 	$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
-	$(INSTALL) -m 755 xfs_info.sh $(PKG_SBIN_DIR)/xfs_info
 install-dev:
 
 -include .dep
growfs/xfs_info.sh deleted +0 -32
deleted file mode 100755
index b85f120..0000000
@@ -1,32 +0,0 @@
-#!/bin/sh -f
-#
-# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
-#
-
-OPTS=""
-USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
-
-while getopts "t:V" c
-do
-	case $c in
-	t)	OPTS="-t $OPTARG" ;;
-	V)	xfs_growfs -p xfs_info -V
-		status=$?
-		exit $status
-		;;
-	*)	echo $USAGE 1>&2
-		exit 2
-		;;
-	esac
-done
-set -- extra "$@"
-shift $OPTIND
-case $# in
-	1)	xfs_growfs -p xfs_info -n $OPTS "$1"
-		status=$?
-		;;
-	*)	echo $USAGE 1>&2
-		exit 2
-		;;
-esac
-exit $status
spaceman/Makefile +2 -0
index c1d903b..0d5ae2d 100644
@@ -8,6 +8,7 @@ include $(TOPDIR)/include/builddefs
 LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = info.c init.c file.c prealloc.c trim.c
+LSRCFILES = xfs_info.sh
 
 LLDLIBS = $(LIBXCMD) $(LIBFROG)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
@@ -35,6 +36,7 @@ include $(BUILDRULES)
 install: default
 	$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
 	$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
+	$(INSTALL) -m 755 xfs_info.sh $(PKG_SBIN_DIR)/xfs_info
 install-dev:
 
 -include .dep
spaceman/init.c +4 -1
index 895504f..91c773f 100644
@@ -81,11 +81,14 @@ init(
 	textdomain(PACKAGE);
 
 	fs_table_initialise(0, NULL, 0, NULL);
-	while ((c = getopt(argc, argv, "c:V")) != EOF) {
+	while ((c = getopt(argc, argv, "c:p:V")) != EOF) {
 		switch (c) {
 		case 'c':
 			add_user_command(optarg);
 			break;
+		case 'p':
+			progname = optarg;
+			break;
 		case 'V':
 			printf(_("%s version %s\n"), progname, VERSION);
 			exit(0);
spaceman/xfs_info.sh new file +32 -1
new file mode 100755
index 0000000..5df0a26
@@ -0,0 +1,32 @@
+#!/bin/sh -f
+#
+# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+#
+
+OPTS=""
+USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
+
+while getopts "t:V" c
+do
+	case $c in
+	t)	OPTS="-t $OPTARG" ;;
+	V)	xfs_spaceman -p xfs_info -V
+		status=$?
+		exit $status
+		;;
+	*)	echo $USAGE 1>&2
+		exit 2
+		;;
+	esac
+done
+set -- extra "$@"
+shift $OPTIND
+case $# in
+	1)	xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
+		status=$?
+		;;
+	*)	echo $USAGE 1>&2
+		exit 2
+		;;
+esac
+exit $status
 
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#26 lore raw

Re: [PATCH 7/9] xfs_info: move to xfs_spaceman

Quoted 9 lines · Eric Sandeen
Quoted 3 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move xfs_info to be under spaceman so that we can remove growfs -N.

Seems ok in general, though how will this work with Dave's upcoming special subvol-files-no-they're-devices-no-they're-files?

Do we worry about all that later? I guess?

I think we can worry about that later seeing as Dave hasn't posted patches recently. :)

Quoted 3 lines

(I guess we don't document -p as it's for internal use)

Modulo that concern,

FWIW this patch just moves xfs_info to use spaceman instead of growfs, so I'll go blather about xfs_db/xfs_spaceman switcheroo in that patch.

--D

Quoted 163 lines

-Eric

Quoted 150 lines
---
 growfs/Makefile      |    2 --
 growfs/xfs_info.sh   |   32 --------------------------------
 spaceman/Makefile    |    2 ++
 spaceman/init.c      |    5 ++++-
 spaceman/xfs_info.sh |   32 ++++++++++++++++++++++++++++++++
 5 files changed, 38 insertions(+), 35 deletions(-)
 delete mode 100755 growfs/xfs_info.sh
 create mode 100755 spaceman/xfs_info.sh
growfs/Makefile +0 -2
index f0190e4..adcd84b 100644
@@ -20,7 +20,6 @@ endif
 
 LTDEPENDENCIES = $(LIBXFS) $(LIBXCMD) $(LIBFROG)
 LLDFLAGS = -static-libtool-libs
-LSRCFILES = xfs_info.sh
 
 default: depend $(LTCOMMAND)
 
@@ -29,7 +28,6 @@ include $(BUILDRULES)
 install: default
 	$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
 	$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
-	$(INSTALL) -m 755 xfs_info.sh $(PKG_SBIN_DIR)/xfs_info
 install-dev:
 
 -include .dep
growfs/xfs_info.sh deleted +0 -32
deleted file mode 100755
index b85f120..0000000
@@ -1,32 +0,0 @@
-#!/bin/sh -f
-#
-# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
-#
-
-OPTS=""
-USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
-
-while getopts "t:V" c
-do
-	case $c in
-	t)	OPTS="-t $OPTARG" ;;
-	V)	xfs_growfs -p xfs_info -V
-		status=$?
-		exit $status
-		;;
-	*)	echo $USAGE 1>&2
-		exit 2
-		;;
-	esac
-done
-set -- extra "$@"
-shift $OPTIND
-case $# in
-	1)	xfs_growfs -p xfs_info -n $OPTS "$1"
-		status=$?
-		;;
-	*)	echo $USAGE 1>&2
-		exit 2
-		;;
-esac
-exit $status
spaceman/Makefile +2 -0
index c1d903b..0d5ae2d 100644
@@ -8,6 +8,7 @@ include $(TOPDIR)/include/builddefs
 LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
 CFILES = info.c init.c file.c prealloc.c trim.c
+LSRCFILES = xfs_info.sh
 
 LLDLIBS = $(LIBXCMD) $(LIBFROG)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
@@ -35,6 +36,7 @@ include $(BUILDRULES)
 install: default
 	$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
 	$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
+	$(INSTALL) -m 755 xfs_info.sh $(PKG_SBIN_DIR)/xfs_info
 install-dev:
 
 -include .dep
spaceman/init.c +4 -1
index 895504f..91c773f 100644
@@ -81,11 +81,14 @@ init(
 	textdomain(PACKAGE);
 
 	fs_table_initialise(0, NULL, 0, NULL);
-	while ((c = getopt(argc, argv, "c:V")) != EOF) {
+	while ((c = getopt(argc, argv, "c:p:V")) != EOF) {
 		switch (c) {
 		case 'c':
 			add_user_command(optarg);
 			break;
+		case 'p':
+			progname = optarg;
+			break;
 		case 'V':
 			printf(_("%s version %s\n"), progname, VERSION);
 			exit(0);
spaceman/xfs_info.sh new file +32 -1
new file mode 100755
index 0000000..5df0a26
@@ -0,0 +1,32 @@
+#!/bin/sh -f
+#
+# Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+#
+
+OPTS=""
+USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
+
+while getopts "t:V" c
+do
+	case $c in
+	t)	OPTS="-t $OPTARG" ;;
+	V)	xfs_spaceman -p xfs_info -V
+		status=$?
+		exit $status
+		;;
+	*)	echo $USAGE 1>&2
+		exit 2
+		;;
+	esac
+done
+set -- extra "$@"
+shift $OPTIND
+case $# in
+	1)	xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
+		status=$?
+		;;
+	*)	echo $USAGE 1>&2
+		exit 2
+		;;
+esac
+exit $status
 
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#27 lore raw

PATCH 8/9 xfs_info: call xfs_db for offline filesystems

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the online filesystem geometry query doesn't work, try using xfs_db to see if we can grab the information offline.

---
 man/man8/xfs_growfs.8 |   47 +-----------------------
 man/man8/xfs_info.8   |   95 +++++++++++++++++++++++++++++++++++++++++++++++++
 spaceman/xfs_info.sh  |   12 +++++-
 3 files changed, 106 insertions(+), 48 deletions(-)
 create mode 100644 man/man8/xfs_info.8
man/man8/xfs_growfs.8 +2 -45
index e23d30e..7e6a387 100644
@@ -11,7 +11,7 @@
 
 .TH xfs_growfs 8
 .SH NAME
-xfs_growfs, xfs_info \- expand an XFS filesystem
+xfs_growfs \- expand an XFS filesystem
 .SH SYNOPSIS
 .B xfs_growfs
 [
@@ -38,16 +38,6 @@ xfs_growfs, xfs_info \- expand an XFS filesystem
 .I mount-point
 .br
 .B xfs_growfs \-V
-.PP
-.br
-.B xfs_info
-[
-.B \-t
-.I mtab
-]
-.I mount-point
-.br
-.B xfs_info \-V
 .SH DESCRIPTION
 .B xfs_growfs
 expands an existing XFS filesystem (see
@@ -59,13 +49,6 @@ is mounted. The filesystem must be mounted to be grown (see
 .BR mount (8)).
 The existing contents of the filesystem are undisturbed, and the added space
 becomes available for additional file storage.
-.PP
-.B xfs_info
-is equivalent to invoking
-.B xfs_growfs
-with the
-.B \-n
-option (see discussion below).
 .SH OPTIONS
 .TP
 .BI "\-d | \-D " size
@@ -169,35 +152,9 @@ reside. In order to grow a filesystem, it is necessary to provide added
 space for it to occupy. Therefore there must be at least one spare new
 disk partition available. Adding the space is often done through the use
 of a logical volume manager.
-.SH "EXAMPLES"
-
-Understanding xfs_info output.
-.PP
-Suppose one has the following "xfs_info /dev/sda" output:
-.PP
-.RS 2
-.Vb
-\&meta-data=/dev/sda      isize=256    agcount=32, agsize=16777184 blks
-\&         =              sectsz=512   attr=2
-\&data     =              bsize=4096   blocks=536869888, imaxpct=5
-\&         =              sunit=32     swidth=128 blks
-\&naming   =version 2     bsize=4096
-\&log      =internal      bsize=4096   blocks=32768, version=2
-\&         =              sectsz=512   sunit=32 blks, lazy-count=1
-\&realtime =none          extsz=524288 blocks=0, rtextents=0
-.Ve
-.RE
-.PP
-
-Here, the data section of the output indicates "bsize=4096",
-meaning the data block size for this filesystem is 4096 bytes.
-This section also shows "sunit=32 swidth=128 blks", which means
-the stripe unit is 32*4096 bytes = 128 kibibytes and the stripe
-width is 128*4096 bytes = 512 kibibytes.
-A single stripe of this filesystem therefore consists
-of four stripe units (128 blocks / 32 blocks per unit).
 .SH SEE ALSO
 .BR mkfs.xfs (8),
+.BR xfs_info (8),
 .BR md (4),
 .BR lvm (8),
 .BR mount (8).
man/man8/xfs_info.8 new file +95 -0

95 lines not on this page · raw message

spaceman/xfs_info.sh +9 -3
index 5df0a26..2e17fd9 100755
@@ -4,7 +4,7 @@
 #
 
 OPTS=""
-USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
+USAGE="Usage: xfs_info [-V] [-t mtab] [mountpoint|device|file]"
 
 while getopts "t:V" c
 do
@@ -22,8 +22,14 @@ done
 set -- extra "$@"
 shift $OPTIND
 case $# in
-	1)	xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
-		status=$?
+	1)
+		if [ -b "$1" ] || [ -f "$1" ]; then
+			xfs_db -p xfs_info -c "info" $OPTS "$1"
+			status=$?
+		else
+			xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
+			status=$?
+		fi
 		;;
 	*)	echo $USAGE 1>&2
 		exit 2
#28 lore raw

Re: [PATCH 8/9] xfs_info: call xfs_db for offline filesystems

Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the online filesystem geometry query doesn't work, try using xfs_db to see if we can grab the information offline.

I'm slightly concerned that having all-singing, all-dancing tools that operate on mounted, unmounted, devices, mountpoints, and images will further encourage people to think that operations on mounted block devices are Just Fine(tm).

But ... I suppose the convenience is worth it.

...

Quoted 10 lines
man/man8/xfs_info.8 new file +4 -0
new file mode 100644
index 0000000..c4c470d
@@ -0,0 +1,95 @@
+.\" Verbatim blocks taken from openssl req manpage content
+.de Vb \" Begin verbatim text
+.ft CW
+.nf

man/man8/xfs_info.8 line 14

Quoted 10 lines
man/man8/xfs_info.8 new file +10 -0
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+
+.TH xfs_info 8
+.SH NAME
+xfs_info, \- display XFS filesystem geometry information

drop the comma pls, or I can do this.

...

Quoted 8 lines
man/man8/xfs_info.8 new file +8 -0
+.BR \-V .
+.SH "EXAMPLES"
+
+Understanding xfs_info output.
+.PP
+Suppose one has the following "xfs_info /dev/sda" output:
+.PP
+.RS 2

man/man8/xfs_info.8 line 80

Quoted 10 lines
man/man8/xfs_info.8 new file +10 -0
+.Vb
+\&meta-data=/dev/sda      isize=256    agcount=32, agsize=16777184 blks
+\&         =              sectsz=512   attr=2
+\&data     =              bsize=4096   blocks=536869888, imaxpct=5
+\&         =              sunit=32     swidth=128 blks
+\&naming   =version 2     bsize=4096
+\&log      =internal log  bsize=4096   blocks=32768, version=2
+\&         =              sectsz=512   sunit=32 blks, lazy-count=1
+\&realtime =none          extsz=524288 blocks=0, rtextents=0
+.Ve

Should we update this to a more modern version? *shrug*

#29 lore raw

Re: [PATCH 8/9] xfs_info: call xfs_db for offline filesystems

Quoted 11 lines · Eric Sandeen
Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the online filesystem geometry query doesn't work, try using xfs_db to see if we can grab the information offline.

I'm slightly concerned that having all-singing, all-dancing tools that operate on mounted, unmounted, devices, mountpoints, and images will further encourage people to think that operations on mounted block devices are Just Fine(tm).

<nod> The current semantics of xfs_info are that one has to feed it a mountpoint, which means the arg is a direct... oh dangit.

# touch mugga
# mount /bin/true mugga --bind
# xfs_info ./mugga 
meta-data=/dev/mapper/system-root isize=512    agcount=4, agsize=1953024 blks

Uh, ok, so the new behavior of xfs_info is that if you pass it a block device or a file it'll try to call xfs_db (assuming it's a fs, fs image file, or I guess future-dchinner subvolume); and if it's any other kind of fs object it'll try spaceman (which requires a mountpoint arg).

Hopefully that's ok with Dave's subvol plans?

Quoted 18 lines

But ... I suppose the convenience is worth it.

...

Quoted 14 lines
man/man8/xfs_info.8 new file +8 -0
new file mode 100644
index 0000000..c4c470d
@@ -0,0 +1,95 @@
+.\" Verbatim blocks taken from openssl req manpage content
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
Quoted 8 lines

man/man8/xfs_info.8 line 14

Quoted 6 lines
man/man8/xfs_info.8 new file +6 -0
+.fi
+..
+
+.TH xfs_info 8
+.SH NAME
+xfs_info, \- display XFS filesystem geometry information

drop the comma pls, or I can do this.

I'll drop it in my patches, though if you don't find any serious problems that warrant a reissue then you should do it.

Quoted 14 lines

...

Quoted 12 lines

+.BR \-V .
+.SH "EXAMPLES"

man/man8/xfs_info.8 new file +10 -0
+
+Understanding xfs_info output.
+.PP
+Suppose one has the following "xfs_info /dev/sda" output:
+.PP
+.RS 2
+.Vb
+\&meta-data=/dev/sda      isize=256    agcount=32, agsize=16777184 blks
+\&         =              sectsz=512   attr=2
+\&data     =              bsize=4096   blocks=536869888, imaxpct=5
Quoted 8 lines
Quoted 6 lines
+\&         =              sunit=32     swidth=128 blks
+\&naming   =version 2     bsize=4096
+\&log      =internal log  bsize=4096   blocks=32768, version=2
+\&         =              sectsz=512   sunit=32 blks, lazy-count=1
+\&realtime =none          extsz=524288 blocks=0, rtextents=0

+.Ve

Should we update this to a more modern version? *shrug*

Yeah probably.

--D

Quoted 7 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#30 lore raw

PATCH v2 8/9 xfs_info: call xfs_db for offline filesystems

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the online filesystem geometry query doesn't work, try using xfs_db to see if we can grab the information offline.

---
 man/man8/xfs_growfs.8 |   47 +-----------------------
 man/man8/xfs_info.8   |   97 +++++++++++++++++++++++++++++++++++++++++++++++++
 spaceman/xfs_info.sh  |   12 +++++-
 3 files changed, 108 insertions(+), 48 deletions(-)
 create mode 100644 man/man8/xfs_info.8
man/man8/xfs_growfs.8 +2 -45
index e23d30e2..7e6a387c 100644
@@ -11,7 +11,7 @@
 
 .TH xfs_growfs 8
 .SH NAME
-xfs_growfs, xfs_info \- expand an XFS filesystem
+xfs_growfs \- expand an XFS filesystem
 .SH SYNOPSIS
 .B xfs_growfs
 [
@@ -38,16 +38,6 @@ xfs_growfs, xfs_info \- expand an XFS filesystem
 .I mount-point
 .br
 .B xfs_growfs \-V
-.PP
-.br
-.B xfs_info
-[
-.B \-t
-.I mtab
-]
-.I mount-point
-.br
-.B xfs_info \-V
 .SH DESCRIPTION
 .B xfs_growfs
 expands an existing XFS filesystem (see
@@ -59,13 +49,6 @@ is mounted. The filesystem must be mounted to be grown (see
 .BR mount (8)).
 The existing contents of the filesystem are undisturbed, and the added space
 becomes available for additional file storage.
-.PP
-.B xfs_info
-is equivalent to invoking
-.B xfs_growfs
-with the
-.B \-n
-option (see discussion below).
 .SH OPTIONS
 .TP
 .BI "\-d | \-D " size
@@ -169,35 +152,9 @@ reside. In order to grow a filesystem, it is necessary to provide added
 space for it to occupy. Therefore there must be at least one spare new
 disk partition available. Adding the space is often done through the use
 of a logical volume manager.
-.SH "EXAMPLES"
-
-Understanding xfs_info output.
-.PP
-Suppose one has the following "xfs_info /dev/sda" output:
-.PP
-.RS 2
-.Vb
-\&meta-data=/dev/sda      isize=256    agcount=32, agsize=16777184 blks
-\&         =              sectsz=512   attr=2
-\&data     =              bsize=4096   blocks=536869888, imaxpct=5
-\&         =              sunit=32     swidth=128 blks
-\&naming   =version 2     bsize=4096
-\&log      =internal      bsize=4096   blocks=32768, version=2
-\&         =              sectsz=512   sunit=32 blks, lazy-count=1
-\&realtime =none          extsz=524288 blocks=0, rtextents=0
-.Ve
-.RE
-.PP
-
-Here, the data section of the output indicates "bsize=4096",
-meaning the data block size for this filesystem is 4096 bytes.
-This section also shows "sunit=32 swidth=128 blks", which means
-the stripe unit is 32*4096 bytes = 128 kibibytes and the stripe
-width is 128*4096 bytes = 512 kibibytes.
-A single stripe of this filesystem therefore consists
-of four stripe units (128 blocks / 32 blocks per unit).
 .SH SEE ALSO
 .BR mkfs.xfs (8),
+.BR xfs_info (8),
 .BR md (4),
 .BR lvm (8),
 .BR mount (8).
man/man8/xfs_info.8 new file +97 -0

97 lines not on this page · raw message

spaceman/xfs_info.sh +9 -3
index 5df0a265..2e17fd91 100755
@@ -4,7 +4,7 @@
 #
 
 OPTS=""
-USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
+USAGE="Usage: xfs_info [-V] [-t mtab] [mountpoint|device|file]"
 
 while getopts "t:V" c
 do
@@ -22,8 +22,14 @@ done
 set -- extra "$@"
 shift $OPTIND
 case $# in
-	1)	xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
-		status=$?
+	1)
+		if [ -b "$1" ] || [ -f "$1" ]; then
+			xfs_db -p xfs_info -c "info" $OPTS "$1"
+			status=$?
+		else
+			xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
+			status=$?
+		fi
 		;;
 	*)	echo $USAGE 1>&2
 		exit 2
#31 lore raw

Re: [PATCH v2 8/9] xfs_info: call xfs_db for offline filesystems

Ok, you can add my review:
Reviewed by: Allison Henderson <[email protected]>

Quoted 232 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

If the online filesystem geometry query doesn't work, try using xfs_db to see if we can grab the information offline.

---
  man/man8/xfs_growfs.8 |   47 +-----------------------
  man/man8/xfs_info.8   |   97 +++++++++++++++++++++++++++++++++++++++++++++++++
  spaceman/xfs_info.sh  |   12 +++++-
  3 files changed, 108 insertions(+), 48 deletions(-)

create mode 100644 man/man8/xfs_info.8

man/man8/xfs_growfs.8 +2 -45
index e23d30e2..7e6a387c 100644
@@ -11,7 +11,7 @@
 
  .TH xfs_growfs 8
  .SH NAME
-xfs_growfs, xfs_info \- expand an XFS filesystem
+xfs_growfs \- expand an XFS filesystem
  .SH SYNOPSIS
  .B xfs_growfs
  [
@@ -38,16 +38,6 @@ xfs_growfs, xfs_info \- expand an XFS filesystem
  .I mount-point
  .br
  .B xfs_growfs \-V
-.PP
-.br
-.B xfs_info
-[
-.B \-t
-.I mtab
-]
-.I mount-point
-.br
-.B xfs_info \-V
  .SH DESCRIPTION
  .B xfs_growfs
  expands an existing XFS filesystem (see
@@ -59,13 +49,6 @@ is mounted. The filesystem must be mounted to be grown (see
  .BR mount (8)).
  The existing contents of the filesystem are undisturbed, and the added space
  becomes available for additional file storage.
-.PP
-.B xfs_info
-is equivalent to invoking
-.B xfs_growfs
-with the
-.B \-n
-option (see discussion below).
  .SH OPTIONS
  .TP
  .BI "\-d | \-D " size
@@ -169,35 +152,9 @@ reside. In order to grow a filesystem, it is necessary to provide added
  space for it to occupy. Therefore there must be at least one spare new
  disk partition available. Adding the space is often done through the use
  of a logical volume manager.
-.SH "EXAMPLES"
-
-Understanding xfs_info output.
-.PP
-Suppose one has the following "xfs_info /dev/sda" output:
-.PP
-.RS 2
-.Vb
-\&meta-data=/dev/sda      isize=256    agcount=32, agsize=16777184 blks
-\&         =              sectsz=512   attr=2
-\&data     =              bsize=4096   blocks=536869888, imaxpct=5
-\&         =              sunit=32     swidth=128 blks
-\&naming   =version 2     bsize=4096
-\&log      =internal      bsize=4096   blocks=32768, version=2
-\&         =              sectsz=512   sunit=32 blks, lazy-count=1
-\&realtime =none          extsz=524288 blocks=0, rtextents=0
-.Ve
-.RE
-.PP
-
-Here, the data section of the output indicates "bsize=4096",
-meaning the data block size for this filesystem is 4096 bytes.
-This section also shows "sunit=32 swidth=128 blks", which means
-the stripe unit is 32*4096 bytes = 128 kibibytes and the stripe
-width is 128*4096 bytes = 512 kibibytes.
-A single stripe of this filesystem therefore consists
-of four stripe units (128 blocks / 32 blocks per unit).
  .SH SEE ALSO
  .BR mkfs.xfs (8),
+.BR xfs_info (8),
  .BR md (4),
  .BR lvm (8),
  .BR mount (8).
man/man8/xfs_info.8 new file +97 -0
new file mode 100644
index 00000000..429356a8
@@ -0,0 +1,97 @@
+.\" Verbatim blocks taken from openssl req manpage content
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+
+.TH xfs_info 8
+.SH NAME
+xfs_info \- display XFS filesystem geometry information
+.SH SYNOPSIS
+.B xfs_info
+[
+.B \-t
+.I mtab
+]
+[
+.I mount-point
+|
+.I block-device
+|
+.I file-image
+]
+.br
+.B xfs_info \-V
+.SH DESCRIPTION
+.B xfs_info
+displays geometry information about an existing XFS filesystem.
+The
+.I mount-point
+argument is the pathname of a directory where the filesystem
+is mounted.
+The
+.I block-device
+or
+.I file-image
+contain a raw XFS filesystem.
+The existing contents of the filesystem are undisturbed.
+.SH OPTIONS
+.TP
+.B \-t
+Specifies an alternate mount table file (default is
+.I /proc/mounts
+if it exists, else
+.IR /etc/mtab ).
+This is used when working with filesystems mounted without writing to
+.I /etc/mtab
+file - refer to
+.BR mount (8)
+for further details.
+This option has no effect with the
+.IR block-device " or " file-image
+parameters.
+.TP
+.B \-V
+Prints the version number and exits. The
+.I mount-point
+argument is not required with
+.BR \-V .
+.SH "EXAMPLES"
+
+Understanding xfs_info output.
+.PP
+Suppose one has the following "xfs_info /dev/sda" output:
+.PP
+.RS 2
+.Vb
+\&meta-data=/dev/pmem0             isize=512    agcount=8, agsize=5974144 blks
+\&         =                       sectsz=512   attr=2, projid32bit=1
+\&         =                       crc=1        finobt=1, sparse=1, rmapbt=1
+\&         =                       reflink=1
+\&data     =                       bsize=4096   blocks=47793152, imaxpct=25
+\&         =                       sunit=32     swidth=128 blks
+\&naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
+\&log      =internal log           bsize=4096   blocks=23336, version=2
+\&         =                       sectsz=512   sunit=0 blks, lazy-count=1
+\&realtime =none                   extsz=4096   blocks=0, rtextents=0
+.Ve
+.RE
+.PP
+
+Here, the data section of the output indicates "bsize=4096",
+meaning the data block size for this filesystem is 4096 bytes.
+This section also shows "sunit=32 swidth=128 blks", which means
+the stripe unit is 32*4096 bytes = 128 kibibytes and the stripe
+width is 128*4096 bytes = 512 kibibytes.
+A single stripe of this filesystem therefore consists
+of four stripe units (128 blocks / 32 blocks per unit).
+.SH SEE ALSO
+.BR mkfs.xfs (8),
+.BR md (4),
+.BR lvm (8),
+.BR mount (8).
spaceman/xfs_info.sh +9 -4
index 5df0a265..2e17fd91 100755
@@ -4,7 +4,7 @@
  #
 
  OPTS=""
-USAGE="Usage: xfs_info [-V] [-t mtab] mountpoint"
+USAGE="Usage: xfs_info [-V] [-t mtab] [mountpoint|device|file]"
 
  while getopts "t:V" c
  do
@@ -22,8 +22,14 @@ done
  set -- extra "$@"
  shift $OPTIND
  case $# in
-	1)	xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
-		status=$?
+	1)
+		if [ -b "$1" ] || [ -f "$1" ]; then
+			xfs_db -p xfs_info -c "info" $OPTS "$1"
+			status=$?
+		else
+			xfs_spaceman -p xfs_info -c "info" $OPTS "$1"
+			status=$?
+		fi
  		;;
  	*)	echo $USAGE 1>&2
  		exit 2
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DwIBAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=LHZQ8fHvy6wDKXGTWcm97burZH5sQKHRDMaY1UthQxc&m=uRT-Nkq5vtStwvh7rxxmiMIK1XkFKJjNdYWIowr_5RE&s=KrEravyvnIfkZJLlnByf7D3rwq_HRTTeL8E4BGwiaoc&e=

#32 lore raw

PATCH 9/9 xfs_growfs: refactor geometry reporting

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Use the new geometry pretty-printing function.

---
 growfs/xfs_growfs.c |   88 +--------------------------------------------------
 1 file changed, 2 insertions(+), 86 deletions(-)
growfs/xfs_growfs.c +2 -86
index 366176b..8ec445a 100644
@@ -18,6 +18,7 @@
 
 #include "libxfs.h"
 #include "path.h"
+#include "fsgeom.h"
 
 static void
 usage(void)
@@ -42,54 +43,6 @@ Options:\n\
 	exit(2);
 }
 
-void
-report_info(
-	xfs_fsop_geom_t	geo,
-	char		*mntpoint,
-	int		isint,
-	char		*logname,
-	char		*rtname,
-	int		lazycount,
-	int		dirversion,
-	int		logversion,
-	int		attrversion,
-	int		projid32bit,
-	int		crcs_enabled,
-	int		cimode,
-	int		ftype_enabled,
-	int		finobt_enabled,
-	int		spinodes,
-	int		rmapbt_enabled,
-	int		reflink_enabled)
-{
-	printf(_(
-	    "meta-data=%-22s isize=%-6u agcount=%u, agsize=%u blks\n"
-	    "         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
-	    "         =%-22s crc=%-8u finobt=%u spinodes=%u rmapbt=%u\n"
-	    "         =%-22s reflink=%u\n"
-	    "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
-	    "         =%-22s sunit=%-6u swidth=%u blks\n"
-	    "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
-	    "log      =%-22s bsize=%-6u blocks=%u, version=%u\n"
-	    "         =%-22s sectsz=%-5u sunit=%u blks, lazy-count=%u\n"
-	    "realtime =%-22s extsz=%-6u blocks=%llu, rtextents=%llu\n"),
-
-		mntpoint, geo.inodesize, geo.agcount, geo.agblocks,
-		"", geo.sectsize, attrversion, projid32bit,
-		"", crcs_enabled, finobt_enabled, spinodes, rmapbt_enabled,
-		"", reflink_enabled,
-		"", geo.blocksize, (unsigned long long)geo.datablocks,
-			geo.imaxpct,
-		"", geo.sunit, geo.swidth,
-  		dirversion, geo.dirblocksize, cimode, ftype_enabled,
-		isint ? _("internal") : logname ? logname : _("external"),
-			geo.blocksize, geo.logblocks, logversion,
-		"", geo.logsectsize, geo.logsunit / geo.blocksize, lazycount,
-		!geo.rtblocks ? _("none") : rtname ? rtname : _("external"),
-		geo.rtextsize * geo.blocksize, (unsigned long long)geo.rtblocks,
-			(unsigned long long)geo.rtextents);
-}
-
 int
 main(int argc, char **argv)
 {
@@ -97,9 +50,6 @@ main(int argc, char **argv)
 	int			c;	/* current option character */
 	long long		ddsize;	/* device size in 512-byte blocks */
 	int			dflag;	/* -d flag */
-	int			attrversion;/* attribute version number */
-	int			dirversion; /* directory version number */
-	int			logversion; /* log version number */
 	long long		dlsize;	/* device size in 512-byte blocks */
 	long long		drsize;	/* device size in 512-byte blocks */
 	long long		dsize;	/* new data size in fs blocks */
@@ -117,8 +67,6 @@ main(int argc, char **argv)
 	xfs_fsop_geom_t		ngeo;	/* new fs geometry */
 	int			rflag;	/* -r flag */
 	long long		rsize;	/* new rt size in fs blocks */
-	int			ci;	/* ASCII case-insensitive fs */
-	int			lazycount; /* lazy superblock counters */
 	int			xflag;	/* -x flag */
 	char			*fname;	/* mount point name */
 	char			*datadev; /* data device name */
@@ -126,13 +74,6 @@ main(int argc, char **argv)
 	char			*rtdev;	/*   RT device name */
 	fs_path_t		*fs;	/* mount point information */
 	libxfs_init_t		xi;	/* libxfs structure */
-	int			projid32bit;
-	int			crcs_enabled;
-	int			ftype_enabled = 0;
-	int			finobt_enabled;	/* free inode btree */
-	int			spinodes;
-	int			rmapbt_enabled;
-	int			reflink_enabled;
 	char			rpath[PATH_MAX];
 
 	progname = basename(argv[0]);
@@ -253,27 +194,6 @@ main(int argc, char **argv)
 		}
 	}
 	isint = geo.logstart > 0;
-	lazycount = geo.flags & XFS_FSOP_GEOM_FLAGS_LAZYSB ? 1 : 0;
-	dirversion = geo.flags & XFS_FSOP_GEOM_FLAGS_DIRV2 ? 2 : 1;
-	logversion = geo.flags & XFS_FSOP_GEOM_FLAGS_LOGV2 ? 2 : 1;
-	attrversion = geo.flags & XFS_FSOP_GEOM_FLAGS_ATTR2 ? 2 : \
-			(geo.flags & XFS_FSOP_GEOM_FLAGS_ATTR ? 1 : 0);
-	ci = geo.flags & XFS_FSOP_GEOM_FLAGS_DIRV2CI ? 1 : 0;
-	projid32bit = geo.flags & XFS_FSOP_GEOM_FLAGS_PROJID32 ? 1 : 0;
-	crcs_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_V5SB ? 1 : 0;
-	ftype_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_FTYPE ? 1 : 0;
-	finobt_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_FINOBT ? 1 : 0;
-	spinodes = geo.flags & XFS_FSOP_GEOM_FLAGS_SPINODES ? 1 : 0;
-	rmapbt_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_RMAPBT ? 1 : 0;
-	reflink_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_REFLINK ? 1 : 0;
-	if (nflag) {
-		report_info(geo, datadev, isint, logdev, rtdev,
-				lazycount, dirversion, logversion,
-				attrversion, projid32bit, crcs_enabled, ci,
-				ftype_enabled, finobt_enabled, spinodes,
-				rmapbt_enabled, reflink_enabled);
-		exit(0);
-	}
 
 	/*
 	 * Need root access from here on (using raw devices)...
@@ -306,11 +226,7 @@ main(int argc, char **argv)
 		exit(1);
 	}
 
-	report_info(geo, datadev, isint, logdev, rtdev,
-			lazycount, dirversion, logversion,
-			attrversion, projid32bit, crcs_enabled, ci, ftype_enabled,
-			finobt_enabled, spinodes, rmapbt_enabled,
-			reflink_enabled);
+	xfs_report_geom(&geo, datadev, logdev, rtdev);
 
 	ddsize = xi.dsize;
 	dlsize = ( xi.logBBsize? xi.logBBsize :
Reviewed-by on v1 9/9
#33 lore raw

Re: [PATCH 9/9] xfs_growfs: refactor geometry reporting

Quoted 5 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Use the new geometry pretty-printing function.

Quoted 152 lines
---
 growfs/xfs_growfs.c |   88 +--------------------------------------------------
 1 file changed, 2 insertions(+), 86 deletions(-)
growfs/xfs_growfs.c +2 -87
index 366176b..8ec445a 100644
@@ -18,6 +18,7 @@
 
 #include "libxfs.h"
 #include "path.h"
+#include "fsgeom.h"
 
 static void
 usage(void)
@@ -42,54 +43,6 @@ Options:\n\
 	exit(2);
 }
 
-void
-report_info(
-	xfs_fsop_geom_t	geo,
-	char		*mntpoint,
-	int		isint,
-	char		*logname,
-	char		*rtname,
-	int		lazycount,
-	int		dirversion,
-	int		logversion,
-	int		attrversion,
-	int		projid32bit,
-	int		crcs_enabled,
-	int		cimode,
-	int		ftype_enabled,
-	int		finobt_enabled,
-	int		spinodes,
-	int		rmapbt_enabled,
-	int		reflink_enabled)
-{
-	printf(_(
-	    "meta-data=%-22s isize=%-6u agcount=%u, agsize=%u blks\n"
-	    "         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
-	    "         =%-22s crc=%-8u finobt=%u spinodes=%u rmapbt=%u\n"
-	    "         =%-22s reflink=%u\n"
-	    "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
-	    "         =%-22s sunit=%-6u swidth=%u blks\n"
-	    "naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
-	    "log      =%-22s bsize=%-6u blocks=%u, version=%u\n"
-	    "         =%-22s sectsz=%-5u sunit=%u blks, lazy-count=%u\n"
-	    "realtime =%-22s extsz=%-6u blocks=%llu, rtextents=%llu\n"),
-
-		mntpoint, geo.inodesize, geo.agcount, geo.agblocks,
-		"", geo.sectsize, attrversion, projid32bit,
-		"", crcs_enabled, finobt_enabled, spinodes, rmapbt_enabled,
-		"", reflink_enabled,
-		"", geo.blocksize, (unsigned long long)geo.datablocks,
-			geo.imaxpct,
-		"", geo.sunit, geo.swidth,
-  		dirversion, geo.dirblocksize, cimode, ftype_enabled,
-		isint ? _("internal") : logname ? logname : _("external"),
-			geo.blocksize, geo.logblocks, logversion,
-		"", geo.logsectsize, geo.logsunit / geo.blocksize, lazycount,
-		!geo.rtblocks ? _("none") : rtname ? rtname : _("external"),
-		geo.rtextsize * geo.blocksize, (unsigned long long)geo.rtblocks,
-			(unsigned long long)geo.rtextents);
-}
-
 int
 main(int argc, char **argv)
 {
@@ -97,9 +50,6 @@ main(int argc, char **argv)
 	int			c;	/* current option character */
 	long long		ddsize;	/* device size in 512-byte blocks */
 	int			dflag;	/* -d flag */
-	int			attrversion;/* attribute version number */
-	int			dirversion; /* directory version number */
-	int			logversion; /* log version number */
 	long long		dlsize;	/* device size in 512-byte blocks */
 	long long		drsize;	/* device size in 512-byte blocks */
 	long long		dsize;	/* new data size in fs blocks */
@@ -117,8 +67,6 @@ main(int argc, char **argv)
 	xfs_fsop_geom_t		ngeo;	/* new fs geometry */
 	int			rflag;	/* -r flag */
 	long long		rsize;	/* new rt size in fs blocks */
-	int			ci;	/* ASCII case-insensitive fs */
-	int			lazycount; /* lazy superblock counters */
 	int			xflag;	/* -x flag */
 	char			*fname;	/* mount point name */
 	char			*datadev; /* data device name */
@@ -126,13 +74,6 @@ main(int argc, char **argv)
 	char			*rtdev;	/*   RT device name */
 	fs_path_t		*fs;	/* mount point information */
 	libxfs_init_t		xi;	/* libxfs structure */
-	int			projid32bit;
-	int			crcs_enabled;
-	int			ftype_enabled = 0;
-	int			finobt_enabled;	/* free inode btree */
-	int			spinodes;
-	int			rmapbt_enabled;
-	int			reflink_enabled;
 	char			rpath[PATH_MAX];
 
 	progname = basename(argv[0]);
@@ -253,27 +194,6 @@ main(int argc, char **argv)
 		}
 	}
 	isint = geo.logstart > 0;
-	lazycount = geo.flags & XFS_FSOP_GEOM_FLAGS_LAZYSB ? 1 : 0;
-	dirversion = geo.flags & XFS_FSOP_GEOM_FLAGS_DIRV2 ? 2 : 1;
-	logversion = geo.flags & XFS_FSOP_GEOM_FLAGS_LOGV2 ? 2 : 1;
-	attrversion = geo.flags & XFS_FSOP_GEOM_FLAGS_ATTR2 ? 2 : \
-			(geo.flags & XFS_FSOP_GEOM_FLAGS_ATTR ? 1 : 0);
-	ci = geo.flags & XFS_FSOP_GEOM_FLAGS_DIRV2CI ? 1 : 0;
-	projid32bit = geo.flags & XFS_FSOP_GEOM_FLAGS_PROJID32 ? 1 : 0;
-	crcs_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_V5SB ? 1 : 0;
-	ftype_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_FTYPE ? 1 : 0;
-	finobt_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_FINOBT ? 1 : 0;
-	spinodes = geo.flags & XFS_FSOP_GEOM_FLAGS_SPINODES ? 1 : 0;
-	rmapbt_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_RMAPBT ? 1 : 0;
-	reflink_enabled = geo.flags & XFS_FSOP_GEOM_FLAGS_REFLINK ? 1 : 0;
-	if (nflag) {
-		report_info(geo, datadev, isint, logdev, rtdev,
-				lazycount, dirversion, logversion,
-				attrversion, projid32bit, crcs_enabled, ci,
-				ftype_enabled, finobt_enabled, spinodes,
-				rmapbt_enabled, reflink_enabled);
-		exit(0);
-	}
 
 	/*
 	 * Need root access from here on (using raw devices)...
@@ -306,11 +226,7 @@ main(int argc, char **argv)
 		exit(1);
 	}
 
-	report_info(geo, datadev, isint, logdev, rtdev,
-			lazycount, dirversion, logversion,
-			attrversion, projid32bit, crcs_enabled, ci, ftype_enabled,
-			finobt_enabled, spinodes, rmapbt_enabled,
-			reflink_enabled);
+	xfs_report_geom(&geo, datadev, logdev, rtdev);
 
 	ddsize = xi.dsize;
 	dlsize = ( xi.logBBsize? xi.logBBsize :
 
--

To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html