Skip to contentSkip to conversation

fstests: help user to troubleshoot the re-mount issue quickly

PATCH Superseded Jia He 3 participants 9 messages Jan 7, 2016 – Jan 11, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jia He

author
#0 lore raw

cover fstests: help user to troubleshoot the re-mount issue quickly

When I tried to fix a mount issue of tests/xfs/003 failure, I found the root cause is my mistake that I added "/" to the end of TEST_DIR, eg. export TEST_DIR=/root/xfstests/test/
This patch set is to let user find the correct cause quickly

Jia He (2):
fstests: comments to prevent from adding "/" to the end of 2 environment variables
fstests: give user friendly prompts for already mounted dir

 common/rc                | 8 ++++++--
 configs/example.config   | 1 +
 configs/localhost.config | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH 1/2 fstests: comments to prevent from adding "/" to the end of 2 environment variables

This adds comments to prevent user from adding "/" to the end of TEST_DIR and SCRATCH_MNT

---
 configs/example.config   | 1 +
 configs/localhost.config | 1 +
 2 files changed, 2 insertions(+)
configs/example.config +1 -0
index 7b6e142..cf8f08e 100644
@@ -1,5 +1,6 @@
 # Example config file with all typical device options set for full
 # XFS kernel, progs and dump testing.
+# please do NOT add "/" to end of TEST_DIR and SCRATCH_MNT
 MODULAR=0
 SCRATCH_MNT=/mnt/scratch
 SCRATCH_DEV=/dev/sdb5
configs/localhost.config +1 -0
index f47e694..a7b9fe3 100644
@@ -1,5 +1,6 @@
 # default localhost file, set up for virtual machines using KVM and
 # virtio for it's block devices
+# Please do NOT add "/" to the end of TEST_DIR and SCRATCH_MNT
 #
 MODULAR=0
 TEST_DIR=/mnt/test
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH 1/2] fstests: comments to prevent from adding "/" to the end of 2 environment variables

Quoted 2 lines · Jia He

This adds comments to prevent user from adding "/" to the end of TEST_DIR and SCRATCH_MNT

Instead of adding comments, how about removing the trailing "/" in the code, something like:

common/config +5 -0
index e82d279..cb34fd7 100644
@@ -551,5 +551,10 @@ if [ -z "$CONFIG_INCLUDED" ]; then
 	[ -z "$FSCK_OPTIONS" ] && _fsck_opts
 fi
 
+# canonicalize the mount points
+# this follows symlinks and removes all trailing "/"s
+export TEST_DIR=`readlink -e "$TEST_DIR"`
+export SCRATCH_MNT=`readlink -e "$SCRATCH_MNT"`
+
 # make sure this script returns success
 /bin/true

Thanks,
Eryu

author
#3 lore raw

Re: [PATCH 1/2] fstests: comments to prevent from adding "/" to the end of 2 environment variables

Hi Eryu Guan
Thanks for the comments, reasonable to me.
I will add it into v2 patch together with other

Quoted 11 lines · Eryu Guan
Quoted 2 lines · Jia He

This adds comments to prevent user from adding "/" to the end of TEST_DIR and SCRATCH_MNT

Instead of adding comments, how about removing the trailing "/" in the code, something like:

common/config +0 -0
index e82d279..cb34fd7 100644

common/config if [ -z "$CONFIG_INCLUDED" ]; then · line 558

Quoted 8 lines
common/config +5 -0
@@ -551,5 +551,10 @@ if [ -z "$CONFIG_INCLUDED" ]; then
  	[ -z "$FSCK_OPTIONS" ] && _fsck_opts
  fi
 
+# canonicalize the mount points
+# this follows symlinks and removes all trailing "/"s
+export TEST_DIR=`readlink -e "$TEST_DIR"`
+export SCRATCH_MNT=`readlink -e "$SCRATCH_MNT"`
+

Thanks, but maybe it will empty the invalid path and the user doesn't know why his TEST_DIR/SCRATCH_MNT are assigned to NULL?

eg.
[root@host ~]# ls /root/not_existed
ls: cannot access /root/not_existed: No such file or directory [root@host ~]# readlink -e /root/not_existed [root@host ~]#

Quoted 6 lines
common/config +0 -0
  # make sure this script returns success
  /bin/true

Thanks,
Eryu

#4 lore raw

Re: [PATCH 1/2] fstests: comments to prevent from adding "/" to the end of 2 environment variables

Quoted 10 lines · hejianet

Hi Eryu Guan
Thanks for the comments, reasonable to me.
I will add it into v2 patch together with other

Quoted 6 lines · Eryu Guan
Quoted 2 lines · Jia He

This adds comments to prevent user from adding "/" to the end of TEST_DIR and SCRATCH_MNT

Instead of adding comments, how about removing the trailing "/" in the code, something like:

Quoted 14 lines

common/config if [ -z "$CONFIG_INCLUDED" ]; then · line 557

Quoted 12 lines
common/config +5 -0
index e82d279..cb34fd7 100644
@@ -551,5 +551,10 @@ if [ -z "$CONFIG_INCLUDED" ]; then
 	[ -z "$FSCK_OPTIONS" ] && _fsck_opts
 fi
+# canonicalize the mount points
+# this follows symlinks and removes all trailing "/"s
+export TEST_DIR=`readlink -e "$TEST_DIR"`
+export SCRATCH_MNT=`readlink -e "$SCRATCH_MNT"`
+

Thanks, but maybe it will empty the invalid path and the user doesn't know why his TEST_DIR/SCRATCH_MNT are assigned to NULL?

These values have been proved to be a directory in get_next_config(), if they're not, the test errors out there.

Thanks,
Eryu

author
#5 lore raw

Re: [PATCH 1/2] fstests: comments to prevent from adding "/" to the end of 2 environment variables

Hi Eryu
Yes, you are wright

root@justin-u1504:~/xfstests/xfstests# ./check -d xfs/003
common/config: Error: $TEST_DIR (/root/xfstests/test1) is not a directory

B.R.
Justin

Quoted 31 lines · Eryu Guan
Quoted 10 lines · hejianet

Hi Eryu Guan
Thanks for the comments, reasonable to me.
I will add it into v2 patch together with other

Quoted 6 lines · Eryu Guan
Quoted 2 lines · Jia He

This adds comments to prevent user from adding "/" to the end of TEST_DIR and SCRATCH_MNT

Instead of adding comments, how about removing the trailing "/" in the code, something like:

Quoted 14 lines

common/config if [ -z "$CONFIG_INCLUDED" ]; then · line 557

Quoted 12 lines
common/config +5 -0
index e82d279..cb34fd7 100644
@@ -551,5 +551,10 @@ if [ -z "$CONFIG_INCLUDED" ]; then
  	[ -z "$FSCK_OPTIONS" ] && _fsck_opts
  fi
+# canonicalize the mount points
+# this follows symlinks and removes all trailing "/"s
+export TEST_DIR=`readlink -e "$TEST_DIR"`
+export SCRATCH_MNT=`readlink -e "$SCRATCH_MNT"`
+

Thanks, but maybe it will empty the invalid path and the user doesn't know why his TEST_DIR/SCRATCH_MNT are assigned to NULL?

These values have been proved to be a directory in get_next_config(), if they're not, the test errors out there.

Thanks,
Eryu

author
#6 lore raw

PATCH 2/2 fstests: give user friendly prompts for already mounted dir

In reply to Jia He

This adds user friendly prompts to output the already mounted line from _mount. xfstests will do the cleanup (ie. umount) and user can not get the mount directory information.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +6 -2
index d33e3fb..5b40fb4 100644
@@ -1271,7 +1271,9 @@ _require_scratch_nocheck()
         # if it's mounted, make sure its on $SCRATCH_MNT
         if ! _mount | grep -F $SCRATCH_DEV | grep -q $SCRATCH_MNT
         then
-            echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
+            echo "\$SCRATCH_DEV=$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT=$SCRATCH_MNT - aborting"
+            echo "Already mounted result:"
+            _mount | grep -F $SCRATCH_DEV
             exit 1
         fi
         # and then unmount it
@@ -1353,7 +1355,9 @@ _require_test()
         # if it's mounted, make sure its on $TEST_DIR
         if ! _mount | grep -F $TEST_DEV | grep -q $TEST_DIR
         then
-            echo "\$TEST_DEV is mounted but not on \$TEST_DIR - aborting"
+            echo "\$TEST_DEV=$TEST_DEV is mounted but not on \$TEST_DIR=$TEST_DIR - aborting"
+            echo "Already mounted result:"
+            _mount | grep -F $TEST_DEV
             exit 1
         fi
     else
Signature · 1 line
2.1.4
#7 lore raw

Re: [PATCH 2/2] fstests: give user friendly prompts for already mounted dir

Quoted 14 lines · Jia He

This adds user friendly prompts to output the already mounted line from _mount. xfstests will do the cleanup (ie. umount) and user can not get the mount directory information.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +0 -0
index d33e3fb..5b40fb4 100644

common/rc _require_scratch_nocheck() · line 1278

Quoted 9 lines
common/rc +3 -1
@@ -1271,7 +1271,9 @@ _require_scratch_nocheck()
         # if it's mounted, make sure its on $SCRATCH_MNT
         if ! _mount | grep -F $SCRATCH_DEV | grep -q $SCRATCH_MNT
         then
-            echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
+            echo "\$SCRATCH_DEV=$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT=$SCRATCH_MNT - aborting"
+            echo "Already mounted result:"
+            _mount | grep -F $SCRATCH_DEV
             exit 1
         fi

Should use a temporary local variable rather than looking at the mount table twice. e.g.

mount_rec=_mount | grep -F $SCRATCH_DEV
echo $mount_rec | grep -q $SCRATCH_MNT
if [ $? -ne 0 ]; then
# new error message
echo $mount_rec
fi

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#8 lore raw

Re: [PATCH 2/2] fstests: give user friendly prompts for already mounted dir

Quoted 27 lines · Dave Chinner
Quoted 14 lines · Jia He

This adds user friendly prompts to output the already mounted line from _mount. xfstests will do the cleanup (ie. umount) and user can not get the mount directory information.

---
  common/rc | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +0 -0
index d33e3fb..5b40fb4 100644

common/rc _require_scratch_nocheck() · line 1278

Quoted 9 lines
common/rc +3 -1
@@ -1271,7 +1271,9 @@ _require_scratch_nocheck()
          # if it's mounted, make sure its on $SCRATCH_MNT
          if ! _mount | grep -F $SCRATCH_DEV | grep -q $SCRATCH_MNT
          then
-            echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
+            echo "\$SCRATCH_DEV=$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT=$SCRATCH_MNT - aborting"
+            echo "Already mounted result:"
+            _mount | grep -F $SCRATCH_DEV
              exit 1
          fi

Should use a temporary local variable rather than looking at the mount table twice. e.g.

Quoted 6 lines

mount_rec=_mount | grep -F $SCRATCH_DEV
echo $mount_rec | grep -q $SCRATCH_MNT
if [ $? -ne 0 ]; then
# new error message
echo $mount_rec
fi

Thanks, Dave
v3 is sending.

B.R.
Justin

Quoted 4 lines

Cheers,

Dave.