]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix incorrect compression ratio detection
authorShilong Wang <wangshilong1991@gmail.com>
Tue, 7 Oct 2014 22:44:35 +0000 (18:44 -0400)
committerChris Mason <clm@fb.com>
Fri, 21 Nov 2014 01:14:27 +0000 (17:14 -0800)
commit2386580675b7b67c59e3bc11d7ce6ef3c5d052e0
tree13e3cd9b2f2cbd7e9380ffedeef1a139534ea50e
parent59f6dfb46e24e94655676c95e06cbc11b41e877e
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 ccf746a9100(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>
fs/btrfs/inode.c