Return-Path: linux-nfs-owner@vger.kernel.org Received: from mail-qa0-f44.google.com ([209.85.216.44]:61831 "EHLO mail-qa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758027AbaFSOwA (ORCPT ); Thu, 19 Jun 2014 10:52:00 -0400 Received: by mail-qa0-f44.google.com with SMTP id hw13so2046113qab.3 for ; Thu, 19 Jun 2014 07:52:00 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 043/104] NFSd: Migrate the stateid reference into nfs4_lookup_stateid() Date: Thu, 19 Jun 2014 10:49:49 -0400 Message-Id: <1403189450-18729-44-git-send-email-jlayton@primarydata.com> 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 List-ID: From: Trond Myklebust Allow nfs4_lookup_stateid to take the stateid reference, instead of having all the callers do so. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4state.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 7ce4edcc0e61..25af8b7628ae 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3998,6 +3998,8 @@ static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, *s = find_stateid_by_type(cl, stateid, typemask); if (!*s) return nfserr_bad_stateid; + /* FIXME: move into find_stateid_by_type */ + atomic_inc(&(*s)->sc_count); return nfs_ok; } @@ -4031,7 +4033,7 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate, status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, &s, cstate->minorversion, nn); if (status) - goto out; + goto unlock_state; status = check_stateid_generation(stateid, &s->sc_stateid, nfsd4_has_session(cstate)); if (status) goto out; @@ -4078,6 +4080,8 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate, if (file) *filpp = file; out: + nfs4_put_stid(s); +unlock_state: nfs4_unlock_state(); return status; } @@ -4209,11 +4213,10 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp); - if (!status) { - /* FIXME: move into find_stateid_by_type */ - atomic_inc(&stp->st_stid.sc_count); + if (!status) *stpp = stp; - } + else + put_generic_stateid(stp); return status; } @@ -4477,9 +4480,11 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, dp = delegstateid(s); status = check_stateid_generation(stateid, &dp->dl_stid.sc_stateid, nfsd4_has_session(cstate)); if (status) - goto out; + goto put_stateid; unhash_and_destroy_delegation(dp); +put_stateid: + nfs4_put_delegation(dp); out: nfs4_unlock_state(); -- 1.9.3