Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 371681
b: refs/heads/master
c: ce85722
h: refs/heads/master
i:
  371679: 74502a2
v: v3
  • Loading branch information
Al Viro authored and Linus Torvalds committed May 3, 2013
1 parent ebf402d commit b038575
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 20a2078ce7705a6e0722ef5184336eb8657a58d8
refs/heads/master: ce857229e0c3adc211944a13a5579ef84fd7b4af
29 changes: 8 additions & 21 deletions trunk/ipc/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,28 +328,12 @@ static inline void sem_lock_and_putref(struct sem_array *sma)
ipc_rcu_putref(sma);
}

static inline void sem_getref_and_unlock(struct sem_array *sma)
{
WARN_ON_ONCE(!ipc_rcu_getref(sma));
sem_unlock(sma, -1);
}

static inline void sem_putref(struct sem_array *sma)
{
sem_lock_and_putref(sma);
sem_unlock(sma, -1);
}

/*
* Call inside the rcu read section.
*/
static inline void sem_getref(struct sem_array *sma)
{
sem_lock(sma, NULL, -1);
WARN_ON_ONCE(!ipc_rcu_getref(sma));
sem_unlock(sma, -1);
}

static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s)
{
ipc_rmid(&sem_ids(ns), &s->sem_perm);
Expand Down Expand Up @@ -1116,9 +1100,14 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
ushort __user *array = p;
int i;

sem_lock(sma, NULL, -1);
if(nsems > SEMMSL_FAST) {
sem_getref(sma);

if (!ipc_rcu_getref(sma)) {
sem_unlock(sma, -1);
err = -EIDRM;
goto out_free;
}
sem_unlock(sma, -1);
sem_io = ipc_alloc(sizeof(ushort)*nsems);
if(sem_io == NULL) {
sem_putref(sma);
Expand All @@ -1131,9 +1120,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
err = -EIDRM;
goto out_free;
}
} else
sem_lock(sma, NULL, -1);

}
for (i = 0; i < sma->sem_nsems; i++)
sem_io[i] = sma->sem_base[i].semval;
sem_unlock(sma, -1);
Expand Down

0 comments on commit b038575

Please sign in to comment.