All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] get UUID of mounted filesystems
@ 2023-01-05  0:36 Catherine Hoang
  2023-01-05  0:36 ` [PATCH v3 1/2] xfs_io: add fsuuid command Catherine Hoang
  2023-01-05  0:36 ` [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem Catherine Hoang
  0 siblings, 2 replies; 6+ messages in thread
From: Catherine Hoang @ 2023-01-05  0:36 UTC (permalink / raw)
  To: linux-xfs

Hi all,

This series adds a new fsuuid command and adapts xfs_admin to call xfs_io
when a filesystem is mounted. This is a precursor to enabling xfs_admin to
set the UUID of a mounted filesystem.

v2->v3
- Keep track of which commands require a mounted/unmounted fs
- Return error if both online and offline options are specified

Comments and feedback appreciated!

Catherine

Catherine Hoang (2):
  xfs_io: add fsuuid command
  xfs_admin: get UUID of mounted filesystem

 db/xfs_admin.sh   | 61 +++++++++++++++++++++++++++++++++++++++--------
 io/Makefile       |  6 ++---
 io/fsuuid.c       | 49 +++++++++++++++++++++++++++++++++++++
 io/init.c         |  1 +
 io/io.h           |  1 +
 man/man8/xfs_io.8 |  3 +++
 6 files changed, 108 insertions(+), 13 deletions(-)
 create mode 100644 io/fsuuid.c

-- 
2.25.1


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

* [PATCH v3 1/2] xfs_io: add fsuuid command
  2023-01-05  0:36 [PATCH v3 0/2] get UUID of mounted filesystems Catherine Hoang
@ 2023-01-05  0:36 ` Catherine Hoang
  2023-01-05  0:36 ` [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem Catherine Hoang
  1 sibling, 0 replies; 6+ messages in thread
From: Catherine Hoang @ 2023-01-05  0:36 UTC (permalink / raw)
  To: linux-xfs

Add support for the fsuuid command to retrieve the UUID of a mounted
filesystem.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
 io/Makefile       |  6 +++---
 io/fsuuid.c       | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 io/init.c         |  1 +
 io/io.h           |  1 +
 man/man8/xfs_io.8 |  3 +++
 5 files changed, 57 insertions(+), 3 deletions(-)
 create mode 100644 io/fsuuid.c

diff --git a/io/Makefile b/io/Makefile
index 498174cf..53fef09e 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -10,12 +10,12 @@ LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh
 HFILES = init.h io.h
 CFILES = init.c \
 	attr.c bmap.c bulkstat.c crc32cselftest.c cowextsize.c encrypt.c \
-	file.c freeze.c fsync.c getrusage.c imap.c inject.c label.c link.c \
-	mmap.c open.c parent.c pread.c prealloc.c pwrite.c reflink.c \
+	file.c freeze.c fsuuid.c fsync.c getrusage.c imap.c inject.c label.c \
+	link.c mmap.c open.c parent.c pread.c prealloc.c pwrite.c reflink.c \
 	resblks.c scrub.c seek.c shutdown.c stat.c swapext.c sync.c \
 	truncate.c utimes.c
 
-LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD)
+LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD) $(LIBUUID)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG)
 LLDFLAGS = -static-libtool-libs
 
diff --git a/io/fsuuid.c b/io/fsuuid.c
new file mode 100644
index 00000000..af2f87a2
--- /dev/null
+++ b/io/fsuuid.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2023 Oracle.
+ * All Rights Reserved.
+ */
+
+#include "libxfs.h"
+#include "command.h"
+#include "init.h"
+#include "io.h"
+#include "libfrog/fsgeom.h"
+#include "libfrog/logging.h"
+
+static cmdinfo_t fsuuid_cmd;
+
+static int
+fsuuid_f(
+	int			argc,
+	char			**argv)
+{
+	struct xfs_fsop_geom	fsgeo;
+	int			ret;
+	char			bp[40];
+
+	ret = -xfrog_geometry(file->fd, &fsgeo);
+
+	if (ret) {
+		xfrog_perror(ret, "XFS_IOC_FSGEOMETRY");
+		exitcode = 1;
+	} else {
+		platform_uuid_unparse((uuid_t *)fsgeo.uuid, bp);
+		printf("UUID = %s\n", bp);
+	}
+
+	return 0;
+}
+
+void
+fsuuid_init(void)
+{
+	fsuuid_cmd.name = "fsuuid";
+	fsuuid_cmd.cfunc = fsuuid_f;
+	fsuuid_cmd.argmin = 0;
+	fsuuid_cmd.argmax = 0;
+	fsuuid_cmd.flags = CMD_FLAG_ONESHOT | CMD_NOMAP_OK;
+	fsuuid_cmd.oneline = _("get mounted filesystem UUID");
+
+	add_command(&fsuuid_cmd);
+}
diff --git a/io/init.c b/io/init.c
index 033ed67d..104cd2c1 100644
--- a/io/init.c
+++ b/io/init.c
@@ -56,6 +56,7 @@ init_commands(void)
 	flink_init();
 	freeze_init();
 	fsmap_init();
+	fsuuid_init();
 	fsync_init();
 	getrusage_init();
 	help_init();
diff --git a/io/io.h b/io/io.h
index 64b7a663..fe474faf 100644
--- a/io/io.h
+++ b/io/io.h
@@ -94,6 +94,7 @@ extern void		encrypt_init(void);
 extern void		file_init(void);
 extern void		flink_init(void);
 extern void		freeze_init(void);
+extern void		fsuuid_init(void);
 extern void		fsync_init(void);
 extern void		getrusage_init(void);
 extern void		help_init(void);
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 223b5152..ef7087b3 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -1455,6 +1455,9 @@ This option is not compatible with the
 flag.
 .RE
 .PD
+.TP
+.B fsuuid
+Print the mounted filesystem UUID.
 
 
 .SH OTHER COMMANDS
-- 
2.25.1


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

* [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem
  2023-01-05  0:36 [PATCH v3 0/2] get UUID of mounted filesystems Catherine Hoang
  2023-01-05  0:36 ` [PATCH v3 1/2] xfs_io: add fsuuid command Catherine Hoang
@ 2023-01-05  0:36 ` Catherine Hoang
  2023-01-05 19:47   ` Darrick J. Wong
  2023-01-13  0:15   ` Allison Henderson
  1 sibling, 2 replies; 6+ messages in thread
From: Catherine Hoang @ 2023-01-05  0:36 UTC (permalink / raw)
  To: linux-xfs

Adapt this tool to call xfs_io to retrieve the UUID of a mounted filesystem.
This is a precursor to enabling xfs_admin to set the UUID of a mounted
filesystem.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
---
 db/xfs_admin.sh | 61 +++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 51 insertions(+), 10 deletions(-)

diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
index 409975b2..b73fb3ad 100755
--- a/db/xfs_admin.sh
+++ b/db/xfs_admin.sh
@@ -5,8 +5,11 @@
 #
 
 status=0
+require_offline=""
+require_online=""
 DB_OPTS=""
 REPAIR_OPTS=""
+IO_OPTS=""
 REPAIR_DEV_OPTS=""
 LOG_OPTS=""
 USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
@@ -14,17 +17,37 @@ USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev
 while getopts "c:efjlL:O:pr:uU:V" c
 do
 	case $c in
-	c)	REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;;
-	e)	DB_OPTS=$DB_OPTS" -c 'version extflg'";;
-	f)	DB_OPTS=$DB_OPTS" -f";;
-	j)	DB_OPTS=$DB_OPTS" -c 'version log2'";;
+	c)	REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG
+		require_offline=1
+		;;
+	e)	DB_OPTS=$DB_OPTS" -c 'version extflg'"
+		require_offline=1
+		;;
+	f)	DB_OPTS=$DB_OPTS" -f"
+		require_offline=1
+		;;
+	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
+		require_offline=1
+		;;
 	l)	DB_OPTS=$DB_OPTS" -r -c label";;
-	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";;
-	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG";;
-	p)	DB_OPTS=$DB_OPTS" -c 'version projid32bit'";;
-	r)	REPAIR_DEV_OPTS=" -r '$OPTARG'";;
-	u)	DB_OPTS=$DB_OPTS" -r -c uuid";;
-	U)	DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";;
+	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
+		require_offline=1
+		;;
+	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
+		require_offline=1
+		;;
+	p)	DB_OPTS=$DB_OPTS" -c 'version projid32bit'"
+		require_offline=1
+		;;
+	r)	REPAIR_DEV_OPTS=" -r '$OPTARG'"
+		require_offline=1
+		;;
+	u)	DB_OPTS=$DB_OPTS" -r -c uuid"
+		IO_OPTS=$IO_OPTS" -r -c fsuuid"
+		;;
+	U)	DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'"
+		require_offline=1
+		;;
 	V)	xfs_db -p xfs_admin -V
 		status=$?
 		exit $status
@@ -38,6 +61,24 @@ set -- extra $@
 shift $OPTIND
 case $# in
 	1|2)
+		if mntpt="$(findmnt -t xfs -f -n -o TARGET "$1" 2>/dev/null)"; then
+			# filesystem is mounted
+			if [ -n "$require_offline" ]; then
+				echo "$1: filesystem is mounted."
+				exit 2
+			fi
+
+			if [ -n "$IO_OPTS" ]; then
+				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+			fi
+		fi
+
+		# filesystem is not mounted
+		if [ -n "$require_online" ]; then
+			echo "$1: filesystem is not mounted"
+			exit 2
+		fi
+
 		# Pick up the log device, if present
 		if [ -n "$2" ]; then
 			LOG_OPTS=" -l '$2'"
-- 
2.25.1


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

* Re: [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem
  2023-01-05  0:36 ` [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem Catherine Hoang
@ 2023-01-05 19:47   ` Darrick J. Wong
  2023-01-06  0:37     ` Catherine Hoang
  2023-01-13  0:15   ` Allison Henderson
  1 sibling, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2023-01-05 19:47 UTC (permalink / raw)
  To: Catherine Hoang; +Cc: linux-xfs

On Wed, Jan 04, 2023 at 04:36:13PM -0800, Catherine Hoang wrote:
> Adapt this tool to call xfs_io to retrieve the UUID of a mounted filesystem.
> This is a precursor to enabling xfs_admin to set the UUID of a mounted
> filesystem.
> 
> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> ---
>  db/xfs_admin.sh | 61 +++++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 51 insertions(+), 10 deletions(-)
> 
> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
> index 409975b2..b73fb3ad 100755
> --- a/db/xfs_admin.sh
> +++ b/db/xfs_admin.sh
> @@ -5,8 +5,11 @@
>  #
>  
>  status=0
> +require_offline=""
> +require_online=""
>  DB_OPTS=""
>  REPAIR_OPTS=""
> +IO_OPTS=""
>  REPAIR_DEV_OPTS=""
>  LOG_OPTS=""
>  USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
> @@ -14,17 +17,37 @@ USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev
>  while getopts "c:efjlL:O:pr:uU:V" c
>  do
>  	case $c in
> -	c)	REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;;
> -	e)	DB_OPTS=$DB_OPTS" -c 'version extflg'";;
> -	f)	DB_OPTS=$DB_OPTS" -f";;
> -	j)	DB_OPTS=$DB_OPTS" -c 'version log2'";;
> +	c)	REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG
> +		require_offline=1
> +		;;
> +	e)	DB_OPTS=$DB_OPTS" -c 'version extflg'"
> +		require_offline=1
> +		;;
> +	f)	DB_OPTS=$DB_OPTS" -f"
> +		require_offline=1
> +		;;
> +	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
> +		require_offline=1
> +		;;
>  	l)	DB_OPTS=$DB_OPTS" -r -c label";;

Now that xfs_admin can issue commands directly against mounted
filesystems, I suppose it ought to wire up support for querying and
changing the label as well.  Doing that should be trivial, and
definitely an idea for a separate patch:

# xfs_io -c 'label' /mnt
label = "hi"
# xfs_io -c 'label -s bye' /mnt
label = "bye"
# xfs_io -c 'label' /mnt
label = "bye"

*This* patch looks correct to me, so
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> -	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";;
> -	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG";;
> -	p)	DB_OPTS=$DB_OPTS" -c 'version projid32bit'";;
> -	r)	REPAIR_DEV_OPTS=" -r '$OPTARG'";;
> -	u)	DB_OPTS=$DB_OPTS" -r -c uuid";;
> -	U)	DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";;
> +	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
> +		require_offline=1
> +		;;
> +	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
> +		require_offline=1
> +		;;
> +	p)	DB_OPTS=$DB_OPTS" -c 'version projid32bit'"
> +		require_offline=1
> +		;;
> +	r)	REPAIR_DEV_OPTS=" -r '$OPTARG'"
> +		require_offline=1
> +		;;
> +	u)	DB_OPTS=$DB_OPTS" -r -c uuid"
> +		IO_OPTS=$IO_OPTS" -r -c fsuuid"
> +		;;
> +	U)	DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'"
> +		require_offline=1
> +		;;
>  	V)	xfs_db -p xfs_admin -V
>  		status=$?
>  		exit $status
> @@ -38,6 +61,24 @@ set -- extra $@
>  shift $OPTIND
>  case $# in
>  	1|2)
> +		if mntpt="$(findmnt -t xfs -f -n -o TARGET "$1" 2>/dev/null)"; then
> +			# filesystem is mounted
> +			if [ -n "$require_offline" ]; then
> +				echo "$1: filesystem is mounted."
> +				exit 2
> +			fi
> +
> +			if [ -n "$IO_OPTS" ]; then
> +				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
> +			fi
> +		fi
> +
> +		# filesystem is not mounted
> +		if [ -n "$require_online" ]; then
> +			echo "$1: filesystem is not mounted"
> +			exit 2
> +		fi
> +
>  		# Pick up the log device, if present
>  		if [ -n "$2" ]; then
>  			LOG_OPTS=" -l '$2'"
> -- 
> 2.25.1
> 

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

* Re: [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem
  2023-01-05 19:47   ` Darrick J. Wong
@ 2023-01-06  0:37     ` Catherine Hoang
  0 siblings, 0 replies; 6+ messages in thread
From: Catherine Hoang @ 2023-01-06  0:37 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

> On Jan 5, 2023, at 11:47 AM, Darrick J. Wong <djwong@kernel.org> wrote:
> 
> On Wed, Jan 04, 2023 at 04:36:13PM -0800, Catherine Hoang wrote:
>> Adapt this tool to call xfs_io to retrieve the UUID of a mounted filesystem.
>> This is a precursor to enabling xfs_admin to set the UUID of a mounted
>> filesystem.
>> 
>> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
>> ---
>> db/xfs_admin.sh | 61 +++++++++++++++++++++++++++++++++++++++++--------
>> 1 file changed, 51 insertions(+), 10 deletions(-)
>> 
>> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
>> index 409975b2..b73fb3ad 100755
>> --- a/db/xfs_admin.sh
>> +++ b/db/xfs_admin.sh
>> @@ -5,8 +5,11 @@
>> #
>> 
>> status=0
>> +require_offline=""
>> +require_online=""
>> DB_OPTS=""
>> REPAIR_OPTS=""
>> +IO_OPTS=""
>> REPAIR_DEV_OPTS=""
>> LOG_OPTS=""
>> USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
>> @@ -14,17 +17,37 @@ USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev
>> while getopts "c:efjlL:O:pr:uU:V" c
>> do
>> 	case $c in
>> -	c)	REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;;
>> -	e)	DB_OPTS=$DB_OPTS" -c 'version extflg'";;
>> -	f)	DB_OPTS=$DB_OPTS" -f";;
>> -	j)	DB_OPTS=$DB_OPTS" -c 'version log2'";;
>> +	c)	REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG
>> +		require_offline=1
>> +		;;
>> +	e)	DB_OPTS=$DB_OPTS" -c 'version extflg'"
>> +		require_offline=1
>> +		;;
>> +	f)	DB_OPTS=$DB_OPTS" -f"
>> +		require_offline=1
>> +		;;
>> +	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
>> +		require_offline=1
>> +		;;
>> 	l)	DB_OPTS=$DB_OPTS" -r -c label";;
> 
> Now that xfs_admin can issue commands directly against mounted
> filesystems, I suppose it ought to wire up support for querying and
> changing the label as well.  Doing that should be trivial, and
> definitely an idea for a separate patch:
> 
> # xfs_io -c 'label' /mnt
> label = "hi"
> # xfs_io -c 'label -s bye' /mnt
> label = "bye"
> # xfs_io -c 'label' /mnt
> label = "bye"

Sure, I can do that in a separate patch. Thank you!
> 
> *This* patch looks correct to me, so
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> 
> --D
> 
>> -	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";;
>> -	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG";;
>> -	p)	DB_OPTS=$DB_OPTS" -c 'version projid32bit'";;
>> -	r)	REPAIR_DEV_OPTS=" -r '$OPTARG'";;
>> -	u)	DB_OPTS=$DB_OPTS" -r -c uuid";;
>> -	U)	DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";;
>> +	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
>> +		require_offline=1
>> +		;;
>> +	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
>> +		require_offline=1
>> +		;;
>> +	p)	DB_OPTS=$DB_OPTS" -c 'version projid32bit'"
>> +		require_offline=1
>> +		;;
>> +	r)	REPAIR_DEV_OPTS=" -r '$OPTARG'"
>> +		require_offline=1
>> +		;;
>> +	u)	DB_OPTS=$DB_OPTS" -r -c uuid"
>> +		IO_OPTS=$IO_OPTS" -r -c fsuuid"
>> +		;;
>> +	U)	DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'"
>> +		require_offline=1
>> +		;;
>> 	V)	xfs_db -p xfs_admin -V
>> 		status=$?
>> 		exit $status
>> @@ -38,6 +61,24 @@ set -- extra $@
>> shift $OPTIND
>> case $# in
>> 	1|2)
>> +		if mntpt="$(findmnt -t xfs -f -n -o TARGET "$1" 2>/dev/null)"; then
>> +			# filesystem is mounted
>> +			if [ -n "$require_offline" ]; then
>> +				echo "$1: filesystem is mounted."
>> +				exit 2
>> +			fi
>> +
>> +			if [ -n "$IO_OPTS" ]; then
>> +				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
>> +			fi
>> +		fi
>> +
>> +		# filesystem is not mounted
>> +		if [ -n "$require_online" ]; then
>> +			echo "$1: filesystem is not mounted"
>> +			exit 2
>> +		fi
>> +
>> 		# Pick up the log device, if present
>> 		if [ -n "$2" ]; then
>> 			LOG_OPTS=" -l '$2'"
>> -- 
>> 2.25.1
>> 


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

* Re: [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem
  2023-01-05  0:36 ` [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem Catherine Hoang
  2023-01-05 19:47   ` Darrick J. Wong
@ 2023-01-13  0:15   ` Allison Henderson
  1 sibling, 0 replies; 6+ messages in thread
From: Allison Henderson @ 2023-01-13  0:15 UTC (permalink / raw)
  To: Catherine Hoang, linux-xfs

On Wed, 2023-01-04 at 16:36 -0800, Catherine Hoang wrote:
> Adapt this tool to call xfs_io to retrieve the UUID of a mounted
> filesystem.
> This is a precursor to enabling xfs_admin to set the UUID of a
> mounted
> filesystem.
> 
> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Sorry for the delay here, this patch looks good to me, you can add my
review:
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

> ---
>  db/xfs_admin.sh | 61 +++++++++++++++++++++++++++++++++++++++++------
> --
>  1 file changed, 51 insertions(+), 10 deletions(-)
> 
> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
> index 409975b2..b73fb3ad 100755
> --- a/db/xfs_admin.sh
> +++ b/db/xfs_admin.sh
> @@ -5,8 +5,11 @@
>  #
>  
>  status=0
> +require_offline=""
> +require_online=""
>  DB_OPTS=""
>  REPAIR_OPTS=""
> +IO_OPTS=""
>  REPAIR_DEV_OPTS=""
>  LOG_OPTS=""
>  USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O
> v5_feature] [-r rtdev] [-U uuid] device [logdev]"
> @@ -14,17 +17,37 @@ USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L
> label] [-O v5_feature] [-r rtdev
>  while getopts "c:efjlL:O:pr:uU:V" c
>  do
>         case $c in
> -       c)      REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;;
> -       e)      DB_OPTS=$DB_OPTS" -c 'version extflg'";;
> -       f)      DB_OPTS=$DB_OPTS" -f";;
> -       j)      DB_OPTS=$DB_OPTS" -c 'version log2'";;
> +       c)      REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG
> +               require_offline=1
> +               ;;
> +       e)      DB_OPTS=$DB_OPTS" -c 'version extflg'"
> +               require_offline=1
> +               ;;
> +       f)      DB_OPTS=$DB_OPTS" -f"
> +               require_offline=1
> +               ;;
> +       j)      DB_OPTS=$DB_OPTS" -c 'version log2'"
> +               require_offline=1
> +               ;;
>         l)      DB_OPTS=$DB_OPTS" -r -c label";;
> -       L)      DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";;
> -       O)      REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG";;
> -       p)      DB_OPTS=$DB_OPTS" -c 'version projid32bit'";;
> -       r)      REPAIR_DEV_OPTS=" -r '$OPTARG'";;
> -       u)      DB_OPTS=$DB_OPTS" -r -c uuid";;
> -       U)      DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";;
> +       L)      DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
> +               require_offline=1
> +               ;;
> +       O)      REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
> +               require_offline=1
> +               ;;
> +       p)      DB_OPTS=$DB_OPTS" -c 'version projid32bit'"
> +               require_offline=1
> +               ;;
> +       r)      REPAIR_DEV_OPTS=" -r '$OPTARG'"
> +               require_offline=1
> +               ;;
> +       u)      DB_OPTS=$DB_OPTS" -r -c uuid"
> +               IO_OPTS=$IO_OPTS" -r -c fsuuid"
> +               ;;
> +       U)      DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'"
> +               require_offline=1
> +               ;;
>         V)      xfs_db -p xfs_admin -V
>                 status=$?
>                 exit $status
> @@ -38,6 +61,24 @@ set -- extra $@
>  shift $OPTIND
>  case $# in
>         1|2)
> +               if mntpt="$(findmnt -t xfs -f -n -o TARGET "$1"
> 2>/dev/null)"; then
> +                       # filesystem is mounted
> +                       if [ -n "$require_offline" ]; then
> +                               echo "$1: filesystem is mounted."
> +                               exit 2
> +                       fi
> +
> +                       if [ -n "$IO_OPTS" ]; then
> +                               exec xfs_io -p xfs_admin $IO_OPTS
> "$mntpt"
> +                       fi
> +               fi
> +
> +               # filesystem is not mounted
> +               if [ -n "$require_online" ]; then
> +                       echo "$1: filesystem is not mounted"
> +                       exit 2
> +               fi
> +
>                 # Pick up the log device, if present
>                 if [ -n "$2" ]; then
>                         LOG_OPTS=" -l '$2'"


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

end of thread, other threads:[~2023-01-13  0:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05  0:36 [PATCH v3 0/2] get UUID of mounted filesystems Catherine Hoang
2023-01-05  0:36 ` [PATCH v3 1/2] xfs_io: add fsuuid command Catherine Hoang
2023-01-05  0:36 ` [PATCH v3 2/2] xfs_admin: get UUID of mounted filesystem Catherine Hoang
2023-01-05 19:47   ` Darrick J. Wong
2023-01-06  0:37     ` Catherine Hoang
2023-01-13  0:15   ` Allison Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.