f



File locking between Linux server and HP-UX 10.20 client

We are running into odd file locking problems between our NFS server
which is running on Redhat 9.0 - kernel 2.4.20-8 and HP-UX 10.20
clients.  When a HP-UX 10.20 client requests a file lock on a mounted
directory that resides on Linux, we get the following error: No locks
available

The kernel parameter nflocks is set to 200 which seems like a
reasonable limit. I'm pretty certain this limit isn't being reached,
but it is some type of NFS problem. Has anyone else seen this problem
and fixed it?

I've written a small program that demonstrates the problem:

[madden@hacksaw locktest]$ ./locktest locktest.c
Locking locktest.c...
fcntl: No locks available

/* locktest.c - compiled as: gcc -Wall -O2 locktest.c  -o locktest */

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

static void setlock(int fd, struct flock fl)
{
    if (fcntl(fd, F_SETLKW, &fl) == -1) {
        perror("fcntl");
        exit(EXIT_FAILURE);
    }
}

int main(int argc, char **argv)
{
    struct flock fl = { F_WRLCK, 0, 0, 0, 0 };
    int fd;

    if (argc != 2) {
        printf("Usage: %s file\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    if ((fd = open(argv[1], O_RDWR)) == -1) {
        perror("open");
        exit(EXIT_FAILURE);
    }

    printf("Locking %s...\n", argv[1]);
    fl.l_type = F_RDLCK;
    setlock(fd, fl);
    printf("%s locked successfully.\n\n", argv[1]);

    printf("Unlocking %s...\n", argv[1]);
    fl.l_type = F_UNLCK;
    setlock(fd, fl);
    printf("%s unlocked successfully.\n\n", argv[1]);

    return (EXIT_SUCCESS);
}
0
madden
5/21/2004 3:26:52 PM
comp.sys.hp.hpux 4408 articles. 1 followers. dewi.bening (7) is leader. Post Follow

3 Replies
799 Views

Similar Articles

[PageSpeed] 34

madden@cmsrtp.com (Michael Madden) writes:

> We are running into odd file locking problems between our NFS server
> which is running on Redhat 9.0 - kernel 2.4.20-8 and HP-UX 10.20
> clients.  When a HP-UX 10.20 client requests a file lock on a mounted
> directory that resides on Linux, we get the following error: No locks
> available

tcpdump output would probably shed some light. Also make sure rpc.lockd
is running on the redhat host. 

tim
0
tbutler
5/22/2004 6:01:54 PM
> We are running into odd file locking problems between our NFS server
> which is running on Redhat 9.0 - kernel 2.4.20-8 and HP-UX 10.20
> clients.  When a HP-UX 10.20 client requests a file lock on a mounted
> directory that resides on Linux, we get the following error: No locks
> available

 I would run:

# rpcinfo -p <RH server> 

...from one of the HP clients. This would at lesat reveal if you can contact
the portmapper on the server and whether a lock service is available. The
relevant network status monitor services should be able communicate. Perhaps
you need to check if this is allowed by your firewall configuration.

DaveN.
0
djn
5/24/2004 1:53:39 PM
We figured out the file locking problem.  Either do one of the
following:

1.) Ensure the directory permissions are set to 755 and the file
permissions are set to 644.  The file permissions were 640. Otherwise
the file cannot be locked.

2.) On the Linux server, add the insecure_locks option to
/etc/exports, re-export, and restart NFS.

Thanks,
Mike
0
madden
5/25/2004 10:02:10 PM
Reply: