summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorYan2007-11-07 19:31:09 +0100
committerChris Mason2008-09-25 17:03:57 +0200
commit008630c17cc5654e141c7fd24a3e737de643fec1 (patch)
tree5f46b4c573d4410cdf514158152fbf511861afe9 /fs/btrfs/inode.c
parentBtrfs: Change push_leaf_{leaf,right} to empty the src leave during item deletion (diff)
downloadkernel-qcow2-linux-008630c17cc5654e141c7fd24a3e737de643fec1.tar.gz
kernel-qcow2-linux-008630c17cc5654e141c7fd24a3e737de643fec1.tar.xz
kernel-qcow2-linux-008630c17cc5654e141c7fd24a3e737de643fec1.zip
Properly delete csum item in btrfs_truncate_in_trans.
When 'item_end' is equal to 'inode->i_size', 'found_type' is updated and current item is skipped. This behavior is correct for extent item, but incorrect for csum item. For example, there is a csum item with 'offset == 0'. When deleting the inode, 'inode->i_size' is set to 0, so the csum item isn't deleted. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 25f32d7c7ee8..90cb71d68294 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -611,13 +611,14 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
item_end += btrfs_file_extent_inline_len(leaf,
item);
}
+ item_end--;
}
if (found_type == BTRFS_CSUM_ITEM_KEY) {
ret = btrfs_csum_truncate(trans, root, path,
inode->i_size);
BUG_ON(ret);
}
- if (item_end <= inode->i_size) {
+ if (item_end < inode->i_size) {
if (found_type == BTRFS_DIR_ITEM_KEY) {
found_type = BTRFS_INODE_ITEM_KEY;
} else if (found_type == BTRFS_EXTENT_ITEM_KEY) {