Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=dea7bbb603735ceceb07bb370eca17198faf7c8d
Commit:     dea7bbb603735ceceb07bb370eca17198faf7c8d
Parent:     14b8869ff4f00f105ea76678997b4d49d27baae3
Author:     Anthony Liguori <[EMAIL PROTECTED]>
AuthorDate: Wed Feb 6 19:25:04 2008 -0600
Committer:  Eric Van Hensbergen <[EMAIL PROTECTED]>
CommitDate: Wed Feb 6 19:25:04 2008 -0600

    9p: Convert semaphore to spinlock for p9_idpool
    
    When booting from v9fs, down_interruptible in p9_idpool_get() triggered a 
BUG
    as it was being called with IRQs disabled.  A spinlock seems like the right
    thing to be using since the idr functions go out of their way not to sleep.
    
    This patch eliminates the BUG by converting the semaphore to a spinlock.
    
    Signed-off-by: Anthony Liguori <[EMAIL PROTECTED]>
    Acked-by: Eric Van Hensbergen <[EMAIL PROTECTED]>
---
 net/9p/util.c |   20 ++++++++------------
 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);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to