* [PATCH] xfs_admin: pick up log arguments correctly
@ 2021-03-24 2:10 Darrick J. Wong
2021-03-24 20:47 ` Eric Sandeen
0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2021-03-24 2:10 UTC (permalink / raw)
To: Eric Sandeen; +Cc: xfs, Brian Foster
From: Darrick J. Wong <djwong@kernel.org>
In commit ab9d8d69, we added support to xfs_admin to pass an external
log to xfs_db and xfs_repair. Unfortunately, we didn't do this
correctly -- by appending the log arguments to DB_OPTS, we now guarantee
an invocation of xfs_db when we don't have any work for it to do.
Brian Foster noticed that this results in xfs/764 hanging fstests
because xfs_db (when not compiled with libeditline) will wait for input
on stdin. I didn't notice because my build includes libeditline and my
test runner script does silly things with pipes such that xfs_db would
exit immediately.
Reported-by: Brian Foster <bfoster@redhat.com>
Fixes: ab9d8d69 ("xfs_admin: support adding features to V5 filesystems")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
db/xfs_admin.sh | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
index 916050cb..409975b2 100755
--- a/db/xfs_admin.sh
+++ b/db/xfs_admin.sh
@@ -8,7 +8,7 @@ status=0
DB_OPTS=""
REPAIR_OPTS=""
REPAIR_DEV_OPTS=""
-DB_LOG_OPTS=""
+LOG_OPTS=""
USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
while getopts "c:efjlL:O:pr:uU:V" c
@@ -40,19 +40,18 @@ case $# in
1|2)
# Pick up the log device, if present
if [ -n "$2" ]; then
- DB_OPTS=$DB_OPTS" -l '$2'"
- REPAIR_DEV_OPTS=$REPAIR_DEV_OPTS" -l '$2'"
+ LOG_OPTS=" -l '$2'"
fi
if [ -n "$DB_OPTS" ]
then
- eval xfs_db -x -p xfs_admin $DB_OPTS "$1"
+ eval xfs_db -x -p xfs_admin $LOG_OPTS $DB_OPTS "$1"
status=$?
fi
if [ -n "$REPAIR_OPTS" ]
then
echo "Running xfs_repair to upgrade filesystem."
- eval xfs_repair $REPAIR_DEV_OPTS $REPAIR_OPTS "$1"
+ eval xfs_repair $LOG_OPTS $REPAIR_DEV_OPTS $REPAIR_OPTS "$1"
status=`expr $? + $status`
fi
;;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs_admin: pick up log arguments correctly
2021-03-24 2:10 [PATCH] xfs_admin: pick up log arguments correctly Darrick J. Wong
@ 2021-03-24 20:47 ` Eric Sandeen
2021-03-25 4:32 ` Darrick J. Wong
0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2021-03-24 20:47 UTC (permalink / raw)
To: Darrick J. Wong, Eric Sandeen; +Cc: xfs, Brian Foster
On 3/23/21 9:10 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> In commit ab9d8d69, we added support to xfs_admin to pass an external
> log to xfs_db and xfs_repair. Unfortunately, we didn't do this
> correctly -- by appending the log arguments to DB_OPTS, we now guarantee
> an invocation of xfs_db when we don't have any work for it to do.
>
> Brian Foster noticed that this results in xfs/764 hanging fstests
> because xfs_db (when not compiled with libeditline) will wait for input
> on stdin. I didn't notice because my build includes libeditline and my
> test runner script does silly things with pipes such that xfs_db would
> exit immediately.
>
> Reported-by: Brian Foster <bfoster@redhat.com>
> Fixes: ab9d8d69 ("xfs_admin: support adding features to V5 filesystems")
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
This seems fine. While astute bashophiles will have no problem with this,
at some point it might be nice to add some comments above DB_OPTS and
REPAIR_OPTS that point out hey, if you set these, you WILL be invoking the
tool.
I also chafe a little at accumulating some device options in REPAIR_DEV_OPTS
and others in LOG_OPTS; why not REPAIR_DEV_OPTS and DB_DEV_OPTS for some
consistency?
But, this does seem to solve the problem, and in the
Spirit of Lets Not Navel-Gaze And Just Keep Fixing Things(tm),
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> ---
> db/xfs_admin.sh | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
> index 916050cb..409975b2 100755
> --- a/db/xfs_admin.sh
> +++ b/db/xfs_admin.sh
> @@ -8,7 +8,7 @@ status=0
> DB_OPTS=""
> REPAIR_OPTS=""
> REPAIR_DEV_OPTS=""
> -DB_LOG_OPTS=""
> +LOG_OPTS=""
> USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
>
> while getopts "c:efjlL:O:pr:uU:V" c
> @@ -40,19 +40,18 @@ case $# in
> 1|2)
> # Pick up the log device, if present
> if [ -n "$2" ]; then
> - DB_OPTS=$DB_OPTS" -l '$2'"
> - REPAIR_DEV_OPTS=$REPAIR_DEV_OPTS" -l '$2'"
> + LOG_OPTS=" -l '$2'"
> fi
>
> if [ -n "$DB_OPTS" ]
> then
> - eval xfs_db -x -p xfs_admin $DB_OPTS "$1"
> + eval xfs_db -x -p xfs_admin $LOG_OPTS $DB_OPTS "$1"
> status=$?
> fi
> if [ -n "$REPAIR_OPTS" ]
> then
> echo "Running xfs_repair to upgrade filesystem."
> - eval xfs_repair $REPAIR_DEV_OPTS $REPAIR_OPTS "$1"
> + eval xfs_repair $LOG_OPTS $REPAIR_DEV_OPTS $REPAIR_OPTS "$1"
> status=`expr $? + $status`
> fi
> ;;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs_admin: pick up log arguments correctly
2021-03-24 20:47 ` Eric Sandeen
@ 2021-03-25 4:32 ` Darrick J. Wong
0 siblings, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2021-03-25 4:32 UTC (permalink / raw)
To: Eric Sandeen; +Cc: Eric Sandeen, xfs, Brian Foster
On Wed, Mar 24, 2021 at 03:47:54PM -0500, Eric Sandeen wrote:
> On 3/23/21 9:10 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > In commit ab9d8d69, we added support to xfs_admin to pass an external
> > log to xfs_db and xfs_repair. Unfortunately, we didn't do this
> > correctly -- by appending the log arguments to DB_OPTS, we now guarantee
> > an invocation of xfs_db when we don't have any work for it to do.
> >
> > Brian Foster noticed that this results in xfs/764 hanging fstests
> > because xfs_db (when not compiled with libeditline) will wait for input
> > on stdin. I didn't notice because my build includes libeditline and my
> > test runner script does silly things with pipes such that xfs_db would
> > exit immediately.
> >
> > Reported-by: Brian Foster <bfoster@redhat.com>
> > Fixes: ab9d8d69 ("xfs_admin: support adding features to V5 filesystems")
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
>
> This seems fine. While astute bashophiles will have no problem with this,
> at some point it might be nice to add some comments above DB_OPTS and
> REPAIR_OPTS that point out hey, if you set these, you WILL be invoking the
> tool.
That "should" be obvious from reading the source code, but this
maintainer obviously didn't notice that, and bash is horrible so I don't
blame anyone else for missing things.
> I also chafe a little at accumulating some device options in REPAIR_DEV_OPTS
> and others in LOG_OPTS; why not REPAIR_DEV_OPTS and DB_DEV_OPTS for some
> consistency?
Why not dump each arg into a bash array so that we don't have to deal
with all this shell space-escaping crap? :P
> But, this does seem to solve the problem, and in the
> Spirit of Lets Not Navel-Gaze And Just Keep Fixing Things(tm),
Ok, thanks. Enjoy your vacation! :)
--D
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
>
> > ---
> > db/xfs_admin.sh | 9 ++++-----
> > 1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
> > index 916050cb..409975b2 100755
> > --- a/db/xfs_admin.sh
> > +++ b/db/xfs_admin.sh
> > @@ -8,7 +8,7 @@ status=0
> > DB_OPTS=""
> > REPAIR_OPTS=""
> > REPAIR_DEV_OPTS=""
> > -DB_LOG_OPTS=""
> > +LOG_OPTS=""
> > USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
> >
> > while getopts "c:efjlL:O:pr:uU:V" c
> > @@ -40,19 +40,18 @@ case $# in
> > 1|2)
> > # Pick up the log device, if present
> > if [ -n "$2" ]; then
> > - DB_OPTS=$DB_OPTS" -l '$2'"
> > - REPAIR_DEV_OPTS=$REPAIR_DEV_OPTS" -l '$2'"
> > + LOG_OPTS=" -l '$2'"
> > fi
> >
> > if [ -n "$DB_OPTS" ]
> > then
> > - eval xfs_db -x -p xfs_admin $DB_OPTS "$1"
> > + eval xfs_db -x -p xfs_admin $LOG_OPTS $DB_OPTS "$1"
> > status=$?
> > fi
> > if [ -n "$REPAIR_OPTS" ]
> > then
> > echo "Running xfs_repair to upgrade filesystem."
> > - eval xfs_repair $REPAIR_DEV_OPTS $REPAIR_OPTS "$1"
> > + eval xfs_repair $LOG_OPTS $REPAIR_DEV_OPTS $REPAIR_OPTS "$1"
> > status=`expr $? + $status`
> > fi
> > ;;
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-25 4:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 2:10 [PATCH] xfs_admin: pick up log arguments correctly Darrick J. Wong
2021-03-24 20:47 ` Eric Sandeen
2021-03-25 4:32 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).