Bug 235775

Summary: [FUSEFS]: Reuse cached attributes, when available and valid
Product: Base System Reporter: Conrad Meyer <cem>
Component: kernAssignee: Alan Somers <asomers>
Status: In Progress ---    
Severity: Affects Some People CC: acid, asomers, ben.rubson, freebsd, jSML4ThWwBID69YC, markj, piotr.konopelko
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   
Bug Depends on: 230258    
Bug Blocks: 236136    

Description Conrad Meyer freebsd_committer 2019-02-16 00:51:39 UTC
When cached attributes are valid, save a round-trip through FUSE and return the cached values in VOP_GETATTR.

(Ditto: use cache_enter and keep lookup dentries cached.)

This is a performance optimization rather than a correctness issue.

+++ This bug was initially created as a clone of Bug #230258 +++
Comment 1 commit-hook freebsd_committer 2019-03-01 23:53:33 UTC
A commit references this bug:

Author: asomers
Date: Fri Mar  1 23:53:07 UTC 2019
New revision: 344715
URL: https://svnweb.freebsd.org/changeset/base/344715

Log:
  Begin a fuse(4) test suite

  It only tests the kernel portion of fuse, not the userspace portion (which
  comes from sysutils/fusefs-libs).  The kernel-userspace interface is
  de-facto standardized, and this test suite seeks to validate FreeBSD's
  implementation.

  It uses GoogleMock to substitute for a userspace daemon and validate the
  kernel's behavior in response to filesystem access.  GoogleMock is
  convenient because it can validate the order, number, and arguments of each
  operation, and return canned responses.

  But that also means that the test suite must use GoogleTest, since
  GoogleMock is incompatible with atf-c++ and atf.test.mk does not allow C++
  programs to use atf-c.

  This commit adds the first 10 test cases out of an estimated 130 total.

  PR:		235775, 235773
  Sponsored by:	The FreeBSD Foundation

Changes:
  projects/fuse2/etc/mtree/BSD.tests.dist
  projects/fuse2/tests/sys/fs/Makefile
  projects/fuse2/tests/sys/fs/fuse/
  projects/fuse2/tests/sys/fs/fuse/Makefile
  projects/fuse2/tests/sys/fs/fuse/getattr.cc
  projects/fuse2/tests/sys/fs/fuse/lookup.cc
  projects/fuse2/tests/sys/fs/fuse/mockfs.cc
  projects/fuse2/tests/sys/fs/fuse/mockfs.hh
  projects/fuse2/tests/sys/fs/fuse/utils.cc
  projects/fuse2/tests/sys/fs/fuse/utils.hh
Comment 2 commit-hook freebsd_committer 2019-03-04 22:08:31 UTC
A commit references this bug:

Author: asomers
Date: Mon Mar  4 22:07:34 UTC 2019
New revision: 344785
URL: https://svnweb.freebsd.org/changeset/base/344785

Log:
  fuse(4): add tests for CREATE, OPEN, READLINK, SETATTR and SYMLINK

  The new SETATTR tests deal with already-open files.

  PR:		235775
  PR:		236231
  Sponsored by:	The FreeBSD Foundation

Changes:
  projects/fuse2/tests/sys/fs/fuse/Makefile
  projects/fuse2/tests/sys/fs/fuse/create.cc
  projects/fuse2/tests/sys/fs/fuse/mockfs.hh
  projects/fuse2/tests/sys/fs/fuse/open.cc
  projects/fuse2/tests/sys/fs/fuse/readlink.cc
  projects/fuse2/tests/sys/fs/fuse/setattr.cc
  projects/fuse2/tests/sys/fs/fuse/symlink.cc
Comment 3 commit-hook freebsd_committer 2019-04-08 18:46:21 UTC
A commit references this bug:

Author: asomers
Date: Mon Apr  8 18:45:45 UTC 2019
New revision: 346043
URL: https://svnweb.freebsd.org/changeset/base/346043

Log:
  fusefs: cache file attributes

  FUSE_LOOKUP, FUSE_GETATTR, FUSE_SETATTR, FUSE_MKDIR, FUSE_LINK,
  FUSE_SYMLINK, FUSE_MKNOD, and FUSE_CREATE all return file attributes with a
  cache validity period.  fusefs will now cache the attributes, if the server
  returns a non-zero cache validity period.

  This change does _not_ implement finite attr cache timeouts.  That will
  follow as part of PR 235773.

  PR:		235775
  Reported by:	cem
  Sponsored by:	The FreeBSD Foundation

Changes:
  projects/fuse2/sys/fs/fuse/fuse_internal.c
  projects/fuse2/sys/fs/fuse/fuse_internal.h
  projects/fuse2/sys/fs/fuse/fuse_node.c
  projects/fuse2/sys/fs/fuse/fuse_node.h
  projects/fuse2/sys/fs/fuse/fuse_vnops.c
  projects/fuse2/tests/sys/fs/fusefs/allow_other.cc
  projects/fuse2/tests/sys/fs/fusefs/create.cc
  projects/fuse2/tests/sys/fs/fusefs/default_permissions.cc
  projects/fuse2/tests/sys/fs/fusefs/flush.cc
  projects/fuse2/tests/sys/fs/fusefs/fsync.cc
  projects/fuse2/tests/sys/fs/fusefs/getattr.cc
  projects/fuse2/tests/sys/fs/fusefs/locks.cc
  projects/fuse2/tests/sys/fs/fusefs/lookup.cc
  projects/fuse2/tests/sys/fs/fusefs/open.cc
  projects/fuse2/tests/sys/fs/fusefs/read.cc
  projects/fuse2/tests/sys/fs/fusefs/release.cc
  projects/fuse2/tests/sys/fs/fusefs/setattr.cc
  projects/fuse2/tests/sys/fs/fusefs/unlink.cc
  projects/fuse2/tests/sys/fs/fusefs/utils.cc
  projects/fuse2/tests/sys/fs/fusefs/write.cc
Comment 4 Alan Somers freebsd_committer 2019-04-19 22:34:31 UTC
This is complete on the fuse2 branch.
Comment 5 commit-hook freebsd_committer 2019-08-07 00:39:57 UTC
A commit references this bug:

Author: asomers
Date: Wed Aug  7 00:38:28 UTC 2019
New revision: 350665
URL: https://svnweb.freebsd.org/changeset/base/350665

Log:
  fusefs: merge from projects/fuse2

  This commit imports the new fusefs driver. It raises the protocol level
  from 7.8 to 7.23, fixes many bugs, adds a test suite for the driver, and
  adds many new features. New features include:

  * Optional kernel-side permissions checks (-o default_permissions)
  * Implement VOP_MKNOD, VOP_BMAP, and VOP_ADVLOCK
  * Allow interrupting FUSE operations
  * Support named pipes and unix-domain sockets in fusefs file systems
  * Forward UTIME_NOW during utimensat(2) to the daemon
  * kqueue support for /dev/fuse
  * Allow updating mounts with "mount -u"
  * Allow exporting fusefs file systems over NFS
  * Server-initiated invalidation of the name cache or data cache
  * Respect RLIMIT_FSIZE
  * Try to support servers as old as protocol 7.4

  Performance enhancements include:

  * Implement FUSE's FOPEN_KEEP_CACHE and FUSE_ASYNC_READ flags
  * Cache file attributes
  * Cache lookup entries, both positive and negative
  * Server-selectable cache modes: writethrough, writeback, or uncached
  * Write clustering
  * Readahead
  * Use counter(9) for statistical reporting

  PR:		199934 216391 233783 234581 235773 235774 235775
  PR:		236226 236231 236236 236291 236329 236381 236405
  PR:		236327 236466 236472 236473 236474 236530 236557
  PR:		236560 236844 237052 237181 237588 238565
  Reviewed by:	bcr (man pages)
  Reviewed by:	cem, ngie, rpokala, glebius, kib, bde, emaste (post-commit
  		review on project branch)
  MFC after:	3 weeks
  Relnotes:	yes
  Sponsored by:	The FreeBSD Foundation
  Pull Request:	https://reviews.freebsd.org/D21110

Changes:
_U  head/
  head/MAINTAINERS
  head/UPDATING
  head/etc/mtree/BSD.tests.dist
  head/sbin/mount_fusefs/mount_fusefs.8
  head/sbin/mount_fusefs/mount_fusefs.c
  head/share/man/man5/fusefs.5
  head/sys/fs/fuse/fuse.h
  head/sys/fs/fuse/fuse_device.c
  head/sys/fs/fuse/fuse_file.c
  head/sys/fs/fuse/fuse_file.h
  head/sys/fs/fuse/fuse_internal.c
  head/sys/fs/fuse/fuse_internal.h
  head/sys/fs/fuse/fuse_io.c
  head/sys/fs/fuse/fuse_io.h
  head/sys/fs/fuse/fuse_ipc.c
  head/sys/fs/fuse/fuse_ipc.h
  head/sys/fs/fuse/fuse_kernel.h
  head/sys/fs/fuse/fuse_main.c
  head/sys/fs/fuse/fuse_node.c
  head/sys/fs/fuse/fuse_node.h
  head/sys/fs/fuse/fuse_param.h
  head/sys/fs/fuse/fuse_vfsops.c
  head/sys/fs/fuse/fuse_vnops.c
  head/sys/sys/param.h
  head/tests/sys/fs/Makefile
  head/tests/sys/fs/fusefs/