]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
NFS: swap-out must always use STABLE writes.
authorNeilBrown <neilb@suse.de>
Sun, 6 Mar 2022 23:41:44 +0000 (10:41 +1100)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 13:19:52 +0000 (15:19 +0200)
commit4ea1d5c57870732c717d71136c9c8bfd488dcdde
tree9841b042ecc9c7a08ae4cf9a4f76bb4e50aa5063
parentec9d5b7c2e22b13fb017177dab3e4f70451c1022
NFS: swap-out must always use STABLE writes.

BugLink: https://bugs.launchpad.net/bugs/1971497
[ Upstream commit c265de257f558a05c1859ee9e3fed04883b9ec0e ]

The commit handling code is not safe against memory-pressure deadlocks
when writing to swap.  In particular, nfs_commitdata_alloc() blocks
indefinitely waiting for memory, and this can consume all available
workqueue threads.

swap-out most likely uses STABLE writes anyway as COND_STABLE indicates
that a stable write should be used if the write fits in a single
request, and it normally does.  However if we ever swap with a small
wsize, or gather unusually large numbers of pages for a single write,
this might change.

For safety, make it explicit in the code that direct writes used for swap
must always use FLUSH_STABLE.

Signed-off-by: NeilBrown <neilb@suse.de>
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/direct.c