]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
NFS: Fix another fsync() issue after a server reboot
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 13 Aug 2022 12:22:25 +0000 (08:22 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 23 Nov 2022 14:11:08 +0000 (15:11 +0100)
commit93b45a77c0ce48383bf24fff8e4c5087268f4118
tree79d75959d0e31b9fd741cab93f6e77eb91a2ec08
parentdacfbfce78d13e643cb51880417344e06566a968
NFS: Fix another fsync() issue after a server reboot

BugLink: https://bugs.launchpad.net/bugs/1993003
[ Upstream commit 67f4b5dc49913abcdb5cc736e73674e2f352f81d ]

Currently, when the writeback code detects a server reboot, it redirties
any pages that were not committed to disk, and it sets the flag
NFS_CONTEXT_RESEND_WRITES in the nfs_open_context of the file descriptor
that dirtied the file. While this allows the file descriptor in question
to redrive its own writes, it violates the fsync() requirement that we
should be synchronising all writes to disk.
While the problem is infrequent, we do see corner cases where an
untimely server reboot causes the fsync() call to abandon its attempt to
sync data to disk and causing data corruption issues due to missed error
conditions or similar.

In order to tighted up the client's ability to deal with this situation
without introducing livelocks, add a counter that records the number of
times pages are redirtied due to a server reboot-like condition, and use
that in fsync() to redrive the sync to disk.

Fixes: 2197e9b06c22 ("NFS: Fix up fsync() when the server rebooted")
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/nfs/file.c
fs/nfs/inode.c
fs/nfs/write.c
include/linux/nfs_fs.h