diff mbox series

[-v3,7/7] ext4: create file systems with the encrypt feature as necessary

Message ID 20220629124540.175775-8-tytso@mit.edu (mailing list archive)
State New, archived
Headers show
Series Miscellaneous ext4 test fix ups | expand

Commit Message

Theodore Ts'o June 29, 2022, 12:45 p.m. UTC
The linux kernel commit 5f41fdaea63d ("ext4: only allow
test_dummy_encryption when supported") the kernel will reject mounts
with the test_dummy_encryption option if the ext4 file system does not
have the encrypt feature enabled.

There are a handful of tests (ext4/003, ext4/035, ext4/306, and
generic/260) which will format the scratch file system using a
hard-coded set of mkfs.ext4 parameters ignoring the MKFS_OPTION that
is set by the file system test config.

For file system configs which includes test_dummy_encryption in
MOUNT_OPTIONS and "-O encrypt" in MKFS_OPTIONS, we need to test for
test_dummy_encryption and force the hard-coded mkfs options to enable
the encrypt feature.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 tests/ext4/003    | 6 +++++-
 tests/ext4/035    | 5 ++++-
 tests/ext4/306    | 3 +++
 tests/generic/260 | 5 ++++-
 4 files changed, 16 insertions(+), 3 deletions(-)

Comments

Zorro Lang June 29, 2022, 1:30 p.m. UTC | #1
On Wed, Jun 29, 2022 at 08:45:40AM -0400, Theodore Ts'o wrote:
> The linux kernel commit 5f41fdaea63d ("ext4: only allow
> test_dummy_encryption when supported") the kernel will reject mounts
> with the test_dummy_encryption option if the ext4 file system does not
> have the encrypt feature enabled.
> 
> There are a handful of tests (ext4/003, ext4/035, ext4/306, and
> generic/260) which will format the scratch file system using a
> hard-coded set of mkfs.ext4 parameters ignoring the MKFS_OPTION that
> is set by the file system test config.
> 
> For file system configs which includes test_dummy_encryption in
> MOUNT_OPTIONS and "-O encrypt" in MKFS_OPTIONS, we need to test for
> test_dummy_encryption and force the hard-coded mkfs options to enable
> the encrypt feature.
> 
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> ---

This patch makes sense to me. 

Reviewed-by: Zorro Lang <zlang@redhat.com>

As Eric gave some review points to V2, so double check with Eric, if it's good
to him?

>  tests/ext4/003    | 6 +++++-
>  tests/ext4/035    | 5 ++++-
>  tests/ext4/306    | 3 +++
>  tests/generic/260 | 5 ++++-
>  4 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/ext4/003 b/tests/ext4/003
> index 773bcb03..6a4518e3 100755
> --- a/tests/ext4/003
> +++ b/tests/ext4/003
> @@ -27,7 +27,11 @@ _require_scratch
>  _require_scratch_ext4_feature "bigalloc"
>  
>  BLOCK_SIZE=$(get_page_size)
> -$MKFS_EXT4_PROG -F -b $BLOCK_SIZE -O bigalloc -C $(($BLOCK_SIZE * 16)) -g 256 $SCRATCH_DEV 512m \
> +FEATURES=bigalloc
> +if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
> +    FEATURES=${FEATURES},encrypt
> +fi
> +$MKFS_EXT4_PROG -F -b $BLOCK_SIZE -O ${FEATURES} -C $(($BLOCK_SIZE * 16)) -g 256 $SCRATCH_DEV 512m \
>  	>> $seqres.full 2>&1
>  _scratch_mount
>  
> diff --git a/tests/ext4/035 b/tests/ext4/035
> index 1f26e766..a1ccce45 100755
> --- a/tests/ext4/035
> +++ b/tests/ext4/035
> @@ -25,7 +25,10 @@ _require_scratch
>  _exclude_scratch_mount_option dax
>  _require_command "$RESIZE2FS_PROG" resize2fs
>  
> -$MKFS_EXT4_PROG -F -b 1024 -E "resize=262144" $SCRATCH_DEV 32768 >> $seqres.full 2>&1
> +if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
> +    ENCRYPT="-O encrypt"
> +fi
> +$MKFS_EXT4_PROG -F -b 1024 -E "resize=262144" $ENCRYPT $SCRATCH_DEV 32768 >> $seqres.full 2>&1
>  if [ $? -ne 0 ]; then
>      _notrun "Can't make file system with a block size of 1024"
>  fi
> diff --git a/tests/ext4/306 b/tests/ext4/306
> index 2ff88537..a6b7eab5 100755
> --- a/tests/ext4/306
> +++ b/tests/ext4/306
> @@ -33,6 +33,9 @@ features="^extents"
>  if grep -q 64bit /etc/mke2fs.conf ; then
>      features="^extents,^64bit"
>  fi
> +if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
> +    features=${features},encrypt
> +fi
>  
>  blksz=$(get_page_size)
>  
> diff --git a/tests/generic/260 b/tests/generic/260
> index b4d72e0f..e86afe9c 100755
> --- a/tests/generic/260
> +++ b/tests/generic/260
> @@ -120,7 +120,10 @@ case $FSTYP in
>  		bsize=4096
>  		start=$(_math "$base*$agsize*$bsize")
>  		len=$start
> -		export MKFS_OPTIONS="-F -b $bsize -g $agsize"
> +		if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
> +		    ENCRYPT="-O encrypt"
> +		fi
> +		export MKFS_OPTIONS="-F -b $bsize -g $agsize $ENCRYPT"
>  		;;
>  	xfs)
>  		agsize=65538
> -- 
> 2.31.0
>
Theodore Ts'o June 29, 2022, 7:30 p.m. UTC | #2
On Wed, Jun 29, 2022 at 09:30:52PM +0800, Zorro Lang wrote:
> 
> As Eric gave some review points to V2, so double check with Eric, if it's good
> to him?

Eric, any other issues than the ones which you had mentioned (and
which I have addressed)?

Zorro, I have the patches based against for-next, and with your
reviewed-by tags appended, and tagged with a signed tag on the
for-upstream branch up on github.  Or if you like I can resend patch
series via e-mail.

      	    	       	   	- Ted

The following changes since commit 34c1208f601b5f22c62d0f3ed6f6c55c88aa4eff:

  xfs/{422,517}: kill background jobs on test termination (2022-06-25 00:27:11 +0800)

are available in the Git repository at:

  https://github.com/tytso/xfstests tags/for-zorro

for you to fetch changes up to 43dec26fe614b1d8ad8f4c67aaf6f88413b7f2f8:

  ext4: create file systems with the encrypt feature as necessary (2022-06-29 15:11:41 -0400)

----------------------------------------------------------------
Miscellaneous ext4 test fix ups

Previous versions of this patch series can be found at:

 - v1: https://lore.kernel.org/r/20220625030718.1215980-1-tytso@mit.edu
 - v2: https://lore.kernel.org/r/20220628182545.1834145-1-tytso@mit.edu
 - v3: https://lore.kernel.org/r/20220629124540.175775-1-tytso@mit.edu

----------------------------------------------------------------
Theodore Ts'o (7):
      ext4/050: support indirect as well as extent mapped journals
      ext4/044: skip test if the file system does not have a journal
      ext4/045: _require_dumpe2fs doesn't take any arguments so remove them
      ext4/054: skip test if the dax mount option is enabled
      ext4/055: skip test if dax mount option is used
      ext4/035: skip this test if the scratch device does not support 1k block sizes
      ext4: create file systems with the encrypt feature as necessary

 common/rc         |  3 +++
 tests/ext4/003    |  6 +++++-
 tests/ext4/035    |  8 +++++++-
 tests/ext4/044    |  1 +
 tests/ext4/045    |  2 +-
 tests/ext4/050    | 58 +++++-----------------------------------------------------
 tests/ext4/054    |  5 ++---
 tests/ext4/055    |  1 +
 tests/ext4/306    |  3 +++
 tests/generic/260 |  5 ++++-
 10 files changed, 32 insertions(+), 60 deletions(-)
Eric Biggers June 29, 2022, 9:20 p.m. UTC | #3
On Wed, Jun 29, 2022 at 03:30:04PM -0400, Theodore Ts'o wrote:
> On Wed, Jun 29, 2022 at 09:30:52PM +0800, Zorro Lang wrote:
> > 
> > As Eric gave some review points to V2, so double check with Eric, if it's good
> > to him?
> 
> Eric, any other issues than the ones which you had mentioned (and
> which I have addressed)?

Well, not all the comments I made on v2 were addressed; see
https://lore.kernel.org/fstests/YrvgMkrXh8iUItVv@sol.localdomain.
As I said, the overall approach is fine though.

- Eric
Zorro Lang June 30, 2022, 1:39 a.m. UTC | #4
On Wed, Jun 29, 2022 at 03:30:04PM -0400, Theodore Ts'o wrote:
> On Wed, Jun 29, 2022 at 09:30:52PM +0800, Zorro Lang wrote:
> > 
> > As Eric gave some review points to V2, so double check with Eric, if it's good
> > to him?
> 
> Eric, any other issues than the ones which you had mentioned (and
> which I have addressed)?
> 
> Zorro, I have the patches based against for-next, and with your
> reviewed-by tags appended, and tagged with a signed tag on the
> for-upstream branch up on github.  Or if you like I can resend patch
> series via e-mail.
> 
>       	    	       	   	- Ted
> 
> The following changes since commit 34c1208f601b5f22c62d0f3ed6f6c55c88aa4eff:
> 
>   xfs/{422,517}: kill background jobs on test termination (2022-06-25 00:27:11 +0800)
> 
> are available in the Git repository at:
> 
>   https://github.com/tytso/xfstests tags/for-zorro
> 
> for you to fetch changes up to 43dec26fe614b1d8ad8f4c67aaf6f88413b7f2f8:
> 
>   ext4: create file systems with the encrypt feature as necessary (2022-06-29 15:11:41 -0400)

Hi Ted,

Sure, if you won't change anymore, I'll get this patchset by:
  $ b4 am $message_id_of_this_email

If you still need to do more change, I can fetch the final version from above
git repo you metioned. Feel free to tell me, if it's ready to be merged :)

Thanks,
Zorro


> 
> ----------------------------------------------------------------
> Miscellaneous ext4 test fix ups
> 
> Previous versions of this patch series can be found at:
> 
>  - v1: https://lore.kernel.org/r/20220625030718.1215980-1-tytso@mit.edu
>  - v2: https://lore.kernel.org/r/20220628182545.1834145-1-tytso@mit.edu
>  - v3: https://lore.kernel.org/r/20220629124540.175775-1-tytso@mit.edu
> 
> ----------------------------------------------------------------
> Theodore Ts'o (7):
>       ext4/050: support indirect as well as extent mapped journals
>       ext4/044: skip test if the file system does not have a journal
>       ext4/045: _require_dumpe2fs doesn't take any arguments so remove them
>       ext4/054: skip test if the dax mount option is enabled
>       ext4/055: skip test if dax mount option is used
>       ext4/035: skip this test if the scratch device does not support 1k block sizes
>       ext4: create file systems with the encrypt feature as necessary
> 
>  common/rc         |  3 +++
>  tests/ext4/003    |  6 +++++-
>  tests/ext4/035    |  8 +++++++-
>  tests/ext4/044    |  1 +
>  tests/ext4/045    |  2 +-
>  tests/ext4/050    | 58 +++++-----------------------------------------------------
>  tests/ext4/054    |  5 ++---
>  tests/ext4/055    |  1 +
>  tests/ext4/306    |  3 +++
>  tests/generic/260 |  5 ++++-
>  10 files changed, 32 insertions(+), 60 deletions(-)
>
Theodore Ts'o June 30, 2022, 2:45 p.m. UTC | #5
On Thu, Jun 30, 2022 at 09:39:45AM +0800, Zorro Lang wrote:
> On Wed, Jun 29, 2022 at 03:30:04PM -0400, Theodore Ts'o wrote:
> > On Wed, Jun 29, 2022 at 09:30:52PM +0800, Zorro Lang wrote:
> > > 
> > > As Eric gave some review points to V2, so double check with Eric, if it's good
> > > to him?
> > 
> > Eric, any other issues than the ones which you had mentioned (and
> > which I have addressed)?
> > 
> > Zorro, I have the patches based against for-next, and with your
> > reviewed-by tags appended, and tagged with a signed tag on the
> > for-upstream branch up on github.  Or if you like I can resend patch
> > series via e-mail.
> > 
> >       	    	       	   	- Ted
> > 
> > The following changes since commit 34c1208f601b5f22c62d0f3ed6f6c55c88aa4eff:
> > 
> >   xfs/{422,517}: kill background jobs on test termination (2022-06-25 00:27:11 +0800)
> > 
> > are available in the Git repository at:
> > 
> >   https://github.com/tytso/xfstests tags/for-zorro
> > 
> > for you to fetch changes up to 43dec26fe614b1d8ad8f4c67aaf6f88413b7f2f8:
> > 
> >   ext4: create file systems with the encrypt feature as necessary (2022-06-29 15:11:41 -0400)
> 
> Hi Ted,
> 
> Sure, if you won't change anymore, I'll get this patchset by:
>   $ b4 am $message_id_of_this_email
> 
> If you still need to do more change, I can fetch the final version from above
> git repo you metioned. Feel free to tell me, if it's ready to be merged :)

I've made some changes that requested by Eric (sorry Eric, I showhow
missed your comments from the -v2 patch series) , and will be
reposting a V4 of this patch series.

						- Ted
diff mbox series

Patch

diff --git a/tests/ext4/003 b/tests/ext4/003
index 773bcb03..6a4518e3 100755
--- a/tests/ext4/003
+++ b/tests/ext4/003
@@ -27,7 +27,11 @@  _require_scratch
 _require_scratch_ext4_feature "bigalloc"
 
 BLOCK_SIZE=$(get_page_size)
-$MKFS_EXT4_PROG -F -b $BLOCK_SIZE -O bigalloc -C $(($BLOCK_SIZE * 16)) -g 256 $SCRATCH_DEV 512m \
+FEATURES=bigalloc
+if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
+    FEATURES=${FEATURES},encrypt
+fi
+$MKFS_EXT4_PROG -F -b $BLOCK_SIZE -O ${FEATURES} -C $(($BLOCK_SIZE * 16)) -g 256 $SCRATCH_DEV 512m \
 	>> $seqres.full 2>&1
 _scratch_mount
 
diff --git a/tests/ext4/035 b/tests/ext4/035
index 1f26e766..a1ccce45 100755
--- a/tests/ext4/035
+++ b/tests/ext4/035
@@ -25,7 +25,10 @@  _require_scratch
 _exclude_scratch_mount_option dax
 _require_command "$RESIZE2FS_PROG" resize2fs
 
-$MKFS_EXT4_PROG -F -b 1024 -E "resize=262144" $SCRATCH_DEV 32768 >> $seqres.full 2>&1
+if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
+    ENCRYPT="-O encrypt"
+fi
+$MKFS_EXT4_PROG -F -b 1024 -E "resize=262144" $ENCRYPT $SCRATCH_DEV 32768 >> $seqres.full 2>&1
 if [ $? -ne 0 ]; then
     _notrun "Can't make file system with a block size of 1024"
 fi
diff --git a/tests/ext4/306 b/tests/ext4/306
index 2ff88537..a6b7eab5 100755
--- a/tests/ext4/306
+++ b/tests/ext4/306
@@ -33,6 +33,9 @@  features="^extents"
 if grep -q 64bit /etc/mke2fs.conf ; then
     features="^extents,^64bit"
 fi
+if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
+    features=${features},encrypt
+fi
 
 blksz=$(get_page_size)
 
diff --git a/tests/generic/260 b/tests/generic/260
index b4d72e0f..e86afe9c 100755
--- a/tests/generic/260
+++ b/tests/generic/260
@@ -120,7 +120,10 @@  case $FSTYP in
 		bsize=4096
 		start=$(_math "$base*$agsize*$bsize")
 		len=$start
-		export MKFS_OPTIONS="-F -b $bsize -g $agsize"
+		if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
+		    ENCRYPT="-O encrypt"
+		fi
+		export MKFS_OPTIONS="-F -b $bsize -g $agsize $ENCRYPT"
 		;;
 	xfs)
 		agsize=65538