Skip to contentSkip to conversation

4.1 server tests: old stateid seqid after an OPEN upgrade

PATCH New Seunghun Shin 1 participant 4 messages Dec 6

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover 4.1 server tests: old stateid seqid after an OPEN upgrade

NFSv4.1 has no tests for a CLOSE, OPEN_DOWNGRADE or LOCKU that presents an outdated stateid seqid; 4.0 has CLOSE5, OPDG7 and LKU7. RFC 8881 section 8.2.2 requires NFS4ERR_OLD_STATEID here, and names the case where a client closes a file without knowing that a parallel OPEN upgraded it. Servers that accept the old seqid destroy an open the client has just been given, and the Linux client then stalls in open(2).

Add OPEN32 (CLOSE), OPEN33 (OPEN_DOWNGRADE) and LKU1 (LOCKU). Each checks that the request fails with NFS4ERR_OLD_STATEID and that the open or lock stateid is still usable afterwards.

Tested against the Linux NFS server (Ubuntu, kernel 7.0.0-38-generic):
all three pass, repeatedly. (One run of LKU1 in a batch right after the test tree was created failed once; I could not reproduce it in nine further runs and did not capture the message.)
Against dCache nfs4j master (c231be58) OPEN32 and OPEN33 pass, and LKU1 fails with "NFS4ERR_OLD_STATEID, instead got NFS4_OK", which matches a missing check there.

Seunghun Shin (3):
4.1 server tests: add CLOSE test with an old stateid seqid after OPEN
upgrade
4.1 server tests: add OPEN_DOWNGRADE test with an old stateid seqid
after OPEN upgrade
4.1 server tests: add LOCKU test with an old lock stateid seqid

 nfs4.1/server41tests/__init__.py |  1 +
 nfs4.1/server41tests/st_locku.py | 49 ++++++++++++++++++++++++++++
 nfs4.1/server41tests/st_open.py  | 55 ++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 nfs4.1/server41tests/st_locku.py
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/3 4.1 server tests: add CLOSE test with an old stateid seqid after OPEN upgrade

RFC 8881 section 8.2.2 requires NFS4ERR_OLD_STATEID when a stateid carries a seqid older than the current one, which happens when a client closes a file without knowing that a parallel OPEN upgraded it. A server that accepts the old seqid destroys the open the client was just given.

NFSv4.0 has this test (CLOSE5); add it for NFSv4.1.

---
 nfs4.1/server41tests/st_open.py | 37 +++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
nfs4.1/server41tests/st_open.py +37 -0
index 28540b5..92c06ba 100644
@@ -195,3 +195,40 @@ def testCloseWithZeroSeqid(t, env):
     stateid.seqid = 0
     res = close_file(sess1, fh, stateid=stateid)
     check(res)
+
+def _open_upgrade(sess, name):
+    """OPEN a file for WRITE, then upgrade it with a second OPEN for READ
+
+    Return the file handle, and the stateids of the first and second OPEN.
+    """
+    owner = b"owner_%s" % name
+    path = sess.c.homedir + [name]
+    res = create_file(sess, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
+    check(res)
+    expect(res, seqid=1)
+    old = res.resarray[-2].stateid
+    res = open_file(sess, owner, path, access=OPEN4_SHARE_ACCESS_READ)
+    check(res)
+    expect(res, seqid=2)
+    fh = res.resarray[-1].object
+    return fh, old, res.resarray[-2].stateid
+
+def testCloseWithOldStateid(t, env):
+    """CLOSE with the stateid of an OPEN that was since upgraded
+    should return NFS4ERR_OLD_STATEID, and leave the open alive
+
+    A client can send such a CLOSE when it closes a file without knowing
+    that a parallel OPEN upgraded it (RFC 8881 section 8.2.2).
+
+    FLAGS: open oldid all
+    CODE: OPEN32
+    """
+    sess1 = env.c1.new_client_session(env.testname(t))
+    fh, old, stateid = _open_upgrade(sess1, env.testname(t))
+
+    res = close_file(sess1, fh, stateid=old)
+    check(res, NFS4ERR_OLD_STATEID, "CLOSE with old stateid")
+    # The open must have survived
+    res = close_file(sess1, fh, stateid=stateid)
+    check(res)
+
Signature · 1 line
2.55.0
#2 lore raw

PATCH 2/3 4.1 server tests: add OPEN_DOWNGRADE test with an old stateid seqid after OPEN upgrade

In reply to Seunghun Shin

RFC 8881 section 8.2.2 requires NFS4ERR_OLD_STATEID when the stateid presented carries a seqid older than the current one. NFSv4.0 has this test (OPDG7); add it for NFSv4.1.

---
 nfs4.1/server41tests/st_open.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
nfs4.1/server41tests/st_open.py +18 -0
index 92c06ba..a42b10d 100644
@@ -232,3 +232,21 @@ def testCloseWithOldStateid(t, env):
     res = close_file(sess1, fh, stateid=stateid)
     check(res)
 
+def testOpenDowngradeWithOldStateid(t, env):
+    """OPEN_DOWNGRADE with the stateid of an OPEN that was since upgraded
+    should return NFS4ERR_OLD_STATEID
+
+    FLAGS: open oldid all
+    CODE: OPEN33
+    """
+    sess1 = env.c1.new_client_session(env.testname(t))
+    fh, old, stateid = _open_upgrade(sess1, env.testname(t))
+
+    ops = [op.putfh(fh), op.open_downgrade(old, 0, OPEN4_SHARE_ACCESS_READ,
+                                           OPEN4_SHARE_DENY_NONE)]
+    res = sess1.compound(ops)
+    check(res, NFS4ERR_OLD_STATEID, "OPEN_DOWNGRADE with old stateid")
+    # The open must have survived
+    res = close_file(sess1, fh, stateid=stateid)
+    check(res)
+
Signature · 1 line
2.55.0
#3 lore raw

PATCH 3/3 4.1 server tests: add LOCKU test with an old lock stateid seqid

In reply to Seunghun Shin

RFC 8881 section 8.2.2 requires NFS4ERR_OLD_STATEID when the stateid presented carries a seqid older than the current one. NFSv4.0 has this test (LKU7); add it for NFSv4.1.

---
 nfs4.1/server41tests/__init__.py |  1 +
 nfs4.1/server41tests/st_locku.py | 49 ++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 nfs4.1/server41tests/st_locku.py
nfs4.1/server41tests/__init__.py +1 -0
index 156c5e3..13c778c 100644
@@ -23,6 +23,7 @@ __all__ = ["st_exchange_id.py", # draft 21
 ##           "st_debug.py",
 ##           "st_loop",
            "st_current_stateid.py",
+           "st_locku.py",
            "st_sparse.py",
            "st_flex.py",
            "st_xattr.py",
nfs4.1/server41tests/st_locku.py new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.55.0