Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Feb 2004 15:09:58 +0200
From:      Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Changing v_op for vnode on the fly
Message-ID:  <20040216130958.GC304@pm514-9.comsys.ntu-kpi.kiev.ua>
In-Reply-To: <200402140249.i1E2ns8R001417@green.homeunix.org>
References:  <20040213090838.GA221@pm514-9.comsys.ntu-kpi.kiev.ua> <200402140249.i1E2ns8R001417@green.homeunix.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 13, 2004 at 09:49:53PM -0500, Brian F. Feldman wrote:
> Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua> wrote:
> > 
> > Is it enough to get exclusive lock on vnode, before changing
> > v_op pointer?  Here is my code:
> > 
> > 	vn_lock(cvp->vp, LK_EXCLUSIVE | LK_RETRY, p);
> > 
> > 	if (flag > 0)
> > 		cvp->vp->v_op = catch_vnode_vnodeop_p;	/* My vnodeop_p. */
> > 	else
> > 		cvp->vp->v_op = cvp->vnodeop_p;		/* Original v_op. */
> > 
> > 	VOP_UNLOCK(cvp->vp, 0, p);
> > 
> > I made some tests and see that most of VOP_xxx require lock (shared
> > or exclusive) on vnode, as well this is documented in the manual pages.
> 
> No, you are not allowed to change v_op, ever.  Can you do what you're trying 
> to do in the MAC framework?  It seems like that is what you want to be 
> doing!  The other possibility is using something like umapfs/lomacfs/
> unionfs.
> 

First of all thanks for your answer.

I need to control activities on vnode not for protecting it from
processes.  I try to find a way to synchronize shared access (read,
write, mmap'ed file) to existent vnode (vnode which is currently is
used on home host by local processes) from process on remote hosts.

This situation is like NFS, but NFS (or similar systems) has own
vnode operation vector for their vnodes and can synchronize access
in their VOPs.  Since in my situation vnodes can have different vnode
operation vectors (i.e. files can belong to different VFS) I can't
set v_op for vnode when vnode is created (getnewvnode()).

Having read documentation and analyzed sources, I think that MAC can't
help.  MAC allows to synchronize access in read() and write() syscalls,
but access to VOP_GETPAGES, which is called in vm_fault() for example,
can't be synchronized using MAC framework.

File systems umapfs, lomacfs, unionfs also don't help.  May be it is
possible to do something with stackable VFS, but I haven't find
a solution with stackable VFS yet.

What can be broken when v_op is changed during holding exclusive
lock on vnode?  Does a moment when v_op is changed can cause any problems?
Currently I found that nullfs and uniofs will not work if v_op is changed,
because they compare v_op with their vnodeop_p.

Thanks for your help again.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040216130958.GC304>