Locking NFS files on kernels 2.4.19 and 2.4.20

From: Bob Vickers (bobv@cs.rhul.ac.uk)
Date: Mon Jun 09 2003 - 08:25:26 EST

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
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

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
May 23 17:34:22 castor kernel: lockd: nsm_monitor(
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

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>
  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");
    stat=fcntl (fd, F_SETLK, &lck);
    if ( stat == -1 )
      perror ("SETLK failed");
      printf ("SETLK worked\n");

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

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

This archive was generated by hypermail 2b29 : Sun Jun 15 2003 - 22:00:20 EST