diff mbox series

[v1] xfs_admin: get/set label of mounted filesystem

Message ID 20230117223743.71899-1-catherine.hoang@oracle.com (mailing list archive)
State Superseded
Headers show
Series [v1] xfs_admin: get/set label of mounted filesystem | expand

Commit Message

Catherine Hoang Jan. 17, 2023, 10:37 p.m. UTC
Adapt this tool to call xfs_io to get/set the label of a mounted filesystem.

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

Comments

Darrick J. Wong Jan. 18, 2023, 3:54 a.m. UTC | #1
On Tue, Jan 17, 2023 at 02:37:43PM -0800, Catherine Hoang wrote:
> Adapt this tool to call xfs_io to get/set the label of a mounted filesystem.
> 
> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> ---
>  db/xfs_admin.sh | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
> index b73fb3ad..cc650c42 100755
> --- a/db/xfs_admin.sh
> +++ b/db/xfs_admin.sh
> @@ -29,9 +29,11 @@ do
>  	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
>  		require_offline=1
>  		;;
> -	l)	DB_OPTS=$DB_OPTS" -r -c label";;
> +	l)	DB_OPTS=$DB_OPTS" -r -c label"
> +		IO_OPTS=$IO_OPTS" -r -c label"
> +		;;
>  	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
> -		require_offline=1
> +		IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
>  		;;
>  	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
>  		require_offline=1
> @@ -69,7 +71,8 @@ case $# in
>  			fi
>  
>  			if [ -n "$IO_OPTS" ]; then
> -				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
> +				eval xfs_io -p xfs_admin $IO_OPTS "$mntpt"
> +				exit $?

I'm curious, why did this change from exec to eval+exit?

Otherwise, this looks good to me.

--D

>  			fi
>  		fi
>  
> -- 
> 2.25.1
>
Catherine Hoang Jan. 19, 2023, 2:21 a.m. UTC | #2
> On Jan 17, 2023, at 7:54 PM, Darrick J. Wong <djwong@kernel.org> wrote:
> 
> On Tue, Jan 17, 2023 at 02:37:43PM -0800, Catherine Hoang wrote:
>> Adapt this tool to call xfs_io to get/set the label of a mounted filesystem.
>> 
>> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
>> ---
>> db/xfs_admin.sh | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>> 
>> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
>> index b73fb3ad..cc650c42 100755
>> --- a/db/xfs_admin.sh
>> +++ b/db/xfs_admin.sh
>> @@ -29,9 +29,11 @@ do
>> 	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
>> 		require_offline=1
>> 		;;
>> -	l)	DB_OPTS=$DB_OPTS" -r -c label";;
>> +	l)	DB_OPTS=$DB_OPTS" -r -c label"
>> +		IO_OPTS=$IO_OPTS" -r -c label"
>> +		;;
>> 	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
>> -		require_offline=1
>> +		IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
>> 		;;
>> 	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
>> 		require_offline=1
>> @@ -69,7 +71,8 @@ case $# in
>> 			fi
>> 
>> 			if [ -n "$IO_OPTS" ]; then
>> -				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
>> +				eval xfs_io -p xfs_admin $IO_OPTS "$mntpt"
>> +				exit $?
> 
> I'm curious, why did this change from exec to eval+exit?

For some reason exec doesn’t correctly parse the $IO_OPTS arguments.
I get this error when using exec:

# xfs_admin -L test /dev/sda2
test': No such file or directory
> 
> Otherwise, this looks good to me.
> 
> --D
> 
>> 			fi
>> 		fi
>> 
>> -- 
>> 2.25.1
>>
Allison Henderson Jan. 19, 2023, 11:47 p.m. UTC | #3
On Thu, 2023-01-19 at 02:21 +0000, Catherine Hoang wrote:
> > On Jan 17, 2023, at 7:54 PM, Darrick J. Wong <djwong@kernel.org>
> > wrote:
> > 
> > On Tue, Jan 17, 2023 at 02:37:43PM -0800, Catherine Hoang wrote:
> > > Adapt this tool to call xfs_io to get/set the label of a mounted
> > > filesystem.
> > > 
> > > Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> > > ---
> > > db/xfs_admin.sh | 9 ++++++---
> > > 1 file changed, 6 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
> > > index b73fb3ad..cc650c42 100755
> > > --- a/db/xfs_admin.sh
> > > +++ b/db/xfs_admin.sh
> > > @@ -29,9 +29,11 @@ do
> > >         j)      DB_OPTS=$DB_OPTS" -c 'version log2'"
> > >                 require_offline=1
> > >                 ;;
> > > -       l)      DB_OPTS=$DB_OPTS" -r -c label";;
> > > +       l)      DB_OPTS=$DB_OPTS" -r -c label"
> > > +               IO_OPTS=$IO_OPTS" -r -c label"
> > > +               ;;
> > >         L)      DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
> > > -               require_offline=1
> > > +               IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
> > >                 ;;
> > >         O)      REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
> > >                 require_offline=1
> > > @@ -69,7 +71,8 @@ case $# in
> > >                         fi
> > > 
> > >                         if [ -n "$IO_OPTS" ]; then
> > > -                               exec xfs_io -p xfs_admin $IO_OPTS
> > > "$mntpt"
> > > +                               eval xfs_io -p xfs_admin $IO_OPTS
> > > "$mntpt"
> > > +                               exit $?
> > 
> > I'm curious, why did this change from exec to eval+exit?
> 
> For some reason exec doesn’t correctly parse the $IO_OPTS arguments.
> I get this error when using exec:
Did some poking around with this.  I think you need "$IO_OPTS" to be in
quotations like "$mntpt" is.  Otherwise the parameters of "label -s
test" get separated and passed to xfs_io instead of xfs_admin.  It
doesnt complain about -s, which it interprets as sync, and "test"
becomes the mount point, which of course does not exist.

It doesnt look like your UUID set has merged, which is where the above
line of code first appears. And it looks like this patch cannot apply
cleanly without it.  So I think the cleanest solution might be to fix
the quotations in "xfs_io: add fsuuid command", and then add this patch
to that set.  Maybe just adapt the series title to "xfsprogs: get UUID
and label of mounted filesystems".

Otherwise the set is looking really good :-)
Allison

> 
> # xfs_admin -L test /dev/sda2
> test': No such file or directory
> > 
> > Otherwise, this looks good to me.
> > 
> > --D
> > 
> > >                         fi
> > >                 fi
> > > 
> > > -- 
> > > 2.25.1
> > > 
>
Catherine Hoang Jan. 20, 2023, 3:34 a.m. UTC | #4
> On Jan 19, 2023, at 3:47 PM, Allison Henderson <allison.henderson@oracle.com> wrote:
> 
> On Thu, 2023-01-19 at 02:21 +0000, Catherine Hoang wrote:
>>> On Jan 17, 2023, at 7:54 PM, Darrick J. Wong <djwong@kernel.org>
>>> wrote:
>>> 
>>> On Tue, Jan 17, 2023 at 02:37:43PM -0800, Catherine Hoang wrote:
>>>> Adapt this tool to call xfs_io to get/set the label of a mounted
>>>> filesystem.
>>>> 
>>>> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
>>>> ---
>>>> db/xfs_admin.sh | 9 ++++++---
>>>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>>> 
>>>> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
>>>> index b73fb3ad..cc650c42 100755
>>>> --- a/db/xfs_admin.sh
>>>> +++ b/db/xfs_admin.sh
>>>> @@ -29,9 +29,11 @@ do
>>>>         j)      DB_OPTS=$DB_OPTS" -c 'version log2'"
>>>>                 require_offline=1
>>>>                 ;;
>>>> -       l)      DB_OPTS=$DB_OPTS" -r -c label";;
>>>> +       l)      DB_OPTS=$DB_OPTS" -r -c label"
>>>> +               IO_OPTS=$IO_OPTS" -r -c label"
>>>> +               ;;
>>>>         L)      DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
>>>> -               require_offline=1
>>>> +               IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
>>>>                 ;;
>>>>         O)      REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
>>>>                 require_offline=1
>>>> @@ -69,7 +71,8 @@ case $# in
>>>>                         fi
>>>> 
>>>>                         if [ -n "$IO_OPTS" ]; then
>>>> -                               exec xfs_io -p xfs_admin $IO_OPTS
>>>> "$mntpt"
>>>> +                               eval xfs_io -p xfs_admin $IO_OPTS
>>>> "$mntpt"
>>>> +                               exit $?
>>> 
>>> I'm curious, why did this change from exec to eval+exit?
>> 
>> For some reason exec doesn’t correctly parse the $IO_OPTS arguments.
>> I get this error when using exec:
> Did some poking around with this.  I think you need "$IO_OPTS" to be in
> quotations like "$mntpt" is.  Otherwise the parameters of "label -s
> test" get separated and passed to xfs_io instead of xfs_admin.  It
> doesnt complain about -s, which it interprets as sync, and "test"
> becomes the mount point, which of course does not exist.
> 
> It doesnt look like your UUID set has merged, which is where the above
> line of code first appears. And it looks like this patch cannot apply
> cleanly without it.  So I think the cleanest solution might be to fix
> the quotations in "xfs_io: add fsuuid command", and then add this patch
> to that set.  Maybe just adapt the series title to "xfsprogs: get UUID
> and label of mounted filesystems".

Ah that makes sense, thank you! I’ll send out a new patchset with the changes.
> 
> Otherwise the set is looking really good :-)
> Allison
> 
>> 
>> # xfs_admin -L test /dev/sda2
>> test': No such file or directory
>>> 
>>> Otherwise, this looks good to me.
>>> 
>>> --D
>>> 
>>>>                         fi
>>>>                 fi
>>>> 
>>>> -- 
>>>> 2.25.1
diff mbox series

Patch

diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
index b73fb3ad..cc650c42 100755
--- a/db/xfs_admin.sh
+++ b/db/xfs_admin.sh
@@ -29,9 +29,11 @@  do
 	j)	DB_OPTS=$DB_OPTS" -c 'version log2'"
 		require_offline=1
 		;;
-	l)	DB_OPTS=$DB_OPTS" -r -c label";;
+	l)	DB_OPTS=$DB_OPTS" -r -c label"
+		IO_OPTS=$IO_OPTS" -r -c label"
+		;;
 	L)	DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'"
-		require_offline=1
+		IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'"
 		;;
 	O)	REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG"
 		require_offline=1
@@ -69,7 +71,8 @@  case $# in
 			fi
 
 			if [ -n "$IO_OPTS" ]; then
-				exec xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+				eval xfs_io -p xfs_admin $IO_OPTS "$mntpt"
+				exit $?
 			fi
 		fi