Skip to contentSkip to conversation

common: use mke2fs -F instead of piping in yes

PATCH New Theodore Ts'o 1 participant 1 message Dec 12, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common: use mke2fs -F instead of piping in yes

It's possible based on a race conditions (and possibly the version of coreutils which supplies /usr/bin/yes) that commands of the form:

yes | $MKFS_PROG ...

will end up causing the following failure:

shared/298 16s ... [23:49:03] [23:49:19] - output mismatch (see /results/results-4k/shared/298.out.bad)
--- tests/shared/298.out 2014-10-31 10:13:04.000000000 -0400
+++ /results/results-4k/shared/298.out.bad 2014-11-29 23:49:19.118138099 -0500
@@ -1,4 +1,6 @@
QA output created by 298
+yes: standard output: Broken pipe
+yes: write error
Generating garbage on loop...done.
Running fstrim...done.
Detecting interesting holes in image...done.
...
(Run 'diff -u tests/shared/298.out /results/results-4k/shared/298.out.bad' to see the entire diff)

Using mke2fs's -F option instad of "yes | $MKFS_PROG" fixes this issue.

---
 common/rc | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
common/rc +12 -1
index 692d45c..ec4440b 100644
@@ -517,6 +517,9 @@ _test_mkfs()
     btrfs)
         $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $TEST_DEV > /dev/null
 	;;
+    ext2|ext3|ext4)
+	$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* $TEST_DEV
+	;;
     *)
 	yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* $TEST_DEV
 	;;
@@ -535,6 +538,11 @@ _mkfs_dev()
     btrfs)
         $MKFS_BTRFS_PROG $MKFS_OPTIONS $* 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
 	;;
+    ext2|ext3|ext4)
+	$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* \
+		2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
+	;;
+
     *)
 	yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* \
 		2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
@@ -581,6 +589,9 @@ _scratch_mkfs()
     btrfs)
         $MKFS_BTRFS_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
 	;;
+    ext2|ext3)
+	$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* $SCRATCH_DEV
+	;;
     ext4)
 	_scratch_mkfs_ext4 $*
 	;;
@@ -657,7 +668,7 @@ _scratch_mkfs_sized()
 	fi
 	;;
     ext2|ext3|ext4|ext4dev)
-	yes | ${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
+	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
 	;;
     udf)
 	$MKFS_UDF_PROG $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV $blocks
Signature · 1 line
2.1.0