Don't open code grabbing the block size; just use the helper.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
blks=2000
margin='15%'
sz=$((blksz * blks))
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
blks=2000
margin='15%'
sz=$((blksz * blks))
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
blks=2000
margin='15%'
sz=$((blksz * blks))
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
blks=2000
margin='15%'
sz=$((blksz * blks))
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
blks=2000
margin='15%'
free_blocks0=$(stat -f $testdir -c '%f')
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
blks=2000
margin='15%'
sz=$((blksz * blks))
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
blks=2000
margin='15%'
sz=$((blksz * blks))
mkdir $testdir2
echo "Create the original files"
-blksz="$(stat -f $testdir1 -c '%S')"
+blksz="$(get_block_size $testdir1)"
blks=1000
margin='7%'
sz=$((blksz * blks))
mkdir $testdir2
echo "Create the original files"
-blksz="$(stat -f $testdir1 -c '%S')"
+blksz="$(get_block_size $testdir1)"
blks=1000
margin='7%'
sz=$((blksz * blks))
mkdir $testdir1
echo "Create the original files"
-blksz="$(stat -f $testdir1 -c '%S')"
+blksz="$(get_block_size $testdir1)"
blks=1000
margin='7%'
sz=$((blksz * blks))
mkdir $testdir1
echo "Create the original files"
-blksz="$(stat -f $testdir1 -c '%S')"
+blksz="$(get_block_size $testdir1)"
blks=1000
margin='7%'
sz=$((blksz * blks))
mkdir $testdir
echo "Reformat with appropriate size"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=10240
umount $SCRATCH_MNT
sz_bytes=$((nr_blks * 8 * blksz))
mkdir $testdir
echo "Reformat with appropriate size"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=10240
umount $SCRATCH_MNT
sz_bytes=$((nr_blks * 8 * blksz))
mkdir $testdir
echo "Reformat with appropriate size"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=10240
umount $SCRATCH_MNT
sz_bytes=$((nr_blks * 8 * blksz))
mkdir "$testdir"
echo "Create a one block file"
-blksz="$(stat -f "$testdir" -c '%S')"
+blksz="$(get_block_size $testdir)"
_pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
fnr=19
# 2^17 blocks... that should be plenty for anyone.
fnr=20
free_blocks=$(stat -f -c '%a' "$testdir")
-blksz=$(stat -f -c '%S' "$testdir")
+blksz=$(get_block_size "$testdir")
space_avail=$((free_blocks * blksz))
calc_space() {
blocks_needed=$(( 2 ** (fnr + 1) ))
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
echo "Create the original files"
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
echo "Create the original files"
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
echo "Create the original files"
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
echo "Create the original files"
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
echo "Create the original files"
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
echo "Create the original files"
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
echo "Create the original files"
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
echo "Create the original files"
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
runtest() {
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
runtest() {
bufsize=$((blksz * bufnr))
free_blocks=$(stat -f -c '%a' $testdir)
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
space_needed=$(((filesize * 3) * 5 / 4))
space_avail=$((free_blocks * real_blksz))
test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
bufsize=$((blksz * bufnr))
free_blocks=$(stat -f -c '%a' $testdir)
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
space_needed=$(((filesize * 3) * 5 / 4))
space_avail=$((free_blocks * real_blksz))
test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
bufnr=16
bufsize=$((blksz * bufnr))
-real_blksz=$(stat -f -c '%S' "$testdir")
+real_blksz=$(get_block_size "$testdir")
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
echo "Create the original files"
mkdir $testdir
echo "Create a one block file"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
_pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
fnr=26 # 2^26 reflink extents should be enough to find a slow op?
mkdir $testdir
echo "Create a one block file"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
_pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
fnr=26 # 2^26 reflink extents should be enough to find a slow op?
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
mkdir $testdir
echo "Create the original file and reflink to copy1, copy2"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
_pwrite_byte 0x61 0 $((blksz * 14 + 71)) $testdir/original >> $seqres.full
_cp_reflink $testdir/original $testdir/copy1
_cp_reflink $testdir/copy1 $testdir/copy2
blks=2000
margin=160
blksz=65536
-real_blksz="$(stat -f $testdir -c '%S')"
+real_blksz="$(get_block_size $testdir)"
blksz_factor=$((blksz / real_blksz))
_pwrite_byte 0x61 0 $((blks * blksz)) $testdir/file1 >> $seqres.full
_cp_reflink $testdir/file1 $testdir/file2
metadump_file=$TEST_DIR/${seq}_metadump
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=$((4 * blksz / 12))
_pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
blks=2000
margin=100
sz=$((blksz * blks))
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
echo "Create the original files"
sz=$((48 * 1048576))
testdir=$SCRATCH_MNT/test-$seq
mkdir $testdir
-blksz=$(stat -f -c '%S' $testdir)
+blksz=$(get_block_size $testdir)
echo "Create the original files"
sz=$((48 * 1048576))
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=$((8 * blksz / 12))
for i in 1 2 x; do
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 2 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
blksz=65536
nr=64
filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
$XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
_weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
bufsize=$((blksz * bufnr))
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
internal_blks=$((filesize / real_blksz))
echo "Create the original files"
mkdir $testdir
echo "Create the original files"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
_pwrite_byte 0x61 0 $((blksz * 14 + 71)) $testdir/original >> $seqres.full
cp -p $testdir/original $testdir/copy1
cp -p $testdir/copy1 $testdir/copy2
metadump_file=$TEST_DIR/${seq}_metadump
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=$((4 * blksz / 12))
_pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
sync
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=$((8 * blksz / 12))
for i in 1 2 x; do
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=$((2 * blksz / 12))
for i in 1 2 x; do
mkdir $testdir
echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
nr_blks=$((2 * blksz / 12))
for i in 1 2 x; do
_scratch_mount >> $seqres.full
testdir=$SCRATCH_MNT/test-$seq
-blksz="$(stat -f $SCRATCH_MNT -c '%S')"
+blksz="$(get_block_size $SCRATCH_MNT)"
umount $SCRATCH_MNT
echo "Create the original file blocks"
mkdir $testdir
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
$XFS_IO_PROG -f -c "falloc 0 $((nr_blks * blksz))" $testdir/file1 >> $seqres.full
echo "Check extent count"
# 2^10 blocks... that should be plenty for anyone.
fnr=$((12 + LOAD_FACTOR))
free_blocks=$(stat -f -c '%a' "$testdir")
-blksz=$(stat -f -c '%S' "$testdir")
+blksz=$(get_block_size $testdir)
space_avail=$((free_blocks * blksz))
calc_space()
{