diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-04-02 11:20:42 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-04-02 11:20:42 -0400 |
commit | 5caf2a002901f0fde475371c4bf1c553b51884af (patch) | |
tree | 1c262f723307fe924ea4e960761354f194f3843e /fs/btrfs/dir-item.c | |
parent | 2c90e5d658424bc71b111eb5a972240d5d06fe86 (diff) |
Btrfs: dynamic allocation of path struct
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/dir-item.c')
-rw-r--r-- | fs/btrfs/dir-item.c | 18 |
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]); |
39 | out: | 40 | out: |
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 | ||