Linux NFS development
 help / color / mirror / Atom feed
From: Dai Ngo <dai.ngo@oracle.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 1/1] st_opendowngrade.py: add open upgrade with deny mode tests
Date: Thu, 16 Feb 2023 12:01:15 -0800	[thread overview]
Message-ID: <1676577675-16451-1-git-send-email-dai.ngo@oracle.com> (raw)

Add 2 tests, OPDG12 and OPDG13, to test deny mode code paths in
nfs4_upgrade_open.

OPDG12: test open upgrade that has deny mode conflict with an active
client.

OPDG12: test open upgrade that has deny mode conflict with a courtesy
client.

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

diff --git a/nfs4.0/servertests/st_opendowngrade.py b/nfs4.0/servertests/st_opendowngrade.py
index 59e975000724..de7e4d3db2b0 100644
--- a/nfs4.0/servertests/st_opendowngrade.py
+++ b/nfs4.0/servertests/st_opendowngrade.py
@@ -180,3 +180,65 @@ def testOpenDowngradeLock(t, env):
     os.open(OPEN4_SHARE_ACCESS_READ)
     os.downgrade(OPEN4_SHARE_ACCESS_READ)
     os.close()
+
+def testOpenUpgradeconflict(t, env):
+    """test open upgrade that conflicts with another active client
+
+    FLAGS: opendowngrade all
+    DEPEND: MKFILE
+    CODE:OPDG12
+    """
+    c = env.c1
+    c.init_connection()
+    os = open_sequence(c, t.word())
+    os.open(OPEN4_SHARE_ACCESS_WRITE)
+
+    c2 = env.c2
+    c2.init_connection()
+    res = c2.open_file(t.word(), access=OPEN4_SHARE_ACCESS_READ,
+                       deny=OPEN4_SHARE_DENY_NONE)
+    check(res)
+    fh, stateid = c2.confirm(t.word(), res)
+    res = c2.open_file(t.word(), access=OPEN4_SHARE_ACCESS_READ,
+                       deny=OPEN4_SHARE_DENY_WRITE)
+    check(res, NFS4ERR_SHARE_DENIED)
+
+    res = c2.close_file(t.word(), fh, stateid)
+    check(res)
+    os.close()
+
+def testOpenUpgradeCourtesy(t, env):
+    """test open upgrade that conflicts with courtesy client
+
+    FLAGS: opendowngrade all
+    DEPEND: MKFILE
+    CODE:OPDG13
+    """
+    c = env.c1
+    c.init_connection()
+    os = open_sequence(c, t.word())
+    os.open(OPEN4_SHARE_ACCESS_WRITE)
+    leasetime = c.getLeaseTime()
+    env.sleep(leasetime/2, "sleep 1/2 grace period")
+
+    c2 = env.c2
+    c2.init_connection()
+    owner = t.word()
+    res = c2.open_file(owner, access=OPEN4_SHARE_ACCESS_READ,
+                       deny=OPEN4_SHARE_DENY_NONE)
+    check(res)
+    fh, stateid = c2.confirm(owner, res)
+
+    env.sleep((leasetime/2) + 5, "wait for c1's lease to expire")
+    while 1:
+        res = c2.open_file(owner, access=OPEN4_SHARE_ACCESS_READ,
+                       deny=OPEN4_SHARE_DENY_WRITE)
+        if res.status == NFS4_OK: break
+        check(res, [NFS4_OK, NFS4ERR_DELAY],
+                   "Open which causes conflict with courtesy client")
+        env.sleep(2, 'Got NFS4ERR_DELAY on open')
+
+    fh = res.resarray[-1].switch.switch.object
+    stateid = res.resarray[-2].switch.switch.stateid
+    res = c2.close_file(owner, fh, stateid)
+    check(res)
-- 
2.27.0


                 reply	other threads:[~2023-02-16 20:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1676577675-16451-1-git-send-email-dai.ngo@oracle.com \
    --to=dai.ngo@oracle.com \
    --cc=bfields@fieldses.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox