From 173b0eeec736b75e5cb5d1cc1f50f5fcfd7749f5 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mar 25 2024 01:19:23 +0000 Subject: nfs: only issue commit in DIO codepath if we have uncommitted data (git-fixes). --- diff --git a/patches.suse/nfs-only-issue-commit-in-DIO-codepath-if-we-have-unc.patch b/patches.suse/nfs-only-issue-commit-in-DIO-codepath-if-we-have-unc.patch new file mode 100644 index 0000000..e993b82 --- /dev/null +++ b/patches.suse/nfs-only-issue-commit-in-DIO-codepath-if-we-have-unc.patch @@ -0,0 +1,107 @@ +From: Jeff Layton +Date: Fri, 22 Jul 2022 14:12:20 -0400 +Subject: [PATCH] nfs: only issue commit in DIO codepath if we have uncommitted + data +Git-commit: 69d966510d9f5de81588b37d23a9ee8ccc477b23 +Patch-mainline: v6.0 +References: git-fixes + +Currently, we try to determine whether to issue a commit based on +nfs_write_need_commit which looks at the current verifier. In the case +where we got a short write and then tried to follow it up with one that +failed, the verifier can't be trusted. + +What we really want to know is whether the pgio request had any +successful writes that came back as UNSTABLE. Add a new flag to the pgio +request, and use that to indicate that we've had a successful unstable +write. Only issue a commit if that flag is set. + +Signed-off-by: Jeff Layton +Signed-off-by: Trond Myklebust +Acked-by: NeilBrown + +--- + fs/nfs/direct.c | 2 +- + fs/nfs/write.c | 48 ++++++++++++++++++++++++++++++------------------ + include/linux/nfs_xdr.h | 1 + + 3 files changed, 32 insertions(+), 19 deletions(-) + +--- a/fs/nfs/direct.c ++++ b/fs/nfs/direct.c +@@ -737,7 +737,7 @@ static void nfs_direct_write_completion( + } + + nfs_direct_count_bytes(dreq, hdr); +- if (hdr->good_bytes != 0 && nfs_write_need_commit(hdr)) { ++ if (test_bit(NFS_IOHDR_UNSTABLE_WRITES, &hdr->flags)) { + switch (dreq->flags) { + case 0: + dreq->flags = NFS_ODIRECT_DO_COMMIT; +--- a/fs/nfs/write.c ++++ b/fs/nfs/write.c +@@ -1582,25 +1582,37 @@ static int nfs_writeback_done(struct rpc + return status; + nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, hdr->res.count); + +- if (hdr->res.verf->committed < hdr->args.stable && +- task->tk_status >= 0) { +- /* We tried a write call, but the server did not +- * commit data to stable storage even though we +- * requested it. +- * Note: There is a known bug in Tru64 < 5.0 in which +- * the server reports NFS_DATA_SYNC, but performs +- * NFS_FILE_SYNC. We therefore implement this checking +- * as a dprintk() in order to avoid filling syslog. +- */ +- static unsigned long complain; ++ if (task->tk_status >= 0) { ++ enum nfs3_stable_how committed = hdr->res.verf->committed; + +- /* Note this will print the MDS for a DS write */ +- if (time_before(complain, jiffies)) { +- dprintk("NFS: faulty NFS server %s:" +- " (committed = %d) != (stable = %d)\n", +- NFS_SERVER(inode)->nfs_client->cl_hostname, +- hdr->res.verf->committed, hdr->args.stable); +- complain = jiffies + 300 * HZ; ++ if (committed == NFS_UNSTABLE) { ++ /* ++ * We have some uncommitted data on the server at ++ * this point, so ensure that we keep track of that ++ * fact irrespective of what later writes do. ++ */ ++ set_bit(NFS_IOHDR_UNSTABLE_WRITES, &hdr->flags); ++ } ++ ++ if (committed < hdr->args.stable) { ++ /* We tried a write call, but the server did not ++ * commit data to stable storage even though we ++ * requested it. ++ * Note: There is a known bug in Tru64 < 5.0 in which ++ * the server reports NFS_DATA_SYNC, but performs ++ * NFS_FILE_SYNC. We therefore implement this checking ++ * as a dprintk() in order to avoid filling syslog. ++ */ ++ static unsigned long complain; ++ ++ /* Note this will print the MDS for a DS write */ ++ if (time_before(complain, jiffies)) { ++ dprintk("NFS: faulty NFS server %s:" ++ " (committed = %d) != (stable = %d)\n", ++ NFS_SERVER(inode)->nfs_client->cl_hostname, ++ committed, hdr->args.stable); ++ complain = jiffies + 300 * HZ; ++ } + } + } + +--- a/include/linux/nfs_xdr.h ++++ b/include/linux/nfs_xdr.h +@@ -1422,6 +1422,7 @@ enum { + NFS_IOHDR_EOF, + NFS_IOHDR_REDO, + NFS_IOHDR_STAT, ++ NFS_IOHDR_UNSTABLE_WRITES, + }; + + struct nfs_io_completion; diff --git a/series.conf b/series.conf index f03125a..c52f3fa 100644 --- a/series.conf +++ b/series.conf @@ -63721,6 +63721,7 @@ patches.suse/fs-add-mode_strip_sgid-helper.patch patches.suse/fs-Add-missing-umask-strip-in-vfs_tmpfile.patch patches.suse/fs-move-S_ISGID-stripping-into-the-vfs_-helpers.patch + patches.suse/nfs-only-issue-commit-in-DIO-codepath-if-we-have-unc.patch patches.suse/NFSv4.1-RECLAIM_COMPLETE-must-handle-EACCES.patch patches.suse/SUNRPC-Reinitialise-the-backchannel-request-buffers-.patch patches.suse/Makefile-link-with-z-noexecstack-no-warn-rwx-segment.patch