Skip to contentSkip to conversation

File lock with multiple clients

DISCUSSION [email protected] 3 participants 3 messages Oct 20, 2005 – Oct 21, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,

I have a question about NFS and file locking on multiple clients.

Let's say I have a NFS server and two clients; "client a" and "client b". Is it possible to flock() a file on "client a", and make "client b" respect a's lock?

I've managed to lock files on "client a" and let other processes on "client a" honour the locks, but "client b" doesn't seem to be able to see the lock= s.

Before I research any further, does anyone know if this is possible?

Thanks in advance,

Petter=

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#1 lore raw
Quoted 8 lines · On Friday October 21, [email protected] wrote:

Hello,

I have a question about NFS and file locking on multiple clients.

Let's say I have a NFS server and two clients; "client a" and "client b". Is it possible to flock() a file on "client a", and make "client b" respect a's lock?

Quoted 5 lines

I've managed to lock files on "client a" and let other processes on "client a" honour the locks, but "client b" doesn't seem to be able to see the locks.

Before I research any further, does anyone know if this is possible?

Check the man page: "man flock":

NOTES
flock(2) does not lock files over NFS. Use fcntl(2) instead: that does work over NFS, given a sufficiently recent version of Linux and a server which supports locking.

Use fcntl or lockf (which is wrapper for fcntl) if you want to lock over NFS.

NeilBrown

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#2 lore raw

fr den 21.10.2005 klokka 10:43 (+1000) skreiv Neil Brown:

Quoted 5 lines

NOTES
flock(2) does not lock files over NFS. Use fcntl(2) instead: that does work over NFS, given a sufficiently recent version of Linux and a server which supports locking.

Note that this is not entirely accurate any more. Recent kernels will emulate flock() over NFS by using fcntl() locks.

Cheers,
Trond

-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs