fi
}
+# Round a proposed filesystem size up to the minimium supported size. The
+# input is in MB and so is the output.
+_small_fs_size_mb()
+{
+ local size="$1"
+ local runner_min_size=0
+ local fs_min_size=0
+
+ case "$FSTYP" in
+ xfs)
+ # xfs no longer supports filesystems smaller than 600m
+ fs_min_size=600
+ ;;
+ f2fs)
+ # f2fs-utils 1.9.0 needs at least 38 MB space for f2fs image.
+ # However, f2fs-utils 1.14.0 needs at least 52 MB. Not sure if
+ # it will change again. So just set it 128M.
+ fs_min_size=128
+ ;;
+ esac
+ (( size < fs_min_size )) && size="$fs_min_size"
+
+ # If the test runner wanted a minimum size, enforce that here.
+ test -n "$MIN_FSSIZE" && runner_min_size=$((MIN_FSSIZE / 1048576))
+ (( size < runner_min_size)) && size="$runner_min_size"
+
+ echo "$size"
+}
+
# Create fs of certain size on scratch device
# _scratch_mkfs_sized <size in bytes> [optional blocksize]
_scratch_mkfs_sized()
img=$SCRATCH_MNT/$seq.img
mnt=$SCRATCH_MNT/$seq.mnt
file=$mnt/file
- size=25M
-
- # f2fs-utils 1.9.0 needs at least 38 MB space for f2fs image. However,
- # f2fs-utils 1.14.0 needs at least 52 MB. Not sure if it will change
- # again. So just set it 128M.
- if [ $FSTYP == "f2fs" ]; then
- size=128M
- fi
+ size=$(_small_fs_size_mb 25)M
# Create an fs on a small, initialized image. The pattern is written to
# the image to detect stale data exposure.
mnt=$TEST_DIR/mnt_$seq
mkdir -p $mnt
+size=$(_small_fs_size_mb 300)
+lvsize=$((size * 85 / 100)) # ~256M
+
# make sure there's enough disk space for 256M lv, test for 300M here in case
# lvm uses some space for metadata
-_scratch_mkfs_sized $((300 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((size * 1024 * 1024)) >>$seqres.full 2>&1
$LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
# We use yes pipe instead of 'lvcreate --yes' because old version of lvm
# (like 2.02.95 in RHEL6) don't support --yes option
-yes | $LVM_PROG lvcreate -L 256M -n $lvname $vgname >>$seqres.full 2>&1
+yes | $LVM_PROG lvcreate -L ${lvsize}M -n $lvname $vgname >>$seqres.full 2>&1
# wait for lvcreation to fully complete
$UDEV_SETTLE_PROG >>$seqres.full 2>&1
physical=`blockdev --getpbsz $SCRATCH_DEV`
logical=`blockdev --getss $SCRATCH_DEV`
+size=$(_small_fs_size_mb 300)
+lvsize=$((size * 91 / 100))
# _get_scsi_debug_dev returns a scsi debug device with 128M in size by default
-SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 300`
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 $size`
test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
$LVM_PROG vgcreate -f $vgname $SCSI_DEBUG_DEV $SCRATCH_DEV >>$seqres.full 2>&1
# We use yes pipe instead of 'lvcreate --yes' because old version of lvm
# (like 2.02.95 in RHEL6) don't support --yes option
-yes | $LVM_PROG lvcreate -i 2 -I 4m -L 275m -n $lvname $vgname \
+yes | $LVM_PROG lvcreate -i 2 -I 4m -L ${lvsize}m -n $lvname $vgname \
>>$seqres.full 2>&1
# wait for lv creation to fully complete
$UDEV_SETTLE_PROG >>$seqres.full 2>&1
rm -rf $SANITY_DIR
mkdir $SANITY_DIR
-devsize=$((1024*1024*200 / 512)) # 200m phys/virt size
+size=$(_small_fs_size_mb 200) # 200m phys/virt size
+devsize=$((1024*1024*size / 512))
csize=$((1024*64 / 512)) # 64k cluster size
lowspace=$((1024*1024 / 512)) # 1m low space threshold
rm -rf $SANITY_DIR
mkdir $SANITY_DIR
-devsize=$((1024*1024*200 / 512)) # 200m phys/virt size
+size=$(_small_fs_size_mb 200) # 200m phys/virt size
+devsize=$((1024*1024*size / 512))
csize=$((1024*64 / 512)) # 64k cluster size
lowspace=$((1024*1024 / 512)) # 1m low space threshold
fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \
$FSSTRESS_AVOID)
-devsize=$((1024*1024*200 / 512)) # 200m phys/virt size
+size=$(_small_fs_size_mb 200) # 200m phys/virt size
+devsize=$((1024*1024*size / 512))
csize=$((1024*64 / 512)) # 64k cluster size
lowspace=$((1024*1024 / 512)) # 1m low space threshold
_require_test
_require_block_device $TEST_DEV
+size=$(_small_fs_size_mb 256)
echo "Get a device with 4096 physical sector size and 512 logical sector size"
-SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 256`
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 $size`
blockdev --getpbsz --getss $SCSI_DEBUG_DEV
echo "mkfs and mount"
_require_block_device $TEST_DEV
_require_scsi_debug
-SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 256`
+size=$(_small_fs_size_mb 256)
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 $size`
test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
_supported_fs generic
_require_scsi_debug
-SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 256`
+size=$(_small_fs_size_mb 256)
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev 512 512 0 $size`
test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
fssize=3000
else
_require_fs_space $TEST_DIR 307200
- fssize=300
+ fssize=$(_small_fs_size_mb 300) # 200m phys/virt size
fi
[ "$FSTYP" = "ext4" ] && _require_dumpe2fs
_supported_fs xfs
_require_scsi_debug
+size=$(_small_fs_size_mb 128)
# Remove xfs signature so -f isn't needed to re-mkfs
_wipe_device()
(
echo "==================="
echo "4k physical 512b logical aligned"
-SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128`
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 $size`
test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
# sector size should default to 4k
_check_mkfs $SCSI_DEBUG_DEV
(
echo "==================="
echo "4k physical 512b logical unaligned"
-SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128`
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 $size`
test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
# should fail on misalignment
_check_mkfs $SCSI_DEBUG_DEV
(
echo "==================="
echo "hard 4k physical / 4k logical"
-SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128`
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 $size`
test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
# block size smaller than sector size should fail
_check_mkfs -b size=2048 $SCSI_DEBUG_DEV