[PATCH 2/2] fstests: add configuration option for executing post mkfs commands

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



This patch introduces new configuration file parameters,
POST_SCRATCH_MKFS_CMD and POST_SCRATCH_POOL_MKFS_CMD.

Usage example:

        POST_SCRATCH_MKFS_CMD="btrfstune -m"
        POST_SCRATCH_POOL_MKFS_CMD="btrfstune -m"

With this configuration option, test cases using _scratch_mkfs(),
scratch_pool_mkfs(), or _scratch_mkfs_sized() will run the above
set value after the mkfs operation.

Other mkfs functions, such as _mkfs_dev(), are not connected to the
POST_SCRATCH_MKFS_CMD.

Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx>
---
 common/btrfs | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/common/btrfs b/common/btrfs
index 798c899f6233..b0972e882c7c 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -690,17 +690,48 @@ _require_btrfs_scratch_logical_resolve_v2()
 	_scratch_unmount
 }
 
+post_scratch_mkfs_cmd()
+{
+	if [[ -v POST_SCRATCH_MKFS_CMD ]]; then
+		echo "$POST_SCRATCH_MKFS_CMD $SCRATCH_DEV"
+		$POST_SCRATCH_MKFS_CMD $SCRATCH_DEV
+		return $?
+	fi
+
+	return 0
+}
+
+post_scratch_pool_mkfs_cmd()
+{
+	if [[ -v POST_SCRATCH_POOL_MKFS_CMD ]]; then
+		echo "$POST_SCRATCH_POOL_MKFS_CMD $SCRATCH_DEV_POOL"
+		$POST_SCRATCH_POOL_MKFS_CMD $SCRATCH_DEV_POOL
+		return $?
+	fi
+
+	return 0
+}
+
 _scratch_mkfs_retry_btrfs()
 {
 	# _scratch_do_mkfs() may retry mkfs without $MKFS_OPTIONS
 	_scratch_do_mkfs "$MKFS_BTRFS_PROG" "cat" $*
 
+	if [[ $? == 0 ]]; then
+		post_scratch_mkfs_cmd
+	fi
+
 	return $?
 }
 
 _scratch_mkfs_btrfs()
 {
 	$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
+
+	if [[ $? == 0 ]]; then
+		post_scratch_mkfs_cmd
+	fi
+
 	return $?
 }
 
@@ -708,5 +739,9 @@ _scratch_pool_mkfs_btrfs()
 {
 	$MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV_POOL
 
+	if [[ $? == 0 ]]; then
+		post_scratch_pool_mkfs_cmd
+	fi
+
 	return $?
 }
-- 
2.39.3




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux