Adding namecache entries outside of vfs_lookup and vn_open ?

Konstantin Belousov kostikbel at gmail.com
Sun Mar 3 16:25:26 UTC 2019


On Sun, Mar 03, 2019 at 09:02:07AM -0700, Alan Somers wrote:
> On Sun, Mar 3, 2019 at 4:03 AM Konstantin Belousov <kostikbel at gmail.com> wrote:
> >
> > On Sat, Mar 02, 2019 at 06:02:06PM -0700, Alan Somers wrote:
> > > It looks like lookup and open are the only common vops that create new
> > > namecache entries.  At least, those are the only ones that set
> > > MAKEENTRY in the cn_flags field.  However, fuse(4)'s create-like
> > > operations (FUSE_CREATE, FUSE_SYMLINK, etc) all return enough
> > > information to create a namecache entry for the newly created file.
> > > As-is, an operation like FUSE_CREATE will almost always be followed up
> > > by a FUSE_LOOKUP, necessitating an extra round-trip to userland.
> > In VFS, creation of the new file is done by VOP_CREATE() after negative
> > VOP_LOOKUP().   VOP_CREATE() returns the new vnode that is installed into
> > file.  [A flag VN_OPEN_NAMECACHE was added for vn_open_cred() which results
> > in created name entry insertion into namecache.  It was done to handle
> > very specific situation in core dump code, which is no longer relevant.
> > The flag is still there.]
> >
> > Similar discussion occured some time ago.  I think that the current
> > selection of the cases where namecache entry is created, is optimized
> > for the scenario where extracting large tarball does not largely affect
> > the non-directory elements of the cache.  If you do such extraction,
> > it is unlikely that you will access most of the files shortly.
> >
> > > Would it be possible and wise to add these newly created entries to
> > > the namecache automatically?
> > Not from VFS, but the policy can be overriden by the filesystem by inserting
> > the elements into cache from VOPs as it finds suitable.
> 
> So MAKEENTRY is just advisory, and there shouldn't be a problem with
> inserting cache entries from fuse_nop_create even if MAKEENTRY isn't
> set?  I might try that.  The penalty for not doing so is an extra trip
> to userland, which is greater than the penalty for other file systems
> not doing it.
There can be problems from the too aggressive caching.  See below.

> 
> >
> > Does FUSE cache vnodes ?  I would find aggressive caching on the kernel
> > side somewhat unexpected for it.
> 
> No, it just uses the regular vnode cache.  The unique things that it
> does is it caches file attributes within the vnode, and the daemon can
> request a timeout period for either the attr cache or the entry cache.
> When the timeout expires, the kernel is supposed to purge (or ignore)
> its cached values.

This is what I mean, e.g. one of the strategy there might be to reclaim
fuse vnode on inactivation.  This is very harsh, of course, but was done
by nullfs not too long time ago.

For less contrived example, on NFS with its relatively defined semantic,
caching on the client sometimes become problematic. AFAIR, nfs client
re-checks mtime in strategic places, and ensures close-to-open
consistency by always flushing attributes on close, at least for NFS v3.

I am somewhat surprised that for FUSE it is considered safe (and useful)
to cache at all.


More information about the freebsd-hackers mailing list