diff mbox

[v2,1/4] common/rc: factor out _require_scratch_fs_option

Message ID 1524722007-30891-2-git-send-email-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Amir Goldstein April 26, 2018, 5:53 a.m. UTC
Factor out _require_scratch_fs_option and _check_scratch_fs_option
from the helper _require_scratch_dax.
Those are generic helpers to test if mount option is supported and
if mount option was enabled.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 common/rc | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/common/rc b/common/rc
index 366489b..78bc59d 100644
--- a/common/rc
+++ b/common/rc
@@ -3036,20 +3036,35 @@  _require_scratch_shutdown()
 	_scratch_unmount
 }
 
-# Does dax mount option work on this dev/fs?
-_require_scratch_dax()
+_check_scratch_fs_option()
+{
+	local opt=$1
+
+	_fs_options $SCRATCH_DEV | grep -qw "$opt"
+}
+
+# Does mount option work on this dev/fs?
+_require_scratch_fs_option()
 {
+	local opt=$1
+
 	_require_scratch
 	_scratch_mkfs > /dev/null 2>&1
-	_try_scratch_mount -o dax || \
-		_notrun "mount $SCRATCH_DEV with dax failed"
-	# Check options to be sure. XFS ignores dax option
+	_try_scratch_mount -o "$opt" || \
+		_notrun "mount $SCRATCH_DEV with $opt failed"
+	# Check options to be sure. For example, XFS ignores dax option
 	# and goes on if dev underneath does not support dax.
-	_fs_options $SCRATCH_DEV | grep -qw "dax" || \
-		_notrun "$SCRATCH_DEV $FSTYP does not support -o dax"
+	_check_scratch_fs_option "$opt" || \
+		_notrun "$SCRATCH_DEV $FSTYP does not support -o $opt"
 	_scratch_unmount
 }
 
+# Does dax mount option work on this dev/fs?
+_require_scratch_dax()
+{
+	_require_scratch_fs_option "dax"
+}
+
 # Does norecovery support by this fs?
 _require_norecovery()
 {