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:32 +0100
commitf2f7da66c5ad657052c8b0f5d02ba11a900c32a2 (patch)
treeaaa9481d9645efc298d66e84a4e45a3bf930854e
parent919f914483f95721f3c7a9046af1f1530cc498b9 (diff)
btrfs-progs: check: use on-stack path buffer in delete_duplicate_records
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.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 21bdaa13..62bcca0b 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -7267,17 +7267,13 @@ static int delete_duplicate_records(struct btrfs_root *root,
{
struct btrfs_trans_handle *trans;
LIST_HEAD(delete_list);
- struct btrfs_path *path;
+ struct btrfs_path path;
struct extent_record *tmp, *good, *n;
int nr_del = 0;
int ret = 0, err;
struct btrfs_key key;
- path = btrfs_alloc_path();
- if (!path) {
- ret = -ENOMEM;
- goto out;
- }
+ btrfs_init_path(&path);
good = rec;
/* Find the record that covers all of the duplicates. */
@@ -7329,16 +7325,16 @@ static int delete_duplicate_records(struct btrfs_root *root,
abort();
}
- ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
+ ret = btrfs_search_slot(trans, root, &key, &path, -1, 1);
if (ret) {
if (ret > 0)
ret = -EINVAL;
break;
}
- ret = btrfs_del_item(trans, root, path);
+ ret = btrfs_del_item(trans, root, &path);
if (ret)
break;
- btrfs_release_path(path);
+ btrfs_release_path(&path);
nr_del++;
}
err = btrfs_commit_transaction(trans, root);
@@ -7359,7 +7355,7 @@ out:
free(tmp);
}
- btrfs_free_path(path);
+ btrfs_release_path(&path);
if (!ret && !nr_del)
rec->num_duplicates = 0;