From patchwork Thu Jun 19 14:50: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: 4384181 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 D14D1BEECB for ; Thu, 19 Jun 2014 14:52:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0156020384 for ; Thu, 19 Jun 2014 14:52:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 266CE20396 for ; Thu, 19 Jun 2014 14:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932083AbaFSOwa (ORCPT ); Thu, 19 Jun 2014 10:52:30 -0400 Received: from mail-qg0-f42.google.com ([209.85.192.42]:38888 "EHLO mail-qg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932184AbaFSOwa (ORCPT ); Thu, 19 Jun 2014 10:52:30 -0400 Received: by mail-qg0-f42.google.com with SMTP id e89so2254633qgf.1 for ; Thu, 19 Jun 2014 07:52:29 -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=lMByje3zYX3Im1azGe9xrSY6f4tHRhkFQe18xfvjDVM=; b=X8SJmzmWCJ7X/AalY2Ku/JUII0jlLa04g+7TMwuUlHVx2LPg/df8EjE6OTxzno4kUb VVZdGKhGFqKsXzB6fTLlqR/HSv8OOQyLlGPxJjT6SGbpDEn0DZch6gXVZvLYqLzXCbO0 u9ebLoM7X79BvNOs/Ze2aO6kulliO3b41vfS4WXO76KV1r2ZzF8IY6Oj3csCNsUqqJvc LTX1Gy3BWYsmKS9CFYuUEr53lep60PxT584BgW8yFwm6BGdu/yHDkh29DoepxAIAnnfP wJZtgeAGLgcMA+UPjm0DSjZ2L3MPXDFCtbVOTiVM+k4IVTZCueblZ6gcoRSHSbICJ2tz yyww== X-Gm-Message-State: ALoCoQmpOvOHyLq3fEj4ZLYUKZ6vSxRwc6TRmlWrGeJ+3iRnt2vnKPWncFytpAiIBK16L/90x32M X-Received: by 10.140.102.79 with SMTP id v73mr7642015qge.8.1403189549448; Thu, 19 Jun 2014 07:52:29 -0700 (PDT) Received: from tlielax.poochiereds.net (cpe-107-015-124-230.nc.res.rr.com. [107.15.124.230]) by mx.google.com with ESMTPSA id r60sm3364044qgd.26.2014.06.19.07.52.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jun 2014 07:52:28 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 063/104] nfsd: add locking to stateowner release Date: Thu, 19 Jun 2014 10:50:09 -0400 Message-Id: <1403189450-18729-64-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403189450-18729-1-git-send-email-jlayton@primarydata.com> References: <1403189450-18729-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 858778cbcc7d..e5e1a7abee06 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -563,6 +563,8 @@ static void nfs4_put_stid(struct nfs4_stid *s) { struct nfs4_client *clp = s->sc_client; + lockdep_assert_not_held(&clp->cl_lock); + if (!atomic_dec_and_lock(&s->sc_count, &clp->cl_lock)) { wake_up_all(&close_wq); return; @@ -2923,9 +2925,14 @@ static inline void *alloc_stateowner(struct kmem_cache *slab, struct xdr_netobj static void nfs4_put_stateowner(struct nfs4_stateowner *sop) { - if (!atomic_dec_and_test(&sop->so_count)) + struct nfs4_client *clp = sop->so_client; + + lockdep_assert_not_held(&clp->cl_lock); + + if (!atomic_dec_and_lock(&sop->so_count, &clp->cl_lock)) return; sop->so_unhash(sop); + spin_unlock(&clp->cl_lock); sop->so_free(sop); } @@ -2939,11 +2946,7 @@ static void hash_openowner(struct nfs4_openowner *oo, struct nfs4_client *clp, u static void nfs4_unhash_openowner(struct nfs4_stateowner *so) { - struct nfs4_client *clp = so->so_client; - - spin_lock(&clp->cl_lock); unhash_openowner_locked(openowner(so)); - spin_unlock(&clp->cl_lock); } static void nfs4_free_openowner(struct nfs4_stateowner *so) @@ -4730,11 +4733,7 @@ static void hash_lockowner(struct nfs4_lockowner *lo, unsigned int strhashval, s static void nfs4_unhash_lockowner(struct nfs4_stateowner *sop) { - struct nfs4_client *clp = sop->so_client; - - spin_lock(&clp->cl_lock); unhash_lockowner_locked(lockowner(sop)); - spin_unlock(&clp->cl_lock); } static void nfs4_free_lockowner(struct nfs4_stateowner *sop)