]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
fusefs: fix mmap'd writes in direct_io mode
authorAlan Somers <asomers@FreeBSD.org>
Thu, 24 Sep 2020 16:27:53 +0000 (16:27 +0000)
committerAlan Somers <asomers@FreeBSD.org>
Thu, 24 Sep 2020 16:27:53 +0000 (16:27 +0000)
commita62772a78e524da2de90f67bf8824b8a3035dd5c
treec37c6bff8628c8df368c90cb905af577f01837af
parentf0f718ce96f74076ea14bff7e71e578573d80641
fusefs: fix mmap'd writes in direct_io mode

If a FUSE server returns FOPEN_DIRECT_IO in response to FUSE_OPEN, that
instructs the kernel to bypass the page cache for that file. This feature
is also known by libfuse's name: "direct_io".

However, when accessing a file via mmap, there is no possible way to bypass
the cache completely. This change fixes a deadlock that would happen when
an mmap'd write tried to invalidate a portion of the cache, wrongly assuming
that a write couldn't possibly come from cache if direct_io were set.

Arguably, we could instead disable mmap for files with FOPEN_DIRECT_IO set.
But allowing it is less likely to cause user complaints, and is more in
keeping with the spirit of open(2), where O_DIRECT instructs the kernel to
"reduce", not "eliminate" cache effects.

PR: 247276
Reported by: trapexit@spawn.link
Reviewed by: cem
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26485
sys/fs/fuse/fuse_io.c
tests/sys/fs/fusefs/write.cc