Skip to contentSkip to conversation

btrfs: Test if btrfs hits EDQUOT without trying to reclaim some space

PATCH Superseded Qu Wenruo 2 participants 2 messages Jan 28, 2019 – Jan 29, 2019 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs: Test if btrfs hits EDQUOT without trying to reclaim some space

Commit a514d63882c3 ("btrfs: qgroup: Commit transaction in advance to reduce early EDQUOT") is no longer forcing transaction commit to reclaim space, and only commits transaction asynchronously in advance to address it.

However the criteria used in async transaction commit is not comprehensive, thus it doesn't reclaim space automatically.

This test case will check the behavior by:
1) Falloc a large padding file
This file will take 90% of the qgroup limit

2) Sync the fs
To reflect the qgroup changes

3) Delete the file
Qgroup won't reclaim the space until transaction committed.

4) Try to write a file
If kernel not fixed, qgroup will not automatically commit transaction to reclaim the freed space and hit EDQUOT.

This bug is going to be fxied by a patch for kernel titled "btrfs: qgroup: Make qgroup async transaction commit more aggressive".

---
 tests/btrfs/180     | 62 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/180.out |  3 +++
 tests/btrfs/group   |  1 +
 3 files changed, 66 insertions(+)
 create mode 100755 tests/btrfs/180
 create mode 100644 tests/btrfs/180.out
tests/btrfs/180 new file +62 -0
new file mode 100755
index 00000000..df876310
@@ -0,0 +1,62 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test 180
+#
+# Test if btrfs hits EDQUOT without reclaim already freed extents when quota
+# is enabled.
+#
+# This bug is going to be fxied by a patch for kernel titled
+# "btrfs: qgroup: Make qgroup async transaction commit more aggressive"
+#
+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
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_xfs_io_command falloc
+
+_scratch_mkfs > /dev/null
+_scratch_mount
+
+$BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null
+$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null
+$BTRFS_UTIL_PROG qgroup limit -e 1G "$SCRATCH_MNT"
+
+$XFS_IO_PROG -f -c "falloc 0 900M" "$SCRATCH_MNT/padding" | _filter_xfs_io
+
+# Commit transaction to reflect the quota usage
+sync
+
+rm "$SCRATCH_MNT/padding"
+
+# Without the kernel fix, this will trigger EDQUOT.
+_pwrite_byte 0xcd 0 512M "$SCRATCH_MNT/real_file" | _filter_xfs_io
+
+# success, all done
+status=0
+exit
tests/btrfs/180.out new file +3 -0
new file mode 100644
index 00000000..17187477
@@ -0,0 +1,3 @@
+QA output created by 180
+wrote 536870912/536870912 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
tests/btrfs/group +1 -0
index 46dd3c95..03eb62f9 100644
@@ -182,3 +182,4 @@
 177 auto quick swap balance
 178 auto quick send
 179 auto qgroup dangerous
+180 auto quick qgroup limit
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Qu Wenruo

Commit a514d63882c3 ("btrfs: qgroup: Commit transaction in advance to reduce early EDQUOT") is no longer forcing transaction commit to reclaim space, and only commits transaction asynchronously in advance to address it.

However the criteria used in async transaction commit is not comprehensive, thus it doesn't reclaim space automatically.

This test case will check the behavior by:
1) Falloc a large padding file
This file will take 90% of the qgroup limit

2) Sync the fs
To reflect the qgroup changes

Quoted 8 lines

3) Delete the file
Qgroup won't reclaim the space until transaction committed.

4) Try to write a file
If kernel not fixed, qgroup will not automatically commit transaction to reclaim the freed space and hit EDQUOT.

This bug is going to be fxied by a patch for kernel titled

fxied -> fixed

titled -> titled:

Quoted 17 lines

"btrfs: qgroup: Make qgroup async transaction commit more aggressive".

---
 tests/btrfs/180     | 62 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/180.out |  3 +++
 tests/btrfs/group   |  1 +
 3 files changed, 66 insertions(+)
 create mode 100755 tests/btrfs/180
 create mode 100644 tests/btrfs/180.out
tests/btrfs/180 new file +0 -0
new file mode 100755
index 00000000..df876310

tests/btrfs/180 line 7

Quoted 7 lines
tests/btrfs/180 new file +7 -0
@@ -0,0 +1,62 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test 180
+#
+# Test if btrfs hits EDQUOT without reclaim already freed extents when quota

reclaim -> reclaiming

Quoted 33 lines
tests/btrfs/180 new file +33 -0
+# is enabled.
+#
+# This bug is going to be fxied by a patch for kernel titled
+# "btrfs: qgroup: Make qgroup async transaction commit more aggressive"
+#
+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
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch

tests/btrfs/180 line 50

Quoted 10 lines
tests/btrfs/180 new file +10 -0
+_require_xfs_io_command falloc
+
+_scratch_mkfs > /dev/null
+_scratch_mount
+
+$BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null
+$BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null
+$BTRFS_UTIL_PROG qgroup limit -e 1G "$SCRATCH_MNT"
+
+$XFS_IO_PROG -f -c "falloc 0 900M" "$SCRATCH_MNT/padding" | _filter_xfs_io

No need to use the _filter_xfs_io for falloc (it doesn't output throughput values such as the write, reflink and dedupe commands).

tests/btrfs/180 line 55

Quoted 5 lines
tests/btrfs/180 new file +5 -0
+
+# Commit transaction to reflect the quota usage
+sync
+
+rm "$SCRATCH_MNT/padding"

I would pass -f to rm. It's not uncommon to have setups with "alias rm='rm -i'".

Other than that, it looks good.

Thanks.

Quoted 28 lines
tests/btrfs/180 new file +7 -0
+
+# Without the kernel fix, this will trigger EDQUOT.
+_pwrite_byte 0xcd 0 512M "$SCRATCH_MNT/real_file" | _filter_xfs_io
+
+# success, all done
+status=0
+exit
tests/btrfs/180.out new file +3 -0
new file mode 100644
index 00000000..17187477
@@ -0,0 +1,3 @@
+QA output created by 180
+wrote 536870912/536870912 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
tests/btrfs/group +1 -1
index 46dd3c95..03eb62f9 100644
@@ -182,3 +182,4 @@
 177 auto quick swap balance
 178 auto quick send
 179 auto qgroup dangerous
+180 auto quick qgroup limit
--

2.18.0

Signature · 3 lines
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”