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

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Jun 20 13:29:27 CDT 2005


Author: mfasheh
Signed-off-by: jlbec
Date: 2005-06-20 13:29:25 -0500 (Mon, 20 Jun 2005)
New Revision: 2412

Modified:
   trunk/fs/ocfs2/dlmglue.c
   trunk/fs/ocfs2/dlmglue.h
   trunk/fs/ocfs2/inode.c
   trunk/fs/ocfs2/ocfs2.h
Log:
* inline l_name - dynamically allocating it is pointless.

Signed-off-by: jlbec



Modified: trunk/fs/ocfs2/dlmglue.c
===================================================================
--- trunk/fs/ocfs2/dlmglue.c	2005-06-19 06:16:08 UTC (rev 2411)
+++ trunk/fs/ocfs2/dlmglue.c	2005-06-20 18:29:25 UTC (rev 2412)
@@ -55,11 +55,6 @@
 
 #include "buffer_head_io.h"
 
-static int ocfs2_build_lock_name(enum ocfs2_lock_type type,
-				 u64 blkno,
-				 u32 generation,
-				 char **ret);
-
 static void ocfs2_inode_ast_func(void *opaque);
 static void ocfs2_inode_bast_func(void *opaque,
 				  int level);
@@ -273,24 +268,17 @@
 	mlog_exit_void();
 }
 
-static int ocfs2_build_lock_name(enum ocfs2_lock_type type,
-				 u64 blkno,
-				 u32 generation,
-				 char **ret)
+static void ocfs2_build_lock_name(enum ocfs2_lock_type type,
+				  u64 blkno,
+				  u32 generation,
+				  char *name)
 {
 	int len;
-	char *name = NULL;
 
 	mlog_entry_void();
 
 	BUG_ON(type >= OCFS2_NUM_LOCK_TYPES);
 
-	name = kcalloc(1, OCFS2_LOCK_ID_MAX_LEN, GFP_KERNEL);
-	if (!name) {
-		len = -ENOMEM;
-		goto bail;
-	}
-
 	len = snprintf(name, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016"MLFx64"%08x", 
 		       ocfs2_lock_type_char(type), OCFS2_LOCK_ID_PAD, blkno, 
 		       generation);
@@ -299,17 +287,18 @@
 
 	mlog(0, "built lock resource with name: %s\n", name);
 
-	*ret = name;
-bail:
 	mlog_exit_void();
-	return len;
 }
 
 static void ocfs2_lock_res_init_common(struct ocfs2_lock_res *res,
 				       enum ocfs2_lock_type type,
+				       u64 blkno,
+				       u32 generation,
 				       struct ocfs2_lock_res_ops *ops,
 				       void *priv)
 {
+	ocfs2_build_lock_name(type, blkno, generation, res->l_name);
+
 	res->l_type          = type;
 	res->l_ops           = ops;
 	res->l_priv          = priv;
@@ -333,88 +322,43 @@
 	INIT_LIST_HEAD(&res->l_flag_cb_list);
 }
 
-int ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res,
-			      enum ocfs2_lock_type type,
-			      struct inode *inode)
+void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res,
+			       enum ocfs2_lock_type type,
+			       struct inode *inode)
 {
-	int status;
 	struct ocfs2_lock_res_ops *ops;
 
-	mlog_entry_void();
+	BUG_ON(type != OCFS2_LOCK_TYPE_META &&
+	       type != OCFS2_LOCK_TYPE_DATA);
 
-	OCFS2_ASSERT(type == OCFS2_LOCK_TYPE_META ||
-		    type == OCFS2_LOCK_TYPE_DATA);
-
-	status = ocfs2_build_lock_name(type,
-				       OCFS2_I(inode)->ip_blkno,
-				       inode->i_generation,
-				       &res->l_name);
-	if (status < 0) {
-		mlog_errno(status);
-		goto bail;
-	}
-
 	if (type == OCFS2_LOCK_TYPE_META)
 		ops = &ocfs2_inode_meta_lops;
 	else
 		ops = &ocfs2_inode_data_lops;
 
-	ocfs2_lock_res_init_common(res, type, ops, inode);
-
-bail:
-	mlog_exit(status);
-	return status;
+	ocfs2_lock_res_init_common(res, type, OCFS2_I(inode)->ip_blkno,
+				   inode->i_generation, ops, inode);
 }
 
-int ocfs2_super_lock_res_init(struct ocfs2_lock_res *res,
-     			      ocfs2_super *osb)
+static void ocfs2_super_lock_res_init(struct ocfs2_lock_res *res,
+				      ocfs2_super *osb)
 {
-	enum ocfs2_lock_type type = OCFS2_LOCK_TYPE_SUPER;
-	int status;
-
-	mlog_entry_void();
-
 	/* Superblock lockres doesn't come from a slab so we call init
 	 * once on it manually.  */
 	ocfs2_lock_res_init_once(res);
-
-	status = ocfs2_build_lock_name(type,
-				       OCFS2_SUPER_BLOCK_BLKNO,
-				       0,
-				       &res->l_name);
-	if (status < 0) {
-		mlog_errno(status);
-		goto bail;
-	}
-
-	ocfs2_lock_res_init_common(res, type, &ocfs2_super_lops, osb);
-
-bail:
-	mlog_exit(status);
-	return status;
+	ocfs2_lock_res_init_common(res, OCFS2_LOCK_TYPE_SUPER,
+				   OCFS2_SUPER_BLOCK_BLKNO, 0,
+				   &ocfs2_super_lops, osb);
 }
 
-int ocfs2_rename_lock_res_init(struct ocfs2_lock_res *res,
-			       ocfs2_super *osb)
+static void ocfs2_rename_lock_res_init(struct ocfs2_lock_res *res,
+				       ocfs2_super *osb)
 {
-	enum ocfs2_lock_type type = OCFS2_LOCK_TYPE_RENAME;
-	int status;
-
-	mlog_entry_void();
-
+	/* Rename lockres doesn't come from a slab so we call init
+	 * once on it manually.  */
 	ocfs2_lock_res_init_once(res);
-
-	status = ocfs2_build_lock_name(type, 0, 0, &res->l_name);
-	if (status < 0) {
-		mlog_errno(status);
-		goto bail;
-	}
-
-	ocfs2_lock_res_init_common(res, type, &ocfs2_rename_lops, osb);
-
-bail:
-	mlog_exit(status);
-	return status;
+	ocfs2_lock_res_init_common(res, OCFS2_LOCK_TYPE_RENAME, 0, 0,
+				   &ocfs2_rename_lops, osb);
 }
 
 void ocfs2_lock_res_free(struct ocfs2_lock_res *res)
@@ -424,8 +368,6 @@
 	if (!(res->l_flags & OCFS2_LOCK_INITIALIZED))
 		return;
 
-	mlog_bug_on_msg(!res->l_name,
-			"Lockres initialized without name!\n");
 	mlog_bug_on_msg(!list_empty(&res->l_blocked_list),
 			"Lockres %s is on the blocked list\n",
 			res->l_name);
@@ -442,8 +384,6 @@
 			"Lockres %s has %u ex holders\n",
 			res->l_name, res->l_ex_holders);
 
-	kfree(res->l_name);
-	res->l_name = NULL;
 	res->l_local_seq = 0;
 	/* Need to clear out the lock status block for the dlm */
 	memset(&res->l_lksb, 0, sizeof(res->l_lksb));
@@ -1849,18 +1789,12 @@
 		goto bail;
 	}
 
+	ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb);
+	ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb);
+
 	osb->dlm = dlm;
 
-	status = ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb);
-	if (status < 0) {
-		mlog_errno(status);
-		goto bail;
-	}
-
-	status = ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb);
-	if (status < 0)
-		mlog_errno(status);
-
+	status = 0;
 bail:
 
 	mlog_exit(status);

Modified: trunk/fs/ocfs2/dlmglue.h
===================================================================
--- trunk/fs/ocfs2/dlmglue.h	2005-06-19 06:16:08 UTC (rev 2411)
+++ trunk/fs/ocfs2/dlmglue.h	2005-06-20 18:29:25 UTC (rev 2412)
@@ -81,11 +81,9 @@
 int ocfs2_dlm_init(ocfs2_super *osb);
 void ocfs2_dlm_shutdown(ocfs2_super *osb);
 void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res);
-int ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res,
-			      enum ocfs2_lock_type type,
-			      struct inode *inode);
-int ocfs2_super_lock_res_init(struct ocfs2_lock_res *res,
-			      ocfs2_super *osb);
+void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res,
+			       enum ocfs2_lock_type type,
+			       struct inode *inode);
 void ocfs2_lock_res_free(struct ocfs2_lock_res *res);
 int ocfs2_create_new_inode_locks(struct inode *inode);
 int ocfs2_drop_inode_locks(struct inode *inode);

Modified: trunk/fs/ocfs2/inode.c
===================================================================
--- trunk/fs/ocfs2/inode.c	2005-06-19 06:16:08 UTC (rev 2411)
+++ trunk/fs/ocfs2/inode.c	2005-06-20 18:29:25 UTC (rev 2412)
@@ -302,20 +302,16 @@
 		    break;
 	}
 
-	status = ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres,
-					   OCFS2_LOCK_TYPE_META, inode);
-	if (status < 0) {
-		mlog_errno(status);
-		goto bail;
-	}
-	status = ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_data_lockres,
-					   OCFS2_LOCK_TYPE_DATA, inode);
-	if (status < 0)
-		mlog_errno(status);
+	ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres,
+				  OCFS2_LOCK_TYPE_META, inode);
+	ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_data_lockres,
+				  OCFS2_LOCK_TYPE_DATA, inode);
+
+	status = 0;
 bail:
 	mlog_exit(status);
 	return status;
-}				/* ocfs2_populate_inode */
+}
 
 static int ocfs2_read_locked_inode(struct inode *inode,
 				   struct ocfs2_find_inode_args *args)

Modified: trunk/fs/ocfs2/ocfs2.h
===================================================================
--- trunk/fs/ocfs2/ocfs2.h	2005-06-19 06:16:08 UTC (rev 2411)
+++ trunk/fs/ocfs2/ocfs2.h	2005-06-20 18:29:25 UTC (rev 2412)
@@ -109,7 +109,7 @@
 
 	enum ocfs2_lock_type     l_type;
 	unsigned long		 l_flags;
-	char                    *l_name;
+	char                     l_name[OCFS2_LOCK_ID_MAX_LEN];
 	int                      l_level;
 	unsigned int             l_ro_holders;
 	unsigned int             l_ex_holders;



More information about the Ocfs2-commits mailing list