Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 83721
b: refs/heads/master
c: dea7bbb
h: refs/heads/master
i:
  83719: cdaa1ae
v: v3
  • Loading branch information
Anthony Liguori authored and Eric Van Hensbergen committed Feb 7, 2008
1 parent 5664864 commit fce9b18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 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: 14b8869ff4f00f105ea76678997b4d49d27baae3
refs/heads/master: dea7bbb603735ceceb07bb370eca17198faf7c8d
20 changes: 8 additions & 12 deletions trunk/net/9p/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <net/9p/9p.h>

struct p9_idpool {
struct semaphore lock;
spinlock_t lock;
struct idr pool;
};

Expand All @@ -45,7 +45,7 @@ struct p9_idpool *p9_idpool_create(void)
if (!p)
return ERR_PTR(-ENOMEM);

init_MUTEX(&p->lock);
spin_lock_init(&p->lock);
idr_init(&p->pool);

return p;
Expand All @@ -71,19 +71,17 @@ int p9_idpool_get(struct p9_idpool *p)
{
int i = 0;
int error;
unsigned int flags;

retry:
if (idr_pre_get(&p->pool, GFP_KERNEL) == 0)
return 0;

if (down_interruptible(&p->lock) == -EINTR) {
P9_EPRINTK(KERN_WARNING, "Interrupted while locking\n");
return -1;
}
spin_lock_irqsave(&p->lock, flags);

/* no need to store exactly p, we just need something non-null */
error = idr_get_new(&p->pool, p, &i);
up(&p->lock);
spin_unlock_irqrestore(&p->lock, flags);

if (error == -EAGAIN)
goto retry;
Expand All @@ -104,12 +102,10 @@ EXPORT_SYMBOL(p9_idpool_get);

void p9_idpool_put(int id, struct p9_idpool *p)
{
if (down_interruptible(&p->lock) == -EINTR) {
P9_EPRINTK(KERN_WARNING, "Interrupted while locking\n");
return;
}
unsigned int flags;
spin_lock_irqsave(&p->lock, flags);
idr_remove(&p->pool, id);
up(&p->lock);
spin_unlock_irqrestore(&p->lock, flags);
}
EXPORT_SYMBOL(p9_idpool_put);

Expand Down

0 comments on commit fce9b18

Please sign in to comment.