2004-06-09 19:21:29

by Ruben Puettmann

[permalink] [raw]
Subject: 2.6.X File locking on NFS stil broken


hello,


I have a big iproblem with the nfs file locking on some 2.6 er kernel

Kernel Server: 2.4.9
Kernel Client: 2.6.7-rc3-bk2
2.6.6-rc3-mm2
2.6.5

mount options :

10.0.0.149:/export /mnt/server nfs rw,auto,soft,bg,timeo=12,retrans=3,in tr,rsize=8192,wsize=8192,mountvers=3,nfsvers=3,udp 0 0

nfs-utils : 1.0.6

Both Server an Client Debian Sarge. Wiht kernel 2.4.21-pre5 the locking
runs very fine against the server.

This little testscript I used ( got it from a friend):

#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>

int main(int c, char **v)
{
for (++v, --c; c--; ++v) {
struct flock lck = {F_RDLCK, SEEK_SET, 0, 0}; /* whole file */
int fd = open(*v, O_RDONLY);
if ( fd < 0 )
fprintf(stderr, "%s: %s\n", *v, strerror(errno));
else {
if ( fcntl(fd, F_SETLK, &lck) < 0 )
fprintf(stderr, "%s[%d]: %s\n", *v, lck.l_pid, strerror(errno));
else
printf("%s..ok\n", *v);
close(fd);
}
}
return 0;
}


The programm hangs after executing ./script testfile.


Ruben





--
Ruben Puettmann
[email protected]
http://www.puettmann.net


2004-06-09 20:41:50

by Trond Myklebust

[permalink] [raw]
Subject: Re: 2.6.X File locking on NFS stil broken

P? on , 09/06/2004 klokka 15:17, skreiv Ruben Puettmann:
> hello,
>
>
> I have a big iproblem with the nfs file locking on some 2.6 er kernel
>
> Kernel Server: 2.4.9
> Kernel Client: 2.6.7-rc3-bk2
> 2.6.6-rc3-mm2
> 2.6.5
<snip>
> This little testscript I used ( got it from a friend):

That script works fine for me: I haven't seen any hangs on locking in
any of the 2.6 series kernels so far.

What does 'rpcinfo -p' show on the client and server?

Cheers,
Trond

2004-06-09 20:47:25

by linux-kernel-owner

[permalink] [raw]
Subject: Re: 2.6.X File locking on NFS stil broken

On Wed, Jun 09, 2004 at 04:41:12PM -0400, Trond Myklebust wrote:

> That script works fine for me: I haven't seen any hangs on locking in
> any of the 2.6 series kernels so far.

If I mount it with nolock it runs fine too ;-). I have not enough C
knowledge to see whree the bug is.

>
> What does 'rpcinfo -p' show on the client and server?
>

Server :


sslnfs:~# rpcinfo -p
Program Vers Proto Port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 759 status
100024 1 tcp 762 status
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100021 1 udp 32779 nlockmgr
100021 3 udp 32779 nlockmgr
100021 4 udp 32779 nlockmgr
100005 1 udp 901 mountd
100005 1 tcp 904 mountd
100005 2 udp 901 mountd
100005 2 tcp 904 mountd
100005 3 udp 901 mountd
100005 3 tcp 904 mountd

Client:

root@www10:[~] > rpcinfo -p
Program Vers Proto Port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100021 1 udp 32768 nlockmgr
100021 3 udp 32768 nlockmgr
100021 4 udp 32768 nlockmgr
100024 1 udp 938 status
100024 1 tcp 941 status


Ruben


--
Ruben Puettmann
[email protected]
http://www.puettmann.net


Attachments:
(No filename) (1.37 kB)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-06-09 21:28:00

by Ruben Puettmann

[permalink] [raw]
Subject: Re: 2.6.X File locking on NFS stil broken

On Wed, Jun 09, 2004 at 05:13:43PM -0400, Trond Myklebust wrote:
> P? on , 09/06/2004 klokka 17:03, skreiv Ruben Puettmann:
>
> > attached the strace and one tcpdump from the testprogramm.
>
> According to that tcpdump, the server is denying you the lock because it
> is still in its grace period.
>
> During that period only clients that held locks before the server
> rebooted are allowed to reclaim those locks. Your client will need to
> wait until that grace period is over (usually ~ 1 minute or so).
>

I have done a reboot on teh server ( It was up for over 315 day's ;-( )
now all runs fine seems to be an race condition. I will take a look on
it if this happend again.

Thanks for your help !!


Ruben

--
Ruben Puettmann
[email protected]
http://www.puettmann.net


Attachments:
(No filename) (800.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-06-10 02:59:10

by Ryan Anderson

[permalink] [raw]
Subject: Re: 2.6.X File locking on NFS stil broken

On Wed, Jun 09, 2004 at 11:24:30PM +0200, Ruben Puettmann wrote:
> On Wed, Jun 09, 2004 at 05:13:43PM -0400, Trond Myklebust wrote:
> > P? on , 09/06/2004 klokka 17:03, skreiv Ruben Puettmann:
> >
> > > attached the strace and one tcpdump from the testprogramm.
> >
> > According to that tcpdump, the server is denying you the lock because it
> > is still in its grace period.
> >
> > During that period only clients that held locks before the server
> > rebooted are allowed to reclaim those locks. Your client will need to
> > wait until that grace period is over (usually ~ 1 minute or so).
>
> I have done a reboot on teh server ( It was up for over 315 day's ;-( )
> now all runs fine seems to be an race condition. I will take a look on
> it if this happend again.

Did you change libc and/or your DNS configuration without restarting
nfs-common? (statd/lockd)

--

Ryan Anderson