LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-31-2012, 04:24 PM   #1
eval-
LQ Newbie
 
Registered: Aug 2012
Posts: 2

Rep: Reputation: Disabled
Angry flock() fail between NFSv4 server (Linux 3.0/3.2) and client (works with two clients)


If, on NFSv4 client 1, I:
Code:
strace flock -x ./test -c "sleep 60"
it succeeds:
Code:
flock(3, LOCK_EX)                       = 0
On client 2, the same line results in a block, as expected:
Code:
flock(3, LOCK_EX
However, an flock() on the NFSv4 server gets the lock!
Code:
flock(3, LOCK_EX)                       = 0
Why is this? Shouldn't flock() syscall on the NFS server coordinate with the running nfs kernel server?

rpc.statd, lockd, (portmapper: nlockmgr, status) are all running on all clients and also the server.
I've reproduced this on 3.0 and 3.2 kernels and on Ubuntu (12.04) and SuSE (SLES11SP2) Is it expected behavior?

One workaround is to have the NFS server mount itself, then third-party apps depending on flock() still work.
I know that in the ancient past, flock() did not work over NFS, but now it ..almost does?
Does anyone get "proper" behavior with NFSv4 server and client flocks?
 
Old 10-02-2012, 06:15 AM   #2
eval-
LQ Newbie
 
Registered: Aug 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by eval- View Post
Why is this? Shouldn't flock() syscall on the NFS server coordinate with the running nfs kernel server?
I never followed up that I figured this out myself (I think) after reading this comment in the kernel source (fs/nfs/file.c):

Code:
 /* We're simulating flock() locks using posix locks on the server */
If I understand correctly the NFS server sees the client's flocks() as fcntl()-implemented locks, which do not conflict with the server's own flock()s. This is rather annoying and counter-intuitive behavior but hey, welcome to Linux, where file locking is a disaster. If I had read these links before banging my head against our servers and these third-party daemons (or grepping through Linux source) I might've saved an evening:

http://0pointer.de/blog/projects/locking2.html
http://0pointer.de/blog/projects/locking.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Files always locked using Windows Clients with Samba + NFSv4/NIS Server ichrispa Linux - Software 1 10-12-2010 12:22 AM
Can NFSv4 server translate symlinks for clients? onymouse Linux - Server 3 12-25-2009 06:44 PM
linux ppp client fails to connect to linux pptpd serve, works with windows vpn server wastingtime Linux - Server 3 09-20-2008 08:13 PM
Client server model using linux server and w2k clients? siva_bhavani Linux - Networking 2 09-29-2003 03:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration