diff options
Diffstat (limited to 'fs/ext4')
| -rw-r--r-- | fs/ext4/block_validity.c | 2 | ||||
| -rw-r--r-- | fs/ext4/dir.c | 5 | ||||
| -rw-r--r-- | fs/ext4/extents-test.c | 4 | ||||
| -rw-r--r-- | fs/ext4/extents.c | 12 | ||||
| -rw-r--r-- | fs/ext4/fsmap.c | 2 | ||||
| -rw-r--r-- | fs/ext4/mballoc-test.c | 13 | ||||
| -rw-r--r-- | fs/ext4/mballoc.c | 11 | ||||
| -rw-r--r-- | fs/ext4/orphan.c | 3 | ||||
| -rw-r--r-- | fs/ext4/resize.c | 11 | ||||
| -rw-r--r-- | fs/ext4/super.c | 18 | ||||
| -rw-r--r-- | fs/ext4/sysfs.c | 2 | ||||
| -rw-r--r-- | fs/ext4/xattr.c | 18 |
12 files changed, 45 insertions, 56 deletions
diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c index e8c5525afc67..75179be4a488 100644 --- a/fs/ext4/block_validity.c +++ b/fs/ext4/block_validity.c @@ -217,7 +217,7 @@ int ext4_setup_system_zone(struct super_block *sb) ext4_group_t i; int ret; - system_blks = kzalloc(sizeof(*system_blks), GFP_KERNEL); + system_blks = kzalloc_obj(*system_blks, GFP_KERNEL); if (!system_blks) return -ENOMEM; diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index 00c4b3c82b65..b285ce18b183 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c @@ -480,8 +480,7 @@ int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, p = &info->root.rb_node; /* Create and allocate the fname structure */ - new_fn = kzalloc(struct_size(new_fn, name, ent_name->len + 1), - GFP_KERNEL); + new_fn = kzalloc_flex(*new_fn, name, ent_name->len + 1, GFP_KERNEL); if (!new_fn) return -ENOMEM; new_fn->hash = hash; @@ -673,7 +672,7 @@ static int ext4_dir_open(struct inode *inode, struct file *file) { struct dir_private_info *info; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc_obj(*info, GFP_KERNEL); if (!info) return -ENOMEM; file->private_data = info; diff --git a/fs/ext4/extents-test.c b/fs/ext4/extents-test.c index 4879e68e465d..913103089799 100644 --- a/fs/ext4/extents-test.c +++ b/fs/ext4/extents-test.c @@ -229,7 +229,7 @@ static int extents_kunit_init(struct kunit *test) sb->s_blocksize = 4096; sb->s_blocksize_bits = 12; - sbi = kzalloc(sizeof(struct ext4_sb_info), GFP_KERNEL); + sbi = kzalloc_obj(struct ext4_sb_info, GFP_KERNEL); if (sbi == NULL) return -ENOMEM; @@ -240,7 +240,7 @@ static int extents_kunit_init(struct kunit *test) sbi->s_extent_max_zeroout_kb = 32; /* setup the mock inode */ - k_ctx.k_ei = kzalloc(sizeof(struct ext4_inode_info), GFP_KERNEL); + k_ctx.k_ei = kzalloc_obj(struct ext4_inode_info, GFP_KERNEL); if (k_ctx.k_ei == NULL) return -ENOMEM; ei = k_ctx.k_ei; diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 3630b27e4fd7..ae3804f36535 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -621,8 +621,7 @@ int ext4_ext_precache(struct inode *inode) return ret; } - path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), - GFP_NOFS); + path = kzalloc_objs(struct ext4_ext_path, depth + 1, GFP_NOFS); if (path == NULL) { up_read(&ei->i_data_sem); return -ENOMEM; @@ -916,8 +915,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block, } if (!path) { /* account possible depth increase */ - path = kcalloc(depth + 2, sizeof(struct ext4_ext_path), - gfp_flags); + path = kzalloc_objs(struct ext4_ext_path, depth + 2, gfp_flags); if (unlikely(!path)) return ERR_PTR(-ENOMEM); path[0].p_maxdepth = depth + 1; @@ -1105,7 +1103,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, * We need this to handle errors and free blocks * upon them. */ - ablocks = kcalloc(depth, sizeof(ext4_fsblk_t), gfp_flags); + ablocks = kzalloc_objs(ext4_fsblk_t, depth, gfp_flags); if (!ablocks) return -ENOMEM; @@ -2947,8 +2945,8 @@ again: path[k].p_block = le16_to_cpu(path[k].p_hdr->eh_entries)+1; } else { - path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), - GFP_NOFS | __GFP_NOFAIL); + path = kzalloc_objs(struct ext4_ext_path, depth + 1, + GFP_NOFS | __GFP_NOFAIL); path[0].p_maxdepth = path[0].p_depth = depth; path[0].p_hdr = ext_inode_hdr(inode); i = 0; diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c index 22fc333244ef..8b1138d2dc8e 100644 --- a/fs/ext4/fsmap.c +++ b/fs/ext4/fsmap.c @@ -348,7 +348,7 @@ static inline int ext4_getfsmap_fill(struct list_head *meta_list, { struct ext4_fsmap *fsm; - fsm = kmalloc(sizeof(*fsm), GFP_NOFS); + fsm = kmalloc_obj(*fsm, GFP_NOFS); if (!fsm) return -ENOMEM; fsm->fmr_device = 0; diff --git a/fs/ext4/mballoc-test.c b/fs/ext4/mballoc-test.c index 4abb40d4561c..6b448aad6f63 100644 --- a/fs/ext4/mballoc-test.c +++ b/fs/ext4/mballoc-test.c @@ -34,7 +34,7 @@ static struct inode *mbt_alloc_inode(struct super_block *sb) { struct ext4_inode_info *ei; - ei = kmalloc(sizeof(struct ext4_inode_info), GFP_KERNEL); + ei = kmalloc_obj(struct ext4_inode_info, GFP_KERNEL); if (!ei) return NULL; @@ -73,11 +73,11 @@ static int mbt_mb_init(struct super_block *sb) int ret; /* needed by ext4_mb_init->bdev_nonrot(sb->s_bdev) */ - sb->s_bdev = kzalloc(sizeof(*sb->s_bdev), GFP_KERNEL); + sb->s_bdev = kzalloc_obj(*sb->s_bdev, GFP_KERNEL); if (sb->s_bdev == NULL) return -ENOMEM; - sb->s_bdev->bd_queue = kzalloc(sizeof(struct request_queue), GFP_KERNEL); + sb->s_bdev->bd_queue = kzalloc_obj(struct request_queue, GFP_KERNEL); if (sb->s_bdev->bd_queue == NULL) { kfree(sb->s_bdev); return -ENOMEM; @@ -137,7 +137,7 @@ static struct super_block *mbt_ext4_alloc_super_block(void) struct super_block *sb; struct ext4_sb_info *sbi; - fsb = kzalloc(sizeof(*fsb), GFP_KERNEL); + fsb = kzalloc_obj(*fsb, GFP_KERNEL); if (fsb == NULL) return NULL; @@ -148,7 +148,7 @@ static struct super_block *mbt_ext4_alloc_super_block(void) sbi = &fsb->sbi; sbi->s_blockgroup_lock = - kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); + kzalloc_obj(struct blockgroup_lock, GFP_KERNEL); if (!sbi->s_blockgroup_lock) goto out_deactivate; @@ -252,8 +252,7 @@ static int mbt_ctx_init(struct super_block *sb) struct mbt_ctx *ctx = MBT_CTX(sb); ext4_group_t i, ngroups = ext4_get_groups_count(sb); - ctx->grp_ctx = kcalloc(ngroups, sizeof(struct mbt_grp_ctx), - GFP_KERNEL); + ctx->grp_ctx = kzalloc_objs(struct mbt_grp_ctx, ngroups, GFP_KERNEL); if (ctx->grp_ctx == NULL) return -ENOMEM; diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index b99d1a7e580e..4d0bf2fcf2d3 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3754,8 +3754,7 @@ int ext4_mb_init(struct super_block *sb) } while (i < MB_NUM_ORDERS(sb)); sbi->s_mb_avg_fragment_size = - kmalloc_array(MB_NUM_ORDERS(sb), sizeof(struct xarray), - GFP_KERNEL); + kmalloc_objs(struct xarray, MB_NUM_ORDERS(sb), GFP_KERNEL); if (!sbi->s_mb_avg_fragment_size) { ret = -ENOMEM; goto out; @@ -3764,8 +3763,7 @@ int ext4_mb_init(struct super_block *sb) xa_init(&sbi->s_mb_avg_fragment_size[i]); sbi->s_mb_largest_free_orders = - kmalloc_array(MB_NUM_ORDERS(sb), sizeof(struct xarray), - GFP_KERNEL); + kmalloc_objs(struct xarray, MB_NUM_ORDERS(sb), GFP_KERNEL); if (!sbi->s_mb_largest_free_orders) { ret = -ENOMEM; goto out; @@ -3817,8 +3815,9 @@ int ext4_mb_init(struct super_block *sb) sbi->s_mb_nr_global_goals = umin(num_possible_cpus(), DIV_ROUND_UP(sbi->s_groups_count, 4)); - sbi->s_mb_last_groups = kcalloc(sbi->s_mb_nr_global_goals, - sizeof(ext4_group_t), GFP_KERNEL); + sbi->s_mb_last_groups = kzalloc_objs(ext4_group_t, + sbi->s_mb_nr_global_goals, + GFP_KERNEL); if (sbi->s_mb_last_groups == NULL) { ret = -ENOMEM; goto out; diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c index c9b93b670b0f..2dbaf3c01168 100644 --- a/fs/ext4/orphan.c +++ b/fs/ext4/orphan.c @@ -598,8 +598,7 @@ int ext4_init_orphan_info(struct super_block *sb) } oi->of_blocks = inode->i_size >> sb->s_blocksize_bits; oi->of_csum_seed = EXT4_I(inode)->i_csum_seed; - oi->of_binfo = kvmalloc_array(oi->of_blocks, - sizeof(struct ext4_orphan_block), + oi->of_binfo = kvmalloc_objs(struct ext4_orphan_block, oi->of_blocks, GFP_KERNEL); if (!oi->of_binfo) { ret = -ENOMEM; diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 76842f0957b5..780679645b6e 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -32,7 +32,7 @@ static void ext4_rcu_ptr_callback(struct rcu_head *head) void ext4_kvfree_array_rcu(void *to_free) { - struct ext4_rcu_ptr *ptr = kzalloc(sizeof(*ptr), GFP_KERNEL); + struct ext4_rcu_ptr *ptr = kzalloc_obj(*ptr, GFP_KERNEL); if (ptr) { ptr->ptr = to_free; @@ -242,7 +242,7 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned int flexbg_size, unsigned int max_resize_bg; struct ext4_new_flex_group_data *flex_gd; - flex_gd = kmalloc(sizeof(*flex_gd), GFP_NOFS); + flex_gd = kmalloc_obj(*flex_gd, GFP_NOFS); if (flex_gd == NULL) goto out3; @@ -260,9 +260,8 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned int flexbg_size, if (WARN_ON_ONCE(flex_gd->resize_bg > max_resize_bg)) flex_gd->resize_bg = max_resize_bg; - flex_gd->groups = kmalloc_array(flex_gd->resize_bg, - sizeof(struct ext4_new_group_data), - GFP_NOFS); + flex_gd->groups = kmalloc_objs(struct ext4_new_group_data, + flex_gd->resize_bg, GFP_NOFS); if (flex_gd->groups == NULL) goto out2; @@ -1031,7 +1030,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode, int res, i; int err; - primary = kmalloc_array(reserved_gdb, sizeof(*primary), GFP_NOFS); + primary = kmalloc_objs(*primary, reserved_gdb, GFP_NOFS); if (!primary) return -ENOMEM; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 504148b2142b..63784d9b1874 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2016,7 +2016,7 @@ int ext4_init_fs_context(struct fs_context *fc) { struct ext4_fs_context *ctx; - ctx = kzalloc(sizeof(struct ext4_fs_context), GFP_KERNEL); + ctx = kzalloc_obj(struct ext4_fs_context, GFP_KERNEL); if (!ctx) return -ENOMEM; @@ -2496,11 +2496,11 @@ static int parse_apply_sb_mount_options(struct super_block *sb, if (strscpy_pad(s_mount_opts, sbi->s_es->s_mount_opts) < 0) return -E2BIG; - fc = kzalloc(sizeof(struct fs_context), GFP_KERNEL); + fc = kzalloc_obj(struct fs_context, GFP_KERNEL); if (!fc) return -ENOMEM; - s_ctx = kzalloc(sizeof(struct ext4_fs_context), GFP_KERNEL); + s_ctx = kzalloc_obj(struct ext4_fs_context, GFP_KERNEL); if (!s_ctx) goto out_free; @@ -3962,7 +3962,7 @@ static int ext4_li_info_new(void) { struct ext4_lazy_init *eli = NULL; - eli = kzalloc(sizeof(*eli), GFP_KERNEL); + eli = kzalloc_obj(*eli, GFP_KERNEL); if (!eli) return -ENOMEM; @@ -3981,7 +3981,7 @@ static struct ext4_li_request *ext4_li_request_new(struct super_block *sb, { struct ext4_li_request *elr; - elr = kzalloc(sizeof(*elr), GFP_KERNEL); + elr = kzalloc_obj(*elr, GFP_KERNEL); if (!elr) return NULL; @@ -4328,7 +4328,7 @@ static struct ext4_sb_info *ext4_alloc_sbi(struct super_block *sb) { struct ext4_sb_info *sbi; - sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); + sbi = kzalloc_obj(*sbi, GFP_KERNEL); if (!sbi) return NULL; @@ -4336,7 +4336,7 @@ static struct ext4_sb_info *ext4_alloc_sbi(struct super_block *sb) NULL, NULL); sbi->s_blockgroup_lock = - kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); + kzalloc_obj(struct blockgroup_lock, GFP_KERNEL); if (!sbi->s_blockgroup_lock) goto err_out; @@ -4879,9 +4879,7 @@ static int ext4_group_desc_init(struct super_block *sb, } } rcu_assign_pointer(sbi->s_group_desc, - kvmalloc_array(db_count, - sizeof(struct buffer_head *), - GFP_KERNEL)); + kvmalloc_objs(struct buffer_head *, db_count, GFP_KERNEL)); if (sbi->s_group_desc == NULL) { ext4_msg(sb, KERN_ERR, "not enough memory"); return -ENOMEM; diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index d2ecc1026c0c..cdf78da85861 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -655,7 +655,7 @@ int __init ext4_init_sysfs(void) if (!ext4_root) return -ENOMEM; - ext4_feat = kzalloc(sizeof(*ext4_feat), GFP_KERNEL); + ext4_feat = kzalloc_obj(*ext4_feat, GFP_KERNEL); if (!ext4_feat) { ret = -ENOMEM; goto root_err; diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 4ed8ddf2a60b..7bf9ba19a89d 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -390,7 +390,7 @@ static int ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t size) int i, ret; if (bh_count > ARRAY_SIZE(bhs_inline)) { - bhs = kmalloc_array(bh_count, sizeof(*bhs), GFP_NOFS); + bhs = kmalloc_objs(*bhs, bh_count, GFP_NOFS); if (!bhs) return -ENOMEM; } @@ -2618,8 +2618,8 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode, int needs_kvfree = 0; int error; - is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS); - bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS); + is = kzalloc_obj(struct ext4_xattr_ibody_find, GFP_NOFS); + bs = kzalloc_obj(struct ext4_xattr_block_find, GFP_NOFS); b_entry_name = kmalloc(entry->e_name_len + 1, GFP_NOFS); if (!is || !bs || !b_entry_name) { error = -ENOMEM; @@ -2876,9 +2876,8 @@ ext4_expand_inode_array(struct ext4_xattr_inode_array **ea_inode_array, /* * Start with 15 inodes, so it fits into a power-of-two size. */ - (*ea_inode_array) = kmalloc( - struct_size(*ea_inode_array, inodes, EIA_MASK), - GFP_NOFS); + (*ea_inode_array) = kmalloc_flex(**ea_inode_array, inodes, + EIA_MASK, GFP_NOFS); if (*ea_inode_array == NULL) return -ENOMEM; (*ea_inode_array)->count = 0; @@ -2886,10 +2885,9 @@ ext4_expand_inode_array(struct ext4_xattr_inode_array **ea_inode_array, /* expand the array once all 15 + n * 16 slots are full */ struct ext4_xattr_inode_array *new_array = NULL; - new_array = kmalloc( - struct_size(*ea_inode_array, inodes, - (*ea_inode_array)->count + EIA_INCR), - GFP_NOFS); + new_array = kmalloc_flex(**ea_inode_array, inodes, + (*ea_inode_array)->count + EIA_INCR, + GFP_NOFS); if (new_array == NULL) return -ENOMEM; memcpy(new_array, *ea_inode_array, |
