On Fri, Jun 01 2018, Klemens Nanni <k...@openbsd.org> wrote: > On Sun, May 27, 2018 at 04:37:52PM +0200, Klemens Nanni wrote: >> Spotted and reported on IRC by Georg Bege <georg@bege.email>, >> vfs_cache(9) lacks way behind beck's "Namecache revamp" from 2009. >> >> This diff syncs the manual with sys/sys/namei.h and sys/kern/vfs_cache.c: >> I went through it and checked the APIs, this seems fine to me for now >> but since I'm not all too familiar with VFS yet, feedback is welcome. >> >> Maybe we want to sync descriptions in the manual a bit more with code >> comments to reduce differences in two places describing the same thing? > I have OKs from visa and jmc for the initial diff already; here's an > updated one that syncs other manuals as well. > > Syncing descriptions and comments turned out to be much more churn than > useful changes. One thing I stripped though is the note about too long > names in vfs_lookup()'s comment; that bit is already mentioned around > NAMECACHE_MAXLEN's definition. > > For struct vnode, I copied it as is to avoid picking around whitespace > changes so we end up with the exact same struct in both places. > > There might be more. > > Feedback? OK?
I'm not sure I see the point of shortening the comment but no objection either. ok jca@ > > Index: sys/kern/vfs_cache.c > =================================================================== > RCS file: /cvs/src/sys/kern/vfs_cache.c,v > retrieving revision 1.56 > diff -u -p -r1.56 vfs_cache.c > --- sys/kern/vfs_cache.c 27 May 2018 06:02:14 -0000 1.56 > +++ sys/kern/vfs_cache.c 1 Jun 2018 11:32:32 -0000 > @@ -128,9 +128,7 @@ cache_zap(struct namecache *ncp) > } > > /* > - * Look for a name in the cache. We don't do this if the segment name is > - * long, simply so the cache can avoid holding long names (which would > - * either waste space, or add greatly to the complexity). > + * Look for a name in the cache. > * dvp points to the directory to search. The componentname cnp holds > * the information on the entry being sought, such as its length > * and its name. If the lookup succeeds, vpp is set to point to the vnode > Index: share/man/man9/VOP_LOOKUP.9 > =================================================================== > RCS file: /cvs/src/share/man/man9/VOP_LOOKUP.9,v > retrieving revision 1.41 > diff -u -p -r1.41 VOP_LOOKUP.9 > --- share/man/man9/VOP_LOOKUP.9 28 Apr 2018 03:13:04 -0000 1.41 > +++ share/man/man9/VOP_LOOKUP.9 1 Jun 2018 12:04:24 -0000 > @@ -327,7 +327,7 @@ struct vattr { > uid_t va_uid; /* owner user id */ > gid_t va_gid; /* owner group id */ > long va_fsid; /* file system id */ > - long va_fileid; /* file id */ > + u_quad_t va_fileid; /* file id */ > u_quad_t va_size; /* file size in bytes */ > long va_blocksize; /* blocksize preferred for i/o */ > struct timespec va_atime; /* time of last access */ > Index: share/man/man9/vfs_cache.9 > =================================================================== > RCS file: /cvs/src/share/man/man9/vfs_cache.9,v > retrieving revision 1.3 > diff -u -p -r1.3 vfs_cache.9 > --- share/man/man9/vfs_cache.9 31 May 2007 19:20:01 -0000 1.3 > +++ share/man/man9/vfs_cache.9 1 Jun 2018 11:32:31 -0000 > @@ -37,15 +37,16 @@ recently looked-up file name translation > Entries in this cache have the following definition: > .Bd -literal > struct namecache { > - LIST_ENTRY(namecache) nc_hash; /* hash chain */ > - LIST_ENTRY(namecache) nc_vhash; /* (reverse) dir hash chain */ > - TAILQ_ENTRY(namecache) nc_lru; /* LRU chain */ > + TAILQ_ENTRY(namecache) nc_lru; /* Regular Entry LRU chain */ > + TAILQ_ENTRY(namecache) nc_neg; /* Negative Entry LRU chain */ > + RBT_ENTRY(namecache) n_rbcache; /* Namecache rb tree from vnode */ > + TAILQ_ENTRY(namecache) nc_me; /* ncp's referring to me */ > struct vnode *nc_dvp; /* vnode of parent of name */ > u_long nc_dvpid; /* capability number of nc_dvp */ > struct vnode *nc_vp; /* vnode the name refers to */ > u_long nc_vpid; /* capability number of nc_vp */ > char nc_nlen; /* length of name */ > - char nc_name[NCHNAMLEN]; /* segment name */ > + char nc_name[NAMECACHE_MAXLEN]; /* segment name */ > }; > .Ed > .Pp > @@ -55,7 +56,7 @@ Negative caching is also performed so th > names of files that do not exist do not result in expensive lookups. > .Pp > File names with length longer than > -.Dv NCHNAMLEN > +.Dv NAMECACHE_MAXLEN > are not cached to simplify lookups and to save space. > Such names are rare and are generally not worth caching. > .Pp > @@ -169,7 +170,8 @@ API is implemented in the file > .Xr vmstat 8 , > .Xr namei 9 , > .Xr vfs 9 , > -.Xr vnode 9 > +.Xr vnode 9 , > +.Xr VOP_LOOKUP 9 > .Sh HISTORY > The > .Nm > Index: share/man/man9/vnode.9 > =================================================================== > RCS file: /cvs/src/share/man/man9/vnode.9,v > retrieving revision 1.28 > diff -u -p -r1.28 vnode.9 > --- share/man/man9/vnode.9 18 Jul 2011 12:03:45 -0000 1.28 > +++ share/man/man9/vnode.9 1 Jun 2018 12:15:40 -0000 > @@ -66,41 +66,45 @@ provided by the VFS to create and manage > The definition of a vnode is as follows: > .Bd -literal > struct vnode { > - struct uvm_vnode v_uvm; /* uvm(9) data */ > - int (**v_op)(void *); /* vnode operations vector */ > - enum vtype v_type; /* vnode type */ > - u_int v_flag; /* vnode flags (see below) */ > - u_int v_usecount; /* reference count of users */ > - u_int v_writecount; /* reference count of writers */ > + struct uvm_vnode *v_uvm; /* uvm data */ > + struct vops *v_op; /* vnode operations vector */ > + enum vtype v_type; /* vnode type */ > + enum vtagtype v_tag; /* type of underlying data */ > + u_int v_flag; /* vnode flags (see below) */ > + u_int v_usecount; /* reference count of users */ > + /* reference count of writers */ > + u_int v_writecount; > /* Flags that can be read/written in interrupts */ > - u_int v_bioflag; /* flags used by intr handlers */ > - u_int v_holdcnt; /* buffer references */ > - u_int v_id; /* capability identifier */ > - struct mount *v_mount; /* ptr to vfs we are in */ > - TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ > - LIST_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ > - struct buflists v_cleanblkhd; /* clean blocklist head */ > - struct buflists v_dirtyblkhd; /* dirty blocklist head */ > - u_int v_numoutput; /* num of writes in progress */ > - LIST_ENTRY(vnode) v_synclist; /* vnode with dirty buffers */ > + u_int v_bioflag; > + u_int v_holdcnt; /* buffer references */ > + u_int v_id; /* capability identifier */ > + u_int v_inflight; > + struct mount *v_mount; /* ptr to vfs we are in */ > + TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ > + LIST_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ > + struct buf_rb_bufs v_bufs_tree; /* lookup of all bufs */ > + struct buflists v_cleanblkhd; /* clean blocklist head */ > + struct buflists v_dirtyblkhd; /* dirty blocklist head */ > + u_int v_numoutput; /* num of writes in progress */ > + LIST_ENTRY(vnode) v_synclist; /* vnode with dirty buffers */ > union { > - struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */ > - struct socket *vu_socket; /* UNIX IPC (VSOCK) */ > - struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */ > - struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */ > + struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */ > + struct socket *vu_socket; /* unix ipc (VSOCK) */ > + struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */ > + struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */ > } v_un; > > - enum vtagtype v_tag; /* type of underlying data */ > - void *v_data; /* private data for fs */ > - struct { > - struct simplelock vsi_lock; /* lock to protect below */ > - struct selinfo vsi_selinfo; /* identity of poller(s) */ > - } v_selectinfo; > + /* VFS namecache */ > + struct namecache_rb_cache v_nc_tree; > + TAILQ_HEAD(, namecache) v_cache_dst; /* cache entries to us */ > + > + void *v_data; /* private data for fs */ > + struct selinfo v_selectinfo; /* identity of poller(s) */ > }; > -#define v_mountedhere v_un.vu_mountedhere > -#define v_socket v_un.vu_socket > -#define v_specinfo v_un.vu_specinfo > -#define v_fifoinfo v_un.vu_fifoinfo > +#define v_mountedhere v_un.vu_mountedhere > +#define v_socket v_un.vu_socket > +#define v_specinfo v_un.vu_specinfo > +#define v_fifoinfo v_un.vu_fifoinfo > .Ed > .Ss Vnode life cycle > When a client of the VFS requests a new vnode, the vnode allocation > -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE