fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: guaneryu@gmail.com, Christoph Hellwig <hch@infradead.org>
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH 27/24] common/rc: fix indentation in _scratch_mkfs_sized
Date: Thu, 17 Sep 2020 19:11:09 -0700	[thread overview]
Message-ID: <20200918021109.GL7954@magnolia> (raw)
In-Reply-To: <160013417420.2923511.6825722200699287884.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Fix the weird indentation in _scratch_mkfs_sized.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc |  205 ++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 102 insertions(+), 103 deletions(-)

diff --git a/common/rc b/common/rc
index 3adeeefe..94936a8e 100644
--- a/common/rc
+++ b/common/rc
@@ -956,116 +956,115 @@ _available_memory_bytes()
 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
 _scratch_mkfs_sized()
 {
-    local fssize=$1
-    local blocksize=$2
-    local def_blksz
+	local fssize=$1
+	local blocksize=$2
+	local def_blksz
 
-    case $FSTYP in
-    xfs)
-	def_blksz=`echo $MKFS_OPTIONS|sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
-	;;
-    ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2|reiserfs)
-	def_blksz=`echo $MKFS_OPTIONS| sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
-	;;
-    jfs)
-	def_blksz=4096
-	;;
-    esac
+	case $FSTYP in
+	xfs)
+		def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
+		;;
+	ext2|ext3|ext4|ext4dev|udf|btrfs|reiser4|ocfs2|reiserfs)
+		def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
+		;;
+	jfs)
+		def_blksz=4096
+		;;
+	esac
 
-    [ -n "$def_blksz" ] && blocksize=$def_blksz
-    [ -z "$blocksize" ] && blocksize=4096
+	[ -n "$def_blksz" ] && blocksize=$def_blksz
+	[ -z "$blocksize" ] && blocksize=4096
 
+	local re='^[0-9]+$'
+	if ! [[ $fssize =~ $re ]] ; then
+		_notrun "error: _scratch_mkfs_sized: fs size \"$fssize\" not an integer."
+	fi
+	if ! [[ $blocksize =~ $re ]] ; then
+		_notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
+	fi
 
-    local re='^[0-9]+$'
-    if ! [[ $fssize =~ $re ]] ; then
-        _notrun "error: _scratch_mkfs_sized: fs size \"$fssize\" not an integer."
-    fi
-    if ! [[ $blocksize =~ $re ]] ; then
-        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
-    fi
-
-    local blocks=`expr $fssize / $blocksize`
-
-    if [ -b "$SCRATCH_DEV" ]; then
-	local devsize=`blockdev --getsize64 $SCRATCH_DEV`
-	[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
-    fi
-
-    if [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
-	local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
-	[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
-	rt_ops="-r size=$fssize"
-    fi
+	local blocks=`expr $fssize / $blocksize`
 
-    case $FSTYP in
-    xfs)
-	# don't override MKFS_OPTIONS that set a block size.
-	echo $MKFS_OPTIONS |egrep -q "b?size="
-	if [ $? -eq 0 ]; then
-		_scratch_mkfs_xfs -d size=$fssize $rt_ops
-	else
-		_scratch_mkfs_xfs -d size=$fssize $rt_ops -b size=$blocksize
-	fi
-	;;
-    ext2|ext3|ext4|ext4dev)
-	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    gfs2)
-	# mkfs.gfs2 doesn't automatically shrink journal files on small
-	# filesystems, so the journal files may end up being bigger than the
-	# filesystem, which will cause mkfs.gfs2 to fail.  Until that's fixed,
-	# shrink the journal size to at most one eigth of the filesystem and at
-	# least 8 MiB, the minimum size allowed.
-	local min_journal_size=8
-	local default_journal_size=128
-	if (( fssize/8 / (1024*1024) < default_journal_size )); then
-	    local journal_size=$(( fssize/8 / (1024*1024) ))
-	    (( journal_size >= min_journal_size )) || journal_size=$min_journal_size
-	    MKFS_OPTIONS="-J $journal_size $MKFS_OPTIONS"
+	if [ -b "$SCRATCH_DEV" ]; then
+		local devsize=`blockdev --getsize64 $SCRATCH_DEV`
+		[ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
 	fi
-	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    ocfs2)
-	yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    udf)
-	$MKFS_UDF_PROG $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    btrfs)
-	local mixed_opt=
-	# minimum size that's needed without the mixed option.
-	# Ref: btrfs-prog: btrfs_min_dev_size()
-	# Non mixed mode is also the default option.
-	(( fssize < $((256 * 1024 *1024)) )) && mixed_opt='--mixed'
-	$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
-	;;
-    jfs)
-	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS $SCRATCH_DEV $blocks
-	;;
-    reiserfs)
-	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
-	;;
-    reiser4)
-	# mkfs.resier4 requires size in KB as input for creating filesystem
-	$MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \
-			   `expr $fssize / 1024`
-	;;
-    f2fs)
-	# mkfs.f2fs requires # of sectors as an input for the size
-	local sector_size=`blockdev --getss $SCRATCH_DEV`
-	$MKFS_F2FS_PROG $MKFS_OPTIONS $SCRATCH_DEV `expr $fssize / $sector_size`
-	;;
-    tmpfs)
-	local free_mem=`_free_memory_bytes`
-	if [ "$free_mem" -lt "$fssize" ] ; then
-	   _notrun "Not enough memory ($free_mem) for tmpfs with $fssize bytes"
+
+	if [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
+		local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
+		[ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
+		rt_ops="-r size=$fssize"
 	fi
-	export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS"
-	;;
-    *)
-	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
-	;;
-    esac
+
+	case $FSTYP in
+	xfs)
+		# don't override MKFS_OPTIONS that set a block size.
+		echo $MKFS_OPTIONS |egrep -q "b?size="
+		if [ $? -eq 0 ]; then
+			_scratch_mkfs_xfs -d size=$fssize $rt_ops
+		else
+			_scratch_mkfs_xfs -d size=$fssize $rt_ops -b size=$blocksize
+		fi
+		;;
+	ext2|ext3|ext4|ext4dev)
+		${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	gfs2)
+		# mkfs.gfs2 doesn't automatically shrink journal files on small
+		# filesystems, so the journal files may end up being bigger than the
+		# filesystem, which will cause mkfs.gfs2 to fail.  Until that's fixed,
+		# shrink the journal size to at most one eigth of the filesystem and at
+		# least 8 MiB, the minimum size allowed.
+		local min_journal_size=8
+		local default_journal_size=128
+		if (( fssize/8 / (1024*1024) < default_journal_size )); then
+			local journal_size=$(( fssize/8 / (1024*1024) ))
+			(( journal_size >= min_journal_size )) || journal_size=$min_journal_size
+			MKFS_OPTIONS="-J $journal_size $MKFS_OPTIONS"
+		fi
+		${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -O -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	ocfs2)
+		yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	udf)
+		$MKFS_UDF_PROG $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	btrfs)
+		local mixed_opt=
+		# minimum size that's needed without the mixed option.
+		# Ref: btrfs-prog: btrfs_min_dev_size()
+		# Non mixed mode is also the default option.
+		(( fssize < $((256 * 1024 *1024)) )) && mixed_opt='--mixed'
+		$MKFS_BTRFS_PROG $MKFS_OPTIONS $mixed_opt -b $fssize $SCRATCH_DEV
+		;;
+	jfs)
+		${MKFS_PROG}.$FSTYP $MKFS_OPTIONS $SCRATCH_DEV $blocks
+		;;
+	reiserfs)
+		${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+		;;
+	reiser4)
+		# mkfs.resier4 requires size in KB as input for creating filesystem
+		$MKFS_REISER4_PROG $MKFS_OPTIONS -y -b $blocksize $SCRATCH_DEV \
+				   `expr $fssize / 1024`
+		;;
+	f2fs)
+		# mkfs.f2fs requires # of sectors as an input for the size
+		local sector_size=`blockdev --getss $SCRATCH_DEV`
+		$MKFS_F2FS_PROG $MKFS_OPTIONS $SCRATCH_DEV `expr $fssize / $sector_size`
+		;;
+	tmpfs)
+		local free_mem=`_free_memory_bytes`
+		if [ "$free_mem" -lt "$fssize" ] ; then
+		   _notrun "Not enough memory ($free_mem) for tmpfs with $fssize bytes"
+		fi
+		export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS"
+		;;
+	*)
+		_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
+		;;
+	esac
 }
 
 # Emulate an N-data-disk stripe w/ various stripe units

  parent reply	other threads:[~2020-09-18  2:41 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15  1:42 [PATCH 00/24] fstests: tons of random fixes Darrick J. Wong
2020-09-15  1:43 ` [PATCH 01/24] xfs/331: don't run this test if fallocate isn't supported Darrick J. Wong
2020-09-15 12:39   ` Zorro Lang
2020-09-17  7:50   ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 02/24] generic/60[01]: fix test failure when setting new grace limit Darrick J. Wong
2020-09-15 12:55   ` Zorro Lang
2020-09-17  7:51   ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs Darrick J. Wong
2020-09-15 13:16   ` Zorro Lang
2020-09-17  1:41   ` Xiao Yang
2020-09-17  3:27     ` Darrick J. Wong
2020-09-17  3:43       ` Xiao Yang
2020-09-17  3:56         ` Darrick J. Wong
2020-09-17  7:52           ` Christoph Hellwig
2020-09-17 15:54             ` Darrick J. Wong
2020-09-17 16:02               ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 04/24] xfs: skip tests that rely on allocation behaviors of the data device Darrick J. Wong
2020-09-16  2:04   ` Zorro Lang
2020-09-17  7:53   ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 05/24] xfs/031: make sure we don't set rtinherit=1 on mkfs Darrick J. Wong
2020-09-16  2:21   ` Zorro Lang
2020-09-17  7:53   ` Christoph Hellwig
2020-09-17 15:57     ` Darrick J. Wong
2020-09-17 16:01       ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 06/24] xfs: wrap xfs_db calls to the test device Darrick J. Wong
2020-09-16  2:25   ` Zorro Lang
2020-09-17  7:54   ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 07/24] xfs/{111,137}: replace open-coded calls to repair with _scratch_xfs_repair Darrick J. Wong
2020-09-16  2:28   ` Zorro Lang
2020-09-17  7:54   ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 08/24] xfs: replace open-coded calls to xfs_logprint with helpers Darrick J. Wong
2020-09-16  2:35   ` Zorro Lang
2020-09-17  7:54   ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 09/24] xfs/070: add scratch log device options to direct repair invocation Darrick J. Wong
2020-09-16  2:42   ` Zorro Lang
2020-09-16  3:42     ` Darrick J. Wong
2020-09-16 11:25       ` Zorro Lang
2020-09-17  7:55   ` Christoph Hellwig
2020-09-15  1:43 ` [PATCH 10/24] xfs: add a _require_xfs_copy helper Darrick J. Wong
2020-09-16  3:29   ` Zorro Lang
2020-09-17  7:55   ` Christoph Hellwig
2020-09-15  1:44 ` [PATCH 11/24] overlay/{069,071}: fix undefined variables Darrick J. Wong
2020-09-15  8:48   ` Amir Goldstein
2020-09-15  1:44 ` [PATCH 12/24] overlay/020: make sure the system supports the required namespaces Darrick J. Wong
2020-09-15  8:46   ` Amir Goldstein
2020-09-15  1:44 ` [PATCH 13/24] generic/204: don't flood stdout with ENOSPC messages on an ENOSPC test Darrick J. Wong
2020-09-16  4:14   ` Zorro Lang
2020-09-17  7:56   ` Christoph Hellwig
2020-09-17 16:02     ` Darrick J. Wong
2020-09-15  1:44 ` [PATCH 14/24] common/xfs: extract minimum log size message from mkfs correctly Darrick J. Wong
2020-09-16  5:28   ` Zorro Lang
2020-09-17  7:56   ` Christoph Hellwig
2020-09-15  1:44 ` [PATCH 15/24] xfs/194: actually check if we got 512-byte blocks before proceeding Darrick J. Wong
2020-09-16 11:34   ` Zorro Lang
2020-09-16 21:07     ` Darrick J. Wong
2020-09-15  1:44 ` [PATCH 16/24] xfs/098: adapt to external log devices Darrick J. Wong
2020-09-16 11:36   ` Zorro Lang
2020-09-17  7:58   ` Christoph Hellwig
2020-09-15  1:44 ` [PATCH 17/24] xfs: refactor _xfs_check calls to the scratch device Darrick J. Wong
2020-09-16 11:39   ` Zorro Lang
2020-09-17  7:58   ` Christoph Hellwig
2020-09-17 16:03     ` Darrick J. Wong
2020-09-15  1:44 ` [PATCH 18/24] xfs/291: fix open-coded repair call to mdrestore'd fs image Darrick J. Wong
2020-09-16 11:41   ` Zorro Lang
2020-09-15  1:44 ` [PATCH 19/24] xfs/424: disable external devices Darrick J. Wong
2020-09-16 11:48   ` Zorro Lang
2020-09-17  7:59   ` Christoph Hellwig
2020-09-15  1:45 ` [PATCH 20/24] xfs/449: fix xfs info report output if realtime device specified Darrick J. Wong
2020-09-16 11:50   ` Zorro Lang
2020-09-17  7:59   ` Christoph Hellwig
2020-09-15  1:45 ` [PATCH 21/24] common/rc: teach _scratch_mkfs_sized to set a size on an xfs realtime volume Darrick J. Wong
2020-09-16 12:02   ` Zorro Lang
2020-09-17  8:00   ` Christoph Hellwig
2020-09-17 16:04     ` Darrick J. Wong
2020-09-18  2:08   ` [PATCH v2 " Darrick J. Wong
2020-09-15  1:45 ` [PATCH 22/24] xfs/141: run for longer with TIME_FACTOR Darrick J. Wong
2020-09-16 12:05   ` Zorro Lang
2020-09-17  8:01   ` Christoph Hellwig
2020-09-15  1:45 ` [PATCH 23/24] generic/204: sync before scrub hits EIO Darrick J. Wong
2020-09-16 12:09   ` Zorro Lang
2020-09-17  8:01   ` Christoph Hellwig
2020-09-15  1:45 ` [PATCH 24/24] check: try reloading modules Darrick J. Wong
2020-09-15  8:42   ` Amir Goldstein
2020-09-18  2:10 ` [PATCH 26/24] common: drop HOSTOS Darrick J. Wong
2020-09-18  2:11 ` Darrick J. Wong [this message]
2020-09-19  5:13   ` [PATCH 27/24] common/rc: fix indentation in _scratch_mkfs_sized Christoph Hellwig
     [not found] ` <20200918020936.GJ7954@magnolia>
2020-09-19  5:13   ` [PATCH 25/24] common: kill _supported_os Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200918021109.GL7954@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=hch@infradead.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).