[PATCH 1/1] generic: add a regression test for sub-block fsmap queries

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Zizhi Wo found some bugs in the GETFSMAP implementation if it is fed
sub-fsblock ranges.  Add a regression test for this.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 tests/generic/1954     |   79 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1954.out |   15 +++++++++
 2 files changed, 94 insertions(+)
 create mode 100755 tests/generic/1954
 create mode 100644 tests/generic/1954.out


diff --git a/tests/generic/1954 b/tests/generic/1954
new file mode 100755
index 0000000000..cfdfaf15e2
--- /dev/null
+++ b/tests/generic/1954
@@ -0,0 +1,79 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 1954
+#
+# Regression test for sub-fsblock key handling errors in GETFSMAP.
+#
+. ./common/preamble
+_begin_fstest auto rmap fsmap
+
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+	"xfs: Fix the owner setting issue for rmap query in xfs fsmap"
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+	"xfs: Fix missing interval for missing_owner in xfs fsmap"
+
+. ./common/filter
+
+_require_xfs_io_command "fsmap"
+_require_scratch
+
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+
+blksz=$(_get_block_size "$SCRATCH_MNT")
+if ((blksz < 2048)); then
+	_notrun "test requires at least 4 bblocks per fsblock"
+fi
+
+$XFS_IO_PROG -c 'fsmap' $SCRATCH_MNT >> $seqres.full
+
+find_freesp() {
+	$XFS_IO_PROG -c 'fsmap -d' $SCRATCH_MNT | tr '.[]:' '    ' | \
+		grep 'free space' | awk '{printf("%s:%s\n", $4, $5);}' | \
+		head -n 1
+}
+
+filter_fsmap() {
+	_filter_xfs_io_numbers | sed \
+		-e 's/inode XXXX data XXXX..XXXX/inode data/g' \
+		-e 's/inode XXXX attr XXXX..XXXX/inode attr/g' \
+		-e 's/: free space XXXX/: FREE XXXX/g' \
+		-e 's/: [a-z].*XXXX/: USED XXXX/g'
+}
+
+$XFS_IO_PROG -c 'fsmap -d' $SCRATCH_MNT | filter_fsmap >> $seqres.full
+
+freesp="$(find_freesp)"
+
+freesp_start="$(echo "$freesp" | cut -d ':' -f 1)"
+freesp_end="$(echo "$freesp" | cut -d ':' -f 2)"
+echo "$freesp:$freesp_start:$freesp_end" >> $seqres.full
+
+echo "test incorrect setting of high key"
+$XFS_IO_PROG -c 'fsmap -d 0 3' $SCRATCH_MNT | filter_fsmap
+
+echo "test missing free space extent"
+$XFS_IO_PROG -c "fsmap -d $((freesp_start + 1)) $((freesp_start + 2))" $SCRATCH_MNT | \
+	filter_fsmap
+
+echo "test whatever came before freesp"
+$XFS_IO_PROG -c "fsmap -d $((freesp_start - 3)) $((freesp_start - 2))" $SCRATCH_MNT | \
+	filter_fsmap
+
+echo "test whatever came after freesp"
+$XFS_IO_PROG -c "fsmap -d $((freesp_end + 2)) $((freesp_end + 3))" $SCRATCH_MNT | \
+	filter_fsmap
+
+echo "test crossing start of freesp"
+$XFS_IO_PROG -c "fsmap -d $((freesp_start - 2)) $((freesp_start + 1))" $SCRATCH_MNT | \
+	filter_fsmap
+
+echo "test crossing end of freesp"
+$XFS_IO_PROG -c "fsmap -d $((freesp_end - 1)) $((freesp_end + 2))" $SCRATCH_MNT | \
+	filter_fsmap
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/1954.out b/tests/generic/1954.out
new file mode 100644
index 0000000000..6baec43511
--- /dev/null
+++ b/tests/generic/1954.out
@@ -0,0 +1,15 @@
+QA output created by 1954
+test incorrect setting of high key
+	XXXX: XXXX:XXXX [XXXX..XXXX]: USED XXXX
+test missing free space extent
+	XXXX: XXXX:XXXX [XXXX..XXXX]: FREE XXXX
+test whatever came before freesp
+	XXXX: XXXX:XXXX [XXXX..XXXX]: USED XXXX
+test whatever came after freesp
+	XXXX: XXXX:XXXX [XXXX..XXXX]: USED XXXX
+test crossing start of freesp
+	XXXX: XXXX:XXXX [XXXX..XXXX]: USED XXXX
+	XXXX: XXXX:XXXX [XXXX..XXXX]: FREE XXXX
+test crossing end of freesp
+	XXXX: XXXX:XXXX [XXXX..XXXX]: FREE XXXX
+	XXXX: XXXX:XXXX [XXXX..XXXX]: USED XXXX





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux