2004-05-25 12:23:54

by Jeff Layton

[permalink] [raw]
Subject: Linux' NFS locking b0rken?

I've been doing a little testing of lock handling. My findings seem to
indicate that Linux does not handle NFS locking at all, but I want to
sanity check what I'm doing against the knowledgeable people on this
list.

I wrote a small perl script to do an exclusive lock on a file:

----------------------------------------------
#!/usr/bin/perl

use Fcntl qw(:DEFAULT :flock);

$file=$ARGV[0];

open (FH, "+< $file") or die "Can't open $file: $!\n";
if ( flock(FH, LOCK_EX|LOCK_NB) ) {
print "Lock acquired! Sleeping for 5 mins...\n";
sleep 300;
} else {
print "Unable to acquire lock! Exiting...\n";
exit 1;
}

close FH;

exit 0;
-----------------------------------------------

The fileserver is Linux (and I've tried both 2.4 and 2.6 kernels and
seem to get the same result), and for clients, I've tested Solaris 8,
and Linux 2.4 and 2.6. The Linux boxes are Debian machines using 1.0.6
nfs-kernel-server and nfs-common packages.

I then touched a file on the NFS-shared directory and ran this script to
lock it using different clients.

Locking seems to work with 2 Solaris 8 clients. If I run this script
against the same file, then the second one gets the 'Unable to acquire
lock' message.

However, when I try this with 2 Linux clients, or with a Linux and
Solaris client, they both claim to acquire the lock. When I run the test
in 2 terminals on the same Linux client the second one is unable to
acquire the lock, so the problem seems to be in dealing with locks as
registered by the NFS server.

I've tried several things to work around this problem:

Kernel version does not seem to matter here, at least I see this with
recent versions of both the 2.4 and 2.6 kernel tree, on both clients and
servers.

My mount options for the Linux side are:

nosuid,soft,bg,udp

I've tried other options too, in particular, both NFSv2 and v3, as well
as v3 over TCP. None of that seems to help.

Has anyone successfully been able to get Linux to respect fcntl locking
over NFS? If so, do you have any ideas what I'm doing wrong?

Thanks,
Jeff




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2004-05-28 13:28:49

by Ara.T.Howard

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Thu, 27 May 2004, Trond Myklebust wrote:

> That said, I believe that RHEL-3 at least is returning an error these days
> whenever you try to flock over NFS

yes it does:

~/shared > cat /etc/redhat-release
Red Hat Enterprise Linux WS release 3 (Taroon Update 2)

~/shared > uname -srm
Linux 2.4.21-15.ELsmp i686

~/shared > ruby -e 'open("nfs","w").flock File::LOCK_EX'
-e:1:in `flock': No locks available - nfs (Errno::ENOLCK)
from -e:1


cheers.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| "640K ought to be enough for anybody." - Bill Gates, 1981
===============================================================================



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-25 12:37:02

by Olaf Kirch

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Tue, May 25, 2004 at 08:23:49AM -0400, Jeffrey Layton wrote:
> if ( flock(FH, LOCK_EX|LOCK_NB) ) {

BSD flock locks have never worked over NFS, and probably will
never work over NFS. Please use POSIX (i.e. fcntl) locks instead.

Olaf
--
Olaf Kirch | The Hardware Gods hate me.
[email protected] |
---------------+


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-25 16:42:12

by Jeff Layton

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Tue, 2004-05-25 at 08:34, Olaf Kirch wrote:
> BSD flock locks have never worked over NFS, and probably will
> never work over NFS. Please use POSIX (i.e. fcntl) locks instead.
>
> Olaf

Ahh I learned something new today! I didn't realize there were 2 locking
implementations. I ended up writing a small C program to test this, and
fcntl locks do seem to work over NFS.

Perhaps Solaris does some sort of BSD-POSIX lock translation which makes
flock() work there?

Thanks for the info!
-- Jeff




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-25 17:47:18

by Trond Myklebust

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

P=E5 ty , 25/05/2004 klokka 12:42, skreiv Jeffrey Layton:

> Perhaps Solaris does some sort of BSD-POSIX lock translation which makes
> flock() work there?

The convention for local filesystems under Linux is that BSD and POSIX
locks are not allowed to see each other. That rules out using the above
trick for NFS.

Cheers,
Trond


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-25 18:56:40

by Dan Stromberg

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Tue, 2004-05-25 at 10:47, Trond Myklebust wrote:
> P? ty , 25/05/2004 klokka 12:42, skreiv Jeffrey Layton:
>
> > Perhaps Solaris does some sort of BSD-POSIX lock translation which makes
> > flock() work there?
>
> The convention for local filesystems under Linux is that BSD and POSIX
> locks are not allowed to see each other. That rules out using the above
> trick for NFS.
>
> Cheers,
> Trond

Actually, wouldn't you be OK if you had a flock that was just a wrapper
around fcntl?

>
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id149&alloc_id?66&op?k
> _______________________________________________
> NFS maillist - [email protected]
> https://lists.sourceforge.net/lists/listinfo/nfs
--
Dan Stromberg DCS/NACS/UCI <[email protected]>


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part

2004-05-25 19:03:58

by Trond Myklebust

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

P=E5 ty , 25/05/2004 klokka 14:56, skreiv Dan Stromberg:

> Actually, wouldn't you be OK if you had a flock that was just a wrapper
> around fcntl?

No! flock locks behave very differently from POSIX locks after a fork().

Cheers,
Trond


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-25 19:08:49

by Ara.T.Howard

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Tue, 25 May 2004, Dan Stromberg wrote:

> On Tue, 2004-05-25 at 10:47, Trond Myklebust wrote:
> > P=E5 ty , 25/05/2004 klokka 12:42, skreiv Jeffrey Layton:
> >=20
> > > Perhaps Solaris does some sort of BSD-POSIX lock translation which ma=
kes
> > > flock() work there?
> >=20
> > The convention for local filesystems under Linux is that BSD and POSIX
> > locks are not allowed to see each other. That rules out using the above
> > trick for NFS.
> >=20
> > Cheers,
> > Trond
>=20
> Actually, wouldn't you be OK if you had a flock that was just a wrapper
> around fcntl?

yes, in that it would work, you simply would not coordinate with other
processes which do NOT use fcntl based locks. ruby and perl ship with
implemtations of flock which are, in fact, fctnl under the hood.

-a
--=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| "640K ought to be enough for anybody." - Bill Gates, 1981
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-25 19:12:11

by Trond Myklebust

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

P=E5 ty , 25/05/2004 klokka 15:08, skreiv Ara.T.Howard:
> yes, in that it would work, you simply would not coordinate with other
> processes which do NOT use fcntl based locks. ruby and perl ship with
> implemtations of flock which are, in fact, fctnl under the hood.

No it would not. Read the manpages...

Trond


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-25 21:11:08

by Ara.T.Howard

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Tue, 25 May 2004, Trond Myklebust wrote:

> P=E5 ty , 25/05/2004 klokka 15:08, skreiv Ara.T.Howard:
> > yes, in that it would work, you simply would not coordinate with other
> > processes which do NOT use fcntl based locks. ruby and perl ship with
> > implemtations of flock which are, in fact, fctnl under the hood.
>=20
> No it would not. Read the manpages...
>=20
> Trond

i'm not saying this is GOOD - just that you certainly can make a wrapper
around fcntl and call it flock (or anything else for that matter) and so lo=
ng
as all your processes are using this interface all will be well. of course
the two types don't mix. in any case i understand what you are saying,
nevertheless it __is__ being done out there:


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D
file: ruby-1.8.1/missing/flock.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D

#include "config.h"

#if defined HAVE_FCNTL && defined HAVE_FCNTL_H

/* These are the flock() constants. Since this sytems doesn't have
flock(), the values of the constants are probably not available.
*/
# ifndef LOCK_SH
# define LOCK_SH 1
# endif
# ifndef LOCK_EX
# define LOCK_EX 2
# endif
# ifndef LOCK_NB
# define LOCK_NB 4
# endif
# ifndef LOCK_UN
# define LOCK_UN 8
# endif

#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

int
flock(fd, operation)
int fd;
int operation;
{
struct flock lock;
=20
switch (operation & ~LOCK_NB) {
case LOCK_SH:
=09lock.l_type =3D F_RDLCK;
=09break;
case LOCK_EX:
=09lock.l_type =3D F_WRLCK;
=09break;
case LOCK_UN:
=09lock.l_type =3D F_UNLCK;
=09break;
default:
=09errno =3D EINVAL;
=09return -1;
}
lock.l_whence =3D SEEK_SET;
lock.l_start =3D lock.l_len =3D 0L;
=20
return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock);
}

#elif defined(HAVE_LOCKF)

#include <unistd.h>
#include <errno.h>

/* Emulate flock() with lockf() or fcntl(). This is just to increase
portability of scripts. The calls might not be completely
interchangeable. What's really needed is a good file
locking module.
*/

# ifndef F_ULOCK
# define F_ULOCK=090=09/* Unlock a previously locked region */
# endif
# ifndef F_LOCK
# define F_LOCK=091=09/* Lock a region for exclusive use */
# endif
# ifndef F_TLOCK
# define F_TLOCK=092=09/* Test and lock a region for exclusive use */
# endif
# ifndef F_TEST
# define F_TEST=093=09/* Test a region for other processes locks */
# endif

/* These are the flock() constants. Since this sytems doesn't have
flock(), the values of the constants are probably not available.
*/
# ifndef LOCK_SH
# define LOCK_SH 1
# endif
# ifndef LOCK_EX
# define LOCK_EX 2
# endif
# ifndef LOCK_NB
# define LOCK_NB 4
# endif
# ifndef LOCK_UN
# define LOCK_UN 8
# endif

int
flock(fd, operation)
int fd;
int operation;
{
switch (operation) {

=09/* LOCK_SH - get a shared lock */
case LOCK_SH:
rb_notimplement();
return -1;
=09/* LOCK_EX - get an exclusive lock */
case LOCK_EX:
=09return lockf (fd, F_LOCK, 0);

=09/* LOCK_SH|LOCK_NB - get a non-blocking shared lock */
case LOCK_SH|LOCK_NB:
rb_notimplement();
return -1;
=09/* LOCK_EX|LOCK_NB - get a non-blocking exclusive lock */
case LOCK_EX|LOCK_NB:
=09return lockf (fd, F_TLOCK, 0);

=09/* LOCK_UN - unlock */
case LOCK_UN:
=09return lockf (fd, F_ULOCK, 0);

=09/* Default - can't decipher operation */
default:
=09errno =3D EINVAL;
return -1;
}
}
#elif !defined _WIN32
int
flock(fd, operation)
int fd;
int operation;
{
rb_notimplement();
return -1;
}
#endif



-a
--=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| "640K ought to be enough for anybody." - Bill Gates, 1981
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-25 22:11:19

by Trond Myklebust

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

P=E5 ty , 25/05/2004 klokka 17:09, skreiv Ara.T.Howard:
> i'm not saying this is GOOD - just that you certainly can make a wrapper
> around fcntl and call it flock (or anything else for that matter) and so =
long
> as all your processes are using this interface all will be well. of cour=
se
> the two types don't mix. in any case i understand what you are saying,
> nevertheless it __is__ being done out there:

That's like saying you can paint the word "aeroplane" on a bicycle then
launch it off a cliff. Sure, you can, but that doesn't mean a passenger
won't notice the subtle differences...

http://www.freebsd.org/cgi/man.cgi?query=3Dflock&sektion=3D2&apropos=3D0&ma=
npath=3DFreeBSD+5.2-RELEASE+and+Ports
defines precisely what is expected of a lock that was set by flock().

Any program which relies on the fact that BSD locks are inherited by
child processes will fail to work correctly with you wrapper (because
fcntl() locks are not inherited).

...and indeed the people who wrote it *do* acknowledge in their comments
that "The calls might not be completely interchangeable".

Cheers,
Trond


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-26 07:51:06

by Olaf Kirch

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Tue, May 25, 2004 at 06:11:08PM -0400, Trond Myklebust wrote:
> Any program which relies on the fact that BSD locks are inherited by
> child processes will fail to work correctly with you wrapper (because
> fcntl() locks are not inherited).

Shouldn't it be possible to map flock locks onto the NLM interface
if we simply record the PID of the process originally requesting
the lock, and reuse that pid in all future operations? All the
flock semantics are provided by fs/locks.c already; all the
NLM client needs to do is to formulate appropriate NLM calls
for lock type changes (SH->EX and vice versa), and unlocks.

Really the only gotcha is that subsequent calls on an existing
lock use the same PID as the original call, so that the server
lockd can match up the request with its existing list of locks.

Olaf
--
Olaf Kirch | The Hardware Gods hate me.
[email protected] |
---------------+


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-26 16:04:15

by Trond Myklebust

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

P=E5 on , 26/05/2004 klokka 03:50, skreiv Olaf Kirch:
> Shouldn't it be possible to map flock locks onto the NLM interface
> if we simply record the PID of the process originally requesting
> the lock, and reuse that pid in all future operations? All the
> flock semantics are provided by fs/locks.c already; all the
> NLM client needs to do is to formulate appropriate NLM calls
> for lock type changes (SH->EX and vice versa), and unlocks.
>=20
> Really the only gotcha is that subsequent calls on an existing
> lock use the same PID as the original call, so that the server
> lockd can match up the request with its existing list of locks.

Sure we could. The question is whether or not there are any applications
out there that set both flock and fcntl locks? They would break with
such a scheme.

Cheers,
Trond


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-27 16:15:10

by Olaf Kirch

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Wed, May 26, 2004 at 12:04:01PM -0400, Trond Myklebust wrote:
> Sure we could. The question is whether or not there are any applications
> out there that set both flock and fcntl locks? They would break with
> such a scheme.

Don't they deserve to break?

I'd rather make flock work over NFS (and have one FAQ less to deal with),
than supporting patently broken apps.

We could create a mount option or even better a lockd module option to
make the old behavior selectable for those that need it.

Olaf
--
Olaf Kirch | The Hardware Gods hate me.
[email protected] |
---------------+


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-27 16:25:01

by Jeff Layton

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

Just for posterity, the Solaris manpage for flock(3UCB) says:

"The compatibility version of flock() has been implemented on top of
fcntl(2) locking."

----------------

My guess is that if Linux were to adopt a similar scheme it would likely
not break much, if anything...

But what do I know? ;-)

-- Jeff




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-27 16:31:59

by Trond Myklebust

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

P=E5 to , 27/05/2004 klokka 12:14, skreiv Olaf Kirch:
> On Wed, May 26, 2004 at 12:04:01PM -0400, Trond Myklebust wrote:
> > Sure we could. The question is whether or not there are any application=
s
> > out there that set both flock and fcntl locks? They would break with
> > such a scheme.
>=20
> Don't they deserve to break?

Yep, but since the main users of flock tend to be mail-related
applications, we'd better check first. People tend to get grumpy when
their favourite MTA locks up and dies.

That said, I believe that RHEL-3 at least is returning an error these
days whenever you try to flock over NFS: I dunno if you are doing this
at SuSE yet?
Hopefully that will suffice to wipe the slate clean w.r.t. borken apps
(I know it caused my old uni to be aware of the problem and fix up a
couple of "movemail"s that were using flock).

> I'd rather make flock work over NFS (and have one FAQ less to deal with),
> than supporting patently broken apps.
>=20
> We could create a mount option or even better a lockd module option to
> make the old behavior selectable for those that need it.

lockd sysctl...

Cheers,
Trond


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2004-05-27 17:06:55

by Olaf Kirch

[permalink] [raw]
Subject: Re: Linux' NFS locking b0rken?

On Thu, May 27, 2004 at 12:31:49PM -0400, Trond Myklebust wrote:
> That said, I believe that RHEL-3 at least is returning an error these
> days whenever you try to flock over NFS: I dunno if you are doing this
> at SuSE yet?

We did, on SLES8. Those were some silly third party patches we included
that changed flock to call the lock() function of the underlying FS.
The NFS lock function returns -ENOLCK in this case.

I don't know where this patch came from. Maybe it was GFS related.
I did have to handle a fair share of bug reports because of that.

But I think those broken movemails are not the issue; in fact this
change would actually _fix_ these apps to work over NFS, for the first
time. The only problematic apps would be those mixing flock and fcntl
on a single open file.

Olaf
--
Olaf Kirch | The Hardware Gods hate me.
[email protected] |
---------------+


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs