From: Darrick J. Wong Date: Tue, 7 Nov 2017 01:54:11 +0000 (-0800) Subject: generic/204: use available blocks to determine the number of files to create X-Git-Tag: v2022.05.01~1783 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=1e24e5173efa09c9f2dea17ffd7d344f48f77fc9 generic/204: use available blocks to determine the number of files to create Use the available block count to compute the number of files we think we can create, rather than hardcoding a particular size. This fixes the ENOSPC failures for xfs filesystems with rmap/reflink support. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Eryu Guan --- diff --git a/tests/generic/204 b/tests/generic/204 index ebc9c0fa..1eed8bec 100755 --- a/tests/generic/204 +++ b/tests/generic/204 @@ -69,7 +69,7 @@ _scratch_mount # work out correctly. Space usages is based 22500 files and 1024 reserved blocks # on a 4k block size 256 byte inode size filesystem. resv_blks=1024 -space=97920000 +space=$(stat -f -c '%f * %S' $SCRATCH_MNT | $BC_PROG) # decrease files for inode size. # 22500 * (256 + 4k) = ~97MB @@ -78,10 +78,20 @@ space=97920000 files=$((space / (isize + dbsize))) +# Now do it again, but factor in the filename sizes too. +# We naively assume 8 bytes for inode number, 1 byte for ftype, +# and 1 more byte for namelen, then round up to the nearest 8 +# bytes. + +namelen="$(echo -n "$files" | wc -c)" +direntlen="$(echo "(10 + $namelen + 7) / 8 * 8" | $BC_PROG)" + +files=$((space / (direntlen + isize + dbsize))) + echo files $files, resvblks $resv_blks >> $seqres.full _scratch_resvblks $resv_blks >> $seqres.full 2>&1 -for i in `seq 1 $files`; do +for i in `seq -w 1 $files`; do echo -n > $SCRATCH_MNT/$i echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i done