]> git.hungrycats.org Git - linux/commitdiff
btrfs: expand btrfs_find_item if found_key is NULL
authorDavid Sterba <dsterba@suse.cz>
Fri, 2 Jan 2015 18:36:14 +0000 (19:36 +0100)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Sun, 8 Mar 2015 04:03:53 +0000 (23:03 -0500)
If the found_key is NULL, then btrfs_find_item becomes a verbose wrapper
for simple btrfs_search_slot.

After we've removed all such callers, passing a NULL key is not valid
anymore.

Signed-off-by: David Sterba <dsterba@suse.cz>
(cherry picked from commit 1d4c08e0a60be356134d0c466744d0d4e16ebab0)

fs/btrfs/ctree.c
fs/btrfs/disk-io.c
fs/btrfs/inode.c
fs/btrfs/scrub.c

index aaa06d2a669e23105aaf4bec542445f20c6f8967..38d642c11264a50c0de176eb9b772eedced9aff9 100644 (file)
@@ -2623,13 +2623,14 @@ int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path,
        struct extent_buffer *eb;
 
        ASSERT(path);
+       ASSERT(found_key);
 
        key.type = key_type;
        key.objectid = iobjectid;
        key.offset = ioff;
 
        ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0);
-       if ((ret < 0) || (found_key == NULL))
+       if (ret < 0)
                return ret;
 
        eb = path->nodes[0];
index f1a9cc463f10670ce5d84e21d268a0f11db64568..a0074f5aa3ba54c83143be94044b768095cc1f0c 100644 (file)
@@ -1630,6 +1630,7 @@ struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
 {
        struct btrfs_root *root;
        struct btrfs_path *path;
+       struct btrfs_key key;
        int ret;
 
        if (location->objectid == BTRFS_ROOT_TREE_OBJECTID)
@@ -1674,8 +1675,11 @@ again:
                ret = -ENOMEM;
                goto fail;
        }
-       ret = btrfs_find_item(fs_info->tree_root, path, BTRFS_ORPHAN_OBJECTID,
-                       location->objectid, BTRFS_ORPHAN_ITEM_KEY, NULL);
+       key.objectid = BTRFS_ORPHAN_OBJECTID;
+       key.type = BTRFS_ORPHAN_ITEM_KEY;
+       key.offset = location->objectid;
+
+       ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
        btrfs_free_path(path);
        if (ret < 0)
                goto fail;
index b6aa91bccaea7043fdbfd1a4c7cab825c406f12d..58bf42f037925d6a298d92b1e0d3165ea1d402fa 100644 (file)
@@ -4957,6 +4957,7 @@ static int fixup_tree_root_location(struct btrfs_root *root,
        struct btrfs_root *new_root;
        struct btrfs_root_ref *ref;
        struct extent_buffer *leaf;
+       struct btrfs_key key;
        int ret;
        int err = 0;
 
@@ -4967,9 +4968,12 @@ static int fixup_tree_root_location(struct btrfs_root *root,
        }
 
        err = -ENOENT;
-       ret = btrfs_find_item(root->fs_info->tree_root, path,
-                               BTRFS_I(dir)->root->root_key.objectid,
-                               location->objectid, BTRFS_ROOT_REF_KEY, NULL);
+       key.objectid = BTRFS_I(dir)->root->root_key.objectid;
+       key.type = BTRFS_ROOT_REF_KEY;
+       key.offset = location->objectid;
+
+       ret = btrfs_search_slot(NULL, root->fs_info->tree_root, &key, path,
+                               0, 0);
        if (ret) {
                if (ret < 0)
                        err = ret;
index bb5d31a7eb5e45b0e1c5802eb3aa04e81904b1a3..0b88ff74b78a83fa9dd4c9dbc9647594232bb7e7 100644 (file)
@@ -470,6 +470,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
        struct inode_fs_paths *ipath = NULL;
        struct btrfs_root *local_root;
        struct btrfs_key root_key;
+       struct btrfs_key key;
 
        root_key.objectid = root;
        root_key.type = BTRFS_ROOT_ITEM_KEY;
@@ -483,8 +484,11 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
        /*
         * this makes the path point to (inum INODE_ITEM ioff)
         */
-       ret = btrfs_find_item(local_root, swarn->path, inum, 0,
-                       BTRFS_INODE_ITEM_KEY, NULL);
+       key.objectid = inum;
+       key.type = BTRFS_INODE_ITEM_KEY;
+       key.offset = 0;
+
+       ret = btrfs_search_slot(NULL, local_root, &key, swarn->path, 0, 0);
        if (ret) {
                btrfs_release_path(swarn->path);
                goto err;