tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Vnode API change: add global vnode cache



On 22 May 2014, at 00:48, David Holland <dholland-tech%netbsd.org@localhost> wrote:

<snip>

> As I discovered while prodding lfs last weekend, this is too
> optimistic, as there's another family of cases: allocating a new inode
> and constructing a vnode for it.
> 
> It is *possible* to do this by allocating an inode number and then
> using vcache_get to procure the vnode, such that when the vnode cache
> calls VFS_LOADVNODE it will load a blank inode. This is what ffs does,
> and it works fine there since unallocated inodes have fixed known
> locations that are in a known on-disk state.
> 
> It doesn't work for lfs, and it won't work for any other filesystem
> where inode locations aren't fixed, at least not without some ugly
> hackery: you can update the fs state with a location for the new
> inode, and write a buffer with the intended inode contents, and then
> have VFS_LOADVNODE find and use this buffer, but this is inefficient
> and gross. (This isn't itself adequate for lfs because lfs has some
> additional self-inflicted issues.)
> 
> After sleeping on this a few times, ISTM that the best way to handle
> this is as follows:
> 
>   - add an additional call vcache_new to the API;
>   - have vcache_new take a type argument;
>   - have vcache_new assert that no vnode with the same key already
>     exists (FS-level locking should guarantee this);
>   - have vcache_new call a new op VFS_NEWVNODE instead of
>     VFS_LOADVNODE and pass the type in.

<snip>

Here comes the new operation "vcache_new()" to allocate and initialise
a new vnode/fsnode pair.  Passing the type is not sufficient, therefore
pass all information we get from VOP_MKNOD:

int
vcache_new(struct mount *mp, struct vnode *dvp, struct vattr *vap,
    kauth_cred_t cred, struct vnode **vpp)

where dvp is the (referenced) directory where we want to create the
new node, vap passes va_type, va_mode and possibly va_rdev and cred
gives the credentials to setup uid/guid.

The node returned from vcache_new() is referenced, fully initialised
and has link count zero.

A diff showing the implementation is here:

	http://www.netbsd.org/~hannken/vnode-pass7-1a.diff

and a diff showing its usage for ffs is here:

	http://www.netbsd.org/~hannken/vnode-pass7-1b.diff

Comments or objections anyone?

--
J. Hannken-Illjes - hannken%eis.cs.tu-bs.de@localhost - TU Braunschweig (Germany)



Home | Main Index | Thread Index | Old Index