summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/root-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-02 11:20:42 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-02 11:20:42 -0400
commit5caf2a002901f0fde475371c4bf1c553b51884af (patch)
tree1c262f723307fe924ea4e960761354f194f3843e /fs/btrfs/root-tree.c
parent2c90e5d658424bc71b111eb5a972240d5d06fe86 (diff)
downloadlinux-5caf2a002901f0fde475371c4bf1c553b51884af.tar.bz2
Btrfs: dynamic allocation of path struct
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/root-tree.c')
-rw-r--r--fs/btrfs/root-tree.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index f37dab87de16..ddc1c13a5352 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -6,7 +6,7 @@
int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
struct btrfs_root_item *item, struct btrfs_key *key)
{
- struct btrfs_path path;
+ struct btrfs_path *path;
struct btrfs_key search_key;
struct btrfs_leaf *l;
int ret;
@@ -16,14 +16,16 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
search_key.flags = (u32)-1;
search_key.offset = (u32)-1;
- btrfs_init_path(&path);
- ret = btrfs_search_slot(NULL, root, &search_key, &path, 0, 0);
+ path = btrfs_alloc_path();
+ BUG_ON(!path);
+ btrfs_init_path(path);
+ ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
if (ret < 0)
goto out;
BUG_ON(ret == 0);
- l = btrfs_buffer_leaf(path.nodes[0]);
- BUG_ON(path.slots[0] == 0);
- slot = path.slots[0] - 1;
+ l = btrfs_buffer_leaf(path->nodes[0]);
+ BUG_ON(path->slots[0] == 0);
+ slot = path->slots[0] - 1;
if (btrfs_disk_key_objectid(&l->items[slot].key) != objectid) {
ret = 1;
goto out;
@@ -31,9 +33,10 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
memcpy(item, btrfs_item_ptr(l, slot, struct btrfs_root_item),
sizeof(*item));
btrfs_disk_key_to_cpu(key, &l->items[slot].key);
- btrfs_release_path(root, &path);
ret = 0;
out:
+ btrfs_release_path(root, path);
+ btrfs_free_path(path);
return ret;
}
@@ -41,24 +44,27 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct btrfs_key *key, struct btrfs_root_item
*item)
{
- struct btrfs_path path;
+ struct btrfs_path *path;
struct btrfs_leaf *l;
int ret;
int slot;
struct btrfs_root_item *update_item;
- btrfs_init_path(&path);
- ret = btrfs_search_slot(trans, root, key, &path, 0, 1);
+ path = btrfs_alloc_path();
+ BUG_ON(!path);
+ btrfs_init_path(path);
+ ret = btrfs_search_slot(trans, root, key, path, 0, 1);
if (ret < 0)
goto out;
BUG_ON(ret != 0);
- l = btrfs_buffer_leaf(path.nodes[0]);
- slot = path.slots[0];
+ l = btrfs_buffer_leaf(path->nodes[0]);
+ slot = path->slots[0];
update_item = btrfs_item_ptr(l, slot, struct btrfs_root_item);
btrfs_memcpy(root, l, update_item, item, sizeof(*item));
- btrfs_mark_buffer_dirty(path.nodes[0]);
+ btrfs_mark_buffer_dirty(path->nodes[0]);
out:
- btrfs_release_path(root, &path);
+ btrfs_release_path(root, path);
+ btrfs_free_path(path);
return ret;
}
@@ -75,16 +81,19 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct btrfs_key *key)
{
- struct btrfs_path path;
+ struct btrfs_path *path;
int ret;
- btrfs_init_path(&path);
- ret = btrfs_search_slot(trans, root, key, &path, -1, 1);
+ path = btrfs_alloc_path();
+ BUG_ON(!path);
+ btrfs_init_path(path);
+ ret = btrfs_search_slot(trans, root, key, path, -1, 1);
if (ret < 0)
goto out;
BUG_ON(ret != 0);
- ret = btrfs_del_item(trans, root, &path);
+ ret = btrfs_del_item(trans, root, path);
out:
- btrfs_release_path(root, &path);
+ btrfs_release_path(root, path);
+ btrfs_free_path(path);
return ret;
}