logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

[SSI] openssi/kernel/ipc sem.c,1.9,1.10: msg#00280

Subject: [SSI] openssi/kernel/ipc sem.c,1.9,1.10
Update of /cvsroot/ssic-linux/openssi/kernel/ipc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15733/ipc

Modified Files:
        sem.c 
Log Message:
- Redo the sem_undo list to work with the base code. 
- Clean up white space changes


Index: sem.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/ipc/sem.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- sem.c       22 Oct 2004 02:09:25 -0000      1.9
+++ sem.c       26 Oct 2004 01:06:36 -0000      1.10
@@ -154,7 +154,7 @@
 
 void ssi_semexit(int semid, pid_t pid);
 
-static struct sem_undo* freeundos(struct sem_undo*);
+static struct sem_undo* freeundos(struct sem_undo*, int);
 static clusternode_t sem_get_svr_node(int);
 static void sem_set_svr_node(int, clusternode_t);
 
@@ -301,32 +301,32 @@
        int retval = 0;
        int create = nsems;
 
-        down(&sem_ids.sem);
-        if (key != IPC_PRIVATE) {
-                 if ((id = ipc_findkey(&sem_ids, key)) != -1) {
-                 /*key found on local node*/
-                        if (semflg & IPC_CREAT && semflg & IPC_EXCL) {
-                                retval = -EEXIST;
-                        } else {
-                                sma = sem_lock(id);
-                                if(sma==NULL)
-                                        BUG();
-                                if(nsems > sma->sem_nsems)
-                                        retval = -EINVAL;
-                                else if (ipcperms(&sma->sem_perm, semflg))
-                                        retval = -EACCES;
-                                else
-                                        retval = sem_buildid(id,
-                                                  sma->sem_perm.seq);
-                                sem_unlock(sma);
-                        }
-                        up(&sem_ids.sem);
-                        return retval;
-                }
-        }
+       down(&sem_ids.sem);
+       if (key != IPC_PRIVATE) {
+               if ((id = ipc_findkey(&sem_ids, key)) != -1) {
+                       /*key found on local node*/
+                       if (semflg & IPC_CREAT && semflg & IPC_EXCL) {
+                               retval = -EEXIST;
+                       } else {
+                               sma = sem_lock(id);
+                               if(sma==NULL)
+                                       BUG();
+                               if(nsems > sma->sem_nsems)
+                                       retval = -EINVAL;
+                               else if (ipcperms(&sma->sem_perm, semflg))
+                                       retval = -EACCES;
+                               else
+                                       retval = sem_buildid(id,
+                                                       sma->sem_perm.seq);
+                               sem_unlock(sma);
+                       }
+                       up(&sem_ids.sem);
+                       return retval;
+               }
+       }
        newid = -1;
        up(&sem_ids.sem);
-        retval = cli_ipcname_getid(NAME_SERVICE_SEM, key, semflg, &newid, 
+       retval = cli_ipcname_getid(NAME_SERVICE_SEM, key, semflg, &newid,
                                        &server, ssi_get_localview(), &create);
        down(&sem_ids.sem);
        if (!retval) {
@@ -344,8 +344,8 @@
                sem_set_svr_node(newid, server);
        }
 out_up:
-        up(&sem_ids.sem);
-        return retval;
+       up(&sem_ids.sem);
+       return retval;
 }
 #endif /* CONFIG_SSI */
 
@@ -360,13 +360,13 @@
 #ifdef CONFIG_SSI
        (void) id;
        (void) err;
-        sma = NULL;
+       sma = NULL;
 
-        /* Do not allow to create semaphore set with no members */
-        if((nsems == 0) && ((semflg & IPC_CREAT) || (key == IPC_PRIVATE)))
-                return -EINVAL;
+       /* Do not allow to create semaphore set with no members */
+       if((nsems == 0) && ((semflg & IPC_CREAT) || (key == IPC_PRIVATE)))
+               return -EINVAL;
 
-        return ssi_semget(key, nsems, semflg, sma);
+       return ssi_semget(key, nsems, semflg, sma);
 #else
 
        down(&sem_ids.sem);
@@ -618,7 +618,7 @@
        int size;
 
 #ifdef CONFIG_SSI
-        for (un = sma->undo; un;) {
+       for (un = sma->undo; un;) {
                u = un;
                un = u->id_next;
                kfree(u);
@@ -718,7 +718,7 @@
 #ifdef CONFIG_SSI
                        if (!ssi_get_localview() && (remote_cmd == FALSE))
                        {
-                               ssi_procstate_get(&pstate);
+                               ssi_procstate_get(&pstate);
                                max_id = 0;
                                nl = clms_get_nsc_nodelist(CLMS_NODE_UP);
                                cookie = CLUSTERNODE_INVAL;
@@ -726,12 +726,12 @@
                                for (;svrnode != CLUSTERNODE_INVAL;
                                   svrnode = nsc_nodelist_get_next(&cookie,nl))
                                {
-                                       if( svrnode != this_node ) 
+                                       if( svrnode != this_node )
                                        {
-                                               memset (arg.__buf, 0, 
+                                               memset (arg.__buf, 0,
                                                        sizeof(struct seminfo));
                                                cli_ripc_semctl(svrnode, &err, 
-1, 0, SEM_INFO, &pstate, &arg, sizeof(union semun));
-                                               if (arg.__buf->semusz) 
+                                               if (arg.__buf->semusz)
                                                {
                                                        seminfo.semusz +=
                                                              arg.__buf->semusz;
@@ -1054,8 +1054,8 @@
 #ifdef CONFIG_SSI
                undo_list = current->sysvsem.undo_list;
 
-               if(undo_list->proc_list && (current->epid == current->pid))
-                       freeundos(undo_list->proc_list);
+               if(undo_list->proc_list && (current->tgid == current->pid))
+                       freeundos(undo_list->proc_list, semid);
                sem_set_svr_node(semid, 0);
 #endif /* CONFIG_SSI */
                err = 0;
@@ -1094,11 +1094,11 @@
        key_t key;
        int tmpcmd = cmd;
        struct sem_undo_list *undo_list;
-       
+
        remote_cmd = FALSE;
        if ((cmd&SEM_INFO) == SEM_INFO || (cmd&IPC_INFO) == IPC_INFO) {
                svr_node = this_node;
-       
+
                if (semid == -1) {
                        remote_cmd=TRUE;
                        semid = 0;
@@ -1136,20 +1136,20 @@
                        int status;
                        ssi_procstate_get(&pstate);
                        arg_len = sizeof((union semun)arg);
-                       status = cli_ripc_semctl(svr_node, &rval, semid, semnum,
-                                        cmd, &pstate, &arg, arg_len);
-                       version = ipc_parse_version(&cmd);
-                       /* If we are able to invalidate server semaphore objects
-                          delete the local objects. */
+                       status = cli_ripc_semctl(svr_node, &rval, semid, semnum,
+                                               cmd, &pstate, &arg, arg_len);
+                       version = ipc_parse_version(&cmd);
+                       /* If we are able to invalidate server semaphore objects
+                          delete the local objects. */
                        if (status) {
                                cmd = tmpcmd;
                                sem_set_svr_node(semid, 0);
                                goto namesvr_go;
-                       } else if (undo_list->proc_list && (rval == 0) && 
+                       } else if (undo_list->proc_list && (rval == 0) &&
                                                        (cmd == IPC_RMID)) {
-                               /* If we are able to invalidate server semaphore
+                               /* If we are able to invalidate server semaphore
                                   objects, delete the local objects. */
-                               freeundos(undo_list->proc_list);
+                               freeundos(undo_list->proc_list, semid);
                                sem_set_svr_node(semid, 0);
                                return rval;
                        }
@@ -1190,14 +1190,14 @@
 }
 
 #ifdef CONFIG_SSI
-static struct sem_undo* freeundos(struct sem_undo* un)
+static struct sem_undo* freeundos(struct sem_undo* un, int semid)
 {
        struct sem_undo* u;
        struct sem_undo** up;
        struct sem_undo_list *undo_list = current->sysvsem.undo_list;
 
        for(up = &undo_list->proc_list;(u=*up);up=&u->proc_next) {
-               if(un==u) {
+               if(u->semid==semid) {
                        un=u->proc_next;
                        *up=un;
                        kfree(u);
@@ -1208,54 +1208,40 @@
        return un->proc_next;
 }
 
-int alloc_undo(struct sem_undo** unp, int semid)
-{
-        int size;
-        struct sem_undo *un;
-       struct sem_undo_list *undo_list = current->sysvsem.undo_list;
-
-        size = sizeof(struct sem_undo);
-
-        un = (struct sem_undo *) kmalloc(size, GFP_KERNEL);
-        if (!un)
-                return -ENOMEM;
-
-        memset(un, 0, size);
-
-        un->semid = semid;
-        un->proc_next = undo_list->proc_list;
-        undo_list->proc_list = un;
-        *unp = un;
-        return 0;
-}
-
 static int alloc_semundo(struct sem_array *sma, struct sem_semundo** unp, int 
semid,int alter)
 {
-        int size, nsems, error;
-        struct sem_semundo *un;
+       int size, nsems, error;
+       struct sem_semundo *un;
 
-        nsems = sma->sem_nsems;
+       nsems = sma->sem_nsems;
 
-        size = sizeof(struct sem_semundo) + sizeof(short)*nsems;
-        sem_unlock(sma);
+       size = sizeof(struct sem_semundo) + sizeof(short)*nsems;
 
-        un = (struct sem_semundo *) kmalloc(size, GFP_KERNEL);
-        if (!un)
-                return -ENOMEM;
+       un = (struct sem_semundo *) kmalloc(size, GFP_KERNEL);
+       if (!un)
+               return -ENOMEM;
 
-        memset(un, 0, size);
-        error = sem_revalidate(semid, sma, nsems, alter ? S_IWUGO : S_IRUGO);
-        if(error) {
-                kfree(un);
-                return error;
-        }
+       memset(un, 0, size);
 
-        un->semadj = (short *) &un[1];
-        un->id_next = sma->undo;
-        un->pid = current->epid;
-        sma->undo = un;
-        *unp = un;
-        return 0;
+       sma = sem_lock(semid);
+       if (!sma) {
+               kfree(un);
+               return -EINVAL;
+       }
+       error = sem_revalidate(semid, sma, nsems, alter ? S_IWUGO : S_IRUGO);
+       if(error) {
+               kfree(un);
+               sem_unlock(sma);
+               return error;
+       }
+
+       un->semadj = (short *) &un[1];
+       un->id_next = sma->undo;
+       un->pid = current->tgid;
+       sma->undo = un;
+       sem_unlock(sma);
+       *unp = un;
+       return 0;
 }
 #endif /* CONFIG_SSI */
 
@@ -1322,7 +1308,6 @@
        return 0;
 }
 
-#ifndef CONFIG_SSI
 static struct sem_undo *lookup_undo(struct sem_undo_list *ulp, int semid)
 {
        struct sem_undo **last, *un;
@@ -1362,6 +1347,11 @@
                goto out;
 
        /* no undo structure around - allocate one. */
+#ifdef CONFIG_SSI
+       /* In SSI the proc sem_undo structure does not have the semadj values */
+       (void)sma;
+       nsems = 0;
+#else
        sma = sem_lock(semid);
        un = ERR_PTR(-EINVAL);
        if(sma==NULL)
@@ -1373,12 +1363,15 @@
        }
        nsems = sma->sem_nsems;
        sem_unlock(sma);
+#endif
 
        new = (struct sem_undo *) kmalloc(sizeof(struct sem_undo) + 
sizeof(short)*nsems, GFP_KERNEL);
        if (!new)
                return ERR_PTR(-ENOMEM);
        memset(new, 0, sizeof(struct sem_undo) + sizeof(short)*nsems);
+#ifndef CONFIG_SSI
        new->semadj = (short *) &new[1];
+#endif
        new->semid = semid;
 
        lock_semundo();
@@ -1388,6 +1381,8 @@
                kfree(new);
                goto out;
        }
+#ifndef CONFIG_SSI
+       /* SSI: sem_array only on the semaphore server */
        error = sem_revalidate(semid, sma, nsems, 0);
        if (error) {
                unlock_semundo();
@@ -1395,21 +1390,23 @@
                un = ERR_PTR(error);
                goto out;
        }
+#endif
        new->proc_next = ulp->proc_list;
        ulp->proc_list = new;
+#ifndef CONFIG_SSI
        new->id_next = sma->undo;
        sma->undo = new;
        sem_unlock(sma);
+#endif
        un = new;
        unlock_semundo();
 out:
        return un;
 }
-#endif /* !CONFIG_SSI */
 
 #ifdef CONFIG_SSI
 long ssi_semop(int semid, struct sembuf *tsops, unsigned nsops,
-              const struct timespec *timeout)
+               const struct timespec *timeout)
 {
        int error = -EINVAL;
        struct sem_array *sma;
@@ -1419,16 +1416,17 @@
        int undos = 0, decrease = 0, alter = 0;
        struct sem_queue queue;
        unsigned long jiffies_left = 0;
+       int max;
 
-        if(nsops > SEMOPM_FAST) {
-                sops = kmalloc(sizeof(*sops)*nsops,GFP_KERNEL);
-                if(sops==NULL)
-                        return -ENOMEM;
-        }
-        if (copy_from_user (sops, tsops, nsops * sizeof(*tsops))) {
-                error=-EFAULT;
-                goto out_free;
-        }
+       if(nsops > SEMOPM_FAST) {
+               sops = kmalloc(sizeof(*sops)*nsops,GFP_KERNEL);
+               if(sops==NULL)
+                       return -ENOMEM;
+       }
+       if (copy_from_user (sops, tsops, nsops * sizeof(*tsops))) {
+               error=-EFAULT;
+               goto out_free;
+       }
        if (timeout) {
                struct timespec _timeout;
                if (copy_from_user(&_timeout, timeout, sizeof(*timeout))) {
@@ -1442,149 +1440,156 @@
                }
                jiffies_left = timespec_to_jiffies(&_timeout);
        }
-        sma = sem_lock(semid);
-        error=-EINVAL;
-        if(sma==NULL)
-                goto out_free;
-        error = -EIDRM;
-        if (sem_checkid(sma,semid))
-                goto out_unlock_free;
-        error = -EFBIG;
-        for (sop = sops; sop < sops + nsops; sop++) {
-                if (sop->sem_num >= sma->sem_nsems)
-                        goto out_unlock_free;
-                if (sop->sem_flg & SEM_UNDO)
-                        undos++;
-                if (sop->sem_op < 0)
-                        decrease = 1;
-                if (sop->sem_op > 0)
-                        alter = 1;
-        }
-        alter |= decrease;
+       max = 0;
+       for (sop = sops; sop < sops + nsops; sop++) {
+               if (sop->sem_num >= max)
+                       max = sop->sem_num;
+               if (sop->sem_flg & SEM_UNDO)
+                       undos++;
+               if (sop->sem_op < 0)
+                       decrease = 1;
+               if (sop->sem_op > 0)
+                       alter = 1;
+       }
+       alter |= decrease;
 
-        error = -EACCES;
-        if (ipcperms(&sma->sem_perm, alter ? S_IWUGO : S_IRUGO))
-                goto out_unlock_free;
-        if (undos) {
-                /* Make sure we have an undo structure
-                 * for this process and this semaphore set.
-                 */
-                un = sma->undo;
-                while(un != NULL) {
-                        if(un->pid==current->epid)
-                                break;
-                         un=un->id_next;
-                }
-                if (!un) { /* No sem_undo struct already exists */
-                        error = alloc_semundo(sma,&un,semid,alter);
-                        if(error)
-                                goto out_free;
-                }
-        } else
-                un = NULL;
+       if (undos) {
+               /* Make sure we have an undo structure
+                * for this process and this semaphore set.
+                */
+               sma = sem_lock(semid);
+               if (sma == NULL)
+                       goto out_free;
+               un = sma->undo;
+               while(un != NULL) {
+                       if(un->pid==current->tgid)
+                               break;
+                       un=un->id_next;
+               }
+               sem_unlock(sma);
+               if (!un) { /* No sem_undo struct already exists */
+                       error = alloc_semundo(sma,&un,semid,alter);
+                       if(error)
+                               goto out_free;
+               }
+       } else
+               un = NULL;
 
-        error = try_atomic_semop (sma, sops, nsops, un, current->epid);
-        if (error <= 0)
-                goto update;
+       sma = sem_lock(semid);
+       error=-EINVAL;
+       if(sma==NULL)
+               goto out_free;
+       error = -EIDRM;
+       if (sem_checkid(sma,semid))
+               goto out_unlock_free;
 
-        /* We need to sleep on this operation, so we put the current
-         * task into the pending queue and go to sleep.
-         */
+       error = -EFBIG;
+       if (max >= sma->sem_nsems)
+               goto out_unlock_free;
 
-        queue.sma = sma;
-        queue.sops = sops;
-        queue.nsops = nsops;
-        queue.undo = un;
-        queue.pid = current->epid;
-        queue.id = semid;
-        if (alter)
-                append_to_queue(sma ,&queue);
-        else
-                prepend_to_queue(sma ,&queue);
+       error = -EACCES;
+       if (ipcperms(&sma->sem_perm, alter ? S_IWUGO : S_IRUGO))
+               goto out_unlock_free;
 
-        for (;;) {
-                struct sem_array* tmp;
-                queue.status = -EINTR;
-                queue.sleeper = current;
-                current->state = TASK_INTERRUPTIBLE;
-                sem_unlock(sma);
+       error = try_atomic_semop (sma, sops, nsops, un, current->tgid);
+       if (error <= 0)
+               goto update;
 
-               if (timeout)
-                       jiffies_left = schedule_timeout(jiffies_left);
-               else
-                       schedule();
+       /* We need to sleep on this operation, so we put the current
+        * task into the pending queue and go to sleep.
+        */
+
+       queue.sma = sma;
+       queue.sops = sops;
+       queue.nsops = nsops;
+       queue.undo = un;
+       queue.pid = current->tgid;
+       queue.id = semid;
+       if (alter)
+               append_to_queue(sma ,&queue);
+       else
+               prepend_to_queue(sma ,&queue);
+
+       queue.status = -EINTR;
+       queue.sleeper = current;
+       current->state = TASK_INTERRUPTIBLE;
+       sem_unlock(sma);
+
+       if (timeout)
+               jiffies_left = schedule_timeout(jiffies_left);
+       else
+               schedule();
+
+       error = queue.status;
+       while(unlikely(error == IN_WAKEUP)) {
+               cpu_relax();
+               error = queue.status;
+       }
+
+       if (error != -EINTR) {
+               /* fast path: update_queue already obtained all requested
+                * resources */
+               goto out_free;
+       }
+
+       sma = sem_lock(semid);
+       if(sma==NULL) {
+               if(queue.prev != NULL)
+                       BUG();
+               error = -EIDRM;
+               goto out_free;
+       }
+
+       /*
+        * If queue.status != -EINTR we are woken up by another process
+        */
+       error = queue.status;
+       if (error != -EINTR) {
+               goto out_unlock_free;
+       }
+
+       /*
+        * If an interrupt occurred we have to clean up the queue
+        */
+       if (timeout && jiffies_left == 0)
+               error = -EAGAIN;
+       remove_from_queue(sma,&queue);
+       goto out_unlock_free;
 
-                tmp = sem_lock(semid);
-                if(tmp==NULL) {
-                        if(queue.prev != NULL)
-                                BUG();
-                        error = -EIDRM;
-                        goto out_free;
-                }
-                /*
-                 * If queue.status == 1 we where woken up and
-                 * have to retry else we simply return.
-                 * If an interrupt occurred we have to clean up the
-                 * queue
-                 *
-                 */
-                if (queue.status == 1)
-                {
-                        error = try_atomic_semop (sma, sops, nsops, un,
-                                                  current->epid);
-                        if (error <= 0)
-                                break;
-                } else {
-                        error = queue.status;
-                        if (queue.prev) /* got Interrupt */
-                                break;
-                        /* Everything done by update_queue */
-                        goto out_unlock_free;
-                }
-        }
-        remove_from_queue(sma,&queue);
 update:
-        if (alter)
-                update_queue (sma);
+       if (alter)
+               update_queue (sma);
 out_unlock_free:
-        sem_unlock(sma);
+       sem_unlock(sma);
 out_free:
-        if(sops != fast_sops)
-                kfree(sops);
-        return error;
+       if(sops != fast_sops)
+               kfree(sops);
+       return error;
 }
 
 int undocheck(struct sembuf* sops,int semid, int nsops)
 {
-        struct sembuf* sop;
-        struct sem_undo *un;
-        int undos=0;
-        int error=0;
-       struct sem_undo_list *undo_list = current->sysvsem.undo_list;
+       struct sembuf* sop;
+       struct sem_undo *un;
+       int undos=0;
+       int error=0;
 
-        for (sop = sops; sop < sops + nsops; sop++) {
-                if (sop->sem_flg & SEM_UNDO)
-                        undos++;
-        }
+       for (sop = sops; sop < sops + nsops; sop++) {
+               if (sop->sem_flg & SEM_UNDO)
+               undos++;
+       }
 
-        if (undos) {
-                /* Make sure we have an undo structure
-                 * for this process and this semaphore set.
-                 */
-                un=undo_list->proc_list;
-                while(un != NULL) {
-                        if(un->semid==semid)
-                                break;
-                        SSI_ASSERT(un->semid != -1);
-                        un=un->proc_next;
-                }
-                if (!un)
-                        error = alloc_undo(&un,semid);
-                else
-                        un = NULL;
-        }
+       if (undos) {
+               /* Make sure we have an undo structure
+                * for this process and this semaphore set.
+                */
+               un = find_undo(semid);
+               if (IS_ERR(un)) {
+                       error = PTR_ERR(un);
+               }
+       }
 
-        return error;
+       return error;
 }
 
 void
@@ -1641,31 +1646,31 @@
                        up(&sem_ids.sem);
                }
        }
-        if (svr_node && (svr_node != this_node)) {
-                ssi_procstate_get(&pstate);
+       if (svr_node && (svr_node != this_node)) {
+               ssi_procstate_get(&pstate);
 
                ics_userbuf_set(&utsops, tsops, nsops * sizeof(*tsops));
                ics_userbuf_set(&utimeout, timeout, sizeof(*timeout));
-                cli_ripc_semop(svr_node, &rval, semid, nsops,
+               cli_ripc_semop(svr_node, &rval, semid, nsops,
                               &pstate, &utsops, &utimeout);
 
-                if(!rval)
-                        undocheck(tsops, semid, nsops);
+               if(!rval)
+                       undocheck(tsops, semid, nsops);
                if (rval == -EINVAL) {
                        sem_set_svr_node(semid, 0);
                        goto namesvr_op_go;
                }
-                return rval;
-        } else {
-                error = ssi_semop(semid, tsops, nsops, timeout);
-                if(!error) {
-                        undocheck(tsops, semid, nsops);
+               return rval;
+       } else {
+               error = ssi_semop(semid, tsops, nsops, timeout);
+               if(!error) {
+                       undocheck(tsops, semid, nsops);
                } else if (error == -EINVAL) {
                        sem_set_svr_node(semid, 0);
                        goto namesvr_op_go;
                }
-               return error;
-        }
+               return error;
+       }
 #else
        if(nsops > SEMOPM_FAST) {
                sops = kmalloc(sizeof(*sops)*nsops,GFP_KERNEL);
@@ -1863,17 +1868,25 @@
  */
 void exit_sem(struct task_struct *tsk)
 {
-#ifdef CONFIG_SSI
+       struct sem_undo_list *undo_list;
        struct sem_undo *u, **up;
+
+       undo_list = tsk->sysvsem.undo_list;
+       if (!undo_list)
+               return;
+
+       if (!atomic_dec_and_test(&undo_list->refcnt))
+               return;
+
+#ifdef CONFIG_SSI
        int rval, flags, view, sz;
        clusternode_t svr_node=0;
        ssi_procstate_t pstate;
        key_t key;
-       struct sem_undo_list *undo_list = current->sysvsem.undo_list;
 
-        for (up = &undo_list->proc_list; (u = *up);
+       for (up = &undo_list->proc_list; (u = *up);
                *up = u->proc_next, kfree(u)) {
-                int semid = u->semid;
+               int semid = u->semid;
 namesvr_semexit_go:
                svr_node = sem_get_svr_node(semid);
                if (!svr_node) {
@@ -1887,26 +1900,15 @@
                        } else if (svr_node)
                                sem_set_svr_node(semid, svr_node);
                }
-                if (svr_node && (svr_node != this_node)) {
+               if (svr_node && (svr_node != this_node)) {
                        sem_set_svr_node(semid, 0);
-                        ssi_procstate_get(&pstate);
-                        cli_ripc_semexit(svr_node, &rval, &pstate, semid, 
current->epid);
-                } else
-                        ssi_semexit(semid, current->pid);
-        }
+                       ssi_procstate_get(&pstate);
+                       cli_ripc_semexit(svr_node, &rval, &pstate, semid, 
current->tgid);
+               } else
+                       ssi_semexit(semid, current->pid);
+       }
        undo_list->proc_list =NULL;
-        return;
 #else
-       struct sem_undo_list *undo_list;
-       struct sem_undo *u, **up;
-
-       undo_list = tsk->sysvsem.undo_list;
-       if (!undo_list)
-               return;
-
-       if (!atomic_dec_and_test(&undo_list->refcnt))
-               return;
-
        /* There's no need to hold the semundo list lock, as current
          * is the last task exiting for this undo list.
         */
@@ -1955,8 +1957,8 @@
 next_entry:
                sem_unlock(sma);
        }
-       kfree(undo_list);
 #endif /* CONFIG_SSI */
+       kfree(undo_list);
 }
 
 #ifdef CONFIG_PROC_FS
@@ -2052,7 +2054,7 @@
                        pos += len;
                        if(pos < offset) {
                                len = 0;
-                               begin = pos;
+                               begin = pos;
                        }
                        if(pos > offset + length)
                                goto done;
@@ -2106,32 +2108,29 @@
        struct sem_array *sma;
        int nsems, i;
 
-        sma = sem_lock(semid);
-        if (sma == NULL)
-                return;
-
-        if (sem_checkid(sma,semid)) {
-                sem_unlock(sma);
-                return;
-        }
+       sma = sem_lock(semid);
+       if (sma == NULL)
+               return;
 
-        for (unp = &sma->undo; (un = *unp); unp = &un->id_next) {
-                   if (pid == un->pid)
-                          goto found;
-        }
-        printk ("sem_exit undo list error id=%d\n", un->pid);
-        goto next_entry;
+       for (unp = &sma->undo; (un = *unp); unp = &un->id_next) {
+               if (pid == un->pid)
+                       goto found;
+       }
+       printk ("sem_exit undo list error id=%d\n", un->pid);
+       goto next_entry;
 
 found:
-        *unp = un->id_next;
-        /* perform adjustments registered in u */
-        nsems = sma->sem_nsems;
-        for (i = 0; i < nsems; i++) {
-                struct sem * sem = &sma->sem_base[i];
-                sem->semval += un->semadj[i];
-                if (sem->semval < 0)
-                   sem->semval = 0; /* shouldn't happen */
-               sem->sempid = pid;
+       *unp = un->id_next;
+       /* perform adjustments registered in u */
+       nsems = sma->sem_nsems;
+       for (i = 0; i < nsems; i++) {
+               struct sem * sem = &sma->sem_base[i];
+               if (un->semadj[i]) {
+                       sem->semval += un->semadj[i];
+                       if (sem->semval < 0)
+                               sem->semval = 0; /* shouldn't happen */
+                       sem->sempid = current->tgid;
+               }
        }
        kfree(un);
        sma->sem_otime = get_seconds();
@@ -2163,19 +2162,19 @@
                        sem_unlock(sma);
                        continue;
                }
-               for (unp = &sma->undo; (un = *unp); unp = &(un->id_next)) {
+               for (unp = &sma->undo; (un = *unp); unp = &(un->id_next)) {
                        if (!process_is_alive(un->pid)) {
-                               nsems = sma->sem_nsems;
-                               for (j = 0; j < nsems; j++) {
-                                       struct sem * sem = &sma->sem_base[i];
-                                       sem->semval += un->semadj[i];
-                                       if (sem->semval < 0) /*shudn't happen */
-                                               sem->semval = 0;
+                               nsems = sma->sem_nsems;
+                               for (j = 0; j < nsems; j++) {
+                                       struct sem * sem = &sma->sem_base[i];
+                                       sem->semval += un->semadj[i];
+                                       if (sem->semval < 0) /*shudn't happen */
+                                               sem->semval = 0;
                                        sem->sempid = un->pid;
                                }
                                sma->sem_otime = get_seconds();
-                               *unp = un->id_next;
-                               kfree (un);
+                               *unp = un->id_next;
+                               kfree (un);
                        }
                }
                sem_unlock(sma);



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl


<Prev in Thread] Current Thread [Next in Thread>