linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Locking over NFS
@ 2003-11-27 23:09 J.A. Magallon
  2003-11-28  1:01 ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: J.A. Magallon @ 2003-11-27 23:09 UTC (permalink / raw)
  To: Lista Linux-Kernel

Hi all...

Is locking via lockf/fcntl supposed to work over NFS mounted volumes 
in 2.4 ?
I can't get it to work, even if kernel [lockd] is running in the server.
Server locks the file, and client gets an error:

annwn:~/dev/lk> lockf 10000
locked
<switch term>
annwn:~/dev/lk> bpsh 0 lockf
lockf:F_LOCK: No locks available

lockf.c:

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>

int main(int argc, char** argv)
{
    int fd;

    fd = open("lock",O_RDWR);
    if (fd<0)
        perror("open");

    if (lockf(fd,F_LOCK,0)<0)
        perror("lockf:F_LOCK");
    else
        printf("locked\n");
    fflush(stdout);

    if (argc>1)
        sleep(atoi(argv[1]));

    if (lockf(fd,F_ULOCK,0)<0)
        perror("lockf:F_ULOCK");
    else
        printf("unlocked\n");
    fflush(stdout);

    return 0;
}

TIA

-- 
J.A. Magallon <jamagallon()able!es>     \                 Software is like sex:
werewolf!able!es                         \           It's better when it's free
Mandrake Linux release 10.0 (Cooker) for i586
Linux 2.4.23-rc5-jam1 (gcc 3.3.1 (Mandrake Linux 9.2 3.3.1-4mdk))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Locking over NFS
  2003-11-27 23:09 Locking over NFS J.A. Magallon
@ 2003-11-28  1:01 ` Trond Myklebust
  2003-11-28  1:12   ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2003-11-28  1:01 UTC (permalink / raw)
  To: J.A. Magallon; +Cc: Lista Linux-Kernel

>>>>> " " == J A Magallon <J.A.> writes:

     > Hi all...  Is locking via lockf/fcntl supposed to work over NFS
     > mounted volumes in 2.4 ?  I can't get it to work, even if

Yes, it works just fine.

You're probably failing to run rpc.statd or something like that. See
the NFS FAQ & HOWTO on http://nfs.sourceforge.net

Cheers,
  Trond

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Locking over NFS
  2003-11-28  1:01 ` Trond Myklebust
@ 2003-11-28  1:12   ` Trond Myklebust
  0 siblings, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2003-11-28  1:12 UTC (permalink / raw)
  To: J.A. Magallon, Lista Linux-Kernel

>>>>> " " == Trond Myklebust <trond.myklebust@fys.uio.no> writes:

     > Yes, it works just fine.

     > You're probably failing to run rpc.statd or something like
     > that. See the NFS FAQ & HOWTO on http://nfs.sourceforge.net

Come to think of it, are you perhaps trying to set the lock on an
NFSroot volume? Those are automatically mounted with the 'nolock'
mount option set.

Cheers,
  Trond

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-11-28  1:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-27 23:09 Locking over NFS J.A. Magallon
2003-11-28  1:01 ` Trond Myklebust
2003-11-28  1:12   ` Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).