From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH v1 1/3] NFSD: Make the write verifier reset helper available outside vfs.c
Date: Wed, 12 Aug 2026 10:24:34 -0400 [thread overview]
Message-ID: <20260812142436.35042-2-cel@kernel.org> (raw)
In-Reply-To: <20260812142436.35042-1-cel@kernel.org>
A subsequent patch moves the NFSv4-specific portions of
nfsd4_clone_file_range() out of fs/nfsd/vfs.c and into its caller in
fs/nfsd/nfs4proc.c. One of those portions resets the write verifier
when the post-clone sync fails.
netns.h already exposes nfsd_reset_write_verifier(), but that is the
unconditional reset. commit_reset_write_verifier() wraps it with the
policy that decides which errors warrant a reset: -EAGAIN and -ESTALE
do not indicate a problem with durable storage, so they leave the
verifier alone. A caller outside vfs.c has to apply the same policy,
so make the wrapper visible rather than duplicate its switch.
Rename it to nfsd_maybe_reset_write_verifier() on the way out.
Signed-off-by: Chuck Lever <cel@kernel.org>
---
fs/nfsd/vfs.c | 29 ++++++++++++++++++++---------
fs/nfsd/vfs.h | 5 +++++
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 6d865f4f9ba3..fad51a899062 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -352,9 +352,20 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
return err;
}
-static void
-commit_reset_write_verifier(struct nfsd_net *nn, struct svc_rqst *rqstp,
- int err)
+/**
+ * nfsd_maybe_reset_write_verifier - Reset the write verifier after an I/O error
+ * @nn: nfsd namespace holding the write verifier
+ * @rqstp: RPC transaction context
+ * @err: errno reported by the failed operation
+ *
+ * A write verifier reset tells clients that unstable data the server has
+ * already acknowledged might have been lost. Client response is to resend
+ * in-flight dirty data.
+ *
+ * Context: Process context.
+ */
+void nfsd_maybe_reset_write_verifier(struct nfsd_net *nn,
+ struct svc_rqst *rqstp, int err)
{
switch (err) {
case -EAGAIN:
@@ -735,7 +746,7 @@ __be32 nfsd4_clone_file_range(struct svc_rqst *rqstp,
&nfsd4_get_cstate(rqstp)->current_fh,
dst_pos,
count, status);
- commit_reset_write_verifier(nn, rqstp, status);
+ nfsd_maybe_reset_write_verifier(nn, rqstp, status);
ret = nfserrno(status);
}
}
@@ -1472,21 +1483,21 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp,
break;
}
if (host_err < 0) {
- commit_reset_write_verifier(nn, rqstp, host_err);
+ nfsd_maybe_reset_write_verifier(nn, rqstp, host_err);
goto out_nfserr;
}
nfsd_stats_io_write_add(nn, exp, *cnt);
fsnotify_modify(file);
host_err = filemap_check_wb_err(file->f_mapping, since);
if (host_err < 0) {
- commit_reset_write_verifier(nn, rqstp, host_err);
+ nfsd_maybe_reset_write_verifier(nn, rqstp, host_err);
goto out_nfserr;
}
if (iocb_flags && fhp->fh_use_wgather) {
host_err = wait_for_concurrent_writes(file);
if (host_err < 0)
- commit_reset_write_verifier(nn, rqstp, host_err);
+ nfsd_maybe_reset_write_verifier(nn, rqstp, host_err);
}
out_nfserr:
@@ -1662,14 +1673,14 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
err2 = filemap_check_wb_err(nf->nf_file->f_mapping,
since);
if (err2 < 0)
- commit_reset_write_verifier(nn, rqstp, err2);
+ nfsd_maybe_reset_write_verifier(nn, rqstp, err2);
err = nfserrno(err2);
break;
case -EINVAL:
err = nfserr_notsupp;
break;
default:
- commit_reset_write_verifier(nn, rqstp, err2);
+ nfsd_maybe_reset_write_verifier(nn, rqstp, err2);
err = nfserrno(err2);
}
} else
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 3aa4522ca0a4..18171ccc6d16 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -86,7 +86,12 @@ static inline bool nfsd_attrs_valid(struct nfsd_attrs *attrs)
attrs->na_pacl || attrs->na_dpacl);
}
+struct nfsd_net;
+
__be32 nfserrno (int errno);
+void nfsd_maybe_reset_write_verifier(struct nfsd_net *nn,
+ struct svc_rqst *rqstp,
+ int err);
__be32 nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
struct svc_export **expp);
__be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *,
--
2.54.0
next prev parent reply other threads:[~2026-08-12 14:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 14:24 [PATCH v1 0/3] Clean up fs/nfsd/vfs.c includes Chuck Lever
2026-08-12 14:24 ` Chuck Lever [this message]
2026-08-12 14:24 ` [PATCH v1 2/3] NFSD: Move NFSv4-specific CLONE logic into nfsd4_clone() Chuck Lever
2026-08-12 14:24 ` [PATCH v1 3/3] NFSD: Remove xdr-related headers from fs/nfsd/vfs.c Chuck Lever
2026-08-12 17:36 ` [PATCH v1 0/3] Clean up fs/nfsd/vfs.c includes Jeff Layton
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=20260812142436.35042-2-cel@kernel.org \
--to=cel@kernel.org \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.