[SSI] openssi/kernel/cluster/ssi/ipc namesvr_clnt.c, 1.6, 1.7 namesvr_func.c, 1.15, 1.16 namesvr_svr.c, 1.5, 1.6

Roger Tsang <[email protected]>
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14613/cluster/ssi/ipc

Modified Files:
      Tag: OPENSSI-FC
	namesvr_clnt.c namesvr_func.c namesvr_svr.c 
Log Message:
CFS:
- Fast path directory i_op->permission cfs_permission(); redundant since there is a recheck after token hold.

IPC:
- Fix [ ssic-linux-Bugs-2719607 ] memory leak in ipcname_gettotal() path; based on patch from John Hughes (hughesj).


Index: namesvr_svr.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/namesvr_svr.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- namesvr_svr.c	7 Aug 2007 03:06:09 -0000	1.5
+++ namesvr_svr.c	28 Mar 2009 23:44:16 -0000	1.6
@@ -36,7 +36,7 @@
 
 int ipcname_failover_flag = 0;
 extern int ipcname_getid(int, key_t, int, u_long *, clusternode_t*, int, int*);
-extern int ipcname_gettotal(int service, char **node_id_pairs, int *size);
+extern int ipcname_gettotal(int service, struct ssi_nodeid_pair *node_id_pairs, int *size);
 extern int ipcname_rmid(int, long, int);
 extern int ipcname_dumpinfo (int, int, int, int, int*, int*, int*, time_t*);
 extern int ipcname_findid(int, u_long, key_t *, clusternode_t*, int *, int *, int *);
@@ -81,29 +81,45 @@
 
 
 }
+
 /* 
- * This function trys to calculate the total number of given ipc structures
+ * This function tries to calculate the total number of given ipc structures
  * in the name server.
  */
 void
-ripc_ipcname_gettotal(clusternode_t *node, int *rval, int service, ssi_procstate_t *pstate, char **node_id_pairs, int *len, int *sz)
+ripc_ipcname_gettotal(clusternode_t *node, int *rval, int service,
+		ssi_procstate_t *pstate, struct ssi_nodeid_pair **node_id_pairs,
+		int *len, int *sz)
 {
 	ssi_procstate_t save_pstate;
 	int count = *sz;
 
-	if (ipcname_failover_flag) 
-	{
+	if (ipcname_failover_flag) {
 		*rval = -EAGAIN;
 		return;
 	}
+
 	*len = 0;
 	ssi_procstate_get(&save_pstate);
 	ssi_procstate_set(pstate);
-	*rval = ipcname_gettotal(service, node_id_pairs, sz);
-	if (count > 0)
-		*len = (*sz) * sizeof(int);
+	if (count > 0) {
+		*node_id_pairs = kmalloc(count * sizeof(**node_id_pairs), GFP_KERNEL);
+		if (*node_id_pairs == NULL) {
+			*sz = 0;
+			goto done;
+		}
+	}
+
+	*rval = ipcname_gettotal(service, *node_id_pairs, sz);
+	if (count > 0) {
+		if (count > *sz)
+			count = *sz;
+		*len = count * sizeof(**node_id_pairs);
+	}
+done:
 	ssi_procstate_set(&save_pstate);
 }
+
 /*
  * remove the id from name server for given service.
  */
@@ -117,8 +133,8 @@
 	}
 
 	*rval = ipcname_rmid(service, glid, 0);
-
 }
+
 void
 ripc_ipcname_findid(clusternode_t *node, int *rval, int service,
 	       global_id_t glid,

Index: namesvr_func.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/namesvr_func.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- namesvr_func.c	24 Feb 2009 01:51:47 -0000	1.15
+++ namesvr_func.c	28 Mar 2009 23:44:16 -0000	1.16
@@ -597,12 +597,11 @@
 }
 int
 ipcname_gettotal(int service,
-		char  **node_id_pairs, /* [OUT] nodenum-id pairs */
+		struct ssi_nodeid_pair *node_id_pairs, /* [OUT] nodenum-id pairs */
 		int  *size) 	      /* [INOUT] the number of ipc structs */
 {
 	ipc_obj_db_t	*odbp;
-	char		*buf;
-	int		idx=0, count;
+	int		idx, count = -1;
 
 	odbp = &nsc_name_odb[service];
 #ifdef NSC_IPC_RWLOCK_DOWNGRADE
@@ -613,33 +612,19 @@
 #ifdef TEST_IPC
 	printk("%s\n","Message nameserver locked in getid");
 #endif
-	for (count=0; count < odbp->iodb_size; count++) {
-		if (odbp->iodb_active[count] != NULL)
-			idx = idx + 2;
-	}
-	if ((idx <= 0) || (*size == -1)) goto done;
-
-	*node_id_pairs = (char*)kmalloc(idx * sizeof(int),GFP_KERNEL);
-	if (*node_id_pairs == NULL)
-	{
-		idx = 0;
-		goto done;
-	}
-	buf = *node_id_pairs;
-	for (count=0; count < odbp->iodb_size; count++) {
-		if (odbp->iodb_active[count] == NULL)
+	for (idx = 0; idx < odbp->iodb_size; idx++) {
+		if (odbp->iodb_active[idx] == NULL)
 			continue;
-		*((int *)buf) = odbp->iodb_active[count]->svr_node;
-		buf += sizeof(int);
-		*((int *)buf) = odbp->iodb_active[count]->io_id;
-		buf += sizeof(int);
+		if (++count >= *size)
+			continue;
+		node_id_pairs[count].node_num = odbp->iodb_active[idx]->svr_node;
+		node_id_pairs[count].ipc_id = odbp->iodb_active[idx]->io_id;
 	}
-done:
 #ifdef NSC_IPC_RWLOCK_DOWNGRADE
 	NSC_IPC_RDUNLOCK(odbp);
-	*size = idx;
+	*size = count + 1;
 #else
-	*size = idx;
+	*size = count + 1;
 	NSC_IPC_WRUNLOCK(odbp);
 #endif
 #ifdef TEST_IPC

Index: namesvr_clnt.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/namesvr_clnt.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- namesvr_clnt.c	7 Aug 2007 03:06:09 -0000	1.6
+++ namesvr_clnt.c	28 Mar 2009 23:44:16 -0000	1.7
@@ -46,7 +46,7 @@
 
 extern int ipcname_getid(int service, key_t key, int in_flag,
 	       	global_id_t *glid, clusternode_t *server, int view, int *size);
-extern int ipcname_gettotal(int service, char **node_id_pairs, int *size);
+extern int ipcname_gettotal(int service, struct ssi_nodeid_pair *node_id_pairs, int *size);
 extern int ipcname_findid(int, global_id_t, key_t *, clusternode_t *,
 							int *, int *, int *);
 
@@ -185,34 +185,32 @@
 	return status;
 }
 
-int cli_ipcname_gettotal(int service, char **node_id_pairs, int *sz)
+int cli_ipcname_gettotal(int service, struct ssi_nodeid_pair **node_id_pairs, int *sz)
 {
-	int		status;
 	clusternode_t	server_node;
-	int 		rval, len=0;
+	int		status, rval, len = 0;
 	extern clms_key_svc_t ipc_key_service;
 again:
 	server_node = name_server_node;
 #ifdef TEST_IPC
-	printk("cli_ipcname_gettotal: this_node = %d, namesvr_node = %d\n",this_node,name_server_node);
+	printk("cli_ipcname_gettotal: this_node = %d, namesvr_node = %d\n",
+			this_node, name_server_node);
 #endif
-	if (server_node == this_node)
-	{
+	if (server_node == this_node) {
 		if (ipcname_failover_flag)
 			clms_waitfor_key_service(ipc_key_service);
-		status = ipcname_gettotal(service, node_id_pairs, sz);
-	}
-	else
-	{
-		ssi_procstate_t pstate;
 
-		if (*sz != -1)
-			len = (*sz) * sizeof(int);
+		rval = ipcname_gettotal(service, *node_id_pairs, sz);
+	} else {
+		ssi_procstate_t pstate;
 
+		if (*sz > 0)
+			len = *sz * sizeof(struct ssi_nodeid_pair);
 		ssi_procstate_get(&pstate);
-		status = RIPC_IPCNAME_GETTOTAL(server_node,&rval,service,&pstate, node_id_pairs, &len, sz);
-		if (status == -EAGAIN || status == -EREMOTE) 
-		{
+
+		status = RIPC_IPCNAME_GETTOTAL(server_node, &rval, service, &pstate,
+						node_id_pairs, &len, sz);
+		if (status == -EAGAIN || status == -EREMOTE) {
 			/* Server is doing failover,dying, or isn't ready yet.*/
 			clms_waitfor_key_service(0);
 			goto again;


------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.