From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neil@brown.name>, Chuck Lever <chuck.lever@oracle.com>
Cc: Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH v5 03/11] nfsd: simplify foreign-filehandle handling to better match RFC-7862
Date: Wed, 19 Nov 2025 14:23:14 -0500 [thread overview]
Message-ID: <a28961a088cdc0aa78b1dbd4a453b10bdcd76568.camel@kernel.org> (raw)
In-Reply-To: <20251119033204.360415-4-neilb@ownmail.net>
On Wed, 2025-11-19 at 14:28 +1100, NeilBrown wrote:
> From: NeilBrown <neil@brown.name>
>
> When the COPY v4.2 op is used in the inter-server copy mode, the file
> handle of the source file (presented as the saved filehandle to COPY)
> is for a different ("foreign") file server which would not be expected
> to be understood by this server. fh_verify() might return nfserr_stale
> or nfserr_badhandle.
>
> In order of this filehandle to still be available to COPY, both PUTFH
> and SAVEFH much not trigger an error.
>
> RFC 7862 section 15.2.3 says:
>
> If the request is for an inter-server copy, the source-fh is a
> filehandle from the source server and the COMPOUND procedure is being
> executed on the destination server. In this case, the source-fh is a
> foreign filehandle on the server receiving the COPY request. If
> either PUTFH or SAVEFH checked the validity of the filehandle, the
> operation would likely fail and return NFS4ERR_STALE.
>
> If a server supports the inter-server copy feature, a PUTFH followed
> by a SAVEFH MUST NOT return NFS4ERR_STALE for either operation.
> These restrictions do not pose substantial difficulties for servers.
> CURRENT_FH and SAVED_FH may be validated in the context of the
> operation referencing them and an NFS4ERR_STALE error returned for an
> invalid filehandle at that point.
>
> [The RFC neglects the possibility of NFS4ERR_BADHANDLE]
>
> Linux nfsd currently takes a different approach. Rather than just
> checking for "a PUTFH followed by a SAVEFH", it goes further to consider
> only that case when this filehandle is then used for COPY, and allows
> that it might have been subject of RESTOREFH and SAVEFH in between.
>
> This is not a problem in itself except for the extra code with little
> benefit. This analysis of the COMPOUND to detect PUTFH ops which need
> care is performed on every COMPOUND request, which is not necessary.
>
> It is sufficient to check if the relevant conditions are met only when a
> PUTFH op actually receives an error from fh_verify().
>
> This patch removes the checking code from common paths and places it in
> nfsd4_putfh() only when fh_verify() returns a relevant error.
>
> Rather than scanning ahead for a COPY, this patch notes (in
> nfsd4_compoundargs) when an inter-server COPY is decoded, and in that
> case only checks the next op to see if it is SAVEFH as this is what the
> RFC requires.
>
> A test on "inter_copy_offload_enable" is also added to be completely
> consistent with the "If a server supports the inter-server copy feature"
> precondition.
>
> As we do this test in nfsd4_putfh() there is no now need to mark the
> putfh op as "no_verify".
>
> Signed-off-by: NeilBrown <neil@brown.name>
> ---
> fs/nfsd/nfs4proc.c | 64 ++++++++++++++++------------------------------
> fs/nfsd/nfs4xdr.c | 2 +-
> fs/nfsd/xdr4.h | 2 +-
> 3 files changed, 24 insertions(+), 44 deletions(-)
>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2025-11-19 19:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 3:28 [PATCH v5 00/11] nfsd: assorted cleanups involving v4 special stateids NeilBrown
2025-11-19 3:28 ` [PATCH v5 01/11] nfsd: rename ALLOWED_WITHOUT_FH to ALLOWED_WITHOUT_LOCAL_FH and revise use NeilBrown
2025-11-19 16:02 ` Chuck Lever
2025-11-19 21:13 ` NeilBrown
2025-11-19 19:12 ` Jeff Layton
2025-11-19 3:28 ` [PATCH v5 02/11] nfsd: discard NFSD4_FH_FOREIGN NeilBrown
2025-11-19 16:27 ` Chuck Lever
2025-11-19 21:25 ` NeilBrown
2025-11-19 19:13 ` Jeff Layton
2025-11-19 3:28 ` [PATCH v5 03/11] nfsd: simplify foreign-filehandle handling to better match RFC-7862 NeilBrown
2025-11-19 16:55 ` Chuck Lever
2025-11-19 21:38 ` NeilBrown
2025-11-20 21:58 ` Chuck Lever
2025-11-22 0:46 ` NeilBrown
2025-11-19 19:23 ` Jeff Layton [this message]
2025-11-19 3:28 ` [PATCH v5 04/11] nfsd: report correct error for attempt to use foreign filehandle NeilBrown
2025-11-19 19:26 ` Jeff Layton
2025-11-19 3:28 ` [PATCH v5 05/11] nfsd: drop explicit tests for special stateids which would be invalid NeilBrown
2025-11-19 19:11 ` Chuck Lever
2025-11-19 19:32 ` Jeff Layton
2025-11-19 3:28 ` [PATCH v5 06/11] nfsd: revise names of special stateid, and predicate functions NeilBrown
2025-11-19 19:27 ` Chuck Lever
2025-11-19 21:47 ` NeilBrown
2025-11-19 3:28 ` [PATCH v5 07/11] nfsd: simplify clearing of current-state-id NeilBrown
2025-11-19 20:23 ` Chuck Lever
2025-11-19 21:55 ` NeilBrown
2025-11-19 3:28 ` [PATCH v5 08/11] nfsd: simplify use of the current stateid NeilBrown
2025-11-19 3:28 ` [PATCH v5 09/11] nfsd: simplify saving " NeilBrown
2025-11-19 3:28 ` [PATCH v5 10/11] nfsd: discard current_stateid.h NeilBrown
2025-11-19 3:28 ` [PATCH v5 11/11] nfsd: conditionally clear seqid when current_stateid is used NeilBrown
2025-11-19 20:32 ` [PATCH v5 00/11] nfsd: assorted cleanups involving v4 special stateids Chuck Lever
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=a28961a088cdc0aa78b1dbd4a453b10bdcd76568.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/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