summaryrefslogtreecommitdiff
path: root/qgroup-verify.c
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
commit64e9dbf550026ca1c2a001c67beb490016113e84 (patch)
tree22ac8987e02a644ad8f53af31a3d12ebf91c43a7 /qgroup-verify.c
parentb059f926b80f9c5c085b069603a91aa7e3326ee0 (diff)
btrfs-progs: qgroup: use on-stack path buffer in repair_qgroup_status
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>
Diffstat (limited to 'qgroup-verify.c')
-rw-r--r--qgroup-verify.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/qgroup-verify.c b/qgroup-verify.c
index f5760dec..aa575fb6 100644
--- a/qgroup-verify.c
+++ b/qgroup-verify.c
@@ -1534,26 +1534,21 @@ static int repair_qgroup_status(struct btrfs_fs_info *info)
int ret;
struct btrfs_root *root = info->quota_root;
struct btrfs_trans_handle *trans;
- struct btrfs_path *path;
+ struct btrfs_path path;
struct btrfs_key key;
struct btrfs_qgroup_status_item *status_item;
printf("Repair qgroup status item\n");
- 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);
- }
+ btrfs_init_path(&path);
key.objectid = 0;
key.type = BTRFS_QGROUP_STATUS_KEY;
key.offset = 0;
- ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
+ ret = btrfs_search_slot(trans, root, &key, &path, 0, 1);
if (ret) {
error("Could not find qgroup status item\n");
if (ret > 0)
@@ -1561,19 +1556,19 @@ static int repair_qgroup_status(struct btrfs_fs_info *info)
goto out;
}
- status_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
+ status_item = btrfs_item_ptr(path.nodes[0], path.slots[0],
struct btrfs_qgroup_status_item);
- btrfs_set_qgroup_status_flags(path->nodes[0], status_item,
+ btrfs_set_qgroup_status_flags(path.nodes[0], status_item,
BTRFS_QGROUP_STATUS_FLAG_ON);
- btrfs_set_qgroup_status_rescan(path->nodes[0], status_item, 0);
- btrfs_set_qgroup_status_generation(path->nodes[0], status_item,
+ btrfs_set_qgroup_status_rescan(path.nodes[0], status_item, 0);
+ btrfs_set_qgroup_status_generation(path.nodes[0], status_item,
trans->transid);
- btrfs_mark_buffer_dirty(path->nodes[0]);
+ btrfs_mark_buffer_dirty(path.nodes[0]);
out:
btrfs_commit_transaction(trans, root);
- btrfs_free_path(path);
+ btrfs_release_path(&path);
return ret;
}