summaryrefslogtreecommitdiffstats
path: root/net/9p/util.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 18:06:58 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 18:06:58 -0800
commit488b5ec871191359b9b79262a3d48456dae7ea5f (patch)
treeaf9d1ca5d16e7cd195cf132e7af74222dc00a6f9 /net/9p/util.c
parenta80a438bd08827d0581fca849f3e4e539a22b39c (diff)
parent727674435470537a5e75e5f81f96d5d97de57956 (diff)
downloadop-kernel-dev-488b5ec871191359b9b79262a3d48456dae7ea5f.zip
op-kernel-dev-488b5ec871191359b9b79262a3d48456dae7ea5f.tar.gz
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs: 9p: fix p9_printfcall export 9p: transport API reorganization 9p: add remove function to trans_virtio 9p: Convert semaphore to spinlock for p9_idpool 9p: fix mmap to be read-only 9p: add support for sticky bit 9p: Fix soft lockup in virtio transport 9p: fix bug in attach-per-user 9p: block-based virtio client 9p: create transport rpc cut-thru 9p: fix bug in p9_clone_stat
Diffstat (limited to 'net/9p/util.c')
-rw-r--r--net/9p/util.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/net/9p/util.c b/net/9p/util.c
index 22077b7..ef72155 100644
--- a/net/9p/util.c
+++ b/net/9p/util.c
@@ -33,7 +33,7 @@
#include <net/9p/9p.h>
struct p9_idpool {
- struct semaphore lock;
+ spinlock_t lock;
struct idr pool;
};
@@ -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;
@@ -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;
@@ -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);
OpenPOWER on IntegriCloud