Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: VFS-Lock patch on MAC OS X



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:
http://lists.apple.com/mailman/options/darwin-kernel/email@hidden

This email sent to email@hidden

References: 
 >VFS-Lock patch on MAC OS X (From: Yogesh P <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.