From patchwork Wed Jul 30 12:27:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4647981 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5A77AC0338 for ; Wed, 30 Jul 2014 12:28:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D229200E9 for ; Wed, 30 Jul 2014 12:28:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB46620121 for ; Wed, 30 Jul 2014 12:28:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753320AbaG3M17 (ORCPT ); Wed, 30 Jul 2014 08:27:59 -0400 Received: from mail-qg0-f41.google.com ([209.85.192.41]:53718 "EHLO mail-qg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754673AbaG3M14 (ORCPT ); Wed, 30 Jul 2014 08:27:56 -0400 Received: by mail-qg0-f41.google.com with SMTP id q107so1321222qgd.28 for ; Wed, 30 Jul 2014 05:27:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=emDHQAWjXW7Zt5P+Rb1pDOLmQPZBLrnx7jPWwRsb7Xg=; b=HUGRYkiQneFNtfKgjPzpizh0cL+lBabgzm0xnEUi+R5qlykAMv1/elwqWYwTLgS0kc 61GxRHGaaYdh8Z8tWEAyR/u+UoX7A8lqTo1jdECbp0JF4tC/OIBdr+OdiLQhsZuu1DcJ mcZpnFkiG0yhtVY/pAs7bra69xIDLNVueJySwbRGSQjbtXOHdq0ym5XirwVoiHUmpBJV Q8eK2oH+xsTgWfldoXvQcGq/MTWwfF92+0S3IeXnFAO1D/z8iw6JRyOhaq1pkiynRyk0 BS/8l2T/SK+Ko1JV8iV6e5zCdo0HuXkmbwzhkvo5k1I2NZ2fxr1DT1wpTnN0YWXSDgdq gsbA== X-Gm-Message-State: ALoCoQkhkqMcPQMo9Ya3bREbgKakCcwKzl77Sw1dPnpvFQuuNWQfggwV3dTR3ird0t9zF9wb9+yD X-Received: by 10.224.111.193 with SMTP id t1mr6059099qap.103.1406723275896; Wed, 30 Jul 2014 05:27:55 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id t23sm2384767qge.13.2014.07.30.05.27.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 05:27:54 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org, Trond Myklebust Subject: [PATCH 08/37] nfsd: Ensure lookup_clientid() takes client_lock Date: Wed, 30 Jul 2014 08:27:09 -0400 Message-Id: <1406723258-8512-9-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406723258-8512-1-git-send-email-jlayton@primarydata.com> References: <1406723258-8512-1-git-send-email-jlayton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Trond Myklebust Ensure that the client lookup is done safely under the client_lock, so we're not relying on the client_mutex. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 68383b09c7dc..f9d077d800ee 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3451,13 +3451,17 @@ static __be32 lookup_clientid(clientid_t *clid, * will be false. */ WARN_ON_ONCE(cstate->session); + spin_lock(&nn->client_lock); found = find_confirmed_client(clid, false, nn); - if (!found) + if (!found) { + spin_unlock(&nn->client_lock); return nfserr_expired; + } + atomic_inc(&found->cl_refcount); + spin_unlock(&nn->client_lock); /* Cache the nfs4_client in cstate! */ cstate->clp = found; - atomic_inc(&found->cl_refcount); return nfs_ok; }