All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Zorro Lang <zlang@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	Alexander Larsson <alexl@redhat.com>,
	Christian Brauner <brauner@kernel.org>,
	linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH] overlay: add test for persistent unique fsid
Date: Sun,  3 Sep 2023 10:54:11 +0300	[thread overview]
Message-ID: <20230903075411.2596590-1-amir73il@gmail.com> (raw)

Test overlayfs fsid behavior with new mount options uuid=null/on
that were introduced in kernel v6.6:

- Test inherited upper fs fsid with mount option uuid=off/null
- Test uuid=null behavior for existing overlayfs by default
- Test persistent unique fsid with mount option uuid=on
- Test uuid=on behavior for new overlayfs by default

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Zorro,

This is the functional test for an overlayfs feature merged to v6.6.
The test does _notrun on older kernels:

overlay/081 14s ...  [07:40:13][   57.780790] overlay: Bad value for 'uuid'
 [07:40:14] [not run]
	overlay/081 -- Overlayfs does not support unique fsid feature

The test for another big overlayfs feature that was merged to v6.6,
overlay/080 (validate lower using fs-verity) is already merged to fstests.

Note that overlay/080 requires running overlayfs over a base filesystem
with fs-verity support enabled, for example, on ext4 formatted with
mkfs.ext4 -O verity [1].

Thanks,
Amir.

[1] https://lore.kernel.org/fstests/20230625135033.3205742-2-amir73il@gmail.com/

 tests/overlay/081     | 128 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/081.out |   2 +
 2 files changed, 130 insertions(+)
 create mode 100755 tests/overlay/081
 create mode 100644 tests/overlay/081.out

diff --git a/tests/overlay/081 b/tests/overlay/081
new file mode 100755
index 00000000..05156a3c
--- /dev/null
+++ b/tests/overlay/081
@@ -0,0 +1,128 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2023 CTERA Networks. All Rights Reserved.
+#
+# FSQA Test No. 081
+#
+# Test persistent (and optionally unique) overlayfs fsid
+# with mount options uuid=null/on introduced in kernel v6.6
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+# Import common functions.
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_fs overlay
+
+_scratch_mkfs >>$seqres.full 2>&1
+
+# Create overlay layer with pre-packaged merge dir
+upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
+workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
+mkdir -p $upperdir/test_dir
+mkdir -p $lowerdir/test_dir
+test_dir=$SCRATCH_MNT/test_dir/
+
+# Record base fs fsid
+upper_fsid=$(stat -f -c '%i' $upperdir)
+lower_fsid=$(stat -f -c '%i' $lowerdir)
+
+# Sanity tests
+[[ -n "$upper_fsid" ]] || \
+	echo "invalid upper fs fsid"
+[[ "$lower_fsid" == "$upper_fsid" ]] || \
+	echo "lower fs and upper fs fsid differ"
+
+# Test legacy behavior - ovl fsid inherited from upper fs
+_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir -o uuid=null 2>/dev/null || \
+	_notrun "Overlayfs does not support unique fsid feature"
+
+# Lookup of test_dir marks upper root as "impure", so following (uuid=auto) mounts
+# will NOT behave as first time mount of a new overlayfs
+ovl_fsid=$(stat -f -c '%i' $test_dir)
+[[ "$ovl_fsid" == "$upper_fsid" ]] || \
+	echo "Overlayfs (uuid=null) and upper fs fsid differ"
+
+# Keep base fs mounted in case it has a volatile fsid (e.g. tmpfs)
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Test legacy behavior is preserved by default for existing "impure" overlayfs
+_scratch_mount
+
+ovl_fsid=$(stat -f -c '%i' $test_dir)
+[[ "$ovl_fsid" == "$upper_fsid" ]] || \
+	echo "Overlayfs (uuid=auto) and upper fs fsid differ"
+
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Test unique fsid on explicit opt-in for existing "impure" overlayfs
+_scratch_mount -o uuid=on
+
+ovl_fsid=$(stat -f -c '%i' $test_dir)
+ovl_unique_fsid=$ovl_fsid
+[[ "$ovl_fsid" != "$upper_fsid" ]] || \
+	echo "Overlayfs (uuid=on) and upper fs fsid are the same"
+
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Test unique fsid is persistent by default after it was created
+_scratch_mount
+
+ovl_fsid=$(stat -f -c '%i' $test_dir)
+[[ "$ovl_fsid" == "$ovl_unique_fsid" ]] || \
+	echo "Overlayfs (uuid=auto) unique fsid is not persistent"
+
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Test ignore existing persistent fsid on explicit opt-out
+_scratch_mount -o uuid=off
+
+ovl_fsid=$(stat -f -c '%i' $test_dir)
+[[ "$ovl_fsid" == "$upper_fsid" ]] || \
+	echo "Overlayfs (uuid=off) and upper fs fsid differ"
+
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Test fallback to uuid=null with non-upper ovelray
+_overlay_scratch_mount_dirs "$upperdir:$lowerdir" "-" "-" -o ro,uuid=on
+
+ovl_fsid=$(stat -f -c '%i' $test_dir)
+[[ "$ovl_fsid" == "$lower_fsid" ]] || \
+	echo "Overlayfs (uuid=null) and lower fs fsid differ"
+
+# Re-create fresh overlay layers, so following (uuid=auto) mounts
+# will behave as first time mount of a new overlayfs
+_scratch_unmount
+_scratch_mkfs >>$seqres.full 2>&1
+mkdir -p $upperdir/test_dir
+mkdir -p $lowerdir/test_dir
+
+# Record new base fs fsid
+upper_fsid=$(stat -f -c '%i' $upperdir)
+
+# Test unique fsid by default for first time mount of new overlayfs
+_scratch_mount
+
+ovl_fsid=$(stat -f -c '%i' $test_dir)
+ovl_unique_fsid=$ovl_fsid
+[[ "$ovl_fsid" != "$upper_fsid" ]] || \
+	echo "Overlayfs (uuid=auto) and upper fs fsid are the same"
+
+$UMOUNT_PROG $SCRATCH_MNT
+
+# Test unique fsid is persistent by default after it was created
+_scratch_mount -o uuid=on
+
+ovl_fsid=$(stat -f -c '%i' $test_dir)
+[[ "$ovl_fsid" == "$ovl_unique_fsid" ]] || \
+	echo "Overlayfs (uuid=on) unique fsid is not persistent"
+
+$UMOUNT_PROG $SCRATCH_MNT
+
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/overlay/081.out b/tests/overlay/081.out
new file mode 100644
index 00000000..663a8864
--- /dev/null
+++ b/tests/overlay/081.out
@@ -0,0 +1,2 @@
+QA output created by 081
+Silence is golden
-- 
2.34.1


             reply	other threads:[~2023-09-03  7:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-03  7:54 Amir Goldstein [this message]
2023-09-13 16:23 ` [PATCH] overlay: add test for persistent unique fsid Zorro Lang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230903075411.2596590-1-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=alexl@redhat.com \
    --cc=brauner@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=zlang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.