diff options
Diffstat (limited to 'fs/btrfs/inode-item.c')
-rw-r--r-- | fs/btrfs/inode-item.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c index 72ce3c173d6a..64f1150bb48d 100644 --- a/fs/btrfs/inode-item.c +++ b/fs/btrfs/inode-item.c | |||
@@ -49,6 +49,33 @@ static int find_name_in_backref(struct btrfs_path *path, const char *name, | |||
49 | return 0; | 49 | return 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | struct btrfs_inode_ref * | ||
53 | btrfs_lookup_inode_ref(struct btrfs_trans_handle *trans, | ||
54 | struct btrfs_root *root, | ||
55 | struct btrfs_path *path, | ||
56 | const char *name, int name_len, | ||
57 | u64 inode_objectid, u64 ref_objectid, int mod) | ||
58 | { | ||
59 | struct btrfs_key key; | ||
60 | struct btrfs_inode_ref *ref; | ||
61 | int ins_len = mod < 0 ? -1 : 0; | ||
62 | int cow = mod != 0; | ||
63 | int ret; | ||
64 | |||
65 | key.objectid = inode_objectid; | ||
66 | key.type = BTRFS_INODE_REF_KEY; | ||
67 | key.offset = ref_objectid; | ||
68 | |||
69 | ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); | ||
70 | if (ret < 0) | ||
71 | return ERR_PTR(ret); | ||
72 | if (ret > 0) | ||
73 | return NULL; | ||
74 | if (!find_name_in_backref(path, name, name_len, &ref)) | ||
75 | return NULL; | ||
76 | return ref; | ||
77 | } | ||
78 | |||
52 | int btrfs_del_inode_ref(struct btrfs_trans_handle *trans, | 79 | int btrfs_del_inode_ref(struct btrfs_trans_handle *trans, |
53 | struct btrfs_root *root, | 80 | struct btrfs_root *root, |
54 | const char *name, int name_len, | 81 | const char *name, int name_len, |