Test script [1] tries to punch hole on a full FS and it works fine as
long as the hole size and the offset is aligned with the sectorsize and
the extent, so that it could just drop the relevant extent to create the
hole.
The reason why this test fails for non aligned hole size and offset is
because, as it rightfully tries to truncate the non aligned extent at
the front and back of the hole, it tries to create new extent which ends
up with ENOSPC.
Any idea, how do we solve this?
xfs is fine.
[1]
cat ./punch-hole-on-full-fs
------------------------
cleanup()
{
umount /dev/sdb > /dev/null 2>&1
btrfs_reload
}
full_fs_setup()
{
btrfs-dyndbg disable
mkfs.$fs -b 200M -fq $mkfs_options /dev/sdb || exit
mount $mount_options /dev/sdb /mnt/scratch || exit
dd status=none if=/dev/zero of=/mnt/scratch/filler bs=512 > /dev/null 2>&1
}
test()
{
cleanup
full_fs_setup
btrfs-dyndbg enable
echo "---- fallocate -p -o 0 -l $punch_hole_size /mnt/scratch/filler ----"
fallocate -p -o 0 -l $punch_hole_size /mnt/scratch/filler
}
fs=btrfs; mkfs_options=""; mount_options="";
[[ $1 ]] || { echo "usage: $0 <hole-len>"; exit; }
punch_hole_size=$1 && test
------------------------
./punch-hole-on-full-fs 512
-- fallocate -p -o 0 -l 512 /mnt/scratch/filler --
fallocate: /mnt/scratch/filler: fallocate failed: No space left on device
./punch-hole-on-full-fs 8000
-- fallocate -p -o 0 -l 8000 /mnt/scratch/filler --
fallocate: /mnt/scratch/filler: fallocate failed: No space left on device
Thanks, Anand