All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Bruce Fields <bfields@redhat.com>
Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 4/8] nfsd: refactor lookup_clientid
Date: Wed, 20 Jan 2021 21:02:25 +0000	[thread overview]
Message-ID: <D646BC66-D79B-4EA7-807E-A60B5255FFF9@oracle.com> (raw)
In-Reply-To: <1611095729-31104-5-git-send-email-bfields@redhat.com>



> On Jan 19, 2021, at 5:35 PM, J. Bruce Fields <bfields@redhat.com> wrote:
> 
> From: "J. Bruce Fields" <bfields@redhat.com>
> 
> I think set_client is a better name, and the lookup itself I want to
> use somewhere else.

Should this be two patches?
- Rename lookup_clientid() to set_client()
- Refactor the lookup_clientid() helper

nfs4state.c stops compiling with this patch. See below.


> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> ---
> fs/nfsd/nfs4state.c | 50 ++++++++++++++++++++++-----------------------
> 1 file changed, 24 insertions(+), 26 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index ba955bbf21df..d7128e16c86e 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -4633,40 +4633,40 @@ static __be32 nfsd4_check_seqid(struct nfsd4_compound_state *cstate, struct nfs4
> 	return nfserr_bad_seqid;
> }
> 
> -static __be32 lookup_clientid(clientid_t *clid,
> +static struct nfs4_client *lookup_clientid(clientid_t *clid, bool sessions,
> +						struct nfsd_net *nn)
> +{
> +	struct nfs4_client *found;
> +
> +	spin_lock(&nn->client_lock);
> +	found = find_confirmed_client(clid, sessions, nn);
> +	if (found)
> +		atomic_inc(&found->cl_rpc_users);
> +	spin_unlock(&nn->client_lock);
> +	return found;
> +}
> +
> +static __be32 set_client(clientid_t *clid,
> 		struct nfsd4_compound_state *cstate,
> 		struct nfsd_net *nn,
> 		bool sessions)
> {
> -	struct nfs4_client *found;
> -
> 	if (cstate->clp) {
> -		found = cstate->clp;
> -		if (!same_clid(&found->cl_clientid, clid))
> +		if (!same_clid(&cstate->clp->cl_clientid, clid))
> 			return nfserr_stale_clientid;
> 		return nfs_ok;
> 	}
> -
> 	if (STALE_CLIENTID(clid, nn))
> 		return nfserr_stale_clientid;
> -
> 	/*
> 	 * For v4.1+ we get the client in the SEQUENCE op. If we don't have one
> 	 * cached already then we know this is for is for v4.0 and "sessions"
> 	 * will be false.
> 	 */
> 	WARN_ON_ONCE(cstate->session);
> -	spin_lock(&nn->client_lock);
> -	found = find_confirmed_client(clid, sessions, nn);
> -	if (!found) {
> -		spin_unlock(&nn->client_lock);
> +	cstate->clp = lookup_clientid(clid, sessions, nn);
> +	if (!cstate->clp)
> 		return nfserr_expired;
> -	}
> -	atomic_inc(&found->cl_rpc_users);
> -	spin_unlock(&nn->client_lock);
> -
> -	/* Cache the nfs4_client in cstate! */
> -	cstate->clp = found;
> 	return nfs_ok;
> }
> 
> @@ -4688,7 +4688,7 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
> 	if (open->op_file == NULL)
> 		return nfserr_jukebox;
> 
> -	status = lookup_clientid(clientid, cstate, nn, false);
> +	status = set_client(clientid, cstate, nn, false);
> 	if (status)
> 		return status;
> 	clp = cstate->clp;
> @@ -5298,7 +5298,7 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> 	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
> 
> 	trace_nfsd_clid_renew(clid);
> -	status = lookup_clientid(clid, cstate, nn, false);
> +	status = set_client(clid, cstate, nn, false);
> 	if (status)
> 		return status;
> 	clp = cstate->clp;
> @@ -5681,8 +5681,7 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
> 	if (ZERO_STATEID(stateid) || ONE_STATEID(stateid) ||
> 		CLOSE_STATEID(stateid))
> 		return nfserr_bad_stateid;
> -	status = lookup_clientid(&stateid->si_opaque.so_clid, cstate, nn,
> -				 false);
> +	status = set_client(&stateid->si_opaque.so_clid, cstate, nn, false);
> 	if (status == nfserr_stale_clientid) {
> 		if (cstate->session)
> 			return nfserr_bad_stateid;
> @@ -5821,7 +5820,7 @@ static __be32 find_cpntf_state(struct nfsd_net *nn, stateid_t *st,
> 
> 	cps->cpntf_time = ktime_get_boottime_seconds();
> 	memset(&cstate, 0, sizeof(cstate));
> -	status = lookup_clientid(&cps->cp_p_clid, &cstate, nn, true);
> +	status = set_clientid(&cps->cp_p_clid, &cstate, nn, true);

This doesn't compile. I think you meant set_client() here.


> 	if (status)
> 		goto out;
> 	status = nfsd4_lookup_stateid(&cstate, &cps->cp_p_stateid,
> @@ -6900,8 +6899,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> 		 return nfserr_inval;
> 
> 	if (!nfsd4_has_session(cstate)) {
> -		status = lookup_clientid(&lockt->lt_clientid, cstate, nn,
> -					 false);
> +		status = set_client(&lockt->lt_clientid, cstate, nn, false);
> 		if (status)
> 			goto out;
> 	}
> @@ -7085,7 +7083,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
> 	dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n",
> 		clid->cl_boot, clid->cl_id);
> 
> -	status = lookup_clientid(clid, cstate, nn, false);
> +	status = set_client(clid, cstate, nn, false);
> 	if (status)
> 		return status;
> 
> @@ -7232,7 +7230,7 @@ nfs4_check_open_reclaim(clientid_t *clid,
> 	__be32 status;
> 
> 	/* find clientid in conf_id_hashtbl */
> -	status = lookup_clientid(clid, cstate, nn, false);
> +	status = set_clientid(clid, cstate, nn, false);

Ditto.


> 	if (status)
> 		return nfserr_reclaim_bad;
> 
> -- 
> 2.29.2
> 

--
Chuck Lever




  reply	other threads:[~2021-01-20 22:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 22:35 [PATCH 0/8] miscellaneous nfsd4 state cleanup J. Bruce Fields
2021-01-19 22:35 ` [PATCH 1/8] nfsd4: simplify process_lookup1 J. Bruce Fields
2021-01-19 22:35 ` [PATCH 2/8] nfsd: simplify process_lock J. Bruce Fields
2021-01-20 21:01   ` Chuck Lever
2021-01-20 21:25     ` J. Bruce Fields
2021-01-19 22:35 ` [PATCH 3/8] nfsd: simplify nfsd_renew J. Bruce Fields
2021-01-19 22:35 ` [PATCH 4/8] nfsd: refactor lookup_clientid J. Bruce Fields
2021-01-20 21:02   ` Chuck Lever [this message]
2021-01-20 23:01     ` J. Bruce Fields
2021-01-21  1:54       ` Chuck Lever
2021-01-21 18:49         ` [PATCH 1/9] nfsd4: simplify process_lookup1 J. Bruce Fields
2021-01-21 18:49           ` [PATCH 2/9] nfsd: simplify process_lock J. Bruce Fields
2021-01-21 18:49           ` [PATCH 3/9] nfsd: simplify nfsd_renew J. Bruce Fields
2021-01-21 18:49           ` [PATCH 4/9] nfsd: rename lookup_clientid->set_client J. Bruce Fields
2021-01-21 18:49           ` [PATCH 5/9] nfsd: refactor lookup_clientid J. Bruce Fields
2021-01-21 18:49           ` [PATCH 6/9] nfsd: find_cpntf_state cleanup J. Bruce Fields
2021-01-21 18:49           ` [PATCH 7/9] nfsd: remove unused set_clientid argument J. Bruce Fields
2021-01-21 20:20             ` Chuck Lever
2021-01-21 20:42               ` J. Bruce Fields
2021-01-21 22:57                 ` [PATCH v3 1/9] nfsd4: simplify process_lookup1 J. Bruce Fields
2021-01-21 22:57                   ` [PATCH v3 2/9] nfsd: simplify process_lock J. Bruce Fields
2021-01-21 22:57                   ` [PATCH v3 3/9] nfsd: simplify nfsd_renew J. Bruce Fields
2021-01-21 22:57                   ` [PATCH v3 4/9] nfsd: rename lookup_clientid->set_client J. Bruce Fields
2021-01-21 22:57                   ` [PATCH v3 5/9] nfsd: refactor set_client J. Bruce Fields
2021-01-21 22:57                   ` [PATCH v3 6/9] nfsd: find_cpntf_state cleanup J. Bruce Fields
2021-01-21 22:57                   ` [PATCH v3 7/9] nfsd: remove unused set_client argument J. Bruce Fields
2021-01-21 22:57                   ` [PATCH v3 8/9] nfsd: simplify nfsd4_check_open_reclaim J. Bruce Fields
2021-01-21 22:57                   ` [PATCH v3 9/9] nfsd: cstate->session->se_client -> cstate->clp J. Bruce Fields
2021-01-21 23:34                     ` Chuck Lever
2021-01-21 18:49           ` [PATCH 8/9] nfsd: simplify nfsd4_check_open_reclaim J. Bruce Fields
2021-01-21 18:49           ` [PATCH 9/9] nfsd: cstate->session->se_client -> cstate->clp J. Bruce Fields
2021-01-19 22:35 ` [PATCH 5/8] nfsd: find_cpntf_state cleanup J. Bruce Fields
2021-01-19 22:35 ` [PATCH 6/8] nfsd: remove unused set_clientid argument J. Bruce Fields
2021-01-19 22:35 ` [PATCH 7/8] nfsd: simplify nfsd4_check_open_reclaim J. Bruce Fields
2021-01-19 22:35 ` [PATCH 8/8] nfsd: cstate->session->se_client -> cstate->clp J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D646BC66-D79B-4EA7-807E-A60B5255FFF9@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.