]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
sunrpc: Fix lockd sleeping until timeout
authorAndriy Skulysh <andriy_skulysh@xyratex.com>
Sun, 6 Jan 2013 22:12:15 +0000 (00:12 +0200)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 23 Jan 2013 23:17:39 +0000 (18:17 -0500)
There is a race in enqueueing thread to a pool and
waking up a thread.
lockd doesn't wake up on reception of lock granted callback
if svc_wake_up() is called before lockd's thread is added
to a pool.

Signed-off-by: Andriy Skulysh <Andriy_Skulysh@xyratex.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
include/linux/sunrpc/svc.h
net/sunrpc/svc_xprt.c

index 676ddf53b3eee063b3c6b433de057c1da6894023..1f0216b9a6c9d0cbd556cfa501ec7739997c2361 100644 (file)
@@ -50,6 +50,7 @@ struct svc_pool {
        unsigned int            sp_nrthreads;   /* # of threads in pool */
        struct list_head        sp_all_threads; /* all server threads */
        struct svc_pool_stats   sp_stats;       /* statistics on pool operation */
+       int                     sp_task_pending;/* has pending task */
 } ____cacheline_aligned_in_smp;
 
 /*
index b8e47fac731557bdde5bc5d96250e30a822f6c6c..5a9d40c5a9f32e9859ac793a3ca872b733263fa1 100644 (file)
@@ -499,7 +499,8 @@ void svc_wake_up(struct svc_serv *serv)
                        rqstp->rq_xprt = NULL;
                         */
                        wake_up(&rqstp->rq_wait);
-               }
+               } else
+                       pool->sp_task_pending = 1;
                spin_unlock_bh(&pool->sp_lock);
        }
 }
@@ -634,7 +635,13 @@ struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
                 * long for cache updates.
                 */
                rqstp->rq_chandle.thread_wait = 1*HZ;
+               pool->sp_task_pending = 0;
        } else {
+               if (pool->sp_task_pending) {
+                       pool->sp_task_pending = 0;
+                       spin_unlock_bh(&pool->sp_lock);
+                       return ERR_PTR(-EAGAIN);
+               }
                /* No data pending. Go to sleep */
                svc_thread_enqueue(pool, rqstp);