From patchwork Thu Jun 26 19:12:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4430871 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 81D79BEEAA for ; Thu, 26 Jun 2014 19:15:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E35FC2024D for ; Thu, 26 Jun 2014 19:15:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 143F0201BB for ; Thu, 26 Jun 2014 19:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751836AbaFZTPa (ORCPT ); Thu, 26 Jun 2014 15:15:30 -0400 Received: from mail-qg0-f54.google.com ([209.85.192.54]:54036 "EHLO mail-qg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbaFZTP2 (ORCPT ); Thu, 26 Jun 2014 15:15:28 -0400 Received: by mail-qg0-f54.google.com with SMTP id q107so3410901qgd.41 for ; Thu, 26 Jun 2014 12:15:27 -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=VY70G6JV1QaGoHCgbZNkVGXIFubKquKtKTi/WisznPg=; b=i3M47KJMnK1lEHBMES0QQk4JTBEemE261XOTWK1qCn+I2oYedyynOzLa1ix6YF6ode AiwXhEHznH6kg1eXm0IFezqshHKYz4w9pCiYpFB+TrZyJkP8ErQkYeDFM9O4TS6mQ8Sp Xf7RGzrXWhkoRfC6t/7WmSMuq5QNT8Kkvr7KjMBVZKJti8vBGtcbw1AN2xp7r0X0QNAl 7SBfFAEgek+ltzbkVB7ofer/tq0MKVJxz2Nisc6S7w4aZsDAoU0hokfRMkjfMwLYitKe ChOriTg+yF7XQenoM6GjCYjAgEyGH65SieBjLe7jaKXcq3Zs/tAZDrSG6r1LqIZJaNuG IU6w== X-Gm-Message-State: ALoCoQlri0naXDUvbG01xyItAaLuTnoetKNVeBFBwbu2yuluEfUadZ2WsP+47z12kzCCUp6/KKG/ X-Received: by 10.140.86.99 with SMTP id o90mr23966865qgd.14.1403810127722; Thu, 26 Jun 2014 12:15:27 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id 88sm4763039qgh.5.2014.06.26.12.15.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jun 2014 12:15:26 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 075/117] nfsd: add locking to stateowner release Date: Thu, 26 Jun 2014 15:12:55 -0400 Message-Id: <1403810017-16062-76-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403810017-16062-1-git-send-email-jlayton@primarydata.com> References: <1403810017-16062-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 Once we remove the client_mutex, we'll need to properly protect the stateowner reference counts using the cl_lock. 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 503beb3faa6c..92680d6531e7 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -678,6 +678,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; @@ -3030,9 +3032,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); } @@ -3047,11 +3054,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) @@ -4823,11 +4826,7 @@ find_lockowner_str(clientid_t *clid, struct xdr_netobj *owner, 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)