All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] common/rc: fix detection of already mounted test device
@ 2016-12-15  7:19 Eryu Guan
  2016-12-15  7:54 ` Amir Goldstein
  2016-12-15  9:01 ` [PATCH v2] " Eryu Guan
  0 siblings, 2 replies; 4+ messages in thread
From: Eryu Guan @ 2016-12-15  7:19 UTC (permalink / raw)
  To: fstests; +Cc: linux-unionfs, Eryu Guan

I saw this failure in overlayfs testing:

+$SCRATCH_DEV=/mnt/ovl/scratch is mounted but not on $SCRATCH_MNT=/mnt/xfstests/mnt2 - aborting
+Already mounted result:
+/dev/sda5 on /mnt/ovl/scratch type xfs (rw,relatime,seclabel,attr2,inode64,logbsize=256k,sunit=512,swidth=1536,noquota)

Because we grep for TEST_DEV and SCRATCH_DEV in mount output to see
if test device is already mounted, and report failure if device is
not mounted at desired mount point, but in the case of overlayfs
testing these "test device"s are directories and may have other real
devices mounted there.

Fix it by checking TEST_DEV and SCRATCH_DEV at the beginning of
mount entries.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/rc b/common/rc
index 26d715d..6fcab17 100644
--- a/common/rc
+++ b/common/rc
@@ -1363,7 +1363,7 @@ _require_scratch_nocheck()
     # mounted?
     # Note that we use -F here so grep doesn't try to interpret an NFS over
     # IPv6 server as a regular expression.
-    mount_rec=`_mount | grep -F $SCRATCH_DEV`
+    mount_rec=`_mount | grep -F "^$SCRATCH_DEV"`
     if [ "$mount_rec" ]
     then
         # if it's mounted, make sure its on $SCRATCH_MNT
@@ -1448,7 +1448,7 @@ _require_test()
     # mounted?
     # Note that we use -F here so grep doesn't try to interpret an NFS over
     # IPv6 server as a regular expression.
-    mount_rec=`_mount | grep -F $TEST_DEV`
+    mount_rec=`_mount | grep -F "^$TEST_DEV"`
     if [ "$mount_rec" ]
     then
         # if it's mounted, make sure its on $TEST_DIR
-- 
2.9.3

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

* Re: [PATCH] common/rc: fix detection of already mounted test device
  2016-12-15  7:19 [PATCH] common/rc: fix detection of already mounted test device Eryu Guan
@ 2016-12-15  7:54 ` Amir Goldstein
  2016-12-15  8:23   ` Eryu Guan
  2016-12-15  9:01 ` [PATCH v2] " Eryu Guan
  1 sibling, 1 reply; 4+ messages in thread
From: Amir Goldstein @ 2016-12-15  7:54 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, linux-unionfs

On Thu, Dec 15, 2016 at 9:19 AM, Eryu Guan <eguan@redhat.com> wrote:
> I saw this failure in overlayfs testing:
>
> +$SCRATCH_DEV=/mnt/ovl/scratch is mounted but not on $SCRATCH_MNT=/mnt/xfstests/mnt2 - aborting
> +Already mounted result:
> +/dev/sda5 on /mnt/ovl/scratch type xfs (rw,relatime,seclabel,attr2,inode64,logbsize=256k,sunit=512,swidth=1536,noquota)
>
> Because we grep for TEST_DEV and SCRATCH_DEV in mount output to see
> if test device is already mounted, and report failure if device is
> not mounted at desired mount point, but in the case of overlayfs
> testing these "test device"s are directories and may have other real
> devices mounted there.
>
> Fix it by checking TEST_DEV and SCRATCH_DEV at the beginning of
> mount entries.
>
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---
>  common/rc | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/common/rc b/common/rc
> index 26d715d..6fcab17 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1363,7 +1363,7 @@ _require_scratch_nocheck()
>      # mounted?
>      # Note that we use -F here so grep doesn't try to interpret an NFS over
>      # IPv6 server as a regular expression.
> -    mount_rec=`_mount | grep -F $SCRATCH_DEV`
> +    mount_rec=`_mount | grep -F "^$SCRATCH_DEV"`

Are you sure?
A manual test I did -F treats ^ as regular char in string and fails to
grep the entry

How about grep -F "$SCRATCH_DEV on "` ?


>      if [ "$mount_rec" ]
>      then
>          # if it's mounted, make sure its on $SCRATCH_MNT
> @@ -1448,7 +1448,7 @@ _require_test()
>      # mounted?
>      # Note that we use -F here so grep doesn't try to interpret an NFS over
>      # IPv6 server as a regular expression.
> -    mount_rec=`_mount | grep -F $TEST_DEV`
> +    mount_rec=`_mount | grep -F "^$TEST_DEV"`
>      if [ "$mount_rec" ]
>      then
>          # if it's mounted, make sure its on $TEST_DIR
> --
> 2.9.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] common/rc: fix detection of already mounted test device
  2016-12-15  7:54 ` Amir Goldstein
@ 2016-12-15  8:23   ` Eryu Guan
  0 siblings, 0 replies; 4+ messages in thread
From: Eryu Guan @ 2016-12-15  8:23 UTC (permalink / raw)
  To: Amir Goldstein; +Cc: fstests, linux-unionfs

On Thu, Dec 15, 2016 at 09:54:07AM +0200, Amir Goldstein wrote:
> On Thu, Dec 15, 2016 at 9:19 AM, Eryu Guan <eguan@redhat.com> wrote:
> > I saw this failure in overlayfs testing:
> >
> > +$SCRATCH_DEV=/mnt/ovl/scratch is mounted but not on $SCRATCH_MNT=/mnt/xfstests/mnt2 - aborting
> > +Already mounted result:
> > +/dev/sda5 on /mnt/ovl/scratch type xfs (rw,relatime,seclabel,attr2,inode64,logbsize=256k,sunit=512,swidth=1536,noquota)
> >
> > Because we grep for TEST_DEV and SCRATCH_DEV in mount output to see
> > if test device is already mounted, and report failure if device is
> > not mounted at desired mount point, but in the case of overlayfs
> > testing these "test device"s are directories and may have other real
> > devices mounted there.
> >
> > Fix it by checking TEST_DEV and SCRATCH_DEV at the beginning of
> > mount entries.
> >
> > Signed-off-by: Eryu Guan <eguan@redhat.com>
> > ---
> >  common/rc | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/common/rc b/common/rc
> > index 26d715d..6fcab17 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -1363,7 +1363,7 @@ _require_scratch_nocheck()
> >      # mounted?
> >      # Note that we use -F here so grep doesn't try to interpret an NFS over
> >      # IPv6 server as a regular expression.
> > -    mount_rec=`_mount | grep -F $SCRATCH_DEV`
> > +    mount_rec=`_mount | grep -F "^$SCRATCH_DEV"`
> 
> Are you sure?
> A manual test I did -F treats ^ as regular char in string and fails to
> grep the entry

What have I done.. I really need some good rest.

> 
> How about grep -F "$SCRATCH_DEV on "` ?

Will revise. Thanks for the review!

Eryu

> 
> 
> >      if [ "$mount_rec" ]
> >      then
> >          # if it's mounted, make sure its on $SCRATCH_MNT
> > @@ -1448,7 +1448,7 @@ _require_test()
> >      # mounted?
> >      # Note that we use -F here so grep doesn't try to interpret an NFS over
> >      # IPv6 server as a regular expression.
> > -    mount_rec=`_mount | grep -F $TEST_DEV`
> > +    mount_rec=`_mount | grep -F "^$TEST_DEV"`
> >      if [ "$mount_rec" ]
> >      then
> >          # if it's mounted, make sure its on $TEST_DIR
> > --
> > 2.9.3
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe fstests" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2] common/rc: fix detection of already mounted test device
  2016-12-15  7:19 [PATCH] common/rc: fix detection of already mounted test device Eryu Guan
  2016-12-15  7:54 ` Amir Goldstein
@ 2016-12-15  9:01 ` Eryu Guan
  1 sibling, 0 replies; 4+ messages in thread
From: Eryu Guan @ 2016-12-15  9:01 UTC (permalink / raw)
  To: fstests; +Cc: linux-unionfs, Eryu Guan

I saw this failure in overlayfs testing:

+$SCRATCH_DEV=/mnt/ovl/scratch is mounted but not on $SCRATCH_MNT=/mnt/xfstests/mnt2 - aborting
+Already mounted result:
+/dev/sda5 on /mnt/ovl/scratch type xfs (rw,relatime,seclabel,attr2,inode64,logbsize=256k,sunit=512,swidth=1536,noquota)

Because we grep for TEST_DEV and SCRATCH_DEV in mount output to see
if test device is already mounted, and report failure if device is
not mounted at desired mount point, but in the case of overlayfs
testing these "test device"s are directories and may have other real
devices mounted there.

Fix it by checking TEST_DEV and SCRATCH_DEV at the beginning of
mount entries.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---

v2: fix bug that regexp not working in grep -F

 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/rc b/common/rc
index 26d715d..e960607 100644
--- a/common/rc
+++ b/common/rc
@@ -1363,7 +1363,7 @@ _require_scratch_nocheck()
     # mounted?
     # Note that we use -F here so grep doesn't try to interpret an NFS over
     # IPv6 server as a regular expression.
-    mount_rec=`_mount | grep -F $SCRATCH_DEV`
+    mount_rec=`_mount | grep -F "$SCRATCH_DEV on "`
     if [ "$mount_rec" ]
     then
         # if it's mounted, make sure its on $SCRATCH_MNT
@@ -1448,7 +1448,7 @@ _require_test()
     # mounted?
     # Note that we use -F here so grep doesn't try to interpret an NFS over
     # IPv6 server as a regular expression.
-    mount_rec=`_mount | grep -F $TEST_DEV`
+    mount_rec=`_mount | grep -F "$TEST_DEV on "`
     if [ "$mount_rec" ]
     then
         # if it's mounted, make sure its on $TEST_DIR
-- 
2.9.3

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

end of thread, other threads:[~2016-12-15  9:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-15  7:19 [PATCH] common/rc: fix detection of already mounted test device Eryu Guan
2016-12-15  7:54 ` Amir Goldstein
2016-12-15  8:23   ` Eryu Guan
2016-12-15  9:01 ` [PATCH v2] " Eryu Guan

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.