diff options
author | David Sterba <dsterba@suse.com> | 2016-11-03 00:37:51 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-11-09 13:47:34 +0100 |
commit | 8c4e5fbe899959df905ad8f22618582f2244e0b6 (patch) | |
tree | 8d7cab2ae75d866c5ce35784cbcbd818772819e9 | |
parent | ac2a08956040e028f860c727a2627ba5eeafa807 (diff) |
btrfs-progs: btrfstune: use on-stack path buffer in change_devices_uuid
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-- | btrfstune.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/btrfstune.c b/btrfstune.c index 0a22b98c..e8e3d00a 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -200,28 +200,26 @@ static int change_device_uuid(struct btrfs_root *root, struct extent_buffer *eb, static int change_devices_uuid(struct btrfs_fs_info *fs_info) { struct btrfs_root *root = fs_info->chunk_root; - struct btrfs_path *path; + struct btrfs_path path; struct btrfs_key key = {0, 0, 0}; int ret = 0; - path = btrfs_alloc_path(); - if (!path) - return -ENOMEM; + btrfs_init_path(&path); /* No transaction again */ - ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); + ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) goto out; while (1) { - btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); + btrfs_item_key_to_cpu(path.nodes[0], &key, path.slots[0]); if (key.type != BTRFS_DEV_ITEM_KEY || key.objectid != BTRFS_DEV_ITEMS_OBJECTID) goto next; - ret = change_device_uuid(root, path->nodes[0], path->slots[0]); + ret = change_device_uuid(root, path.nodes[0], path.slots[0]); if (ret < 0) goto out; next: - ret = btrfs_next_item(root, path); + ret = btrfs_next_item(root, &path); if (ret < 0) goto out; if (ret > 0) { @@ -230,7 +228,7 @@ next: } } out: - btrfs_free_path(path); + btrfs_release_path(&path); return ret; } |