lkml.org 
[lkml]   [2001]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectFix for an SMP locking bug in NFS code
Linus,

I've already run this by Trond so I'm sending this patch without
further ado. It adds a lock_kernel around a call into NLM code,
and removes an extraneous (really) lock_kernel in sys_fcntl64.

In more detail:

There's no lock_kernel around the F_SETLK case in fcntl, but
some of the NLM code which gets called in the NFS case needs
to be protected by locks (in particular, nlmclnt_block fiddles
with the global list nlm_blocked). We decided that, to protect
the RPC code as well, the best place to put a lock would be
around the call to nlmclnt_proc in nfs_lock.

There is, on the other hand, a lock_kernel in fcntl64, and
analysis shows that if it's not needed in fcntl - which it
shouldn't be, if the filesystems do any necessary locking -
then it's not needed in fcntl64 either (the code is essentially
identical).

Cheers,
Matt

diff -u --recursive --new-file linux-2.4.5-pre4/fs/fcntl.c linux-2.4.5-pre4-nfslockfix/fs/fcntl.c
--- linux-2.4.5-pre4/fs/fcntl.c Thu Nov 16 17:50:25 2000
+++ linux-2.4.5-pre4-nfslockfix/fs/fcntl.c Tue May 22 22:37:32 2001
@@ -338,7 +338,6 @@
if (!filp)
goto out;

- lock_kernel();
switch (cmd) {
case F_GETLK64:
err = fcntl_getlk64(fd, (struct flock64 *) arg);
@@ -353,7 +352,6 @@
err = do_fcntl(fd, cmd, arg, filp);
break;
}
- unlock_kernel();
fput(filp);
out:
return err;
diff -u --recursive --new-file linux-2.4.5-pre4/fs/nfs/file.c linux-2.4.5-pre4-nfslockfix/fs/nfs/file.c
--- linux-2.4.5-pre4/fs/nfs/file.c Tue May 22 22:32:52 2001
+++ linux-2.4.5-pre4-nfslockfix/fs/nfs/file.c Tue May 22 22:36:00 2001
@@ -299,10 +299,13 @@
if (status < 0)
return status;

- if ((status = nlmclnt_proc(inode, cmd, fl)) < 0)
+ lock_kernel();
+ status = nlmclnt_proc(inode, cmd, fl);
+ unlock_kernel();
+ if (status < 0)
return status;
- else
- status = 0;
+
+ status = 0;

/*
* Make sure we clear the cache whenever we try to get the lock.
\
 
 \ /
  Last update: 2005-03-22 12:53    [W:0.118 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site