Commit 68f32b9c authored by Leo Martins's avatar Leo Martins Committed by David Sterba

btrfs: BTRFS_PATH_AUTO_FREE in orphan.c

All cleanup paths lead to btrfs_path_free so path can be defined with
the automatic freeing callback in the following functions:

- btrfs_insert_orphan_item()
- btrfs_del_orphan_item()
Signed-off-by: default avatarLeo Martins <loemra.dev@gmail.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 45763a0c
...@@ -9,9 +9,8 @@ ...@@ -9,9 +9,8 @@
int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans, int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 offset) struct btrfs_root *root, u64 offset)
{ {
struct btrfs_path *path; BTRFS_PATH_AUTO_FREE(path);
struct btrfs_key key; struct btrfs_key key;
int ret = 0;
key.objectid = BTRFS_ORPHAN_OBJECTID; key.objectid = BTRFS_ORPHAN_OBJECTID;
key.type = BTRFS_ORPHAN_ITEM_KEY; key.type = BTRFS_ORPHAN_ITEM_KEY;
...@@ -21,16 +20,13 @@ int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans, ...@@ -21,16 +20,13 @@ int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
ret = btrfs_insert_empty_item(trans, root, path, &key, 0); return btrfs_insert_empty_item(trans, root, path, &key, 0);
btrfs_free_path(path);
return ret;
} }
int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 offset) struct btrfs_root *root, u64 offset)
{ {
struct btrfs_path *path; BTRFS_PATH_AUTO_FREE(path);
struct btrfs_key key; struct btrfs_key key;
int ret = 0; int ret = 0;
...@@ -44,15 +40,9 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, ...@@ -44,15 +40,9 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
ret = btrfs_search_slot(trans, root, &key, path, -1, 1); ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
if (ret < 0) if (ret < 0)
goto out; return ret;
if (ret) { /* JDM: Really? */ if (ret)
ret = -ENOENT; return -ENOENT;
goto out;
}
ret = btrfs_del_item(trans, root, path);
out: return btrfs_del_item(trans, root, path);
btrfs_free_path(path);
return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment