Messages in this thread | | | Date | Fri, 24 Sep 1999 20:33:59 +0200 | From | Kenneth Johansson <> | Subject | nfs lockup |
| |
If I run the included program on a nfs mounted filesystem my system hangs only ping works.
This happens on 2.2.12 and 2.3.18 systems.
/* test whether fcntl locking works on this system */
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <fcntl.h> #include <sys/fcntl.h> #include <errno.h>
static int sys_waitpid(pid_t pid,int *status,int options) { return waitpid(pid,status,options); }
#define DATA "conftest.fcntl"
#ifndef SEEK_SET #define SEEK_SET 0 #endif
/* lock a byte range in a open file */ int main(int argc, char *argv[]) { struct flock lock; int fd, pid, ret, status=1;
if (!(pid=fork())) { sleep(2); fd = open(DATA, O_RDONLY);
if (fd == -1) exit(1);
lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; lock.l_start = 0; lock.l_len = 4; lock.l_pid = getpid(); lock.l_type = F_WRLCK; /* check if a lock applies */ ret = fcntl(fd,F_GETLK,&lock);
if ((ret == -1) || (lock.l_type == F_UNLCK)) { exit(1); } else { exit(0); } }
fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600);
lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; lock.l_start = 0; lock.l_len = 4; lock.l_pid = getpid();
/* set a 4 byte write lock */ fcntl(fd,F_SETLK,&lock);
sys_waitpid(pid, &status, 0);
unlink(DATA);
exit(status); }
| |