Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Sep 2001 18:42:26 -0400
From:      "Buzz Megg" <buzmeg@hotmail.com>
To:        stable@freebsd.org
Subject:   NFS locks failing under certain circumstances ,,, (fwd)
Message-ID:  <F722TUSzbAUfKRfcjcM00005342@hotmail.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Here is a forwarded message from myself about NFS lock failures.

Side note: When did the FreeBSD mailing lists become so anal about valid 
reverse DNS?

-a

>---------- Forwarded message ----------
Date: Mon, 3 Sep 2001 03:09:45 -0500 (CDT)
From: andrewl@nshore.com
To: stable@freebsd.org
Cc: andrewl@nshore.com
Subject: NFS locks failing under certain circumstances ,,,

I have bumped into a few problems with locking files over NFS ...

With FreeBSD 4.4-20010827-RC2 #0: Mon Aug 27 20:53:32 PDT 2001 ...

Using fcntl to lock files the following combinations work:

User1               User 2
Disk File           Disk file	SETLK
Disk File           Disk file	SETLKW
NFS file            NFS file    SETLK

Using fcntl to lock files, the following combination do not work:

User1               User 2
NFS file            NFS file    SETLKW
Disk file           NFS file    SETLK
Disk file           NFS file    SETLKW

I have included the little program I use to test this stuff for reference.

-a



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

[-- Attachment #2 --]
#include <stdio.h>
#include <fcntl.h>
#include <sys/file.h>
#ifndef SEEK_SET
#define SEEK_SET        0
#endif

main()
{
  char buffer[80];
  int fh, lock_val;
  struct flock fl;

  printf("f_rdlck,f_wrlck,f_unlck,seek_set,f_setlk=%d,%d,%d,%d,%d\n",
	 F_RDLCK,F_WRLCK,F_UNLCK,SEEK_SET,F_SETLK);

  fh = open("lock1.file", O_RDWR|O_CREAT, 0644);

  printf("File handle: %d\n",fh);
	  
  fl.l_type = F_WRLCK;
  fl.l_whence = SEEK_SET;
  fl.l_start = fl.l_len = 0L;

  printf("Attempting to lock file...\n");
  lock_val = fcntl (fh, F_SETLKW, &fl);
  if (lock_val == -1)
    {
      perror("After trying to lock ");
    }
  printf("lock_val = %d\n",lock_val);
  printf("Holding for user input...");
  buffer[0] = getchar();

  printf("Attempting to unlock file...\n");
  fl.l_type = F_UNLCK;
  lock_val = fcntl (fh, F_SETLK, &fl);
  if (lock_val == -1)
    {
      perror("After trying to lock ");
    }
  printf("lock_val = %d\n",lock_val);

  close(fh);
} 
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F722TUSzbAUfKRfcjcM00005342>