sysmark@physics.utoronto.ca (Mark Bartelt) (03/19/91)
Am I just overlooking something obvious, or does lockf() not work properly on NFS-mounted volumes? More specifically, the lock gets created, but doesn't get removed when the requesting process exits. I R'ed TFM, and TFM claims (in the lockf(3c) man page) that All the locks for a process are removed when the process terminates. However, this seems to happen only for local files, not for NFS-mounted ones. For the latter, subsequent attempts to do a test-and-lock (by using F_TLOCK) return EACCES. For example: % x /usr/people/sysmark/tmp/foo # This file is on the client /usr/people/sysmark/tmp/foo: ok % x /usr/people/sysmark/tmp/foo /usr/people/sysmark/tmp/foo: ok % % x /hemlock/sysmark/tmp/snarf # This file is on the server /hemlock/sysmark/tmp/snarf: ok % x /hemlock/sysmark/tmp/snarf /hemlock/sysmark/tmp/snarf: lock error 13 # GACK! % The trivial program "x" (source appended below) just does an open/lockf/close for each file named on the command line. Configuration details: The program was run on a 4D/25 running IRIX 3.3.1; the server is a 4D/280 running 3.3.2. And lockd/statd are running on both systems. Is this just a horrible botch in lockf() and/or lockd? Or (more likely) have I just missed something in TFM? ------------------------------------- x.c ------------------------------------- #include <unistd.h> extern int errno; main(ac,av) int ac; char ** av; { int fd; while ( --ac > 0 ) if ( (fd=open(*++av,2)) < 0 ) printf("%s: open error\n",*av); else { if ( lockf(fd,F_TLOCK,0) < 0 ) printf("%s: lock error %d\n",*av,errno); else printf("%s: ok\n",*av); close(fd); } exit(0); } ------------------------------------------------------------------------------- Mark Bartelt 416/978-5619 Canadian Institute for sysmark@cita.toronto.edu Theoretical Astrophysics sysmark@cita.utoronto.ca
krogh@talon.ncsa.uiuc.edu (Mike Krogh) (03/20/91)
There is a bug with lockf() with respect to NFS files. You can obtain a lock on such a file, but if the file size equals zero after locking, the file will appear to contain binary garbage from then on. Deleting the file or rebooting the system is the cure. This occurs on 3.3.2. If you're running 3.3.1, then you only need to set the lock for the problem to occur. The file size does not need to equal zero. This can real make reading email a pain if your mail is on a NFS partition. This was reported to SGI and is bug #10894 As a side note, if you plan on using lockf(), make sure that lockd and statd are running (see 'man lockd'). Mike Krogh NCSA krogh@ncsa.uiuc.edu