diff mbox

[v2,4/5] CLNT: test lock before RECLAIM_COMPLETE

Message ID 4D904E15.9030401@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mi Jinlong March 28, 2011, 9 a.m. UTC
None
diff mbox

Patch

diff --git a/nfs4.1/server41tests/st_reclaim_complete.py b/nfs4.1/server41tests/st_reclaim_complete.py
index 4c9fc37..c712d0e 100644
--- a/nfs4.1/server41tests/st_reclaim_complete.py
+++ b/nfs4.1/server41tests/st_reclaim_complete.py
@@ -70,3 +70,40 @@  def testReclaimAfterRECC(t, env):
     res = sess.compound([op.putfh(cfh), op.lock(READ_LT, TRUE, 0, 1, lowner)])
     check(res, NFS4ERR_NO_GRACE)
     sess.destroy()
+
+def testLockBeforeRECC(t, env):
+    """After a client establishes a new client ID, if non-reclaim
+       locking operations are done before the RECLAIM_COMPLETE,
+       error NFS4ERR_GRACE will be returned. rfc5661 18.51.3
+
+    FLAGS: reclaim_complete all
+    CODE: RECC3
+    """
+    name = env.testname(t)
+    c = env.c1.new_client(name)
+    sess = c.create_session()
+
+    fname = "owner_%s" % name
+    path = sess.c.homedir + [name]
+    res = create_file(sess, fname, path, access=OPEN4_SHARE_ACCESS_BOTH)
+    check(res)
+
+    # Get stateid from OPEN4resok for making a lockowner
+    nres = opt_result(res, OP_OPEN)
+    if nres == None:
+        fail("Can not get OPEN4resok!")
+    oseqid = nres.stateid
+
+    owner = open_owner4(0, "My Open Owner")
+    otlowner = open_to_lock_owner4(0, oseqid, 0, owner)
+    lowner = locker4(TRUE, otlowner)
+
+    # Get filehandle from GETFHresok for locking
+    nres = opt_result(res, OP_GETFH)
+    if nres == None:
+        fail("Can not get GETFHresok!")
+    cfh = nres.object
+
+    res = sess.compound([op.putfh(cfh), op.lock(READ_LT, FALSE, 0, 1, lowner)])
+    check(res, NFS4ERR_NO_GRACE)
+    sess.destroy()