]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
ext4: create file systems with the encrypt feature as necessary
authorTheodore Ts'o <tytso@mit.edu>
Thu, 30 Jun 2022 14:46:37 +0000 (10:46 -0400)
committerZorro Lang <zlang@kernel.org>
Sat, 2 Jul 2022 13:31:10 +0000 (21:31 +0800)
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>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/ext4/003
tests/ext4/035
tests/ext4/306
tests/generic/260

index 773bcb03edd9af7a4b75e3f0c0bf0d911e4c8e40..8ac467b89b9eac728c28211fed4614bc627582b3 100755 (executable)
@@ -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+=",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
 
index 1f26e766625fe9224fcf5bc4a3f3b7b31de903c1..a8278b0ee500f5915421100fbd1f670ebb4a9151 100755 (executable)
@@ -25,7 +25,11 @@ _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
+encrypt=
+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
index 2ff88537e70c555e6d6bab02dd98ebe930de868a..db2562848e2d371a17a87c9165089713aebdbf6c 100755 (executable)
@@ -31,7 +31,10 @@ _require_command "$RESIZE2FS_PROG" resize2fs
 # Make a small ext4 fs with extents disabled & mount it
 features="^extents"
 if grep -q 64bit /etc/mke2fs.conf ; then
-    features="^extents,^64bit"
+    features+=",^64bit"
+fi
+if echo "${MOUNT_OPTIONS}" | grep -q 'test_dummy_encryption' ; then
+    features+=",encrypt"
 fi
 
 blksz=$(get_page_size)
index b4d72e0fff67ccc415a2758324a16e751e46ba06..2f653b4af22df01ba2e31a2893a6ed36fc134cf7 100755 (executable)
@@ -121,6 +121,9 @@ case $FSTYP in
                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
+                   MKFS_OPTIONS+=" -O encrypt"
+               fi
                ;;
        xfs)
                agsize=65538