From patchwork Thu Jun 19 14:50:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4384201 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 416AF9F1D6 for ; Thu, 19 Jun 2014 14:52:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BA362038F for ; Thu, 19 Jun 2014 14:52:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91B9520384 for ; Thu, 19 Jun 2014 14:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932215AbaFSOwe (ORCPT ); Thu, 19 Jun 2014 10:52:34 -0400 Received: from mail-qg0-f43.google.com ([209.85.192.43]:60488 "EHLO mail-qg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932184AbaFSOwd (ORCPT ); Thu, 19 Jun 2014 10:52:33 -0400 Received: by mail-qg0-f43.google.com with SMTP id z60so2237195qgd.30 for ; Thu, 19 Jun 2014 07:52:32 -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=2BlsKgILf+uK3Q3Q6SOiBz/n4N5v9atLDI4GtzZSv4U=; b=gIuBqOJKhp0SDFG3+aLYUoQSoCMcljyQu78zQAmmaNy1cPAmjSQzw87fsLYBrFsrPD QEF4uyoClkjcx8jL8BCYCYfYysroxXzO5qpMMiqVIKioFdIS0i3XHRfa3woxthmISwNC ci/wgeIKTT/Q7uz7y9lihP8bg6iQlas+68lS3xe0/wHg42/vnDY0d1YrK7Gp+9OFVHLB 7r23t0LxgcimjZUxhI5sIfOA0MDw5f9DYGSVU8LHCZpI11pYnvZVoB96mdEG7Gy4wk5b h2OZd5AXSqEwTG8sV0jlM939FJ6mFpFheLvE0chklrQfH80cOzHBbBJ3oAXcPKOA9Low fFVw== X-Gm-Message-State: ALoCoQkMdtKSjzsNjC+r3TU/Yt1gHwP8P6vVgSO7KiuxNcGzT1rm0QjOeAJQwg2X+zs137ObTARd X-Received: by 10.140.33.200 with SMTP id j66mr6596344qgj.81.1403189552122; Thu, 19 Jun 2014 07:52:32 -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.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jun 2014 07:52:31 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 065/104] nfsd: reduce cl_lock trashing in release_openowner Date: Thu, 19 Jun 2014 10:50:11 -0400 Message-Id: <1403189450-18729-66-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 | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 62af2431f118..7bb7dd19e275 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -899,16 +899,10 @@ static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp) static void unhash_open_stateid(struct nfs4_ol_stateid *stp) { - spin_lock(&stp->st_stateowner->so_client->cl_lock); + lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); + unhash_generic_stateid(stp); release_open_stateid_locks(stp); - spin_unlock(&stp->st_stateowner->so_client->cl_lock); -} - -static void release_open_stateid(struct nfs4_ol_stateid *stp) -{ - unhash_open_stateid(stp); - put_generic_stateid(stp); } static void unhash_openowner_locked(struct nfs4_openowner *oo) @@ -932,30 +926,36 @@ static void release_last_closed_stateid(struct nfs4_openowner *oo) } } -static void release_openowner_stateids(struct nfs4_openowner *oo) +static void release_openowner(struct nfs4_openowner *oo) { struct nfs4_ol_stateid *stp; struct nfs4_client *clp = oo->oo_owner.so_client; + struct list_head reaplist; - lockdep_assert_held(&clp->cl_lock); + INIT_LIST_HEAD(&reaplist); + spin_lock(&clp->cl_lock); + unhash_openowner_locked(oo); while (!list_empty(&oo->oo_owner.so_stateids)) { stp = list_first_entry(&oo->oo_owner.so_stateids, struct nfs4_ol_stateid, st_perstateowner); - spin_unlock(&clp->cl_lock); - release_open_stateid(stp); - spin_lock(&clp->cl_lock); + unhash_open_stateid(stp); + /* + * Put the persistent reference to the stateid. If it's + * the last reference, then put it onto the reaplist + * for later destruction. + */ + if (atomic_dec_and_test(&stp->st_stid.sc_count)) { + remove_stid_locked(clp, &stp->st_stid); + list_add(&stp->st_locks, &reaplist); + } } -} - -static void release_openowner(struct nfs4_openowner *oo) -{ - struct nfs4_client *clp = oo->oo_owner.so_client; - - spin_lock(&clp->cl_lock); - unhash_openowner_locked(oo); - release_openowner_stateids(oo); spin_unlock(&clp->cl_lock); + while (!list_empty(&reaplist)) { + stp = list_first_entry(&reaplist, struct nfs4_ol_stateid, st_locks); + list_del(&stp->st_locks); + stp->st_stid.sc_free(&stp->st_stid); + } release_last_closed_stateid(oo); nfs4_put_stateowner(&oo->oo_owner); } @@ -4554,7 +4554,9 @@ static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s) struct nfs4_client *clp = s->st_stid.sc_client; s->st_stid.sc_type = NFS4_CLOSED_STID; + spin_lock(&clp->cl_lock); unhash_open_stateid(s); + spin_unlock(&clp->cl_lock); /* * We can't safely clear the sc_file pointer while there are still