31 unsigned long name_ptr;
36 leaf = path->
nodes[0];
37 item_size = btrfs_item_size_nr(leaf, path->
slots[0]);
39 while (cur_offset < item_size) {
41 len = btrfs_inode_ref_name_len(leaf, ref);
42 name_ptr = (
unsigned long)(ref + 1);
43 cur_offset += len +
sizeof(*ref);
55 const char *name,
int name_len,
61 unsigned long name_ptr;
66 leaf = path->
nodes[0];
67 item_size = btrfs_item_size_nr(leaf, path->
slots[0]);
76 while (cur_offset < item_size) {
78 name_ptr = (
unsigned long)(&extref->
name);
79 ref_name_len = btrfs_inode_extref_name_len(leaf, extref);
81 if (ref_name_len == name_len &&
82 btrfs_inode_extref_parent(leaf, extref) == ref_objectid &&
89 cur_offset += ref_name_len +
sizeof(*extref);
98 const char *name,
int name_len,
99 u64 inode_objectid,
u64 ref_objectid,
int ins_len,
106 key.objectid = inode_objectid;
108 key.offset = ref_objectid;
115 if (!find_name_in_backref(path, name, name_len, &ref))
125 const char *name,
int name_len,
126 u64 inode_objectid,
u64 ref_objectid,
int ins_len,
135 key.
offset = btrfs_extref_hash(ref_objectid, name, name_len);
150 const char *name,
int name_len,
151 u64 inode_objectid,
u64 ref_objectid,
int mod,
156 int ins_len = mod < 0 ? -1 : 0;
159 ref = btrfs_lookup_inode_ref(trans, root, path, name, name_len,
160 inode_objectid, ref_objectid, ins_len,
166 *ret_index = btrfs_inode_ref_index(path->
nodes[0], ref);
173 name_len, inode_objectid,
174 ref_objectid, ins_len, cow);
176 return PTR_ERR(extref);
179 *ret_index = btrfs_inode_extref_index(path->
nodes[0], extref);
188 const char *name,
int name_len,
196 int del_len = name_len +
sizeof(*extref);
198 unsigned long item_start;
203 key.
offset = btrfs_extref_hash(ref_objectid, name, name_len);
223 name, name_len, &extref)) {
229 leaf = path->
nodes[0];
230 item_size = btrfs_item_size_nr(leaf, path->
slots[0]);
232 *index = btrfs_inode_extref_index(leaf, extref);
234 if (del_len == item_size) {
239 ret = btrfs_del_item(trans, root, path);
243 ptr = (
unsigned long)extref;
247 item_size - (ptr + del_len - item_start));
259 const char *name,
int name_len,
267 unsigned long item_start;
271 int search_ext_refs = 0;
272 int del_len = name_len +
sizeof(*ref);
275 key.
offset = ref_objectid;
289 }
else if (ret < 0) {
292 if (!find_name_in_backref(path, name, name_len, &ref)) {
297 leaf = path->
nodes[0];
298 item_size = btrfs_item_size_nr(leaf, path->
slots[0]);
301 *index = btrfs_inode_ref_index(leaf, ref);
303 if (del_len == item_size) {
304 ret = btrfs_del_item(trans, root, path);
307 ptr = (
unsigned long)ref;
308 sub_item_len = name_len +
sizeof(*ref);
311 item_size - (ptr + sub_item_len - item_start));
316 if (search_ext_refs) {
323 inode_objectid, ref_objectid, index);
336 const char *name,
int name_len,
341 int ins_len = name_len +
sizeof(*extref);
348 key.objectid = inode_objectid;
350 key.offset = btrfs_extref_hash(ref_objectid, name, name_len);
357 ret = btrfs_insert_empty_item(trans, root, path, &
key,
361 name, name_len,
NULL))
370 leaf = path->
nodes[0];
371 item = btrfs_item_nr(leaf, path->
slots[0]);
373 ptr += btrfs_item_size(leaf, item) - ins_len;
376 btrfs_set_inode_extref_name_len(path->
nodes[0], extref, name_len);
377 btrfs_set_inode_extref_index(path->
nodes[0], extref, index);
378 btrfs_set_inode_extref_parent(path->
nodes[0], extref, ref_objectid);
380 ptr = (
unsigned long)&extref->name;
392 const char *name,
int name_len,
393 u64 inode_objectid,
u64 ref_objectid,
u64 index)
400 int ins_len = name_len +
sizeof(*ref);
403 key.
offset = ref_objectid;
411 ret = btrfs_insert_empty_item(trans, root, path, &key,
416 if (find_name_in_backref(path, name, name_len, &ref))
419 old_size = btrfs_item_size_nr(path->
nodes[0], path->
slots[0]);
424 btrfs_set_inode_ref_name_len(path->
nodes[0], ref, name_len);
425 btrfs_set_inode_ref_index(path->
nodes[0], ref, index);
426 ptr = (
unsigned long)(ref + 1);
428 }
else if (ret < 0) {
435 btrfs_set_inode_ref_name_len(path->
nodes[0], ref, name_len);
436 btrfs_set_inode_ref_index(path->
nodes[0], ref, index);
437 ptr = (
unsigned long)(ref + 1);
449 if (btrfs_super_incompat_flags(disk_super)
451 ret = btrfs_insert_inode_extref(trans, root, name,
454 ref_objectid, index);
470 ret = btrfs_insert_empty_item(trans, root, path, &key,
479 int ins_len = mod < 0 ? -1 : 0;
489 slot = path->
slots[0] - 1;
490 leaf = path->
nodes[0];
491 btrfs_item_key_to_cpu(leaf, &found_key, slot);
493 btrfs_key_type(&found_key) == btrfs_key_type(location)) {