VFS messaging/interfacing work stage 7/99. BEGIN DESTABILIZATION!
authorMatthew Dillon <dillon@dragonflybsd.org>
Thu, 30 Sep 2004 19:00:29 +0000 (19:00 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Thu, 30 Sep 2004 19:00:29 +0000 (19:00 +0000)
commit217396181c21908d5ec1a8581504dda822dbe7f1
treef5fca756b50e82c9b116e57b7e6d71edfd95cf8b
parented987dc9a75cd182823b6576d0d42f79049c20ba
VFS messaging/interfacing work stage 7/99.  BEGIN DESTABILIZATION!

Implement the infrastructure required to allow us to begin switching to the
new nlookup() VFS API.

filedesc->fd_ncdir, fd_nrdir, fd_njdir

    File descriptors (associated with processes) now record the
    namecache pointer related to the current directory, root directory,
    and jail directory, in addition to the vnode pointers.  These
    pointers are used as the basis for the new path lookup code
    (nlookup() and friends).

file->f_ncp

    File pointers may now have a referenced+unlocked namecache
    pointer associated with them.  All fp's representing directories
    have this attached.  This allows fchdir() to properly record
    the ncp in fdp->fd_ncdir and friends.

mount->mnt_ncp

    The namecache topology for crossing a mount point works as
    follows: when looking up a path element which is a mount point,
    cache_nlookup() will locate the ncp for the vnode-under the
    mount point.  mount->mnt_ncp represents the root of the mount,
    that is the vnode-over.  nlookup() detects the mount point and
    accesses mount->mnt_ncp to skip past the vnode-under.  When going
    backwards (..), nlookup() detects the case and skips backwards.

    The ncp linkages are: ncp->ncp->ncp[vnode_under]->ncp[vnode_over].
    That is, when going forwards or backwards nlookup must explicitly
    skip over the double-ncp when crossing a mount point.  This allows
    us to keep the namecache topology intact across mount points.

NEW CACHE level API functions:

cache_get() Reference and lock a namecache entry
cache_put() Dereference and unlock a namecache entry
cache_lock() lock an already-referenced namecache entry
cache_unlock() unlock a lockednamecache entry

    NOTE: namecache locks are exclusive and recursive.  These are
    the 'namespace' locks that we will be using to guarentee namespace
    operations such as in a CREATE, RENAME, or REMOVE.

vfs_cache_setroot()  Set the new system-wide root directory
cache_allocroot()    System bootstrap helper function to allocate
      the root namecache node.

cache_resolve() Resolve a NCF_UNRESOLVED namecache node.  The
namecache node should be locked on call.

cache_setvp() (resolver) associate a VP or create a negative
cache entry representation for a namecache
pointer and clear NCF_UNRESOLVED.  The
namecache node should be locked on call.

cache_setunresolved() Revert a resolved namecache entry back to an
unresolved state, disassociating any vnode
but leaving the topology intact.  The
namecache node should be locked on call.

cache_vget() Obtain the locked+refd vnode related to
a namecache entry, resolving the entry if
necessary.  Return ENOENT if the entry
represents a negative cache hit.

cache_vref() Obtained a refd (not locked) vnode related to
a namecache entry, as above.

cache_nlookup() The new namecache lookup routine.  This routine
does a lookup and allocates a new namecache
node (into an unresolved state) if necessary.
Returns a namecache record whether or not
the item can be found and whether or not it
represents a positive or negative hit.

cache_lookup() OLD API CODE DEPRECATED, but must be maintained
until everything has been converted over.
cache_enter() OLD API CODE DEPRECATED, but must be maintained
until everything has been converted over.

NEW default VOPs

vop_noresolve() Implements a namecache resolver for VFSs
which are still using the old VOP_LOOKUP/
VOP_CACHEDLOOKUP API (which is all of them
still).

VOP_LOOKUP OLD API CODE DEPRECATED, but must be maintained
until everything has been converted over.
VOP_CACHEDLOOKUP OLD API CODE DEPRECATED, but must be maintained
until everything has been converted over.

NEW PATHNAME LOOKUP CODE

nlookup_init() Similar to NDINIT, initialize a nlookupdata
structure for nlookup() and nlookup_done().

nlookup() Lookup a path.  Unlike the old namei/lookup
code the new lookup code does not do any
fancy pre-disposition of the cache for
create/delete, it simply looks up the requested
path and returns the appropriate locked
namecache pointer.  The caller can obtain the
vnode and directory vnode, as applicable, from
the one namecache structure that is returned.

Access checks are done on directories leading
up to the result but not done on the returned
namecache node.

nlookup_done() Mandatory routine to cleanup a nlookupdata
structure after it has been initialized and
all operations have been completed on it.

nlookup_simple() (in progress) all-in-one wrapped new lookup.

nlookup_mp() helper call for resolving a mount point's
glue NCP.  hackish, will be cleaned up later.

nreadsymlink() helper call to resolve a symlink.  Note that
the namecache does not yet cache symlink data
but the intention is to eventually do so to
avoid having to do VFS ops to get the data.

naccess() Perform access checks on a namecache node
given a mode and cred.

naccess_va() Perform access cheks on a vattr given a
mode and cred.

Begin switching VFS operations from using namei to using nlookup.
In this batch:

* mount  (install mnt_ncp for cross-mount-point handling in
nlookup, simplify the vfs_mount() API to no longer
pass a nameidata structure)
* [l]stat (use nlookup)
* [f]chdir (use nlookup, use recorded f_ncp)
* [f]chroot (use nlookup, use recorded f_ncp)
54 files changed:
sys/bus/usb/usb_port.h
sys/emulation/43bsd/43bsd_stats.c
sys/emulation/linux/i386/linprocfs/linprocfs_vfsops.c
sys/emulation/linux/linux_file.c
sys/emulation/linux/linux_stats.c
sys/emulation/svr4/svr4_misc.c
sys/kern/init_main.c
sys/kern/kern_descrip.c
sys/kern/vfs_cache.c
sys/kern/vfs_conf.c
sys/kern/vfs_default.c
sys/kern/vfs_lookup.c
sys/kern/vfs_nlookup.c
sys/kern/vfs_syscalls.c
sys/kern/vfs_vopops.c
sys/sys/file.h
sys/sys/kern_syscall.h
sys/sys/mount.h
sys/sys/namecache.h
sys/sys/nlookup.h
sys/sys/systm.h
sys/sys/vfsops.h
sys/sys/vnode.h
sys/vfs/coda/coda_vfsops.c
sys/vfs/coda/coda_vfsops.h
sys/vfs/fdesc/fdesc_vfsops.c
sys/vfs/gnu/ext2fs/ext2_lookup.c
sys/vfs/gnu/ext2fs/ext2_vfsops.c
sys/vfs/hpfs/hpfs_vfsops.c
sys/vfs/hpfs/hpfs_vnops.c
sys/vfs/isofs/cd9660/cd9660_lookup.c
sys/vfs/isofs/cd9660/cd9660_vfsops.c
sys/vfs/mfs/mfs_vfsops.c
sys/vfs/msdosfs/msdosfs_lookup.c
sys/vfs/msdosfs/msdosfs_vfsops.c
sys/vfs/nfs/nfs_vfsops.c
sys/vfs/nfs/nfs_vnops.c
sys/vfs/ntfs/ntfs_vfsops.c
sys/vfs/ntfs/ntfs_vnops.c
sys/vfs/nullfs/null_vfsops.c
sys/vfs/nwfs/nwfs_io.c
sys/vfs/nwfs/nwfs_vfsops.c
sys/vfs/nwfs/nwfs_vnops.c
sys/vfs/portal/portal_vfsops.c
sys/vfs/procfs/procfs_vfsops.c
sys/vfs/smbfs/smbfs_io.c
sys/vfs/smbfs/smbfs_vfsops.c
sys/vfs/smbfs/smbfs_vnops.c
sys/vfs/udf/udf_vfsops.c
sys/vfs/udf/udf_vnops.c
sys/vfs/ufs/ffs_vfsops.c
sys/vfs/ufs/ufs_lookup.c
sys/vfs/umapfs/umap_vfsops.c
sys/vfs/union/union_vfsops.c