From: Philippe Troin <phil@fifi.org>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Kenny Simpson <theonetruekenny@yahoo.com>,
linux-kernel@vger.kernel.org, nfs@lists.sourceforge.net
Subject: Re: [NFS client] NFS locks not released on abnormal process termination
Date: 09 Dec 2003 10:46:44 -0800 [thread overview]
Message-ID: <8765gpvnfv.fsf@ceramic.fifi.org> (raw)
In-Reply-To: <shsekvetmat.fsf@guts.uio.no>
[-- Attachment #1: Type: text/plain, Size: 982 bytes --]
Trond Myklebust <trond.myklebust@fys.uio.no> writes:
> >>>>> " " == Philippe Troin <phil@fifi.org> writes:
>
> > From my reading of the patch, it supersedes the old patch, and
> > is only
> > necessary on the client. Is also does not compile :-)
>
> Yeah, I admit I didn't test it out...
>
> > Here's an updated patch which does compile.
>
> Thanks.
>
> > I am still running tests, but so far it looks good (that is all
> > locks are freed when a process with locks running on a NFS
> > client is killed).
>
> Good...
I've ran test overnight on four boxen, and no locks were lost.
I guess you can send this patch to Marcello now.
I've tested with the enclosed program.
> There are still 2 other issues with the generic POSIX locking code.
> Both issues have to do with CLONE_VM and have been raised on
> linux-kernel & linux-fsdevel. Unfortunately they met with no response,
> so I'm unable to pursue...
Can we help? Pointers?
Phil.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: kill-locks.c --]
[-- Type: text/x-csrc, Size: 2549 bytes --]
#define _GNU_SOURCE
#define _LARGEFILE_SOURCE
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <errno.h>
#define FNAME "kill-locks.tmp"
#define BUFSIZE 16384
#define DEATHSIG SIGINT
#define LOCKTRIES 10
#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)
#define LOCKTRIESSTR STRINGIFY(LOCKTRIES)
#define LOCKSLEEPSECS 1
void parent_try_lock(int mfd, int successcount, int status)
{
int i;
struct flock lck;
for (i=0; 1 /* always true */; ++i)
{
lck.l_type = F_WRLCK;
lck.l_whence = SEEK_SET;
lck.l_start = (off_t)0;
lck.l_len = (off_t)0;
if (fcntl(mfd, F_SETLK, &lck) == -1)
{
if (errno == EAGAIN)
{
if ( i == LOCKTRIES )
{
fprintf(stderr,
"unexpected status from child %08X\n"
"successful locking attempts: %d\n",
status, successcount);
exit(1);
}
else
{
sleep(LOCKSLEEPSECS);
}
}
else
perror("[parent] fcntl(F_SETLK)"), exit(1);
}
else
{
lck.l_type = F_UNLCK;
lck.l_whence = SEEK_SET;
lck.l_start = (off_t)0;
lck.l_len = (off_t)0;
if (fcntl(mfd, F_SETLK, &lck) == -1)
perror("[parent] fcntl(F_SETLK) UNLCK"), exit(1);
if (status)
fprintf(stderr, "[parent] transient error, going on...\n");
break;
}
}
}
int
main()
{
int successcount = 0;
int mfd;
/**/
mfd = open(FNAME, O_RDWR|O_CREAT, 0666);
if (mfd == -1)
perror("open()"), exit(1);
parent_try_lock(mfd, successcount, 0);
while (1)
{
pid_t childpid;
int status;
/**/
childpid = fork();
if (childpid == (pid_t) -1)
perror("fork()"), exit(1);
if (childpid == 0)
{
/* Child */
int fd;
struct flock lck;
char buf[BUFSIZE];
/**/
fd = open(FNAME, O_RDWR|O_CREAT, 0666);
if (fd == -1)
perror("[child] open()"), exit(1);
lck.l_type = F_WRLCK;
lck.l_whence = SEEK_SET;
lck.l_start = (off_t)0;
lck.l_len = (off_t)0;
if (fcntl(fd, F_SETLK, &lck) == -1)
perror("[child] fcntl(F_SETLK)"), exit(1);
memset(buf, 0, sizeof(buf));
while(1)
write(fd, buf, sizeof(buf));
}
usleep(rand()%1000);
kill(childpid, DEATHSIG);
if (waitpid(childpid, &status, 0) != childpid)
perror("waitpid"), exit(1);
if ( ! (WIFSIGNALED(status) && WTERMSIG(status) == DEATHSIG))
parent_try_lock(mfd, successcount, status);
++successcount;
}
}
next prev parent reply other threads:[~2003-12-09 18:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-06 4:48 [NFS client] NFS locks not released on abnormal process termination Kenny Simpson
2003-12-06 19:50 ` Philippe Troin
2003-12-08 3:39 ` Kenny Simpson
2003-12-08 5:16 ` Trond Myklebust
2003-12-08 17:32 ` Philippe Troin
2003-12-08 19:56 ` Trond Myklebust
2003-12-09 8:15 ` Philippe Troin
2003-12-09 8:42 ` Trond Myklebust
2003-12-09 18:46 ` Philippe Troin [this message]
2003-12-10 2:42 ` Kenny Simpson
2003-12-15 1:04 ` Kenny Simpson
2003-12-15 1:14 ` Trond Myklebust
2004-01-08 10:47 ` YAMAMOTO Takashi
2004-01-08 16:50 ` trond.myklebust
2004-01-09 2:56 ` [NFS] " YAMAMOTO Takashi
2004-01-09 3:40 ` trond.myklebust
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=8765gpvnfv.fsf@ceramic.fifi.org \
--to=phil@fifi.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfs@lists.sourceforge.net \
--cc=theonetruekenny@yahoo.com \
--cc=trond.myklebust@fys.uio.no \
/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;
as well as URLs for NNTP newsgroup(s).