From patchwork Thu Jun 26 19:12:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4430341 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 D17289F2C8 for ; Thu, 26 Jun 2014 19:14:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 027D52024D for ; Thu, 26 Jun 2014 19:14:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 198D0202D1 for ; Thu, 26 Jun 2014 19:14:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751732AbaFZTOR (ORCPT ); Thu, 26 Jun 2014 15:14:17 -0400 Received: from mail-qg0-f47.google.com ([209.85.192.47]:47649 "EHLO mail-qg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751672AbaFZTOR (ORCPT ); Thu, 26 Jun 2014 15:14:17 -0400 Received: by mail-qg0-f47.google.com with SMTP id q108so3482075qgd.34 for ; Thu, 26 Jun 2014 12:14:16 -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=Aaz3QLSqLg66ESxMEEOiaXMRZ51ywUtALT6LfgvZKRE=; b=fQBuG/wqqzlemQrSE4jDrMLabpi51XUSrbWTrw8QcBgyjtUM62BUK8EziigI/L2jCb 5A9fFYYD4YG4GYZ2fiQhvWz/Ywc8D9UpYOn9tfvzG1WBX7/8IK/aEm8DO8IXmEQhz6LC jTHOxIDNyx/LlzTHU0ejgiwF82FGClZr/8Gp4/ZMj/7Vz0FsHlm5ciiWB+3UTUZjN2hM G9JGkg75+5TCCYp4W79A010ueKdy189JW5grkZGPbD8dHxQh/bcAsUlzGXHgUmLwYHY5 TBpYt/x//MSENuqNgA0ZqsAeueRheQm9aXbMZfmE0Erjj0WtGmXE+qh1tasitGO3m5ao Z34g== X-Gm-Message-State: ALoCoQlnaYfMwypLBcmYDiXJa9KJJnUqB1AZbZmnbiO8aykT8oW2s1GXLDc+3uAdLJQw4wLEK75I X-Received: by 10.140.89.197 with SMTP id v63mr22642387qgd.71.1403810056319; Thu, 26 Jun 2014 12:14:16 -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.14.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jun 2014 12:14:15 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH v2 022/117] nfsd: Cache the client that was looked up in lookup_clientid() Date: Thu, 26 Jun 2014 15:12:02 -0400 Message-Id: <1403810017-16062-23-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 From: Trond Myklebust We want to use the nfsd4_compound_state to cache the nfs4_client in order to optimise away extra lookups of the clid. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index f782ed5cad63..fb78d1ab2655 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3521,15 +3521,31 @@ void nfsd4_cleanup_open_state(struct nfsd4_open *open, __be32 status) free_generic_stateid(open->op_stp); } -static __be32 lookup_clientid(clientid_t *clid, bool session, struct nfsd_net *nn, struct nfs4_client **clp) +static __be32 lookup_clientid(clientid_t *clid, + struct nfsd4_compound_state *cstate, + struct nfsd_net *nn) { struct nfs4_client *found; - if (STALE_CLIENTID(clid, nn)) - return nfserr_stale_clientid; - found = find_confirmed_client(clid, session, nn); - if (clp) - *clp = found; + if (cstate->clp != NULL) { + found = cstate->clp; + if (!same_clid(&found->cl_clientid, clid)) + return nfserr_stale_clientid; + } else { + if (STALE_CLIENTID(clid, nn)) + return nfserr_stale_clientid; + /* + * Usually for v4.1+ we get the client in the SEQUENCE op, so + * if we don't have one cached already then we know this is for + * is for v4.0 and "sessions" will be false. + */ + found = find_confirmed_client(clid, false, nn); + /* Cache the nfs4_client in cstate! */ + if (found) { + cstate->clp = found; + atomic_inc(&found->cl_refcount); + } + } return found ? nfs_ok : nfserr_expired; } @@ -3544,9 +3560,10 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfs4_lock_state(); dprintk("process_renew(%08x/%08x): starting\n", clid->cl_boot, clid->cl_id); - status = lookup_clientid(clid, cstate->minorversion, nn, &clp); + status = lookup_clientid(clid, cstate, nn); if (status) goto out; + clp = cstate->clp; status = nfserr_cb_path_down; if (!list_empty(&clp->cl_delegations) && clp->cl_cb_state != NFSD4_CB_UP) @@ -3809,22 +3826,19 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid, unsigned char typemask, struct nfs4_stid **s, struct nfsd_net *nn) { - struct nfs4_client *cl; __be32 status; - bool sessions = cstate->minorversion != 0; if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) return nfserr_bad_stateid; - status = lookup_clientid(&stateid->si_opaque.so_clid, sessions, - nn, &cl); + status = lookup_clientid(&stateid->si_opaque.so_clid, cstate, nn); if (status == nfserr_stale_clientid) { - if (sessions) + if (cstate->session) return nfserr_bad_stateid; return nfserr_stale_stateid; } if (status) return status; - *s = find_stateid_by_type(cl, stateid, typemask); + *s = find_stateid_by_type(cstate->clp, stateid, typemask); if (!*s) return nfserr_bad_stateid; return nfs_ok; @@ -4674,7 +4688,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfs4_lock_state(); if (!nfsd4_has_session(cstate)) { - status = lookup_clientid(&lockt->lt_clientid, false, nn, NULL); + status = lookup_clientid(&lockt->lt_clientid, cstate, nn); if (status) goto out; } @@ -4844,7 +4858,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, nfs4_lock_state(); - status = lookup_clientid(clid, cstate->minorversion, nn, NULL); + status = lookup_clientid(clid, cstate, nn); if (status) goto out;