opnsense-src/sys/fs
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
..
autofs Ensure that dirent's d_off field is initialized 2021-01-03 11:50:31 -05:00
cd9660 buffer pager: allow get_blksize method to return error 2021-09-24 03:26:59 +03:00
cuse Fix for loading cuse.ko via rc.d . Make sure we declare the cuse(3) 2020-10-23 08:44:53 +00:00
deadfs vn_open(): If the vnode is reclaimed during open(2), do not return error. 2021-02-24 09:42:42 +02:00
devfs fs: fix a few common typos in source code comments 2022-02-09 07:18:56 +01:00
ext2fs fs: fix a few common typos in source code comments 2022-02-09 07:18:56 +01:00
fdescfs fdescfs: add an option to return underlying file vnode on lookup 2021-06-11 03:33:48 +03:00
fifofs fifo: support flock 2021-10-11 09:12:48 +00:00
fuse Fix NFS exports of FUSE file systems for big directories 2022-03-02 16:35:33 -07:00
mntfs mntfs: lock mntfs pseudo devfs vnode properly 2021-11-19 06:25:28 +02:00
msdosfs msdosfs: Fix mounting when the device sector size is >512B 2022-02-21 09:57:54 -05:00
nfs nfsclient: Delete unused function nfscl_getcookie() 2022-02-09 19:39:00 -08:00
nfsclient nfsclient: Delete unused function nfscl_getcookie() 2022-02-09 19:39:00 -08:00
nfsserver nfsd: Reply NFSERR_SEQMISORDERED for bogus seqid argument 2022-02-15 17:02:28 -08:00
nullfs null_vput_pair(): release use reference on dvp earlier 2021-08-14 13:21:59 +03:00
procfs procfs_doprocfile(): simplify 2021-11-06 04:12:32 +02:00
pseudofs pseudofs: use vget_prep + vget_finish instead of vget + the interlock 2021-05-22 18:22:35 +00:00
smbfs Ensure that dirent's d_off field is initialized 2021-01-03 11:50:31 -05:00
tmpfs tmpfs: remove write-only variables 2021-10-27 03:24:40 +03:00
udf Make MAXPHYS tunable. Bump MAXPHYS to 1M. 2020-11-28 12:12:51 +00:00
unionfs unionfs: do not use bare struct componentname 2021-07-07 13:23:30 +03:00