All of lore.kernel.org
 help / color / mirror / Atom feed
From: Calum Mackay <calum.mackay@oracle.com>
To: bfields@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 2/2] pynfs: courtesy: add a test to ensure server releases state appropriately
Date: Wed, 24 Mar 2021 01:46:30 +0000	[thread overview]
Message-ID: <20210324014630.2454-3-calum.mackay@oracle.com> (raw)
In-Reply-To: <20210324014630.2454-1-calum.mackay@oracle.com>

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


  parent reply	other threads:[~2021-03-24  1:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-03-25 17:25 ` [PATCH 0/2] add another courteous server test J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210324014630.2454-3-calum.mackay@oracle.com \
    --to=calum.mackay@oracle.com \
    --cc=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.