]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfs/837: fix test to work with pre-metadir quota mount options
authorDarrick J. Wong <djwong@kernel.org>
Mon, 10 Nov 2025 18:27:20 +0000 (10:27 -0800)
committerZorro Lang <zlang@kernel.org>
Fri, 14 Nov 2025 18:54:37 +0000 (02:54 +0800)
Prior to metadir, xfs users always had to supply quota mount options to
get quota functionality, even if the mount options match the ondisk
superblock's qflag state.  The kernel, in turn, required a writable
filesystem if any mount options were specified.  As a result, this test
fails on those old filesystems because the _scratch_mount fails.

Metadir filesystems reuse whatever's in qflags if no mount options are
supplied, so we don't need them in MOUNT_OPTS anymore.

Change the _scratch_mount to _try_scratch_mount and add configurable
golden output to handle this case.

Cc: fstests@vger.kernel.org # v2025.06.22
Fixes: e225772353e212 ("xfs: add mount test for read only rt devices")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/xfs/837
tests/xfs/837.cfg [new file with mode: 0644]
tests/xfs/837.out [deleted file]
tests/xfs/837.out.default [new file with mode: 0644]
tests/xfs/837.out.oldquota [new file with mode: 0644]

index 61e51d3a7d0e81476928838de484c1aa24664f27..2fe195a009f10f7fc39f3b0b0cd5597ea07709a4 100755 (executable)
@@ -8,6 +8,7 @@
 # Check out various mount/remount/unmount scenarious on a read-only rtdev
 # Based on generic/050
 #
+seqfull=$0
 . ./common/preamble
 _begin_fstest mount auto quick
 
@@ -36,6 +37,17 @@ _register_cleanup "_cleanup_setrw"
 
 _scratch_mkfs "-d rtinherit" > /dev/null 2>&1
 
+# Select appropriate output file
+features=""
+if ! _xfs_has_feature "$SCRATCH_DEV" metadir && echo "$MOUNT_OPTIONS" | grep -q quota ; then
+       # Mounting with quota mount options on a non-metadir fs requires a
+       # writable fs because the kernel requires write access even if the
+       # mount options match the superblock qflags.  This means we expect to
+       # fail the ro blockdev test with with EPERM.
+       features="oldquota"
+fi
+_link_out_file "$features"
+
 #
 # Mark the rt device read-only.
 #
@@ -46,19 +58,19 @@ blockdev --setro $SCRATCH_RTDEV
 # Mount it and make sure it can't be written to.
 #
 echo "mounting read-only rt block device:"
-_scratch_mount 2>&1 | _filter_ro_mount | _filter_scratch
+_try_scratch_mount 2>&1 | _filter_ro_mount | _filter_scratch
 if [ "${PIPESTATUS[0]}" -eq 0 ]; then
        echo "writing to file on read-only filesystem:"
        dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=1 oflag=direct 2>&1 | _filter_scratch
-else
-       _fail "failed to mount"
-fi
 
-echo "remounting read-write:"
-_scratch_remount rw 2>&1 | _filter_scratch | _filter_ro_mount
+       echo "remounting read-write:"
+       _scratch_remount rw 2>&1 | _filter_scratch | _filter_ro_mount
 
-echo "unmounting read-only filesystem"
-_scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
+       echo "unmounting read-only filesystem"
+       _scratch_unmount 2>&1 | _filter_scratch | _filter_ending_dot
+else
+       echo "failed to mount"
+fi
 
 # success, all done
 echo "*** done"
diff --git a/tests/xfs/837.cfg b/tests/xfs/837.cfg
new file mode 100644 (file)
index 0000000..01456b2
--- /dev/null
@@ -0,0 +1 @@
+oldquota: oldquota
diff --git a/tests/xfs/837.out b/tests/xfs/837.out
deleted file mode 100644 (file)
index 0a843a0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-QA output created by 837
-setting device read-only
-mounting read-only rt block device:
-mount: device write-protected, mounting read-only
-writing to file on read-only filesystem:
-dd: failed to open 'SCRATCH_MNT/foo': Read-only file system
-remounting read-write:
-mount: cannot remount device read-write, is write-protected
-unmounting read-only filesystem
-*** done
diff --git a/tests/xfs/837.out.default b/tests/xfs/837.out.default
new file mode 100644 (file)
index 0000000..0a843a0
--- /dev/null
@@ -0,0 +1,10 @@
+QA output created by 837
+setting device read-only
+mounting read-only rt block device:
+mount: device write-protected, mounting read-only
+writing to file on read-only filesystem:
+dd: failed to open 'SCRATCH_MNT/foo': Read-only file system
+remounting read-write:
+mount: cannot remount device read-write, is write-protected
+unmounting read-only filesystem
+*** done
diff --git a/tests/xfs/837.out.oldquota b/tests/xfs/837.out.oldquota
new file mode 100644 (file)
index 0000000..1383b44
--- /dev/null
@@ -0,0 +1,6 @@
+QA output created by 837
+setting device read-only
+mounting read-only rt block device:
+mount: SCRATCH_MNT: permission denied
+failed to mount
+*** done