Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] pynfs: add test for read with delegation stateid after close
@ 2025-04-11 11:19 Tigran Mkrtchyan
  2025-04-21 13:40 ` Jeff Layton
  0 siblings, 1 reply; 2+ messages in thread
From: Tigran Mkrtchyan @ 2025-04-11 11:19 UTC (permalink / raw)
  To: calum.mackay; +Cc: linux-nfs, Tigran Mkrtchyan

This test checks the independence of delegation stateid from open
stateid.

Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
---
 nfs4.1/server41tests/st_delegation.py | 50 ++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
index f27e852..ea4c073 100644
--- a/nfs4.1/server41tests/st_delegation.py
+++ b/nfs4.1/server41tests/st_delegation.py
@@ -2,7 +2,7 @@ from .st_create_session import create_session
 from .st_open import open_claim4
 from xdrdef.nfs4_const import *
 
-from .environment import check, fail, create_file, open_file, close_file, do_getattrdict
+from .environment import check, fail, create_file, open_file, close_file, do_getattrdict, close_file, write_file, read_file
 from xdrdef.nfs4_type import *
 import nfs_ops
 op = nfs_ops.NFS4ops()
@@ -390,3 +390,51 @@ def testCbGetattrWithChange(t, env):
     if FATTR4_TIME_DELEG_MODIFY in attrs2:
         if attrs1[FATTR4_TIME_MODIFY] == attrs2[FATTR4_TIME_DELEG_MODIFY]:
             fail("Bad modify time: ", attrs1[FATTR4_TIME_MODIFY], " == ", attrs2[FATTR4_TIME_DELEG_MODIFY])
+
+def testDelegReadAfterClose(t, env):
+    """Test read with delegation stateid after close
+
+    Create file with some data. Open the file for read, get delegation, close the file.
+    Tesr that reads with delegation stateid still works.
+
+    FLAGS: deleg all
+    CODE: DELEG26
+    """
+    sess1 = env.c1.new_client_session(b"%s_1" % env.testname(t))
+
+    name = env.testname(t)
+    owner = b"owner_%s" % name
+
+    # craete file with some data
+    res = create_file(sess1, owner)
+    check(res)
+
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
+
+    res = write_file(sess1, fh, b'data', 0, stateid)
+    check(res)
+
+    res = close_file(sess1, fh, stateid=stateid)
+    check(res)
+
+
+    # open file, get delegation, close the file
+    access = OPEN4_SHARE_ACCESS_READ | OPEN4_SHARE_ACCESS_WANT_READ_DELEG;
+    res = open_file(sess1, owner, access = access)
+    check(res)
+
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
+    delegstateid = res.resarray[-2].delegation.read.stateid
+
+    res = close_file(sess1, fh, stateid=stateid)
+    check(res)
+
+    # Issue READ with delegation sateid
+    res = read_file(sess1, fh, 0, 10, delegstateid)
+    check(res)
+
+    # cleanup: return delegation
+    res = sess1.compound([op.putfh(fh), op.delegreturn(delegstateid)])
+    check(res)
-- 
2.49.0


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

* Re: [PATCH] pynfs: add test for read with delegation stateid after close
  2025-04-11 11:19 [PATCH] pynfs: add test for read with delegation stateid after close Tigran Mkrtchyan
@ 2025-04-21 13:40 ` Jeff Layton
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2025-04-21 13:40 UTC (permalink / raw)
  To: Tigran Mkrtchyan, calum.mackay; +Cc: linux-nfs

On Fri, 2025-04-11 at 13:19 +0200, Tigran Mkrtchyan wrote:
> This test checks the independence of delegation stateid from open
> stateid.
> 
> Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
> ---
>  nfs4.1/server41tests/st_delegation.py | 50 ++++++++++++++++++++++++++-
>  1 file changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
> index f27e852..ea4c073 100644
> --- a/nfs4.1/server41tests/st_delegation.py
> +++ b/nfs4.1/server41tests/st_delegation.py
> @@ -2,7 +2,7 @@ from .st_create_session import create_session
>  from .st_open import open_claim4
>  from xdrdef.nfs4_const import *
>  
> -from .environment import check, fail, create_file, open_file, close_file, do_getattrdict
> +from .environment import check, fail, create_file, open_file, close_file, do_getattrdict, close_file, write_file, read_file
>  from xdrdef.nfs4_type import *
>  import nfs_ops
>  op = nfs_ops.NFS4ops()
> @@ -390,3 +390,51 @@ def testCbGetattrWithChange(t, env):
>      if FATTR4_TIME_DELEG_MODIFY in attrs2:
>          if attrs1[FATTR4_TIME_MODIFY] == attrs2[FATTR4_TIME_DELEG_MODIFY]:
>              fail("Bad modify time: ", attrs1[FATTR4_TIME_MODIFY], " == ", attrs2[FATTR4_TIME_DELEG_MODIFY])
> +
> +def testDelegReadAfterClose(t, env):
> +    """Test read with delegation stateid after close
> +
> +    Create file with some data. Open the file for read, get delegation, close the file.
> +    Tesr that reads with delegation stateid still works.
> +
> +    FLAGS: deleg all
> +    CODE: DELEG26
> +    """
> +    sess1 = env.c1.new_client_session(b"%s_1" % env.testname(t))
> +
> +    name = env.testname(t)
> +    owner = b"owner_%s" % name
> +
> +    # craete file with some data

nit: "create"

> +    res = create_file(sess1, owner)
> +    check(res)
> +
> +    fh = res.resarray[-1].object
> +    stateid = res.resarray[-2].stateid
> +
> +    res = write_file(sess1, fh, b'data', 0, stateid)
> +    check(res)
> +
> +    res = close_file(sess1, fh, stateid=stateid)
> +    check(res)
> +
> +
> +    # open file, get delegation, close the file
> +    access = OPEN4_SHARE_ACCESS_READ | OPEN4_SHARE_ACCESS_WANT_READ_DELEG;
> +    res = open_file(sess1, owner, access = access)
> +    check(res)
> +
> +    fh = res.resarray[-1].object
> +    stateid = res.resarray[-2].stateid
> +    delegstateid = res.resarray[-2].delegation.read.stateid
> +

It might be good to check that you got a delegation here, though the
test will obviously fail either way.
 * 
> +    res = close_file(sess1, fh, stateid=stateid)
> +    check(res)
> +
> +    # Issue READ with delegation sateid

nit: "delegation stateid"

> +    res = read_file(sess1, fh, 0, 10, delegstateid)
> +    check(res)
> +
> +    # cleanup: return delegation
> +    res = sess1.compound([op.putfh(fh), op.delegreturn(delegstateid)])
> +    check(res)

Looks reasonable otherwise.

Reviewed-by: Jeff Layton <jlayton@kernel.org>

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

end of thread, other threads:[~2025-04-21 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 11:19 [PATCH] pynfs: add test for read with delegation stateid after close Tigran Mkrtchyan
2025-04-21 13:40 ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox