diff mbox

[v6,3/6] fstests: Add btrfs dedupe post mount hook

Message ID 20160914015527.10274-4-quwenruo@cn.fujitsu.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Qu Wenruo Sept. 14, 2016, 1:55 a.m. UTC
Now fstests can run any test cases with btrfs inband-dedupe enabled.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 common/rc | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/common/rc b/common/rc
index 636cba6..e0da69b 100644
--- a/common/rc
+++ b/common/rc
@@ -326,10 +326,26 @@  _run_btrfs_post_mount_hook()
 	mnt_point=$1
 	for n in $ALWAYS_ENABLE_BTRFS_FEATURE; do
 		if [ $n == "quota" -o $n == "qgroup" ]; then
-			# Quota can be enabled for several times
-			# and won't cause bug
+			# Re-enable quota won't cause anything wrong
 			_run_btrfs_util_prog quota enable $mnt_point
 		fi
+		if [ $n == "dedupe" -o $n == "inband-dedupe" -o $n == "dedupe-inband" ]; then
+			# Need to check if kernel/progs support dedupe
+			_require_btrfs_fs_feature dedupe
+			_require_btrfs_subcommand dedupe
+
+			# Check if dedupe is already enabled, or we will
+			# overwrite previous on-disk backend config
+			$BTRFS_UTIL_PROG dedupe status $mnt_point | grep -q "Enabled"
+			if [ $1 -eq 0 ]; then
+				continue
+			fi
+
+			# This will enable dedupe with default options, so
+			# btrfs dedupe test cases needs to use '-f' option to
+			# override default config.
+			_run_btrfs_util_prog dedupe enable $mnt_point
+		fi
 	done
 }