Skip to content

Commit 666e837

Browse files
jtlaytongregkh
authored andcommitted
nfsd: reset write verifier on deferred writeback errors
commit 2090b05 upstream. nfsd_vfs_write() and nfsd_commit() both call filemap_check_wb_err() to detect deferred writeback errors, but neither rotates the server's write verifier (nn->writeverf) when this check fails. Every other durable-storage-failure path in these functions calls commit_reset_write_verifier() before returning an error. The missing rotation means clients holding UNSTABLE write data under the current verifier will COMMIT, receive the unchanged verifier back, and conclude their data is durable — silently dropping data that failed writeback. This violates the UNSTABLE+COMMIT durability contract (RFC 1813 §3.3.7, RFC 8881 §18.32). Add commit_reset_write_verifier() calls at both filemap_check_wb_err() error sites, matching the pattern used by adjacent error paths in the same functions. The helper already filters -EAGAIN and -ESTALE internally, so the calls are unconditionally safe. Reported-by: Chris Mason <clm@meta.com> Fixes: 555dbf1 ("nfsd: Replace use of rwsem with errseq_t") Cc: stable@vger.kernel.org Assisted-by: kres:claude-opus-4-6 Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> [ cel: 6.6.y predates the commit_reset_write_verifier() helper (v6.7); open-coded nfsd_reset_write_verifier() and the reset tracepoint at both sites, matching the other reset paths in these functions ] Signed-off-by: Chuck Lever <cel@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 48a586e commit 666e837

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

fs/nfsd/vfs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,8 +1185,11 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
11851185
nfsd_stats_io_write_add(nn, exp, *cnt);
11861186
fsnotify_modify(file);
11871187
host_err = filemap_check_wb_err(file->f_mapping, since);
1188-
if (host_err < 0)
1188+
if (host_err < 0) {
1189+
nfsd_reset_write_verifier(nn);
1190+
trace_nfsd_writeverf_reset(nn, rqstp, host_err);
11891191
goto out_nfserr;
1192+
}
11901193

11911194
if (stable && use_wgather) {
11921195
host_err = wait_for_concurrent_writes(file);
@@ -1330,6 +1333,10 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
13301333
nfsd_copy_write_verifier(verf, nn);
13311334
err2 = filemap_check_wb_err(nf->nf_file->f_mapping,
13321335
since);
1336+
if (err2 < 0) {
1337+
nfsd_reset_write_verifier(nn);
1338+
trace_nfsd_writeverf_reset(nn, rqstp, err2);
1339+
}
13331340
err = nfserrno(err2);
13341341
break;
13351342
case -EINVAL:

0 commit comments

Comments
 (0)