Skip to content

Commit a1d1701

Browse files
loemrawkdave
authored andcommitted
btrfs: use btrfs_path auto free in zoned.c
All cleanup paths lead to btrfs_path_free so path can be defined with the automatic freeing callback in the following functions: - calculate_emulated_zone_size() - calculate_alloc_pointer() Signed-off-by: Leo Martins <loemra.dev@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 9b72abb commit a1d1701

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

fs/btrfs/zoned.c

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos,
287287
/* The emulated zone size is determined from the size of device extent */
288288
static int calculate_emulated_zone_size(struct btrfs_fs_info *fs_info)
289289
{
290-
struct btrfs_path *path;
290+
BTRFS_PATH_AUTO_FREE(path);
291291
struct btrfs_root *root = fs_info->dev_root;
292292
struct btrfs_key key;
293293
struct extent_buffer *leaf;
@@ -304,28 +304,21 @@ static int calculate_emulated_zone_size(struct btrfs_fs_info *fs_info)
304304

305305
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
306306
if (ret < 0)
307-
goto out;
307+
return ret;
308308

309309
if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {
310310
ret = btrfs_next_leaf(root, path);
311311
if (ret < 0)
312-
goto out;
312+
return ret;
313313
/* No dev extents at all? Not good */
314-
if (ret > 0) {
315-
ret = -EUCLEAN;
316-
goto out;
317-
}
314+
if (ret > 0)
315+
return -EUCLEAN;
318316
}
319317

320318
leaf = path->nodes[0];
321319
dext = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_extent);
322320
fs_info->zone_size = btrfs_dev_extent_length(leaf, dext);
323-
ret = 0;
324-
325-
out:
326-
btrfs_free_path(path);
327-
328-
return ret;
321+
return 0;
329322
}
330323

331324
int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info)
@@ -1211,7 +1204,7 @@ static int calculate_alloc_pointer(struct btrfs_block_group *cache,
12111204
{
12121205
struct btrfs_fs_info *fs_info = cache->fs_info;
12131206
struct btrfs_root *root;
1214-
struct btrfs_path *path;
1207+
BTRFS_PATH_AUTO_FREE(path);
12151208
struct btrfs_key key;
12161209
struct btrfs_key found_key;
12171210
int ret;
@@ -1246,15 +1239,15 @@ static int calculate_alloc_pointer(struct btrfs_block_group *cache,
12461239
if (!ret)
12471240
ret = -EUCLEAN;
12481241
if (ret < 0)
1249-
goto out;
1242+
return ret;
12501243

12511244
ret = btrfs_previous_extent_item(root, path, cache->start);
12521245
if (ret) {
12531246
if (ret == 1) {
12541247
ret = 0;
12551248
*offset_ret = 0;
12561249
}
1257-
goto out;
1250+
return ret;
12581251
}
12591252

12601253
btrfs_item_key_to_cpu(path->nodes[0], &found_key, path->slots[0]);
@@ -1266,15 +1259,10 @@ static int calculate_alloc_pointer(struct btrfs_block_group *cache,
12661259

12671260
if (!(found_key.objectid >= cache->start &&
12681261
found_key.objectid + length <= cache->start + cache->length)) {
1269-
ret = -EUCLEAN;
1270-
goto out;
1262+
return -EUCLEAN;
12711263
}
12721264
*offset_ret = found_key.objectid + length - cache->start;
1273-
ret = 0;
1274-
1275-
out:
1276-
btrfs_free_path(path);
1277-
return ret;
1265+
return 0;
12781266
}
12791267

12801268
struct zone_info {

0 commit comments

Comments
 (0)