On Mon, 2025-07-07 at 14:46 -0400, Benjamin Coddington wrote: > We've been investigating new reports of filesystem corruption on > loopback images on NFS clients. It appears that during writeback the > loopback driver encounters allocation failures in NFS and fails to write > dirty pages to the backing file. > > We believe the problem is due to the loopback driver performing writeback > from a workqueue (so PF_WQ_WORKER is set), however ever since work to > improve NFS' memory allocation strategies [1] its possible that NFS > incorrectly assumes that if PF_WQ_WORKER is set then the writeback context > is nfsiod. To make things worse, NFS does not expect PF_WQ_WORKER to be set > along with other PF_ flags such as PF_MEMALLOC_NOIO, but cannot really know > (without checking them all) which other allocation flags are set should > writeback be entered from a NFS-external workqueue worker. > > To fix this, I'd like to introduce a way to check which specific workqueue > is being served by a worker (in patch 1), so that NFS can ensure that it > sets certain allocation flags only for the nfsiod workqueue workers (in > patch 2). > > [1]: https://lore.kernel.org/linux-nfs/20220322011618.1052288-1-trondmy@xxxxxxxxxx/ > > Benjamin Coddington (2): > workqueue: Add a helper to identify current workqueue > NFS: Improve nfsiod workqueue detection for allocation flags > > fs/nfs/internal.h | 12 +++++++++++- > include/linux/workqueue.h | 1 + > kernel/workqueue.c | 18 ++++++++++++++++++ > 3 files changed, 30 insertions(+), 1 deletion(-) Looks like a nice simple solution, and the workqueue helper seems reasonable. Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>