[PATCH pynfs v3 20/26] server41tests: test cross-directory rename REMOVE notification
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
Verify that a cross-directory rename generates a NOTIFY4_REMOVE_ENTRY notification on the source directory's delegation, rather than a NOTIFY4_RENAME_ENTRY (which is only for within-directory renames). Signed-off-by: Jeff Layton <[email protected]> --- nfs4.1/server41tests/st_dir_deleg.py | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/nfs4.1/server41tests/st_dir_deleg.py b/nfs4.1/server41tests/st_dir_deleg.py index 5d7c1a8fbaca..0751cf1ec47e 100644 --- a/nfs4.1/server41tests/st_dir_deleg.py +++ b/nfs4.1/server41tests/st_dir_deleg.py @@ -738,3 +738,60 @@ def testDirDelegFilehandle(t, env): fail("No filehandle in ADD notification attributes") if attr_dict[FATTR4_FILEHANDLE] != file_fh: fail("Filehandle in notification doesn't match GETFH result") + +def testDirDelegCrossRename(t, env): + """Verify cross-directory rename generates REMOVE notification on source + + Per RFC 8881bis Section 27.4.6, a rename across directories sends + a REMOVE notification to the source directory and an ADD notification + to the target directory, rather than a RENAME notification. + + FLAGS: dirdeleg all + CODE: DIRDELEG17 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_REMOVE_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + # Create a file in the delegated directory + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + # Create a target directory (sibling of the delegated directory) + topdir = c.homedir + [t.code.encode('utf8')] + targetdir = c.homedir + [b"%s_target" % t.code.encode('utf8')] + res = create_obj(sess1, targetdir) + check(res) + + # Rename the file from the delegated dir to the target dir from sess2 + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + oldpath = topdir + [env.testname(t)] + newpath = targetdir + [env.testname(t)] + res = rename_obj(sess2, oldpath, newpath) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_REMOVE_ENTRY: + fail("Expected REMOVE notification for cross-dir rename, got %d" % evt_type) + if evt.nrm_old_entry.ne_file != env.testname(t): + fail("Wrong entry name in REMOVE notification") -- 2.54.0