Bug 236560 - [FUSEFS] fuse(4) ignores FOPEN_KEEP_CACHE
Summary: [FUSEFS] fuse(4) ignores FOPEN_KEEP_CACHE
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 22:42 UTC by Alan Somers
Modified: 2019-04-19 22:40 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer 2019-03-15 22:42:00 UTC
If a fuse filesystem sets FOPEN_KEEP_CACHE in the response to FUSE_OPEN, then the kernel should not flush its read caches on subsequent open(2)s of the same file.  Our fuse(4) driver does indeed check for that flag in fuse_vnode_open.  However, the check doesn't work, because the flag isn't saved from the previous FUSE_OPEN.  The flag is guaranteed to be unset in that code path.  The solution would be to save the open_flags in the vnode.
Comment 1 commit-hook freebsd_committer 2019-03-15 22:48:25 UTC
A commit references this bug:

Author: asomers
Date: Fri Mar 15 22:47:26 UTC 2019
New revision: 345207
URL: https://svnweb.freebsd.org/changeset/base/345207

Log:
  fuse(4): add tests for the FOPEN_KEEP_CACHE option

  PR:		236560
  Sponsored by:	The FreeBSD Foundation

Changes:
  projects/fuse2/tests/sys/fs/fuse/access.cc
  projects/fuse2/tests/sys/fs/fuse/create.cc
  projects/fuse2/tests/sys/fs/fuse/destroy.cc
  projects/fuse2/tests/sys/fs/fuse/flush.cc
  projects/fuse2/tests/sys/fs/fuse/fsync.cc
  projects/fuse2/tests/sys/fs/fuse/fsyncdir.cc
  projects/fuse2/tests/sys/fs/fuse/getattr.cc
  projects/fuse2/tests/sys/fs/fuse/interrupt.cc
  projects/fuse2/tests/sys/fs/fuse/link.cc
  projects/fuse2/tests/sys/fs/fuse/locks.cc
  projects/fuse2/tests/sys/fs/fuse/mkdir.cc
  projects/fuse2/tests/sys/fs/fuse/open.cc
  projects/fuse2/tests/sys/fs/fuse/opendir.cc
  projects/fuse2/tests/sys/fs/fuse/read.cc
  projects/fuse2/tests/sys/fs/fuse/readdir.cc
  projects/fuse2/tests/sys/fs/fuse/readlink.cc
  projects/fuse2/tests/sys/fs/fuse/release.cc
  projects/fuse2/tests/sys/fs/fuse/releasedir.cc
  projects/fuse2/tests/sys/fs/fuse/rename.cc
  projects/fuse2/tests/sys/fs/fuse/unlink.cc
  projects/fuse2/tests/sys/fs/fuse/utils.cc
  projects/fuse2/tests/sys/fs/fuse/utils.hh
  projects/fuse2/tests/sys/fs/fuse/write.cc
  projects/fuse2/tests/sys/fs/fuse/xattr.cc
Comment 2 commit-hook freebsd_committer 2019-03-31 03:20:04 UTC
A commit references this bug:

Author: asomers
Date: Sun Mar 31 03:19:12 UTC 2019
New revision: 345742
URL: https://svnweb.freebsd.org/changeset/base/345742

Log:
  fusefs: replace the fufh table with a linked list

  The FUSE protocol allows each open file descriptor to have a unique file
  handle.  On FreeBSD, these file handles must all be stored in the vnode.
  The old method (also used by OSX and OpenBSD) is to store them all in a
  small array.  But that limits the total number that can be stored.  This
  commit replaces the array with a linked list (a technique also used by
  Illumos).  There is not yet any change in functionality, but this is the
  first step to fixing several bugs.

  PR:		236329, 236340, 236381, 236560, 236844
  Discussed with:	cem
  Sponsored by:	The FreeBSD Foundation

Changes:
  projects/fuse2/sys/fs/fuse/fuse_file.c
  projects/fuse2/sys/fs/fuse/fuse_file.h
  projects/fuse2/sys/fs/fuse/fuse_internal.c
  projects/fuse2/sys/fs/fuse/fuse_node.c
  projects/fuse2/sys/fs/fuse/fuse_node.h
  projects/fuse2/sys/fs/fuse/fuse_vnops.c
Comment 3 commit-hook freebsd_committer 2019-04-04 20:30:30 UTC
A commit references this bug:

Author: asomers
Date: Thu Apr  4 20:30:16 UTC 2019
New revision: 345892
URL: https://svnweb.freebsd.org/changeset/base/345892

Log:
  fusefs: properly handle FOPEN_KEEP_CACHE

  If a fuse file system returne FOPEN_KEEP_CACHE in the open or create
  response, then the client is supposed to _not_ clear its caches for that
  file.  I don't know why clearing the caches would be the default given that
  there's a separate flag to bypass the cache altogether, but that's the way
  it is.  fusefs(5) will now honor this flag.

  Our behavior is slightly different than Linux's because we reuse file
  handles.  That means that open(2) wont't clear the cache if there's a
  reusable file handle, even if the file server wouldn't have sent
  FOPEN_KEEP_CACHE had we opened a new file handle like Linux does.

  PR:		236560
  Sponsored by:	The FreeBSD Foundation

Changes:
  projects/fuse2/sys/fs/fuse/fuse_file.c
  projects/fuse2/sys/fs/fuse/fuse_file.h
  projects/fuse2/sys/fs/fuse/fuse_node.c
  projects/fuse2/sys/fs/fuse/fuse_vnops.c
  projects/fuse2/tests/sys/fs/fusefs/read.cc
Comment 4 commit-hook freebsd_committer 2019-04-09 21:39:01 UTC
A commit references this bug:

Author: asomers
Date: Tue Apr  9 21:38:21 UTC 2019
New revision: 346068
URL: https://svnweb.freebsd.org/changeset/base/346068

Log:
  fusefs: skip the Read.keep_cache test when cache is disabled

  This should've been part of r345892

  PR:		236560
  Sponsored by:	The FreeBSD Foundation

Changes:
  projects/fuse2/tests/sys/fs/fusefs/read.cc
Comment 5 Alan Somers freebsd_committer 2019-04-19 22:40:33 UTC
This is complete on the fuse2 branch.