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>

+5 -1
+5 -1
fs/btrfs/inode.c
··· 2504 2504 struct btrfs_path *path; 2505 2505 struct btrfs_key key; 2506 2506 struct btrfs_key found_key; 2507 - u32 found_type; 2507 + u32 found_type = (u8)-1; 2508 2508 struct extent_buffer *leaf; 2509 2509 struct btrfs_file_extent_item *fi; 2510 2510 u64 extent_start = 0; ··· 2691 2691 if (pending_del_nr) 2692 2692 goto del_pending; 2693 2693 btrfs_release_path(root, path); 2694 + if (found_type == BTRFS_INODE_ITEM_KEY) 2695 + break; 2694 2696 goto search_again; 2695 2697 } 2696 2698 ··· 2709 2707 BUG_ON(ret); 2710 2708 pending_del_nr = 0; 2711 2709 btrfs_release_path(root, path); 2710 + if (found_type == BTRFS_INODE_ITEM_KEY) 2711 + break; 2712 2712 goto search_again; 2713 2713 } 2714 2714 }