diff options
Diffstat (limited to 'fs/ocfs2')
31 files changed, 73 insertions, 79 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index b7db177d17d6..ce8ce1470981 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -686,7 +686,7 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, BUG_ON(le16_to_cpu(root_el->l_tree_depth) >= OCFS2_MAX_PATH_DEPTH); - path = kzalloc(sizeof(*path), GFP_NOFS); + path = kzalloc_obj(*path, GFP_NOFS); if (path) { path->p_tree_depth = le16_to_cpu(root_el->l_tree_depth); get_bh(root_bh); @@ -1202,8 +1202,7 @@ static int ocfs2_add_branch(handle_t *handle, } /* allocate the number of new eb blocks we need */ - new_eb_bhs = kcalloc(new_blocks, sizeof(struct buffer_head *), - GFP_KERNEL); + new_eb_bhs = kzalloc_objs(struct buffer_head *, new_blocks, GFP_KERNEL); if (!new_eb_bhs) { status = -ENOMEM; mlog_errno(status); @@ -6493,7 +6492,7 @@ int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, int ret = 0; struct ocfs2_cached_block_free *item; - item = kzalloc(sizeof(*item), GFP_NOFS); + item = kzalloc_obj(*item, GFP_NOFS); if (item == NULL) { ret = -ENOMEM; mlog_errno(ret); @@ -6619,7 +6618,7 @@ ocfs2_find_per_slot_free_list(int type, fl = fl->f_next_suballocator; } - fl = kmalloc(sizeof(*fl), GFP_NOFS); + fl = kmalloc_obj(*fl, GFP_NOFS); if (fl) { fl->f_inode_type = type; fl->f_slot = slot; @@ -6794,7 +6793,7 @@ int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, goto out; } - item = kzalloc(sizeof(*item), GFP_NOFS); + item = kzalloc_obj(*item, GFP_NOFS); if (item == NULL) { ret = -ENOMEM; mlog_errno(ret); @@ -6984,8 +6983,8 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, if (range_start >= range_end) return 0; - folios = kcalloc(ocfs2_pages_per_cluster(sb), - sizeof(struct folio *), GFP_NOFS); + folios = kzalloc_objs(struct folio *, ocfs2_pages_per_cluster(sb), + GFP_NOFS); if (folios == NULL) { ret = -ENOMEM; mlog_errno(ret); diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 76c86f1c2b1c..17ba79f443ee 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -823,7 +823,7 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp, u32 cend; struct ocfs2_write_ctxt *wc; - wc = kzalloc(sizeof(struct ocfs2_write_ctxt), GFP_NOFS); + wc = kzalloc_obj(struct ocfs2_write_ctxt, GFP_NOFS); if (!wc) return -ENOMEM; @@ -1325,8 +1325,7 @@ retry: if (new == NULL) { spin_unlock(&oi->ip_lock); - new = kmalloc(sizeof(struct ocfs2_unwritten_extent), - GFP_NOFS); + new = kmalloc_obj(struct ocfs2_unwritten_extent, GFP_NOFS); if (new == NULL) { ret = -ENOMEM; goto out; @@ -2080,7 +2079,7 @@ ocfs2_dio_alloc_write_ctx(struct buffer_head *bh, int *alloc) if (bh->b_private) return bh->b_private; - dwc = kmalloc(sizeof(struct ocfs2_dio_write_ctxt), GFP_NOFS); + dwc = kmalloc_obj(struct ocfs2_dio_write_ctxt, GFP_NOFS); if (dwc == NULL) return NULL; INIT_LIST_HEAD(&dwc->dw_zero_list); diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 8e9cbc334cf4..91fb76a43900 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -1677,8 +1677,8 @@ static int o2hb_map_slot_data(struct o2hb_region *reg) if (reg->hr_tmp_block == NULL) return -ENOMEM; - reg->hr_slots = kcalloc(reg->hr_blocks, - sizeof(struct o2hb_disk_slot), GFP_KERNEL); + reg->hr_slots = kzalloc_objs(struct o2hb_disk_slot, reg->hr_blocks, + GFP_KERNEL); if (reg->hr_slots == NULL) return -ENOMEM; @@ -1694,8 +1694,8 @@ static int o2hb_map_slot_data(struct o2hb_region *reg) "at %u blocks per page\n", reg->hr_num_pages, reg->hr_blocks, spp); - reg->hr_slot_data = kcalloc(reg->hr_num_pages, sizeof(struct page *), - GFP_KERNEL); + reg->hr_slot_data = kzalloc_objs(struct page *, reg->hr_num_pages, + GFP_KERNEL); if (!reg->hr_slot_data) return -ENOMEM; @@ -2001,7 +2001,7 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g struct o2hb_region *reg = NULL; int ret; - reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); + reg = kzalloc_obj(struct o2hb_region, GFP_KERNEL); if (reg == NULL) return ERR_PTR(-ENOMEM); @@ -2211,7 +2211,7 @@ struct config_group *o2hb_alloc_hb_set(void) struct o2hb_heartbeat_group *hs = NULL; struct config_group *ret = NULL; - hs = kzalloc(sizeof(struct o2hb_heartbeat_group), GFP_KERNEL); + hs = kzalloc_obj(struct o2hb_heartbeat_group, GFP_KERNEL); if (hs == NULL) goto out; diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index bc27301eab6d..2cb3162aeb89 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c @@ -380,7 +380,7 @@ static int sc_common_open(struct file *file, int ctxt) struct o2net_sock_debug *sd; struct o2net_sock_container *dummy_sc; - dummy_sc = kzalloc(sizeof(*dummy_sc), GFP_KERNEL); + dummy_sc = kzalloc_obj(*dummy_sc, GFP_KERNEL); if (!dummy_sc) return -ENOMEM; diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index c5e83c774d73..6fb8bc38c0f7 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -587,7 +587,7 @@ static struct config_item *o2nm_node_group_make_item(struct config_group *group, if (strlen(name) > O2NM_MAX_NAME_LEN) return ERR_PTR(-ENAMETOOLONG); - node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); + node = kzalloc_obj(struct o2nm_node, GFP_KERNEL); if (node == NULL) return ERR_PTR(-ENOMEM); @@ -695,8 +695,8 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g if (o2nm_single_cluster) return ERR_PTR(-ENOSPC); - cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); - ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); + cluster = kzalloc_obj(struct o2nm_cluster, GFP_KERNEL); + ns = kzalloc_obj(struct o2nm_node_group, GFP_KERNEL); o2hb_group = o2hb_alloc_hb_set(); if (cluster == NULL || ns == NULL || o2hb_group == NULL) goto out; diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 79b281e32f4c..09a1f3b77bb8 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -415,7 +415,7 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node) int status = 0; page = alloc_page(GFP_NOFS); - sc = kzalloc(sizeof(*sc), GFP_NOFS); + sc = kzalloc_obj(*sc, GFP_NOFS); if (sc == NULL || page == NULL) goto out; @@ -825,7 +825,7 @@ int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, goto out; } - nmh = kzalloc(sizeof(struct o2net_msg_handler), GFP_NOFS); + nmh = kzalloc_obj(struct o2net_msg_handler, GFP_NOFS); if (nmh == NULL) { ret = -ENOMEM; goto out; @@ -1064,14 +1064,14 @@ int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec, o2net_set_nst_sock_container(&nst, sc); veclen = caller_veclen + 1; - vec = kmalloc_array(veclen, sizeof(struct kvec), GFP_ATOMIC); + vec = kmalloc_objs(struct kvec, veclen, GFP_ATOMIC); if (vec == NULL) { mlog(0, "failed to %zu element kvec!\n", veclen); ret = -ENOMEM; goto out; } - msg = kmalloc(sizeof(struct o2net_msg), GFP_ATOMIC); + msg = kmalloc_obj(struct o2net_msg, GFP_ATOMIC); if (!msg) { mlog(0, "failed to allocate a o2net_msg!\n"); ret = -ENOMEM; diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c index 1873bbbb7e5b..c4ba968e778b 100644 --- a/fs/ocfs2/dcache.c +++ b/fs/ocfs2/dcache.c @@ -265,7 +265,7 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry, /* * There are no other aliases */ - dl = kmalloc(sizeof(*dl), GFP_NOFS); + dl = kmalloc_obj(*dl, GFP_NOFS); if (!dl) { ret = -ENOMEM; mlog_errno(ret); diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 782afd9fa934..1c8abf2c592c 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c @@ -2550,8 +2550,7 @@ static struct buffer_head **ocfs2_dx_dir_kmalloc_leaves(struct super_block *sb, int num_dx_leaves = ocfs2_clusters_to_blocks(sb, 1); struct buffer_head **dx_leaves; - dx_leaves = kcalloc(num_dx_leaves, sizeof(struct buffer_head *), - GFP_NOFS); + dx_leaves = kzalloc_objs(struct buffer_head *, num_dx_leaves, GFP_NOFS); if (dx_leaves && ret_num_leaves) *ret_num_leaves = num_dx_leaves; diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index cf3ca2f597c2..ff4868619d35 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -1048,7 +1048,7 @@ static int dlm_send_regions(struct dlm_ctxt *dlm, unsigned long *node_map) if (find_first_bit(node_map, O2NM_MAX_NODES) >= O2NM_MAX_NODES) goto bail; - qr = kzalloc(sizeof(struct dlm_query_region), GFP_KERNEL); + qr = kzalloc_obj(struct dlm_query_region, GFP_KERNEL); if (!qr) { ret = -ENOMEM; mlog_errno(ret); @@ -1220,7 +1220,7 @@ static int dlm_send_nodeinfo(struct dlm_ctxt *dlm, unsigned long *node_map) if (find_first_bit(node_map, O2NM_MAX_NODES) >= O2NM_MAX_NODES) goto bail; - qn = kzalloc(sizeof(struct dlm_query_nodeinfo), GFP_KERNEL); + qn = kzalloc_obj(struct dlm_query_nodeinfo, GFP_KERNEL); if (!qn) { ret = -ENOMEM; mlog_errno(ret); @@ -1592,7 +1592,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) mlog(0, "%p", dlm); - ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL); + ctxt = kzalloc_obj(*ctxt, GFP_KERNEL); if (!ctxt) { status = -ENOMEM; mlog_errno(status); @@ -1946,7 +1946,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain, int ret; struct dlm_ctxt *dlm = NULL; - dlm = kzalloc(sizeof(*dlm), GFP_KERNEL); + dlm = kzalloc_obj(*dlm, GFP_KERNEL); if (!dlm) { ret = -ENOMEM; mlog_errno(ret); diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index 041fd1791ae7..46120eb75d90 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c @@ -414,7 +414,7 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie, if (!lksb) { /* zero memory only if kernel-allocated */ - lksb = kzalloc(sizeof(*lksb), GFP_NOFS); + lksb = kzalloc_obj(*lksb, GFP_NOFS); if (!lksb) { kmem_cache_free(dlm_lock_cache, lock); return NULL; diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 4145e06d2c08..eb62724bbe9b 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -2040,7 +2040,7 @@ int dlm_dispatch_assert_master(struct dlm_ctxt *dlm, int ignore_higher, u8 request_from, u32 flags) { struct dlm_work_item *item; - item = kzalloc(sizeof(*item), GFP_ATOMIC); + item = kzalloc_obj(*item, GFP_ATOMIC); if (!item) return -ENOMEM; @@ -2303,7 +2303,7 @@ int dlm_deref_lockres_handler(struct o2net_msg *msg, u32 len, void *data, goto done; } - item = kzalloc(sizeof(*item), GFP_NOFS); + item = kzalloc_obj(*item, GFP_NOFS); if (!item) { ret = -ENOMEM; mlog_errno(ret); diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 843ee02bd85f..128872bd945d 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -743,7 +743,7 @@ static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node) } BUG_ON(num == dead_node); - ndata = kzalloc(sizeof(*ndata), GFP_NOFS); + ndata = kzalloc_obj(*ndata, GFP_NOFS); if (!ndata) { dlm_destroy_recovery_area(dlm); return -ENOMEM; @@ -830,7 +830,7 @@ int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data, } BUG_ON(lr->dead_node != dlm->reco.dead_node); - item = kzalloc(sizeof(*item), GFP_NOFS); + item = kzalloc_obj(*item, GFP_NOFS); if (!item) { dlm_put(dlm); return -ENOMEM; @@ -1382,7 +1382,7 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data, ret = -ENOMEM; buf = kmalloc(be16_to_cpu(msg->data_len), GFP_NOFS); - item = kzalloc(sizeof(*item), GFP_NOFS); + item = kzalloc_obj(*item, GFP_NOFS); if (!buf || !item) goto leave; diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 339f0b11cdc8..45cce261da65 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -134,7 +134,7 @@ static int dlmfs_file_open(struct inode *inode, * doesn't make sense for LVB writes. */ file->f_flags &= ~O_APPEND; - fp = kmalloc(sizeof(*fp), GFP_NOFS); + fp = kmalloc_obj(*fp, GFP_NOFS); if (!fp) { status = -ENOMEM; goto bail; diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 619ff03b15d6..627d488b0148 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -3030,7 +3030,7 @@ struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void) { struct ocfs2_dlm_debug *dlm_debug; - dlm_debug = kmalloc(sizeof(struct ocfs2_dlm_debug), GFP_KERNEL); + dlm_debug = kmalloc_obj(struct ocfs2_dlm_debug, GFP_KERNEL); if (!dlm_debug) { mlog_errno(-ENOMEM); goto out; diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index ef147e8b3271..d68229422dda 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -246,7 +246,7 @@ search: if (new_emi == NULL) { spin_unlock(&oi->ip_lock); - new_emi = kmalloc(sizeof(*new_emi), GFP_NOFS); + new_emi = kmalloc_obj(*new_emi, GFP_NOFS); if (new_emi == NULL) goto out; diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index ed961a854983..70879058b0c9 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -54,7 +54,7 @@ static int ocfs2_init_file_private(struct inode *inode, struct file *file) { struct ocfs2_file_private *fp; - fp = kzalloc(sizeof(struct ocfs2_file_private), GFP_KERNEL); + fp = kzalloc_obj(struct ocfs2_file_private, GFP_KERNEL); if (!fp) return -ENOMEM; diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c index 3ad7baf67658..be713d7d24a7 100644 --- a/fs/ocfs2/filecheck.c +++ b/fs/ocfs2/filecheck.c @@ -169,7 +169,7 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb) struct ocfs2_filecheck *fcheck; struct ocfs2_filecheck_sysfs_entry *entry = &osb->osb_fc_ent; - fcheck = kmalloc(sizeof(struct ocfs2_filecheck), GFP_NOFS); + fcheck = kmalloc_obj(struct ocfs2_filecheck, GFP_NOFS); if (!fcheck) return -ENOMEM; @@ -464,7 +464,7 @@ static ssize_t ocfs2_filecheck_attr_store(struct kobject *kobj, goto exit; } - entry = kmalloc(sizeof(struct ocfs2_filecheck_entry), GFP_NOFS); + entry = kmalloc_obj(struct ocfs2_filecheck_entry, GFP_NOFS); if (!entry) { ret = -ENOMEM; goto exit; diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index b6864602814c..872b826979ec 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -334,7 +334,7 @@ static int ocfs2_info_handle_freeinode(struct inode *inode, struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct inode *inode_alloc = NULL; - oifi = kzalloc(sizeof(struct ocfs2_info_freeinode), GFP_KERNEL); + oifi = kzalloc_obj(struct ocfs2_info_freeinode, GFP_KERNEL); if (!oifi) { status = -ENOMEM; mlog_errno(status); @@ -620,7 +620,7 @@ static int ocfs2_info_handle_freefrag(struct inode *inode, struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct inode *gb_inode = NULL; - oiff = kzalloc(sizeof(struct ocfs2_info_freefrag), GFP_KERNEL); + oiff = kzalloc_obj(struct ocfs2_info_freefrag, GFP_KERNEL); if (!oiff) { status = -ENOMEM; mlog_errno(status); diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 85239807dec7..1b9359304aef 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -114,9 +114,8 @@ int ocfs2_compute_replay_slots(struct ocfs2_super *osb) if (osb->replay_map) return 0; - replay_map = kzalloc(struct_size(replay_map, rm_replay_slots, - osb->max_slots), - GFP_KERNEL); + replay_map = kzalloc_flex(*replay_map, rm_replay_slots, osb->max_slots, + GFP_KERNEL); if (!replay_map) { mlog_errno(-ENOMEM); return -ENOMEM; @@ -178,8 +177,7 @@ int ocfs2_recovery_init(struct ocfs2_super *osb) osb->recovery_thread_task = NULL; init_waitqueue_head(&osb->recovery_event); - rm = kzalloc(struct_size(rm, rm_entries, osb->max_slots), - GFP_KERNEL); + rm = kzalloc_flex(*rm, rm_entries, osb->max_slots, GFP_KERNEL); if (!rm) { mlog_errno(-ENOMEM); return -ENOMEM; @@ -878,7 +876,7 @@ int ocfs2_journal_alloc(struct ocfs2_super *osb) int status = 0; struct ocfs2_journal *journal; - journal = kzalloc(sizeof(struct ocfs2_journal), GFP_KERNEL); + journal = kzalloc_obj(struct ocfs2_journal, GFP_KERNEL); if (!journal) { mlog(ML_ERROR, "unable to alloc journal\n"); status = -ENOMEM; @@ -1394,7 +1392,7 @@ static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal, { struct ocfs2_la_recovery_item *item; - item = kmalloc(sizeof(struct ocfs2_la_recovery_item), GFP_NOFS); + item = kmalloc_obj(struct ocfs2_la_recovery_item, GFP_NOFS); if (!item) { /* Though we wish to avoid it, we are in fact safe in * skipping local alloc cleanup as fsck.ocfs2 is more @@ -1480,7 +1478,7 @@ static int __ocfs2_recovery_thread(void *arg) } if (quota_enabled) { - rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS); + rm_quota = kzalloc_objs(int, osb->max_slots, GFP_NOFS); if (!rm_quota) { status = -ENOMEM; goto bail; diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 56be21c695d6..29fa6fb11ea5 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c @@ -1094,7 +1094,7 @@ static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, { int status; - *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); + *ac = kzalloc_obj(struct ocfs2_alloc_context, GFP_KERNEL); if (!(*ac)) { status = -ENOMEM; mlog_errno(status); diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index e3cdf8788484..c53de4439d93 100644 --- a/fs/ocfs2/move_extents.c +++ b/fs/ocfs2/move_extents.c @@ -1011,7 +1011,7 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp) goto out_drop; } - context = kzalloc(sizeof(struct ocfs2_move_extents_context), GFP_NOFS); + context = kzalloc_obj(struct ocfs2_move_extents_context, GFP_NOFS); if (!context) { status = -ENOMEM; mlog_errno(status); diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 4ec6dbed65a8..85ad1a9db734 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -1736,7 +1736,7 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb, goto bail; } - bhs = kcalloc(blocks, sizeof(struct buffer_head *), GFP_KERNEL); + bhs = kzalloc_objs(struct buffer_head *, blocks, GFP_KERNEL); if (!bhs) { status = -ENOMEM; mlog_errno(status); diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c index de7f12858729..c4e0117d8977 100644 --- a/fs/ocfs2/quota_local.c +++ b/fs/ocfs2/quota_local.c @@ -298,7 +298,7 @@ static int ocfs2_add_recovery_chunk(struct super_block *sb, { struct ocfs2_recovery_chunk *rc; - rc = kmalloc(sizeof(struct ocfs2_recovery_chunk), GFP_NOFS); + rc = kmalloc_obj(struct ocfs2_recovery_chunk, GFP_NOFS); if (!rc) return -ENOMEM; rc->rc_chunk = chunk; @@ -372,7 +372,7 @@ static struct ocfs2_quota_recovery *ocfs2_alloc_quota_recovery(void) int type; struct ocfs2_quota_recovery *rec; - rec = kmalloc(sizeof(struct ocfs2_quota_recovery), GFP_NOFS); + rec = kmalloc_obj(struct ocfs2_quota_recovery, GFP_NOFS); if (!rec) return NULL; for (type = 0; type < OCFS2_MAXQUOTAS; type++) @@ -692,7 +692,7 @@ static int ocfs2_local_read_info(struct super_block *sb, int type) info->dqi_max_spc_limit = 0x7fffffffffffffffLL; info->dqi_max_ino_limit = 0x7fffffffffffffffLL; - oinfo = kmalloc(sizeof(struct ocfs2_mem_dqinfo), GFP_NOFS); + oinfo = kmalloc_obj(struct ocfs2_mem_dqinfo, GFP_NOFS); if (!oinfo) { mlog(ML_ERROR, "failed to allocate memory for ocfs2 quota" " info."); diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index c92e0ea85bca..c1cdececdfa4 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -311,7 +311,7 @@ ocfs2_allocate_refcount_tree(struct ocfs2_super *osb, u64 rf_blkno) { struct ocfs2_refcount_tree *new; - new = kzalloc(sizeof(struct ocfs2_refcount_tree), GFP_NOFS); + new = kzalloc_obj(struct ocfs2_refcount_tree, GFP_NOFS); if (!new) return NULL; @@ -3397,7 +3397,7 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode, BUG_ON(cow_len == 0); - context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS); + context = kzalloc_obj(struct ocfs2_cow_context, GFP_NOFS); if (!context) { ret = -ENOMEM; mlog_errno(ret); @@ -3606,7 +3606,7 @@ int ocfs2_refcount_cow_xattr(struct inode *inode, BUG_ON(cow_len == 0); - context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS); + context = kzalloc_obj(struct ocfs2_cow_context, GFP_NOFS); if (!context) { ret = -ENOMEM; mlog_errno(ret); diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index ea4a68abc25b..3ea14f00e84a 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c @@ -385,8 +385,8 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb, trace_ocfs2_map_slot_buffers(bytes, si->si_blocks); - si->si_bh = kcalloc(si->si_blocks, sizeof(struct buffer_head *), - GFP_KERNEL); + si->si_bh = kzalloc_objs(struct buffer_head *, si->si_blocks, + GFP_KERNEL); if (!si->si_bh) { status = -ENOMEM; mlog_errno(status); @@ -425,7 +425,7 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb) struct inode *inode = NULL; struct ocfs2_slot_info *si; - si = kzalloc(struct_size(si, si_slots, osb->max_slots), GFP_KERNEL); + si = kzalloc_flex(*si, si_slots, osb->max_slots, GFP_KERNEL); if (!si) { status = -ENOMEM; mlog_errno(status); diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c index f58e891aa2da..78a97c37398b 100644 --- a/fs/ocfs2/stack_o2cb.c +++ b/fs/ocfs2/stack_o2cb.c @@ -334,7 +334,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn) goto out; } - priv = kzalloc(sizeof(struct o2dlm_private), GFP_KERNEL); + priv = kzalloc_obj(struct o2dlm_private, GFP_KERNEL); if (!priv) { rc = -ENOMEM; goto out_free; diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index be0a5758bd40..11b34407de36 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c @@ -593,7 +593,7 @@ static int ocfs2_control_open(struct inode *inode, struct file *file) { struct ocfs2_control_private *p; - p = kzalloc(sizeof(struct ocfs2_control_private), GFP_KERNEL); + p = kzalloc_obj(struct ocfs2_control_private, GFP_KERNEL); if (!p) return -ENOMEM; p->op_this_node = -1; @@ -967,7 +967,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn) BUG_ON(conn == NULL); - lc = kzalloc(sizeof(struct ocfs2_live_connection), GFP_KERNEL); + lc = kzalloc_obj(struct ocfs2_live_connection, GFP_KERNEL); if (!lc) return -ENOMEM; diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index fca2fd07c881..46ff5835da2e 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c @@ -328,8 +328,7 @@ int ocfs2_cluster_connect(const char *stack_name, goto out; } - new_conn = kzalloc(sizeof(struct ocfs2_cluster_connection), - GFP_KERNEL); + new_conn = kzalloc_obj(struct ocfs2_cluster_connection, GFP_KERNEL); if (!new_conn) { rc = -ENOMEM; goto out; diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 79d1325b2111..872c7b303a3c 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -1034,7 +1034,7 @@ int ocfs2_reserve_new_metadata_blocks(struct ocfs2_super *osb, int status; int slot = ocfs2_get_meta_steal_slot(osb); - *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); + *ac = kzalloc_obj(struct ocfs2_alloc_context, GFP_KERNEL); if (!(*ac)) { status = -ENOMEM; mlog_errno(status); @@ -1105,7 +1105,7 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb, int slot = ocfs2_get_inode_steal_slot(osb); u64 alloc_group; - *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); + *ac = kzalloc_obj(struct ocfs2_alloc_context, GFP_KERNEL); if (!(*ac)) { status = -ENOMEM; mlog_errno(status); @@ -1221,7 +1221,7 @@ static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb, int status, ret = 0; int retried = 0; - *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); + *ac = kzalloc_obj(struct ocfs2_alloc_context, GFP_KERNEL); if (!(*ac)) { status = -ENOMEM; mlog_errno(status); @@ -2245,7 +2245,7 @@ int ocfs2_find_new_inode_loc(struct inode *dir, BUG_ON(ac->ac_bits_wanted != 1); BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); - res = kzalloc(sizeof(*res), GFP_NOFS); + res = kzalloc_obj(*res, GFP_NOFS); if (res == NULL) { ret = -ENOMEM; mlog_errno(ret); diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 3cbafac50cd1..9779f524ff1a 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -1200,7 +1200,7 @@ static int ocfs2_init_fs_context(struct fs_context *fc) { struct mount_options *mopt; - mopt = kzalloc(sizeof(struct mount_options), GFP_KERNEL); + mopt = kzalloc_obj(struct mount_options, GFP_KERNEL); if (!mopt) return -EINVAL; @@ -1953,7 +1953,7 @@ static int ocfs2_initialize_super(struct super_block *sb, struct ocfs2_super *osb; u64 total_blocks; - osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL); + osb = kzalloc_obj(struct ocfs2_super, GFP_KERNEL); if (!osb) { status = -ENOMEM; mlog_errno(status); diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index e434a62dd69f..42ee5db362d3 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -324,7 +324,7 @@ static struct ocfs2_xattr_bucket *ocfs2_xattr_bucket_new(struct inode *inode) BUG_ON(blks > OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET); - bucket = kzalloc(sizeof(struct ocfs2_xattr_bucket), GFP_NOFS); + bucket = kzalloc_obj(struct ocfs2_xattr_bucket, GFP_NOFS); if (bucket) { bucket->bu_inode = inode; bucket->bu_blocks = blks; |
