Skip to contentSkip to conversation

ext4: use mkfs.ext4 -F instead of piping in yes

PATCH In review Theodore Ts'o 4 participants 18 messages Sep 7, 2014 – Sep 27, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: use mkfs.ext4 -F instead of piping in yes

Using "yes | mkfs.ext4 ..." results in the error message results in the test failing, at least for some versions of e2fsprogs:

+yes: standard output: Broken pipe
+yes: write error

It better to use the -F option, which will eliminate the questions.

Cc Xiaoguang Wang <[email protected]>
Cc Eryu Guan <[email protected]>
---
 tests/ext4/003 | 2 +-
 tests/ext4/306 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/ext4/003 +1 -1
index 572e685..a2e9d75 100755
@@ -43,7 +43,7 @@ _require_ext4_bigalloc
 
 rm -f $seqres.full
 
-yes | mkfs.ext4 -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
+mkfs.ext4 -F -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
 	>> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
tests/ext4/306 +1 -1
index fd50b0e..fd5c3a2 100755
@@ -48,7 +48,7 @@ _require_scratch
 rm -f $seqres.full
 
 # Make a small ext4 fs with extents disabled & mount it
-yes | mkfs.ext4 -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
+mkfs.ext4 -F -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
 # Create a small non-extent-based file
Signature · 1 line
2.1.0
#1 lore raw
Quoted 7 lines · Theodore Ts'o

Using "yes | mkfs.ext4 ..." results in the error message results in the test failing, at least for some versions of e2fsprogs:

+yes: standard output: Broken pipe
+yes: write error

It better to use the -F option, which will eliminate the questions.

Looks good, but maybe we should have a $MKFS_EXT4_PROG variable similar to $MKFS_XFS_PROG so that we can set this in one place?

#2 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 7 lines · Theodore Ts'o

Using "yes | mkfs.ext4 ..." results in the error message results in the test failing, at least for some versions of e2fsprogs:

+yes: standard output: Broken pipe
+yes: write error

It better to use the -F option, which will eliminate the questions.

Looks good, but maybe we should have a $MKFS_EXT4_PROG variable similar to $MKFS_XFS_PROG so that we can set this in one place?

Agreed, I'll send a separate patch to fix that. One amusing thing:

% git grep mkfs.ext4
common/rc:_scratch_mkfs_ext4()
common/rc: _scratch_mkfs_ext4 $*
common/rc:# this test requires the bigalloc feature to be available in mkfs.ext4

common/rc:      _scratch_mkfs_ext4 -O bigalloc >/dev/null 2>&1 \
common/rc:         || _notrun "mkfs.ext4 doesn't have bigalloc feature"
common/rc:      _scratch_mkfs_ext4 -O bigalloc >/dev/null 2>&1

tests/btrfs/012:MKFS_EXT4_PROG="set_prog_path mkfs.ext4" tests/btrfs/012:_require_command $MKFS_EXT4_PROG mkfs.ext4 tests/ext4/003:mkfs.ext4 -F -O bigalloc -C 65536 -g 256 $SCRATCH_DEV 512m \
tests/ext4/306:mkfs.ext4 -F -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1

(note the btrfs test is the one place using and defining MKFS_EXT4_PROG :-)

- Ted

#3 lore raw

PATCH 1/2 ext4: define MKFS_EXT4_PROG and use it instead of "mkfs.ext4" / "mkfs -t ext4"

---
 common/config   | 1 +
 common/rc       | 7 +++++--
 tests/btrfs/012 | 1 -
 tests/ext4/003  | 2 +-
 tests/ext4/306  | 2 +-
 5 files changed, 8 insertions(+), 5 deletions(-)
common/config +1 -0
index 10cc6fe..f038813 100644
@@ -209,6 +209,7 @@ case "$HOSTOS" in
         ;;
     Linux)
         export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
+        export MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
         export MKFS_UDF_PROG="`set_prog_path mkudffs`"
         export MKFS_BTRFS_PROG="`set_btrfs_mkfs_prog_path_with_opts`"
         export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
common/rc +5 -2
index 16da898..285bd7c 100644
@@ -105,6 +105,9 @@ case "$FSTYP" in
     btrfs)
 	 [ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
 	 ;;
+    ext4)
+	 [ "$MKFS_EXT4_PROG" = "" ] && _fatal "mkfs.ext4 not found"
+	 ;;
     nfs)
 	 ;;
 esac
@@ -451,7 +454,7 @@ _scratch_mkfs_ext4()
 
 	local tmp_dir=/tmp/
 
-	/sbin/mkfs -t ext4 -- -F $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
+	$MKFS_EXT4_PROG -F $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
 			2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
 	local mkfs_status=$?
 
@@ -466,7 +469,7 @@ _scratch_mkfs_ext4()
 		) >> $seqres.full
 
 		# running mkfs again. overwrite previous mkfs output files
-		/sbin/mkfs -t ext4 -- -F $extra_mkfs_options $SCRATCH_DEV \
+		$MKFS_EXT4_PROG -F $extra_mkfs_options $SCRATCH_DEV \
 				2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
 		local mkfs_status=$?
 	fi
tests/btrfs/012 +0 -1
index f7e5da5..124c8ae 100755
@@ -55,7 +55,6 @@ _supported_os Linux
 _require_scratch
 
 BTRFS_CONVERT_PROG="`set_prog_path btrfs-convert`"
-MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
 E2FSCK_PROG="`set_prog_path e2fsck`"
 
 _require_command $BTRFS_CONVERT_PROG btrfs-convert
tests/ext4/003 +1 -1
index a2e9d75..53875a9 100755
@@ -43,7 +43,7 @@ _require_ext4_bigalloc
 
 rm -f $seqres.full
 
-mkfs.ext4 -F -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
+$MKFS_EXT4_PROG -F -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
 	>> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
tests/ext4/306 +1 -1
index fd5c3a2..edc0204 100755
@@ -48,7 +48,7 @@ _require_scratch
 rm -f $seqres.full
 
 # Make a small ext4 fs with extents disabled & mount it
-mkfs.ext4 -F -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
+$MKFS_EXT4_PROG -F -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
 # Create a small non-extent-based file
Signature · 1 line
2.1.0
#4 lore raw

PATCH 2/2 ext4: speed up _require_ext4_bigalloc and _require_ext4_mkfs_bigalloc

We don't need to make a full-sized file system in order to test whether "mkfs.ext4 -O bigalloc" works.

---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/rc +2 -2
index 285bd7c..56e1847 100644
@@ -1189,7 +1189,7 @@ _require_xfs_crc()
 #
 _require_ext4_mkfs_bigalloc()
 {
-	_scratch_mkfs_ext4 -O bigalloc >/dev/null 2>&1 \
+	$MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 200k >/dev/null 2>&1 \
 	   || _notrun "mkfs.ext4 doesn't have bigalloc feature"
 }
 
@@ -1197,7 +1197,7 @@ _require_ext4_mkfs_bigalloc()
 #
 _require_ext4_bigalloc()
 {
-	_scratch_mkfs_ext4 -O bigalloc >/dev/null 2>&1
+	$MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 200k >/dev/null 2>&1
 	_scratch_mount >/dev/null 2>&1 \
 	   || _notrun "Ext4 kernel doesn't support bigalloc feature"
 	umount $SCRATCH_MNT
Signature · 1 line
2.1.0
#5 lore raw

Re: [PATCH 2/2] ext4: speed up _require_ext4_bigalloc and _require_ext4_mkfs_bigalloc

Quoted 2 lines · Theodore Ts'o

We don't need to make a full-sized file system in order to test whether "mkfs.ext4 -O bigalloc" works.

Why wouldn't you just use the "-n" option? If bigalloc is not supported, that should still fail, right?

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#6 lore raw

Re: [PATCH 2/2] ext4: speed up _require_ext4_bigalloc and _require_ext4_mkfs_bigalloc

Quoted 6 lines · Dave Chinner
Quoted 2 lines · Theodore Ts'o

We don't need to make a full-sized file system in order to test whether "mkfs.ext4 -O bigalloc" works.

Why wouldn't you just use the "-n" option? If bigalloc is not supported, that should still fail, right?

Good point. We still need to make the file system for _require_ext4_bigalloc, but there's no need to create one for _require_ext4_mkfs_bigalloc.

- Ted

#7 lore raw

PATCH 1/1 ext4: speed up _require_ext4_bigalloc and _require_ext4_mkfs_bigalloc

We don't need to make a full-sized file system in order to test whether "mkfs.ext4 -O bigalloc" works.

---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/rc +2 -2
index 285bd7c..0baac86 100644
@@ -1189,7 +1189,7 @@ _require_xfs_crc()
 #
 _require_ext4_mkfs_bigalloc()
 {
-	_scratch_mkfs_ext4 -O bigalloc >/dev/null 2>&1 \
+	$MKFS_EXT4_PROG -F -O bigalloc -n $SCRATCH_DEV 200k >/dev/null 2>&1 \
 	   || _notrun "mkfs.ext4 doesn't have bigalloc feature"
 }
 
@@ -1197,7 +1197,7 @@ _require_ext4_mkfs_bigalloc()
 #
 _require_ext4_bigalloc()
 {
-	_scratch_mkfs_ext4 -O bigalloc >/dev/null 2>&1
+	$MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 200k >/dev/null 2>&1
 	_scratch_mount >/dev/null 2>&1 \
 	   || _notrun "Ext4 kernel doesn't support bigalloc feature"
 	umount $SCRATCH_MNT
Signature · 1 line
2.1.0
#8 lore raw

Re: [PATCH -v2] ext4: speed up _require_ext4_bigalloc and _require_ext4_mkfs_bigalloc

Quoted 4 lines · Theodore Ts'o

We don't need to make a full-sized file system in order to test whether "mkfs.ext4 -O bigalloc" works.

Got it - thanks for the quick turnaround.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#9 lore raw

Re: [PATCH -v2] ext4: speed up _require_ext4_bigalloc and _require_ext4_mkfs_bigalloc

Quoted 7 lines · Dave Chinner
Quoted 4 lines · Theodore Ts'o

We don't need to make a full-sized file system in order to test whether "mkfs.ext4 -O bigalloc" works.

Got it - thanks for the quick turnaround.

You're not going to apply this one until I send out the rebased version of the 1/2 version of this patch series, right? Because this one depends on MKFS_EXT4_PROG...

- Ted

#10 lore raw

Re: [PATCH -v2] ext4: speed up _require_ext4_bigalloc and _require_ext4_mkfs_bigalloc

Quoted 5 lines · Theodore Ts'o
Quoted 4 lines · Dave Chinner
Quoted 3 lines · Theodore Ts'o

We don't need to make a full-sized file system in order to test whether "mkfs.ext4 -O bigalloc" works.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Got it - thanks for the quick turnaround.

You're not going to apply this one until I send out the rebased version of the 1/2 version of this patch series, right? Because this one depends on MKFS_EXT4_PROG...

No, I haven't applied it, just put it at the end of the patch queue so I don't forget it...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#11 lore raw

Re: [PATCH 1/2] ext4: define MKFS_EXT4_PROG and use it instead of "mkfs.ext4" / "mkfs -t ext4"

In reply to Theodore Ts'o
Quoted 8 lines · Theodore Ts'o
---
 common/config   | 1 +
 common/rc       | 7 +++++--
 tests/btrfs/012 | 1 -
 tests/ext4/003  | 2 +-
 tests/ext4/306  | 2 +-
 5 files changed, 8 insertions(+), 5 deletions(-)

This throws lots of rejects with all the other patches I've already queued up. Can you rebase it and resend it when I push out my current tree in the morning, Ted?

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#12 lore raw

Re: [PATCH 1/2] ext4: define MKFS_EXT4_PROG and use it instead of "mkfs.ext4" / "mkfs -t ext4"

Quoted 10 lines · Dave Chinner
Quoted 8 lines · Theodore Ts'o
---
 common/config   | 1 +
 common/rc       | 7 +++++--
 tests/btrfs/012 | 1 -
 tests/ext4/003  | 2 +-
 tests/ext4/306  | 2 +-
 5 files changed, 8 insertions(+), 5 deletions(-)
Quoted 3 lines

This throws lots of rejects with all the other patches I've already queued up. Can you rebase it and resend it when I push out my current tree in the morning, Ted?

Hi Ted,

Can you send an update for this patch if you still need it?

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#13 lore raw

Re: [PATCH 1/2] ext4: define MKFS_EXT4_PROG and use it instead of "mkfs.ext4" / "mkfs -t ext4"

Quoted 2 lines · Dave Chinner

Can you send an update for this patch if you still need it?

Thanks for pinging me; I've been so busy these past few weeks I forgot to check to see if the fstests repo had been updated. I see you did so quite a while ago, my bad.

- Ted

#14 lore raw

PATCH 1/3 ext4: define MKFS_EXT4_PROG and use it instead of "mkfs.ext4" / "mkfs -t ext4"

---
 common/config   | 1 +
 common/rc       | 7 +++++--
 tests/btrfs/012 | 1 -
 tests/ext4/003  | 2 +-
 tests/ext4/306  | 2 +-
 5 files changed, 8 insertions(+), 5 deletions(-)
common/config +1 -0
index fc21b37..d68d4d0 100644
@@ -210,6 +210,7 @@ case "$HOSTOS" in
         ;;
     Linux)
         export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
+        export MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
         export MKFS_UDF_PROG="`set_prog_path mkudffs`"
         export MKFS_BTRFS_PROG="`set_btrfs_mkfs_prog_path_with_opts`"
         export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
common/rc +5 -2
index b8f711a..35d7d5d 100644
@@ -105,6 +105,9 @@ case "$FSTYP" in
     btrfs)
 	 [ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
 	 ;;
+    ext4)
+	 [ "$MKFS_EXT4_PROG" = "" ] && _fatal "mkfs.ext4 not found"
+	 ;;
     nfs)
 	 ;;
     cifs)
@@ -459,7 +462,7 @@ _scratch_mkfs_ext4()
 
 	local tmp_dir=/tmp/
 
-	/sbin/mkfs -t ext4 -- -F $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
+	$MKFS_EXT4_PROG -F $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
 			2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
 	local mkfs_status=$?
 
@@ -474,7 +477,7 @@ _scratch_mkfs_ext4()
 		) >> $seqres.full
 
 		# running mkfs again. overwrite previous mkfs output files
-		/sbin/mkfs -t ext4 -- -F $extra_mkfs_options $SCRATCH_DEV \
+		$MKFS_EXT4_PROG -F $extra_mkfs_options $SCRATCH_DEV \
 				2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
 		local mkfs_status=$?
 	fi
tests/btrfs/012 +0 -1
index f7e5da5..124c8ae 100755
@@ -55,7 +55,6 @@ _supported_os Linux
 _require_scratch
 
 BTRFS_CONVERT_PROG="`set_prog_path btrfs-convert`"
-MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
 E2FSCK_PROG="`set_prog_path e2fsck`"
 
 _require_command $BTRFS_CONVERT_PROG btrfs-convert
tests/ext4/003 +1 -1
index 572e685..fde0e9c 100755
@@ -43,7 +43,7 @@ _require_ext4_bigalloc
 
 rm -f $seqres.full
 
-yes | mkfs.ext4 -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
+yes | $MKFS_EXT4_PROG -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
 	>> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
tests/ext4/306 +1 -1
index fd50b0e..caffe0e 100755
@@ -48,7 +48,7 @@ _require_scratch
 rm -f $seqres.full
 
 # Make a small ext4 fs with extents disabled & mount it
-yes | mkfs.ext4 -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
+yes | $MKFS_EXT4_PROG -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
 # Create a small non-extent-based file
Signature · 1 line
2.1.0
#15 lore raw

PATCH 2/3 ext4: use mkfs.ext4 -F instead of piping in yes

Using "yes | mkfs.ext4 ..." results in the error message results in the test failing, at least for some versions of e2fsprogs:

+yes: standard output: Broken pipe
+yes: write error

It better to use the -F option, which will eliminate the questions.

---
 tests/ext4/003 | 2 +-
 tests/ext4/306 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/ext4/003 +1 -1
index fde0e9c..53875a9 100755
@@ -43,7 +43,7 @@ _require_ext4_bigalloc
 
 rm -f $seqres.full
 
-yes | $MKFS_EXT4_PROG -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
+$MKFS_EXT4_PROG -F -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
 	>> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
tests/ext4/306 +1 -1
index caffe0e..edc0204 100755
@@ -48,7 +48,7 @@ _require_scratch
 rm -f $seqres.full
 
 # Make a small ext4 fs with extents disabled & mount it
-yes | $MKFS_EXT4_PROG -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
+$MKFS_EXT4_PROG -F -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
 # Create a small non-extent-based file
Signature · 1 line
2.1.0
#16 lore raw

PATCH 3/3 ext4: speed up _require_ext4_bigalloc and _require_ext4_mkfs_bigalloc

In reply to Theodore Ts'o

We don't need to make a full-sized file system in order to test whether "mkfs.ext4 -O bigalloc" works.

---
 common/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/rc +2 -2
index 35d7d5d..d49137c 100644
@@ -1267,7 +1267,7 @@ _require_xfs_crc()
 #
 _require_ext4_mkfs_bigalloc()
 {
-	_scratch_mkfs_ext4 -O bigalloc >/dev/null 2>&1 \
+	$MKFS_EXT4_PROG -F -O bigalloc -n $SCRATCH_DEV 200k >/dev/null 2>&1 \
 	   || _notrun "mkfs.ext4 doesn't have bigalloc feature"
 }
 
@@ -1275,7 +1275,7 @@ _require_ext4_mkfs_bigalloc()
 #
 _require_ext4_bigalloc()
 {
-	_scratch_mkfs_ext4 -O bigalloc >/dev/null 2>&1
+	$MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 200k >/dev/null 2>&1
 	_scratch_mount >/dev/null 2>&1 \
 	   || _notrun "Ext4 kernel doesn't support bigalloc feature"
 	umount $SCRATCH_MNT
Signature · 1 line
2.1.0
Reviewed-by on v1 1/1
#17 lore raw
In reply to Theodore Ts'o
Quoted 11 lines · Theodore Ts'o

Using "yes | mkfs.ext4 ..." results in the error message results in the test failing, at least for some versions of e2fsprogs:

+yes: standard output: Broken pipe
+yes: write error

It better to use the -F option, which will eliminate the questions.

Cc Xiaoguang Wang <[email protected]>
Cc Eryu Guan <[email protected]>

Looks good to me.

Thanks,
Eryu

Quoted 38 lines
---
 tests/ext4/003 | 2 +-
 tests/ext4/306 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/ext4/003 +1 -1
index 572e685..a2e9d75 100755
@@ -43,7 +43,7 @@ _require_ext4_bigalloc
 
 rm -f $seqres.full
 
-yes | mkfs.ext4 -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
+mkfs.ext4 -F -O bigalloc -C 65536  -g 256 $SCRATCH_DEV 512m \
 	>> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
tests/ext4/306 +1 -1
index fd50b0e..fd5c3a2 100755
@@ -48,7 +48,7 @@ _require_scratch
 rm -f $seqres.full
 
 # Make a small ext4 fs with extents disabled & mount it
-yes | mkfs.ext4 -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
+mkfs.ext4 -F -O ^extents,^64bit $SCRATCH_DEV 512m >> $seqres.full 2>&1
 _scratch_mount || _fail "couldn't mount fs"
 
 # Create a small non-extent-based file
Signature · 6 lines
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html