summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-03 00:37:51 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-09 13:47:33 +0100
commit5cbedb02e1f50175e65610e39c6717fe2162a8ec (patch)
treeca30afd2610a40c7799d114aa9a67e1cc66057c2
parent29bfb8318bbe2bfb6c3c3faf1b7f79ed6fe534ea (diff)
btrfs-progs: check: use on-stack path buffer in delete_bad_item
We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--cmds-check.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 45ad20bb..21b15c8d 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -10507,7 +10507,7 @@ static int recow_extent_buffer(struct btrfs_root *root, struct extent_buffer *eb
static int delete_bad_item(struct btrfs_root *root, struct bad_item *bad)
{
- struct btrfs_path *path;
+ struct btrfs_path path;
struct btrfs_trans_handle *trans;
struct btrfs_key key;
int ret;
@@ -10525,26 +10525,21 @@ static int delete_bad_item(struct btrfs_root *root, struct bad_item *bad)
return PTR_ERR(root);
}
- path = btrfs_alloc_path();
- if (!path)
- return -ENOMEM;
-
trans = btrfs_start_transaction(root, 1);
- if (IS_ERR(trans)) {
- btrfs_free_path(path);
+ if (IS_ERR(trans))
return PTR_ERR(trans);
- }
- ret = btrfs_search_slot(trans, root, &bad->key, path, -1, 1);
+ btrfs_init_path(&path);
+ ret = btrfs_search_slot(trans, root, &bad->key, &path, -1, 1);
if (ret) {
if (ret > 0)
ret = 0;
goto out;
}
- ret = btrfs_del_item(trans, root, path);
+ ret = btrfs_del_item(trans, root, &path);
out:
btrfs_commit_transaction(trans, root);
- btrfs_free_path(path);
+ btrfs_release_path(&path);
return ret;
}