aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-01-02 13:36:14 -0500
committerDavid Sterba <dsterba@suse.cz>2015-01-14 13:23:48 -0500
commit1d4c08e0a60be356134d0c466744d0d4e16ebab0 (patch)
tree99e3394eaf7542f187b1d70f7ec6d89b7d28fe1f /fs
parent9c4f61f01d269815bb7c37be3ede59c5587747c6 (diff)
btrfs: expand btrfs_find_item if found_key is NULL
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.c3
-rw-r--r--fs/btrfs/disk-io.c8
-rw-r--r--fs/btrfs/inode.c10
-rw-r--r--fs/btrfs/scrub.c8
4 files changed, 21 insertions, 8 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index f54511dd287e..20d1f2b0403d 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2618,13 +2618,14 @@ int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path,
2618 struct extent_buffer *eb; 2618 struct extent_buffer *eb;
2619 2619
2620 ASSERT(path); 2620 ASSERT(path);
2621 ASSERT(found_key);
2621 2622
2622 key.type = key_type; 2623 key.type = key_type;
2623 key.objectid = iobjectid; 2624 key.objectid = iobjectid;
2624 key.offset = ioff; 2625 key.offset = ioff;
2625 2626
2626 ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0); 2627 ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0);
2627 if ((ret < 0) || (found_key == NULL)) 2628 if (ret < 0)
2628 return ret; 2629 return ret;
2629 2630
2630 eb = path->nodes[0]; 2631 eb = path->nodes[0];
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6182e5493d0f..8d486603e8a3 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1631,6 +1631,7 @@ struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
1631{ 1631{
1632 struct btrfs_root *root; 1632 struct btrfs_root *root;
1633 struct btrfs_path *path; 1633 struct btrfs_path *path;
1634 struct btrfs_key key;
1634 int ret; 1635 int ret;
1635 1636
1636 if (location->objectid == BTRFS_ROOT_TREE_OBJECTID) 1637 if (location->objectid == BTRFS_ROOT_TREE_OBJECTID)
@@ -1675,8 +1676,11 @@ again:
1675 ret = -ENOMEM; 1676 ret = -ENOMEM;
1676 goto fail; 1677 goto fail;
1677 } 1678 }
1678 ret = btrfs_find_item(fs_info->tree_root, path, BTRFS_ORPHAN_OBJECTID, 1679 key.objectid = BTRFS_ORPHAN_OBJECTID;
1679 location->objectid, BTRFS_ORPHAN_ITEM_KEY, NULL); 1680 key.type = BTRFS_ORPHAN_ITEM_KEY;
1681 key.offset = location->objectid;
1682
1683 ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
1680 btrfs_free_path(path); 1684 btrfs_free_path(path);
1681 if (ret < 0) 1685 if (ret < 0)
1682 goto fail; 1686 goto fail;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8bf326affb94..370f23416080 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5009,6 +5009,7 @@ static int fixup_tree_root_location(struct btrfs_root *root,
5009 struct btrfs_root *new_root; 5009 struct btrfs_root *new_root;
5010 struct btrfs_root_ref *ref; 5010 struct btrfs_root_ref *ref;
5011 struct extent_buffer *leaf; 5011 struct extent_buffer *leaf;
5012 struct btrfs_key key;
5012 int ret; 5013 int ret;
5013 int err = 0; 5014 int err = 0;
5014 5015
@@ -5019,9 +5020,12 @@ static int fixup_tree_root_location(struct btrfs_root *root,
5019 } 5020 }
5020 5021
5021 err = -ENOENT; 5022 err = -ENOENT;
5022 ret = btrfs_find_item(root->fs_info->tree_root, path, 5023 key.objectid = BTRFS_I(dir)->root->root_key.objectid;
5023 BTRFS_I(dir)->root->root_key.objectid, 5024 key.type = BTRFS_ROOT_REF_KEY;
5024 location->objectid, BTRFS_ROOT_REF_KEY, NULL); 5025 key.offset = location->objectid;
5026
5027 ret = btrfs_search_slot(NULL, root->fs_info->tree_root, &key, path,
5028 0, 0);
5025 if (ret) { 5029 if (ret) {
5026 if (ret < 0) 5030 if (ret < 0)
5027 err = ret; 5031 err = ret;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 4846f66391a4..53575a45f7d1 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -520,6 +520,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
520 struct inode_fs_paths *ipath = NULL; 520 struct inode_fs_paths *ipath = NULL;
521 struct btrfs_root *local_root; 521 struct btrfs_root *local_root;
522 struct btrfs_key root_key; 522 struct btrfs_key root_key;
523 struct btrfs_key key;
523 524
524 root_key.objectid = root; 525 root_key.objectid = root;
525 root_key.type = BTRFS_ROOT_ITEM_KEY; 526 root_key.type = BTRFS_ROOT_ITEM_KEY;
@@ -533,8 +534,11 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
533 /* 534 /*
534 * this makes the path point to (inum INODE_ITEM ioff) 535 * this makes the path point to (inum INODE_ITEM ioff)
535 */ 536 */
536 ret = btrfs_find_item(local_root, swarn->path, inum, 0, 537 key.objectid = inum;
537 BTRFS_INODE_ITEM_KEY, NULL); 538 key.type = BTRFS_INODE_ITEM_KEY;
539 key.offset = 0;
540
541 ret = btrfs_search_slot(NULL, local_root, &key, swarn->path, 0, 0);
538 if (ret) { 542 if (ret) {
539 btrfs_release_path(swarn->path); 543 btrfs_release_path(swarn->path);
540 goto err; 544 goto err;