btrfs: test that defrag on small files does not hang or crashes
authorFilipe Manana <fdmanana@suse.com>
Tue, 18 Jan 2022 16:36:52 +0000 (16:36 +0000)
committerEryu Guan <guaneryu@gmail.com>
Sun, 23 Jan 2022 14:25:12 +0000 (22:25 +0800)
commit5c0235c9565c53aff2338f17da101eff7c13e582
tree0d6415aab4f5a92dc81a1786bab804ac45aa4817
parentcf686862d840bd8e2906db5abc38d78be96d0249
btrfs: test that defrag on small files does not hang or crashes

Test that defragging files with very small sizes works and does not
result in any crash, hang or corruption.

This is motivated by a regression introduced in kernel 5.16 where
attempting to defrag a file with a size of 1 byte would result in
the kernel code hitting an "infinite" loop (iterating from 0 to
(u64)-1 in increments of 256K, which in practice is an eternity).

The regression is fixed by a patch with the following subject:

  "btrfs: fix too long loop when defragging a 1 byte file"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/256 [new file with mode: 0755]
tests/btrfs/256.out [new file with mode: 0644]