diff options
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 64b87894460b..22629809c9c4 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -2461,32 +2461,32 @@ static int key_search(struct extent_buffer *b, struct btrfs_key *key, | |||
2461 | return 0; | 2461 | return 0; |
2462 | } | 2462 | } |
2463 | 2463 | ||
2464 | /* Proposed generic search function, meant to take the place of the | 2464 | int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *found_path, |
2465 | * various small search helper functions throughout the code and standardize | ||
2466 | * the search interface. Right now, it only replaces the former __inode_info | ||
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. | ||
2474 | */ | ||
2475 | int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path, | ||
2476 | u64 iobjectid, u64 ioff, u8 key_type, | 2465 | u64 iobjectid, u64 ioff, u8 key_type, |
2477 | struct btrfs_key *found_key) | 2466 | struct btrfs_key *found_key) |
2478 | { | 2467 | { |
2479 | int ret; | 2468 | int ret; |
2480 | struct btrfs_key key; | 2469 | struct btrfs_key key; |
2481 | struct extent_buffer *eb; | 2470 | struct extent_buffer *eb; |
2471 | struct btrfs_path *path; | ||
2482 | 2472 | ||
2483 | key.type = key_type; | 2473 | key.type = key_type; |
2484 | key.objectid = iobjectid; | 2474 | key.objectid = iobjectid; |
2485 | key.offset = ioff; | 2475 | key.offset = ioff; |
2486 | 2476 | ||
2477 | if (found_path == NULL) { | ||
2478 | path = btrfs_alloc_path(); | ||
2479 | if (!path) | ||
2480 | return -ENOMEM; | ||
2481 | } else | ||
2482 | path = found_path; | ||
2483 | |||
2487 | ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0); | 2484 | ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0); |
2488 | if ((ret < 0) || (found_key == NULL)) | 2485 | if ((ret < 0) || (found_key == NULL)) { |
2486 | if (path != found_path) | ||
2487 | btrfs_free_path(path); | ||
2489 | return ret; | 2488 | return ret; |
2489 | } | ||
2490 | 2490 | ||
2491 | eb = path->nodes[0]; | 2491 | eb = path->nodes[0]; |
2492 | if (ret && path->slots[0] >= btrfs_header_nritems(eb)) { | 2492 | if (ret && path->slots[0] >= btrfs_header_nritems(eb)) { |