diff mbox series

[1/2] nfs4lib.py: enhance open_file to work with courteous server

Message ID 1655314495-17735-1-git-send-email-dai.ngo@oracle.com (mailing list archive)
State New, archived
Headers show
Series [1/2] nfs4lib.py: enhance open_file to work with courteous server | expand

Commit Message

Dai Ngo June 15, 2022, 5:34 p.m. UTC
Enhance open_file to handle NFS4ERR_DELAY returned by the server
in case of share/access/delegation conflict.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
---
 nfs4.0/nfs4lib.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

J. Bruce Fields June 15, 2022, 7:34 p.m. UTC | #1
THere are tests that want to explicitly test for DELAY returns.  (Grep
for ERR_DELAY.  Look at the delegation tests especially.)  Does this
work for them?  I assumed we'd want an optional parameter that allowed
to caller to circument the DELAY handling.

--b.

On Wed, Jun 15, 2022 at 10:34:54AM -0700, Dai Ngo wrote:
> Enhance open_file to handle NFS4ERR_DELAY returned by the server
> in case of share/access/delegation conflict.
> 
> Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
> ---
>  nfs4.0/nfs4lib.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
> index 934def3b7333..e0299e8d6676 100644
> --- a/nfs4.0/nfs4lib.py
> +++ b/nfs4.0/nfs4lib.py
> @@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
>                            claim_type=claim_type, deleg_type=deleg_type,
>                            deleg_cur_info=deleg_cur_info)]
>          ops += [op4.getfh()]
> -        res = self.compound(ops)
> +        while 1:
> +            res = self.compound(ops)
> +            if res.status == NFS4ERR_DELAY:
> +                time.sleep(2)
> +            else:
> +                break
>          self.advance_seqid(owner, res)
>          if set_recall and (res.status != NFS4_OK or \
>             res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
> -- 
> 2.27.0
Dai Ngo June 15, 2022, 7:48 p.m. UTC | #2
On 6/15/22 12:34 PM, J. Bruce Fields wrote:
> THere are tests that want to explicitly test for DELAY returns.  (Grep
> for ERR_DELAY.  Look at the delegation tests especially.)  Does this
> work for them?

Those tests expect NFS4_OK but also handle NFS4ERR_DELAY themselves
if the OPEN causes recall. With this patch, the NFS4ERR_DELAY is handled
internally by open_file so the ERR_DELAY never get to those tests.
All tests passed with this patch.

-Dai

>   I assumed we'd want an optional parameter that allowed
> to caller to circument the DELAY handling.
>
> --b.
>
> On Wed, Jun 15, 2022 at 10:34:54AM -0700, Dai Ngo wrote:
>> Enhance open_file to handle NFS4ERR_DELAY returned by the server
>> in case of share/access/delegation conflict.
>>
>> Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
>> ---
>>   nfs4.0/nfs4lib.py | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
>> index 934def3b7333..e0299e8d6676 100644
>> --- a/nfs4.0/nfs4lib.py
>> +++ b/nfs4.0/nfs4lib.py
>> @@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
>>                             claim_type=claim_type, deleg_type=deleg_type,
>>                             deleg_cur_info=deleg_cur_info)]
>>           ops += [op4.getfh()]
>> -        res = self.compound(ops)
>> +        while 1:
>> +            res = self.compound(ops)
>> +            if res.status == NFS4ERR_DELAY:
>> +                time.sleep(2)
>> +            else:
>> +                break
>>           self.advance_seqid(owner, res)
>>           if set_recall and (res.status != NFS4_OK or \
>>              res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
>> -- 
>> 2.27.0
J. Bruce Fields July 11, 2022, 6:05 p.m. UTC | #3
Applying, thanks, sorry for the delay.--b.

On Wed, Jun 15, 2022 at 12:48:17PM -0700, dai.ngo@oracle.com wrote:
> 
> On 6/15/22 12:34 PM, J. Bruce Fields wrote:
> >THere are tests that want to explicitly test for DELAY returns.  (Grep
> >for ERR_DELAY.  Look at the delegation tests especially.)  Does this
> >work for them?
> 
> Those tests expect NFS4_OK but also handle NFS4ERR_DELAY themselves
> if the OPEN causes recall. With this patch, the NFS4ERR_DELAY is handled
> internally by open_file so the ERR_DELAY never get to those tests.
> All tests passed with this patch.
> 
> -Dai
> 
> >  I assumed we'd want an optional parameter that allowed
> >to caller to circument the DELAY handling.
> >
> >--b.
> >
> >On Wed, Jun 15, 2022 at 10:34:54AM -0700, Dai Ngo wrote:
> >>Enhance open_file to handle NFS4ERR_DELAY returned by the server
> >>in case of share/access/delegation conflict.
> >>
> >>Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
> >>---
> >>  nfs4.0/nfs4lib.py | 7 ++++++-
> >>  1 file changed, 6 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
> >>index 934def3b7333..e0299e8d6676 100644
> >>--- a/nfs4.0/nfs4lib.py
> >>+++ b/nfs4.0/nfs4lib.py
> >>@@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
> >>                            claim_type=claim_type, deleg_type=deleg_type,
> >>                            deleg_cur_info=deleg_cur_info)]
> >>          ops += [op4.getfh()]
> >>-        res = self.compound(ops)
> >>+        while 1:
> >>+            res = self.compound(ops)
> >>+            if res.status == NFS4ERR_DELAY:
> >>+                time.sleep(2)
> >>+            else:
> >>+                break
> >>          self.advance_seqid(owner, res)
> >>          if set_recall and (res.status != NFS4_OK or \
> >>             res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
> >>-- 
> >>2.27.0
Dai Ngo July 11, 2022, 6:16 p.m. UTC | #4
On 7/11/22 11:05 AM, J. Bruce Fields wrote:
> Applying, thanks, sorry for the delay.--b.

thank you Bruce!

-Dai

>
> On Wed, Jun 15, 2022 at 12:48:17PM -0700, dai.ngo@oracle.com wrote:
>> On 6/15/22 12:34 PM, J. Bruce Fields wrote:
>>> THere are tests that want to explicitly test for DELAY returns.  (Grep
>>> for ERR_DELAY.  Look at the delegation tests especially.)  Does this
>>> work for them?
>> Those tests expect NFS4_OK but also handle NFS4ERR_DELAY themselves
>> if the OPEN causes recall. With this patch, the NFS4ERR_DELAY is handled
>> internally by open_file so the ERR_DELAY never get to those tests.
>> All tests passed with this patch.
>>
>> -Dai
>>
>>>   I assumed we'd want an optional parameter that allowed
>>> to caller to circument the DELAY handling.
>>>
>>> --b.
>>>
>>> On Wed, Jun 15, 2022 at 10:34:54AM -0700, Dai Ngo wrote:
>>>> Enhance open_file to handle NFS4ERR_DELAY returned by the server
>>>> in case of share/access/delegation conflict.
>>>>
>>>> Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
>>>> ---
>>>>   nfs4.0/nfs4lib.py | 7 ++++++-
>>>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
>>>> index 934def3b7333..e0299e8d6676 100644
>>>> --- a/nfs4.0/nfs4lib.py
>>>> +++ b/nfs4.0/nfs4lib.py
>>>> @@ -677,7 +677,12 @@ class NFS4Client(rpc.RPCClient):
>>>>                             claim_type=claim_type, deleg_type=deleg_type,
>>>>                             deleg_cur_info=deleg_cur_info)]
>>>>           ops += [op4.getfh()]
>>>> -        res = self.compound(ops)
>>>> +        while 1:
>>>> +            res = self.compound(ops)
>>>> +            if res.status == NFS4ERR_DELAY:
>>>> +                time.sleep(2)
>>>> +            else:
>>>> +                break
>>>>           self.advance_seqid(owner, res)
>>>>           if set_recall and (res.status != NFS4_OK or \
>>>>              res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):
>>>> -- 
>>>> 2.27.0
diff mbox series

Patch

diff --git a/nfs4.0/nfs4lib.py b/nfs4.0/nfs4lib.py
index 934def3b7333..e0299e8d6676 100644
--- a/nfs4.0/nfs4lib.py
+++ b/nfs4.0/nfs4lib.py
@@ -677,7 +677,12 @@  class NFS4Client(rpc.RPCClient):
                           claim_type=claim_type, deleg_type=deleg_type,
                           deleg_cur_info=deleg_cur_info)]
         ops += [op4.getfh()]
-        res = self.compound(ops)
+        while 1:
+            res = self.compound(ops)
+            if res.status == NFS4ERR_DELAY:
+                time.sleep(2)
+            else:
+                break
         self.advance_seqid(owner, res)
         if set_recall and (res.status != NFS4_OK or \
            res.resarray[-2].switch.switch.delegation == OPEN_DELEGATE_NONE):