[PATCH V2] xfstests: routine to create scratch of certain size

Eric Sandeen sandeen at sandeen.net
Tue Feb 2 19:54:34 CST 2010


This is needed for later enospc tests to be generic

Signed-off-by: Eric Sandeen <sandeen at sandeen.net>
---

V2: Address Christoph's comment about use of MKFS_OPTIONS;
just do it like the other geom helper and explicitly -set-
MKFS_OPTIONS for scratch, to set the size, then just call
_scratch_mkfs

(this would override any global MKFS_OPTIONS setting, but
I think that's ok for now, and not sure how these options might
interact w/ previously set MKFS_OPTIONS anyway)

diff --git a/common.rc b/common.rc
index 9c375dc..a6526a3 100644
--- a/common.rc
+++ b/common.rc
@@ -297,6 +297,29 @@ _scratch_mkfs()
     esac
 }
 
+# Create fs of certain size on scratch device
+# _scratch_mkfs_sized <size in bytes> [optional blocksize]
+_scratch_mkfs_sized()
+{
+    fssize=$1
+    blocksize=$2
+    [ -z "$blocksize" ] && blocksize=4096
+    let blocks=$fssize/$blocksize
+
+    case $FSTYP in
+    xfs)
+	MKFS_OPTIONS="-d size=$fssize -b size=$blocksize"
+	;;
+    ext2|ext3|ext4)
+	MKFS_OPTIONS="-b $blocksize $SCRATCH_DEV $blocks"
+	;;
+    *)
+	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
+	;;
+    esac
+    _scratch_mkfs
+}
+
 # Emulate an N-data-disk stripe w/ various stripe units
 # _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
 _scratch_mkfs_geom()





More information about the xfs mailing list