From patchwork Wed Dec 26 15:09:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andriy Skulysh X-Patchwork-Id: 1911151 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A2C7E3FC66 for ; Wed, 26 Dec 2012 15:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752742Ab2LZPRH (ORCPT ); Wed, 26 Dec 2012 10:17:07 -0500 Received: from mail-oa0-f44.google.com ([209.85.219.44]:55884 "EHLO mail-oa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752527Ab2LZPRH (ORCPT ); Wed, 26 Dec 2012 10:17:07 -0500 Received: by mail-oa0-f44.google.com with SMTP id n5so8157903oag.17 for ; Wed, 26 Dec 2012 07:17:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=gCI1PX9WBjHgkXpN5Ecevuwlt9+echA2Qg57MRLAzzM=; b=KWAtSeHGXGVAI8Xb0CGE3o3ziMPvTj6u20YjkZRueK8y/dC7uXqD8G8n2KLLFOcAyo zU8Dn/B4DQUdw1TpzESirDLNuGOjTzuewQL9hshINaBgBOK1J33v/N9NHUyVDa3bENdL 51Y2xLLDwZeD4hAmtZCzvCYQylcxKYQFdm88OmHtTp9/wwGaf/9DycJQJse31ZFIGrYl Q4r6jwyOLx/3g5jueWt5bWKXh8Q79tNx9Yn2nVQ2LkWnORvtocpB1W3XvUpky0NeK41d pZT/UXeuhL/9EZ8MaEsPA8bvXcmzWWnop+tfvHfGVb59gMbVOP1GwK0nNBVYAT1Ojhz8 fOzg== MIME-Version: 1.0 Received: by 10.60.172.200 with SMTP id be8mr10994677oec.0.1356534547582; Wed, 26 Dec 2012 07:09:07 -0800 (PST) Received: by 10.76.8.7 with HTTP; Wed, 26 Dec 2012 07:09:07 -0800 (PST) Date: Wed, 26 Dec 2012 17:09:07 +0200 Message-ID: Subject: [PATCH 1/1] sunrpc: Fix lockd sleeping until timeout From: Andriy Skulysh To: Trond Myklebust , "J. Bruce Fields" , linux-nfs@vger.kernel.org Cc: linux-kernel@vger.kernel.org X-Gm-Message-State: ALoCoQlHwZWCvCz/hHpGxbdv0+L9r9JHBvTdPT0T147dvnGOrGPq8WuMFKKGELDpcDkLHSi27CfJ Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- include/linux/sunrpc/svc.h | 1 + net/sunrpc/svc_xprt.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 676ddf5..1f0216b 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -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; /* diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index b8e47fa..c7ab6f5 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -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 -EAGAIN; + } /* No data pending. Go to sleep */ svc_thread_enqueue(pool, rqstp);