Re: VFS-Lock patch on MAC OS X
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com 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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Nikita Danilov