ext4: add test for all ext4/ext3/ext2 mount options
PATCH 1/1 ext4: add test for all ext4/ext3/ext2 mount options
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
--- tests/ext4/053 | 598 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 600 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.out
tests/ext4/053 new file +598 -0
@@ -0,0 +1,598 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +kernel_gte() { + gte=`echo "$KERNEL_VERSION >= $1" | $BC_PROG` + [ $gte -eq 1 ] && return 0 + return 1 +} + +# This test is only relevant for the newer kernel +kernel_gte 4.19 || _notrun "This test is only relevant for kernel versions 4.19 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +_mnt() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + _mnt $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + _mnt "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +_not_remount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + _not_remount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + kernel_gte 5.6 && only_ext4 mnt nodioread_nolock + kernel_gte 5.6 && only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + kernel_gte 5.7 && mnt test_dummy_encryption=v1 + kernel_gte 5.7 && mnt test_dummy_encryption=v2 + kernel_gte 5.7 && not_mnt test_dummy_encryption=v3 + kernel_gte 5.7 && not_mnt test_dummy_encryption= + kernel_gte 5.8 && mnt inlinecrypt + kernel_gte 5.8 && not_mnt inlinecrypt + kernel_gte 5.12 && mnt prefetch_block_bitmaps removed + kernel_gte 5.12 && mnt no_prefetch_block_bitmaps + #kernel_gte 5.12 && mnt mb_optimize_scan=0 + #kernel_gte 5.12 && mnt mb_optimize_scan=1 + #kernel_gte 5.12 && not_mnt mb_optimize_scan=9 + #kernel_gte 5.12 && not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + _mnt prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r grpjquota= + _not_remount -r usrjquota=aaquota.user + _not_remount -r grpjquota=aaquota.group + _not_remount -r jqfmt=vfsv1 + _not_remount -r noquota + _mnt remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + _mnt grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r noquota + _not_remount -r usrjquota=aquota.user + _not_remount -r grpjquota=aquota.group + _not_remount -r jqfmt=vfsv1 + _mnt remount,grpjquota= grpquota,^grpjquota + _mnt remount,usrjquota= usrquota,^usrjquota + _mnt remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + _mnt remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exit
tests/ext4/053.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.
Signature · 1 line
2.31.1
Quoted 72 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner <[email protected]>--- tests/ext4/053 | 598 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 600 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.outtests/ext4/053 new file +54
-0@@ -0,0 +1,598 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs + +LOG="" +print_log() { + LOG="$LOG $@" +}
tests/ext4/053 line 64
Quoted 10 lines
tests/ext4/053 new file +10
-0+ +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +kernel_gte() { + gte=`echo "$KERNEL_VERSION >= $1" | $BC_PROG` + [ $gte -eq 1 ] && return 0 + return 1 +} + +# This test is only relevant for the newer kernel +kernel_gte 4.19 || _notrun "This test is only relevant for kernel versions 4.19 and higher"
What was so magic about 4.19?
Regarding the other tests that are gated on kernel_gte: aren't there other ways to find out if the kernel actually supports those features?
--D
Quoted 545 lines
tests/ext4/053 new file +534
-0+ +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +_mnt() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + _mnt $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + _mnt "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +_not_remount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + _not_remount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + kernel_gte 5.6 && only_ext4 mnt nodioread_nolock + kernel_gte 5.6 && only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + kernel_gte 5.7 && mnt test_dummy_encryption=v1 + kernel_gte 5.7 && mnt test_dummy_encryption=v2 + kernel_gte 5.7 && not_mnt test_dummy_encryption=v3 + kernel_gte 5.7 && not_mnt test_dummy_encryption= + kernel_gte 5.8 && mnt inlinecrypt + kernel_gte 5.8 && not_mnt inlinecrypt + kernel_gte 5.12 && mnt prefetch_block_bitmaps removed + kernel_gte 5.12 && mnt no_prefetch_block_bitmaps + #kernel_gte 5.12 && mnt mb_optimize_scan=0 + #kernel_gte 5.12 && mnt mb_optimize_scan=1 + #kernel_gte 5.12 && not_mnt mb_optimize_scan=9 + #kernel_gte 5.12 && not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + _mnt prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r grpjquota= + _not_remount -r usrjquota=aaquota.user + _not_remount -r grpjquota=aaquota.group + _not_remount -r jqfmt=vfsv1 + _not_remount -r noquota + _mnt remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + _mnt grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r noquota + _not_remount -r usrjquota=aquota.user + _not_remount -r grpjquota=aquota.group + _not_remount -r jqfmt=vfsv1 + _mnt remount,grpjquota= grpquota,^grpjquota + _mnt remount,usrjquota= usrquota,^usrjquota + _mnt remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + _mnt remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1
Quoted 77 lines · Darrick J. Wong
Quoted 76 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner <[email protected]>--- tests/ext4/053 | 598 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 600 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.outtests/ext4/053 new file +58
-0@@ -0,0 +1,598 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +kernel_gte() { + gte=`echo "$KERNEL_VERSION >= $1" | $BC_PROG`
Quoted 8 lines
tests/ext4/053 line 64
Quoted 6 lines
tests/ext4/053 new file +6
-0+ [ $gte -eq 1 ] && return 0 + return 1 +} + +# This test is only relevant for the newer kernel +kernel_gte 4.19 || _notrun "This test is only relevant for kernel versions 4.19 and higher"What was so magic about 4.19?
Oh let me tell you about the good olde days :) No seriously, there is nothing magical about it. Back when I wrote the test it seemed like good point where to stop looking further in the history of ext4 mount options. So it is likely completely arbitraty.
Realistically we only really care about the changes we might introduce from now on. There is no point in testing older kernels with this I don't think, so I could as well set it to something more recent which would have the benefit of getting rid of more, most, or even all of the kernel_gte() check if that's preferable. It's probably a good idea to do so when I think about it.
Quoted 3 lines
Regarding the other tests that are gated on
kernel_gte: aren't there other ways to find out if the kernel actually supports those features?
Strictly speaking it's not about features but mount options and no, as far as I can tell there is no way to reliably tell what mount options are supported, other than just try it out, or look it up in the code.
-Lukas
Quoted 549 lines
--D
Quoted 545 lines
tests/ext4/053 new file +534
-0+ +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +_mnt() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + _mnt $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + _mnt "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +_not_remount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + _not_remount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + kernel_gte 5.6 && only_ext4 mnt nodioread_nolock + kernel_gte 5.6 && only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + kernel_gte 5.7 && mnt test_dummy_encryption=v1 + kernel_gte 5.7 && mnt test_dummy_encryption=v2 + kernel_gte 5.7 && not_mnt test_dummy_encryption=v3 + kernel_gte 5.7 && not_mnt test_dummy_encryption= + kernel_gte 5.8 && mnt inlinecrypt + kernel_gte 5.8 && not_mnt inlinecrypt + kernel_gte 5.12 && mnt prefetch_block_bitmaps removed + kernel_gte 5.12 && mnt no_prefetch_block_bitmaps + #kernel_gte 5.12 && mnt mb_optimize_scan=0 + #kernel_gte 5.12 && mnt mb_optimize_scan=1 + #kernel_gte 5.12 && not_mnt mb_optimize_scan=9 + #kernel_gte 5.12 && not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + _mnt prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r grpjquota= + _not_remount -r usrjquota=aaquota.user + _not_remount -r grpjquota=aaquota.group + _not_remount -r jqfmt=vfsv1 + _not_remount -r noquota + _mnt remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + _mnt grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r noquota + _not_remount -r usrjquota=aquota.user + _not_remount -r grpjquota=aquota.group + _not_remount -r jqfmt=vfsv1 + _mnt remount,grpjquota= grpquota,^grpjquota + _mnt remount,usrjquota= usrquota,^usrjquota + _mnt remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + _mnt remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1
PATCH v2 1/1 ext4: add test for all ext4/ext3/ext2 mount options
In reply to Lukas CzernerAdd test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
---
v2: Move minimum kernel version requirement up to 5.12
Rewrite kernel_gte() to work correctly
tests/ext4/053 | 611 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 613 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.out
tests/ext4/053 new file +611 -0
@@ -0,0 +1,611 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +_mnt() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + _mnt $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + _mnt "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +_not_remount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + _not_remount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + mnt inlinecrypt + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + _mnt prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r grpjquota= + _not_remount -r usrjquota=aaquota.user + _not_remount -r grpjquota=aaquota.group + _not_remount -r jqfmt=vfsv1 + _not_remount -r noquota + _mnt remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + _mnt grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r noquota + _not_remount -r usrjquota=aquota.user + _not_remount -r grpjquota=aquota.group + _not_remount -r jqfmt=vfsv1 + _mnt remount,grpjquota= grpquota,^grpjquota + _mnt remount,usrjquota= usrquota,^usrjquota + _mnt remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + _mnt remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exit
tests/ext4/053.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.
Signature · 1 line
2.31.1
Quoted 8 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner <[email protected]>---
v2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
fstests doesn't do version check but only actually try it and see if the wanted feature is supported, so I want to avoid this kernel version check as much as possible.
OTOH, I understand that there's no good way to tell if a mount option is supported by current kernel, and it's not clear a mount failure is caused by a regression or an unsupported mount option.
I'd like to see if anyone else has better ideas/suggestions.
Some minor issues below.
Quoted 194 lines
tests/ext4/053 | 611 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 613 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.outtests/ext4/053 new file +181
-0@@ -0,0 +1,611 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" "
tests/ext4/053 line 191
Quoted 10 lines
tests/ext4/053 new file +10
-0+ do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +_mnt() {
Local functions don't need the _ prefix, that's for common helpers.
Quoted 72 lines
tests/ext4/053 new file +72
-0+ print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + _mnt $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + _mnt "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail
tests/ext4/053 line 273
Quoted 10 lines
tests/ext4/053 new file +10
-0+ else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +_not_remount() {
Same here.
Thanks,
Eryu
Quoted 348 lines
tests/ext4/053 new file +338
-0+ remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + _not_remount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + mnt inlinecrypt + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + _mnt prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r grpjquota= + _not_remount -r usrjquota=aaquota.user + _not_remount -r grpjquota=aaquota.group + _not_remount -r jqfmt=vfsv1 + _not_remount -r noquota + _mnt remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + _mnt grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r noquota + _not_remount -r usrjquota=aquota.user + _not_remount -r grpjquota=aquota.group + _not_remount -r jqfmt=vfsv1 + _mnt remount,grpjquota= grpquota,^grpjquota + _mnt remount,usrjquota= usrquota,^usrjquota + _mnt remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + _mnt remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1
Quoted 10 lines · Eryu Guan
Quoted 8 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner <[email protected]>---
v2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
Quoted 7 lines
fstests doesn't do version check but only actually try it and see if the wanted feature is supported, so I want to avoid this kernel version check as much as possible.
OTOH, I understand that there's no good way to tell if a mount option is supported by current kernel, and it's not clear a mount failure is caused by a regression or an unsupported mount option.
I understand that fstests doesn't do version checking and. But the fact of the matter is that it is needed for this test for the reasons you mentioned.
Quoted 2 lines
I'd like to see if anyone else has better ideas/suggestions.
So what's the goal here. Am I going to have to wait until someone comes up with a better suggestion ?
Quoted 6 lines
Some minor issues below.
Quoted 1 line
+_mnt() {
Local functions don't need the _ prefix, that's for common helpers.
Ok, I can rename it.
-Lukas
Quoted 438 lines
Quoted 73 lines
tests/ext4/053 new file +72
-0+ print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + _mnt $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + _mnt "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + failtests/ext4/053 line 273
Quoted 10 lines
tests/ext4/053 new file +10
-0+ else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +_not_remount() {Same here.
Thanks,
EryuQuoted 348 lines
tests/ext4/053 new file +338
-0+ remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + _not_remount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + mnt inlinecrypt + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + _mnt prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r grpjquota= + _not_remount -r usrjquota=aaquota.user + _not_remount -r grpjquota=aaquota.group + _not_remount -r jqfmt=vfsv1 + _not_remount -r noquota + _mnt remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + _mnt grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + _not_remount -r noquota + _not_remount -r usrjquota=aquota.user + _not_remount -r grpjquota=aquota.group + _not_remount -r jqfmt=vfsv1 + _mnt remount,grpjquota= grpquota,^grpjquota + _mnt remount,usrjquota= usrquota,^usrjquota + _mnt remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + _mnt remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1
PATCH v3 1/1 ext4: add test for all ext4/ext3/ext2 mount options
In reply to Lukas CzernerAdd test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
---
V2: Move minimum kernel version requirement up to 5.12
Rewrite kernel_gte() to work correctly
V3: Rename functions to not start with _
tests/ext4/053 | 611 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 613 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.out
tests/ext4/053 new file +611 -0
@@ -0,0 +1,611 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + mnt inlinecrypt + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exit
tests/ext4/053.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.
Signature · 1 line
2.31.1
Quoted 5 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner <[email protected]>
I see the following failures when testing on kernel that doesn't have ext4 encryption configured
+mounting ext2 "test_dummy_encryption" checking "test_dummy_encryption" (not found) FAILED +mounting ext2 "test_dummy_encryption=v1" checking "test_dummy_encryption=v1" (not found) FAILED +mounting ext2 "test_dummy_encryption=v2" checking "test_dummy_encryption=v2" (not found) FAILED +mounting ext2 "inlinecrypt" checking "inlinecrypt" (not found) FAILED
+mounting ext3 "test_dummy_encryption" checking "test_dummy_encryption" (not found) FAILED +mounting ext3 "test_dummy_encryption=v1" checking "test_dummy_encryption=v1" (not found) FAILED +mounting ext3 "test_dummy_encryption=v2" checking "test_dummy_encryption=v2" (not found) FAILED +mounting ext3 "inlinecrypt" checking "inlinecrypt" (not found) FAILED
+mounting ext4 "test_dummy_encryption" checking "test_dummy_encryption" (not found) FAILED +mounting ext4 "test_dummy_encryption=v1" checking "test_dummy_encryption=v1" (not found) FAILED +mounting ext4 "test_dummy_encryption=v2" checking "test_dummy_encryption=v2" (not found) FAILED +mounting ext4 "inlinecrypt" checking "inlinecrypt" (not found) FAILED
It seems like we should check if CONFIG_FS_ENCRYPTION and CONFIG_FS_ENCRYPTION_INLINE_CRYPT have been configured.
Thanks,
Eryu
Quoted 638 lines
---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _tests/ext4/053 | 611 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 613 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.outtests/ext4/053 new file +611
-0@@ -0,0 +1,611 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + mnt inlinecrypt + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1
Quoted 23 lines · Eryu Guan
Quoted 5 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner <[email protected]>I see the following failures when testing on kernel that doesn't have ext4 encryption configured
(quoted diff) +12
-0+mounting ext2 "test_dummy_encryption" checking "test_dummy_encryption" (not found) FAILED +mounting ext2 "test_dummy_encryption=v1" checking "test_dummy_encryption=v1" (not found) FAILED +mounting ext2 "test_dummy_encryption=v2" checking "test_dummy_encryption=v2" (not found) FAILED +mounting ext2 "inlinecrypt" checking "inlinecrypt" (not found) FAILED +mounting ext3 "test_dummy_encryption" checking "test_dummy_encryption" (not found) FAILED +mounting ext3 "test_dummy_encryption=v1" checking "test_dummy_encryption=v1" (not found) FAILED +mounting ext3 "test_dummy_encryption=v2" checking "test_dummy_encryption=v2" (not found) FAILED +mounting ext3 "inlinecrypt" checking "inlinecrypt" (not found) FAILED +mounting ext4 "test_dummy_encryption" checking "test_dummy_encryption" (not found) FAILED +mounting ext4 "test_dummy_encryption=v1" checking "test_dummy_encryption=v1" (not found) FAILED +mounting ext4 "test_dummy_encryption=v2" checking "test_dummy_encryption=v2" (not found) FAILED +mounting ext4 "inlinecrypt" checking "inlinecrypt" (not found) FAILED
Quoted 2 lines
It seems like we should check if
CONFIG_FS_ENCRYPTIONandCONFIG_FS_ENCRYPTION_INLINE_CRYPThave been configured.
Yeah, this is the same for CONFIG_EXT4_FS_POSIX_ACL and CONFIG_QFMT_V2 which means the I have to parse the kernel config to actually know if it's configured in. Will fix it in the next version.
Thanks!
-Lukas
Quoted 643 lines
Thanks,
EryuQuoted 638 lines
---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _tests/ext4/053 | 611 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 613 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.outtests/ext4/053 new file +611
-0@@ -0,0 +1,611 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + mnt -t acl + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + mnt inlinecrypt + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1
PATCH v4 1/1 ext4: add test for all ext4/ext3/ext2 mount options
In reply to Lukas CzernerAdd test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
---
V2: Move minimum kernel version requirement up to 5.12
Rewrite kernel_gte() to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
tests/ext4/053 | 645 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 647 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.out
tests/ext4/053 new file +645 -0
@@ -0,0 +1,645 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +_has_kernel_config() +{ + option=$1 + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $config +} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exit
tests/ext4/053.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.
Signature · 1 line
2.31.1
tests/ext4/053 line 35
Quoted 6 lines
tests/ext4/053 new file +6
-0+_has_kernel_config() +{ + option=$1 + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $config +}
In my test infrastructure, /lib/modules/$Kver/build/.config doesn't exist. That's because I build the kernel without any modules, and then launch kvm using its --kernel command-line option. This really helps with development velocity, since the developer doesn't need to waste time installing the kernel, and/or building a kernel rpm or dpkg. Instead, kvm can just launch the kernel directly out of the build tree:
/usr/bin/kvm ... --kernel /build/ext4/arch/x86/boot/bzImage ..
So it would be nice if _has_kernel_config also checks to see if /proc/config.gz exists, and if so, tries to use it.
Thanks,
- Ted
Quoted 15 lines · Theodore Ts'o
tests/ext4/053 line 35
Quoted 6 lines
tests/ext4/053 new file +6
-0+_has_kernel_config() +{ + option=$1 + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $config +}In my test infrastructure,
/lib/modules/$Kver/build/.configdoesn't exist. That's because I build the kernel without any modules, and then launch kvm using its --kernel command-line option. This really helps with development velocity, since the developer doesn't need to waste time installing the kernel, and/or building a kernel rpm or dpkg. Instead, kvm can just launch the kernel directly out of the build tree:
Quoted 4 lines
/usr/bin/kvm... --kernel /build/ext4/arch/x86/boot/bzImage ..So it would be nice if
_has_kernel_configalso checks to see if/proc/config.gzexists, and if so, tries to use it.
Good point. Of course it would only work if kernel is configured to have /proc/config.gz, but I don't know of any other reliable way to checking the kernel config.
Thanks!
-Lukas
Quoted 5 lines
Thanks,
- Ted
PATCH v5 1/1 ext4: add test for all ext4/ext3/ext2 mount options
In reply to Lukas CzernerAdd test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
---
V2: Move minimum kernel version requirement up to 5.12
Rewrite kernel_gte() to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
V5: Check /proc/config.gz for kernel config location first
tests/ext4/053 | 650 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 652 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.out
tests/ext4/053 new file +650 -0
@@ -0,0 +1,650 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +_has_kernel_config() +{ + option=$1 + config="/proc/config.gz" + if [ -f $config ]; then + gzip -cd $config | grep -qE "^${option}=[my]" + return + fi + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $config +} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exit
tests/ext4/053.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.
Signature · 1 line
2.31.1
Quoted 54 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner <[email protected]>---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
V5: Check/proc/config.gzfor kernel config location firsttests/ext4/053 | 650 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 652 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.outtests/ext4/053 new file +29
-0@@ -0,0 +1,650 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} +
tests/ext4/053 line 39
Quoted 10 lines
tests/ext4/053 new file +10
-0+_has_kernel_config() +{ + option=$1 + config="/proc/config.gz" + if [ -f $config ]; then + gzip -cd $config | grep -qE "^${option}=[my]" + return + fi + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $config
This probably ought to check /boot/config-$(uname -r) also, since that file seems to exist on RH and Debian.
(The rest of the logic looks reasonable, but I've been away from ext4 for so long that I don't really have enough of a clue anymore... :( )
--D
Quoted 622 lines
tests/ext4/053 new file +611
-0+} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1
Quoted 60 lines · Darrick J. Wong
Quoted 59 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner <[email protected]>---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
V5: Check/proc/config.gzfor kernel config location firsttests/ext4/053 | 650 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 652 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.outtests/ext4/053 new file +34
-0@@ -0,0 +1,650 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +_has_kernel_config() +{ + option=$1 + config="/proc/config.gz" + if [ -f $config ]; then
Quoted 8 lines
tests/ext4/053 line 39
Quoted 5 lines
tests/ext4/053 new file +5
-0+ gzip -cd $config | grep -qE "^${option}=[my]" + return + fi + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $configThis probably ought to check /boot/config-$(uname -r) also, since that file seems to exist on RH and Debian.
I was thinking about it, but at least on RH the config is in /lib/modules/... which we already check and for custom kernels /boot/config-$(uname -r) does not exist. So it seems redundant, but on the other hand it can't hurt either.
Quoted 3 lines
(The rest of the logic looks reasonable, but I've been away from ext4 for so long that I don't really have enough of a clue anymore... :( )
Thanks!
-Lukas
Quoted 626 lines
--D
Quoted 622 lines
tests/ext4/053 new file +611
-0+} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1
Quoted 70 lines · Lukas Czerner
Quoted 60 lines · Darrick J. Wong
Quoted 59 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner<[email protected]>---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
V5: Check/proc/config.gzfor kernel config location firsttests/ext4/053 | 650 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 652 insertions(+)create mode 100755 tests/ext4/053
create mode 100644 tests/ext4/053.outtests/ext4/053 new file +34
-0@@ -0,0 +1,650 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021Red Hat, Inc., Lukas Czerner<[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} + +_has_kernel_config() +{ + option=$1 + config="/proc/config.gz" + if [ -f $config ]; thenQuoted 8 lines
tests/ext4/053 line 39
Quoted 5 lines
tests/ext4/053 new file +5
-0+ gzip -cd $config | grep -qE "^${option}=[my]" + return + fi + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $configThis probably ought to check /boot/config-$(uname -r) also, since that file seems to exist on RH and Debian.
Quoted 5 lines
I was thinking about it, but at least on RH the config is in
/lib/modules/... which we already check and for custom kernels /boot/config-$(uname -r) does not exist. So it seems redundant, but on the other hand it can't hurt either.
Don't make wheels repeatedly. LTP has sloutions for this. You can refer to it. [1]https://github.com/linux-test-project/ltp/blob/master/lib/tst_kconfig.c#L18
Best Regards
Yang Xu
Quoted 636 lines
Quoted 3 lines
(The rest of the logic looks reasonable, but I've been away from ext4 for so long that I don't really have enough of a clue anymore... :( )
Thanks!
-LukasQuoted 626 lines
--D
Quoted 622 lines
tests/ext4/053 new file +611
-0+} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major&& $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV> /dev/null 2>&1 + [ $? -ne 0 ]&& return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ]&& option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + )> /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG>> $seqres.full + LOG="" +} + +simple_mount() { + _mount $*>> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ]&& print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ]&& return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV> /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV> /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $*>> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT> /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota">> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT>> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT>> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota">> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT>> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT>> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT>> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature ">> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 +echo "$ERR errors encountered">> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden. --2.31.1
Quoted 71 lines · On Fri, Nov 05, 2021 at 12:45:53AM +0000, [email protected] wrote:
Quoted 70 lines · Lukas Czerner
Quoted 68 lines · Darrick J. Wong
Quoted 54 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner<[email protected]>---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
V5: Check/proc/config.gzfor kernel config location firsttests/ext4/053 | 650 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 652 insertions(+)create mode 100755 tests/ext4/053
create mode 100644 tests/ext4/053.outtests/ext4/053 new file +29
-0@@ -0,0 +1,650 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021Red Hat, Inc., Lukas Czerner<[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} +tests/ext4/053 line 39
Quoted 10 lines
tests/ext4/053 new file +10
-0+_has_kernel_config() +{ + option=$1 + config="/proc/config.gz" + if [ -f $config ]; then + gzip -cd $config | grep -qE "^${option}=[my]" + return + fi + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $configThis probably ought to check /boot/config-$(uname -r) also, since that file seems to exist on RH and Debian.
Quoted 8 lines
Quoted 5 lines
I was thinking about it, but at least on RH the config is in
/lib/modules/... which we already check and for custom kernels /boot/config-$(uname -r) does not exist. So it seems redundant, but on the other hand it can't hurt either.Don't make wheels repeatedly. LTP has sloutions for this. You can refer to it. [1]https://github.com/linux-test-project/ltp/blob/master/lib/tst_kconfig.c#L18
I did not know about this; that is a good suggestion!
--D
Quoted 638 lines
Best Regards
Yang XuQuoted 636 lines
Quoted 3 lines
(The rest of the logic looks reasonable, but I've been away from ext4 for so long that I don't really have enough of a clue anymore... :( )
Thanks!
-LukasQuoted 626 lines
--D
Quoted 622 lines
tests/ext4/053 new file +611
-0+} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major&& $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV> /dev/null 2>&1 + [ $? -ne 0 ]&& return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ]&& option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + )> /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG>> $seqres.full + LOG="" +} + +simple_mount() { + _mount $*>> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ]&& print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ]&& return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV> /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV> /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $*>> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT> /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota">> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT>> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT>> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota">> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT>> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT>> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT>> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature ">> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 +echo "$ERR errors encountered">> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden. --2.31.1
Quoted 71 lines · On Fri, Nov 05, 2021 at 12:45:53AM +0000, [email protected] wrote:
Quoted 70 lines · Lukas Czerner
Quoted 68 lines · Darrick J. Wong
Quoted 54 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner<[email protected]>---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
V5: Check/proc/config.gzfor kernel config location firsttests/ext4/053 | 650 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 652 insertions(+)create mode 100755 tests/ext4/053
create mode 100644 tests/ext4/053.outtests/ext4/053 new file +29
-0@@ -0,0 +1,650 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021Red Hat, Inc., Lukas Czerner<[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} +tests/ext4/053 line 39
Quoted 10 lines
tests/ext4/053 new file +10
-0+_has_kernel_config() +{ + option=$1 + config="/proc/config.gz" + if [ -f $config ]; then + gzip -cd $config | grep -qE "^${option}=[my]" + return + fi + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $configThis probably ought to check /boot/config-$(uname -r) also, since that file seems to exist on RH and Debian.
Quoted 8 lines
Quoted 5 lines
I was thinking about it, but at least on RH the config is in
/lib/modules/... which we already check and for custom kernels /boot/config-$(uname -r) does not exist. So it seems redundant, but on the other hand it can't hurt either.Don't make wheels repeatedly. LTP has sloutions for this. You can refer to it. [1]https://github.com/linux-test-project/ltp/blob/master/lib/tst_kconfig.c#L18
Thanks for the tip. However it is missing the location that works most reliably on the systems I tried recently and that is /lib/modules/$(uname -r)/build/.config
Most of my systems don't have anything else for the custom kernels I am testing.
Anyway I am going to model it after that and move the helpers to common/rc.
Thanks!
-Lukas
Quoted 639 lines
Best Regards
Yang XuQuoted 636 lines
Quoted 3 lines
(The rest of the logic looks reasonable, but I've been away from ext4 for so long that I don't really have enough of a clue anymore... :( )
Thanks!
-LukasQuoted 626 lines
--D
Quoted 622 lines
tests/ext4/053 new file +611
-0+} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major&& $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV> /dev/null 2>&1 + [ $? -ne 0 ]&& return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ]&& option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + )> /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG>> $seqres.full + LOG="" +} + +simple_mount() { + _mount $*>> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ]&& print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ]&& return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV> /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV> /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $*>> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT> /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota">> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT>> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT>> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota">> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT>> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT>> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT>> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature ">> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 +echo "$ERR errors encountered">> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden. --2.31.1
Quoted 81 lines · Lukas Czerner
Quoted 71 lines · On Fri, Nov 05, 2021 at 12:45:53AM +0000, [email protected] wrote:
Quoted 70 lines · Lukas Czerner
Quoted 68 lines · Darrick J. Wong
Quoted 54 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Signed-off-by Lukas Czerner<[email protected]>---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
V5: Check/proc/config.gzfor kernel config location firsttests/ext4/053 | 650 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 652 insertions(+)create mode 100755 tests/ext4/053
create mode 100644 tests/ext4/053.outtests/ext4/053 new file +29
-0@@ -0,0 +1,650 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021Red Hat, Inc., Lukas Czerner<[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null + fi + rm -f $tmp.* +} +tests/ext4/053 line 39
Quoted 10 lines
tests/ext4/053 new file +10
-0+_has_kernel_config() +{ + option=$1 + config="/proc/config.gz" + if [ -f $config ]; then + gzip -cd $config | grep -qE "^${option}=[my]" + return + fi + config="/lib/modules/$(uname -r)/build/.config" + grep -qE "^${option}=[my]" $configThis probably ought to check /boot/config-$(uname -r) also, since that file seems to exist on RH and Debian.
Quoted 8 lines
Quoted 5 lines
I was thinking about it, but at least on RH the config is in
/lib/modules/... which we already check and for custom kernels /boot/config-$(uname -r) does not exist. So it seems redundant, but on the other hand it can't hurt either.Don't make wheels repeatedly. LTP has sloutions for this. You can refer to it. [1]https://github.com/linux-test-project/ltp/blob/master/lib/tst_kconfig.c#L18
Quoted 6 lines
Thanks for the tip. However it is missing the location that works most reliably on the systems I tried recently and that is /lib/modules/$(uname -r)/build/.config
Most of my systems don't have anything else for the custom kernels I am testing.
Good suggestion. I will add this path to ltp. Before this, for myself build linux kernel, I usually use KCONFIG_PATH env.
Best Regards
Yang Xu
Quoted 647 lines
Anyway I am going to model it after that and move the helpers to common/rc.
Thanks!
-LukasQuoted 639 lines
Best Regards
Yang XuQuoted 636 lines
Quoted 3 lines
(The rest of the logic looks reasonable, but I've been away from ext4 for so long that I don't really have enough of a clue anymore... :( )
Thanks!
-LukasQuoted 626 lines
--D
Quoted 622 lines
tests/ext4/053 new file +611
-0+} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major&& $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV> /dev/null 2>&1 + [ $? -ne 0 ]&& return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ]&& option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + )> /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG>> $seqres.full + LOG="" +} + +simple_mount() { + _mount $*>> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ]&& print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ]&& return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV> /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV> /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ]&& fail&& return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $*>> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT> /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota">> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT>> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT>> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota">> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT>> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT>> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT>> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature ">> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT> /dev/null 2>&1 +echo "$ERR errors encountered">> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden. --2.31.1
Quoted 4 lines · Lukas Czerner
Add test to validate that all the ext4, ext3 and ext2 are properly recognized, validate and applied to avoid regressions as ext4 moves to the new mount API.
Quoted 8 lines
Signed-off-by Lukas Czerner <[email protected]>---
V2: Move minimum kernel version requirement up to 5.12
Rewritekernel_gte()to work correctly
V3: Rename functions to not start with _
V4: Check kernel config file to make sure the test works with
various kernel configuration
V5: Check/proc/config.gzfor kernel config location first
Thanks for the revision! Test passed for me now in my test env.
Quoted 38 lines
tests/ext4/053 | 650 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/053.out | 2 + 2 files changed, 652 insertions(+) create mode 100755 tests/ext4/053 create mode 100644 tests/ext4/053.outtests/ext4/053 new file +25
-0@@ -0,0 +1,650 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc., Lukas Czerner <[email protected]>. +# +# FS QA Test 053 +# +# Sanity check of ext4 mount options +# +. ./common/preamble +_begin_fstest auto mount + +seq=`basename $0` +seqres=$RESULT_DIR/$seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + if [ -n "$LOOP_LOGDEV" ];then + _destroy_loop_device $LOOP_LOGDEV 2>/dev/null
tests/ext4/053 line 35
Quoted 10 lines
tests/ext4/053 new file +10
-0+ fi + rm -f $tmp.* +} + +_has_kernel_config() +{ + option=$1 + config="/proc/config.gz" + if [ -f $config ]; then + gzip -cd $config | grep -qE "^${option}=[my]"
Should make sure gzip is available first. Define GZIP_PROG in common/config then
_require_command "$GZIP_PROG" gzip
in _require_kernel_config.
tests/ext4/053 line 38
Quoted 3 lines
tests/ext4/053 new file +3
-0+ return + fi + config="/lib/modules/$(uname -r)/build/.config"
Check if $config exists as well? I think the kconfig_path() function from LTP as xuyang suggested looks good.
tests/ext4/053 line 45
Quoted 7 lines
tests/ext4/053 new file +7
-0+ grep -qE "^${option}=[my]" $config +} + +_require_kernel_config() +{ + _has_kernel_config $1 || _notrun "Installed kernel not built with $1" +}
Above two helpers could be made common in common/rc.
Thanks,
Eryu
Quoted 615 lines
tests/ext4/053 new file +605
-0+ +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota + +# remove previous $seqres.full before test +rm -f $seqres.full + +echo "Silence is golden." + +SIZE=$((1024 * 1024)) # 1GB in KB +LOGSIZE=$((10 *1024)) # 10MB in KB + +_supported_fs ext2 ext3 ext4 +_require_scratch_size $SIZE +_require_quota +_require_loop +_require_command "$TUNE2FS_PROG" tune2fs +MKE2FS_PROG=$(type -P mke2fs) +_require_command "$MKE2FS_PROG" mke2fs +_require_kernel_config CONFIG_QFMT_V2 + +LOG="" +print_log() { + LOG="$LOG $@" +} + +KERNEL_VERSION=`uname -r | cut -d'.' -f1,2` +KERNEL_MAJ=${KERNEL_VERSION%.*} +KERNEL_MIN=${KERNEL_VERSION#*.} + +kernel_gte() { + major=${1%.*} + minor=${1#*.} + + if [ $KERNEL_MAJ -gt $major ]; then + return 0 + elif [[ $KERNEL_MAJ -eq $major && $KERNEL_MIN -ge $minor ]]; then + return 0 + fi + return 1 +} + + +# The aim here is to keep the mount options behaviour stable going forward +# so there is not much point in testing older kernels. +kernel_gte 5.12 || _notrun "This test is only relevant for kernel versions 5.12 and higher" + +IGNORED="remount,defaults,ignored,removed" +CHECK_MINFO="lazytime,noatime,nodiratime,noexec,nosuid,ro" +ERR=0 + +test_mnt() { + findmnt -n $SCRATCH_DEV > /dev/null 2>&1 + [ $? -ne 0 ] && return $? + + if [ $# -eq 1 ]; then + OPTS=$1 + elif [ $# -eq 2 ]; then + OPTS=$2 + else + return 0 + fi + + print_log "checking \"$OPTS\" " + # test options in /proc/fs/ext4/dev/options + ( + ret=0 + IFS=',' + for option in $OPTS; do + if echo $IGNORED | grep -w $option; then + continue + fi + + [ $option = "noload" ] && option="norecovery" + + if [[ $option = ^* ]]; then + expected=1 + else + expected=0 + fi + option=${option#^} + + if echo $CHECK_MINFO | grep -w $option; then + findmnt -n -o OPTIONS $SCRATCH_DEV | grep $option + ret=$? + else + grep $option /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options + ret=$? + fi + + if [ $ret -ne $expected ]; then + exit 1 + fi + done + ) > /dev/null 2>&1 + return $? +} + +fail() { + print_log " FAILED" + ERR=$((ERR+1)) + echo $LOG | tee -a $seqres.full + LOG="" +} + +ok() { + print_log " OK" + echo $LOG >> $seqres.full + LOG="" +} + +simple_mount() { + _mount $* >> $seqres.full 2>&1 +} + +# $1 - can hold -n option, if it does argumetns are shifted +# $1 - options to test +# $2 - if provided it's the option string to check for +do_mnt() { + device=$SCRATCH_DEV + # If -n argument is provided do not specify $SCRATCH_DEV + # usefull for remount + if [ "$1" == "-n" ]; then + unset device + shift + fi + + if [ -z "$1" ]; then + simple_mount $device $SCRATCH_MNT + ret=$? + else + simple_mount -o $1 $device $SCRATCH_MNT + ret=$? + fi + if [ $ret -eq 0 ]; then + test_mnt $1 $2 + ret=$? + [ $ret -ne 0 ] && print_log "(not found)" + else + print_log "(failed mount)" + fi + + return $ret +} + +not_mnt() { + # We don't need -t not not_ variant + if [ "$1" == "-t" ]; then + shift + fi + + print_log "SHOULD FAIL mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -eq 0 ]; then + fail + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +mnt_only() { + print_log "mounting $fstype \"$1\" " + do_mnt $@ + if [ $? -ne 0 ]; then + fail + else + ok + fi +} + +mnt() { + # Do we need to run the tune2fs mount option test ? + t2fs=0 + if [ "$1" == "-t" ]; then + t2fs=1 + shift + fi + + mnt_only $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + [ "$t2fs" -eq 0 ] && return + + op_set=$1 + if [ $# -eq 1 ]; then + check=$1 + elif [ $# -eq 2 ]; then + check=$2 + else + return 0 + fi + + # some options need translation for tune2fs + op_set=$(echo $op_set | sed -e 's/data=journal/journal_data/' \ + -e 's/data=ordered/journal_data_ordered/' \ + -e 's/data=writeback/journal_data_writeback/') + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 + mnt_only "defaults" $check + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + if [ "$op_set" = ^* ]; then + op_set=${op_set#^} + else + op_set="^${op_set}" + fi + $TUNE2FS_PROG -o $op_set $SCRATCH_DEV > /dev/null 2>&1 +} + +# $1 - options to mount with +# $2 - options to remount with +remount() { + # First do this specifying both dev and mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting \"$2\" " + do_mnt remount,$2 $3 + if [ $? -ne 0 ]; then + fail + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + return + else + ok + fi + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + # Now just specify mnt + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + print_log "remounting (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -ne 0 ]; then + fail + else + ok + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + +# $1 - options to mount with, or -r argument +# $2 - options to remount with +not_remount_noumount() { + remount_only=0 + # If -r is specified we're going to do remount only + if [ "$1" == "-r" ]; then + remount_only=1 + # Dont need shift since first argument would + # have been consumed by mount anyway + fi + + if [ $remount_only -eq 0 ]; then + print_log "mounting $fstype \"$1\" " + do_mnt $1 + [ $? -ne 0 ] && fail && return + fi + print_log "SHOULD FAIL remounting $fstype \"$2\" " + do_mnt remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi + + # Now just specify mnt + print_log "SHOULD FAIL remounting $fstype (MNT ONLY) \"$2\" " + do_mnt -n remount,$2 $3 + if [ $? -eq 0 ]; then + fail + else + ok + fi +} + +not_remount() { + not_remount_noumount $* + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null +} + + +do_mkfs() { + $MKE2FS_PROG -T $fstype -Fq $* >> $seqres.full 2>&1 || + _fail "mkfs failed - $MKFS_EXT4_PROG -Fq $* $SCRATCH_DEV" +} + +not_ext2() { + if [[ $fstype == "ext2" ]]; then + not_$* + else + $* + fi +} + +only_ext4() { + if [[ $fstype == "ext4" ]]; then + $* + else + not_$* + fi +} + +# Create logdev for external journal +LOOP_IMG=$tmp.logdev +truncate -s ${LOGSIZE}k $LOOP_IMG +LOOP_LOGDEV=`_create_loop_device $LOOP_IMG` +majmin=`stat -c "%t:%T" $LOOP_LOGDEV` +LOGDEV_DEVNUM=`echo "${majmin%:*}*2^8 + ${majmin#*:}" | bc` + +# Test all the extN file system supported by ext4 driver +fstype= +for fstype in ext2 ext3 ext4; do + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + $UMOUNT_PROG $SCRATCH_DEV 2> /dev/null + + do_mkfs $SCRATCH_DEV ${SIZE}k + + # do we have fstype support ? + do_mnt + if [ $? -ne 0 ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + if [ ! -f /proc/fs/ext4/$(_short_dev $SCRATCH_DEV)/options ]; then + print_log "$fstype not supported. Skipping..." + ok + continue + fi + + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + + not_mnt failme + mnt + mnt bsddf + mnt minixdf + mnt grpid + mnt -t bsdgroups grpid + mnt nogrpid + mnt sysvgroups nogrpid + mnt resgid=1001 + mnt resuid=1001 + mnt sb=131072 + mnt errors=continue + mnt errors=panic + mnt errors=remount-ro + mnt nouid32 + mnt debug + mnt oldalloc removed + mnt orlov removed + mnt -t user_xattr + mnt nouser_xattr + + if _has_kernel_config CONFIG_EXT4_FS_POSIX_ACL; then + mnt -t acl + else + mnt -t acl ^acl + fi + + not_ext2 mnt noload norecovery + mnt bh removed + mnt nobh removed + not_ext2 mnt commit=7 + mnt min_batch_time=200 + mnt max_batch_time=10000 + only_ext4 mnt journal_checksum + only_ext4 mnt nojournal_checksum + only_ext4 mnt journal_async_commit,data=writeback + mnt abort ignored + not_ext2 mnt -t data=journal + not_ext2 mnt -t data=ordered + not_ext2 mnt -t data=writeback + not_ext2 mnt data_err=abort + not_ext2 mnt data_err=ignore ignored + mnt usrjquota=aquota.user,jqfmt=vfsv0 + not_mnt usrjquota=aquota.user + mnt usrjquota= ignored + mnt grpjquota=aquota.group,jqfmt=vfsv0 + not_mnt grpjquota=aquota.group + mnt grpjquota= ignored + mnt jqfmt=vfsold + mnt jqfmt=vfsv0 + mnt jqfmt=vfsv1 + mnt grpquota + mnt quota + mnt noquota + mnt usrquota + mnt grpquota + mnt barrier + mnt barrier=0 nobarrier + mnt barrier=1 barrier + mnt barrier=99 barrier + mnt -t nobarrier + mnt i_version + mnt stripe=512 + only_ext4 mnt delalloc + only_ext4 mnt -t nodelalloc + mnt warn_on_error + mnt nowarn_on_error + not_mnt debug_want_extra_isize=512 + mnt debug_want_extra_isize=32 ignored + mnt mblk_io_submit removed + mnt nomblk_io_submit removed + mnt -t block_validity + mnt noblock_validity + mnt inode_readahead_blks=16 + not_ext2 mnt journal_ioprio=6 ignored + mnt auto_da_alloc=0 noauto_da_alloc + mnt auto_da_alloc=1 auto_da_alloc + mnt auto_da_alloc=95 auto_da_alloc + mnt auto_da_alloc + mnt noauto_da_alloc + only_ext4 mnt dioread_nolock + only_ext4 mnt nodioread_nolock + only_ext4 mnt dioread_lock nodioread_nolock + mnt -t discard + mnt nodiscard + mnt init_itable=20 + mnt init_itable + mnt init_itable=0 + mnt noinit_itable + mnt max_dir_size_kb=4096 + + if _has_kernel_config CONFIG_FS_ENCRYPTION; then + mnt test_dummy_encryption + mnt test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + else + mnt test_dummy_encryption ^test_dummy_encryption + mnt test_dummy_encryption=v1 ^test_dummy_encryption=v1 + mnt test_dummy_encryption=v2 ^test_dummy_encryption=v2 + not_mnt test_dummy_encryption=v3 + not_mnt test_dummy_encryption= + fi + + if _has_kernel_config CONFIG_FS_ENCRYPTION_INLINE_CRYPT; then + mnt inlinecrypt + else + mnt inlinecrypt ^inlinecrypt + fi + + mnt prefetch_block_bitmaps removed + mnt no_prefetch_block_bitmaps + # We don't currently have a way to know that the option has been + # applied, so comment it out for now. This should be fixed in the + # future. + #mnt mb_optimize_scan=0 + #mnt mb_optimize_scan=1 + #not_mnt mb_optimize_scan=9 + #not_mnt mb_optimize_scan= + mnt nombcache + mnt no_mbcache nombcache + mnt check=none removed + mnt nocheck removed + mnt reservation removed + mnt noreservation removed + mnt journal=20 ignored + not_mnt nonsenseoption + not_mnt nonsenseoption=value + + # generic mount options + mnt lazytime + mnt nolazytime ^lazytime + mnt noatime + mnt nodiratime + mnt noexec + mnt nosuid + mnt ro + + # generic remount check + remount barrier nobarrier + remount nobarrier barrier + remount discard nodiscard + remount nodiscard discard + + # dax mount options + simple_mount -o dax=always $SCRATCH_DEV $SCRATCH_MNT > /dev/null 2>&1 + if [ $? -eq 0 ]; then + $UMOUNT_PROG $SCRATCH_MNT 2> /dev/null + mnt dax + mnt dax=always + mnt dax=never + mnt dax=inode + + not_remount lazytime dax + not_remount dax=always dax=never + + if [[ $fstype != "ext2" ]]; then + not_remount data=journal dax + not_remount data=journal dax=always + not_remount data=journal dax=never + not_remount data=journal dax=inode + fi + fi + + # Quota remount check + remount grpquota usrquota + remount usrquota quota + remount usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpquota grpjquota=q.g,jqfmt=vfsv0 + + not_remount usrquota grpjquota=q.g,jqfmt=vfsv0 + not_remount grpquota usrjquota=q.u,jqfmt=vfsv0 + + remount quota usrjquota=q.u,jqfmt=vfsv0 + not_remount quota grpjquota=q.g,jqfmt=vfsv0 + + remount usrjquota=q.u,jqfmt=vfsv0 grpjquota=q.g + not_remount usrjquota=q.u,jqfmt=vfsv0 usrjquota=q.ua + not_remount grpjquota=q.g,jqfmt=vfsv0 grpjquota=q.ga + + remount usrjquota=q.u,jqfmt=vfsv0 usrquota usrjquota=q.u,jqfmt=vfsv0 + remount grpjquota=q.g,jqfmt=vfsv0 grpquota grpjquota=q.g,jqfmt=vfsv0 + not_remount usrjquota=q.u,jqfmt=vfsv0 grpquota + not_remount grpjquota=q.g,jqfmt=vfsv0 usrquota + + remount grpjquota=q.g,jqfmt=vfsv0 grpjquota= ^grpjquota= + remount usrjquota=q.u,jqfmt=vfsv0 usrjquota= ^usrjquota= + remount grpjquota=q.g,usrjquota=q.u,jqfmt=vfsv0 grpjquota=,usrjquota= ^grpjquota=,^usrjquota= + + remount jqfmt=vfsv0 grpjquota=q.g + remount jqfmt=vfsv0 usrjquota=q.u + + if [[ $fstype != "ext2" ]]; then + remount noload data=journal norecovery + not_remount data=ordered data=journal + not_remount data=journal data=writeback + not_remount data=writeback data=ordered + fi + + do_mkfs -O journal_dev $LOOP_LOGDEV ${LOGSIZE}k + do_mkfs -J device=$LOOP_LOGDEV $SCRATCH_DEV ${SIZE}k + mnt defaults + mnt journal_path=$LOOP_LOGDEV ignored + mnt journal_dev=$LOGDEV_DEVNUM ignored + not_mnt journal_path=${LOOP_LOGDEV}_nonexistent ignored + not_mnt journal_dev=123456 ignored + not_mnt journal_dev=999999999999999 ignored + + do_mkfs -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt prjquota + + # test clearing/changing journalled quota when enabled + echo "== Testing active journalled quota" >> $seqres.full + mnt_only prjquota,grpjquota=aquota.group,usrjquota=aquota.user,jqfmt=vfsv0 + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r grpjquota= + not_remount_noumount -r usrjquota=aaquota.user + not_remount_noumount -r grpjquota=aaquota.group + not_remount_noumount -r jqfmt=vfsv1 + not_remount_noumount -r noquota + mnt_only remount,usrquota,grpquota ^usrquota,^grpquota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # test clearing/changing quota when enabled + do_mkfs -E quotatype=^prjquota $SCRATCH_DEV ${SIZE}k + not_mnt prjquota + echo "== Testing active non-journalled quota" >> $seqres.full + mnt_only grpquota,usrquota + + # Prepare and enable quota + quotacheck -vugm $SCRATCH_MNT >> $seqres.full 2>&1 + quotaon -vug $SCRATCH_MNT >> $seqres.full 2>&1 + + not_remount_noumount -r noquota + not_remount_noumount -r usrjquota=aquota.user + not_remount_noumount -r grpjquota=aquota.group + not_remount_noumount -r jqfmt=vfsv1 + mnt_only remount,grpjquota= grpquota,^grpjquota + mnt_only remount,usrjquota= usrquota,^usrjquota + mnt_only remount,usrquota,grpquota usrquota,grpquota + quotaoff -f $SCRATCH_MNT >> $seqres.full 2>&1 + mnt_only remount,noquota ^usrquota,^grpquota,quota + $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 + + # Quota feature + echo "== Testing quota feature " >> $seqres.full + do_mkfs -O quota -E quotatype=prjquota $SCRATCH_DEV ${SIZE}k + mnt usrjquota=aquota.user,jqfmt=vfsv0 ^usrjquota= + mnt grpjquota=aquota.user,jqfmt=vfsv0 ^grpjquota= + mnt jqfmt=vfsv1 ^jqfmt= + mnt prjquota + mnt usrquota + mnt grpquota + not_remount defaults usrjquota=aquota.user + not_remount defaults grpjquota=aquota.user + not_remount defaults jqfmt=vfsv1 + remount defaults grpjquota=,usrjquota= ignored + +done #for fstype in ext2 ext3 ext4; do + +$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 +echo "$ERR errors encountered" >> $seqres.full + +status=$ERR +exittests/ext4/053.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 053 +Silence is golden.Signature · 1 line
2.31.1