diff options
author | Kelley Nielsen <kelleynnn@gmail.com> | 2013-11-04 22:35:58 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-01-28 16:19:36 -0500 |
commit | 75ac2dd907013b44edbdec16f8969d14811149c9 (patch) | |
tree | 63c0ad18dbf6ff14cdfa90e6f396b8c393eb6207 /fs/btrfs/ctree.c | |
parent | e33d5c3d6d61518c7f115af6d11d3dffa230d31f (diff) |
btrfs: expand btrfs_find_item() to include find_root_ref functionality
This patch is the second step in bootstrapping the btrfs_find_item
interface. The btrfs_find_root_ref() is similar to the former
__inode_info(); it accepts four of its parameters, and duplicates the
first half of its functionality.
Replace the one former call to btrfs_find_root_ref() with a call to
btrfs_find_item(), along with the defined key type that was used
internally by btrfs_find_root ref, and a null found key. In
btrfs_find_item(), add a test for the null key at the place where
the functionality of btrfs_find_root_ref() ends; btrfs_find_item()
then returns if the test passes. Finally, remove btrfs_find_root_ref().
Signed-off-by: Kelley Nielsen <kelleynnn@gmail.com>
Suggested-by: Zach Brown <zab@redhat.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 141c15ca294e..64b87894460b 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -2464,7 +2464,13 @@ static int key_search(struct extent_buffer *b, struct btrfs_key *key, | |||
2464 | /* Proposed generic search function, meant to take the place of the | 2464 | /* Proposed generic search function, meant to take the place of the |
2465 | * various small search helper functions throughout the code and standardize | 2465 | * various small search helper functions throughout the code and standardize |
2466 | * the search interface. Right now, it only replaces the former __inode_info | 2466 | * the search interface. Right now, it only replaces the former __inode_info |
2467 | * in backref.c. | 2467 | * in backref.c, and the former btrfs_find_root_ref in root-tree.c. |
2468 | * | ||
2469 | * If a null key is passed, it returns immediately after running | ||
2470 | * btrfs_search_slot, leaving the path filled as it is and passing its | ||
2471 | * return value upward. If a real key is passed, it will set the caller's | ||
2472 | * path to point to the first item in the tree after its specified | ||
2473 | * objectid, type, and offset for which objectid and type match the input. | ||
2468 | */ | 2474 | */ |
2469 | int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path, | 2475 | int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path, |
2470 | u64 iobjectid, u64 ioff, u8 key_type, | 2476 | u64 iobjectid, u64 ioff, u8 key_type, |
@@ -2479,7 +2485,7 @@ int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path, | |||
2479 | key.offset = ioff; | 2485 | key.offset = ioff; |
2480 | 2486 | ||
2481 | ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0); | 2487 | ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0); |
2482 | if (ret < 0) | 2488 | if ((ret < 0) || (found_key == NULL)) |
2483 | return ret; | 2489 | return ret; |
2484 | 2490 | ||
2485 | eb = path->nodes[0]; | 2491 | eb = path->nodes[0]; |