mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
btrfs: Add test for corrupted childless qgroup numbers
This bug is exposed by populating a high level qgroup, and then make it childless with old qgroup numbers, and finally do rescan. Normally rescan should zero out all qgroups' accounting number, but due to a kernel bug which won't mark childless qgroups dirty, their on-disk data is never updated, thus old numbers remain and cause qgroup corruption. Fixed by the following kernel patch: "btrfs: qgroup: Dirty all qgroups before rescan" [Eryu: removed useless _filter_xfs_io] Reported-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
@@ -88,5 +88,14 @@ _filter_btrfs_prop_error()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# filter warning messages caused by "btrfs quota assign/remove" command.
|
||||||
|
# Since qgroup relationship change could cause qgroup inconsistency, it would
|
||||||
|
# either trigger a qgroup rescan, or warning message.
|
||||||
|
_filter_btrfs_qgroup_assign_warnings()
|
||||||
|
{
|
||||||
|
sed -e "/Quota data changed, rescan scheduled/d" \
|
||||||
|
-e "/quotas may be inconsistent, rescan needed/d"
|
||||||
|
}
|
||||||
|
|
||||||
# make sure this script returns success
|
# make sure this script returns success
|
||||||
/bin/true
|
/bin/true
|
||||||
|
|||||||
Executable
+85
@@ -0,0 +1,85 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
# Copyright (c) 2018 SUSE Linux Products GmbH. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# FS QA Test 171
|
||||||
|
#
|
||||||
|
# Test if btrfs can clear high level childless qgroup's accounting numbers
|
||||||
|
# during rescan.
|
||||||
|
#
|
||||||
|
# Fixed by the following kernel patch:
|
||||||
|
# "btrfs: qgroup: Dirty all qgroups before rescan"
|
||||||
|
#
|
||||||
|
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/filter
|
||||||
|
. ./common/filter.btrfs
|
||||||
|
|
||||||
|
# remove previous $seqres.full before test
|
||||||
|
rm -f $seqres.full
|
||||||
|
|
||||||
|
# real QA test starts here
|
||||||
|
_supported_fs btrfs
|
||||||
|
_supported_os Linux
|
||||||
|
_require_scratch
|
||||||
|
|
||||||
|
_scratch_mkfs > /dev/null 2>&1
|
||||||
|
_scratch_mount
|
||||||
|
|
||||||
|
|
||||||
|
# Populate the fs
|
||||||
|
$BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/subvol" > /dev/null
|
||||||
|
_pwrite_byte 0xcdcd 0 1M "$SCRATCH_MNT/subvol/file1" > /dev/null
|
||||||
|
|
||||||
|
# Ensure that buffered file data is persisted, so we won't have an
|
||||||
|
# empty file in the snapshot.
|
||||||
|
sync
|
||||||
|
$BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/subvol" \
|
||||||
|
"$SCRATCH_MNT/snapshot" > /dev/null
|
||||||
|
|
||||||
|
|
||||||
|
$BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null
|
||||||
|
$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null
|
||||||
|
|
||||||
|
# Create high level qgroup
|
||||||
|
$BTRFS_UTIL_PROG qgroup create 1/0 "$SCRATCH_MNT"
|
||||||
|
|
||||||
|
$BTRFS_UTIL_PROG qgroup assign "$SCRATCH_MNT/snapshot" 1/0 "$SCRATCH_MNT" \
|
||||||
|
2>&1 | _filter_btrfs_qgroup_assign_warnings
|
||||||
|
|
||||||
|
# Above assignment will mark qgroup inconsistent due to the shared extents
|
||||||
|
# between subvol/snapshot/high level qgroup, do rescan here.
|
||||||
|
$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null
|
||||||
|
|
||||||
|
# Now remove the qgroup relationship and make 1/0 childless
|
||||||
|
# Due to the shared extent outside of 1/0, we will mark qgroup inconsistent
|
||||||
|
# and keep the number of qgroup 1/0.
|
||||||
|
$BTRFS_UTIL_PROG qgroup remove "$SCRATCH_MNT/snapshot" 1/0 "$SCRATCH_MNT" \
|
||||||
|
2>&1 | _filter_btrfs_qgroup_assign_warnings
|
||||||
|
|
||||||
|
# Above removal also marks qgroup inconsistent, rescan again
|
||||||
|
$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null
|
||||||
|
|
||||||
|
# After the test, btrfs check will verify qgroup numbers to catch any
|
||||||
|
# corruption.
|
||||||
|
|
||||||
|
echo "Silence is golden"
|
||||||
|
|
||||||
|
# success, all done
|
||||||
|
status=0
|
||||||
|
exit
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
QA output created by 171
|
||||||
|
Silence is golden
|
||||||
@@ -173,3 +173,4 @@
|
|||||||
168 auto quick send
|
168 auto quick send
|
||||||
169 auto quick send
|
169 auto quick send
|
||||||
170 auto quick snapshot
|
170 auto quick snapshot
|
||||||
|
171 auto quick qgroup
|
||||||
|
|||||||
Reference in New Issue
Block a user