]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Btrfs: fix btrfsck error 400 when truncating a compressed
authorMiao Xie <miaox@cn.fujitsu.com>
Fri, 13 Jan 2012 00:10:12 +0000 (19:10 -0500)
committerGuru Anbalagane <guru.anbalagane@oracle.com>
Fri, 27 Jan 2012 01:20:57 +0000 (17:20 -0800)
commit314f86e36daa653eac5c254b45baac1b058ad6d7
tree452d243f8a3fd06e3fc161486d32c77a059b3fda
parenta6b647aec95f852b229427b38796713227993da2
Btrfs: fix btrfsck error 400 when truncating a compressed

Reproduce steps:
 # mkfs.btrfs /dev/sdb5
 # mount /dev/sdb5 -o compress=lzo /mnt
 # dd if=/dev/zero of=/mnt/tmpfile bs=128K count=1
 # sync
 # truncate -s 64K /mnt/tmpfile
 root 5 inode 257 errors 400

This is because of the wrong if condition, which is used to check if we should
subtract the bytes of the dropped range from i_blocks/i_bytes of i-node or not.
When we truncate a compressed extent, btrfs substracts the bytes of the whole
extent, it's wrong. We should substract the real size that we truncate, no
matter it is a compressed extent or not. Fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit f70a9a6b94af86fca069a7552ab672c31b457786)
fs/btrfs/inode.c