diff mbox series

[v2,4/5] common/rc: add quirks for fuse-overlayfs device/mount point

Message ID 20200214151848.8328-5-mfo@canonical.com (mailing list archive)
State New, archived
Headers show
Series fstests: overlay: initial support for aufs and | expand

Commit Message

Mauricio Faria de Oliveira Feb. 14, 2020, 3:18 p.m. UTC
On fuse-overlayfs the mount device is always reported as
a "fuse-overlayfs" string, instead of the parent directory
of the mount point (the string expected by overlay/scripts).

Unfortunately, it seems that the fuse mount option 'fsname'
doesn't set the filesystem source/device on fuse-overlayfs,
so the easy fix of just adding it to mount options is gone.

So two quirks are used to check for a fuse-overlayfs mount,
that checks the mount point/directory in _check_mounted_on()
and init_rc(); latter with the new helper _fs_type_dev_dir().

With this, fuse-overlayfs can now keep going through tests!

Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
---
 README.overlay |  1 +
 common/rc      | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

Comments

Amir Goldstein Feb. 14, 2020, 10:37 p.m. UTC | #1
On Fri, Feb 14, 2020 at 5:18 PM Mauricio Faria de Oliveira
<mfo@canonical.com> wrote:
>
> On fuse-overlayfs the mount device is always reported as
> a "fuse-overlayfs" string, instead of the parent directory
> of the mount point (the string expected by overlay/scripts).
>
> Unfortunately, it seems that the fuse mount option 'fsname'
> doesn't set the filesystem source/device on fuse-overlayfs,
> so the easy fix of just adding it to mount options is gone.
>
> So two quirks are used to check for a fuse-overlayfs mount,
> that checks the mount point/directory in _check_mounted_on()
> and init_rc(); latter with the new helper _fs_type_dev_dir().
>
> With this, fuse-overlayfs can now keep going through tests!
>
> Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
> ---
>  README.overlay |  1 +
>  common/rc      | 19 ++++++++++++++++++-
>  2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/README.overlay b/README.overlay
> index 08a39b8830c9..7ef07ae6bbab 100644
> --- a/README.overlay
> +++ b/README.overlay
> @@ -53,4 +53,5 @@ OVERLAY_FSCK_OPTIONS will be used to check both test and scratch overlay.
>
>  To test other filesystem types (experimental) configure the OVL_FSTYP variable:
>
> + OVL_FSTYP=fuse.fuse-overlayfs
>   OVL_FSTYP=aufs
> diff --git a/common/rc b/common/rc
> index 5711eca2a1d2..6a4cb9b6d604 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1481,6 +1481,14 @@ _check_mounted_on()
>
>         # find $dev as the source, and print result in "$dev $mnt" format
>         local mount_rec=`findmnt -rncv -S $dev -o SOURCE,TARGET`
> +
> +       # fuse-overlayfs dev is not $dev, check via $mnt.
> +       if [ -z "$mount_rec" -a "$FSTYP" = "overlay" -a \
> +               "$OVL_FSTYP" = "fuse.fuse-overlayfs" ]; then
> +               dev="fuse-overlayfs"
> +               mount_rec=`findmnt -rncv -S $dev -T $mnt -o SOURCE,TARGET`
> +       fi
> +

I guess if we have to do the quirk then we better do it before the
first findmnt.
I don't see the point of trying the first time.

But I wonder, how come this is not also problem for virtiofs?
Maybe there is a way to make fuse fsname mount option work
instead of these quirks?

>         [ -n "$mount_rec" ] || return 1 # 1 = not mounted
>
>         # if it's mounted, make sure its on $mnt
> @@ -3788,8 +3796,17 @@ init_rc()
>         fi
>
>         # if $TEST_DEV is not mounted, mount it now as XFS
> -       if [ -z "`_fs_type $TEST_DEV`" ]
> +       if [ -n "`_fs_type $TEST_DEV`" ]
>         then
> +               # $TEST_DEV is mounted
> +               true
> +       elif [ "$FSTYP" = "overlay" -a "$OVL_FSTYP" = "fuse.fuse-overlayfs" -a \
> +               -n "`_fs_type_dev_dir fuse-overlayfs $TEST_DEV/$OVL_MNT`" ]

Somewhat simplified:
       elif [ "$OVL_FSTYP" = "fuse.fuse-overlayfs" -a \
               -n "`_fs_type_dev_dir fuse-overlayfs $TEST_DIR`" ]


Thanks,
Amir.
diff mbox series

Patch

diff --git a/README.overlay b/README.overlay
index 08a39b8830c9..7ef07ae6bbab 100644
--- a/README.overlay
+++ b/README.overlay
@@ -53,4 +53,5 @@  OVERLAY_FSCK_OPTIONS will be used to check both test and scratch overlay.
 
 To test other filesystem types (experimental) configure the OVL_FSTYP variable:
 
+ OVL_FSTYP=fuse.fuse-overlayfs
  OVL_FSTYP=aufs
diff --git a/common/rc b/common/rc
index 5711eca2a1d2..6a4cb9b6d604 100644
--- a/common/rc
+++ b/common/rc
@@ -1481,6 +1481,14 @@  _check_mounted_on()
 
 	# find $dev as the source, and print result in "$dev $mnt" format
 	local mount_rec=`findmnt -rncv -S $dev -o SOURCE,TARGET`
+
+	# fuse-overlayfs dev is not $dev, check via $mnt.
+	if [ -z "$mount_rec" -a "$FSTYP" = "overlay" -a \
+		"$OVL_FSTYP" = "fuse.fuse-overlayfs" ]; then
+		dev="fuse-overlayfs"
+		mount_rec=`findmnt -rncv -S $dev -T $mnt -o SOURCE,TARGET`
+	fi
+
 	[ -n "$mount_rec" ] || return 1 # 1 = not mounted
 
 	# if it's mounted, make sure its on $mnt
@@ -3788,8 +3796,17 @@  init_rc()
 	fi
 
 	# if $TEST_DEV is not mounted, mount it now as XFS
-	if [ -z "`_fs_type $TEST_DEV`" ]
+	if [ -n "`_fs_type $TEST_DEV`" ]
 	then
+		# $TEST_DEV is mounted
+		true
+	elif [ "$FSTYP" = "overlay" -a "$OVL_FSTYP" = "fuse.fuse-overlayfs" -a \
+		-n "`_fs_type_dev_dir fuse-overlayfs $TEST_DEV/$OVL_MNT`" ]
+	then
+		# (fuse-overlayfs dev is not $TEST_DEV; check via mount point)
+		# $TEST_DEV is mounted
+		true
+	else
 		# $TEST_DEV is not mounted
 		if ! _test_mount
 		then