All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] add another courteous server test
@ 2021-03-24  1:46 Calum Mackay
  2021-03-24  1:46 ` [PATCH 1/2] pynfs: courtesy: use a helper function to prepare the lock op args Calum Mackay
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Calum Mackay @ 2021-03-24  1:46 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs

This adds a second test of courteous server functionality.

 nfs4.1/server41tests/st_courtesy.py | 44 +++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 4 deletions(-)

Calum Mackay (2):
      pynfs: courtesy: use a helper function to prepare the lock op args
      pynfs: courtesy: add a test to ensure server releases state appropriately




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

* [PATCH 1/2] pynfs: courtesy: use a helper function to prepare the lock op args
  2021-03-24  1:46 [PATCH 0/2] add another courteous server test Calum Mackay
@ 2021-03-24  1:46 ` Calum Mackay
  2021-03-24  1:46 ` [PATCH 2/2] pynfs: courtesy: add a test to ensure server releases state appropriately Calum Mackay
  2021-03-25 17:25 ` [PATCH 0/2] add another courteous server test J. Bruce Fields
  2 siblings, 0 replies; 4+ messages in thread
From: Calum Mackay @ 2021-03-24  1:46 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs

Cleanup.

Future tests to be added will use the same sequence to prepare the args
for the lock op, so use a helper function for that.

Signed-off-by: Calum Mackay <calum.mackay@oracle.com>
---
 nfs4.1/server41tests/st_courtesy.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/nfs4.1/server41tests/st_courtesy.py b/nfs4.1/server41tests/st_courtesy.py
index 5e13dad44a01..e74d9afbca60 100644
--- a/nfs4.1/server41tests/st_courtesy.py
+++ b/nfs4.1/server41tests/st_courtesy.py
@@ -15,6 +15,12 @@ def _getleasetime(sess):
     res = sess.compound([op.putrootfh(), op.getattr(1 << FATTR4_LEASE_TIME)])
     return res.resarray[-1].obj_attributes[FATTR4_LEASE_TIME]
 
+def cour_lockargs(fh, stateid):
+    open_to_lock_owner = open_to_lock_owner4( 0, stateid, 0, lock_owner4(0, b"lock1"))
+    lock_owner = locker4(open_owner=open_to_lock_owner, new_lock_owner=True)
+    lock_ops = [ op.lock(WRITE_LT, False, 0, NFS4_UINT64_MAX, lock_owner) ]
+    return [op.putfh(fh)] + lock_ops
+
 def testLockSleepLockU(t, env):
     """test server courtesy by having LOCK and LOCKU
        in separate compounds, separated by a sleep of twice the lease period
@@ -29,10 +35,7 @@ def testLockSleepLockU(t, env):
 
     fh = res.resarray[-1].object
     stateid = res.resarray[-2].stateid
-    open_to_lock_owner = open_to_lock_owner4( 0, stateid, 0, lock_owner4(0, b"lock1"))
-    lock_owner = locker4(open_owner=open_to_lock_owner, new_lock_owner=True)
-    lock_ops = [ op.lock(WRITE_LT, False, 0, NFS4_UINT64_MAX, lock_owner) ]
-    res = sess1.compound([op.putfh(fh)] + lock_ops)
+    res = sess1.compound(cour_lockargs(fh, stateid))
     check(res, NFS4_OK)
 
     lease_time = _getleasetime(sess1)
-- 
2.27.0


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

* [PATCH 2/2] pynfs: courtesy: add a test to ensure server releases state appropriately
  2021-03-24  1:46 [PATCH 0/2] add another courteous server test Calum Mackay
  2021-03-24  1:46 ` [PATCH 1/2] pynfs: courtesy: use a helper function to prepare the lock op args Calum Mackay
@ 2021-03-24  1:46 ` Calum Mackay
  2021-03-25 17:25 ` [PATCH 0/2] add another courteous server test J. Bruce Fields
  2 siblings, 0 replies; 4+ messages in thread
From: Calum Mackay @ 2021-03-24  1:46 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs

This test checks that the server will allow a conflicting lock from a
second client, after lease expiry of the first client.

This applies to both courteous, and discourteous servers, but ensures
that courteous servers don't just hang onto state indefinitely.

Signed-off-by: Calum Mackay <calum.mackay@oracle.com>
---
 nfs4.1/server41tests/st_courtesy.py | 33 +++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/nfs4.1/server41tests/st_courtesy.py b/nfs4.1/server41tests/st_courtesy.py
index e74d9afbca60..dd911a37772d 100644
--- a/nfs4.1/server41tests/st_courtesy.py
+++ b/nfs4.1/server41tests/st_courtesy.py
@@ -48,3 +48,36 @@ def testLockSleepLockU(t, env):
 
     res = close_file(sess1, fh, stateid=stateid)
     check(res)
+
+def testLockSleepLock(t, env):
+    """ensure that a courteous server will allow a conflicting lock from
+       a second client, after lease expiry of the first client.
+       A discourteous server should allow this too, of course.
+
+    FLAGS: courteous all
+    CODE: COUR2
+    """
+
+    sess1 = env.c1.new_client_session(env.testname(t))
+
+    res = create_file(sess1, env.testname(t))
+    check(res)
+
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
+    res = sess1.compound(cour_lockargs(fh, stateid))
+    check(res, NFS4_OK)
+
+    lease_time = _getleasetime(sess1)
+    env.sleep(lease_time * 2, "twice the lease period")
+
+    c2 = env.c1.new_client(b"%s_2" % env.testname(t))
+    sess2 = c2.create_session()
+
+    res = open_file(sess2, env.testname(t), access=OPEN4_SHARE_ACCESS_WRITE)
+    check(res)
+
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
+    res = sess2.compound(cour_lockargs(fh, stateid))
+    check(res, NFS4_OK)
-- 
2.27.0


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

* Re: [PATCH 0/2] add another courteous server test
  2021-03-24  1:46 [PATCH 0/2] add another courteous server test Calum Mackay
  2021-03-24  1:46 ` [PATCH 1/2] pynfs: courtesy: use a helper function to prepare the lock op args Calum Mackay
  2021-03-24  1:46 ` [PATCH 2/2] pynfs: courtesy: add a test to ensure server releases state appropriately Calum Mackay
@ 2021-03-25 17:25 ` J. Bruce Fields
  2 siblings, 0 replies; 4+ messages in thread
From: J. Bruce Fields @ 2021-03-25 17:25 UTC (permalink / raw)
  To: Calum Mackay; +Cc: bfields, linux-nfs

Thanks!--b.

On Wed, Mar 24, 2021 at 01:46:28AM +0000, Calum Mackay wrote:
> This adds a second test of courteous server functionality.
> 
>  nfs4.1/server41tests/st_courtesy.py | 44 +++++++++++++++++++++++++++++---
>  1 file changed, 40 insertions(+), 4 deletions(-)
> 
> Calum Mackay (2):
>       pynfs: courtesy: use a helper function to prepare the lock op args
>       pynfs: courtesy: add a test to ensure server releases state appropriately
> 
> 

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

end of thread, other threads:[~2021-03-25 17:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24  1:46 [PATCH 0/2] add another courteous server test Calum Mackay
2021-03-24  1:46 ` [PATCH 1/2] pynfs: courtesy: use a helper function to prepare the lock op args Calum Mackay
2021-03-24  1:46 ` [PATCH 2/2] pynfs: courtesy: add a test to ensure server releases state appropriately Calum Mackay
2021-03-25 17:25 ` [PATCH 0/2] add another courteous server test J. Bruce Fields

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.