No locks available

Heiner Kruener (hk@martian.ping.de)
Sun, 27 Jun 1999 03:05:33 +0200 (CEST)


Hi there!

Over nfs I'm trying to lock a file against concurrent use, but it seems as
if on kernel 2.2 upward this is no longer possible (on 2.0 it was a no-op).
(tried kernel 2.2.5 to 2.2.10ac4, 2.3.5)
I use (ripped from the source and simplified, original code is from hpux):
#include <stdio.h>
#include <fcntl.h>
main () {
char datei[]="test.lock";
int fil=0;
FILE *file;

file=fopen(datei,"w");
if(file) {
fil=fileno(file);
fputs("Locked",file); /* print 6 bytes */
lseek(fil,SEEK_SET,0L);/* return to file beginning */
if(lockf(fil, 2, 6)) { /* lock 6 bytes from current position */
perror("lock"); /* couldnt get lock */
fgets(datei[0],1,stdin); /* just to see which daemons get started */
}
fclose(file);
}
}

The file test.lock gets created, but lockf fails with:
lock: No locks available
but
109 ? S 0:00 /usr/sbin/rpc.ugidd
269 p3 SW 0:00 (rpciod)
270 p3 SW 0:00 (lockd)
374 ? S 0:00 /usr/sbin/rpc.statd
get started (or are running anyway).

I'v put 32767 into sunrpc/nlm_debug giving this log:
Jun 23 03:13:36 phobos kernel: NFS locking service started (ver 0.4).
Jun 23 03:14:19 phobos kernel: lockd: nlm_lookup_host(c2610723, p=17, v=1)
Jun 23 03:14:19 phobos kernel: lockd: host garbage collection
Jun 23 03:14:19 phobos kernel: lockd: nlmsvc_mark_resources
Jun 23 03:14:19 phobos kernel: lockd: creating host entry
Jun 23 03:14:19 phobos kernel: lockd: creating host entry
Jun 23 03:14:19 phobos kernel: lockd: nsm_monitor(194.97.7.35)
Jun 23 03:14:19 phobos kernel: nsm_mon_unmon: rpc failed, status=-13
Jun 23 03:14:19 phobos kernel: lockd: failed to monitor 194.97.7.35
Jun 23 03:14:19 phobos kernel: lockd: clnt proc returns -37
Jun 23 03:14:19 phobos kernel: lockd: release host 194.97.7.35

Same result for using knfsd1.4.1 or regular nfsd2.2beta43 (I *have* recompiled
and installed the new kernel using kernel nfs and/or modules)
I have even changed every dprintk in fs/lockd to a corresponding printk, but
in spite of many dprintk's in the source the logfile shows no more information,
apparently because the error occurs very early in the locking stage, esp. in
fs/lockd/mon.c:52, so it's not really a locking problem.

/etc/exports for the filesystem in question is exported
/mnt 194.97.7.*(rw,no_root_squash)
/etc/hosts.allow is
ALL : ALL

>From the error message and from looking through the code in lockd I'd suspect
some identification/authentification failure, but I'm running this test
on 'mount phobos:/mnt /mnt1', the local machine phobos:194.97.7.35; so what?

>From putting 32767 into all sunrpc/*debug I get
Jun 26 23:44:23 phobos kernel: RPC: 61 validating UNIX cred c4cec140
Jun 26 23:44:23 phobos kernel: RPC: 61 call_decode result 0
Jun 26 23:44:23 phobos kernel: RPC: 61 exit() = 0
but in the same second
Jun 26 23:44:23 phobos kernel: RPC: 62 validating UNIX cred c4cec140
Jun 26 23:44:23 phobos kernel: RPC: 62 call_decode result 37
Jun 26 23:44:23 phobos kernel: RPC: 62 exit() = 37
(complete log available on request)

Seems as if during the authentification process some value gets thrashed/mis-
interpreted/overwritten/not retrieved resulting in a 'not zero' return value.
(rpc.statd is running)

Am I missing something so obvious that I can't see it?
(Changes from 2.0.x dont indicate any necessary changes in configuration)

See you
Heiner

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