Re: VFS-Lock patch on MAC OS X
Re: VFS-Lock patch on MAC OS X
- Subject: Re: VFS-Lock patch on MAC OS X
- From: Nikita Danilov <email@hidden>
- Date: Sun, 16 Jan 2005 13:54:50 +0300
Yogesh P writes:
> Hi Folks,
Hello, Yogesh,
>
> I am working on the VFS-Lock patch on linux which gives the
> functionality for locking and unlocking of filesystem.
>
> Is there any patch available on MAC for locking and unlocking of
> filesystem for a fraction of time????OR is the darwinkernel has VFS-Lock
> functionality built in????
>
> Any pointers,reply certainly helps.
If you fail to find any existing interface to do this you can easily do
this yourself: embed
struct lock__bsd__ fs_lock;
in your super block. In all your VFS_FOO() operations and in
VOP_LOCK(vnode) do:
lockmgr(&super_block->fs_lock, LK_SHARED | LK_CANRECURSE, NULL, proc);
As Mac OS X kernel usually calls VOP_LOCK(vnode) before calling any
other VOP operation, this will guarantee that super_block->fs_lock is
taken in shared mode when file system code is entered. LK_CANRECURSE is
needed, because VOP_LOCK can be called twice against the same vnode
during single system call.
NOTE: in a few (unfortunate) places VOP_GETATTR() is called _without_
taking vnode lock, so you will have to take super_block->fs_lock there
explicitly.
Now, to "lock" whole file system one just does:
lockmgr(&super_block->fs_lock, LK_EXCLUSIVE, NULL, proc);
Don't forget to unlock. :)
>
> Thanks,
> YOGESH PAHILWAN
> (SOFTWARE ENGINNER)
Nikita.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden