views:

188

answers:

1

does anybody know how to use the fancy file locking features of NFS v4? (described in e.g. About the NFS protocol (scroll down)). supposedly NFS v4 supports file lock leasing with a 45 second lifetime. I would like to believe that the linux kernel (I'm using gentoo 2.6.30) happily takes care of these details, and I can use fcntl() and it all comes out in the wash. I am guessing, however, that I have to do something special somehow to get, maintain, and release the lock lease. all help appreciated.

+2  A: 

you are right, fcntl takes care of all this business for you. The lease management is done by the nfs client(kernel module in linux)

leeeroy
I like this answer for its simplicity. I am wondering how I know the NFS v4 voodoo is actually working under the hood, since fcntl will happily work on 'vanilla' local filesystems, and supposedly under NFS v3. I guess I have to try it and crash the client machine ;)
shabbychef
when the fcntl call hits the kernel it's dispatched to whatever file sub system that implements it for the file descriptor it's called on. If the file descriptor points to a file on an nfs mount, it'll end up in the fcntl function of the nfs client.
leeeroy
btw, is the NFS v4 lock lease via F_SETLEASE/F_GETLEASE or via the older F_sETLK/F_GETLK ? I would guess the former, but fcntl manpage is ambiguous, and google is not helping..
shabbychef