aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/appletalk/Kconfig1
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fp.c1
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fusion.c1
-rw-r--r--drivers/staging/easycap/easycap_ioctl.c1
-rw-r--r--drivers/target/target_core_device.c1
-rw-r--r--drivers/target/target_core_fabric_lib.c1
-rw-r--r--drivers/target/target_core_file.c1
-rw-r--r--drivers/target/target_core_hba.c1
-rw-r--r--drivers/target/target_core_iblock.c1
-rw-r--r--drivers/target/target_core_pscsi.c1
-rw-r--r--drivers/target/target_core_rd.c1
-rw-r--r--drivers/target/target_core_tpg.c1
-rw-r--r--drivers/target/target_core_transport.c1
-rw-r--r--drivers/tty/n_hdlc.c1
-rw-r--r--drivers/tty/n_r3964.c1
-rw-r--r--drivers/tty/pty.c1
-rw-r--r--drivers/tty/tty_io.c1
-rw-r--r--drivers/tty/tty_ldisc.c2
-rw-r--r--drivers/tty/vt/selection.c1
-rw-r--r--drivers/tty/vt/vc_screen.c1
-rw-r--r--drivers/tty/vt/vt.c1
-rw-r--r--drivers/tty/vt/vt_ioctl.c1
-rw-r--r--fs/adfs/Kconfig1
-rw-r--r--fs/adfs/dir.c6
-rw-r--r--fs/adfs/inode.c6
-rw-r--r--fs/adfs/super.c13
-rw-r--r--fs/hpfs/Kconfig2
-rw-r--r--fs/hpfs/dir.c23
-rw-r--r--fs/hpfs/file.c9
-rw-r--r--fs/hpfs/hpfs_fn.h22
-rw-r--r--fs/hpfs/inode.c9
-rw-r--r--fs/hpfs/namei.c49
-rw-r--r--fs/hpfs/super.c23
-rw-r--r--fs/locks.c1
-rw-r--r--fs/ufs/Kconfig1
-rw-r--r--fs/ufs/inode.c78
-rw-r--r--fs/ufs/namei.c35
-rw-r--r--fs/ufs/super.c64
-rw-r--r--fs/ufs/truncate.c5
-rw-r--r--fs/ufs/ufs.h6
-rw-r--r--fs/ufs/util.c2
-rw-r--r--include/linux/hardirq.h9
-rw-r--r--include/linux/smp_lock.h65
-rw-r--r--include/trace/events/bkl.h61
-rw-r--r--init/Kconfig5
-rw-r--r--kernel/sched.c9
-rw-r--r--lib/Kconfig.debug9
-rw-r--r--lib/Makefile1
-rw-r--r--lib/kernel_lock.c143
-rw-r--r--net/appletalk/ddp.c40
-rw-r--r--net/ipx/Kconfig1
-rw-r--r--net/ipx/af_ipx.c52
-rw-r--r--net/x25/Kconfig1
-rw-r--r--net/x25/af_x25.c58
-rw-r--r--net/x25/x25_out.c7
55 files changed, 220 insertions, 619 deletions
diff --git a/drivers/net/appletalk/Kconfig b/drivers/net/appletalk/Kconfig
index 0b376a990972..f5a89164e779 100644
--- a/drivers/net/appletalk/Kconfig
+++ b/drivers/net/appletalk/Kconfig
@@ -3,7 +3,6 @@
3# 3#
4config ATALK 4config ATALK
5 tristate "Appletalk protocol support" 5 tristate "Appletalk protocol support"
6 depends on BKL # waiting to be removed from net/appletalk/ddp.c
7 select LLC 6 select LLC
8 ---help--- 7 ---help---
9 AppleTalk is the protocol that Apple computers can use to communicate 8 AppleTalk is the protocol that Apple computers can use to communicate
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 53fa96ae2b3e..8fe3a45794fc 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -39,7 +39,6 @@
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/smp_lock.h>
43#include <linux/uio.h> 42#include <linux/uio.h>
44#include <linux/uaccess.h> 43#include <linux/uaccess.h>
45#include <linux/fs.h> 44#include <linux/fs.h>
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index c1e09d5a6196..d6e2a663b165 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -38,7 +38,6 @@
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/smp_lock.h>
42#include <linux/uio.h> 41#include <linux/uio.h>
43#include <linux/uaccess.h> 42#include <linux/uaccess.h>
44#include <linux/fs.h> 43#include <linux/fs.h>
diff --git a/drivers/staging/easycap/easycap_ioctl.c b/drivers/staging/easycap/easycap_ioctl.c
index 64e7ecd4169f..28a28e02c9ce 100644
--- a/drivers/staging/easycap/easycap_ioctl.c
+++ b/drivers/staging/easycap/easycap_ioctl.c
@@ -25,7 +25,6 @@
25*/ 25*/
26/*****************************************************************************/ 26/*****************************************************************************/
27 27
28#include <linux/smp_lock.h>
29#include "easycap.h" 28#include "easycap.h"
30 29
31/*--------------------------------------------------------------------------*/ 30/*--------------------------------------------------------------------------*/
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 5da051a07fa3..350ed401544e 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -33,7 +33,6 @@
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/smp_lock.h>
37#include <linux/kthread.h> 36#include <linux/kthread.h>
38#include <linux/in.h> 37#include <linux/in.h>
39#include <net/sock.h> 38#include <net/sock.h>
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c
index 26285644e4de..a3c695adabec 100644
--- a/drivers/target/target_core_fabric_lib.c
+++ b/drivers/target/target_core_fabric_lib.c
@@ -28,7 +28,6 @@
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/ctype.h> 29#include <linux/ctype.h>
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <linux/smp_lock.h>
32#include <scsi/scsi.h> 31#include <scsi/scsi.h>
33#include <scsi/scsi_cmnd.h> 32#include <scsi/scsi_cmnd.h>
34 33
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 0aaca885668f..190ca8ac2498 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -33,7 +33,6 @@
33#include <linux/blkdev.h> 33#include <linux/blkdev.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/smp_lock.h>
37#include <scsi/scsi.h> 36#include <scsi/scsi.h>
38#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
39 38
diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c
index 4bbe8208b241..73f7d6d81b4c 100644
--- a/drivers/target/target_core_hba.c
+++ b/drivers/target/target_core_hba.c
@@ -31,7 +31,6 @@
31#include <linux/timer.h> 31#include <linux/timer.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/smp_lock.h>
35#include <linux/in.h> 34#include <linux/in.h>
36#include <net/sock.h> 35#include <net/sock.h>
37#include <net/tcp.h> 36#include <net/tcp.h>
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 67f0c09983c8..3df570db0e4f 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -35,7 +35,6 @@
35#include <linux/blkdev.h> 35#include <linux/blkdev.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/smp_lock.h>
39#include <linux/bio.h> 38#include <linux/bio.h>
40#include <linux/genhd.h> 39#include <linux/genhd.h>
41#include <linux/file.h> 40#include <linux/file.h>
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index f2a08477a68c..5a9d2ba4b609 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -34,7 +34,6 @@
34#include <linux/blk_types.h> 34#include <linux/blk_types.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/smp_lock.h>
38#include <linux/genhd.h> 37#include <linux/genhd.h>
39#include <linux/cdrom.h> 38#include <linux/cdrom.h>
40#include <linux/file.h> 39#include <linux/file.h>
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index 979aebf20019..8dc6d74c1d40 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -34,7 +34,6 @@
34#include <linux/blkdev.h> 34#include <linux/blkdev.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/smp_lock.h>
38#include <scsi/scsi.h> 37#include <scsi/scsi.h>
39#include <scsi/scsi_host.h> 38#include <scsi/scsi_host.h>
40 39
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index c26f67467623..5ec745fed931 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -31,7 +31,6 @@
31#include <linux/timer.h> 31#include <linux/timer.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/smp_lock.h>
35#include <linux/in.h> 34#include <linux/in.h>
36#include <net/sock.h> 35#include <net/sock.h>
37#include <net/tcp.h> 36#include <net/tcp.h>
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 4bbf6c147f89..ff9ace01e27a 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -34,7 +34,6 @@
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/blkdev.h> 35#include <linux/blkdev.h>
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/smp_lock.h>
38#include <linux/kthread.h> 37#include <linux/kthread.h>
39#include <linux/in.h> 38#include <linux/in.h>
40#include <linux/cdrom.h> 39#include <linux/cdrom.h>
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index 52fc0c9a6364..cea56033b34c 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -97,7 +97,6 @@
97#include <linux/slab.h> 97#include <linux/slab.h>
98#include <linux/tty.h> 98#include <linux/tty.h>
99#include <linux/errno.h> 99#include <linux/errno.h>
100#include <linux/smp_lock.h>
101#include <linux/string.h> /* used in new tty drivers */ 100#include <linux/string.h> /* used in new tty drivers */
102#include <linux/signal.h> /* used in new tty drivers */ 101#include <linux/signal.h> /* used in new tty drivers */
103#include <linux/if.h> 102#include <linux/if.h>
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
index 88dda0c45ee0..5c6c31459a2f 100644
--- a/drivers/tty/n_r3964.c
+++ b/drivers/tty/n_r3964.c
@@ -57,7 +57,6 @@
57#include <linux/ioport.h> 57#include <linux/ioport.h>
58#include <linux/in.h> 58#include <linux/in.h>
59#include <linux/slab.h> 59#include <linux/slab.h>
60#include <linux/smp_lock.h>
61#include <linux/tty.h> 60#include <linux/tty.h>
62#include <linux/errno.h> 61#include <linux/errno.h>
63#include <linux/string.h> /* used in new tty drivers */ 62#include <linux/string.h> /* used in new tty drivers */
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index c88029af84dd..210774726add 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -23,7 +23,6 @@
23#include <linux/major.h> 23#include <linux/major.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/smp_lock.h>
27#include <linux/sysctl.h> 26#include <linux/sysctl.h>
28#include <linux/device.h> 27#include <linux/device.h>
29#include <linux/uaccess.h> 28#include <linux/uaccess.h>
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 8ef2d69470ec..936a4ead6c21 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -90,7 +90,6 @@
90#include <linux/proc_fs.h> 90#include <linux/proc_fs.h>
91#include <linux/init.h> 91#include <linux/init.h>
92#include <linux/module.h> 92#include <linux/module.h>
93#include <linux/smp_lock.h>
94#include <linux/device.h> 93#include <linux/device.h>
95#include <linux/wait.h> 94#include <linux/wait.h>
96#include <linux/bitops.h> 95#include <linux/bitops.h>
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index c42f402db9ba..0fc564a97706 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -34,8 +34,6 @@
34#include <linux/vt_kern.h> 34#include <linux/vt_kern.h>
35#include <linux/selection.h> 35#include <linux/selection.h>
36 36
37#include <linux/smp_lock.h> /* For the moment */
38
39#include <linux/kmod.h> 37#include <linux/kmod.h>
40#include <linux/nsproxy.h> 38#include <linux/nsproxy.h>
41 39
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index c956ed6c83a3..adf0ad2a8851 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -26,7 +26,6 @@
26#include <linux/selection.h> 26#include <linux/selection.h>
27#include <linux/tiocl.h> 27#include <linux/tiocl.h>
28#include <linux/console.h> 28#include <linux/console.h>
29#include <linux/smp_lock.h>
30 29
31/* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */ 30/* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
32#define isspace(c) ((c) == ' ') 31#define isspace(c) ((c) == ' ')
diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index 7b3bfbe2e6de..1564261e80c8 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -33,7 +33,6 @@
33#include <linux/kbd_kern.h> 33#include <linux/kbd_kern.h>
34#include <linux/console.h> 34#include <linux/console.h>
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/smp_lock.h>
37#include <linux/sched.h> 36#include <linux/sched.h>
38#include <linux/fs.h> 37#include <linux/fs.h>
39#include <linux/poll.h> 38#include <linux/poll.h>
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 798df6f89110..c83cdfb56fcc 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -89,7 +89,6 @@
89#include <linux/mutex.h> 89#include <linux/mutex.h>
90#include <linux/vt_kern.h> 90#include <linux/vt_kern.h>
91#include <linux/selection.h> 91#include <linux/selection.h>
92#include <linux/smp_lock.h>
93#include <linux/tiocl.h> 92#include <linux/tiocl.h>
94#include <linux/kbd_kern.h> 93#include <linux/kbd_kern.h>
95#include <linux/consolemap.h> 94#include <linux/consolemap.h>
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index b64804965316..937d17219984 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -27,7 +27,6 @@
27#include <linux/console.h> 27#include <linux/console.h>
28#include <linux/consolemap.h> 28#include <linux/consolemap.h>
29#include <linux/signal.h> 29#include <linux/signal.h>
30#include <linux/smp_lock.h>
31#include <linux/timex.h> 30#include <linux/timex.h>
32 31
33#include <asm/io.h> 32#include <asm/io.h>
diff --git a/fs/adfs/Kconfig b/fs/adfs/Kconfig
index 1dd5f34b3cf2..e55182a74605 100644
--- a/fs/adfs/Kconfig
+++ b/fs/adfs/Kconfig
@@ -1,7 +1,6 @@
1config ADFS_FS 1config ADFS_FS
2 tristate "ADFS file system support (EXPERIMENTAL)" 2 tristate "ADFS file system support (EXPERIMENTAL)"
3 depends on BLOCK && EXPERIMENTAL 3 depends on BLOCK && EXPERIMENTAL
4 depends on BKL # need to fix
5 help 4 help
6 The Acorn Disc Filing System is the standard file system of the 5 The Acorn Disc Filing System is the standard file system of the
7 RiscOS operating system which runs on Acorn's ARM-based Risc PC 6 RiscOS operating system which runs on Acorn's ARM-based Risc PC
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 3b4a764ed780..3d83075aaa2e 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * Common directory handling for ADFS 10 * Common directory handling for ADFS
11 */ 11 */
12#include <linux/smp_lock.h>
13#include "adfs.h" 12#include "adfs.h"
14 13
15/* 14/*
@@ -27,8 +26,6 @@ adfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
27 struct adfs_dir dir; 26 struct adfs_dir dir;
28 int ret = 0; 27 int ret = 0;
29 28
30 lock_kernel();
31
32 if (filp->f_pos >> 32) 29 if (filp->f_pos >> 32)
33 goto out; 30 goto out;
34 31
@@ -70,7 +67,6 @@ free_out:
70 ops->free(&dir); 67 ops->free(&dir);
71 68
72out: 69out:
73 unlock_kernel();
74 return ret; 70 return ret;
75} 71}
76 72
@@ -276,7 +272,6 @@ adfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
276 struct object_info obj; 272 struct object_info obj;
277 int error; 273 int error;
278 274
279 lock_kernel();
280 error = adfs_dir_lookup_byname(dir, &dentry->d_name, &obj); 275 error = adfs_dir_lookup_byname(dir, &dentry->d_name, &obj);
281 if (error == 0) { 276 if (error == 0) {
282 error = -EACCES; 277 error = -EACCES;
@@ -288,7 +283,6 @@ adfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
288 if (inode) 283 if (inode)
289 error = 0; 284 error = 0;
290 } 285 }
291 unlock_kernel();
292 d_add(dentry, inode); 286 d_add(dentry, inode);
293 return ERR_PTR(error); 287 return ERR_PTR(error);
294} 288}
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 65794b8fe79e..09fe40198d1c 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -7,7 +7,6 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#include <linux/smp_lock.h>
11#include <linux/buffer_head.h> 10#include <linux/buffer_head.h>
12#include <linux/writeback.h> 11#include <linux/writeback.h>
13#include "adfs.h" 12#include "adfs.h"
@@ -316,8 +315,6 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
316 unsigned int ia_valid = attr->ia_valid; 315 unsigned int ia_valid = attr->ia_valid;
317 int error; 316 int error;
318 317
319 lock_kernel();
320
321 error = inode_change_ok(inode, attr); 318 error = inode_change_ok(inode, attr);
322 319
323 /* 320 /*
@@ -359,7 +356,6 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
359 if (ia_valid & (ATTR_SIZE | ATTR_MTIME | ATTR_MODE)) 356 if (ia_valid & (ATTR_SIZE | ATTR_MTIME | ATTR_MODE))
360 mark_inode_dirty(inode); 357 mark_inode_dirty(inode);
361out: 358out:
362 unlock_kernel();
363 return error; 359 return error;
364} 360}
365 361
@@ -374,7 +370,6 @@ int adfs_write_inode(struct inode *inode, struct writeback_control *wbc)
374 struct object_info obj; 370 struct object_info obj;
375 int ret; 371 int ret;
376 372
377 lock_kernel();
378 obj.file_id = inode->i_ino; 373 obj.file_id = inode->i_ino;
379 obj.name_len = 0; 374 obj.name_len = 0;
380 obj.parent_id = ADFS_I(inode)->parent_id; 375 obj.parent_id = ADFS_I(inode)->parent_id;
@@ -384,6 +379,5 @@ int adfs_write_inode(struct inode *inode, struct writeback_control *wbc)
384 obj.size = inode->i_size; 379 obj.size = inode->i_size;
385 380
386 ret = adfs_dir_update(sb, &obj, wbc->sync_mode == WB_SYNC_ALL); 381 ret = adfs_dir_update(sb, &obj, wbc->sync_mode == WB_SYNC_ALL);
387 unlock_kernel();
388 return ret; 382 return ret;
389} 383}
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 2d7954049fbe..06d7388b477b 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -14,7 +14,6 @@
14#include <linux/mount.h> 14#include <linux/mount.h>
15#include <linux/seq_file.h> 15#include <linux/seq_file.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/smp_lock.h>
18#include <linux/statfs.h> 17#include <linux/statfs.h>
19#include "adfs.h" 18#include "adfs.h"
20#include "dir_f.h" 19#include "dir_f.h"
@@ -120,15 +119,11 @@ static void adfs_put_super(struct super_block *sb)
120 int i; 119 int i;
121 struct adfs_sb_info *asb = ADFS_SB(sb); 120 struct adfs_sb_info *asb = ADFS_SB(sb);
122 121
123 lock_kernel();
124
125 for (i = 0; i < asb->s_map_size; i++) 122 for (i = 0; i < asb->s_map_size; i++)
126 brelse(asb->s_map[i].dm_bh); 123 brelse(asb->s_map[i].dm_bh);
127 kfree(asb->s_map); 124 kfree(asb->s_map);
128 kfree(asb); 125 kfree(asb);
129 sb->s_fs_info = NULL; 126 sb->s_fs_info = NULL;
130
131 unlock_kernel();
132} 127}
133 128
134static int adfs_show_options(struct seq_file *seq, struct vfsmount *mnt) 129static int adfs_show_options(struct seq_file *seq, struct vfsmount *mnt)
@@ -359,15 +354,11 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
359 struct adfs_sb_info *asb; 354 struct adfs_sb_info *asb;
360 struct inode *root; 355 struct inode *root;
361 356
362 lock_kernel();
363
364 sb->s_flags |= MS_NODIRATIME; 357 sb->s_flags |= MS_NODIRATIME;
365 358
366 asb = kzalloc(sizeof(*asb), GFP_KERNEL); 359 asb = kzalloc(sizeof(*asb), GFP_KERNEL);
367 if (!asb) { 360 if (!asb)
368 unlock_kernel();
369 return -ENOMEM; 361 return -ENOMEM;
370 }
371 sb->s_fs_info = asb; 362 sb->s_fs_info = asb;
372 363
373 /* set default options */ 364 /* set default options */
@@ -485,7 +476,6 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
485 adfs_error(sb, "get root inode failed\n"); 476 adfs_error(sb, "get root inode failed\n");
486 goto error; 477 goto error;
487 } 478 }
488 unlock_kernel();
489 return 0; 479 return 0;
490 480
491error_free_bh: 481error_free_bh:
@@ -493,7 +483,6 @@ error_free_bh:
493error: 483error:
494 sb->s_fs_info = NULL; 484 sb->s_fs_info = NULL;
495 kfree(asb); 485 kfree(asb);
496 unlock_kernel();
497 return -EINVAL; 486 return -EINVAL;
498} 487}
499 488
diff --git a/fs/hpfs/Kconfig b/fs/hpfs/Kconfig
index 63b6f5632318..0c39dc3ef7d7 100644
--- a/fs/hpfs/Kconfig
+++ b/fs/hpfs/Kconfig
@@ -1,7 +1,7 @@
1config HPFS_FS 1config HPFS_FS
2 tristate "OS/2 HPFS file system support" 2 tristate "OS/2 HPFS file system support"
3 depends on BLOCK 3 depends on BLOCK
4 depends on BKL # nontrivial to fix 4 depends on BROKEN || !PREEMPT
5 help 5 help
6 OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS 6 OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS
7 is the file system used for organizing files on OS/2 hard disk 7 is the file system used for organizing files on OS/2 hard disk
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index d32f63a569f7..b3d7c0ddb609 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -6,16 +6,15 @@
6 * directory VFS functions 6 * directory VFS functions
7 */ 7 */
8 8
9#include <linux/smp_lock.h>
10#include <linux/slab.h> 9#include <linux/slab.h>
11#include "hpfs_fn.h" 10#include "hpfs_fn.h"
12 11
13static int hpfs_dir_release(struct inode *inode, struct file *filp) 12static int hpfs_dir_release(struct inode *inode, struct file *filp)
14{ 13{
15 lock_kernel(); 14 hpfs_lock(inode->i_sb);
16 hpfs_del_pos(inode, &filp->f_pos); 15 hpfs_del_pos(inode, &filp->f_pos);
17 /*hpfs_write_if_changed(inode);*/ 16 /*hpfs_write_if_changed(inode);*/
18 unlock_kernel(); 17 hpfs_unlock(inode->i_sb);
19 return 0; 18 return 0;
20} 19}
21 20
@@ -30,7 +29,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
30 struct hpfs_inode_info *hpfs_inode = hpfs_i(i); 29 struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
31 struct super_block *s = i->i_sb; 30 struct super_block *s = i->i_sb;
32 31
33 lock_kernel(); 32 hpfs_lock(s);
34 33
35 /*printk("dir lseek\n");*/ 34 /*printk("dir lseek\n");*/
36 if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok; 35 if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok;
@@ -43,12 +42,12 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
43 } 42 }
44 mutex_unlock(&i->i_mutex); 43 mutex_unlock(&i->i_mutex);
45ok: 44ok:
46 unlock_kernel(); 45 hpfs_unlock(s);
47 return filp->f_pos = new_off; 46 return filp->f_pos = new_off;
48fail: 47fail:
49 mutex_unlock(&i->i_mutex); 48 mutex_unlock(&i->i_mutex);
50 /*printk("illegal lseek: %016llx\n", new_off);*/ 49 /*printk("illegal lseek: %016llx\n", new_off);*/
51 unlock_kernel(); 50 hpfs_unlock(s);
52 return -ESPIPE; 51 return -ESPIPE;
53} 52}
54 53
@@ -64,7 +63,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
64 int c1, c2 = 0; 63 int c1, c2 = 0;
65 int ret = 0; 64 int ret = 0;
66 65
67 lock_kernel(); 66 hpfs_lock(inode->i_sb);
68 67
69 if (hpfs_sb(inode->i_sb)->sb_chk) { 68 if (hpfs_sb(inode->i_sb)->sb_chk) {
70 if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) { 69 if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) {
@@ -167,7 +166,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
167 hpfs_brelse4(&qbh); 166 hpfs_brelse4(&qbh);
168 } 167 }
169out: 168out:
170 unlock_kernel(); 169 hpfs_unlock(inode->i_sb);
171 return ret; 170 return ret;
172} 171}
173 172
@@ -197,10 +196,10 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
197 struct inode *result = NULL; 196 struct inode *result = NULL;
198 struct hpfs_inode_info *hpfs_result; 197 struct hpfs_inode_info *hpfs_result;
199 198
200 lock_kernel(); 199 hpfs_lock(dir->i_sb);
201 if ((err = hpfs_chk_name(name, &len))) { 200 if ((err = hpfs_chk_name(name, &len))) {
202 if (err == -ENAMETOOLONG) { 201 if (err == -ENAMETOOLONG) {
203 unlock_kernel(); 202 hpfs_unlock(dir->i_sb);
204 return ERR_PTR(-ENAMETOOLONG); 203 return ERR_PTR(-ENAMETOOLONG);
205 } 204 }
206 goto end_add; 205 goto end_add;
@@ -298,7 +297,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
298 297
299 end: 298 end:
300 end_add: 299 end_add:
301 unlock_kernel(); 300 hpfs_unlock(dir->i_sb);
302 d_add(dentry, result); 301 d_add(dentry, result);
303 return NULL; 302 return NULL;
304 303
@@ -311,7 +310,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
311 310
312 /*bail:*/ 311 /*bail:*/
313 312
314 unlock_kernel(); 313 hpfs_unlock(dir->i_sb);
315 return ERR_PTR(-ENOENT); 314 return ERR_PTR(-ENOENT);
316} 315}
317 316
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index c0340887c7ea..2dbae20450f8 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -6,16 +6,15 @@
6 * file VFS functions 6 * file VFS functions
7 */ 7 */
8 8
9#include <linux/smp_lock.h>
10#include "hpfs_fn.h" 9#include "hpfs_fn.h"
11 10
12#define BLOCKS(size) (((size) + 511) >> 9) 11#define BLOCKS(size) (((size) + 511) >> 9)
13 12
14static int hpfs_file_release(struct inode *inode, struct file *file) 13static int hpfs_file_release(struct inode *inode, struct file *file)
15{ 14{
16 lock_kernel(); 15 hpfs_lock(inode->i_sb);
17 hpfs_write_if_changed(inode); 16 hpfs_write_if_changed(inode);
18 unlock_kernel(); 17 hpfs_unlock(inode->i_sb);
19 return 0; 18 return 0;
20} 19}
21 20
@@ -49,14 +48,14 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno)
49static void hpfs_truncate(struct inode *i) 48static void hpfs_truncate(struct inode *i)
50{ 49{
51 if (IS_IMMUTABLE(i)) return /*-EPERM*/; 50 if (IS_IMMUTABLE(i)) return /*-EPERM*/;
52 lock_kernel(); 51 hpfs_lock(i->i_sb);
53 hpfs_i(i)->i_n_secs = 0; 52 hpfs_i(i)->i_n_secs = 0;
54 i->i_blocks = 1 + ((i->i_size + 511) >> 9); 53 i->i_blocks = 1 + ((i->i_size + 511) >> 9);
55 hpfs_i(i)->mmu_private = i->i_size; 54 hpfs_i(i)->mmu_private = i->i_size;
56 hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9)); 55 hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9));
57 hpfs_write_inode(i); 56 hpfs_write_inode(i);
58 hpfs_i(i)->i_n_secs = 0; 57 hpfs_i(i)->i_n_secs = 0;
59 unlock_kernel(); 58 hpfs_unlock(i->i_sb);
60} 59}
61 60
62static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) 61static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create)
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 1c43dbea55e8..c15adbca07ff 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -342,3 +342,25 @@ static inline time32_t gmt_to_local(struct super_block *s, time_t t)
342 extern struct timezone sys_tz; 342 extern struct timezone sys_tz;
343 return t - sys_tz.tz_minuteswest * 60 - hpfs_sb(s)->sb_timeshift; 343 return t - sys_tz.tz_minuteswest * 60 - hpfs_sb(s)->sb_timeshift;
344} 344}
345
346/*
347 * Locking:
348 *
349 * hpfs_lock() is a leftover from the big kernel lock.
350 * Right now, these functions are empty and only left
351 * for documentation purposes. The file system no longer
352 * works on SMP systems, so the lock is not needed
353 * any more.
354 *
355 * If someone is interested in making it work again, this
356 * would be the place to start by adding a per-superblock
357 * mutex and fixing all the bugs and performance issues
358 * caused by that.
359 */
360static inline void hpfs_lock(struct super_block *s)
361{
362}
363
364static inline void hpfs_unlock(struct super_block *s)
365{
366}
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 1ae35baa539e..87f1f787e767 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -6,7 +6,6 @@
6 * inode VFS functions 6 * inode VFS functions
7 */ 7 */
8 8
9#include <linux/smp_lock.h>
10#include <linux/slab.h> 9#include <linux/slab.h>
11#include "hpfs_fn.h" 10#include "hpfs_fn.h"
12 11
@@ -267,7 +266,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
267 struct inode *inode = dentry->d_inode; 266 struct inode *inode = dentry->d_inode;
268 int error = -EINVAL; 267 int error = -EINVAL;
269 268
270 lock_kernel(); 269 hpfs_lock(inode->i_sb);
271 if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root) 270 if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
272 goto out_unlock; 271 goto out_unlock;
273 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) 272 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
@@ -290,7 +289,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
290 hpfs_write_inode(inode); 289 hpfs_write_inode(inode);
291 290
292 out_unlock: 291 out_unlock:
293 unlock_kernel(); 292 hpfs_unlock(inode->i_sb);
294 return error; 293 return error;
295} 294}
296 295
@@ -307,8 +306,8 @@ void hpfs_evict_inode(struct inode *inode)
307 truncate_inode_pages(&inode->i_data, 0); 306 truncate_inode_pages(&inode->i_data, 0);
308 end_writeback(inode); 307 end_writeback(inode);
309 if (!inode->i_nlink) { 308 if (!inode->i_nlink) {
310 lock_kernel(); 309 hpfs_lock(inode->i_sb);
311 hpfs_remove_fnode(inode->i_sb, inode->i_ino); 310 hpfs_remove_fnode(inode->i_sb, inode->i_ino);
312 unlock_kernel(); 311 hpfs_unlock(inode->i_sb);
313 } 312 }
314} 313}
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index f4ad9e31ddc4..d5f8c8a19023 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -6,7 +6,6 @@
6 * adding & removing files & directories 6 * adding & removing files & directories
7 */ 7 */
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/smp_lock.h>
10#include "hpfs_fn.h" 9#include "hpfs_fn.h"
11 10
12static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 11static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
@@ -25,7 +24,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
25 struct hpfs_dirent dee; 24 struct hpfs_dirent dee;
26 int err; 25 int err;
27 if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; 26 if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err;
28 lock_kernel(); 27 hpfs_lock(dir->i_sb);
29 err = -ENOSPC; 28 err = -ENOSPC;
30 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); 29 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
31 if (!fnode) 30 if (!fnode)
@@ -103,7 +102,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
103 } 102 }
104 d_instantiate(dentry, result); 103 d_instantiate(dentry, result);
105 mutex_unlock(&hpfs_i(dir)->i_mutex); 104 mutex_unlock(&hpfs_i(dir)->i_mutex);
106 unlock_kernel(); 105 hpfs_unlock(dir->i_sb);
107 return 0; 106 return 0;
108bail3: 107bail3:
109 mutex_unlock(&hpfs_i(dir)->i_mutex); 108 mutex_unlock(&hpfs_i(dir)->i_mutex);
@@ -115,7 +114,7 @@ bail1:
115 brelse(bh); 114 brelse(bh);
116 hpfs_free_sectors(dir->i_sb, fno, 1); 115 hpfs_free_sectors(dir->i_sb, fno, 1);
117bail: 116bail:
118 unlock_kernel(); 117 hpfs_unlock(dir->i_sb);
119 return err; 118 return err;
120} 119}
121 120
@@ -132,7 +131,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
132 int err; 131 int err;
133 if ((err = hpfs_chk_name(name, &len))) 132 if ((err = hpfs_chk_name(name, &len)))
134 return err==-ENOENT ? -EINVAL : err; 133 return err==-ENOENT ? -EINVAL : err;
135 lock_kernel(); 134 hpfs_lock(dir->i_sb);
136 err = -ENOSPC; 135 err = -ENOSPC;
137 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); 136 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
138 if (!fnode) 137 if (!fnode)
@@ -195,7 +194,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
195 } 194 }
196 d_instantiate(dentry, result); 195 d_instantiate(dentry, result);
197 mutex_unlock(&hpfs_i(dir)->i_mutex); 196 mutex_unlock(&hpfs_i(dir)->i_mutex);
198 unlock_kernel(); 197 hpfs_unlock(dir->i_sb);
199 return 0; 198 return 0;
200 199
201bail2: 200bail2:
@@ -205,7 +204,7 @@ bail1:
205 brelse(bh); 204 brelse(bh);
206 hpfs_free_sectors(dir->i_sb, fno, 1); 205 hpfs_free_sectors(dir->i_sb, fno, 1);
207bail: 206bail:
208 unlock_kernel(); 207 hpfs_unlock(dir->i_sb);
209 return err; 208 return err;
210} 209}
211 210
@@ -224,7 +223,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
224 if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM; 223 if (hpfs_sb(dir->i_sb)->sb_eas < 2) return -EPERM;
225 if (!new_valid_dev(rdev)) 224 if (!new_valid_dev(rdev))
226 return -EINVAL; 225 return -EINVAL;
227 lock_kernel(); 226 hpfs_lock(dir->i_sb);
228 err = -ENOSPC; 227 err = -ENOSPC;
229 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); 228 fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh);
230 if (!fnode) 229 if (!fnode)
@@ -274,7 +273,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
274 d_instantiate(dentry, result); 273 d_instantiate(dentry, result);
275 mutex_unlock(&hpfs_i(dir)->i_mutex); 274 mutex_unlock(&hpfs_i(dir)->i_mutex);
276 brelse(bh); 275 brelse(bh);
277 unlock_kernel(); 276 hpfs_unlock(dir->i_sb);
278 return 0; 277 return 0;
279bail2: 278bail2:
280 mutex_unlock(&hpfs_i(dir)->i_mutex); 279 mutex_unlock(&hpfs_i(dir)->i_mutex);
@@ -283,7 +282,7 @@ bail1:
283 brelse(bh); 282 brelse(bh);
284 hpfs_free_sectors(dir->i_sb, fno, 1); 283 hpfs_free_sectors(dir->i_sb, fno, 1);
285bail: 284bail:
286 unlock_kernel(); 285 hpfs_unlock(dir->i_sb);
287 return err; 286 return err;
288} 287}
289 288
@@ -299,9 +298,9 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
299 struct inode *result; 298 struct inode *result;
300 int err; 299 int err;
301 if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err; 300 if ((err = hpfs_chk_name(name, &len))) return err==-ENOENT ? -EINVAL : err;
302 lock_kernel(); 301 hpfs_lock(dir->i_sb);
303 if (hpfs_sb(dir->i_sb)->sb_eas < 2) { 302 if (hpfs_sb(dir->i_sb)->sb_eas < 2) {
304 unlock_kernel(); 303 hpfs_unlock(dir->i_sb);
305 return -EPERM; 304 return -EPERM;
306 } 305 }
307 err = -ENOSPC; 306 err = -ENOSPC;
@@ -354,7 +353,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
354 hpfs_write_inode_nolock(result); 353 hpfs_write_inode_nolock(result);
355 d_instantiate(dentry, result); 354 d_instantiate(dentry, result);
356 mutex_unlock(&hpfs_i(dir)->i_mutex); 355 mutex_unlock(&hpfs_i(dir)->i_mutex);
357 unlock_kernel(); 356 hpfs_unlock(dir->i_sb);
358 return 0; 357 return 0;
359bail2: 358bail2:
360 mutex_unlock(&hpfs_i(dir)->i_mutex); 359 mutex_unlock(&hpfs_i(dir)->i_mutex);
@@ -363,7 +362,7 @@ bail1:
363 brelse(bh); 362 brelse(bh);
364 hpfs_free_sectors(dir->i_sb, fno, 1); 363 hpfs_free_sectors(dir->i_sb, fno, 1);
365bail: 364bail:
366 unlock_kernel(); 365 hpfs_unlock(dir->i_sb);
367 return err; 366 return err;
368} 367}
369 368
@@ -380,7 +379,7 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
380 int rep = 0; 379 int rep = 0;
381 int err; 380 int err;
382 381
383 lock_kernel(); 382 hpfs_lock(dir->i_sb);
384 hpfs_adjust_length(name, &len); 383 hpfs_adjust_length(name, &len);
385again: 384again:
386 mutex_lock(&hpfs_i(inode)->i_parent_mutex); 385 mutex_lock(&hpfs_i(inode)->i_parent_mutex);
@@ -416,7 +415,7 @@ again:
416 dentry_unhash(dentry); 415 dentry_unhash(dentry);
417 if (!d_unhashed(dentry)) { 416 if (!d_unhashed(dentry)) {
418 dput(dentry); 417 dput(dentry);
419 unlock_kernel(); 418 hpfs_unlock(dir->i_sb);
420 return -ENOSPC; 419 return -ENOSPC;
421 } 420 }
422 if (generic_permission(inode, MAY_WRITE, 0, NULL) || 421 if (generic_permission(inode, MAY_WRITE, 0, NULL) ||
@@ -435,7 +434,7 @@ again:
435 if (!err) 434 if (!err)
436 goto again; 435 goto again;
437 } 436 }
438 unlock_kernel(); 437 hpfs_unlock(dir->i_sb);
439 return -ENOSPC; 438 return -ENOSPC;
440 default: 439 default:
441 drop_nlink(inode); 440 drop_nlink(inode);
@@ -448,7 +447,7 @@ out1:
448out: 447out:
449 mutex_unlock(&hpfs_i(dir)->i_mutex); 448 mutex_unlock(&hpfs_i(dir)->i_mutex);
450 mutex_unlock(&hpfs_i(inode)->i_parent_mutex); 449 mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
451 unlock_kernel(); 450 hpfs_unlock(dir->i_sb);
452 return err; 451 return err;
453} 452}
454 453
@@ -466,7 +465,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
466 int r; 465 int r;
467 466
468 hpfs_adjust_length(name, &len); 467 hpfs_adjust_length(name, &len);
469 lock_kernel(); 468 hpfs_lock(dir->i_sb);
470 mutex_lock(&hpfs_i(inode)->i_parent_mutex); 469 mutex_lock(&hpfs_i(inode)->i_parent_mutex);
471 mutex_lock(&hpfs_i(dir)->i_mutex); 470 mutex_lock(&hpfs_i(dir)->i_mutex);
472 err = -ENOENT; 471 err = -ENOENT;
@@ -508,7 +507,7 @@ out1:
508out: 507out:
509 mutex_unlock(&hpfs_i(dir)->i_mutex); 508 mutex_unlock(&hpfs_i(dir)->i_mutex);
510 mutex_unlock(&hpfs_i(inode)->i_parent_mutex); 509 mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
511 unlock_kernel(); 510 hpfs_unlock(dir->i_sb);
512 return err; 511 return err;
513} 512}
514 513
@@ -521,21 +520,21 @@ static int hpfs_symlink_readpage(struct file *file, struct page *page)
521 int err; 520 int err;
522 521
523 err = -EIO; 522 err = -EIO;
524 lock_kernel(); 523 hpfs_lock(i->i_sb);
525 if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) 524 if (!(fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh)))
526 goto fail; 525 goto fail;
527 err = hpfs_read_ea(i->i_sb, fnode, "SYMLINK", link, PAGE_SIZE); 526 err = hpfs_read_ea(i->i_sb, fnode, "SYMLINK", link, PAGE_SIZE);
528 brelse(bh); 527 brelse(bh);
529 if (err) 528 if (err)
530 goto fail; 529 goto fail;
531 unlock_kernel(); 530 hpfs_unlock(i->i_sb);
532 SetPageUptodate(page); 531 SetPageUptodate(page);
533 kunmap(page); 532 kunmap(page);
534 unlock_page(page); 533 unlock_page(page);
535 return 0; 534 return 0;
536 535
537fail: 536fail:
538 unlock_kernel(); 537 hpfs_unlock(i->i_sb);
539 SetPageError(page); 538 SetPageError(page);
540 kunmap(page); 539 kunmap(page);
541 unlock_page(page); 540 unlock_page(page);
@@ -567,7 +566,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
567 err = 0; 566 err = 0;
568 hpfs_adjust_length(old_name, &old_len); 567 hpfs_adjust_length(old_name, &old_len);
569 568
570 lock_kernel(); 569 hpfs_lock(i->i_sb);
571 /* order doesn't matter, due to VFS exclusion */ 570 /* order doesn't matter, due to VFS exclusion */
572 mutex_lock(&hpfs_i(i)->i_parent_mutex); 571 mutex_lock(&hpfs_i(i)->i_parent_mutex);
573 if (new_inode) 572 if (new_inode)
@@ -659,7 +658,7 @@ end1:
659 mutex_unlock(&hpfs_i(i)->i_parent_mutex); 658 mutex_unlock(&hpfs_i(i)->i_parent_mutex);
660 if (new_inode) 659 if (new_inode)
661 mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex); 660 mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex);
662 unlock_kernel(); 661 hpfs_unlock(i->i_sb);
663 return err; 662 return err;
664} 663}
665 664
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index b30426b1fc97..c89b40808587 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -13,7 +13,6 @@
13#include <linux/statfs.h> 13#include <linux/statfs.h>
14#include <linux/magic.h> 14#include <linux/magic.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/smp_lock.h>
17#include <linux/bitmap.h> 16#include <linux/bitmap.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
19 18
@@ -103,15 +102,11 @@ static void hpfs_put_super(struct super_block *s)
103{ 102{
104 struct hpfs_sb_info *sbi = hpfs_sb(s); 103 struct hpfs_sb_info *sbi = hpfs_sb(s);
105 104
106 lock_kernel();
107
108 kfree(sbi->sb_cp_table); 105 kfree(sbi->sb_cp_table);
109 kfree(sbi->sb_bmp_dir); 106 kfree(sbi->sb_bmp_dir);
110 unmark_dirty(s); 107 unmark_dirty(s);
111 s->s_fs_info = NULL; 108 s->s_fs_info = NULL;
112 kfree(sbi); 109 kfree(sbi);
113
114 unlock_kernel();
115} 110}
116 111
117unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno) 112unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
@@ -143,7 +138,7 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
143 struct super_block *s = dentry->d_sb; 138 struct super_block *s = dentry->d_sb;
144 struct hpfs_sb_info *sbi = hpfs_sb(s); 139 struct hpfs_sb_info *sbi = hpfs_sb(s);
145 u64 id = huge_encode_dev(s->s_bdev->bd_dev); 140 u64 id = huge_encode_dev(s->s_bdev->bd_dev);
146 lock_kernel(); 141 hpfs_lock(s);
147 142
148 /*if (sbi->sb_n_free == -1) {*/ 143 /*if (sbi->sb_n_free == -1) {*/
149 sbi->sb_n_free = count_bitmaps(s); 144 sbi->sb_n_free = count_bitmaps(s);
@@ -160,7 +155,7 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
160 buf->f_fsid.val[1] = (u32)(id >> 32); 155 buf->f_fsid.val[1] = (u32)(id >> 32);
161 buf->f_namelen = 254; 156 buf->f_namelen = 254;
162 157
163 unlock_kernel(); 158 hpfs_unlock(s);
164 159
165 return 0; 160 return 0;
166} 161}
@@ -406,7 +401,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
406 401
407 *flags |= MS_NOATIME; 402 *flags |= MS_NOATIME;
408 403
409 lock_kernel(); 404 hpfs_lock(s);
410 lock_super(s); 405 lock_super(s);
411 uid = sbi->sb_uid; gid = sbi->sb_gid; 406 uid = sbi->sb_uid; gid = sbi->sb_gid;
412 umask = 0777 & ~sbi->sb_mode; 407 umask = 0777 & ~sbi->sb_mode;
@@ -441,12 +436,12 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
441 replace_mount_options(s, new_opts); 436 replace_mount_options(s, new_opts);
442 437
443 unlock_super(s); 438 unlock_super(s);
444 unlock_kernel(); 439 hpfs_unlock(s);
445 return 0; 440 return 0;
446 441
447out_err: 442out_err:
448 unlock_super(s); 443 unlock_super(s);
449 unlock_kernel(); 444 hpfs_unlock(s);
450 kfree(new_opts); 445 kfree(new_opts);
451 return -EINVAL; 446 return -EINVAL;
452} 447}
@@ -484,13 +479,15 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
484 479
485 int o; 480 int o;
486 481
487 lock_kernel(); 482 if (num_possible_cpus() > 1) {
483 printk(KERN_ERR "HPFS is not SMP safe\n");
484 return -EINVAL;
485 }
488 486
489 save_mount_options(s, options); 487 save_mount_options(s, options);
490 488
491 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 489 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
492 if (!sbi) { 490 if (!sbi) {
493 unlock_kernel();
494 return -ENOMEM; 491 return -ENOMEM;
495 } 492 }
496 s->s_fs_info = sbi; 493 s->s_fs_info = sbi;
@@ -677,7 +674,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
677 root->i_blocks = 5; 674 root->i_blocks = 5;
678 hpfs_brelse4(&qbh); 675 hpfs_brelse4(&qbh);
679 } 676 }
680 unlock_kernel();
681 return 0; 677 return 0;
682 678
683bail4: brelse(bh2); 679bail4: brelse(bh2);
@@ -689,7 +685,6 @@ bail0:
689 kfree(sbi->sb_cp_table); 685 kfree(sbi->sb_cp_table);
690 s->s_fs_info = NULL; 686 s->s_fs_info = NULL;
691 kfree(sbi); 687 kfree(sbi);
692 unlock_kernel();
693 return -EINVAL; 688 return -EINVAL;
694} 689}
695 690
diff --git a/fs/locks.c b/fs/locks.c
index 0f3998291f78..822c3d1843af 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -145,7 +145,6 @@ static DEFINE_SPINLOCK(file_lock_lock);
145 145
146/* 146/*
147 * Protects the two list heads above, plus the inode->i_flock list 147 * Protects the two list heads above, plus the inode->i_flock list
148 * FIXME: should use a spinlock, once lockd and ceph are ready.
149 */ 148 */
150void lock_flocks(void) 149void lock_flocks(void)
151{ 150{
diff --git a/fs/ufs/Kconfig b/fs/ufs/Kconfig
index 30c8f223253d..e4f10a40768a 100644
--- a/fs/ufs/Kconfig
+++ b/fs/ufs/Kconfig
@@ -1,7 +1,6 @@
1config UFS_FS 1config UFS_FS
2 tristate "UFS file system support (read only)" 2 tristate "UFS file system support (read only)"
3 depends on BLOCK 3 depends on BLOCK
4 depends on BKL # probably fixable
5 help 4 help
6 BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD, 5 BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD,
7 OpenBSD and NeXTstep) use a file system called UFS. Some System V 6 OpenBSD and NeXTstep) use a file system called UFS. Some System V
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 2b251f2093af..03c255f12df5 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -34,7 +34,6 @@
34#include <linux/stat.h> 34#include <linux/stat.h>
35#include <linux/string.h> 35#include <linux/string.h>
36#include <linux/mm.h> 36#include <linux/mm.h>
37#include <linux/smp_lock.h>
38#include <linux/buffer_head.h> 37#include <linux/buffer_head.h>
39#include <linux/writeback.h> 38#include <linux/writeback.h>
40 39
@@ -43,7 +42,7 @@
43#include "swab.h" 42#include "swab.h"
44#include "util.h" 43#include "util.h"
45 44
46static u64 ufs_frag_map(struct inode *inode, sector_t frag); 45static u64 ufs_frag_map(struct inode *inode, sector_t frag, bool needs_lock);
47 46
48static int ufs_block_to_path(struct inode *inode, sector_t i_block, sector_t offsets[4]) 47static int ufs_block_to_path(struct inode *inode, sector_t i_block, sector_t offsets[4])
49{ 48{
@@ -82,7 +81,7 @@ static int ufs_block_to_path(struct inode *inode, sector_t i_block, sector_t off
82 * the begining of the filesystem. 81 * the begining of the filesystem.
83 */ 82 */
84 83
85static u64 ufs_frag_map(struct inode *inode, sector_t frag) 84static u64 ufs_frag_map(struct inode *inode, sector_t frag, bool needs_lock)
86{ 85{
87 struct ufs_inode_info *ufsi = UFS_I(inode); 86 struct ufs_inode_info *ufsi = UFS_I(inode);
88 struct super_block *sb = inode->i_sb; 87 struct super_block *sb = inode->i_sb;
@@ -107,7 +106,8 @@ static u64 ufs_frag_map(struct inode *inode, sector_t frag)
107 106
108 p = offsets; 107 p = offsets;
109 108
110 lock_kernel(); 109 if (needs_lock)
110 lock_ufs(sb);
111 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) 111 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2)
112 goto ufs2; 112 goto ufs2;
113 113
@@ -152,7 +152,8 @@ ufs2:
152 ret = temp + (u64) (frag & uspi->s_fpbmask); 152 ret = temp + (u64) (frag & uspi->s_fpbmask);
153 153
154out: 154out:
155 unlock_kernel(); 155 if (needs_lock)
156 unlock_ufs(sb);
156 return ret; 157 return ret;
157} 158}
158 159
@@ -415,14 +416,16 @@ out:
415int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create) 416int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create)
416{ 417{
417 struct super_block * sb = inode->i_sb; 418 struct super_block * sb = inode->i_sb;
418 struct ufs_sb_private_info * uspi = UFS_SB(sb)->s_uspi; 419 struct ufs_sb_info * sbi = UFS_SB(sb);
420 struct ufs_sb_private_info * uspi = sbi->s_uspi;
419 struct buffer_head * bh; 421 struct buffer_head * bh;
420 int ret, err, new; 422 int ret, err, new;
421 unsigned long ptr,phys; 423 unsigned long ptr,phys;
422 u64 phys64 = 0; 424 u64 phys64 = 0;
425 bool needs_lock = (sbi->mutex_owner != current);
423 426
424 if (!create) { 427 if (!create) {
425 phys64 = ufs_frag_map(inode, fragment); 428 phys64 = ufs_frag_map(inode, fragment, needs_lock);
426 UFSD("phys64 = %llu\n", (unsigned long long)phys64); 429 UFSD("phys64 = %llu\n", (unsigned long long)phys64);
427 if (phys64) 430 if (phys64)
428 map_bh(bh_result, sb, phys64); 431 map_bh(bh_result, sb, phys64);
@@ -436,7 +439,8 @@ int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head
436 ret = 0; 439 ret = 0;
437 bh = NULL; 440 bh = NULL;
438 441
439 lock_kernel(); 442 if (needs_lock)
443 lock_ufs(sb);
440 444
441 UFSD("ENTER, ino %lu, fragment %llu\n", inode->i_ino, (unsigned long long)fragment); 445 UFSD("ENTER, ino %lu, fragment %llu\n", inode->i_ino, (unsigned long long)fragment);
442 if (fragment > 446 if (fragment >
@@ -498,7 +502,9 @@ out:
498 set_buffer_new(bh_result); 502 set_buffer_new(bh_result);
499 map_bh(bh_result, sb, phys); 503 map_bh(bh_result, sb, phys);
500abort: 504abort:
501 unlock_kernel(); 505 if (needs_lock)
506 unlock_ufs(sb);
507
502 return err; 508 return err;
503 509
504abort_too_big: 510abort_too_big:
@@ -506,48 +512,6 @@ abort_too_big:
506 goto abort; 512 goto abort;
507} 513}
508 514
509static struct buffer_head *ufs_getfrag(struct inode *inode,
510 unsigned int fragment,
511 int create, int *err)
512{
513 struct buffer_head dummy;
514 int error;
515
516 dummy.b_state = 0;
517 dummy.b_blocknr = -1000;
518 error = ufs_getfrag_block(inode, fragment, &dummy, create);
519 *err = error;
520 if (!error && buffer_mapped(&dummy)) {
521 struct buffer_head *bh;
522 bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
523 if (buffer_new(&dummy)) {
524 memset(bh->b_data, 0, inode->i_sb->s_blocksize);
525 set_buffer_uptodate(bh);
526 mark_buffer_dirty(bh);
527 }
528 return bh;
529 }
530 return NULL;
531}
532
533struct buffer_head * ufs_bread (struct inode * inode, unsigned fragment,
534 int create, int * err)
535{
536 struct buffer_head * bh;
537
538 UFSD("ENTER, ino %lu, fragment %u\n", inode->i_ino, fragment);
539 bh = ufs_getfrag (inode, fragment, create, err);
540 if (!bh || buffer_uptodate(bh))
541 return bh;
542 ll_rw_block (READ, 1, &bh);
543 wait_on_buffer (bh);
544 if (buffer_uptodate(bh))
545 return bh;
546 brelse (bh);
547 *err = -EIO;
548 return NULL;
549}
550
551static int ufs_writepage(struct page *page, struct writeback_control *wbc) 515static int ufs_writepage(struct page *page, struct writeback_control *wbc)
552{ 516{
553 return block_write_full_page(page,ufs_getfrag_block,wbc); 517 return block_write_full_page(page,ufs_getfrag_block,wbc);
@@ -900,9 +864,9 @@ static int ufs_update_inode(struct inode * inode, int do_sync)
900int ufs_write_inode(struct inode *inode, struct writeback_control *wbc) 864int ufs_write_inode(struct inode *inode, struct writeback_control *wbc)
901{ 865{
902 int ret; 866 int ret;
903 lock_kernel(); 867 lock_ufs(inode->i_sb);
904 ret = ufs_update_inode(inode, wbc->sync_mode == WB_SYNC_ALL); 868 ret = ufs_update_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
905 unlock_kernel(); 869 unlock_ufs(inode->i_sb);
906 return ret; 870 return ret;
907} 871}
908 872
@@ -922,22 +886,22 @@ void ufs_evict_inode(struct inode * inode)
922 if (want_delete) { 886 if (want_delete) {
923 loff_t old_i_size; 887 loff_t old_i_size;
924 /*UFS_I(inode)->i_dtime = CURRENT_TIME;*/ 888 /*UFS_I(inode)->i_dtime = CURRENT_TIME;*/
925 lock_kernel(); 889 lock_ufs(inode->i_sb);
926 mark_inode_dirty(inode); 890 mark_inode_dirty(inode);
927 ufs_update_inode(inode, IS_SYNC(inode)); 891 ufs_update_inode(inode, IS_SYNC(inode));
928 old_i_size = inode->i_size; 892 old_i_size = inode->i_size;
929 inode->i_size = 0; 893 inode->i_size = 0;
930 if (inode->i_blocks && ufs_truncate(inode, old_i_size)) 894 if (inode->i_blocks && ufs_truncate(inode, old_i_size))
931 ufs_warning(inode->i_sb, __func__, "ufs_truncate failed\n"); 895 ufs_warning(inode->i_sb, __func__, "ufs_truncate failed\n");
932 unlock_kernel(); 896 unlock_ufs(inode->i_sb);
933 } 897 }
934 898
935 invalidate_inode_buffers(inode); 899 invalidate_inode_buffers(inode);
936 end_writeback(inode); 900 end_writeback(inode);
937 901
938 if (want_delete) { 902 if (want_delete) {
939 lock_kernel(); 903 lock_ufs(inode->i_sb);
940 ufs_free_inode (inode); 904 ufs_free_inode (inode);
941 unlock_kernel(); 905 unlock_ufs(inode->i_sb);
942 } 906 }
943} 907}
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index d6f681535eb8..29309e25417f 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -29,7 +29,6 @@
29 29
30#include <linux/time.h> 30#include <linux/time.h>
31#include <linux/fs.h> 31#include <linux/fs.h>
32#include <linux/smp_lock.h>
33 32
34#include "ufs_fs.h" 33#include "ufs_fs.h"
35#include "ufs.h" 34#include "ufs.h"
@@ -55,16 +54,16 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
55 if (dentry->d_name.len > UFS_MAXNAMLEN) 54 if (dentry->d_name.len > UFS_MAXNAMLEN)
56 return ERR_PTR(-ENAMETOOLONG); 55 return ERR_PTR(-ENAMETOOLONG);
57 56
58 lock_kernel(); 57 lock_ufs(dir->i_sb);
59 ino = ufs_inode_by_name(dir, &dentry->d_name); 58 ino = ufs_inode_by_name(dir, &dentry->d_name);
60 if (ino) { 59 if (ino) {
61 inode = ufs_iget(dir->i_sb, ino); 60 inode = ufs_iget(dir->i_sb, ino);
62 if (IS_ERR(inode)) { 61 if (IS_ERR(inode)) {
63 unlock_kernel(); 62 unlock_ufs(dir->i_sb);
64 return ERR_CAST(inode); 63 return ERR_CAST(inode);
65 } 64 }
66 } 65 }
67 unlock_kernel(); 66 unlock_ufs(dir->i_sb);
68 d_add(dentry, inode); 67 d_add(dentry, inode);
69 return NULL; 68 return NULL;
70} 69}
@@ -93,9 +92,9 @@ static int ufs_create (struct inode * dir, struct dentry * dentry, int mode,
93 inode->i_fop = &ufs_file_operations; 92 inode->i_fop = &ufs_file_operations;
94 inode->i_mapping->a_ops = &ufs_aops; 93 inode->i_mapping->a_ops = &ufs_aops;
95 mark_inode_dirty(inode); 94 mark_inode_dirty(inode);
96 lock_kernel(); 95 lock_ufs(dir->i_sb);
97 err = ufs_add_nondir(dentry, inode); 96 err = ufs_add_nondir(dentry, inode);
98 unlock_kernel(); 97 unlock_ufs(dir->i_sb);
99 } 98 }
100 UFSD("END: err=%d\n", err); 99 UFSD("END: err=%d\n", err);
101 return err; 100 return err;
@@ -115,9 +114,9 @@ static int ufs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t
115 init_special_inode(inode, mode, rdev); 114 init_special_inode(inode, mode, rdev);
116 ufs_set_inode_dev(inode->i_sb, UFS_I(inode), rdev); 115 ufs_set_inode_dev(inode->i_sb, UFS_I(inode), rdev);
117 mark_inode_dirty(inode); 116 mark_inode_dirty(inode);
118 lock_kernel(); 117 lock_ufs(dir->i_sb);
119 err = ufs_add_nondir(dentry, inode); 118 err = ufs_add_nondir(dentry, inode);
120 unlock_kernel(); 119 unlock_ufs(dir->i_sb);
121 } 120 }
122 return err; 121 return err;
123} 122}
@@ -133,7 +132,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
133 if (l > sb->s_blocksize) 132 if (l > sb->s_blocksize)
134 goto out_notlocked; 133 goto out_notlocked;
135 134
136 lock_kernel(); 135 lock_ufs(dir->i_sb);
137 inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO); 136 inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO);
138 err = PTR_ERR(inode); 137 err = PTR_ERR(inode);
139 if (IS_ERR(inode)) 138 if (IS_ERR(inode))
@@ -156,7 +155,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
156 155
157 err = ufs_add_nondir(dentry, inode); 156 err = ufs_add_nondir(dentry, inode);
158out: 157out:
159 unlock_kernel(); 158 unlock_ufs(dir->i_sb);
160out_notlocked: 159out_notlocked:
161 return err; 160 return err;
162 161
@@ -172,9 +171,9 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
172 struct inode *inode = old_dentry->d_inode; 171 struct inode *inode = old_dentry->d_inode;
173 int error; 172 int error;
174 173
175 lock_kernel(); 174 lock_ufs(dir->i_sb);
176 if (inode->i_nlink >= UFS_LINK_MAX) { 175 if (inode->i_nlink >= UFS_LINK_MAX) {
177 unlock_kernel(); 176 unlock_ufs(dir->i_sb);
178 return -EMLINK; 177 return -EMLINK;
179 } 178 }
180 179
@@ -183,7 +182,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
183 ihold(inode); 182 ihold(inode);
184 183
185 error = ufs_add_nondir(dentry, inode); 184 error = ufs_add_nondir(dentry, inode);
186 unlock_kernel(); 185 unlock_ufs(dir->i_sb);
187 return error; 186 return error;
188} 187}
189 188
@@ -195,7 +194,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
195 if (dir->i_nlink >= UFS_LINK_MAX) 194 if (dir->i_nlink >= UFS_LINK_MAX)
196 goto out; 195 goto out;
197 196
198 lock_kernel(); 197 lock_ufs(dir->i_sb);
199 inode_inc_link_count(dir); 198 inode_inc_link_count(dir);
200 199
201 inode = ufs_new_inode(dir, S_IFDIR|mode); 200 inode = ufs_new_inode(dir, S_IFDIR|mode);
@@ -216,7 +215,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
216 err = ufs_add_link(dentry, inode); 215 err = ufs_add_link(dentry, inode);
217 if (err) 216 if (err)
218 goto out_fail; 217 goto out_fail;
219 unlock_kernel(); 218 unlock_ufs(dir->i_sb);
220 219
221 d_instantiate(dentry, inode); 220 d_instantiate(dentry, inode);
222out: 221out:
@@ -228,7 +227,7 @@ out_fail:
228 iput (inode); 227 iput (inode);
229out_dir: 228out_dir:
230 inode_dec_link_count(dir); 229 inode_dec_link_count(dir);
231 unlock_kernel(); 230 unlock_ufs(dir->i_sb);
232 goto out; 231 goto out;
233} 232}
234 233
@@ -259,7 +258,7 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
259 struct inode * inode = dentry->d_inode; 258 struct inode * inode = dentry->d_inode;
260 int err= -ENOTEMPTY; 259 int err= -ENOTEMPTY;
261 260
262 lock_kernel(); 261 lock_ufs(dir->i_sb);
263 if (ufs_empty_dir (inode)) { 262 if (ufs_empty_dir (inode)) {
264 err = ufs_unlink(dir, dentry); 263 err = ufs_unlink(dir, dentry);
265 if (!err) { 264 if (!err) {
@@ -268,7 +267,7 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
268 inode_dec_link_count(dir); 267 inode_dec_link_count(dir);
269 } 268 }
270 } 269 }
271 unlock_kernel(); 270 unlock_ufs(dir->i_sb);
272 return err; 271 return err;
273} 272}
274 273
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 2c61ac5d4e48..7693d6293404 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -84,7 +84,6 @@
84#include <linux/blkdev.h> 84#include <linux/blkdev.h>
85#include <linux/init.h> 85#include <linux/init.h>
86#include <linux/parser.h> 86#include <linux/parser.h>
87#include <linux/smp_lock.h>
88#include <linux/buffer_head.h> 87#include <linux/buffer_head.h>
89#include <linux/vfs.h> 88#include <linux/vfs.h>
90#include <linux/log2.h> 89#include <linux/log2.h>
@@ -96,6 +95,26 @@
96#include "swab.h" 95#include "swab.h"
97#include "util.h" 96#include "util.h"
98 97
98void lock_ufs(struct super_block *sb)
99{
100#if defined(CONFIG_SMP) || defined (CONFIG_PREEMPT)
101 struct ufs_sb_info *sbi = UFS_SB(sb);
102
103 mutex_lock(&sbi->mutex);
104 sbi->mutex_owner = current;
105#endif
106}
107
108void unlock_ufs(struct super_block *sb)
109{
110#if defined(CONFIG_SMP) || defined (CONFIG_PREEMPT)
111 struct ufs_sb_info *sbi = UFS_SB(sb);
112
113 sbi->mutex_owner = NULL;
114 mutex_unlock(&sbi->mutex);
115#endif
116}
117
99static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation) 118static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation)
100{ 119{
101 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; 120 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
@@ -313,7 +332,6 @@ void ufs_panic (struct super_block * sb, const char * function,
313 struct ufs_super_block_first * usb1; 332 struct ufs_super_block_first * usb1;
314 va_list args; 333 va_list args;
315 334
316 lock_kernel();
317 uspi = UFS_SB(sb)->s_uspi; 335 uspi = UFS_SB(sb)->s_uspi;
318 usb1 = ubh_get_usb_first(uspi); 336 usb1 = ubh_get_usb_first(uspi);
319 337
@@ -521,7 +539,7 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
521 */ 539 */
522 size = uspi->s_cssize; 540 size = uspi->s_cssize;
523 blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; 541 blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift;
524 base = space = kmalloc(size, GFP_KERNEL); 542 base = space = kmalloc(size, GFP_NOFS);
525 if (!base) 543 if (!base)
526 goto failed; 544 goto failed;
527 sbi->s_csp = (struct ufs_csum *)space; 545 sbi->s_csp = (struct ufs_csum *)space;
@@ -546,7 +564,7 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
546 * Read cylinder group (we read only first fragment from block 564 * Read cylinder group (we read only first fragment from block
547 * at this time) and prepare internal data structures for cg caching. 565 * at this time) and prepare internal data structures for cg caching.
548 */ 566 */
549 if (!(sbi->s_ucg = kmalloc (sizeof(struct buffer_head *) * uspi->s_ncg, GFP_KERNEL))) 567 if (!(sbi->s_ucg = kmalloc (sizeof(struct buffer_head *) * uspi->s_ncg, GFP_NOFS)))
550 goto failed; 568 goto failed;
551 for (i = 0; i < uspi->s_ncg; i++) 569 for (i = 0; i < uspi->s_ncg; i++)
552 sbi->s_ucg[i] = NULL; 570 sbi->s_ucg[i] = NULL;
@@ -564,7 +582,7 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
564 ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); 582 ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data);
565 } 583 }
566 for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { 584 for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) {
567 if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_KERNEL))) 585 if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_NOFS)))
568 goto failed; 586 goto failed;
569 sbi->s_cgno[i] = UFS_CGNO_EMPTY; 587 sbi->s_cgno[i] = UFS_CGNO_EMPTY;
570 } 588 }
@@ -646,8 +664,6 @@ static void ufs_put_super_internal(struct super_block *sb)
646 664
647 UFSD("ENTER\n"); 665 UFSD("ENTER\n");
648 666
649 lock_kernel();
650
651 ufs_put_cstotal(sb); 667 ufs_put_cstotal(sb);
652 size = uspi->s_cssize; 668 size = uspi->s_cssize;
653 blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; 669 blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift;
@@ -676,8 +692,6 @@ static void ufs_put_super_internal(struct super_block *sb)
676 kfree (sbi->s_ucg); 692 kfree (sbi->s_ucg);
677 kfree (base); 693 kfree (base);
678 694
679 unlock_kernel();
680
681 UFSD("EXIT\n"); 695 UFSD("EXIT\n");
682} 696}
683 697
@@ -696,8 +710,6 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
696 unsigned maxsymlen; 710 unsigned maxsymlen;
697 int ret = -EINVAL; 711 int ret = -EINVAL;
698 712
699 lock_kernel();
700
701 uspi = NULL; 713 uspi = NULL;
702 ubh = NULL; 714 ubh = NULL;
703 flags = 0; 715 flags = 0;
@@ -718,6 +730,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
718 goto failed; 730 goto failed;
719 } 731 }
720#endif 732#endif
733 mutex_init(&sbi->mutex);
721 /* 734 /*
722 * Set default mount options 735 * Set default mount options
723 * Parse mount options 736 * Parse mount options
@@ -1165,7 +1178,6 @@ magic_found:
1165 goto failed; 1178 goto failed;
1166 1179
1167 UFSD("EXIT\n"); 1180 UFSD("EXIT\n");
1168 unlock_kernel();
1169 return 0; 1181 return 0;
1170 1182
1171dalloc_failed: 1183dalloc_failed:
@@ -1177,12 +1189,10 @@ failed:
1177 kfree(sbi); 1189 kfree(sbi);
1178 sb->s_fs_info = NULL; 1190 sb->s_fs_info = NULL;
1179 UFSD("EXIT (FAILED)\n"); 1191 UFSD("EXIT (FAILED)\n");
1180 unlock_kernel();
1181 return ret; 1192 return ret;
1182 1193
1183failed_nomem: 1194failed_nomem:
1184 UFSD("EXIT (NOMEM)\n"); 1195 UFSD("EXIT (NOMEM)\n");
1185 unlock_kernel();
1186 return -ENOMEM; 1196 return -ENOMEM;
1187} 1197}
1188 1198
@@ -1193,8 +1203,8 @@ static int ufs_sync_fs(struct super_block *sb, int wait)
1193 struct ufs_super_block_third * usb3; 1203 struct ufs_super_block_third * usb3;
1194 unsigned flags; 1204 unsigned flags;
1195 1205
1206 lock_ufs(sb);
1196 lock_super(sb); 1207 lock_super(sb);
1197 lock_kernel();
1198 1208
1199 UFSD("ENTER\n"); 1209 UFSD("ENTER\n");
1200 1210
@@ -1213,8 +1223,8 @@ static int ufs_sync_fs(struct super_block *sb, int wait)
1213 sb->s_dirt = 0; 1223 sb->s_dirt = 0;
1214 1224
1215 UFSD("EXIT\n"); 1225 UFSD("EXIT\n");
1216 unlock_kernel();
1217 unlock_super(sb); 1226 unlock_super(sb);
1227 unlock_ufs(sb);
1218 1228
1219 return 0; 1229 return 0;
1220} 1230}
@@ -1256,7 +1266,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1256 unsigned new_mount_opt, ufstype; 1266 unsigned new_mount_opt, ufstype;
1257 unsigned flags; 1267 unsigned flags;
1258 1268
1259 lock_kernel(); 1269 lock_ufs(sb);
1260 lock_super(sb); 1270 lock_super(sb);
1261 uspi = UFS_SB(sb)->s_uspi; 1271 uspi = UFS_SB(sb)->s_uspi;
1262 flags = UFS_SB(sb)->s_flags; 1272 flags = UFS_SB(sb)->s_flags;
@@ -1272,7 +1282,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1272 ufs_set_opt (new_mount_opt, ONERROR_LOCK); 1282 ufs_set_opt (new_mount_opt, ONERROR_LOCK);
1273 if (!ufs_parse_options (data, &new_mount_opt)) { 1283 if (!ufs_parse_options (data, &new_mount_opt)) {
1274 unlock_super(sb); 1284 unlock_super(sb);
1275 unlock_kernel(); 1285 unlock_ufs(sb);
1276 return -EINVAL; 1286 return -EINVAL;
1277 } 1287 }
1278 if (!(new_mount_opt & UFS_MOUNT_UFSTYPE)) { 1288 if (!(new_mount_opt & UFS_MOUNT_UFSTYPE)) {
@@ -1280,14 +1290,14 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1280 } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) { 1290 } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) {
1281 printk("ufstype can't be changed during remount\n"); 1291 printk("ufstype can't be changed during remount\n");
1282 unlock_super(sb); 1292 unlock_super(sb);
1283 unlock_kernel(); 1293 unlock_ufs(sb);
1284 return -EINVAL; 1294 return -EINVAL;
1285 } 1295 }
1286 1296
1287 if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { 1297 if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) {
1288 UFS_SB(sb)->s_mount_opt = new_mount_opt; 1298 UFS_SB(sb)->s_mount_opt = new_mount_opt;
1289 unlock_super(sb); 1299 unlock_super(sb);
1290 unlock_kernel(); 1300 unlock_ufs(sb);
1291 return 0; 1301 return 0;
1292 } 1302 }
1293 1303
@@ -1313,7 +1323,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1313 printk("ufs was compiled with read-only support, " 1323 printk("ufs was compiled with read-only support, "
1314 "can't be mounted as read-write\n"); 1324 "can't be mounted as read-write\n");
1315 unlock_super(sb); 1325 unlock_super(sb);
1316 unlock_kernel(); 1326 unlock_ufs(sb);
1317 return -EINVAL; 1327 return -EINVAL;
1318#else 1328#else
1319 if (ufstype != UFS_MOUNT_UFSTYPE_SUN && 1329 if (ufstype != UFS_MOUNT_UFSTYPE_SUN &&
@@ -1323,13 +1333,13 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1323 ufstype != UFS_MOUNT_UFSTYPE_UFS2) { 1333 ufstype != UFS_MOUNT_UFSTYPE_UFS2) {
1324 printk("this ufstype is read-only supported\n"); 1334 printk("this ufstype is read-only supported\n");
1325 unlock_super(sb); 1335 unlock_super(sb);
1326 unlock_kernel(); 1336 unlock_ufs(sb);
1327 return -EINVAL; 1337 return -EINVAL;
1328 } 1338 }
1329 if (!ufs_read_cylinder_structures(sb)) { 1339 if (!ufs_read_cylinder_structures(sb)) {
1330 printk("failed during remounting\n"); 1340 printk("failed during remounting\n");
1331 unlock_super(sb); 1341 unlock_super(sb);
1332 unlock_kernel(); 1342 unlock_ufs(sb);
1333 return -EPERM; 1343 return -EPERM;
1334 } 1344 }
1335 sb->s_flags &= ~MS_RDONLY; 1345 sb->s_flags &= ~MS_RDONLY;
@@ -1337,7 +1347,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1337 } 1347 }
1338 UFS_SB(sb)->s_mount_opt = new_mount_opt; 1348 UFS_SB(sb)->s_mount_opt = new_mount_opt;
1339 unlock_super(sb); 1349 unlock_super(sb);
1340 unlock_kernel(); 1350 unlock_ufs(sb);
1341 return 0; 1351 return 0;
1342} 1352}
1343 1353
@@ -1371,7 +1381,7 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
1371 struct ufs_super_block_third *usb3; 1381 struct ufs_super_block_third *usb3;
1372 u64 id = huge_encode_dev(sb->s_bdev->bd_dev); 1382 u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
1373 1383
1374 lock_kernel(); 1384 lock_ufs(sb);
1375 1385
1376 usb1 = ubh_get_usb_first(uspi); 1386 usb1 = ubh_get_usb_first(uspi);
1377 usb2 = ubh_get_usb_second(uspi); 1387 usb2 = ubh_get_usb_second(uspi);
@@ -1395,7 +1405,7 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
1395 buf->f_fsid.val[0] = (u32)id; 1405 buf->f_fsid.val[0] = (u32)id;
1396 buf->f_fsid.val[1] = (u32)(id >> 32); 1406 buf->f_fsid.val[1] = (u32)(id >> 32);
1397 1407
1398 unlock_kernel(); 1408 unlock_ufs(sb);
1399 1409
1400 return 0; 1410 return 0;
1401} 1411}
@@ -1405,7 +1415,7 @@ static struct kmem_cache * ufs_inode_cachep;
1405static struct inode *ufs_alloc_inode(struct super_block *sb) 1415static struct inode *ufs_alloc_inode(struct super_block *sb)
1406{ 1416{
1407 struct ufs_inode_info *ei; 1417 struct ufs_inode_info *ei;
1408 ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, GFP_KERNEL); 1418 ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, GFP_NOFS);
1409 if (!ei) 1419 if (!ei)
1410 return NULL; 1420 return NULL;
1411 ei->vfs_inode.i_version = 1; 1421 ei->vfs_inode.i_version = 1;
diff --git a/fs/ufs/truncate.c b/fs/ufs/truncate.c
index a58f9155fc9a..e56a4f567212 100644
--- a/fs/ufs/truncate.c
+++ b/fs/ufs/truncate.c
@@ -40,7 +40,6 @@
40#include <linux/time.h> 40#include <linux/time.h>
41#include <linux/stat.h> 41#include <linux/stat.h>
42#include <linux/string.h> 42#include <linux/string.h>
43#include <linux/smp_lock.h>
44#include <linux/buffer_head.h> 43#include <linux/buffer_head.h>
45#include <linux/blkdev.h> 44#include <linux/blkdev.h>
46#include <linux/sched.h> 45#include <linux/sched.h>
@@ -467,7 +466,6 @@ int ufs_truncate(struct inode *inode, loff_t old_i_size)
467 466
468 block_truncate_page(inode->i_mapping, inode->i_size, ufs_getfrag_block); 467 block_truncate_page(inode->i_mapping, inode->i_size, ufs_getfrag_block);
469 468
470 lock_kernel();
471 while (1) { 469 while (1) {
472 retry = ufs_trunc_direct(inode); 470 retry = ufs_trunc_direct(inode);
473 retry |= ufs_trunc_indirect(inode, UFS_IND_BLOCK, 471 retry |= ufs_trunc_indirect(inode, UFS_IND_BLOCK,
@@ -487,7 +485,6 @@ int ufs_truncate(struct inode *inode, loff_t old_i_size)
487 485
488 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; 486 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
489 ufsi->i_lastfrag = DIRECT_FRAGMENT; 487 ufsi->i_lastfrag = DIRECT_FRAGMENT;
490 unlock_kernel();
491 mark_inode_dirty(inode); 488 mark_inode_dirty(inode);
492out: 489out:
493 UFSD("EXIT: err %d\n", err); 490 UFSD("EXIT: err %d\n", err);
@@ -510,7 +507,9 @@ int ufs_setattr(struct dentry *dentry, struct iattr *attr)
510 /* XXX(truncate): truncate_setsize should be called last */ 507 /* XXX(truncate): truncate_setsize should be called last */
511 truncate_setsize(inode, attr->ia_size); 508 truncate_setsize(inode, attr->ia_size);
512 509
510 lock_ufs(inode->i_sb);
513 error = ufs_truncate(inode, old_i_size); 511 error = ufs_truncate(inode, old_i_size);
512 unlock_ufs(inode->i_sb);
514 if (error) 513 if (error)
515 return error; 514 return error;
516 } 515 }
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index c08782e1b48a..5be2755dd715 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -18,6 +18,8 @@ struct ufs_sb_info {
18 unsigned s_cgno[UFS_MAX_GROUP_LOADED]; 18 unsigned s_cgno[UFS_MAX_GROUP_LOADED];
19 unsigned short s_cg_loaded; 19 unsigned short s_cg_loaded;
20 unsigned s_mount_opt; 20 unsigned s_mount_opt;
21 struct mutex mutex;
22 struct task_struct *mutex_owner;
21}; 23};
22 24
23struct ufs_inode_info { 25struct ufs_inode_info {
@@ -109,7 +111,6 @@ extern struct inode *ufs_iget(struct super_block *, unsigned long);
109extern int ufs_write_inode (struct inode *, struct writeback_control *); 111extern int ufs_write_inode (struct inode *, struct writeback_control *);
110extern int ufs_sync_inode (struct inode *); 112extern int ufs_sync_inode (struct inode *);
111extern void ufs_evict_inode (struct inode *); 113extern void ufs_evict_inode (struct inode *);
112extern struct buffer_head * ufs_bread (struct inode *, unsigned, int, int *);
113extern int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create); 114extern int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create);
114 115
115/* namei.c */ 116/* namei.c */
@@ -154,4 +155,7 @@ static inline u32 ufs_dtogd(struct ufs_sb_private_info * uspi, u64 b)
154 return do_div(b, uspi->s_fpg); 155 return do_div(b, uspi->s_fpg);
155} 156}
156 157
158extern void lock_ufs(struct super_block *sb);
159extern void unlock_ufs(struct super_block *sb);
160
157#endif /* _UFS_UFS_H */ 161#endif /* _UFS_UFS_H */
diff --git a/fs/ufs/util.c b/fs/ufs/util.c
index d2c36d53fe66..95425b59ce0a 100644
--- a/fs/ufs/util.c
+++ b/fs/ufs/util.c
@@ -27,7 +27,7 @@ struct ufs_buffer_head * _ubh_bread_ (struct ufs_sb_private_info * uspi,
27 if (count > UFS_MAXFRAG) 27 if (count > UFS_MAXFRAG)
28 return NULL; 28 return NULL;
29 ubh = (struct ufs_buffer_head *) 29 ubh = (struct ufs_buffer_head *)
30 kmalloc (sizeof (struct ufs_buffer_head), GFP_KERNEL); 30 kmalloc (sizeof (struct ufs_buffer_head), GFP_NOFS);
31 if (!ubh) 31 if (!ubh)
32 return NULL; 32 return NULL;
33 ubh->fragment = fragment; 33 ubh->fragment = fragment;
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 32f9fd6619b4..ba362171e8ae 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -93,13 +93,6 @@
93 */ 93 */
94#define in_nmi() (preempt_count() & NMI_MASK) 94#define in_nmi() (preempt_count() & NMI_MASK)
95 95
96#if defined(CONFIG_PREEMPT) && defined(CONFIG_BKL)
97# include <linux/sched.h>
98# define PREEMPT_INATOMIC_BASE (current->lock_depth >= 0)
99#else
100# define PREEMPT_INATOMIC_BASE 0
101#endif
102
103#if defined(CONFIG_PREEMPT) 96#if defined(CONFIG_PREEMPT)
104# define PREEMPT_CHECK_OFFSET 1 97# define PREEMPT_CHECK_OFFSET 1
105#else 98#else
@@ -113,7 +106,7 @@
113 * used in the general case to determine whether sleeping is possible. 106 * used in the general case to determine whether sleeping is possible.
114 * Do not use in_atomic() in driver code. 107 * Do not use in_atomic() in driver code.
115 */ 108 */
116#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_INATOMIC_BASE) 109#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0)
117 110
118/* 111/*
119 * Check whether we were atomic before we did preempt_disable(): 112 * Check whether we were atomic before we did preempt_disable():
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
deleted file mode 100644
index 3a1988202731..000000000000
--- a/include/linux/smp_lock.h
+++ /dev/null
@@ -1,65 +0,0 @@
1#ifndef __LINUX_SMPLOCK_H
2#define __LINUX_SMPLOCK_H
3
4#ifdef CONFIG_LOCK_KERNEL
5#include <linux/sched.h>
6
7extern int __lockfunc __reacquire_kernel_lock(void);
8extern void __lockfunc __release_kernel_lock(void);
9
10/*
11 * Release/re-acquire global kernel lock for the scheduler
12 */
13#define release_kernel_lock(tsk) do { \
14 if (unlikely((tsk)->lock_depth >= 0)) \
15 __release_kernel_lock(); \
16} while (0)
17
18static inline int reacquire_kernel_lock(struct task_struct *task)
19{
20 if (unlikely(task->lock_depth >= 0))
21 return __reacquire_kernel_lock();
22 return 0;
23}
24
25extern void __lockfunc
26_lock_kernel(const char *func, const char *file, int line)
27__acquires(kernel_lock);
28
29extern void __lockfunc
30_unlock_kernel(const char *func, const char *file, int line)
31__releases(kernel_lock);
32
33#define lock_kernel() do { \
34 _lock_kernel(__func__, __FILE__, __LINE__); \
35} while (0)
36
37#define unlock_kernel() do { \
38 _unlock_kernel(__func__, __FILE__, __LINE__); \
39} while (0)
40
41/*
42 * Various legacy drivers don't really need the BKL in a specific
43 * function, but they *do* need to know that the BKL became available.
44 * This function just avoids wrapping a bunch of lock/unlock pairs
45 * around code which doesn't really need it.
46 */
47static inline void cycle_kernel_lock(void)
48{
49 lock_kernel();
50 unlock_kernel();
51}
52
53#else
54
55#ifdef CONFIG_BKL /* provoke build bug if not set */
56#define lock_kernel()
57#define unlock_kernel()
58#define cycle_kernel_lock() do { } while(0)
59#endif /* CONFIG_BKL */
60
61#define release_kernel_lock(task) do { } while(0)
62#define reacquire_kernel_lock(task) 0
63
64#endif /* CONFIG_LOCK_KERNEL */
65#endif /* __LINUX_SMPLOCK_H */
diff --git a/include/trace/events/bkl.h b/include/trace/events/bkl.h
deleted file mode 100644
index 1af72dc24278..000000000000
--- a/include/trace/events/bkl.h
+++ /dev/null
@@ -1,61 +0,0 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM bkl
3
4#if !defined(_TRACE_BKL_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_BKL_H
6
7#include <linux/tracepoint.h>
8
9TRACE_EVENT(lock_kernel,
10
11 TP_PROTO(const char *func, const char *file, int line),
12
13 TP_ARGS(func, file, line),
14
15 TP_STRUCT__entry(
16 __field( int, depth )
17 __field_ext( const char *, func, FILTER_PTR_STRING )
18 __field_ext( const char *, file, FILTER_PTR_STRING )
19 __field( int, line )
20 ),
21
22 TP_fast_assign(
23 /* We want to record the lock_depth after lock is acquired */
24 __entry->depth = current->lock_depth + 1;
25 __entry->func = func;
26 __entry->file = file;
27 __entry->line = line;
28 ),
29
30 TP_printk("depth=%d file:line=%s:%d func=%s()", __entry->depth,
31 __entry->file, __entry->line, __entry->func)
32);
33
34TRACE_EVENT(unlock_kernel,
35
36 TP_PROTO(const char *func, const char *file, int line),
37
38 TP_ARGS(func, file, line),
39
40 TP_STRUCT__entry(
41 __field(int, depth )
42 __field(const char *, func )
43 __field(const char *, file )
44 __field(int, line )
45 ),
46
47 TP_fast_assign(
48 __entry->depth = current->lock_depth;
49 __entry->func = func;
50 __entry->file = file;
51 __entry->line = line;
52 ),
53
54 TP_printk("depth=%d file:line=%s:%d func=%s()", __entry->depth,
55 __entry->file, __entry->line, __entry->func)
56);
57
58#endif /* _TRACE_BKL_H */
59
60/* This part must be outside protection */
61#include <trace/define_trace.h>
diff --git a/init/Kconfig b/init/Kconfig
index 6f49ceb25710..d91de16cf637 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -69,11 +69,6 @@ config BROKEN_ON_SMP
69 depends on BROKEN || !SMP 69 depends on BROKEN || !SMP
70 default y 70 default y
71 71
72config LOCK_KERNEL
73 bool
74 depends on (SMP || PREEMPT) && BKL
75 default y
76
77config INIT_ENV_ARG_LIMIT 72config INIT_ENV_ARG_LIMIT
78 int 73 int
79 default 32 if !UML 74 default 32 if !UML
diff --git a/kernel/sched.c b/kernel/sched.c
index 58d66ea7d200..a172494a9a63 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -32,7 +32,6 @@
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/uaccess.h> 33#include <linux/uaccess.h>
34#include <linux/highmem.h> 34#include <linux/highmem.h>
35#include <linux/smp_lock.h>
36#include <asm/mmu_context.h> 35#include <asm/mmu_context.h>
37#include <linux/interrupt.h> 36#include <linux/interrupt.h>
38#include <linux/capability.h> 37#include <linux/capability.h>
@@ -4086,9 +4085,6 @@ need_resched:
4086 rcu_note_context_switch(cpu); 4085 rcu_note_context_switch(cpu);
4087 prev = rq->curr; 4086 prev = rq->curr;
4088 4087
4089 release_kernel_lock(prev);
4090need_resched_nonpreemptible:
4091
4092 schedule_debug(prev); 4088 schedule_debug(prev);
4093 4089
4094 if (sched_feat(HRTICK)) 4090 if (sched_feat(HRTICK))
@@ -4148,9 +4144,6 @@ need_resched_nonpreemptible:
4148 4144
4149 post_schedule(rq); 4145 post_schedule(rq);
4150 4146
4151 if (unlikely(reacquire_kernel_lock(prev)))
4152 goto need_resched_nonpreemptible;
4153
4154 preempt_enable_no_resched(); 4147 preempt_enable_no_resched();
4155 if (need_resched()) 4148 if (need_resched())
4156 goto need_resched; 4149 goto need_resched;
@@ -8277,7 +8270,7 @@ static inline int preempt_count_equals(int preempt_offset)
8277{ 8270{
8278 int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth(); 8271 int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
8279 8272
8280 return (nested == PREEMPT_INATOMIC_BASE + preempt_offset); 8273 return (nested == preempt_offset);
8281} 8274}
8282 8275
8283void __might_sleep(const char *file, int line, int preempt_offset) 8276void __might_sleep(const char *file, int line, int preempt_offset)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2b97418c67e2..6f440d82b58d 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -470,15 +470,6 @@ config DEBUG_MUTEXES
470 This feature allows mutex semantics violations to be detected and 470 This feature allows mutex semantics violations to be detected and
471 reported. 471 reported.
472 472
473config BKL
474 bool "Big Kernel Lock" if (SMP || PREEMPT)
475 default y
476 help
477 This is the traditional lock that is used in old code instead
478 of proper locking. All drivers that use the BKL should depend
479 on this symbol.
480 Say Y here unless you are working on removing the BKL.
481
482config DEBUG_LOCK_ALLOC 473config DEBUG_LOCK_ALLOC
483 bool "Lock debugging: detect incorrect freeing of live locks" 474 bool "Lock debugging: detect incorrect freeing of live locks"
484 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 475 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
diff --git a/lib/Makefile b/lib/Makefile
index b73ba01a818a..ef7ed71a6ffd 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -43,7 +43,6 @@ obj-$(CONFIG_GENERIC_FIND_LAST_BIT) += find_last_bit.o
43CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS)) 43CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
44obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o 44obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
45 45
46obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
47obj-$(CONFIG_BTREE) += btree.o 46obj-$(CONFIG_BTREE) += btree.o
48obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o 47obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
49obj-$(CONFIG_DEBUG_LIST) += list_debug.o 48obj-$(CONFIG_DEBUG_LIST) += list_debug.o
diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c
deleted file mode 100644
index b135d04aa48a..000000000000
--- a/lib/kernel_lock.c
+++ /dev/null
@@ -1,143 +0,0 @@
1/*
2 * lib/kernel_lock.c
3 *
4 * This is the traditional BKL - big kernel lock. Largely
5 * relegated to obsolescence, but used by various less
6 * important (or lazy) subsystems.
7 */
8#include <linux/module.h>
9#include <linux/kallsyms.h>
10#include <linux/semaphore.h>
11#include <linux/smp_lock.h>
12
13#define CREATE_TRACE_POINTS
14#include <trace/events/bkl.h>
15
16/*
17 * The 'big kernel lock'
18 *
19 * This spinlock is taken and released recursively by lock_kernel()
20 * and unlock_kernel(). It is transparently dropped and reacquired
21 * over schedule(). It is used to protect legacy code that hasn't
22 * been migrated to a proper locking design yet.
23 *
24 * Don't use in new code.
25 */
26static __cacheline_aligned_in_smp DEFINE_RAW_SPINLOCK(kernel_flag);
27
28
29/*
30 * Acquire/release the underlying lock from the scheduler.
31 *
32 * This is called with preemption disabled, and should
33 * return an error value if it cannot get the lock and
34 * TIF_NEED_RESCHED gets set.
35 *
36 * If it successfully gets the lock, it should increment
37 * the preemption count like any spinlock does.
38 *
39 * (This works on UP too - do_raw_spin_trylock will never
40 * return false in that case)
41 */
42int __lockfunc __reacquire_kernel_lock(void)
43{
44 while (!do_raw_spin_trylock(&kernel_flag)) {
45 if (need_resched())
46 return -EAGAIN;
47 cpu_relax();
48 }
49 preempt_disable();
50 return 0;
51}
52
53void __lockfunc __release_kernel_lock(void)
54{
55 do_raw_spin_unlock(&kernel_flag);
56 preempt_enable_no_resched();
57}
58
59/*
60 * These are the BKL spinlocks - we try to be polite about preemption.
61 * If SMP is not on (ie UP preemption), this all goes away because the
62 * do_raw_spin_trylock() will always succeed.
63 */
64#ifdef CONFIG_PREEMPT
65static inline void __lock_kernel(void)
66{
67 preempt_disable();
68 if (unlikely(!do_raw_spin_trylock(&kernel_flag))) {
69 /*
70 * If preemption was disabled even before this
71 * was called, there's nothing we can be polite
72 * about - just spin.
73 */
74 if (preempt_count() > 1) {
75 do_raw_spin_lock(&kernel_flag);
76 return;
77 }
78
79 /*
80 * Otherwise, let's wait for the kernel lock
81 * with preemption enabled..
82 */
83 do {
84 preempt_enable();
85 while (raw_spin_is_locked(&kernel_flag))
86 cpu_relax();
87 preempt_disable();
88 } while (!do_raw_spin_trylock(&kernel_flag));
89 }
90}
91
92#else
93
94/*
95 * Non-preemption case - just get the spinlock
96 */
97static inline void __lock_kernel(void)
98{
99 do_raw_spin_lock(&kernel_flag);
100}
101#endif
102
103static inline void __unlock_kernel(void)
104{
105 /*
106 * the BKL is not covered by lockdep, so we open-code the
107 * unlocking sequence (and thus avoid the dep-chain ops):
108 */
109 do_raw_spin_unlock(&kernel_flag);
110 preempt_enable();
111}
112
113/*
114 * Getting the big kernel lock.
115 *
116 * This cannot happen asynchronously, so we only need to
117 * worry about other CPU's.
118 */
119void __lockfunc _lock_kernel(const char *func, const char *file, int line)
120{
121 int depth = current->lock_depth + 1;
122
123 trace_lock_kernel(func, file, line);
124
125 if (likely(!depth)) {
126 might_sleep();
127 __lock_kernel();
128 }
129 current->lock_depth = depth;
130}
131
132void __lockfunc _unlock_kernel(const char *func, const char *file, int line)
133{
134 BUG_ON(current->lock_depth < 0);
135 if (likely(--current->lock_depth < 0))
136 __unlock_kernel();
137
138 trace_unlock_kernel(func, file, line);
139}
140
141EXPORT_SYMBOL(_lock_kernel);
142EXPORT_SYMBOL(_unlock_kernel);
143
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index c410b93fda2e..3d4f4b043406 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -54,7 +54,6 @@
54#include <linux/capability.h> 54#include <linux/capability.h>
55#include <linux/module.h> 55#include <linux/module.h>
56#include <linux/if_arp.h> 56#include <linux/if_arp.h>
57#include <linux/smp_lock.h>
58#include <linux/termios.h> /* For TIOCOUTQ/INQ */ 57#include <linux/termios.h> /* For TIOCOUTQ/INQ */
59#include <linux/compat.h> 58#include <linux/compat.h>
60#include <linux/slab.h> 59#include <linux/slab.h>
@@ -1052,13 +1051,13 @@ static int atalk_release(struct socket *sock)
1052{ 1051{
1053 struct sock *sk = sock->sk; 1052 struct sock *sk = sock->sk;
1054 1053
1055 lock_kernel(); 1054 lock_sock(sk);
1056 if (sk) { 1055 if (sk) {
1057 sock_orphan(sk); 1056 sock_orphan(sk);
1058 sock->sk = NULL; 1057 sock->sk = NULL;
1059 atalk_destroy_socket(sk); 1058 atalk_destroy_socket(sk);
1060 } 1059 }
1061 unlock_kernel(); 1060 release_sock(sk);
1062 return 0; 1061 return 0;
1063} 1062}
1064 1063
@@ -1143,7 +1142,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1143 if (addr->sat_family != AF_APPLETALK) 1142 if (addr->sat_family != AF_APPLETALK)
1144 return -EAFNOSUPPORT; 1143 return -EAFNOSUPPORT;
1145 1144
1146 lock_kernel(); 1145 lock_sock(sk);
1147 if (addr->sat_addr.s_net == htons(ATADDR_ANYNET)) { 1146 if (addr->sat_addr.s_net == htons(ATADDR_ANYNET)) {
1148 struct atalk_addr *ap = atalk_find_primary(); 1147 struct atalk_addr *ap = atalk_find_primary();
1149 1148
@@ -1179,7 +1178,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1179 sock_reset_flag(sk, SOCK_ZAPPED); 1178 sock_reset_flag(sk, SOCK_ZAPPED);
1180 err = 0; 1179 err = 0;
1181out: 1180out:
1182 unlock_kernel(); 1181 release_sock(sk);
1183 return err; 1182 return err;
1184} 1183}
1185 1184
@@ -1215,7 +1214,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
1215#endif 1214#endif
1216 } 1215 }
1217 1216
1218 lock_kernel(); 1217 lock_sock(sk);
1219 err = -EBUSY; 1218 err = -EBUSY;
1220 if (sock_flag(sk, SOCK_ZAPPED)) 1219 if (sock_flag(sk, SOCK_ZAPPED))
1221 if (atalk_autobind(sk) < 0) 1220 if (atalk_autobind(sk) < 0)
@@ -1233,7 +1232,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
1233 sk->sk_state = TCP_ESTABLISHED; 1232 sk->sk_state = TCP_ESTABLISHED;
1234 err = 0; 1233 err = 0;
1235out: 1234out:
1236 unlock_kernel(); 1235 release_sock(sk);
1237 return err; 1236 return err;
1238} 1237}
1239 1238
@@ -1249,7 +1248,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
1249 struct atalk_sock *at = at_sk(sk); 1248 struct atalk_sock *at = at_sk(sk);
1250 int err; 1249 int err;
1251 1250
1252 lock_kernel(); 1251 lock_sock(sk);
1253 err = -ENOBUFS; 1252 err = -ENOBUFS;
1254 if (sock_flag(sk, SOCK_ZAPPED)) 1253 if (sock_flag(sk, SOCK_ZAPPED))
1255 if (atalk_autobind(sk) < 0) 1254 if (atalk_autobind(sk) < 0)
@@ -1277,17 +1276,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
1277 memcpy(uaddr, &sat, sizeof(sat)); 1276 memcpy(uaddr, &sat, sizeof(sat));
1278 1277
1279out: 1278out:
1280 unlock_kernel(); 1279 release_sock(sk);
1281 return err;
1282}
1283
1284static unsigned int atalk_poll(struct file *file, struct socket *sock,
1285 poll_table *wait)
1286{
1287 int err;
1288 lock_kernel();
1289 err = datagram_poll(file, sock, wait);
1290 unlock_kernel();
1291 return err; 1280 return err;
1292} 1281}
1293 1282
@@ -1596,7 +1585,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1596 if (len > DDP_MAXSZ) 1585 if (len > DDP_MAXSZ)
1597 return -EMSGSIZE; 1586 return -EMSGSIZE;
1598 1587
1599 lock_kernel(); 1588 lock_sock(sk);
1600 if (usat) { 1589 if (usat) {
1601 err = -EBUSY; 1590 err = -EBUSY;
1602 if (sock_flag(sk, SOCK_ZAPPED)) 1591 if (sock_flag(sk, SOCK_ZAPPED))
@@ -1651,7 +1640,9 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1651 sk, size, dev->name); 1640 sk, size, dev->name);
1652 1641
1653 size += dev->hard_header_len; 1642 size += dev->hard_header_len;
1643 release_sock(sk);
1654 skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err); 1644 skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err);
1645 lock_sock(sk);
1655 if (!skb) 1646 if (!skb)
1656 goto out; 1647 goto out;
1657 1648
@@ -1738,7 +1729,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1738 SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len); 1729 SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len);
1739 1730
1740out: 1731out:
1741 unlock_kernel(); 1732 release_sock(sk);
1742 return err ? : len; 1733 return err ? : len;
1743} 1734}
1744 1735
@@ -1753,9 +1744,10 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1753 int err = 0; 1744 int err = 0;
1754 struct sk_buff *skb; 1745 struct sk_buff *skb;
1755 1746
1756 lock_kernel();
1757 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, 1747 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1758 flags & MSG_DONTWAIT, &err); 1748 flags & MSG_DONTWAIT, &err);
1749 lock_sock(sk);
1750
1759 if (!skb) 1751 if (!skb)
1760 goto out; 1752 goto out;
1761 1753
@@ -1787,7 +1779,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1787 skb_free_datagram(sk, skb); /* Free the datagram. */ 1779 skb_free_datagram(sk, skb); /* Free the datagram. */
1788 1780
1789out: 1781out:
1790 unlock_kernel(); 1782 release_sock(sk);
1791 return err ? : copied; 1783 return err ? : copied;
1792} 1784}
1793 1785
@@ -1887,7 +1879,7 @@ static const struct proto_ops atalk_dgram_ops = {
1887 .socketpair = sock_no_socketpair, 1879 .socketpair = sock_no_socketpair,
1888 .accept = sock_no_accept, 1880 .accept = sock_no_accept,
1889 .getname = atalk_getname, 1881 .getname = atalk_getname,
1890 .poll = atalk_poll, 1882 .poll = datagram_poll,
1891 .ioctl = atalk_ioctl, 1883 .ioctl = atalk_ioctl,
1892#ifdef CONFIG_COMPAT 1884#ifdef CONFIG_COMPAT
1893 .compat_ioctl = atalk_compat_ioctl, 1885 .compat_ioctl = atalk_compat_ioctl,
diff --git a/net/ipx/Kconfig b/net/ipx/Kconfig
index 02549cb2c328..e9ad0062fbb6 100644
--- a/net/ipx/Kconfig
+++ b/net/ipx/Kconfig
@@ -3,7 +3,6 @@
3# 3#
4config IPX 4config IPX
5 tristate "The IPX protocol" 5 tristate "The IPX protocol"
6 depends on BKL # should be fixable
7 select LLC 6 select LLC
8 ---help--- 7 ---help---
9 This is support for the Novell networking protocol, IPX, commonly 8 This is support for the Novell networking protocol, IPX, commonly
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index da3d21c41d90..2731b51923d1 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -42,7 +42,6 @@
42#include <linux/uio.h> 42#include <linux/uio.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/skbuff.h> 44#include <linux/skbuff.h>
45#include <linux/smp_lock.h>
46#include <linux/socket.h> 45#include <linux/socket.h>
47#include <linux/sockios.h> 46#include <linux/sockios.h>
48#include <linux/string.h> 47#include <linux/string.h>
@@ -1299,7 +1298,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname,
1299 int opt; 1298 int opt;
1300 int rc = -EINVAL; 1299 int rc = -EINVAL;
1301 1300
1302 lock_kernel(); 1301 lock_sock(sk);
1303 if (optlen != sizeof(int)) 1302 if (optlen != sizeof(int))
1304 goto out; 1303 goto out;
1305 1304
@@ -1314,7 +1313,7 @@ static int ipx_setsockopt(struct socket *sock, int level, int optname,
1314 ipx_sk(sk)->type = opt; 1313 ipx_sk(sk)->type = opt;
1315 rc = 0; 1314 rc = 0;
1316out: 1315out:
1317 unlock_kernel(); 1316 release_sock(sk);
1318 return rc; 1317 return rc;
1319} 1318}
1320 1319
@@ -1326,7 +1325,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
1326 int len; 1325 int len;
1327 int rc = -ENOPROTOOPT; 1326 int rc = -ENOPROTOOPT;
1328 1327
1329 lock_kernel(); 1328 lock_sock(sk);
1330 if (!(level == SOL_IPX && optname == IPX_TYPE)) 1329 if (!(level == SOL_IPX && optname == IPX_TYPE))
1331 goto out; 1330 goto out;
1332 1331
@@ -1347,7 +1346,7 @@ static int ipx_getsockopt(struct socket *sock, int level, int optname,
1347 1346
1348 rc = 0; 1347 rc = 0;
1349out: 1348out:
1350 unlock_kernel(); 1349 release_sock(sk);
1351 return rc; 1350 return rc;
1352} 1351}
1353 1352
@@ -1396,7 +1395,7 @@ static int ipx_release(struct socket *sock)
1396 if (!sk) 1395 if (!sk)
1397 goto out; 1396 goto out;
1398 1397
1399 lock_kernel(); 1398 lock_sock(sk);
1400 if (!sock_flag(sk, SOCK_DEAD)) 1399 if (!sock_flag(sk, SOCK_DEAD))
1401 sk->sk_state_change(sk); 1400 sk->sk_state_change(sk);
1402 1401
@@ -1404,7 +1403,7 @@ static int ipx_release(struct socket *sock)
1404 sock->sk = NULL; 1403 sock->sk = NULL;
1405 sk_refcnt_debug_release(sk); 1404 sk_refcnt_debug_release(sk);
1406 ipx_destroy_socket(sk); 1405 ipx_destroy_socket(sk);
1407 unlock_kernel(); 1406 release_sock(sk);
1408out: 1407out:
1409 return 0; 1408 return 0;
1410} 1409}
@@ -1530,11 +1529,12 @@ out:
1530 1529
1531static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) 1530static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1532{ 1531{
1532 struct sock *sk = sock->sk;
1533 int rc; 1533 int rc;
1534 1534
1535 lock_kernel(); 1535 lock_sock(sk);
1536 rc = __ipx_bind(sock, uaddr, addr_len); 1536 rc = __ipx_bind(sock, uaddr, addr_len);
1537 unlock_kernel(); 1537 release_sock(sk);
1538 1538
1539 return rc; 1539 return rc;
1540} 1540}
@@ -1551,7 +1551,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
1551 sk->sk_state = TCP_CLOSE; 1551 sk->sk_state = TCP_CLOSE;
1552 sock->state = SS_UNCONNECTED; 1552 sock->state = SS_UNCONNECTED;
1553 1553
1554 lock_kernel(); 1554 lock_sock(sk);
1555 if (addr_len != sizeof(*addr)) 1555 if (addr_len != sizeof(*addr))
1556 goto out; 1556 goto out;
1557 addr = (struct sockaddr_ipx *)uaddr; 1557 addr = (struct sockaddr_ipx *)uaddr;
@@ -1598,7 +1598,7 @@ static int ipx_connect(struct socket *sock, struct sockaddr *uaddr,
1598 ipxrtr_put(rt); 1598 ipxrtr_put(rt);
1599 rc = 0; 1599 rc = 0;
1600out: 1600out:
1601 unlock_kernel(); 1601 release_sock(sk);
1602 return rc; 1602 return rc;
1603} 1603}
1604 1604
@@ -1614,7 +1614,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
1614 1614
1615 *uaddr_len = sizeof(struct sockaddr_ipx); 1615 *uaddr_len = sizeof(struct sockaddr_ipx);
1616 1616
1617 lock_kernel(); 1617 lock_sock(sk);
1618 if (peer) { 1618 if (peer) {
1619 rc = -ENOTCONN; 1619 rc = -ENOTCONN;
1620 if (sk->sk_state != TCP_ESTABLISHED) 1620 if (sk->sk_state != TCP_ESTABLISHED)
@@ -1649,19 +1649,7 @@ static int ipx_getname(struct socket *sock, struct sockaddr *uaddr,
1649 1649
1650 rc = 0; 1650 rc = 0;
1651out: 1651out:
1652 unlock_kernel(); 1652 release_sock(sk);
1653 return rc;
1654}
1655
1656static unsigned int ipx_datagram_poll(struct file *file, struct socket *sock,
1657 poll_table *wait)
1658{
1659 int rc;
1660
1661 lock_kernel();
1662 rc = datagram_poll(file, sock, wait);
1663 unlock_kernel();
1664
1665 return rc; 1653 return rc;
1666} 1654}
1667 1655
@@ -1736,7 +1724,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
1736 int rc = -EINVAL; 1724 int rc = -EINVAL;
1737 int flags = msg->msg_flags; 1725 int flags = msg->msg_flags;
1738 1726
1739 lock_kernel(); 1727 lock_sock(sk);
1740 /* Socket gets bound below anyway */ 1728 /* Socket gets bound below anyway */
1741/* if (sk->sk_zapped) 1729/* if (sk->sk_zapped)
1742 return -EIO; */ /* Socket not bound */ 1730 return -EIO; */ /* Socket not bound */
@@ -1788,7 +1776,7 @@ static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
1788 if (rc >= 0) 1776 if (rc >= 0)
1789 rc = len; 1777 rc = len;
1790out: 1778out:
1791 unlock_kernel(); 1779 release_sock(sk);
1792 return rc; 1780 return rc;
1793} 1781}
1794 1782
@@ -1803,7 +1791,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
1803 struct sk_buff *skb; 1791 struct sk_buff *skb;
1804 int copied, rc; 1792 int copied, rc;
1805 1793
1806 lock_kernel(); 1794 lock_sock(sk);
1807 /* put the autobinding in */ 1795 /* put the autobinding in */
1808 if (!ipxs->port) { 1796 if (!ipxs->port) {
1809 struct sockaddr_ipx uaddr; 1797 struct sockaddr_ipx uaddr;
@@ -1862,7 +1850,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
1862out_free: 1850out_free:
1863 skb_free_datagram(sk, skb); 1851 skb_free_datagram(sk, skb);
1864out: 1852out:
1865 unlock_kernel(); 1853 release_sock(sk);
1866 return rc; 1854 return rc;
1867} 1855}
1868 1856
@@ -1874,7 +1862,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1874 struct sock *sk = sock->sk; 1862 struct sock *sk = sock->sk;
1875 void __user *argp = (void __user *)arg; 1863 void __user *argp = (void __user *)arg;
1876 1864
1877 lock_kernel(); 1865 lock_sock(sk);
1878 switch (cmd) { 1866 switch (cmd) {
1879 case TIOCOUTQ: 1867 case TIOCOUTQ:
1880 amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); 1868 amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
@@ -1937,7 +1925,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1937 rc = -ENOIOCTLCMD; 1925 rc = -ENOIOCTLCMD;
1938 break; 1926 break;
1939 } 1927 }
1940 unlock_kernel(); 1928 release_sock(sk);
1941 1929
1942 return rc; 1930 return rc;
1943} 1931}
@@ -1984,7 +1972,7 @@ static const struct proto_ops ipx_dgram_ops = {
1984 .socketpair = sock_no_socketpair, 1972 .socketpair = sock_no_socketpair,
1985 .accept = sock_no_accept, 1973 .accept = sock_no_accept,
1986 .getname = ipx_getname, 1974 .getname = ipx_getname,
1987 .poll = ipx_datagram_poll, 1975 .poll = datagram_poll,
1988 .ioctl = ipx_ioctl, 1976 .ioctl = ipx_ioctl,
1989#ifdef CONFIG_COMPAT 1977#ifdef CONFIG_COMPAT
1990 .compat_ioctl = ipx_compat_ioctl, 1978 .compat_ioctl = ipx_compat_ioctl,
diff --git a/net/x25/Kconfig b/net/x25/Kconfig
index 2196e55e4f61..e6759c9660bb 100644
--- a/net/x25/Kconfig
+++ b/net/x25/Kconfig
@@ -5,7 +5,6 @@
5config X25 5config X25
6 tristate "CCITT X.25 Packet Layer (EXPERIMENTAL)" 6 tristate "CCITT X.25 Packet Layer (EXPERIMENTAL)"
7 depends on EXPERIMENTAL 7 depends on EXPERIMENTAL
8 depends on BKL # should be fixable
9 ---help--- 8 ---help---
10 X.25 is a set of standardized network protocols, similar in scope to 9 X.25 is a set of standardized network protocols, similar in scope to
11 frame relay; the one physical line from your box to the X.25 network 10 frame relay; the one physical line from your box to the X.25 network
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index ad96ee90fe27..4680b1e4c79c 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -40,7 +40,6 @@
40#include <linux/errno.h> 40#include <linux/errno.h>
41#include <linux/kernel.h> 41#include <linux/kernel.h>
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/smp_lock.h>
44#include <linux/timer.h> 43#include <linux/timer.h>
45#include <linux/string.h> 44#include <linux/string.h>
46#include <linux/net.h> 45#include <linux/net.h>
@@ -432,15 +431,6 @@ void x25_destroy_socket_from_timer(struct sock *sk)
432 sock_put(sk); 431 sock_put(sk);
433} 432}
434 433
435static void x25_destroy_socket(struct sock *sk)
436{
437 sock_hold(sk);
438 lock_sock(sk);
439 __x25_destroy_socket(sk);
440 release_sock(sk);
441 sock_put(sk);
442}
443
444/* 434/*
445 * Handling for system calls applied via the various interfaces to a 435 * Handling for system calls applied via the various interfaces to a
446 * X.25 socket object. 436 * X.25 socket object.
@@ -647,18 +637,19 @@ static int x25_release(struct socket *sock)
647 struct sock *sk = sock->sk; 637 struct sock *sk = sock->sk;
648 struct x25_sock *x25; 638 struct x25_sock *x25;
649 639
650 lock_kernel();
651 if (!sk) 640 if (!sk)
652 goto out; 641 return 0;
653 642
654 x25 = x25_sk(sk); 643 x25 = x25_sk(sk);
655 644
645 sock_hold(sk);
646 lock_sock(sk);
656 switch (x25->state) { 647 switch (x25->state) {
657 648
658 case X25_STATE_0: 649 case X25_STATE_0:
659 case X25_STATE_2: 650 case X25_STATE_2:
660 x25_disconnect(sk, 0, 0, 0); 651 x25_disconnect(sk, 0, 0, 0);
661 x25_destroy_socket(sk); 652 __x25_destroy_socket(sk);
662 goto out; 653 goto out;
663 654
664 case X25_STATE_1: 655 case X25_STATE_1:
@@ -678,7 +669,8 @@ static int x25_release(struct socket *sock)
678 669
679 sock_orphan(sk); 670 sock_orphan(sk);
680out: 671out:
681 unlock_kernel(); 672 release_sock(sk);
673 sock_put(sk);
682 return 0; 674 return 0;
683} 675}
684 676
@@ -1085,7 +1077,7 @@ static int x25_sendmsg(struct kiocb *iocb, struct socket *sock,
1085 size_t size; 1077 size_t size;
1086 int qbit = 0, rc = -EINVAL; 1078 int qbit = 0, rc = -EINVAL;
1087 1079
1088 lock_kernel(); 1080 lock_sock(sk);
1089 if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_OOB|MSG_EOR|MSG_CMSG_COMPAT)) 1081 if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_OOB|MSG_EOR|MSG_CMSG_COMPAT))
1090 goto out; 1082 goto out;
1091 1083
@@ -1148,7 +1140,9 @@ static int x25_sendmsg(struct kiocb *iocb, struct socket *sock,
1148 1140
1149 size = len + X25_MAX_L2_LEN + X25_EXT_MIN_LEN; 1141 size = len + X25_MAX_L2_LEN + X25_EXT_MIN_LEN;
1150 1142
1143 release_sock(sk);
1151 skb = sock_alloc_send_skb(sk, size, noblock, &rc); 1144 skb = sock_alloc_send_skb(sk, size, noblock, &rc);
1145 lock_sock(sk);
1152 if (!skb) 1146 if (!skb)
1153 goto out; 1147 goto out;
1154 X25_SKB_CB(skb)->flags = msg->msg_flags; 1148 X25_SKB_CB(skb)->flags = msg->msg_flags;
@@ -1231,26 +1225,10 @@ static int x25_sendmsg(struct kiocb *iocb, struct socket *sock,
1231 len++; 1225 len++;
1232 } 1226 }
1233 1227
1234 /*
1235 * lock_sock() is currently only used to serialize this x25_kick()
1236 * against input-driven x25_kick() calls. It currently only blocks
1237 * incoming packets for this socket and does not protect against
1238 * any other socket state changes and is not called from anywhere
1239 * else. As x25_kick() cannot block and as long as all socket
1240 * operations are BKL-wrapped, we don't need take to care about
1241 * purging the backlog queue in x25_release().
1242 *
1243 * Using lock_sock() to protect all socket operations entirely
1244 * (and making the whole x25 stack SMP aware) unfortunately would
1245 * require major changes to {send,recv}msg and skb allocation methods.
1246 * -> 2.5 ;)
1247 */
1248 lock_sock(sk);
1249 x25_kick(sk); 1228 x25_kick(sk);
1250 release_sock(sk);
1251 rc = len; 1229 rc = len;
1252out: 1230out:
1253 unlock_kernel(); 1231 release_sock(sk);
1254 return rc; 1232 return rc;
1255out_kfree_skb: 1233out_kfree_skb:
1256 kfree_skb(skb); 1234 kfree_skb(skb);
@@ -1271,7 +1249,7 @@ static int x25_recvmsg(struct kiocb *iocb, struct socket *sock,
1271 unsigned char *asmptr; 1249 unsigned char *asmptr;
1272 int rc = -ENOTCONN; 1250 int rc = -ENOTCONN;
1273 1251
1274 lock_kernel(); 1252 lock_sock(sk);
1275 /* 1253 /*
1276 * This works for seqpacket too. The receiver has ordered the queue for 1254 * This works for seqpacket too. The receiver has ordered the queue for
1277 * us! We do one quick check first though 1255 * us! We do one quick check first though
@@ -1300,8 +1278,10 @@ static int x25_recvmsg(struct kiocb *iocb, struct socket *sock,
1300 msg->msg_flags |= MSG_OOB; 1278 msg->msg_flags |= MSG_OOB;
1301 } else { 1279 } else {
1302 /* Now we can treat all alike */ 1280 /* Now we can treat all alike */
1281 release_sock(sk);
1303 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, 1282 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1304 flags & MSG_DONTWAIT, &rc); 1283 flags & MSG_DONTWAIT, &rc);
1284 lock_sock(sk);
1305 if (!skb) 1285 if (!skb)
1306 goto out; 1286 goto out;
1307 1287
@@ -1338,14 +1318,12 @@ static int x25_recvmsg(struct kiocb *iocb, struct socket *sock,
1338 1318
1339 msg->msg_namelen = sizeof(struct sockaddr_x25); 1319 msg->msg_namelen = sizeof(struct sockaddr_x25);
1340 1320
1341 lock_sock(sk);
1342 x25_check_rbuf(sk); 1321 x25_check_rbuf(sk);
1343 release_sock(sk);
1344 rc = copied; 1322 rc = copied;
1345out_free_dgram: 1323out_free_dgram:
1346 skb_free_datagram(sk, skb); 1324 skb_free_datagram(sk, skb);
1347out: 1325out:
1348 unlock_kernel(); 1326 release_sock(sk);
1349 return rc; 1327 return rc;
1350} 1328}
1351 1329
@@ -1581,18 +1559,18 @@ out_cud_release:
1581 1559
1582 case SIOCX25CALLACCPTAPPRV: { 1560 case SIOCX25CALLACCPTAPPRV: {
1583 rc = -EINVAL; 1561 rc = -EINVAL;
1584 lock_kernel(); 1562 lock_sock(sk);
1585 if (sk->sk_state != TCP_CLOSE) 1563 if (sk->sk_state != TCP_CLOSE)
1586 break; 1564 break;
1587 clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags); 1565 clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags);
1588 unlock_kernel(); 1566 release_sock(sk);
1589 rc = 0; 1567 rc = 0;
1590 break; 1568 break;
1591 } 1569 }
1592 1570
1593 case SIOCX25SENDCALLACCPT: { 1571 case SIOCX25SENDCALLACCPT: {
1594 rc = -EINVAL; 1572 rc = -EINVAL;
1595 lock_kernel(); 1573 lock_sock(sk);
1596 if (sk->sk_state != TCP_ESTABLISHED) 1574 if (sk->sk_state != TCP_ESTABLISHED)
1597 break; 1575 break;
1598 /* must call accptapprv above */ 1576 /* must call accptapprv above */
@@ -1600,7 +1578,7 @@ out_cud_release:
1600 break; 1578 break;
1601 x25_write_internal(sk, X25_CALL_ACCEPTED); 1579 x25_write_internal(sk, X25_CALL_ACCEPTED);
1602 x25->state = X25_STATE_3; 1580 x25->state = X25_STATE_3;
1603 unlock_kernel(); 1581 release_sock(sk);
1604 rc = 0; 1582 rc = 0;
1605 break; 1583 break;
1606 } 1584 }
diff --git a/net/x25/x25_out.c b/net/x25/x25_out.c
index d00649fb251d..0144271d2184 100644
--- a/net/x25/x25_out.c
+++ b/net/x25/x25_out.c
@@ -68,8 +68,11 @@ int x25_output(struct sock *sk, struct sk_buff *skb)
68 frontlen = skb_headroom(skb); 68 frontlen = skb_headroom(skb);
69 69
70 while (skb->len > 0) { 70 while (skb->len > 0) {
71 if ((skbn = sock_alloc_send_skb(sk, frontlen + max_len, 71 release_sock(sk);
72 noblock, &err)) == NULL){ 72 skbn = sock_alloc_send_skb(sk, frontlen + max_len,
73 noblock, &err);
74 lock_sock(sk);
75 if (!skbn) {
73 if (err == -EWOULDBLOCK && noblock){ 76 if (err == -EWOULDBLOCK && noblock){
74 kfree_skb(skb); 77 kfree_skb(skb);
75 return sent; 78 return sent;