]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Btrfs: Change btrfs_truncate_inode_items to stop when it hits the inode
authorChris Mason <chris.mason@oracle.com>
Wed, 4 Feb 2009 14:30:58 +0000 (09:30 -0500)
committerChris Mason <chris.mason@oracle.com>
Wed, 4 Feb 2009 14:30:58 +0000 (09:30 -0500)
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>
fs/btrfs/inode.c

index 9b43a6f303b8ee8e1fbfd2f15e5230316a3b300e..ddb0f0ecda6c3a8633dabcab8b5b265192df0f56 100644 (file)
@@ -2504,7 +2504,7 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
        struct btrfs_path *path;
        struct btrfs_key key;
        struct btrfs_key found_key;
-       u32 found_type;
+       u32 found_type = (u8)-1;
        struct extent_buffer *leaf;
        struct btrfs_file_extent_item *fi;
        u64 extent_start = 0;
@@ -2691,6 +2691,8 @@ next:
                        if (pending_del_nr)
                                goto del_pending;
                        btrfs_release_path(root, path);
+                       if (found_type == BTRFS_INODE_ITEM_KEY)
+                               break;
                        goto search_again;
                }
 
@@ -2707,6 +2709,8 @@ del_pending:
                        BUG_ON(ret);
                        pending_del_nr = 0;
                        btrfs_release_path(root, path);
+                       if (found_type == BTRFS_INODE_ITEM_KEY)
+                               break;
                        goto search_again;
                }
        }