From: Frank van Maarseveen <frankvm@frankvm.com>
To: Linux NFS mailing list <nfs@lists.sourceforge.net>
Subject: NFS client locks sometimes not removed from server (reproducable)
Date: Fri, 2 Mar 2007 16:51:45 +0100 [thread overview]
Message-ID: <20070302155145.GA12177@janus> (raw)
[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]
Client and server are the same. Kernels tried: 2.6.19, 2.6.20 and
2.6.20.1 + http://client.linux-nfs.org/Linux-2.6.x/2.6.20/linux-2.6.20-NFS_ALL.dif
kernel compiled with gcc version 3.4.6 (Debian 3.4.6-4)
/proc/mounts says:
server:/mnt /net/server/mnt nfs rw,nosuid,nodev,vers=3,rsize=32768,wsize=32768,hard,proto=udp,timeo=11,retrans=2,sec=sys,addr=server 0 0
cd /net/server/mnt
mkdir t
cd t
(save lck.c and locktest attachments here)
gcc -o lck lck.c
./locktest
When the script terminates:
- ls -li lck-filename
(remember the inode #)
- ps wwwuax|grep lck
(there should not be any running)
- cat /proc/locks
(inode appears not locked)
- ssh server cat /proc/locks
(inode appears locked!)
Trying the same against a tru64 server shows similar symptoms (the file
can no longer be locked. tru64 has no /proc/locks of course).
A possibly related issue: when the client is shut down it says
lockd_down: lockd failed to exit, clearing pid
when the client reboots (rpc.statd?) the server seems to remove the
corresponding locks which is a smart thing to do.
--
Frank
[-- Attachment #2: lck.c --]
[-- Type: text/plain, Size: 1514 bytes --]
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
void die(const char *fmt, ...) __attribute__((format(printf, 1, 2), noreturn));
void die(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "lck: ");
vfprintf(stderr, fmt, ap);
va_end(ap);
exit(1);
}
int main(int argc, char **argv)
{
struct flock flock = {0};
int i, d, locktime, cmd;
const char *name;
flock.l_type = F_WRLCK; /* -w */
flock.l_whence = SEEK_SET;
cmd = F_SETLKW; /* no -t */
name = NULL;
locktime = 10;
for (i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-r") == 0)
flock.l_type = F_RDLCK; /* lock for N readers */
else if (strcmp(argv[i], "-w") == 0)
flock.l_type = F_WRLCK; /* lock for 1 writer */
else if (strcmp(argv[i], "-t") == 0)
cmd = F_SETLK; /* test for a lock, don't wait */
else if (argv[i][0] == '-')
die("Usage: lck [-r|-w] [-t] [<filename> [<locktime>]]\n");
else if (name && isdigit(argv[i][0]))
locktime = atoi(argv[i]); /* after acquiring lock, wait locktime seconds */
else
name = argv[i];
}
if (!name)
name = "lck-filename";
d = open(name, O_RDWR|O_CREAT, 0666);
if (d == -1)
die("open %s: %s\n", name, strerror(errno));
if (fcntl(d, cmd, &flock) == -1)
die("fcntl: %s\n", strerror(errno));
printf("locked...");
fflush(NULL);
sleep(locktime);
if (close(d))
die("close: %s\n", strerror(errno));
printf("unlocked.\n");
return 0;
}
[-- Attachment #3: locktest --]
[-- Type: text/plain, Size: 544 bytes --]
#!/bin/sh
trap ' exit ' 1 2 3 15
trap ' fuser -k $lck ; rm -f $lck ' 0
lck=`mktemp -t lckXXXXXX`
cp lck $lck
chmod +x $lck
rm -f lck-filename
function f1()
{
while :
do
$lck lck-filename 1
sleep 1
done
}
function f2()
{
while :
do
$lck lck-filename 0
done
}
function f3()
{
while :
do
$lck -r lck-filename 0
done
}
function f4()
{
while :
do
$lck -r -t lck-filename 0
done
}
while :
do
( f1 & f2 & f3 & f4 ) 9<$lck &
sleep 5
fuser -k $lck
sleep 2
echo -n write lock test:
lck -t lck-filename 0 || exit
done
[-- Attachment #4: Type: text/plain, Size: 345 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #5: Type: text/plain, Size: 140 bytes --]
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
reply other threads:[~2007-03-02 15:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070302155145.GA12177@janus \
--to=frankvm@frankvm.com \
--cc=nfs@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox