diff mbox series

pynfs: fix key error if FATTR4_OPEN_ARGUMENTS is not supported

Message ID 20250319032402.1789-1-chenhx.fnst@fujitsu.com (mailing list archive)
State Handled Elsewhere
Headers show
Series pynfs: fix key error if FATTR4_OPEN_ARGUMENTS is not supported | expand

Commit Message

Chen Hanxiao March 19, 2025, 3:23 a.m. UTC
If FATTR4_OPEN_ARGUMENTS is not supportd, DELEG24 and DELEG25
will throw:
	KeyError: 86

Check FATTR4_OPEN_ARGUMENTS in caps from server

Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
---
 nfs4.1/server41tests/st_delegation.py | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jeff Layton March 20, 2025, 11 a.m. UTC | #1
On Wed, 2025-03-19 at 11:23 +0800, Chen Hanxiao wrote:
> If FATTR4_OPEN_ARGUMENTS is not supportd, DELEG24 and DELEG25
> will throw:
> 	KeyError: 86
> 
> Check FATTR4_OPEN_ARGUMENTS in caps from server
> 
> Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
> ---
>  nfs4.1/server41tests/st_delegation.py | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
> index fa9b451..f27e852 100644
> --- a/nfs4.1/server41tests/st_delegation.py
> +++ b/nfs4.1/server41tests/st_delegation.py
> @@ -311,6 +311,9 @@ def _testCbGetattr(t, env, change=0, size=0):
>                  OPEN4_SHARE_ACCESS_WRITE |
>                  OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG)
>  
> +    if FATTR4_OPEN_ARGUMENTS not in caps:
> +        fail("FATTR4_OPEN_ARGUMENTS not supported")
> +
>      if caps[FATTR4_SUPPORTED_ATTRS] & FATTR4_OPEN_ARGUMENTS:
>          if caps[FATTR4_OPEN_ARGUMENTS].oa_share_access_want & OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS:
>              openmask |= 1<<OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS

Nice catch.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Calum Mackay March 25, 2025, 8:21 p.m. UTC | #2
On 19/03/2025 3:23 am, Chen Hanxiao wrote:
> If FATTR4_OPEN_ARGUMENTS is not supportd, DELEG24 and DELEG25
> will throw:
> 	KeyError: 86
> 
> Check FATTR4_OPEN_ARGUMENTS in caps from server

That's great, thanks very much.

Applied; tagged pynfs-0.3

cheers,
calum.

> 
> Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
> ---
>   nfs4.1/server41tests/st_delegation.py | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
> index fa9b451..f27e852 100644
> --- a/nfs4.1/server41tests/st_delegation.py
> +++ b/nfs4.1/server41tests/st_delegation.py
> @@ -311,6 +311,9 @@ def _testCbGetattr(t, env, change=0, size=0):
>                   OPEN4_SHARE_ACCESS_WRITE |
>                   OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG)
>   
> +    if FATTR4_OPEN_ARGUMENTS not in caps:
> +        fail("FATTR4_OPEN_ARGUMENTS not supported")
> +
>       if caps[FATTR4_SUPPORTED_ATTRS] & FATTR4_OPEN_ARGUMENTS:
>           if caps[FATTR4_OPEN_ARGUMENTS].oa_share_access_want & OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS:
>               openmask |= 1<<OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS
diff mbox series

Patch

diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
index fa9b451..f27e852 100644
--- a/nfs4.1/server41tests/st_delegation.py
+++ b/nfs4.1/server41tests/st_delegation.py
@@ -311,6 +311,9 @@  def _testCbGetattr(t, env, change=0, size=0):
                 OPEN4_SHARE_ACCESS_WRITE |
                 OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG)
 
+    if FATTR4_OPEN_ARGUMENTS not in caps:
+        fail("FATTR4_OPEN_ARGUMENTS not supported")
+
     if caps[FATTR4_SUPPORTED_ATTRS] & FATTR4_OPEN_ARGUMENTS:
         if caps[FATTR4_OPEN_ARGUMENTS].oa_share_access_want & OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS:
             openmask |= 1<<OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS