aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-02-04 09:30:58 -0500
committerChris Mason <chris.mason@oracle.com>2009-02-04 09:30:58 -0500
commit06d9a8d7c24fe22836bf0b0f82db59d6f98e271e (patch)
treeb6cc453c21c2cb38f8a4b10401bec8652c75a83f /fs
parentf03d9301f15fb69cdf1eb59d53c9fb72f68ecccc (diff)
Btrfs: Change btrfs_truncate_inode_items to stop when it hits the inode
btrfs_truncate_inode_items is setup to stop doing btree searches when it has finished removing the items for the inode. It used to detect the end of the inode by looking for an objectid that didn't match the one we were searching for. But, this would result in an extra search through the btree, which adds extra balancing and cow costs to the operation. This commit adds a check to see if we found the inode item, which means we can stop searching early. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/inode.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 9b43a6f303b8..ddb0f0ecda6c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2504,7 +2504,7 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
2504 struct btrfs_path *path; 2504 struct btrfs_path *path;
2505 struct btrfs_key key; 2505 struct btrfs_key key;
2506 struct btrfs_key found_key; 2506 struct btrfs_key found_key;
2507 u32 found_type; 2507 u32 found_type = (u8)-1;
2508 struct extent_buffer *leaf; 2508 struct extent_buffer *leaf;
2509 struct btrfs_file_extent_item *fi; 2509 struct btrfs_file_extent_item *fi;
2510 u64 extent_start = 0; 2510 u64 extent_start = 0;
@@ -2691,6 +2691,8 @@ next:
2691 if (pending_del_nr) 2691 if (pending_del_nr)
2692 goto del_pending; 2692 goto del_pending;
2693 btrfs_release_path(root, path); 2693 btrfs_release_path(root, path);
2694 if (found_type == BTRFS_INODE_ITEM_KEY)
2695 break;
2694 goto search_again; 2696 goto search_again;
2695 } 2697 }
2696 2698
@@ -2707,6 +2709,8 @@ del_pending:
2707 BUG_ON(ret); 2709 BUG_ON(ret);
2708 pending_del_nr = 0; 2710 pending_del_nr = 0;
2709 btrfs_release_path(root, path); 2711 btrfs_release_path(root, path);
2712 if (found_type == BTRFS_INODE_ITEM_KEY)
2713 break;
2710 goto search_again; 2714 goto search_again;
2711 } 2715 }
2712 } 2716 }