aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dir-item.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/dir-item.c')
-rw-r--r--fs/btrfs/dir-item.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index f55c89472ac0..baceb1da609f 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -9,7 +9,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
9 objectid, u8 type) 9 objectid, u8 type)
10{ 10{
11 int ret = 0; 11 int ret = 0;
12 struct btrfs_path path; 12 struct btrfs_path *path;
13 struct btrfs_dir_item *dir_item; 13 struct btrfs_dir_item *dir_item;
14 char *name_ptr; 14 char *name_ptr;
15 struct btrfs_key key; 15 struct btrfs_key key;
@@ -20,24 +20,26 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
20 btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); 20 btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY);
21 ret = btrfs_name_hash(name, name_len, &key.offset); 21 ret = btrfs_name_hash(name, name_len, &key.offset);
22 BUG_ON(ret); 22 BUG_ON(ret);
23 btrfs_init_path(&path); 23 path = btrfs_alloc_path();
24 btrfs_init_path(path);
24 data_size = sizeof(*dir_item) + name_len; 25 data_size = sizeof(*dir_item) + name_len;
25 ret = btrfs_insert_empty_item(trans, root, &path, &key, data_size); 26 ret = btrfs_insert_empty_item(trans, root, path, &key, data_size);
26 if (ret) 27 if (ret)
27 goto out; 28 goto out;
28 29
29 dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path.nodes[0]), 30 dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
30 path.slots[0], 31 path->slots[0],
31 struct btrfs_dir_item); 32 struct btrfs_dir_item);
32 btrfs_set_dir_objectid(dir_item, objectid); 33 btrfs_set_dir_objectid(dir_item, objectid);
33 btrfs_set_dir_type(dir_item, type); 34 btrfs_set_dir_type(dir_item, type);
34 btrfs_set_dir_flags(dir_item, 0); 35 btrfs_set_dir_flags(dir_item, 0);
35 btrfs_set_dir_name_len(dir_item, name_len); 36 btrfs_set_dir_name_len(dir_item, name_len);
36 name_ptr = (char *)(dir_item + 1); 37 name_ptr = (char *)(dir_item + 1);
37 btrfs_memcpy(root, path.nodes[0]->b_data, name_ptr, name, name_len); 38 btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len);
38 btrfs_mark_buffer_dirty(path.nodes[0]); 39 btrfs_mark_buffer_dirty(path->nodes[0]);
39out: 40out:
40 btrfs_release_path(root, &path); 41 btrfs_release_path(root, path);
42 btrfs_free_path(path);
41 return ret; 43 return ret;
42} 44}
43 45