linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Locking NFS files on kernels 2.4.19 and 2.4.20
@ 2003-06-09 13:25 Bob Vickers
  2003-06-09 17:05 ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Vickers @ 2003-06-09 13:25 UTC (permalink / raw)
  To: linux-kernel

Dear Linex kernel developers,

Forgive me for venturing rather nervously onto such an esteemed mailing
list, but I have hit a problem which looks to me very much like a kernel
bug, and much googling has so far failed to come up with any advice.

I have recently upgraded some machines and have found that it is no longer
possible to lock files on NFS file systems. It is definitely a client-side
problem: upgraded clients could no longer lock files on *any* NFS server
(including Tru64 as well as a variety of Linux servers).

If anyone knows of any bugs in this area I would be grateful to hear more.
Here are the details:

The failing clients are all running off-the-shelf SuSE kernels. They
include
	k_smp-2.4.20-40
	k_smp-2.4.19-257
	k_deflt-2.4.20-39
Programs on these clients get an ENOLCK error when they use fcntl with the
f_SETLK option on an NFS file. This blows galeon and other applications
out of the water.

If nobody has a definite solution it would be useful to know whether
others are hitting the same problem. Has anyone got NFS locking to work on
SuSE 8.0 or 8.1 systems? Does it work on non-SuSE 2.4.19 and 2.4.20
kernels?

On one occasion I enabled some NFS debug messages by typing
  echo "217" >|/proc/sys/sunrpc/nlm_debug
and this produced the following log messages (note the suspicious
arguments to xdr_encode_mon):

May 23 17:34:22 castor kernel: lockd: nlm_lookup_host(86dbbc06, p=17, v=4)
May 23 17:34:22 castor kernel: lockd: get host 134.219.188.6
May 23 17:34:22 castor kernel: lockd: nsm_monitor(134.219.188.6)
May 23 17:34:22 castor kernel: nsm: xdr_encode_mon(86dbbc06, -1249509120,
67108864, 268435456)
May 23 17:34:22 castor kernel: lockd: release host 134.219.188.6


Here is the program I used to test locking (you need to touch mylockfile
before running it):

#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
main()
{
  int fd, stat;
  struct flock lck;
  lck.l_type = F_WRLCK;   /* setting a write lock */
  lck.l_whence = 0;       /* offset l_start from beginning of file */
  lck.l_start = 0;
  lck.l_len = 1;
  fd=open("mylockfile", O_RDWR, 0);
  if ( fd < 0 )
  {
    perror ("Open failed");
  }
  else
  {
    stat=fcntl (fd, F_SETLK, &lck);
    if ( stat == -1 )
    {
      perror ("SETLK failed");
    }
    else
    {
      printf ("SETLK worked\n");
    }
  }
}

Regards,
Bob
==============================================================
Bob Vickers                     R.Vickers@cs.rhul.ac.uk
Dept of Computer Science, Royal Holloway, University of London
WWW:    http://www.cs.rhul.ac.uk/home/bobv
Phone:  +44 1784 443691


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Locking NFS files on kernels 2.4.19 and 2.4.20
  2003-06-09 13:25 Locking NFS files on kernels 2.4.19 and 2.4.20 Bob Vickers
@ 2003-06-09 17:05 ` Trond Myklebust
  2003-06-10 10:17   ` Bob Vickers
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2003-06-09 17:05 UTC (permalink / raw)
  To: Bob Vickers; +Cc: linux-kernel

>>>>> " " == Bob Vickers <bobv@cs.rhul.ac.uk> writes:

     > I have recently upgraded some machines and have found that it
     > is no longer possible to lock files on NFS file systems. It is
     > definitely a client-side problem: upgraded clients could no
     > longer lock files on *any* NFS server (including Tru64 as well
     > as a variety of Linux servers).

Two questions:

  Are you running statd on the client and server?

if no, then you should...

  Does SuSE compile statd with or without the RESTRICTED_STATD flag?

If the latter, then you'll need an extra kernel patch in order to
allow the kernel NSM to use a reserved port. Something like the
appended scheme...

Cheers,
  Trond

--- linux/fs/lockd/mon.c.orig	2002-02-04 23:49:27.000000000 -0800
+++ linux/fs/lockd/mon.c	2003-06-09 10:02:57.000000000 -0700
@@ -105,12 +105,19 @@
 	struct rpc_xprt		*xprt;
 	struct rpc_clnt		*clnt = NULL;
 	struct sockaddr_in	sin;
+	uid_t saved_fsuid = current->fsuid;
+	kernel_cap_t saved_cap = current->cap_effective;
 
 	sin.sin_family = AF_INET;
 	sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 	sin.sin_port = 0;
 
+	/* Create RPC socket as root user so we get a priv port */
+	current->fsuid = 0;
+	cap_raise (current->cap_effective, CAP_NET_BIND_SERVICE);
 	xprt = xprt_create_proto(IPPROTO_UDP, &sin, NULL);
+	current->fsuid = saved_fsuid;
+	current->cap_effective = saved_cap;
 	if (!xprt)
 		goto out;
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Locking NFS files on kernels 2.4.19 and 2.4.20
  2003-06-09 17:05 ` Trond Myklebust
@ 2003-06-10 10:17   ` Bob Vickers
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Vickers @ 2003-06-10 10:17 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: Bob Vickers, linux-kernel

Dear Trond,

Thank you very very much, that is it! rpc.statd was running on the server
but not the client. I have started it and it now works.

The stupid thing is I was really close to seeing this weeks ago, but got
confused by various ancient pieces of documentation and by the fact
that you don't need rpc.lockd any more because lockd is now part of the
kernel.

And the high-level message is: starting SuSE 8.1 you need to type
   chkconfig nfslock on
if you want NFS locking to work on the client. And probably on the server
too.

Bob

 On 9 Jun 2003, Trond Myklebust wrote:

> >>>>> " " == Bob Vickers <bobv@cs.rhul.ac.uk> writes:
>
>      > I have recently upgraded some machines and have found that it
>      > is no longer possible to lock files on NFS file systems. It is
>      > definitely a client-side problem: upgraded clients could no
>      > longer lock files on *any* NFS server (including Tru64 as well
>      > as a variety of Linux servers).
>
> Two questions:
>
>   Are you running statd on the client and server?
>
> if no, then you should...
>
>   Does SuSE compile statd with or without the RESTRICTED_STATD flag?
>
> If the latter, then you'll need an extra kernel patch in order to
> allow the kernel NSM to use a reserved port. Something like the
> appended scheme...
>
> Cheers,
>   Trond
>


==============================================================
Bob Vickers                     R.Vickers@cs.rhul.ac.uk
Dept of Computer Science, Royal Holloway, University of London
WWW:    http://www.cs.rhul.ac.uk/home/bobv
Phone:  +44 1784 443691


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-06-10 10:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-09 13:25 Locking NFS files on kernels 2.4.19 and 2.4.20 Bob Vickers
2003-06-09 17:05 ` Trond Myklebust
2003-06-10 10:17   ` Bob Vickers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).