Skip to contentSkip to conversation

xfs: test a regression in dquot type checking

PATCH In review Darrick J. Wong 5 participants 6 messages Feb 2, 2021 – Feb 8, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: test a regression in dquot type checking

From: Darrick J. Wong <[email protected]>

This is a regression test for incorrect ondisk dquot type checking that was introduced in Linux 5.9. The bug is that we can no longer switch a V4 filesystem from having group quotas to having project quotas (or vice versa) without logging corruption errors. That is a valid use case, so add a regression test to ensure this can be done.

---
 tests/xfs/766     |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/766.out |    5 ++++
 tests/xfs/group   |    1 +
 3 files changed, 69 insertions(+)
 create mode 100755 tests/xfs/766
 create mode 100644 tests/xfs/766.out
tests/xfs/766 new file +63 -0
new file mode 100755
index 00000000..55bc03af
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 766
+#
+# Regression test for incorrect validation of ondisk dquot type flags when
+# we're switching between group and project quotas while mounting a V4
+# filesystem.  This test doesn't actually force the creation of a V4 fs because
+# even V5 filesystems ought to be able to switch between the two without
+# triggering corruption errors.
+#
+# The appropriate XFS patch is:
+# xfs: fix incorrect root dquot corruption error when switching group/project
+# quota types
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/quota
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_debug
+_require_quota
+_require_scratch
+
+rm -f $seqres.full
+
+echo "Format filesystem" | tee -a $seqres.full
+_scratch_mkfs > $seqres.full
+
+echo "Mount with project quota" | tee -a $seqres.full
+_qmount_option 'prjquota'
+_qmount
+_require_prjquota $SCRATCH_DEV
+
+echo "Mount with group quota" | tee -a $seqres.full
+_qmount_option 'grpquota'
+_qmount
+$here/src/feature -G $SCRATCH_DEV || echo "group quota didn't mount?"
+
+echo "Check dmesg for corruption"
+_check_dmesg_for corruption && \
+	echo "should not have seen corruption messages"
+
+# success, all done
+status=0
+exit
tests/xfs/766.out new file +5 -0
new file mode 100644
index 00000000..18bd99f0
@@ -0,0 +1,5 @@
+QA output created by 766
+Format filesystem
+Mount with project quota
+Mount with group quota
+Check dmesg for corruption
tests/xfs/group +1 -0
index fb78b0d7..cdca04b5 100644
@@ -545,6 +545,7 @@
 763 auto quick rw realtime
 764 auto quick repair
 765 auto quick quota
+766 auto quick quota
 908 auto quick bigtime
 909 auto quick bigtime quota
 910 auto quick inobtcount
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This is a regression test for incorrect ondisk dquot type checking that was introduced in Linux 5.9. The bug is that we can no longer switch a V4 filesystem from having group quotas to having project quotas (or vice versa) without logging corruption errors. That is a valid use case, so add a regression test to ensure this can be done.

---

Quoted 100 lines
 tests/xfs/766     |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/766.out |    5 ++++
 tests/xfs/group   |    1 +
 3 files changed, 69 insertions(+)
 create mode 100755 tests/xfs/766
 create mode 100644 tests/xfs/766.out
tests/xfs/766 new file +63 -0
new file mode 100755
index 00000000..55bc03af
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 766
+#
+# Regression test for incorrect validation of ondisk dquot type flags when
+# we're switching between group and project quotas while mounting a V4
+# filesystem.  This test doesn't actually force the creation of a V4 fs because
+# even V5 filesystems ought to be able to switch between the two without
+# triggering corruption errors.
+#
+# The appropriate XFS patch is:
+# xfs: fix incorrect root dquot corruption error when switching group/project
+# quota types
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/quota
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_debug
+_require_quota
+_require_scratch
+
+rm -f $seqres.full
+
+echo "Format filesystem" | tee -a $seqres.full
+_scratch_mkfs > $seqres.full
+
+echo "Mount with project quota" | tee -a $seqres.full
+_qmount_option 'prjquota'
+_qmount
+_require_prjquota $SCRATCH_DEV
+
+echo "Mount with group quota" | tee -a $seqres.full
+_qmount_option 'grpquota'
+_qmount
+$here/src/feature -G $SCRATCH_DEV || echo "group quota didn't mount?"
+
+echo "Check dmesg for corruption"
+_check_dmesg_for corruption && \
+	echo "should not have seen corruption messages"
+
+# success, all done
+status=0
+exit
tests/xfs/766.out new file +5 -0
new file mode 100644
index 00000000..18bd99f0
@@ -0,0 +1,5 @@
+QA output created by 766
+Format filesystem
+Mount with project quota
+Mount with group quota
+Check dmesg for corruption
tests/xfs/group +1 -0
index fb78b0d7..cdca04b5 100644
@@ -545,6 +545,7 @@
 763 auto quick rw realtime
 764 auto quick repair
 765 auto quick quota
+766 auto quick quota
 908 auto quick bigtime
 909 auto quick bigtime quota
 910 auto quick inobtcount
#2 lore raw
In reply to Darrick J. Wong
Quoted 72 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This is a regression test for incorrect ondisk dquot type checking that was introduced in Linux 5.9. The bug is that we can no longer switch a V4 filesystem from having group quotas to having project quotas (or vice versa) without logging corruption errors. That is a valid use case, so add a regression test to ensure this can be done.

---
 tests/xfs/766     |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/766.out |    5 ++++
 tests/xfs/group   |    1 +
 3 files changed, 69 insertions(+)
 create mode 100755 tests/xfs/766
 create mode 100644 tests/xfs/766.out
tests/xfs/766 new file +49 -0
new file mode 100755
index 00000000..55bc03af
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 766
+#
+# Regression test for incorrect validation of ondisk dquot type flags when
+# we're switching between group and project quotas while mounting a V4
+# filesystem.  This test doesn't actually force the creation of a V4 fs because
+# even V5 filesystems ought to be able to switch between the two without
+# triggering corruption errors.
+#
+# The appropriate XFS patch is:
+# xfs: fix incorrect root dquot corruption error when switching group/project
+# quota types
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/quota
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_debug
+_require_quota
+_require_scratch
+
+rm -f $seqres.full
+
+echo "Format filesystem" | tee -a $seqres.full
+_scratch_mkfs > $seqres.full
+
+echo "Mount with project quota" | tee -a $seqres.full
+_qmount_option 'prjquota'
+_qmount

tests/xfs/766 line 59

Quoted 10 lines
tests/xfs/766 new file +10 -0
+_require_prjquota $SCRATCH_DEV
+
+echo "Mount with group quota" | tee -a $seqres.full
+_qmount_option 'grpquota'
+_qmount
+$here/src/feature -G $SCRATCH_DEV || echo "group quota didn't mount?"
+
+echo "Check dmesg for corruption"
+_check_dmesg_for corruption && \
+	echo "should not have seen corruption messages"

Is this dmesg output need XFS_DEBUG? Or need XFS_WARN at least?

Quoted 28 lines
tests/xfs/766 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/xfs/766.out new file +5 -0
new file mode 100644
index 00000000..18bd99f0
@@ -0,0 +1,5 @@
+QA output created by 766
+Format filesystem
+Mount with project quota
+Mount with group quota
+Check dmesg for corruption
tests/xfs/group +1 -0
index fb78b0d7..cdca04b5 100644
@@ -545,6 +545,7 @@
 763 auto quick rw realtime
 764 auto quick repair
 765 auto quick quota
+766 auto quick quota
 908 auto quick bigtime
 909 auto quick bigtime quota
 910 auto quick inobtcount
Reviewed-by on v1 1/1
#3 lore raw
In reply to Darrick J. Wong
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This is a regression test for incorrect ondisk dquot type checking that was introduced in Linux 5.9. The bug is that we can no longer switch a V4 filesystem from having group quotas to having project quotas (or vice versa) without logging corruption errors. That is a valid use case, so add a regression test to ensure this can be done.

Looks good to me.

Quoted 101 lines
---
 tests/xfs/766     |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/766.out |    5 ++++
 tests/xfs/group   |    1 +
 3 files changed, 69 insertions(+)
 create mode 100755 tests/xfs/766
 create mode 100644 tests/xfs/766.out
tests/xfs/766 new file +63 -0
new file mode 100755
index 00000000..55bc03af
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 766
+#
+# Regression test for incorrect validation of ondisk dquot type flags when
+# we're switching between group and project quotas while mounting a V4
+# filesystem.  This test doesn't actually force the creation of a V4 fs because
+# even V5 filesystems ought to be able to switch between the two without
+# triggering corruption errors.
+#
+# The appropriate XFS patch is:
+# xfs: fix incorrect root dquot corruption error when switching group/project
+# quota types
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/quota
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_debug
+_require_quota
+_require_scratch
+
+rm -f $seqres.full
+
+echo "Format filesystem" | tee -a $seqres.full
+_scratch_mkfs > $seqres.full
+
+echo "Mount with project quota" | tee -a $seqres.full
+_qmount_option 'prjquota'
+_qmount
+_require_prjquota $SCRATCH_DEV
+
+echo "Mount with group quota" | tee -a $seqres.full
+_qmount_option 'grpquota'
+_qmount
+$here/src/feature -G $SCRATCH_DEV || echo "group quota didn't mount?"
+
+echo "Check dmesg for corruption"
+_check_dmesg_for corruption && \
+	echo "should not have seen corruption messages"
+
+# success, all done
+status=0
+exit
tests/xfs/766.out new file +5 -0
new file mode 100644
index 00000000..18bd99f0
@@ -0,0 +1,5 @@
+QA output created by 766
+Format filesystem
+Mount with project quota
+Mount with group quota
+Check dmesg for corruption
tests/xfs/group +1 -0
index fb78b0d7..cdca04b5 100644
@@ -545,6 +545,7 @@
 763 auto quick rw realtime
 764 auto quick repair
 765 auto quick quota
+766 auto quick quota
 908 auto quick bigtime
 909 auto quick bigtime quota
 910 auto quick inobtcount
Signature · 1 line
chandan
#4 lore raw
In reply to Darrick J. Wong
Quoted 53 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This is a regression test for incorrect ondisk dquot type checking that was introduced in Linux 5.9. The bug is that we can no longer switch a V4 filesystem from having group quotas to having project quotas (or vice versa) without logging corruption errors. That is a valid use case, so add a regression test to ensure this can be done.

---
 tests/xfs/766     |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/766.out |    5 ++++
 tests/xfs/group   |    1 +
 3 files changed, 69 insertions(+)
 create mode 100755 tests/xfs/766
 create mode 100644 tests/xfs/766.out
tests/xfs/766 new file +30 -0
new file mode 100755
index 00000000..55bc03af
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 766
+#
+# Regression test for incorrect validation of ondisk dquot type flags when
+# we're switching between group and project quotas while mounting a V4
+# filesystem.  This test doesn't actually force the creation of a V4 fs because
+# even V5 filesystems ought to be able to switch between the two without
+# triggering corruption errors.
+#
+# The appropriate XFS patch is:
+# xfs: fix incorrect root dquot corruption error when switching group/project
+# quota types
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}

tests/xfs/766 line 40

Quoted 10 lines
tests/xfs/766 new file +10 -0
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/quota
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_debug
+_require_quota
+_require_scratch

Also need _require_check_dmesg

Quoted 9 lines
tests/xfs/766 new file +9 -0
+
+rm -f $seqres.full
+
+echo "Format filesystem" | tee -a $seqres.full
+_scratch_mkfs > $seqres.full
+
+echo "Mount with project quota" | tee -a $seqres.full
+_qmount_option 'prjquota'
+_qmount

tests/xfs/766 line 59

Quoted 10 lines
tests/xfs/766 new file +10 -0
+_require_prjquota $SCRATCH_DEV
+
+echo "Mount with group quota" | tee -a $seqres.full
+_qmount_option 'grpquota'
+_qmount
+$here/src/feature -G $SCRATCH_DEV || echo "group quota didn't mount?"
+
+echo "Check dmesg for corruption"
+_check_dmesg_for corruption && \
+	echo "should not have seen corruption messages"

I'd do the following to print the dmesg in question as well, so we know what is actually failing the test.

_dmesg_since_test_start | grep corruption

A failure will look like

    --- tests/xfs/527.out       2021-02-07 23:00:46.679485872 +0800
    +++ /root/workspace/xfstests/results//xfs_4k/xfs/527.out.bad        2021-02-07 23:10:16.745371039 +0800
    @@ -3,3 +3,5 @@
     Mount with project quota
     Mount with group quota
     Check dmesg for corruption
    +[1211043.882535] XFS (dm-5): Metadata corruption detected at xfs_dquot_from_disk+0x1b4/0x1f0 [xfs], quota 0
    +[1211043.890173] XFS (dm-5): Metadata corruption detected at xfs_dquot_from_disk+0x1b4/0x1f0 [xfs], quota 0
    ...

I'll fix both on commit.

Thanks,
Eryu

Quoted 27 lines
tests/xfs/766 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/xfs/766.out new file +5 -0
new file mode 100644
index 00000000..18bd99f0
@@ -0,0 +1,5 @@
+QA output created by 766
+Format filesystem
+Mount with project quota
+Mount with group quota
+Check dmesg for corruption
tests/xfs/group +1 -0
index fb78b0d7..cdca04b5 100644
@@ -545,6 +545,7 @@
 763 auto quick rw realtime
 764 auto quick repair
 765 auto quick quota
+766 auto quick quota
 908 auto quick bigtime
 909 auto quick bigtime quota
 910 auto quick inobtcount
#5 lore raw
Quoted 104 lines · Eryu Guan
Quoted 53 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

This is a regression test for incorrect ondisk dquot type checking that was introduced in Linux 5.9. The bug is that we can no longer switch a V4 filesystem from having group quotas to having project quotas (or vice versa) without logging corruption errors. That is a valid use case, so add a regression test to ensure this can be done.

---
 tests/xfs/766     |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/766.out |    5 ++++
 tests/xfs/group   |    1 +
 3 files changed, 69 insertions(+)
 create mode 100755 tests/xfs/766
 create mode 100644 tests/xfs/766.out
tests/xfs/766 new file +30 -0
new file mode 100755
index 00000000..55bc03af
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 766
+#
+# Regression test for incorrect validation of ondisk dquot type flags when
+# we're switching between group and project quotas while mounting a V4
+# filesystem.  This test doesn't actually force the creation of a V4 fs because
+# even V5 filesystems ought to be able to switch between the two without
+# triggering corruption errors.
+#
+# The appropriate XFS patch is:
+# xfs: fix incorrect root dquot corruption error when switching group/project
+# quota types
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}

tests/xfs/766 line 40

Quoted 10 lines
tests/xfs/766 new file +10 -0
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/quota
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_debug
+_require_quota
+_require_scratch

Also need _require_check_dmesg

Quoted 9 lines
tests/xfs/766 new file +9 -0
+
+rm -f $seqres.full
+
+echo "Format filesystem" | tee -a $seqres.full
+_scratch_mkfs > $seqres.full
+
+echo "Mount with project quota" | tee -a $seqres.full
+_qmount_option 'prjquota'
+_qmount

tests/xfs/766 line 59

Quoted 10 lines
tests/xfs/766 new file +10 -0
+_require_prjquota $SCRATCH_DEV
+
+echo "Mount with group quota" | tee -a $seqres.full
+_qmount_option 'grpquota'
+_qmount
+$here/src/feature -G $SCRATCH_DEV || echo "group quota didn't mount?"
+
+echo "Check dmesg for corruption"
+_check_dmesg_for corruption && \
+	echo "should not have seen corruption messages"

I'd do the following to print the dmesg in question as well, so we know what is actually failing the test.

_dmesg_since_test_start | grep corruption

A failure will look like

    --- tests/xfs/527.out       2021-02-07 23:00:46.679485872 +0800
    +++ /root/workspace/xfstests/results//xfs_4k/xfs/527.out.bad        2021-02-07 23:10:16.745371039 +0800
    @@ -3,3 +3,5 @@
     Mount with project quota
     Mount with group quota
     Check dmesg for corruption
    +[1211043.882535] XFS (dm-5): Metadata corruption detected at xfs_dquot_from_disk+0x1b4/0x1f0 [xfs], quota 0
    +[1211043.890173] XFS (dm-5): Metadata corruption detected at xfs_dquot_from_disk+0x1b4/0x1f0 [xfs], quota 0
    ...
Quoted 1 line

I'll fix both on commit.

Oh! Thank you!

--D

Quoted 30 lines

Thanks,
Eryu

Quoted 27 lines
tests/xfs/766 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/xfs/766.out new file +5 -0
new file mode 100644
index 00000000..18bd99f0
@@ -0,0 +1,5 @@
+QA output created by 766
+Format filesystem
+Mount with project quota
+Mount with group quota
+Check dmesg for corruption
tests/xfs/group +1 -0
index fb78b0d7..cdca04b5 100644
@@ -545,6 +545,7 @@
 763 auto quick rw realtime
 764 auto quick repair
 765 auto quick quota
+766 auto quick quota
 908 auto quick bigtime
 909 auto quick bigtime quota
 910 auto quick inobtcount