btrfs: Test if btrfs will report false ENOSPC error balancing small metadata chunk
authorQu Wenruo <wqu@suse.com>
Tue, 29 Jan 2019 12:32:22 +0000 (20:32 +0800)
committerEryu Guan <guaneryu@gmail.com>
Wed, 30 Jan 2019 01:39:08 +0000 (09:39 +0800)
This is a test case for a long existing bug, caused by
over-estimated metadata space_info::bytes_may_use.

There is one proposed patch for btrfs-progs to fix it, titled:
"btrfs-progs: balance: Sync the fs before balancing metadata chunks"

The test case itself is almost the same as btrfs/181, which uses
small files to bump the reserved space to trigger the false alert.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/182 [new file with mode: 0755]
tests/btrfs/182.out [new file with mode: 0644]
tests/btrfs/group

diff --git a/tests/btrfs/182 b/tests/btrfs/182
new file mode 100755 (executable)
index 0000000..19b4ad8
--- /dev/null
@@ -0,0 +1,61 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test 182
+#
+# Test if balance will report false ENOSPC error
+#
+# This is a long existing bug, caused by over-estimated metadata
+# space_info::bytes_may_use.
+#
+# There is one proposed patch for btrfs-progs to fix it, titled:
+# "btrfs-progs: balance: Sync the fs before balancing metadata chunks"
+#
+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
+
+nr_files=1024
+
+_scratch_mkfs > /dev/null
+_scratch_mount
+
+$BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/subvol" > /dev/null
+
+# Create some small files to take up enough metadata reserved space
+for ((i = 0; i < $nr_files; i++)) do
+       _pwrite_byte 0xcd 0 1K "$SCRATCH_MNT/subvol/file_$i" > /dev/null
+done
+
+$BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" > /dev/null
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/182.out b/tests/btrfs/182.out
new file mode 100644 (file)
index 0000000..53d28e5
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 182
+Silence is golden
index 0db485cbe83434b22b5a6d6b6956ed5f21b07074..e32c84e4b253ab0c98ff94d665fc381600e7a875 100644 (file)
 179 auto qgroup dangerous
 180 auto quick qgroup limit
 181 auto quick balance
+182 auto quick balance