linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfsd41: Deny new lock before RECLAIM_COMPLETE done
@ 2011-04-27  1:12 Mi Jinlong
  2011-04-27 13:54 ` J. Bruce Fields
  0 siblings, 1 reply; 4+ messages in thread
From: Mi Jinlong @ 2011-04-27  1:12 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: NFS

Before nfs41 client's RECLAIM_COMPLETE done, nfs server should 
deny it's new lock.

Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>
---
 fs/nfsd/nfs4state.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 4b36ec3..43cda94 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3803,6 +3803,15 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		 */
 		struct nfs4_stateid *open_stp = NULL;
 		
+		/*
+		 * RFC5661 18.51.3
+		 * Before RECLAIM_COMPLETE done, return NFS4ERR_GRACE
+		 */
+		status = nfserr_grace;
+		if (nfsd4_has_session(cstate) &&
+		    !cstate->session->se_client->cl_firststate)
+			goto out;
+
 		status = nfserr_stale_clientid;
 		if (!nfsd4_has_session(cstate) &&
 		    STALE_CLIENTID(&lock->lk_new_clientid))
-- 
1.7.4.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] nfsd41: Deny new lock before RECLAIM_COMPLETE done
  2011-04-27  1:12 [PATCH] nfsd41: Deny new lock before RECLAIM_COMPLETE done Mi Jinlong
@ 2011-04-27 13:54 ` J. Bruce Fields
  2011-05-10  9:17   ` Mi Jinlong
  0 siblings, 1 reply; 4+ messages in thread
From: J. Bruce Fields @ 2011-04-27 13:54 UTC (permalink / raw)
  To: Mi Jinlong; +Cc: NFS

On Wed, Apr 27, 2011 at 09:12:00AM +0800, Mi Jinlong wrote:
> Before nfs41 client's RECLAIM_COMPLETE done, nfs server should 
> deny it's new lock.
> 
> Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>

Is nfserr_grace the right error?  (Honest question, I haven't looked it
up.)

Also I'd think this check should go in nfsd4_open: opens are also
prohibited before RECLAIM_COMPLETE, and if we check there then we don't
need to check here, as you have to have open state before you can do a
lock.

--b.

> ---
>  fs/nfsd/nfs4state.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 4b36ec3..43cda94 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -3803,6 +3803,15 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
>  		 */
>  		struct nfs4_stateid *open_stp = NULL;
>  		
> +		/*
> +		 * RFC5661 18.51.3
> +		 * Before RECLAIM_COMPLETE done, return NFS4ERR_GRACE
> +		 */
> +		status = nfserr_grace;
> +		if (nfsd4_has_session(cstate) &&
> +		    !cstate->session->se_client->cl_firststate)
> +			goto out;
> +
>  		status = nfserr_stale_clientid;
>  		if (!nfsd4_has_session(cstate) &&
>  		    STALE_CLIENTID(&lock->lk_new_clientid))
> -- 
> 1.7.4.1
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nfsd41: Deny new lock before RECLAIM_COMPLETE done
  2011-04-27 13:54 ` J. Bruce Fields
@ 2011-05-10  9:17   ` Mi Jinlong
  2011-05-10  9:23     ` Mi Jinlong
  0 siblings, 1 reply; 4+ messages in thread
From: Mi Jinlong @ 2011-05-10  9:17 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: NFS

Hi Bruce,

 Sorry for so late to reply you.

J. Bruce Fields:
> On Wed, Apr 27, 2011 at 09:12:00AM +0800, Mi Jinlong wrote:
>> Before nfs41 client's RECLAIM_COMPLETE done, nfs server should 
>> deny it's new lock.
>>
>> Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>
> 
> Is nfserr_grace the right error?  (Honest question, I haven't looked it
> up.)

  Yes, rfc5661 says:

  " Whenever a client establishes a new client ID and before it does the
    first non-reclaim operation that obtains a lock, it MUST send a
    RECLAIM_COMPLETE with rca_one_fs set to FALSE, even if there are no
    locks to reclaim.  If non-reclaim locking operations are done before
    the RECLAIM_COMPLETE, an NFS4ERR_GRACE error will be returned. "
 
> 
> Also I'd think this check should go in nfsd4_open: opens are also
> prohibited before RECLAIM_COMPLETE, and if we check there then we don't
> need to check here, as you have to have open state before you can do a
> lock.

  Agree with you, what about the following one??

-- 
----
thanks
Mi Jinlong
===============================

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nfsd41: Deny new lock before RECLAIM_COMPLETE done
  2011-05-10  9:17   ` Mi Jinlong
@ 2011-05-10  9:23     ` Mi Jinlong
  0 siblings, 0 replies; 4+ messages in thread
From: Mi Jinlong @ 2011-05-10  9:23 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: NFS



Mi Jinlong :
> Hi Bruce,
> 
>  Sorry for so late to reply you.
> 
> J. Bruce Fields:
>> On Wed, Apr 27, 2011 at 09:12:00AM +0800, Mi Jinlong wrote:
>>> Before nfs41 client's RECLAIM_COMPLETE done, nfs server should 
>>> deny it's new lock.
>>>
>>> Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>
>> Is nfserr_grace the right error?  (Honest question, I haven't looked it
>> up.)
> 
>   Yes, rfc5661 says:
> 
>   " Whenever a client establishes a new client ID and before it does the
>     first non-reclaim operation that obtains a lock, it MUST send a
>     RECLAIM_COMPLETE with rca_one_fs set to FALSE, even if there are no
>     locks to reclaim.  If non-reclaim locking operations are done before
>     the RECLAIM_COMPLETE, an NFS4ERR_GRACE error will be returned. "
>  
>> Also I'd think this check should go in nfsd4_open: opens are also
>> prohibited before RECLAIM_COMPLETE, and if we check there then we don't
>> need to check here, as you have to have open state before you can do a
>> lock.
> 
>   Agree with you, what about the following one??

  After this patch, we should add a new patch to pynfs41 test site.
  Otherwise, the test site will walk out.

----
thanks
Mi Jinlong

>From baa71190a279f6b35a919088d985482dedf06a71 Mon Sep 17 00:00:00 2001
From: Mi Jinlong <mijinlong@cn.fujitsu.com>
Date: Tue, 10 May 2011 14:14:38 +0800
Subject: [PATCH] CLNT: Send RECLAIM_COMPLETE to server before do 'maketree'

Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>
---
 nfs4.1/server41tests/environment.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/nfs4.1/server41tests/environment.py b/nfs4.1/server41tests/environment.py
index 4ce7a70..857b29f 100644
--- a/nfs4.1/server41tests/environment.py
+++ b/nfs4.1/server41tests/environment.py
@@ -157,6 +157,10 @@ class Environment(testmod.Environment):
 
     def _maketree(self, sess):
         """Make test tree"""
+        # RECLAIM_COMPLETE
+        res = sess.compound([op.reclaim_complete(FALSE)])
+        check(res)
+
         # ensure /tmp (and path leading up) exists
         path = []
         for comp in self.opts.home:
-- 
1.7.4.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-10  9:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-27  1:12 [PATCH] nfsd41: Deny new lock before RECLAIM_COMPLETE done Mi Jinlong
2011-04-27 13:54 ` J. Bruce Fields
2011-05-10  9:17   ` Mi Jinlong
2011-05-10  9:23     ` Mi Jinlong

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).