btrfs: test unaligned punch hole at ENOSPC
authorAnand Jain <anand.jain@oracle.com>
Fri, 31 Jan 2020 05:09:57 +0000 (13:09 +0800)
committerEryu Guan <guaneryu@gmail.com>
Mon, 17 Feb 2020 12:37:50 +0000 (20:37 +0800)
commit108d8cde1c4e6524306e7f23dd137f36e090b628
tree8a0706965f655695a902075aec71f89c7f35ff67
parent2806589445b8ef1108f7c62a53f547021d7a1f93
btrfs: test unaligned punch hole at ENOSPC

Try to punch hole with unaligned size and offset when the FS is full
and mounted with nodatacow option.

Mainly holes are punched at locations which are unaligned with the
file extent boundaries when the FS is full by data.  As the punching
holes at unaligned location will involve truncating blocks instead
of just dropping the extents, it shall involve reserving data and
metadata space for delalloc and so data alloc fails as the FS is
full.

btrfs_punch_hole()
 btrfs_truncate_block()
   btrfs_check_data_free_space() <-- ENOSPC

We don't fail punch hole if the holes are aligned with the file
extent boundaries as it shall involve just dropping the related
extents, without truncating data extent blocks.

This test was orignally merged as btrfs/172 (commit 4c2c678cd), then
Iremoved by commit 538d8a4bcc78. But it's decided to bring back this
test case, now the problem is better understood and the fix is
available in the ML as below.

Link: https://patchwork.kernel.org/patch/11357415/
Reviewed-by: Filipe Manana <fdmanana@suse.com>
(cherry picked from commit 4c2c678cd56a81a210cb16f9f9347073e91e2fb0)
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/204 [new file with mode: 0755]
tests/btrfs/204.out [new file with mode: 0644]
tests/btrfs/group