Re: Bug Report: Btrfs prompts "can't allocate space for delete" when block size arounds 512M

From: Hongzhi, Song
Date: Fri Aug 02 2019 - 03:03:49 EST


Add linux-kernel@xxxxxxxxxxxxxxxx

Ping...


Thanks,

--Hongzhi


On 7/17/19 4:34 PM, Hongzhi, Song wrote:
Hi friends,

*Description:*


ÂÂÂ One LTP testcase, fs_fill.c, fails on btrfs with kernel error when unlink files on Btrfs device:

ÂÂÂ "BTRFS warning (device loop0): could not allocate space for a delete; will truncate on mount".


ÂÂÂ I found the loop block device formatted with btrfs roughly rangs from 460M to 560M will cause the error.

ÂÂÂ 256M and 1G all pass.


ÂÂÂ The fs_fill.c source code:

[https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/fs/fs_fill/fs_fill.c]

ÂÂÂ The fs_fill.c calls unlink which triggers the error.

[https://github.com/linux-test-project/ltp/blob/e3457e42c1b93f54bb81da746eba314fd34ad40e/testcases/kernel/fs/fs_fill/fs_fill.c#L55]

[https://github.com/linux-test-project/ltp/blob/e3457e42c1b93f54bb81da746eba314fd34ad40e/lib/safe_macros.c#L358]


*Error info:*

ÂÂÂ The issue maybe not reproduced everytime but four fifths chance.

ÂÂÂ fs_fill.c:53: INFO: Unlinking mntpoint/thread5/file0
ÂÂÂ safe_macros.c:360: BROK: fs_fill.c:55: unlink(mntpoint/thread10/file0) failed: ENOSPC
ÂÂÂ safe_macros.c:360: BROK: fs_fill.c:55: unlink(mntpoint/thread11/file0) failed: ENOSPC
ÂÂÂ [62477.378848] BTRFS warning (device loop0): could not allocate space for a delete; will truncate on mount
ÂÂÂ [62477.378905] BTRFS warning (device loop0): could not allocate space for a delete; will truncate on mount



*Kernel:*

ÂÂÂ After v5.2-rc1, qemux86-64

ÂÂÂ # make -j40 ARCH=x86_64 CROSS_COMPILE=x86-64-gcc
ÂÂÂ use qemu to bootup kernel


*LTP:*

ÂÂÂ master branch: I tested on 20190625
ÂÂÂ Reproduce:

ÂÂÂ // build Ltp
ÂÂÂ # cd Ltp-source
ÂÂÂ # ./build.sh

ÂÂÂ // copy files to qemu
ÂÂÂ # cp runltp testcases/kernel/fs/fs_fill/fs_fill to qemu

ÂÂÂ // login to qemu:
ÂÂÂ // adjust block device size to 512M
ÂÂÂ # vi runltp
ÂÂÂ in function: create_block()
ÂÂÂ ÂÂÂ dd if=/dev/zero of=${TMP}/test.img bs=1024 count=262144
ÂÂÂ ÂÂÂ --->
ÂÂÂ ÂÂÂ dd if=/dev/zero of=${TMP}/test.img bs=1024 count=524288

ÂÂÂ // execute testcase
ÂÂÂ # runltp -f fs -s fs_fill


*Analysis:*

ÂÂÂ One new kernel commit contained in v5.2-rc1 introduces the issue.

ÂÂÂ commit c8eaeac7b734347c3afba7008b7af62f37b9c140
ÂÂÂ Author: Josef Bacik <josef@xxxxxxxxxxxxxx>
ÂÂÂ Date:ÂÂ Wed Apr 10 15:56:10 2019 -0400

ÂÂÂ ÂÂÂ btrfs: reserve delalloc metadata differently
ÂÂ ÂÂ Â ...


Anyone's reply will be appreciated.

--Hongzhi