[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: nfs lock problems (I/O error)



On Tue, Oct 29, 2002 at 13:32:48 +0100, Robert Kellner wrote:
> I have some problems with file-locking over nfs.
> 
> Not only is mail giving me input/output error when trying to lock
> a mailbox, I also have problems using dbm-files with perl (same
> thing, input/output errors)
> 
> Does anybody know something about the locking-problem?

I had locking problems related to NFS a few months ago at my lab
(preventing from locking NFS mailboxes). After several mails, the
sysadmin cleaned-up the lock manager and the problem was solved.
I don't know if this is the same problem...

The attached program may help you to find the problem.

$ touch blah
$ tfcntl blah 1

Depending on the machine, I got one of the following errors:

tfcntl: lock failed (errno = 22)
tfnctl: Invalid argument

tfcntl: lock failed (errno = 13)
tfnctl: Permission denied

tfcntl: lock failed (errno = 77)
tfnctl: No locks available

On some machines (not Linux), I had to use kill -9 to kill the tfcntl
program (sometimes leaving a zombie).

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

int main (int argc, char *argv[])
{
  FILE *f;
  int fd;
  struct flock lck;

  if (argc != 3)
  {
    fprintf (stderr, "Usage: tfcntl <file> <sleeptime>\n");
    exit (1);
  }

  f = fopen (argv[1], "r+b");
  if (f == NULL)
  {
    fprintf (stderr, "tfcntl: can't open file %s\n", argv[1]);
    perror ("tfnctl");
    exit (2);
  }
  fd = fileno (f);

  memset (&lck, 0, sizeof (struct flock));
  lck.l_type = F_WRLCK;
  lck.l_whence = SEEK_SET;
  if (fcntl (fd, F_SETLK, &lck) == -1)
  {
    fprintf (stderr, "tfcntl: lock failed (errno = %d)\n", errno);
    perror ("tfnctl");
    exit (3);
  }

  sleep(atoi(argv[2]));

  memset (&lck, 0, sizeof (struct flock));
  lck.l_type = F_UNLCK;
  lck.l_whence = SEEK_SET;
  fcntl (fd, F_SETLK, &lck);

  return 0;
}

Reply to: