From patchwork Fri May 27 19:44:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 12863760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA5AFC433EF for ; Fri, 27 May 2022 19:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350400AbiE0TpD (ORCPT ); Fri, 27 May 2022 15:45:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344585AbiE0TpB (ORCPT ); Fri, 27 May 2022 15:45:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3C1E3C4A5 for ; Fri, 27 May 2022 12:44:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7DAC2B824FD for ; Fri, 27 May 2022 19:44:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1080CC385A9; Fri, 27 May 2022 19:44:56 +0000 (UTC) Subject: [PATCH v2] Test renaming onto an open file From: Chuck Lever To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Date: Fri, 27 May 2022 15:44:55 -0400 Message-ID: <165368065607.3280217.2106378952611449081.stgit@morisot.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org There has been a recent report of RENAME onto an open file resulting in a bogus ESTALE when that open (and now deleted) file is closed. Build in some testing with and without SEQUENCE to ensure a server is handling this case as expected. Signed-off-by: Chuck Lever Changes since v1: - None. This is a just a repost. --- nfs4.0/servertests/st_rename.py | 16 ++++++++++++++++ nfs4.1/server41tests/st_rename.py | 19 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/nfs4.0/servertests/st_rename.py b/nfs4.0/servertests/st_rename.py index afe9a7fe0a58..3302608719e3 100644 --- a/nfs4.0/servertests/st_rename.py +++ b/nfs4.0/servertests/st_rename.py @@ -524,6 +524,22 @@ def testLinkRename(t, env): t.fail("RENAME of file into its hard link should do nothing, " "but cinfo was changed") +def testStaleRename(t, env): + """RENAME file over an open file should allow CLOSE + + FLAGS: rename all + CODE: RNM21 + """ + c = env.c1 + c.init_connection() + basedir = c.homedir + [t.word()] + c.maketree([t.word(), b'file']) + fh, stateid = c.create_confirm(t.word(), path=basedir + [b'file2']) + res = c.rename_obj(basedir + [b'file'], basedir + [b'file2']) + check(res) + res = c.close_file(t.word(), fh, stateid) + check(res, msg="CLOSE after RENAME deletes target returns ESTALE") + ########################################### def testNamingPolicy(t, env): diff --git a/nfs4.1/server41tests/st_rename.py b/nfs4.1/server41tests/st_rename.py index 066df749379f..26ed4d275067 100644 --- a/nfs4.1/server41tests/st_rename.py +++ b/nfs4.1/server41tests/st_rename.py @@ -1,5 +1,5 @@ from xdrdef.nfs4_const import * -from .environment import check, fail, maketree, rename_obj, get_invalid_utf8strings, create_obj, create_confirm, link, use_obj, create_file +from .environment import check, fail, maketree, rename_obj, get_invalid_utf8strings, create_obj, create_confirm, link, use_obj, create_file, close_file import nfs_ops op = nfs_ops.NFS4ops() from xdrdef.nfs4_type import * @@ -529,3 +529,20 @@ def testLinkRename(t, env): if scinfo.before != scinfo.after or tcinfo.before != tcinfo.after: t.fail("RENAME of file into its hard link should do nothing, " "but cinfo was changed") + +def testStaleRename(t, env): + """RENAME file over an open file should allow CLOSE + + FLAGS: rename all + CODE: RNM21 + """ + name = env.testname(t) + owner = b"owner_%s" % name + sess = env.c1.new_client_session(name) + maketree(sess, [name, b'file']) + basedir = env.c1.homedir + [name] + fh, stateid = create_confirm(sess, owner, path=basedir + [b'file2']) + res = rename_obj(sess, basedir + [b'file'], basedir + [b'file2']) + check(res) + res = close_file(sess, fh, stateid) + check(res, msg="CLOSE after RENAME deletes target returns ESTALE")