aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorYan <yanzheng@21cn.com>2007-09-17 11:13:11 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commitbab9fb035faa5119991b64cfee1b14c1d6f6a31b (patch)
tree106f68a6e9ef83f4dc86c24b352ee71de272714d /fs/btrfs/inode.c
parent23223584e44cb1b0b69ba3a9ad74956f292a416b (diff)
Btrfs: truncate: don't update inode->i_blocks when extent is a hole
I think check whether extent is a hole before update 'inode->i_blocks' is unconditional required. (original codes check it only when del_item isn't equal to 0) Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 192fdda0d56e..43bf4337859c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -595,6 +595,7 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
595 btrfs_file_extent_type(fi) != 595 btrfs_file_extent_type(fi) !=
596 BTRFS_FILE_EXTENT_INLINE) { 596 BTRFS_FILE_EXTENT_INLINE) {
597 u64 num_dec; 597 u64 num_dec;
598 extent_start = btrfs_file_extent_disk_blocknr(fi);
598 if (!del_item) { 599 if (!del_item) {
599 u64 orig_num_blocks = 600 u64 orig_num_blocks =
600 btrfs_file_extent_num_blocks(fi); 601 btrfs_file_extent_num_blocks(fi);
@@ -604,12 +605,13 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
604 extent_num_blocks >>= inode->i_blkbits; 605 extent_num_blocks >>= inode->i_blkbits;
605 btrfs_set_file_extent_num_blocks(fi, 606 btrfs_set_file_extent_num_blocks(fi,
606 extent_num_blocks); 607 extent_num_blocks);
607 inode->i_blocks -= (orig_num_blocks - 608 num_dec = (orig_num_blocks -
608 extent_num_blocks) << 3; 609 extent_num_blocks) << 3;
610 if (extent_start != 0) {
611 inode->i_blocks -= num_dec;
612 }
609 btrfs_mark_buffer_dirty(path->nodes[0]); 613 btrfs_mark_buffer_dirty(path->nodes[0]);
610 } else { 614 } else {
611 extent_start =
612 btrfs_file_extent_disk_blocknr(fi);
613 extent_num_blocks = 615 extent_num_blocks =
614 btrfs_file_extent_disk_num_blocks(fi); 616 btrfs_file_extent_disk_num_blocks(fi);
615 /* FIXME blocksize != 4096 */ 617 /* FIXME blocksize != 4096 */