From: "J. Bruce Fields" <bfields@fieldses.org>
To: Benny Halevy <bhalevy@panasas.com>
Cc: Boaz Harrosh <bharrosh@panasas.com>,
linux-nfs@vger.kernel.org, pnfs@linux-nfs.org
Subject: Re: [pnfs] [PATCH] nfsd41: renew_client must be called under the state lock
Date: Thu, 27 Aug 2009 17:16:39 -0400 [thread overview]
Message-ID: <20090827211639.GE11721@fieldses.org> (raw)
In-Reply-To: <4A96B62E.3040708@panasas.com>
On Thu, Aug 27, 2009 at 07:37:02PM +0300, Benny Halevy wrote:
> On Aug. 27, 2009, 0:02 +0300, "J. Bruce Fields" <bfields@fieldses.org> wrote:
> > On Wed, Aug 26, 2009 at 11:20:48AM +0300, Boaz Harrosh wrote:
> >> On 08/26/2009 12:59 AM, J. Bruce Fields wrote:
> >>> commit fdf7875040506ca7e595dffef56cbd81ae6b384b
> >>> Author: Benny Halevy <bhalevy@panasas.com>
> >>> Date: Thu Aug 20 03:21:56 2009 +0300
> >>>
> >>> nfsd41: renew_client must be called under the state lock
> >>>
> >>> Until we work out the state locking so we can use a spin lock to protect
> >>> the cl_lru, we need to take the state_lock to renew the client.
> >>>
> >>> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
> >>> [nfsd41: Do not renew state on error]
> >>> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
> >>> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
> >>> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
> >>>
> >>> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> >>> index d2a0524..8e5ac49 100644
> >>> --- a/fs/nfsd/nfs4state.c
> >>> +++ b/fs/nfsd/nfs4state.c
> >>> @@ -1463,12 +1463,16 @@ nfsd4_sequence(struct svc_rqst *rqstp,
> >>> spin_lock(&sessionid_lock);
> >>> status = nfserr_badsession;
> >>> session = find_in_sessionid_hashtbl(&seq->sessionid);
> >>> - if (!session)
> >>> - goto out;
> >>> + if (!session) {
> >>> + spin_unlock(&sessionid_lock);
> >>> + goto err;
> >>> + }
> >>>
> >>> status = nfserr_badslot;
> >>> - if (seq->slotid >= session->se_fchannel.maxreqs)
> >>> - goto out;
> >>> + if (seq->slotid >= session->se_fchannel.maxreqs) {
> >>> + spin_unlock(&sessionid_lock);
> >>> + goto err;
> >>> + }
> >>>
> >> A spin_unlock is a big and delicate inlined code site
> >> Why not do a "goto err_unlock" or something
> >
> > Yes, we could add an
> >
> > err_unlock:
> > spin_unlock(&sessionid_lock);
> > goto err;
> >
> > at the end. It still seems little delicate.
> >
> > How about the following (on top of Benny's patch), which sends all the
> > unlock cases to one label? (Disclaimer: untested. And this depends on
> > the assumption that cstate->session is NULL on entry to this function,
> > which I haven't checked.)
> >
> > --b.
> >
> > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > index 8e5ac49..5f634d2 100644
> > --- a/fs/nfsd/nfs4state.c
> > +++ b/fs/nfsd/nfs4state.c
> > @@ -1463,16 +1463,12 @@ nfsd4_sequence(struct svc_rqst *rqstp,
> > spin_lock(&sessionid_lock);
> > status = nfserr_badsession;
> > session = find_in_sessionid_hashtbl(&seq->sessionid);
> > - if (!session) {
> > - spin_unlock(&sessionid_lock);
> > - goto err;
> > - }
> > + if (!session)
> > + goto out;
> >
> > status = nfserr_badslot;
> > - if (seq->slotid >= session->se_fchannel.maxreqs) {
> > - spin_unlock(&sessionid_lock);
> > - goto err;
> > - }
> > + if (seq->slotid >= session->se_fchannel.maxreqs)
> > + goto out;
> >
> > slot = &session->se_slots[seq->slotid];
> > dprintk("%s: slotid %d\n", __func__, seq->slotid);
> > @@ -1487,10 +1483,8 @@ nfsd4_sequence(struct svc_rqst *rqstp,
> > cstate->status = nfserr_replay_cache;
> > goto out;
> > }
> > - if (status) {
> > - spin_unlock(&sessionid_lock);
> > - goto err;
> > - }
> > + if (status)
> > + goto out;
> >
> > /* Success! bump slot seqid */
> > slot->sl_inuse = true;
> > @@ -1510,10 +1504,11 @@ nfsd4_sequence(struct svc_rqst *rqstp,
> > out:
> > spin_unlock(&sessionid_lock);
> > /* Renew the clientid on success and on replay */
> > - nfs4_lock_state();
> > - renew_client(session->se_client);
> > - nfs4_unlock_state();
> > -err:
> > + if (cstate->session) {
> > + nfs4_lock_state();
> > + renew_client(session->se_client);
> > + nfs4_unlock_state();
> > + }
> > dprintk("%s: return %d\n", __func__, ntohl(status));
> > return status;
> > }
>
> The code looks correct.
> Coming to think about it, I hope that cstate is initialized to zeroes
> since we're not explicitly clearing it. Should we?
> cstate comes from the struct nfsd4_compoundres * nfsd4_proc_compound
> is being called with...
net/sunrpc/svc.c:svc_process_common() has this:
/* Initialize storage for argp and resp */
memset(rqstp->rq_argp, 0, procp->pc_argsize);
memset(rqstp->rq_resp, 0, procp->pc_ressize);
OK!
--b.
next prev parent reply other threads:[~2009-08-27 21:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 0:21 [PATCH] nfsd41: renew_client must be called under the state lock Benny Halevy
2009-08-24 16:29 ` J. Bruce Fields
2009-08-25 7:06 ` Benny Halevy
2009-08-25 13:18 ` J. Bruce Fields
2009-08-25 17:02 ` Benny Halevy
2009-08-25 21:59 ` J. Bruce Fields
2009-08-26 8:20 ` [pnfs] " Boaz Harrosh
2009-08-26 21:02 ` J. Bruce Fields
2009-08-27 16:37 ` Benny Halevy
2009-08-27 21:16 ` J. Bruce Fields [this message]
2009-08-27 21:38 ` 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=20090827211639.GE11721@fieldses.org \
--to=bfields@fieldses.org \
--cc=bhalevy@panasas.com \
--cc=bharrosh@panasas.com \
--cc=linux-nfs@vger.kernel.org \
--cc=pnfs@linux-nfs.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox