diff mbox series

[v1.2,5/5] xfs/49[12]: skip pre-lazysbcount filesystems

Message ID 20210429013154.GL3122235@magnolia (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Darrick J. Wong April 29, 2021, 1:31 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Prior to lazysbcount, the xfs mount code blindly trusted the value of
the fdblocks counter in the primary super, which means that the kernel
doesn't detect the fuzzed fdblocks value at all.  V4 is deprecated and
pre-lazysbcount V4 hasn't been the default for ~14 years, so we'll just
skip these two tests on those old filesystems.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
v1.2: factor the feature checking into a separate helper
---
 common/xfs    |   12 ++++++++++++
 tests/xfs/491 |    4 ++++
 tests/xfs/492 |    4 ++++
 3 files changed, 20 insertions(+)

Comments

Brian Foster April 29, 2021, 1:30 p.m. UTC | #1
On Wed, Apr 28, 2021 at 06:31:54PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Prior to lazysbcount, the xfs mount code blindly trusted the value of
> the fdblocks counter in the primary super, which means that the kernel
> doesn't detect the fuzzed fdblocks value at all.  V4 is deprecated and
> pre-lazysbcount V4 hasn't been the default for ~14 years, so we'll just
> skip these two tests on those old filesystems.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
> v1.2: factor the feature checking into a separate helper
> ---

Looks good, thanks for the update:

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  common/xfs    |   12 ++++++++++++
>  tests/xfs/491 |    4 ++++
>  tests/xfs/492 |    4 ++++
>  3 files changed, 20 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index 8501b084..92383061 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -1129,6 +1129,18 @@ _check_scratch_xfs_features()
>  	test "${found}" -eq "$#"
>  }
>  
> +# Skip a test if any of the given fs features aren't present on the scratch
> +# filesystem.  The scratch fs must have been formatted already.
> +_require_scratch_xfs_features()
> +{
> +	local features="$(_scratch_xfs_db -c 'version' 2>/dev/null)"
> +
> +	for feature in "$@"; do
> +		echo "${features}" | grep -q -w "${feature}" ||
> +			_notrun "Missing scratch feature: ${feature}"
> +	done
> +}
> +
>  # Decide if xfs_repair knows how to set (or clear) a filesystem feature.
>  _require_xfs_repair_upgrade()
>  {
> diff --git a/tests/xfs/491 b/tests/xfs/491
> index 6420202b..7d447ccf 100755
> --- a/tests/xfs/491
> +++ b/tests/xfs/491
> @@ -36,6 +36,10 @@ _require_scratch
>  
>  echo "Format and mount"
>  _scratch_mkfs > $seqres.full 2>&1
> +
> +# pre-lazysbcount filesystems blindly trust the primary sb fdblocks
> +_require_scratch_xfs_features LAZYSBCOUNT
> +
>  _scratch_mount >> $seqres.full 2>&1
>  echo "test file" > $SCRATCH_MNT/testfile
>  
> diff --git a/tests/xfs/492 b/tests/xfs/492
> index 522def47..21c6872f 100755
> --- a/tests/xfs/492
> +++ b/tests/xfs/492
> @@ -36,6 +36,10 @@ _require_scratch
>  
>  echo "Format and mount"
>  _scratch_mkfs > $seqres.full 2>&1
> +
> +# pre-lazysbcount filesystems blindly trust the primary sb fdblocks
> +_require_scratch_xfs_features LAZYSBCOUNT
> +
>  _scratch_mount >> $seqres.full 2>&1
>  echo "test file" > $SCRATCH_MNT/testfile
>  
>
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index 8501b084..92383061 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1129,6 +1129,18 @@  _check_scratch_xfs_features()
 	test "${found}" -eq "$#"
 }
 
+# Skip a test if any of the given fs features aren't present on the scratch
+# filesystem.  The scratch fs must have been formatted already.
+_require_scratch_xfs_features()
+{
+	local features="$(_scratch_xfs_db -c 'version' 2>/dev/null)"
+
+	for feature in "$@"; do
+		echo "${features}" | grep -q -w "${feature}" ||
+			_notrun "Missing scratch feature: ${feature}"
+	done
+}
+
 # Decide if xfs_repair knows how to set (or clear) a filesystem feature.
 _require_xfs_repair_upgrade()
 {
diff --git a/tests/xfs/491 b/tests/xfs/491
index 6420202b..7d447ccf 100755
--- a/tests/xfs/491
+++ b/tests/xfs/491
@@ -36,6 +36,10 @@  _require_scratch
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
+
+# pre-lazysbcount filesystems blindly trust the primary sb fdblocks
+_require_scratch_xfs_features LAZYSBCOUNT
+
 _scratch_mount >> $seqres.full 2>&1
 echo "test file" > $SCRATCH_MNT/testfile
 
diff --git a/tests/xfs/492 b/tests/xfs/492
index 522def47..21c6872f 100755
--- a/tests/xfs/492
+++ b/tests/xfs/492
@@ -36,6 +36,10 @@  _require_scratch
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
+
+# pre-lazysbcount filesystems blindly trust the primary sb fdblocks
+_require_scratch_xfs_features LAZYSBCOUNT
+
 _scratch_mount >> $seqres.full 2>&1
 echo "test file" > $SCRATCH_MNT/testfile