btrfs-progs: use standard allocation functions in non-kenrel code
authorDavid Sterba <dsterba@suse.com>
Wed, 7 Sep 2016 14:22:33 +0000 (16:22 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Oct 2016 09:33:15 +0000 (11:33 +0200)
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-convert.c
btrfs-corrupt-block.c
btrfs-map-logical.c
chunk-recover.c
cmds-check.c
cmds-filesystem.c
cmds-restore.c
utils.c

index 6a7ea5c..ef9ba90 100644 (file)
@@ -2598,7 +2598,7 @@ static int may_rollback(struct btrfs_root *root)
 
                num_stripes = multi->num_stripes;
                physical = multi->stripes[0].physical;
-               kfree(multi);
+               free(multi);
 
                if (num_stripes != 1) {
                        error("num stripes for bytenr %llu is not 1", bytenr);
index 5e4ae72..629d5a8 100644 (file)
@@ -65,7 +65,7 @@ static int debug_corrupt_block(struct extent_buffer *eb,
                        "mirror %d logical %llu physical %llu device %s\n",
                        mirror_num, (unsigned long long)bytenr,
                        (unsigned long long)eb->dev_bytenr, device->name);
-               kfree(multi);
+               free(multi);
 
                if (!copy || mirror_num == copy) {
                        ret = read_extent_from_disk(eb, 0, eb->len);
index f3be1ea..e49a735 100644 (file)
@@ -125,7 +125,7 @@ static int __print_mapping_info(struct btrfs_fs_info *fs_info, u64 logical,
                                multi->stripes[0].physical,
                                device->name);
                }
-               kfree(multi);
+               free(multi);
                multi = NULL;
                cur_offset += cur_len;
        }
index f1f9849..107ce06 100644 (file)
@@ -968,7 +968,7 @@ static int build_device_map_by_chunk_record(struct btrfs_root *root,
                map->stripes[i].dev = btrfs_find_device(root, devid,
                                                        uuid, NULL);
                if (!map->stripes[i].dev) {
-                       kfree(map);
+                       free(map);
                        return -EIO;
                }
        }
index aff3c03..e786491 100644 (file)
@@ -3210,7 +3210,7 @@ static void free_root_record(struct cache_extent *cache)
                free(backref);
        }
 
-       kfree(rec);
+       free(rec);
 }
 
 FREE_EXTENT_CACHE_BASED_TREE(root_recs, free_root_record);
@@ -5474,7 +5474,7 @@ static int check_cache_range(struct btrfs_root *root,
                                continue;
                        if (logical[nr] == offset) {
                                if (stripe_len >= bytes) {
-                                       kfree(logical);
+                                       free(logical);
                                        return 0;
                                }
                                bytes -= stripe_len;
@@ -5482,7 +5482,7 @@ static int check_cache_range(struct btrfs_root *root,
                        } else if (logical[nr] < offset) {
                                if (logical[nr] + stripe_len >=
                                    offset + bytes) {
-                                       kfree(logical);
+                                       free(logical);
                                        return 0;
                                }
                                bytes = (offset + bytes) -
@@ -5505,7 +5505,7 @@ static int check_cache_range(struct btrfs_root *root,
                                                        offset,
                                                        logical[nr] - offset);
                                if (ret) {
-                                       kfree(logical);
+                                       free(logical);
                                        return ret;
                                }
 
@@ -5516,7 +5516,7 @@ static int check_cache_range(struct btrfs_root *root,
                        }
                }
 
-               kfree(logical);
+               free(logical);
        }
 
        entry = btrfs_find_free_space(cache->free_space_ctl, offset, bytes);
index 90eccf7..26b70e1 100644 (file)
@@ -495,7 +495,7 @@ static int btrfs_scan_kernel(void *search, unsigned unit_mode)
                if ((fd != -1) && !get_df(fd, &space_info_arg)) {
                        print_one_fs(&fs_info_arg, dev_info_arg,
                                     space_info_arg, label, unit_mode);
-                       kfree(space_info_arg);
+                       free(space_info_arg);
                        memset(label, 0, sizeof(label));
                        found = 1;
                }
index b491f08..455c060 100644 (file)
@@ -356,7 +356,7 @@ again:
        dev_fd = device->fd;
        device->total_ios++;
        dev_bytenr = multi->stripes[0].physical;
-       kfree(multi);
+       free(multi);
 
        if (size_left < length)
                length = size_left;
diff --git a/utils.c b/utils.c
index 9942f33..f64f3fd 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -1621,12 +1621,12 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
 
        device_total_bytes = (device_total_bytes / sectorsize) * sectorsize;
 
-       device = kzalloc(sizeof(*device), GFP_NOFS);
+       device = calloc(1, sizeof(*device));
        if (!device) {
                ret = -ENOMEM;
                goto out;
        }
-       buf = kzalloc(sectorsize, GFP_NOFS);
+       buf = calloc(1, sectorsize);
        if (!buf) {
                ret = -ENOMEM;
                goto out;
@@ -1679,14 +1679,14 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
        ret = pwrite(fd, buf, sectorsize, BTRFS_SUPER_INFO_OFFSET);
        BUG_ON(ret != sectorsize);
 
-       kfree(buf);
+       free(buf);
        list_add(&device->dev_list, &root->fs_info->fs_devices->devices);
        device->fs_devices = root->fs_info->fs_devices;
        return 0;
 
 out:
-       kfree(device);
-       kfree(buf);
+       free(device);
+       free(buf);
        return ret;
 }