[Ocfs2-commits] mfasheh commits r2362 - trunk/fs/ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Jun 3 15:49:52 CDT 2005


Author: mfasheh
Signed-off-by: manish
Date: 2005-06-03 15:49:50 -0500 (Fri, 03 Jun 2005)
New Revision: 2362

Modified:
   trunk/fs/ocfs2/alloc.c
   trunk/fs/ocfs2/dlmglue.c
   trunk/fs/ocfs2/journal.c
   trunk/fs/ocfs2/localalloc.c
   trunk/fs/ocfs2/namei.c
   trunk/fs/ocfs2/slot_map.c
   trunk/fs/ocfs2/suballoc.c
   trunk/fs/ocfs2/super.c
   trunk/fs/ocfs2/vote.c
Log:
* use kcalloc where appropriate

Signed-off-by: manish



Modified: trunk/fs/ocfs2/alloc.c
===================================================================
--- trunk/fs/ocfs2/alloc.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/alloc.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -252,7 +252,7 @@
 			    struct buffer_head *last_eb_bh,
 			    ocfs2_alloc_context *meta_ac)
 {
-	int status, new_blocks, size, i;
+	int status, new_blocks, i;
 	u64 next_blkno, new_last_eb_blk;
 	struct buffer_head *bh;
 	struct buffer_head **new_eb_bhs = NULL;
@@ -279,14 +279,13 @@
 	new_blocks = el->l_tree_depth;
 
 	/* allocate the number of new eb blocks we need */
-	size = sizeof(struct buffer_head *) * new_blocks;
-	new_eb_bhs = kmalloc(size, GFP_KERNEL);
+	new_eb_bhs = kcalloc(new_blocks, sizeof(struct buffer_head *),
+			     GFP_KERNEL);
 	if (!new_eb_bhs) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(new_eb_bhs, 0, size);
 
 	status = ocfs2_create_new_meta_bhs(osb, handle, inode, new_blocks, 
 					   meta_ac, new_eb_bhs);
@@ -536,14 +535,13 @@
 		 * for this part of the tree in an array and reserve a
 		 * journal write to them before making any changes. */
 		num_bhs = fe->id2.i_list.l_tree_depth;
-		eb_bhs = kmalloc(sizeof(struct buffer_head *) * num_bhs, 
+		eb_bhs = kcalloc(num_bhs, sizeof(struct buffer_head *),
 				 GFP_KERNEL);
 		if (!eb_bhs) {
 			status = -ENOMEM;
 			mlog_errno(status);
 			goto bail;
 		}
-		memset(eb_bhs, 0, sizeof(struct buffer_head *) * num_bhs);
 
 		i = 0;
 		while(el->l_tree_depth) {
@@ -1834,13 +1832,12 @@
 
 	OCFS2_ASSERT(fe->i_clusters > new_i_clusters);
 
-	*tc = kmalloc(sizeof(ocfs2_truncate_context), GFP_KERNEL);
+	*tc = kcalloc(1, sizeof(ocfs2_truncate_context), GFP_KERNEL);
 	if (!(*tc)) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(*tc, 0, sizeof(ocfs2_truncate_context));
 
 	metadata_delete = 0;
 	if (fe->id2.i_list.l_tree_depth) {

Modified: trunk/fs/ocfs2/dlmglue.c
===================================================================
--- trunk/fs/ocfs2/dlmglue.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/dlmglue.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -286,12 +286,11 @@
 
 	BUG_ON(type >= OCFS2_NUM_LOCK_TYPES);
 
-	name = kmalloc(OCFS2_LOCK_ID_MAX_LEN, GFP_KERNEL);
+	name = kcalloc(1, OCFS2_LOCK_ID_MAX_LEN, GFP_KERNEL);
 	if (!name) {
 		len = -ENOMEM;
 		goto bail;
 	}
-	memset(name, 0, OCFS2_LOCK_ID_MAX_LEN);
 
 	len = snprintf(name, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016"MLFx64"%08x", 
 		       ocfs2_lock_type_char[type], OCFS2_LOCK_ID_PAD, blkno, 

Modified: trunk/fs/ocfs2/journal.c
===================================================================
--- trunk/fs/ocfs2/journal.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/journal.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -118,13 +118,12 @@
 {
 	ocfs2_journal_handle *retval = NULL;
 
-	retval = kmalloc(sizeof(*retval), GFP_KERNEL);
+	retval = kcalloc(1, sizeof(*retval), GFP_KERNEL);
 	if (!retval) {
 		mlog(ML_ERROR, "Failed to allocate memory for journal "
 		     "handle!\n");
 		return NULL;
 	}
-	memset(retval, 0, sizeof(*retval));
 
 	retval->max_buffs = 0;
 	retval->num_locks = 0;

Modified: trunk/fs/ocfs2/localalloc.c
===================================================================
--- trunk/fs/ocfs2/localalloc.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/localalloc.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -761,13 +761,13 @@
 {
 	int status;
 
-	*ac = kmalloc(sizeof(ocfs2_alloc_context), GFP_KERNEL);
+	*ac = kcalloc(1, sizeof(ocfs2_alloc_context), GFP_KERNEL);
 	if (!(*ac)) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(*ac, 0, sizeof(ocfs2_alloc_context));
+
 	(*ac)->ac_handle = handle;
 	(*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb);
 

Modified: trunk/fs/ocfs2/namei.c
===================================================================
--- trunk/fs/ocfs2/namei.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/namei.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -1390,15 +1390,13 @@
 		goto bail;
 	}
 
-	bhs = kmalloc(sizeof(struct buffer_head *) * blocks, GFP_KERNEL);
+	bhs = kcalloc(blocks, sizeof(struct buffer_head *), GFP_KERNEL);
 	if (!bhs) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(bhs, 0, sizeof(struct buffer_head *) * blocks);
 
-
 	status = ocfs2_extent_map_get_blocks(inode, 0, 1, &p_blkno, 
 					     &p_blocks);
 	if (status < 0) {

Modified: trunk/fs/ocfs2/slot_map.c
===================================================================
--- trunk/fs/ocfs2/slot_map.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/slot_map.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -174,13 +174,13 @@
 	struct buffer_head *bh = NULL;
 	ocfs2_slot_info *si;
 
-	si = kmalloc(sizeof(ocfs2_slot_info), GFP_KERNEL);
+	si = kcalloc(1, sizeof(ocfs2_slot_info), GFP_KERNEL);
 	if (!si) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(si, 0, sizeof(ocfs2_slot_info));
+
 	spin_lock_init(&si->si_lock);
 	si->si_num_slots = osb->max_slots;
 	si->si_size = OCFS2_MAX_SLOTS;

Modified: trunk/fs/ocfs2/suballoc.c
===================================================================
--- trunk/fs/ocfs2/suballoc.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/suballoc.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -411,13 +411,13 @@
 	int status;
 	struct inode *alloc_inode = NULL;
 
-	*ac = kmalloc(sizeof(ocfs2_alloc_context), GFP_KERNEL);
+	*ac = kcalloc(1, sizeof(ocfs2_alloc_context), GFP_KERNEL);
 	if (!(*ac)) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(*ac, 0, sizeof(ocfs2_alloc_context));
+
 	(*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe);
 	(*ac)->ac_handle = handle;
 	(*ac)->ac_which = OCFS2_AC_USE_META;
@@ -468,13 +468,13 @@
 	int status;
 	struct inode *alloc_inode = NULL;
 
-	*ac = kmalloc(sizeof(ocfs2_alloc_context), GFP_KERNEL);
+	*ac = kcalloc(1, sizeof(ocfs2_alloc_context), GFP_KERNEL);
 	if (!(*ac)) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(*ac, 0, sizeof(ocfs2_alloc_context));
+
 	(*ac)->ac_bits_wanted = 1;
 	(*ac)->ac_handle = handle;
 	(*ac)->ac_which = OCFS2_AC_USE_INODE;
@@ -551,13 +551,13 @@
 
 	OCFS2_ASSERT(handle);
 
-	*ac = kmalloc(sizeof(ocfs2_alloc_context), GFP_KERNEL);
+	*ac = kcalloc(1, sizeof(ocfs2_alloc_context), GFP_KERNEL);
 	if (!(*ac)) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(*ac, 0, sizeof(ocfs2_alloc_context));
+
 	(*ac)->ac_bits_wanted = bits_wanted;
 	(*ac)->ac_handle = handle;
 

Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/super.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -1166,13 +1166,12 @@
 	 */
 	/* initialize our journal structure */
 
-	journal = kmalloc(sizeof(ocfs2_journal), GFP_KERNEL);
+	journal = kcalloc(1, sizeof(ocfs2_journal), GFP_KERNEL);
 	if (!journal) {
 		mlog(ML_ERROR, "unable to alloc journal\n");
 		status = -ENOMEM;
 		goto bail;
 	}
-	memset(journal, 0, sizeof(ocfs2_journal));
 	osb->journal = journal;
 	journal->j_osb = osb;
 

Modified: trunk/fs/ocfs2/vote.c
===================================================================
--- trunk/fs/ocfs2/vote.c	2005-06-03 20:45:08 UTC (rev 2361)
+++ trunk/fs/ocfs2/vote.c	2005-06-03 20:49:50 UTC (rev 2362)
@@ -469,12 +469,11 @@
 {
 	ocfs2_net_wait_ctxt *w;
 
-	w = kmalloc(sizeof(*w), GFP_KERNEL);
+	w = kcalloc(1, sizeof(*w), GFP_KERNEL);
 	if (!w) {
 		mlog_errno(-ENOMEM);
 		goto bail;
 	}
-	memset(w, 0, sizeof(*w));
 
 	INIT_LIST_HEAD(&w->n_list);
 	init_waitqueue_head(&w->n_event);
@@ -636,13 +635,13 @@
 
 	OCFS2_ASSERT(ocfs2_is_valid_vote_request(type));
 
-	request = kmalloc(sizeof(*request), GFP_KERNEL);
+	request = kcalloc(1, sizeof(*request), GFP_KERNEL);
 	if (!request) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memset(request, 0, sizeof(*request));
+
 	hdr = &request->v_hdr;
 
 	response_id = ocfs2_new_response_id(osb);



More information about the Ocfs2-commits mailing list