tech-kern archive

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

Re: Vnode API change: mnt_vnodelist traversal



On Mar 3, 2014, at 11:32 AM, Thomas Klausner <wiz%netbsd.org@localhost> wrote:

> On Mon, Mar 03, 2014 at 11:11:04AM +0100, J. Hannken-Illjes wrote:
>> A diff implementing this and using it for those operations running
>> vrecycle() is at http://www.netbsd.org/~hannken/vnode-pass4-1.diff
>> 
>> Once all operations are converted, vmark() / vunmark() will go and
>> man pages will be updated.
>> 
>> Comments or objections anyone?
> 
> I have no background clue, so please excuse my questions if they are
> stupid :)
> 
> +void
> +vfs_vnode_iterator_init(struct mount *mp, void **marker)
> +{
> +     struct vnode **mvpp = (struct vnode **)marker;
> +
> +     *mvpp = vnalloc(mp);
> +
> +     mutex_enter(&mntvnode_lock);
> +     TAILQ_INSERT_HEAD(&mp->mnt_vnodelist, *mvpp, v_mntvnodes);
> +     mutex_exit(&mntvnode_lock);
> +}
> +
> +void
> +vfs_vnode_iterator_destroy(void *marker)
> +{
> +     struct vnode *mvp = marker;
> +
> +     KASSERT((mvp->v_iflag & VI_MARKER) != 0);
> +     vnfree(mvp);
> +}
> 
> Why do you cast marker in init, but not in destroy or next?

Because (void **) to (othertype **) needs a cast.  Added casts to
destroy and next anyway.

> I assume that the marker is not struct vnode * so that you can change
> the type later if you want.

It is struct vnode * for now, to the caller it is simply opaque as the
caller doesn't need to know the internals.

> In init, you insert into a tailq, but in destroy you don't remove from
> any tailq. Where does that happen? (Let's say I forget iterating
> between init & destroy, or stop at some random point before going
> through all of them.)

Good catch.  Changed to track this state using v_usecount.

> lfs part: there are new mutex_enter for which I don't see the exits.
> Where did they happen before? Does vget release them? because vrecycle
> tries to acquire that mutex too.

Yes, vget() gets called with v_interlock held and releases on return.

New diff at http://www.netbsd.org/~hannken/vnode-pass4-2.diff

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



Home | Main Index | Thread Index | Old Index