linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: Trond Myklebust <trondmy@primarydata.com>
Cc: Schumaker Anna <anna.schumaker@netapp.com>,
	List Linux NFS Mailing <linux-nfs@vger.kernel.org>,
	Fields Bruce James <bfields@fieldses.org>
Subject: Re: [PATCH v3 8/9] nfs: move nfs4 lock retry attempt loop to a separate function
Date: Fri, 16 Sep 2016 17:47:08 -0400	[thread overview]
Message-ID: <1474062428.13386.15.camel@redhat.com> (raw)
In-Reply-To: <B44BF606-A37E-430A-B076-AF8050F4CBAD@primarydata.com>

On Fri, 2016-09-16 at 21:20 +0000, Trond Myklebust wrote:
> > 
> > On Sep 16, 2016, at 16:27, Jeff Layton <jlayton@redhat.com> wrote:
> > 
> > This also consolidates the waiting logic into a single function,
> > instead of having it spread across two like it is now.
> > 
> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > ---
> > fs/nfs/nfs4proc.c | 51 ++++++++++++++++++++++++------------------
> > ---------
> > 1 file changed, 24 insertions(+), 27 deletions(-)
> > 
> > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> > index c807850ac476..a7517abaf3c7 100644
> > --- a/fs/nfs/nfs4proc.c
> > +++ b/fs/nfs/nfs4proc.c
> > @@ -5530,22 +5530,6 @@ int nfs4_proc_delegreturn(struct inode
> > *inode, struct rpc_cred *cred, const nfs4
> > 	return err;
> > }
> > 
> > -#define NFS4_LOCK_MINTIMEOUT (1 * HZ)
> > -#define NFS4_LOCK_MAXTIMEOUT (30 * HZ)
> > -
> > -/* 
> > - * sleep, with exponential backoff, and retry the LOCK operation. 
> > - */
> > -static unsigned long
> > -nfs4_set_lock_task_retry(unsigned long timeout)
> > -{
> > -	freezable_schedule_timeout_interruptible(timeout);
> > -	timeout <<= 1;
> > -	if (timeout > NFS4_LOCK_MAXTIMEOUT)
> > -		return NFS4_LOCK_MAXTIMEOUT;
> > -	return timeout;
> > -}
> > -
> > static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd,
> > struct file_lock *request)
> > {
> > 	struct inode *inode = state->inode;
> > @@ -6178,12 +6162,34 @@ static int nfs4_proc_setlk(struct
> > nfs4_state *state, int cmd, struct file_lock *
> > 	return err;
> > }
> > 
> > +#define NFS4_LOCK_MINTIMEOUT (1 * HZ)
> > +#define NFS4_LOCK_MAXTIMEOUT (30 * HZ)
> > +
> > +static int
> > +nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct
> > file_lock *request)
> > +{
> > +	int status;
> > +	unsigned long timeout = NFS4_LOCK_MINTIMEOUT;
> > +
> > +	do {
> > +		status = nfs4_proc_setlk(state, cmd, request);
> > +		if ((status != -EAGAIN) || IS_SETLK(cmd))
> > +			break;
> > +		freezable_schedule_timeout_interruptible(timeout);
> > +		timeout *= 2;
> > +		timeout = min_t(unsigned long,
> > NFS4_LOCK_MAXTIMEOUT, timeout);
> > +		status = -ERESTARTSYS;
> > +		if (signalled())
> > +			break;
> > +	} while(status < 0);
> 
> Can it ever be >= 0 here? Why not just use 'while (!signalled())'?
> 


Good point. I'll make that change.

Thanks,

> > 
> > +	return status;
> > +}
> > +
> > static int
> > nfs4_proc_lock(struct file *filp, int cmd, struct file_lock
> > *request)
> > {
> > 	struct nfs_open_context *ctx;
> > 	struct nfs4_state *state;
> > -	unsigned long timeout = NFS4_LOCK_MINTIMEOUT;
> > 	int status;
> > 
> > 	/* verify open state */
> > @@ -6232,16 +6238,7 @@ nfs4_proc_lock(struct file *filp, int cmd,
> > struct file_lock *request)
> > 	if (status != 0)
> > 		return status;
> > 
> > -	do {
> > -		status = nfs4_proc_setlk(state, cmd, request);
> > -		if ((status != -EAGAIN) || IS_SETLK(cmd))
> > -			break;
> > -		timeout = nfs4_set_lock_task_retry(timeout);
> > -		status = -ERESTARTSYS;
> > -		if (signalled())
> > -			break;
> > -	} while(status < 0);
> > -	return status;
> > +	return nfs4_retry_setlk(state, cmd, request);
> > }
> > 
> > int nfs4_lock_delegation_recall(struct file_lock *fl, struct
> > nfs4_state *state, const nfs4_stateid *stateid)
> > 
-- 
Jeff Layton <jlayton@redhat.com>

  reply	other threads:[~2016-09-16 21:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-16 20:27 [PATCH v3 0/9] nfs: add CB_NOTIFY_LOCK support to nfs client Jeff Layton
2016-09-16 20:27 ` [PATCH v3 1/9] nfs: eliminate pointless and confusing do_vfs_lock wrappers Jeff Layton
2016-09-16 20:27 ` [PATCH v3 2/9] nfs: check for POSIX lock capability on server even for flock locks Jeff Layton
2016-09-16 21:14   ` Trond Myklebust
2016-09-16 21:46     ` Jeff Layton
2016-09-16 21:59       ` Trond Myklebust
2016-09-16 20:27 ` [PATCH v3 3/9] nfs: use safe, interruptible sleeps when waiting to retry LOCK Jeff Layton
2016-09-16 20:27 ` [PATCH v3 4/9] nfs: add a new NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK constant Jeff Layton
2016-09-16 20:27 ` [PATCH v3 5/9] nfs: track whether server sets MAY_NOTIFY_LOCK flag Jeff Layton
2016-09-16 20:27 ` [PATCH v3 6/9] nfs: add handling for CB_NOTIFY_LOCK in client Jeff Layton
2016-09-16 20:27 ` [PATCH v3 7/9] nfs: move nfs4_set_lock_state call into caller Jeff Layton
2016-09-16 20:27 ` [PATCH v3 8/9] nfs: move nfs4 lock retry attempt loop to a separate function Jeff Layton
2016-09-16 21:20   ` Trond Myklebust
2016-09-16 21:47     ` Jeff Layton [this message]
2016-09-16 20:27 ` [PATCH v3 9/9] nfs: add code to allow client to wait on lock callbacks Jeff Layton

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=1474062428.13386.15.camel@redhat.com \
    --to=jlayton@redhat.com \
    --cc=anna.schumaker@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@primarydata.com \
    /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;
as well as URLs for NNTP newsgroup(s).