Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

[SSI] openssi/kernel/cluster/ssi/ipc ipc.h,1.3.2.1,1.3.2.2 ipc_ics.c,1.2.2.: msg#00037

Subject: [SSI] openssi/kernel/cluster/ssi/ipc ipc.h,1.3.2.1,1.3.2.2 ipc_ics.c,1.2.2.1,1.2.2.2 namesvr_clnt.c,1.2.2.2,1.2.2.3 namesvr_func.c,1.1.2.9,1.1.2.10
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31205/kernel/cluster/ssi/ipc

Modified Files:
      Tag: OPENSSI-RH
        ipc.h ipc_ics.c namesvr_clnt.c namesvr_func.c 
Log Message:
1. Generating msg and sem ids from nameserver.
2. Handling the "under-migration" ipc object status.
3. Object database updation now follows base logic of id generation.
4. Converting the object data base to array from of linked list.


Index: ipc_ics.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/Attic/ipc_ics.c,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -d -r1.2.2.1 -r1.2.2.2
--- ipc_ics.c   12 Dec 2003 22:41:33 -0000      1.2.2.1
+++ ipc_ics.c   17 Jun 2004 13:15:12 -0000      1.2.2.2
@@ -28,8 +28,8 @@
 
 #include <linux/spinlock.h>
 #include <linux/linkage.h>
-#include <linux/msg.h>
 #include <linux/cluster.h>
+#include <linux/msg.h>
 #include <cluster/icsgen.h>
 #include <cluster/ics.h>
 #include <cluster/ssi/namesvr.h>

Index: ipc.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/Attic/ipc.h,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -d -r1.3.2.1 -r1.3.2.2
--- ipc.h       16 Jan 2004 23:59:32 -0000      1.3.2.1
+++ ipc.h       17 Jun 2004 13:15:12 -0000      1.3.2.2
@@ -43,12 +43,12 @@
 
 struct ipc_obj
 {
-       struct ipc_obj  *io_next;
        ipc_obj_db_t    *io_obj_dbp;
        int              io_id;
-       key_t            io_key;
+       unsigned short   io_seq;
        struct kern_ipc_perm    *io_perm;
        clusternode_t    svr_node;
+       clusternode_t    new_node;
        int              local_view;
 };
 
@@ -59,8 +59,12 @@
 {
        char            *iodb_name;             /* For debugging */
        int              iodb_service;          /* SHM / MSG / SEM */
-       ipc_obj_t       *iodb_active;           /* List of active objects. */
+       ipc_obj_t        *iodb_active[IPCMNI];  /* List of active objects. */
        struct iodb_ops *iodb_ops;
+       int              iodb_size;
+       int              iodb_max;
+       unsigned short   iodb_seq;
+       unsigned short   iodb_seq_max;
        int              iodb_objects;          /* number of objects on chain */
        time_t           iodb_timestamp;        /* timestamp of last update */
        RW_SPIN_LOCK_T   spinlock;              /* database mutex */

Index: namesvr_func.c
===================================================================
RCS file: 
/cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/Attic/namesvr_func.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -d -r1.1.2.9 -r1.1.2.10
--- namesvr_func.c      13 May 2004 02:07:21 -0000      1.1.2.9
+++ namesvr_func.c      17 Jun 2004 13:15:12 -0000      1.1.2.10
@@ -36,6 +36,11 @@
 #include <cluster/ssi/ipc/shm.h>
 #include <cluster/ssi/namesvr.h>
 #include "ipc.h"
+#include "linux/sem.h"
+#include "linux/msg.h"
+#include "linux/shm.h"
+
+#define SEQ_MULTIPLIER (IPCMNI)
 
 clms_key_svc_t ipc_key_service;
 extern int ipcname_failover_flag;
@@ -79,20 +84,34 @@
 {
 {      "nsc_ipcname (msg)",    /* Service name */
        NAME_SERVICE_MSG,       /* Service number */
-       (ipc_obj_t *)NULL,      /* Active list */
-       &nsc_name_iodb_ops
+       {0},                    /* Active list */
+       &nsc_name_iodb_ops,
+       MSGMNI,         /* size */
+       -1,                     /* max_id */
+       1,                      /* seq */
+       USHRT_MAX,              /* seq_max */
+       0                       /* in_use */
 },
 {
        "nsc_ipcname (sem)",    /* Service name */
        NAME_SERVICE_SEM,       /* Service number */
-       (ipc_obj_t *)NULL,      /* Active list */
-       &nsc_name_iodb_ops
+       {0},                    /* Active list */
+       &nsc_name_iodb_ops,
+       SEMMNI,         /* size */
+       -1,                     /* max_id */
+       1,                      /* seq */
+       USHRT_MAX,              /* seq_max */
+       0                       /* in_use */
 },
-
 {      "nsc_ipcname (shm)",    /* Service name */
        NAME_SERVICE_SHM,       /* Service number */
-       (ipc_obj_t *)NULL,      /* Active list */
-       &nsc_name_iodb_ops
+       {0},                    /* Active list */
+       &nsc_name_iodb_ops,
+       SHMMNI+1                /* size */
+       -1,                     /* max_id */
+       1,                      /* seq */
+       USHRT_MAX,              /* seq_max */
+       0                       /* in_use */
 }
 };
 
@@ -119,13 +138,13 @@
        ipc_obj_db_t    *objdbp,        /* Object type's database. */
        int             id)
 {
-       ipc_obj_t *objp;
+       int idx;
 
-       for (objp = objdbp->iodb_active;
-            objp != NULL && objp->io_id != id;
-            objp = objp->io_next)
-               ;
-       return objp;
+       idx = id % SEQ_MULTIPLIER;
+       if (idx >= objdbp->iodb_size) 
+               return NULL;
+       else
+               return (objdbp->iodb_active[idx]);
 }
 
 /*
@@ -146,23 +165,17 @@
        int             view,
        int             nmsvr_version)
 {
-       int     error = 0;
-       ipc_obj_t *newp;
+       int     error, idx=0, newid=id;
        ipc_perm_t *permp;
        extern ATOMIC_INT_T local_nameserver_version;
 
-       newp = (ipc_obj_t *)kmalloc(sizeof(ipc_obj_t), GFP_KERNEL);
-       if (newp == NULL) {
-               NSC_IPC_RDLOCK(objdbp);
-               error = -ENOMEM;
-               goto out;
-       }
-
-       memset(newp, 0, sizeof(ipc_obj_t));
+       error = -ENOSPC;
        (*objdbp->iodb_ops->iop_alloc)(&permp);
 
        NSC_IPC_WRLOCK(objdbp);
 
+       if (permp == NULL)
+               goto out;
        /*
         * If name_server has gone down while this id was in flight to us,
         * or if the id has been claimed by another proc after being
@@ -170,53 +183,62 @@
         */
        if ((nmsvr_version != READ_ATOMIC_INT(&local_nameserver_version))
            || (objsvr_find_id(objdbp, id) != NULL)) {
-#if 0
-               printk("objsvr_new: duplicate id - %d, objdbp - %x, "
-                       "version - %d, current version - %d\n",
-                               id, objdbp, nmsvr_version,
-                               READ_ATOMIC_INT(local_nameserver_version));
-#endif /* 0 (formerly ifdef DEBUG)  */
                (*objdbp->iodb_ops->iop_dealloc)(permp);
-               kfree((void *)newp);
                *new_objpp = NULL;
                printk("%s\n","object pointer is NULL, returning -EAGAIN");
                return -EAGAIN;
        }
-
        /*
         *  Check to see whether the object was created while we slept
         */
-
+       *new_objpp = NULL;
        if (objsvr_find_key(objdbp, key, view, svr_node) != NULL) {
                (*objdbp->iodb_ops->iop_dealloc)(permp);
-               kfree((void *)newp);
-               *new_objpp = NULL;
 #ifdef TEST_IPC
                printk("%s\n","find key not null, returning objpp NULL");
 #endif
                return 0;
        }
-
-       newp->io_id = id;
-       newp->io_key = key;
-       newp->io_perm = permp;
-       newp->svr_node = svr_node;
-       if (permp != NULL) {
-               permp->mode = (flag & S_IRWXUGO);
-               permp->key = key;
-               permp->cuid = permp->uid = current->euid;
-               permp->cgid = permp->gid = current->egid;
+       if (newid) {
+               idx = newid % SEQ_MULTIPLIER;
+               objdbp->iodb_seq = newid / SEQ_MULTIPLIER;
+       } else {
+               for (idx=0; (idx < objdbp->iodb_size) &&
+                                       (objdbp->iodb_active[idx]!=NULL); idx++)
+                       ;
        }
-
-       /* Add the new entry to the specified database. (could be hashed). */
-       newp->io_obj_dbp = objdbp;
-       newp->io_next = objdbp->iodb_active;
-       newp->local_view = view;
-       objdbp->iodb_active = newp;
+       if (idx >= objdbp->iodb_size)
+               goto out;
+       if (objdbp->iodb_active[idx] == NULL) {
+               objdbp->iodb_active[idx] = 
+                           (ipc_obj_t *)kmalloc(sizeof(ipc_obj_t), GFP_KERNEL);
+       } else
+               printk("Warning: overwriting a non-zero id at index %d\n", idx);
+       if (objdbp->iodb_active[idx] == NULL)
+               goto out;
+       error = 0;
+       objdbp->iodb_active[idx]->io_seq = objdbp->iodb_seq++;
        objdbp->iodb_objects++;
+       if (idx > objdbp->iodb_max)
+               objdbp->iodb_max = idx;
+       permp->mode = (flag & S_IRWXUGO);
+       permp->key = key;
+       permp->cuid = permp->uid = current->euid;
+       permp->cgid = permp->gid = current->egid;
+       objdbp->iodb_active[idx]->io_perm = permp;
+       if (objdbp->iodb_seq > objdbp->iodb_seq_max)
+               objdbp->iodb_seq = 0;
+       objdbp->iodb_active[idx]->new_node = svr_node;
+       objdbp->iodb_active[idx]->svr_node = svr_node;
+       objdbp->iodb_active[idx]->io_obj_dbp = objdbp;
+       objdbp->iodb_active[idx]->local_view = view;
+       if (newid)
+               objdbp->iodb_active[idx]->io_id = newid;
+       else
+               objdbp->iodb_active[idx]->io_id = 
+                       objdbp->iodb_active[idx]->io_seq * SEQ_MULTIPLIER + idx;
        objdbp->iodb_timestamp = jiffies;
-
-       *new_objpp = newp;
+       *new_objpp = objdbp->iodb_active[idx];
 #ifdef TEST_IPC
        printk("%s\n","new object registered");
 #endif
@@ -224,7 +246,6 @@
        return error;
 }
 
-
 /*
  * Scans an object manager database for a valid object with the specified key.
  * If found, it is held, locked, and returned.
@@ -235,23 +256,26 @@
        int             view,
        clusternode_t   node)
 {
-       ipc_obj_t *objp;
+       ipc_obj_t **objp = objdbp->iodb_active;
+       int idx;
 
        if (key == IPC_PRIVATE)
                return NULL;
-       for (objp = objdbp->iodb_active; objp != NULL; objp = objp->io_next)
+       for (idx = 0; idx < objdbp->iodb_size; idx++)
        {
-               if (objp->io_key == key)
-               {
-                       if (view ^ objp->local_view)
+               if (objp[idx] && (objp[idx]->io_perm->key == key)) {
+                       if (view ^ objp[idx]->local_view)
                                continue;
-                       else if (view && (objp->svr_node != node))
+                       else if (view && (objp[idx]->svr_node != node))
                                continue;
                        else
                                break;
                }
        }
-       return objp;
+       if (idx < objdbp->iodb_size)
+               return objp[idx];
+       else
+               return NULL;
 }
 
 /*
@@ -358,6 +382,7 @@
                                break;
                case NAME_SERVICE_SEM:
                case NAME_SERVICE_MSG:
+                               break;
                default:
                                return -EINVAL;
        }
@@ -440,7 +465,7 @@
 
        NSC_IPC_UNLOCK(odbp);
 
-       if (!(*glid)) {
+       if (service == NAME_SERVICE_SHM) {
                error = ipcname_genid(odbp, key, size, in_flag, glid, view, 
*server);
                if (error < 0) {
                        NSC_IPC_WRLOCK(odbp);
@@ -464,6 +489,8 @@
                        }
                }
                *server  = objp->svr_node;
+               *glid = objp->io_id;
+               *size = 1;
 
                /*
                 * remember that we may got different global id
@@ -472,7 +499,7 @@
 #ifdef TEST_IPC
                printk("%s\n","assigning glid and server pointers");
                printk("%d glid pointer assigned \n",*glid);
-               printk("%d server pointer assigned\n", (*glid >> SHIFT_SERVER));
+               printk("%d server pointer assigned\n", *server);
 #endif
        }
 out:
@@ -489,41 +516,44 @@
                int  *size)           /* [INOUT] the number of ipc structs */
 {
        ipc_obj_db_t    *odbp;
-       ipc_obj_t       *objp;
        char            *buf;
-       int             count=0;
+       int             idx=0, count;
 
        odbp = &nsc_name_odb[service];
        NSC_IPC_WRLOCK(odbp);
 #ifdef TEST_IPC
        printk("%s\n","Message nameserver locked in getid");
 #endif
-       for (objp = odbp->iodb_active; objp != NULL; objp = objp->io_next)
-               count = count + 2;
-       if ((count <= 0) || (*size == -1)) goto done;
+       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(count * sizeof(int),GFP_KERNEL);
+       *node_id_pairs = (char*)kmalloc(idx * sizeof(int),GFP_KERNEL);
        if (*node_id_pairs == NULL) 
        {
-               count = 0;
+               idx = 0;
                goto done;
        }
        buf = *node_id_pairs;
-       for (objp = odbp->iodb_active; objp != NULL; objp = objp->io_next)
-       {
-               *((int *)buf) = objp->svr_node;
+       for (count=0; count < odbp->iodb_size; count++) {
+               if (odbp->iodb_active[count] == NULL)
+                       continue;
+               *((int *)buf) = odbp->iodb_active[count]->svr_node;
                buf += sizeof(int);
-               *((int *)buf) = objp->io_id;
+               *((int *)buf) = odbp->iodb_active[count]->io_id;
                buf += sizeof(int);
        }
 done:
-       *size = count;
+       *size = idx;
        NSC_IPC_UNLOCK(odbp);
 #ifdef TEST_IPC
        printk("%s\n","name server spin lock dropped in out/getid");
 #endif
        return 0;
 }
+
 /*
  *
  * remove the id from name server for that service.
@@ -544,9 +574,9 @@
        switch(service) {
                case NAME_SERVICE_SHM:
                        error = ipcname_shm_rmid(glid, error, flag);
-                       break;
-               case NAME_SERVICE_SEM:
                case NAME_SERVICE_MSG:
+               case NAME_SERVICE_SEM:
+                       break;
                default:
                        break;
        }
@@ -571,8 +601,11 @@
                NSC_IPC_UNLOCK(odbp);
                return -EINVAL;
        }
-       *key = objp->io_key;
-       *svr = objp->svr_node;
+       *key = objp->io_perm->key;
+       if (objp->new_node != objp->svr_node)
+               *svr = CLUSTERNODE_INVAL;
+       else
+               *svr = objp->svr_node;
        *view = objp->local_view;
        if (service == NAME_SERVICE_SHM)
                get_shm_attr(glid, *key, flags, sz);
@@ -592,23 +625,24 @@
 {
        ipc_obj_db_t    *odbp;
        ipc_obj_t       *objp;
-       int             total;
-       int             count;
+       int             total, idx, count;
 
        odbp = &nsc_name_odb[service];
        NSC_IPC_RDLOCK(odbp);
 
-       total = count = 0;
-       for (objp = odbp->iodb_active; objp != NULL; objp = objp->io_next) {
-               if (server && server != (objp->io_id >> SHIFT_SERVER))
-                       continue;
-               total++;
-               if (start < total && count < nentries) {
-                       *idsp++ = objp->io_id;
-                       count++;
+       total = idx = 0;
+       for (count=0; count<odbp->iodb_size; count++) {
+               if ((objp=odbp->iodb_active[count]) != NULL) {
+                       if (server && server != objp->svr_node)
+                               continue;
+                       total++;
+                       if (start < total && idx < nentries) {
+                               *idsp++ = objp->io_id;
+                               idx++;
+                       }
                }
        }
-       *num_entriesp = count;
+       *num_entriesp = idx;
        *total_entriesp = total;
        *timestampp = odbp->iodb_timestamp;
 
@@ -752,7 +786,7 @@
 {
        ipc_obj_db_t *odbp;
        ipc_obj_t *op;
-       int service;
+       int service, idx;
 
        if (node == name_server_node)
                INCR_ATOMIC_INT(&local_nameserver_version);
@@ -765,17 +799,15 @@
                NSC_IPC_RDLOCK(odbp);
 
 again:
-               for (op = odbp->iodb_active; op != NULL; op = op->io_next) {
-                       if (service == NAME_SERVICE_SHM) {
-                               if (op->svr_node == node){
+               idx = 0;
+               while (idx<odbp->iodb_size) {
+                       if ((op=odbp->iodb_active[idx])!= NULL) {
+                               if (op->svr_node == node) {
                                        (void)nsc_ipcremove(odbp, op->io_id);
                                        goto again;
                                }
                        }
-                       if ((op->io_id >> SHIFT_SERVER) == node) {
-                               (void)nsc_ipcremove(odbp, op->io_id);
-                               goto again;
-                       }
+                       idx++;
                }
                UNLOCK_EXCL_RW_SPIN_LOCK(&odbp->spinlock);
        }
@@ -792,16 +824,26 @@
        ipc_obj_db_t    *objdbp,        /* Object type's database. */
        int             objid)          /* Id of Object to remove */
 {
-       ipc_obj_t *op, **opp;
+       ipc_obj_t *op;
        clusternode_t svr_node;
+       int idx;
 
-       for (opp = &objdbp->iodb_active; (op = *opp) != NULL;
-            opp = &op->io_next) {
+       for (idx=0; idx<objdbp->iodb_size; idx++) {
+               if((op=objdbp->iodb_active[idx])==NULL)
+                       continue;
                if (op->io_id == objid) {
                        svr_node = op->svr_node;
-                       *opp = op->io_next;
+                       kfree((void *)(op->io_perm));
                        kfree((void *)op);
+                       objdbp->iodb_active[idx]=NULL;
                        objdbp->iodb_objects--;
+                       if (idx == objdbp->iodb_max) {
+                               do {
+                                       idx--;
+                                       if (idx == -1) break;
+                               } while (objdbp->iodb_active[idx] == NULL);
+                               objdbp->iodb_max = idx;
+                       }
                        objdbp->iodb_timestamp = jiffies;
                        return ((svr_node == name_server_node) ? 1 : 0);
                }
@@ -809,7 +851,6 @@
        return -ESRCH;
 }
 
-
 void
 ripc_svc_init(void)
 {

Index: namesvr_clnt.c
===================================================================
RCS file: 
/cvsroot/ssic-linux/openssi/kernel/cluster/ssi/ipc/Attic/namesvr_clnt.c,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -d -r1.2.2.2 -r1.2.2.3
--- namesvr_clnt.c      16 Jan 2004 23:59:32 -0000      1.2.2.2
+++ namesvr_clnt.c      17 Jun 2004 13:15:12 -0000      1.2.2.3
@@ -30,6 +30,7 @@
 #include <cluster/ics.h>
 
 #include <linux/msg.h>
+#include <linux/sem.h>
 #include <cluster/clms.h>
 #include <cluster/nodelist.h>
 #include <cluster/icsgen.h>



-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qplus.devel/200...    network.jabber....    debian.qa-packa...    encryption.gpg....    python.dabo.dev...    uclinux.devel/2...    science.mathema...    recreation.pesc...    kernel.ck/2004-...    mozilla.devel.e...    tex.latex.prosp...    ietf.multi6/200...    bbc.cvs/2002-11...    xfree86.newbie/...    jakarta.taglibs...    altlinux.hardwa...    comedi/2002-05/...    horde.bugs/2004...    games.diplomacy...    finance.e-gold....    web.dom.test-su...    lang.ruby.rails...    os.netbsd.devel...    video.gstreamer...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation