Skip to content

Commit 35525b7

Browse files
Andriy SkulyshJ. Bruce Fields
authored andcommitted
sunrpc: Fix lockd sleeping until timeout
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>
1 parent 624ab46 commit 35525b7

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎include/linux/sunrpc/svc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct svc_pool {
5050
unsigned int sp_nrthreads; /* # of threads in pool */
5151
struct list_head sp_all_threads; /* all server threads */
5252
struct svc_pool_stats sp_stats; /* statistics on pool operation */
53+
int sp_task_pending;/* has pending task */
5354
} ____cacheline_aligned_in_smp;
5455

5556
/*

‎net/sunrpc/svc_xprt.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ void svc_wake_up(struct svc_serv *serv)
499499
rqstp->rq_xprt = NULL;
500500
*/
501501
wake_up(&rqstp->rq_wait);
502-
}
502+
} else
503+
pool->sp_task_pending = 1;
503504
spin_unlock_bh(&pool->sp_lock);
504505
}
505506
}
@@ -634,7 +635,13 @@ struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
634635
* long for cache updates.
635636
*/
636637
rqstp->rq_chandle.thread_wait = 1*HZ;
638+
pool->sp_task_pending = 0;
637639
} else {
640+
if (pool->sp_task_pending) {
641+
pool->sp_task_pending = 0;
642+
spin_unlock_bh(&pool->sp_lock);
643+
return ERR_PTR(-EAGAIN);
644+
}
638645
/* No data pending. Go to sleep */
639646
svc_thread_enqueue(pool, rqstp);
640647

0 commit comments

Comments
 (0)