2022-08-03 04:22:46

by Darrick J. Wong

[permalink] [raw]
Subject: [PATCH 2/3] common/rc: move XFS-specific parts of _scratch_options into common/xfs

From: Darrick J. Wong <[email protected]>

Move all the non-XFS code in _scratch_options into a
_scratch_xfs_options helper in common/xfs, in preparation to add ext4
bits.

Signed-off-by: Darrick J. Wong <[email protected]>
---
common/rc | 23 +++--------------------
common/xfs | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+), 20 deletions(-)


diff --git a/common/rc b/common/rc
index 52dd3b41..dc1d65c3 100644
--- a/common/rc
+++ b/common/rc
@@ -172,30 +172,13 @@ _clear_mount_stack()

_scratch_options()
{
- local type=$1
- local rt_opt=""
- local log_opt=""
SCRATCH_OPTIONS=""

- if [ "$FSTYP" != "xfs" ]; then
- return
- fi
-
- case $type in
- mkfs)
- SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
- rt_opt="-r"
- log_opt="-l"
- ;;
- mount)
- rt_opt="-o"
- log_opt="-o"
+ case "$FSTYP" in
+ "xfs")
+ _scratch_xfs_options "[email protected]"
;;
esac
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
- SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
- [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
- SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
}

_test_options()
diff --git a/common/xfs b/common/xfs
index 9f84dffb..f6f4cdd2 100644
--- a/common/xfs
+++ b/common/xfs
@@ -265,6 +265,29 @@ _xfs_check()
return $status
}

+_scratch_xfs_options()
+{
+ local type=$1
+ local rt_opt=""
+ local log_opt=""
+
+ case $type in
+ mkfs)
+ SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
+ rt_opt="-r"
+ log_opt="-l"
+ ;;
+ mount)
+ rt_opt="-o"
+ log_opt="-o"
+ ;;
+ esac
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
+ SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
+}
+
_scratch_xfs_db_options()
{
SCRATCH_OPTIONS=""