]> git.hungrycats.org Git - linux/commit
Btrfs: fix incorrect compression ratio detection
authorShilong Wang <wangshilong1991@gmail.com>
Tue, 7 Oct 2014 22:44:35 +0000 (18:44 -0400)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Fri, 23 Jan 2015 13:16:46 +0000 (08:16 -0500)
commit9bf29e14ef59c3eed179ad549dfffbbbea3225e9
tree9ff79cd4041eb63d4dac3b1d237c8bed6f627fb5
parent83cfc87821a3be54967c86b66e89fc211b0d6493
Btrfs: fix incorrect compression ratio detection

Steps to reproduce:
 # mkfs.btrfs -f /dev/sdb
 # mount -t btrfs /dev/sdb /mnt -o compress=lzo
 # dd if=/dev/zero of=/mnt/data bs=$((33*4096)) count=1

after previous steps, inode will be detected as bad compression ratio,
and NOCOMPRESS flag will be set for that inode.

Reason is that compress have a max limit pages every time(128K), if a
132k write in, it will be splitted into two write(128k+4k), this bug
is a leftover for commit 68bb462d42a(Btrfs: don't compress for a small write)

Fix this problem by checking every time before compression, if it is a
small write(<=blocksize), we bail out and fall into nocompression directly.

Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit 4bcbb33255131adbe481c0467df26d654ce3bc78)
fs/btrfs/inode.c