Skip to contentSkip to conversation

overlay/08[89]: add tests for data-only redirect with userxattr

PATCH In review Miklos Szeredi 2 participants 2 messages Apr 8, 2025 – Apr 9, 2025 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 overlay/08[89]: add tests for data-only redirect with userxattr

New kernel feature (target release is v6.16) allows data-only redirect to be enabled without metacopy and redirect_dir turned on. This works with or without verity enabled.

Tests are done with the userxattr option, to verify that it will work in a user namespace.

---
 common/overlay        |  29 +++++
 tests/overlay/088     | 296 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/088.out |  39 ++++++
 tests/overlay/089     | 272 ++++++++++++++++++++++++++++++++++++++
 tests/overlay/089.out |   5 +
 5 files changed, 641 insertions(+)
 create mode 100755 tests/overlay/088
 create mode 100644 tests/overlay/088.out
 create mode 100755 tests/overlay/089
 create mode 100644 tests/overlay/089.out
common/overlay +29 -0
index 01b6622f5573..a6d37a933e6b 100644
@@ -268,6 +268,22 @@ _require_scratch_overlay_lowerdir_add_layers()
 	_scratch_unmount
 }
 
+# Check kernel support for datadir+=<datadir> without "metacopy=on" option
+_require_scratch_overlay_datadir_without_metacopy()
+{
+	local lowerdir="$OVL_BASE_SCRATCH_MNT/$OVL_UPPER"
+	local datadir="$OVL_BASE_SCRATCH_MNT/$OVL_LOWER"
+
+	_scratch_mkfs > /dev/null 2>&1
+	_overlay_scratch_mount_opts \
+		-o"lowerdir+=$lowerdir,datadir+=$datadir" > /dev/null 2>&1 || \
+	        _notrun "overlay datadir+ without metacopy not supported on ${SCRATCH_DEV}"
+
+	_scratch_unmount
+
+}
+
+
 # Helper function to check underlying dirs of overlay filesystem
 _overlay_fsck_dirs()
 {
@@ -467,6 +483,19 @@ _require_unionmount_testsuite()
 		_notrun "newer version of unionmount testsuite required to support OVERLAY_MOUNT_OPTIONS."
 }
 
+# transform overlay xattrs (trusted.overlay -> user.overlay)
+_overlay_trusted_to_user()
+{
+	local dir=$1
+
+	for file in `find $dir`; do
+		_getfattr --absolute-names -d -m '^trusted.overlay.(redirect|metacopy)$' $file  | sed 's/^trusted/user/' | setfattr --restore=-
+		for xattr in `_getfattr --absolute-names -d -m '^trusted.overlay.' $file  | tail -n +2 | cut -d= -f1`; do
+			setfattr -x $xattr $file;
+		done
+	done
+}
+
 _unionmount_testsuite_run()
 {
 	[ "$FSTYP" = overlay ] || \
tests/overlay/088 new file +296 -0

296 lines not on this page · raw message

tests/overlay/088.out new file +39 -0
new file mode 100644
index 000000000000..c85c998d503a
@@ -0,0 +1,39 @@
+QA output created by 088
+
+== Check no follow to lowerdata layer without redirect ==
+No access to lowerdata layer datafile
+Unmount and Mount rw
+No access to lowerdata layer datafile
+No access to lowerdata layer datafile2
+Unmount and Mount rw
+No access to lowerdata layer datafile2
+No access to lowerdata layer shared
+Unmount and Mount rw
+No access to lowerdata layer shared
+
+== Check no follow to lowerdata layer with relative redirect ==
+No access to lowerdata layer datafile
+Unmount and Mount rw
+No access to lowerdata layer datafile
+No access to lowerdata layer datafile2
+Unmount and Mount rw
+No access to lowerdata layer datafile2
+No access to lowerdata layer shared
+Unmount and Mount rw
+No access to lowerdata layer shared
+
+== Check follow to lowerdata layer with absolute redirect ==
+Mount ro
+check properties of metadata copied up file datafile
+Unmount and Mount rw
+check properties of metadata copied up file datafile
+Mount ro
+check properties of metadata copied up file datafile2
+Unmount and Mount rw
+check properties of metadata copied up file datafile2
+Mount ro
+check properties of metadata copied up file shared
+Unmount and Mount rw
+check properties of metadata copied up file shared
+
+== Check lazy follow to lowerdata layer ==
tests/overlay/089 new file +272 -0

272 lines not on this page · raw message

tests/overlay/089.out new file +5 -0
new file mode 100644
index 000000000000..0c3eee7103b1
@@ -0,0 +1,5 @@
+QA output created by 089
+
+== Check fsverity validation ==
+
+== Check fsverity require ==
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Miklos Szeredi

New kernel feature (target release is v6.16) allows data-only redirect to be enabled without metacopy and redirect_dir turned on. This works with or without verity enabled.

Tests are done with the userxattr option, to verify that it will work in a user namespace.

With some minor nits below fixed, you may add:

Quoted 12 lines
---
 common/overlay        |  29 +++++
 tests/overlay/088     | 296 ++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/088.out |  39 ++++++
 tests/overlay/089     | 272 ++++++++++++++++++++++++++++++++++++++
 tests/overlay/089.out |   5 +
 5 files changed, 641 insertions(+)
 create mode 100755 tests/overlay/088
 create mode 100644 tests/overlay/088.out
 create mode 100755 tests/overlay/089
 create mode 100644 tests/overlay/089.out

...

tests/overlay/088 line 166

Quoted 13 lines
tests/overlay/088 new file +13 -0
+test_common()
+{
+       local _lowerdir=$1 _datadir2=$2 _datadir=$3
+       local _target=$4 _size=$5 _blocks=$6 _data="$7"
+       local _redirect=$8
+
+       echo "Mount ro"
+       mount_ro_overlay $_lowerdir $_datadir2 $_datadir
+
+       # Check redirect xattr to lowerdata
+       [ -n "$_redirect" ] && check_redirect $lowerdir/$_target "$_redirect"
+
+       echo "check properties of metadata copied up file $_target"

Remove "metadata"

tests/overlay/088 line 174

Quoted 8 lines
tests/overlay/088 new file +8 -0
+       check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data"
+       check_file_blocks $SCRATCH_MNT/$_target $_blocks
+
+       # Do a mount cycle and check size and contents again.
+       echo "Unmount and Mount rw"
+       umount_overlay
+       mount_overlay $_lowerdir $_datadir2 $_datadir
+       echo "check properties of metadata copied up file $_target"

Remove "metadata"

tests/overlay/088 line 178

Quoted 4 lines
tests/overlay/088 new file +4 -0
+       check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data"
+       check_file_blocks $SCRATCH_MNT/$_target $_blocks
+
+       # Trigger metadata copy up and check absence of metacopy xattr.

Wrong description. maybe
# Trigger copy up and check upper file properties.

Quoted 5 lines
tests/overlay/088 new file +5 -0
+       chmod 400 $SCRATCH_MNT/$_target
+       umount_overlay
+       check_file_size_contents $upperdir/$_target $_size "$_data"
+}
+

...

Quoted 8 lines
tests/overlay/088.out new file +2 -0
new file mode 100644
index 000000000000..c85c998d503a
@@ -0,0 +1,39 @@
+QA output created by 088
+

...

Quoted 5 lines
tests/overlay/088.out new file +5 -0
+
+== Check follow to lowerdata layer with absolute redirect ==
+Mount ro
+check properties of metadata copied up file datafile
+Unmount and Mount rw

tests/overlay/088.out line 38

Quoted 10 lines
tests/overlay/088.out new file +10 -0
+check properties of metadata copied up file datafile
+Mount ro
+check properties of metadata copied up file datafile2
+Unmount and Mount rw
+check properties of metadata copied up file datafile2
+Mount ro
+check properties of metadata copied up file shared
+Unmount and Mount rw
+check properties of metadata copied up file shared
+

For all of the above - remove "metadata"

Thanks,
Amir.