opnsense-src/sys/fs/fuse
Alan Somers 3d721de049 Fix NFS exports of FUSE file systems for big directories
The FUSE protocol does not require that a directory entry's d_off field
outlive the lifetime of its directory's file handle.  Since the NFS
server must reopen the directory on every VOP_READDIR call, that means
it can't pass uio->uio_offset down to the FUSE server.  Instead, it must
read the directory from 0 each time.  It may need to issue multiple
FUSE_READDIR operations until it finds the d_off field that it's looking
for.  That was the intention behind SVN r348209 and r297887, but a logic
bug prevented subsequent FUSE_READDIR operations from ever being issued,
rendering large directories incompletely browseable.

Reviewed by:	rmacklem

(cherry picked from commit d088dc76e1)

fusefs: optimize NFS readdir for FUSE_NO_OPENDIR_SUPPORT

In its lowest common denominator, FUSE does not require that a directory
entry's d_off field is valid outside of the lifetime of the directory's
FUSE file handle.  But since NFS is stateless, it must reopen the
directory on every call to VOP_READDIR.  That means reading the
directory all the way from the first entry.  Not only does this create
an O(n^2) condition for large directories, but it can also result in
incorrect behavior if either:

* The file system _does_ change the d_off field for the last directory
  entry previously seen by NFS, or
* The file system deletes the last directory entry previously seen by
  NFS.

Handily, for file systems that set FUSE_NO_OPENDIR_SUPPORT d_off is
guaranteed to be valid for the lifetime of the directory entry, there is
no need to read the directory from the start.

Reviewed by:	rmacklem

(cherry picked from commit 4a6526d84a)

fusefs: require FUSE_NO_OPENDIR_SUPPORT for NFS exporting

FUSE file systems that do not set FUSE_NO_OPENDIR_SUPPORT do not
guarantee that d_off will be valid after closing and reopening a
directory.  That conflicts with NFS's statelessness, that results in
unresolvable bugs when NFS reads large directories, if:

* The file system _does_ change the d_off field for the last directory
  entry previously returned by VOP_READDIR, or
* The file system deletes the last directory entry previously seen by
  NFS.

Rather than doing a poor job of exporting such file systems, it's better
just to refuse.

Even though this is technically a breaking change, 13.0-RELEASE's
NFS-FUSE support was bad enough that an MFC should be allowed.

Reviewed by:	rmacklem
Differential Revision: https://reviews.freebsd.org/D33726

(cherry picked from commit 00134a0789)

fusefs: fix the build without INVARIANTS after 00134a0789

MFC with:	00134a0789
Reported by:	se

(cherry picked from commit 18ed2ce77a)
2022-03-02 16:35:33 -07:00
..
fuse.h [skip ci] update copyright headers in fusefs files 2019-06-28 04:18:10 +00:00
fuse_device.c modules: increase MAXMODNAME and provide backward compat 2021-12-30 18:26:18 +00:00
fuse_file.c fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT 2021-12-06 21:51:55 -07:00
fuse_file.h fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT 2021-12-06 21:51:55 -07:00
fuse_internal.c Fix NFS exports of FUSE file systems for big directories 2022-03-02 16:35:33 -07:00
fuse_internal.h Fix NFS exports of FUSE file systems for big directories 2022-03-02 16:35:33 -07:00
fuse_io.c fusefs: Address -Wunused-but-set-variable warnings 2022-01-27 09:24:53 -05:00
fuse_io.h fusefs: inline fuse_io_dispatch 2022-01-02 19:54:39 -07:00
fuse_ipc.c fusefs: implement VOP_ALLOCATE 2022-01-17 18:13:28 -07:00
fuse_ipc.h fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT 2021-12-06 21:51:55 -07:00
fuse_kernel.h fusefs: implement FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT 2021-12-06 21:51:55 -07:00
fuse_main.c modules: increase MAXMODNAME and provide backward compat 2021-12-30 18:26:18 +00:00
fuse_node.c fusefs: Address -Wunused-but-set-variable warnings 2022-01-27 09:24:53 -05:00
fuse_node.h Fix a race in fusefs that can corrupt a file's size. 2022-01-17 17:59:03 -07:00
fuse_vfsops.c Fix a race in fusefs that can corrupt a file's size. 2022-01-17 17:59:03 -07:00
fuse_vnops.c Fix NFS exports of FUSE file systems for big directories 2022-03-02 16:35:33 -07:00