diff options
Diffstat (limited to 'fs')
54 files changed, 678 insertions, 673 deletions
diff --git a/fs/adfs/super.c b/fs/adfs/super.c index 4a3af7075c1d..d9803f73236f 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c | |||
@@ -352,11 +352,15 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) | |||
352 | struct adfs_sb_info *asb; | 352 | struct adfs_sb_info *asb; |
353 | struct inode *root; | 353 | struct inode *root; |
354 | 354 | ||
355 | lock_kernel(); | ||
356 | |||
355 | sb->s_flags |= MS_NODIRATIME; | 357 | sb->s_flags |= MS_NODIRATIME; |
356 | 358 | ||
357 | asb = kzalloc(sizeof(*asb), GFP_KERNEL); | 359 | asb = kzalloc(sizeof(*asb), GFP_KERNEL); |
358 | if (!asb) | 360 | if (!asb) { |
361 | unlock_kernel(); | ||
359 | return -ENOMEM; | 362 | return -ENOMEM; |
363 | } | ||
360 | sb->s_fs_info = asb; | 364 | sb->s_fs_info = asb; |
361 | 365 | ||
362 | /* set default options */ | 366 | /* set default options */ |
@@ -474,6 +478,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) | |||
474 | goto error; | 478 | goto error; |
475 | } else | 479 | } else |
476 | sb->s_root->d_op = &adfs_dentry_operations; | 480 | sb->s_root->d_op = &adfs_dentry_operations; |
481 | unlock_kernel(); | ||
477 | return 0; | 482 | return 0; |
478 | 483 | ||
479 | error_free_bh: | 484 | error_free_bh: |
@@ -481,6 +486,7 @@ error_free_bh: | |||
481 | error: | 486 | error: |
482 | sb->s_fs_info = NULL; | 487 | sb->s_fs_info = NULL; |
483 | kfree(asb); | 488 | kfree(asb); |
489 | unlock_kernel(); | ||
484 | return -EINVAL; | 490 | return -EINVAL; |
485 | } | 491 | } |
486 | 492 | ||
diff --git a/fs/affs/super.c b/fs/affs/super.c index 9581ea94d5a1..fa4fbe1e238a 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/parser.h> | 16 | #include <linux/parser.h> |
17 | #include <linux/magic.h> | 17 | #include <linux/magic.h> |
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/smp_lock.h> | ||
20 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
21 | #include "affs.h" | 20 | #include "affs.h" |
22 | 21 | ||
@@ -46,8 +45,6 @@ affs_put_super(struct super_block *sb) | |||
46 | struct affs_sb_info *sbi = AFFS_SB(sb); | 45 | struct affs_sb_info *sbi = AFFS_SB(sb); |
47 | pr_debug("AFFS: put_super()\n"); | 46 | pr_debug("AFFS: put_super()\n"); |
48 | 47 | ||
49 | lock_kernel(); | ||
50 | |||
51 | if (!(sb->s_flags & MS_RDONLY) && sb->s_dirt) | 48 | if (!(sb->s_flags & MS_RDONLY) && sb->s_dirt) |
52 | affs_commit_super(sb, 1, 1); | 49 | affs_commit_super(sb, 1, 1); |
53 | 50 | ||
@@ -56,8 +53,6 @@ affs_put_super(struct super_block *sb) | |||
56 | affs_brelse(sbi->s_root_bh); | 53 | affs_brelse(sbi->s_root_bh); |
57 | kfree(sbi); | 54 | kfree(sbi); |
58 | sb->s_fs_info = NULL; | 55 | sb->s_fs_info = NULL; |
59 | |||
60 | unlock_kernel(); | ||
61 | } | 56 | } |
62 | 57 | ||
63 | static void | 58 | static void |
@@ -302,6 +297,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) | |||
302 | sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); | 297 | sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); |
303 | if (!sbi) | 298 | if (!sbi) |
304 | return -ENOMEM; | 299 | return -ENOMEM; |
300 | |||
305 | sb->s_fs_info = sbi; | 301 | sb->s_fs_info = sbi; |
306 | mutex_init(&sbi->s_bmlock); | 302 | mutex_init(&sbi->s_bmlock); |
307 | spin_lock_init(&sbi->symlink_lock); | 303 | spin_lock_init(&sbi->symlink_lock); |
@@ -527,7 +523,7 @@ affs_remount(struct super_block *sb, int *flags, char *data) | |||
527 | kfree(new_opts); | 523 | kfree(new_opts); |
528 | return -EINVAL; | 524 | return -EINVAL; |
529 | } | 525 | } |
530 | lock_kernel(); | 526 | |
531 | replace_mount_options(sb, new_opts); | 527 | replace_mount_options(sb, new_opts); |
532 | 528 | ||
533 | sbi->s_flags = mount_flags; | 529 | sbi->s_flags = mount_flags; |
@@ -543,17 +539,15 @@ affs_remount(struct super_block *sb, int *flags, char *data) | |||
543 | memcpy(sbi->s_volume, volume, 32); | 539 | memcpy(sbi->s_volume, volume, 32); |
544 | spin_unlock(&sbi->symlink_lock); | 540 | spin_unlock(&sbi->symlink_lock); |
545 | 541 | ||
546 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { | 542 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) |
547 | unlock_kernel(); | ||
548 | return 0; | 543 | return 0; |
549 | } | 544 | |
550 | if (*flags & MS_RDONLY) { | 545 | if (*flags & MS_RDONLY) { |
551 | affs_write_super(sb); | 546 | affs_write_super(sb); |
552 | affs_free_bitmap(sb); | 547 | affs_free_bitmap(sb); |
553 | } else | 548 | } else |
554 | res = affs_init_bitmap(sb, flags); | 549 | res = affs_init_bitmap(sb, flags); |
555 | 550 | ||
556 | unlock_kernel(); | ||
557 | return res; | 551 | return res; |
558 | } | 552 | } |
559 | 553 | ||
diff --git a/fs/afs/flock.c b/fs/afs/flock.c index 0931bc1325eb..757d664575dd 100644 --- a/fs/afs/flock.c +++ b/fs/afs/flock.c | |||
@@ -9,7 +9,6 @@ | |||
9 | * 2 of the License, or (at your option) any later version. | 9 | * 2 of the License, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/smp_lock.h> | ||
13 | #include "internal.h" | 12 | #include "internal.h" |
14 | 13 | ||
15 | #define AFS_LOCK_GRANTED 0 | 14 | #define AFS_LOCK_GRANTED 0 |
@@ -274,7 +273,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl) | |||
274 | 273 | ||
275 | type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; | 274 | type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; |
276 | 275 | ||
277 | lock_kernel(); | 276 | lock_flocks(); |
278 | 277 | ||
279 | /* make sure we've got a callback on this file and that our view of the | 278 | /* make sure we've got a callback on this file and that our view of the |
280 | * data version is up to date */ | 279 | * data version is up to date */ |
@@ -421,7 +420,7 @@ given_lock: | |||
421 | afs_vnode_fetch_status(vnode, NULL, key); | 420 | afs_vnode_fetch_status(vnode, NULL, key); |
422 | 421 | ||
423 | error: | 422 | error: |
424 | unlock_kernel(); | 423 | unlock_flocks(); |
425 | _leave(" = %d", ret); | 424 | _leave(" = %d", ret); |
426 | return ret; | 425 | return ret; |
427 | 426 | ||
diff --git a/fs/afs/super.c b/fs/afs/super.c index 77e1e5a61154..eacf76d98ae0 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/mount.h> | 19 | #include <linux/mount.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/smp_lock.h> | ||
23 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
24 | #include <linux/pagemap.h> | 23 | #include <linux/pagemap.h> |
25 | #include <linux/parser.h> | 24 | #include <linux/parser.h> |
@@ -453,12 +452,8 @@ static void afs_put_super(struct super_block *sb) | |||
453 | 452 | ||
454 | _enter(""); | 453 | _enter(""); |
455 | 454 | ||
456 | lock_kernel(); | ||
457 | |||
458 | afs_put_volume(as->volume); | 455 | afs_put_volume(as->volume); |
459 | 456 | ||
460 | unlock_kernel(); | ||
461 | |||
462 | _leave(""); | 457 | _leave(""); |
463 | } | 458 | } |
464 | 459 | ||
diff --git a/fs/autofs/root.c b/fs/autofs/root.c index 11b1ea786d00..0c4ca81aeaeb 100644 --- a/fs/autofs/root.c +++ b/fs/autofs/root.c | |||
@@ -27,7 +27,9 @@ static int autofs_root_unlink(struct inode *,struct dentry *); | |||
27 | static int autofs_root_rmdir(struct inode *,struct dentry *); | 27 | static int autofs_root_rmdir(struct inode *,struct dentry *); |
28 | static int autofs_root_mkdir(struct inode *,struct dentry *,int); | 28 | static int autofs_root_mkdir(struct inode *,struct dentry *,int); |
29 | static long autofs_root_ioctl(struct file *,unsigned int,unsigned long); | 29 | static long autofs_root_ioctl(struct file *,unsigned int,unsigned long); |
30 | #ifdef CONFIG_COMPAT | ||
30 | static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long); | 31 | static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long); |
32 | #endif | ||
31 | 33 | ||
32 | const struct file_operations autofs_root_operations = { | 34 | const struct file_operations autofs_root_operations = { |
33 | .llseek = generic_file_llseek, | 35 | .llseek = generic_file_llseek, |
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index cb1bd38dc08c..d5c1401f0031 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/param.h> | 19 | #include <linux/param.h> |
20 | #include <linux/time.h> | 20 | #include <linux/time.h> |
21 | #include <linux/compat.h> | 21 | #include <linux/compat.h> |
22 | #include <linux/smp_lock.h> | 22 | #include <linux/mutex.h> |
23 | 23 | ||
24 | #include "autofs_i.h" | 24 | #include "autofs_i.h" |
25 | 25 | ||
@@ -28,7 +28,9 @@ static int autofs4_dir_unlink(struct inode *,struct dentry *); | |||
28 | static int autofs4_dir_rmdir(struct inode *,struct dentry *); | 28 | static int autofs4_dir_rmdir(struct inode *,struct dentry *); |
29 | static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); | 29 | static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); |
30 | static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); | 30 | static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); |
31 | #ifdef CONFIG_COMPAT | ||
31 | static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long); | 32 | static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long); |
33 | #endif | ||
32 | static int autofs4_dir_open(struct inode *inode, struct file *file); | 34 | static int autofs4_dir_open(struct inode *inode, struct file *file); |
33 | static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); | 35 | static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); |
34 | static void *autofs4_follow_link(struct dentry *, struct nameidata *); | 36 | static void *autofs4_follow_link(struct dentry *, struct nameidata *); |
@@ -978,15 +980,17 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp, | |||
978 | } | 980 | } |
979 | } | 981 | } |
980 | 982 | ||
983 | static DEFINE_MUTEX(autofs4_ioctl_mutex); | ||
984 | |||
981 | static long autofs4_root_ioctl(struct file *filp, | 985 | static long autofs4_root_ioctl(struct file *filp, |
982 | unsigned int cmd, unsigned long arg) | 986 | unsigned int cmd, unsigned long arg) |
983 | { | 987 | { |
984 | long ret; | 988 | long ret; |
985 | struct inode *inode = filp->f_dentry->d_inode; | 989 | struct inode *inode = filp->f_dentry->d_inode; |
986 | 990 | ||
987 | lock_kernel(); | 991 | mutex_lock(&autofs4_ioctl_mutex); |
988 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); | 992 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); |
989 | unlock_kernel(); | 993 | mutex_unlock(&autofs4_ioctl_mutex); |
990 | 994 | ||
991 | return ret; | 995 | return ret; |
992 | } | 996 | } |
@@ -998,13 +1002,13 @@ static long autofs4_root_compat_ioctl(struct file *filp, | |||
998 | struct inode *inode = filp->f_path.dentry->d_inode; | 1002 | struct inode *inode = filp->f_path.dentry->d_inode; |
999 | int ret; | 1003 | int ret; |
1000 | 1004 | ||
1001 | lock_kernel(); | 1005 | mutex_lock(&autofs4_ioctl_mutex); |
1002 | if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL) | 1006 | if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL) |
1003 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); | 1007 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); |
1004 | else | 1008 | else |
1005 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, | 1009 | ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, |
1006 | (unsigned long)compat_ptr(arg)); | 1010 | (unsigned long)compat_ptr(arg)); |
1007 | unlock_kernel(); | 1011 | mutex_unlock(&autofs4_ioctl_mutex); |
1008 | 1012 | ||
1009 | return ret; | 1013 | return ret; |
1010 | } | 1014 | } |
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index c4daf0f5fc02..883e77acd5a8 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | #include <linux/smp_lock.h> | ||
16 | #include <linux/buffer_head.h> | 15 | #include <linux/buffer_head.h> |
17 | #include <linux/vfs.h> | 16 | #include <linux/vfs.h> |
18 | #include <linux/writeback.h> | 17 | #include <linux/writeback.h> |
@@ -215,14 +214,10 @@ static void bfs_put_super(struct super_block *s) | |||
215 | if (!info) | 214 | if (!info) |
216 | return; | 215 | return; |
217 | 216 | ||
218 | lock_kernel(); | ||
219 | |||
220 | mutex_destroy(&info->bfs_lock); | 217 | mutex_destroy(&info->bfs_lock); |
221 | kfree(info->si_imap); | 218 | kfree(info->si_imap); |
222 | kfree(info); | 219 | kfree(info); |
223 | s->s_fs_info = NULL; | 220 | s->s_fs_info = NULL; |
224 | |||
225 | unlock_kernel(); | ||
226 | } | 221 | } |
227 | 222 | ||
228 | static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 223 | static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index b7431afdd76d..50208c15309a 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/kthread.h> | 36 | #include <linux/kthread.h> |
37 | #include <linux/freezer.h> | 37 | #include <linux/freezer.h> |
38 | #include <linux/smp_lock.h> | ||
39 | #include "cifsfs.h" | 38 | #include "cifsfs.h" |
40 | #include "cifspdu.h" | 39 | #include "cifspdu.h" |
41 | #define DECLARE_GLOBALS_HERE | 40 | #define DECLARE_GLOBALS_HERE |
@@ -200,8 +199,6 @@ cifs_put_super(struct super_block *sb) | |||
200 | return; | 199 | return; |
201 | } | 200 | } |
202 | 201 | ||
203 | lock_kernel(); | ||
204 | |||
205 | rc = cifs_umount(sb, cifs_sb); | 202 | rc = cifs_umount(sb, cifs_sb); |
206 | if (rc) | 203 | if (rc) |
207 | cERROR(1, "cifs_umount failed with return code %d", rc); | 204 | cERROR(1, "cifs_umount failed with return code %d", rc); |
@@ -215,8 +212,6 @@ cifs_put_super(struct super_block *sb) | |||
215 | unload_nls(cifs_sb->local_nls); | 212 | unload_nls(cifs_sb->local_nls); |
216 | bdi_destroy(&cifs_sb->bdi); | 213 | bdi_destroy(&cifs_sb->bdi); |
217 | kfree(cifs_sb); | 214 | kfree(cifs_sb); |
218 | |||
219 | unlock_kernel(); | ||
220 | } | 215 | } |
221 | 216 | ||
222 | static int | 217 | static int |
@@ -514,7 +509,9 @@ cifs_get_sb(struct file_system_type *fs_type, | |||
514 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 509 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
515 | { | 510 | { |
516 | int rc; | 511 | int rc; |
517 | struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL); | 512 | struct super_block *sb; |
513 | |||
514 | sb = sget(fs_type, NULL, set_anon_super, NULL); | ||
518 | 515 | ||
519 | cFYI(1, "Devname: %s flags: %d ", dev_name, flags); | 516 | cFYI(1, "Devname: %s flags: %d ", dev_name, flags); |
520 | 517 | ||
@@ -565,8 +562,8 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) | |||
565 | 562 | ||
566 | static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) | 563 | static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) |
567 | { | 564 | { |
568 | /* note that this is called by vfs setlease with the BKL held | 565 | /* note that this is called by vfs setlease with lock_flocks held |
569 | although I doubt that BKL is needed here in cifs */ | 566 | to protect *lease from going away */ |
570 | struct inode *inode = file->f_path.dentry->d_inode; | 567 | struct inode *inode = file->f_path.dentry->d_inode; |
571 | 568 | ||
572 | if (!(S_ISREG(inode->i_mode))) | 569 | if (!(S_ISREG(inode->i_mode))) |
diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 6526e6f21ecf..bfe8179b1295 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c | |||
@@ -148,6 +148,8 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
148 | int error; | 148 | int error; |
149 | int idx; | 149 | int idx; |
150 | 150 | ||
151 | lock_kernel(); | ||
152 | |||
151 | idx = get_device_index((struct coda_mount_data *) data); | 153 | idx = get_device_index((struct coda_mount_data *) data); |
152 | 154 | ||
153 | /* Ignore errors in data, for backward compatibility */ | 155 | /* Ignore errors in data, for backward compatibility */ |
@@ -159,11 +161,13 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
159 | vc = &coda_comms[idx]; | 161 | vc = &coda_comms[idx]; |
160 | if (!vc->vc_inuse) { | 162 | if (!vc->vc_inuse) { |
161 | printk("coda_read_super: No pseudo device\n"); | 163 | printk("coda_read_super: No pseudo device\n"); |
164 | unlock_kernel(); | ||
162 | return -EINVAL; | 165 | return -EINVAL; |
163 | } | 166 | } |
164 | 167 | ||
165 | if ( vc->vc_sb ) { | 168 | if ( vc->vc_sb ) { |
166 | printk("coda_read_super: Device already mounted\n"); | 169 | printk("coda_read_super: Device already mounted\n"); |
170 | unlock_kernel(); | ||
167 | return -EBUSY; | 171 | return -EBUSY; |
168 | } | 172 | } |
169 | 173 | ||
@@ -202,7 +206,8 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
202 | sb->s_root = d_alloc_root(root); | 206 | sb->s_root = d_alloc_root(root); |
203 | if (!sb->s_root) | 207 | if (!sb->s_root) |
204 | goto error; | 208 | goto error; |
205 | return 0; | 209 | unlock_kernel(); |
210 | return 0; | ||
206 | 211 | ||
207 | error: | 212 | error: |
208 | bdi_destroy(&vc->bdi); | 213 | bdi_destroy(&vc->bdi); |
@@ -212,6 +217,7 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
212 | if (vc) | 217 | if (vc) |
213 | vc->vc_sb = NULL; | 218 | vc->vc_sb = NULL; |
214 | 219 | ||
220 | unlock_kernel(); | ||
215 | return -EINVAL; | 221 | return -EINVAL; |
216 | } | 222 | } |
217 | 223 | ||
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 622c95140802..2b9a644b7583 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/security.h> | 31 | #include <linux/security.h> |
32 | #include <linux/compat.h> | 32 | #include <linux/compat.h> |
33 | #include <linux/fs_stack.h> | 33 | #include <linux/fs_stack.h> |
34 | #include <linux/smp_lock.h> | ||
35 | #include "ecryptfs_kernel.h" | 34 | #include "ecryptfs_kernel.h" |
36 | 35 | ||
37 | /** | 36 | /** |
@@ -284,11 +283,9 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag) | |||
284 | int rc = 0; | 283 | int rc = 0; |
285 | struct file *lower_file = NULL; | 284 | struct file *lower_file = NULL; |
286 | 285 | ||
287 | lock_kernel(); | ||
288 | lower_file = ecryptfs_file_to_lower(file); | 286 | lower_file = ecryptfs_file_to_lower(file); |
289 | if (lower_file->f_op && lower_file->f_op->fasync) | 287 | if (lower_file->f_op && lower_file->f_op->fasync) |
290 | rc = lower_file->f_op->fasync(fd, lower_file, flag); | 288 | rc = lower_file->f_op->fasync(fd, lower_file, flag); |
291 | unlock_kernel(); | ||
292 | return rc; | 289 | return rc; |
293 | } | 290 | } |
294 | 291 | ||
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 1ec602673ea8..85df87d0f7b7 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -747,15 +747,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
747 | __le32 features; | 747 | __le32 features; |
748 | int err; | 748 | int err; |
749 | 749 | ||
750 | err = -ENOMEM; | ||
750 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 751 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
751 | if (!sbi) | 752 | if (!sbi) |
752 | return -ENOMEM; | 753 | goto failed_unlock; |
753 | 754 | ||
754 | sbi->s_blockgroup_lock = | 755 | sbi->s_blockgroup_lock = |
755 | kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); | 756 | kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); |
756 | if (!sbi->s_blockgroup_lock) { | 757 | if (!sbi->s_blockgroup_lock) { |
757 | kfree(sbi); | 758 | kfree(sbi); |
758 | return -ENOMEM; | 759 | goto failed_unlock; |
759 | } | 760 | } |
760 | sb->s_fs_info = sbi; | 761 | sb->s_fs_info = sbi; |
761 | sbi->s_sb_block = sb_block; | 762 | sbi->s_sb_block = sb_block; |
@@ -1107,6 +1108,7 @@ failed_sbi: | |||
1107 | sb->s_fs_info = NULL; | 1108 | sb->s_fs_info = NULL; |
1108 | kfree(sbi->s_blockgroup_lock); | 1109 | kfree(sbi->s_blockgroup_lock); |
1109 | kfree(sbi); | 1110 | kfree(sbi); |
1111 | failed_unlock: | ||
1110 | return ret; | 1112 | return ret; |
1111 | } | 1113 | } |
1112 | 1114 | ||
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index a367dd044280..377768009106 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -411,9 +411,6 @@ static void ext3_put_super (struct super_block * sb) | |||
411 | int i, err; | 411 | int i, err; |
412 | 412 | ||
413 | dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); | 413 | dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); |
414 | |||
415 | lock_kernel(); | ||
416 | |||
417 | ext3_xattr_put_super(sb); | 414 | ext3_xattr_put_super(sb); |
418 | err = journal_destroy(sbi->s_journal); | 415 | err = journal_destroy(sbi->s_journal); |
419 | sbi->s_journal = NULL; | 416 | sbi->s_journal = NULL; |
@@ -462,8 +459,6 @@ static void ext3_put_super (struct super_block * sb) | |||
462 | sb->s_fs_info = NULL; | 459 | sb->s_fs_info = NULL; |
463 | kfree(sbi->s_blockgroup_lock); | 460 | kfree(sbi->s_blockgroup_lock); |
464 | kfree(sbi); | 461 | kfree(sbi); |
465 | |||
466 | unlock_kernel(); | ||
467 | } | 462 | } |
468 | 463 | ||
469 | static struct kmem_cache *ext3_inode_cachep; | 464 | static struct kmem_cache *ext3_inode_cachep; |
@@ -1627,8 +1622,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1627 | sbi->s_resgid = EXT3_DEF_RESGID; | 1622 | sbi->s_resgid = EXT3_DEF_RESGID; |
1628 | sbi->s_sb_block = sb_block; | 1623 | sbi->s_sb_block = sb_block; |
1629 | 1624 | ||
1630 | unlock_kernel(); | ||
1631 | |||
1632 | blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); | 1625 | blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); |
1633 | if (!blocksize) { | 1626 | if (!blocksize) { |
1634 | ext3_msg(sb, KERN_ERR, "error: unable to set blocksize"); | 1627 | ext3_msg(sb, KERN_ERR, "error: unable to set blocksize"); |
@@ -2025,7 +2018,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
2025 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": | 2018 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": |
2026 | "writeback"); | 2019 | "writeback"); |
2027 | 2020 | ||
2028 | lock_kernel(); | ||
2029 | return 0; | 2021 | return 0; |
2030 | 2022 | ||
2031 | cantfind_ext3: | 2023 | cantfind_ext3: |
@@ -2055,7 +2047,6 @@ out_fail: | |||
2055 | sb->s_fs_info = NULL; | 2047 | sb->s_fs_info = NULL; |
2056 | kfree(sbi->s_blockgroup_lock); | 2048 | kfree(sbi->s_blockgroup_lock); |
2057 | kfree(sbi); | 2049 | kfree(sbi); |
2058 | lock_kernel(); | ||
2059 | return ret; | 2050 | return ret; |
2060 | } | 2051 | } |
2061 | 2052 | ||
@@ -2538,8 +2529,6 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) | |||
2538 | int i; | 2529 | int i; |
2539 | #endif | 2530 | #endif |
2540 | 2531 | ||
2541 | lock_kernel(); | ||
2542 | |||
2543 | /* Store the original options */ | 2532 | /* Store the original options */ |
2544 | lock_super(sb); | 2533 | lock_super(sb); |
2545 | old_sb_flags = sb->s_flags; | 2534 | old_sb_flags = sb->s_flags; |
@@ -2648,7 +2637,6 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) | |||
2648 | kfree(old_opts.s_qf_names[i]); | 2637 | kfree(old_opts.s_qf_names[i]); |
2649 | #endif | 2638 | #endif |
2650 | unlock_super(sb); | 2639 | unlock_super(sb); |
2651 | unlock_kernel(); | ||
2652 | 2640 | ||
2653 | if (enable_quota) | 2641 | if (enable_quota) |
2654 | dquot_resume(sb, -1); | 2642 | dquot_resume(sb, -1); |
@@ -2669,7 +2657,6 @@ restore_opts: | |||
2669 | } | 2657 | } |
2670 | #endif | 2658 | #endif |
2671 | unlock_super(sb); | 2659 | unlock_super(sb); |
2672 | unlock_kernel(); | ||
2673 | return err; | 2660 | return err; |
2674 | } | 2661 | } |
2675 | 2662 | ||
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 7f47c366bf15..8ecc1e590303 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/blkdev.h> | 27 | #include <linux/blkdev.h> |
28 | #include <linux/parser.h> | 28 | #include <linux/parser.h> |
29 | #include <linux/smp_lock.h> | ||
30 | #include <linux/buffer_head.h> | 29 | #include <linux/buffer_head.h> |
31 | #include <linux/exportfs.h> | 30 | #include <linux/exportfs.h> |
32 | #include <linux/vfs.h> | 31 | #include <linux/vfs.h> |
@@ -708,7 +707,6 @@ static void ext4_put_super(struct super_block *sb) | |||
708 | destroy_workqueue(sbi->dio_unwritten_wq); | 707 | destroy_workqueue(sbi->dio_unwritten_wq); |
709 | 708 | ||
710 | lock_super(sb); | 709 | lock_super(sb); |
711 | lock_kernel(); | ||
712 | if (sb->s_dirt) | 710 | if (sb->s_dirt) |
713 | ext4_commit_super(sb, 1); | 711 | ext4_commit_super(sb, 1); |
714 | 712 | ||
@@ -775,7 +773,6 @@ static void ext4_put_super(struct super_block *sb) | |||
775 | * Now that we are completely done shutting down the | 773 | * Now that we are completely done shutting down the |
776 | * superblock, we need to actually destroy the kobject. | 774 | * superblock, we need to actually destroy the kobject. |
777 | */ | 775 | */ |
778 | unlock_kernel(); | ||
779 | unlock_super(sb); | 776 | unlock_super(sb); |
780 | kobject_put(&sbi->s_kobj); | 777 | kobject_put(&sbi->s_kobj); |
781 | wait_for_completion(&sbi->s_kobj_unregister); | 778 | wait_for_completion(&sbi->s_kobj_unregister); |
@@ -2588,8 +2585,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2588 | sbi->s_sectors_written_start = | 2585 | sbi->s_sectors_written_start = |
2589 | part_stat_read(sb->s_bdev->bd_part, sectors[1]); | 2586 | part_stat_read(sb->s_bdev->bd_part, sectors[1]); |
2590 | 2587 | ||
2591 | unlock_kernel(); | ||
2592 | |||
2593 | /* Cleanup superblock name */ | 2588 | /* Cleanup superblock name */ |
2594 | for (cp = sb->s_id; (cp = strchr(cp, '/'));) | 2589 | for (cp = sb->s_id; (cp = strchr(cp, '/'));) |
2595 | *cp = '!'; | 2590 | *cp = '!'; |
@@ -3164,7 +3159,6 @@ no_journal: | |||
3164 | if (es->s_error_count) | 3159 | if (es->s_error_count) |
3165 | mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */ | 3160 | mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */ |
3166 | 3161 | ||
3167 | lock_kernel(); | ||
3168 | kfree(orig_data); | 3162 | kfree(orig_data); |
3169 | return 0; | 3163 | return 0; |
3170 | 3164 | ||
@@ -3211,7 +3205,6 @@ out_fail: | |||
3211 | sb->s_fs_info = NULL; | 3205 | sb->s_fs_info = NULL; |
3212 | kfree(sbi->s_blockgroup_lock); | 3206 | kfree(sbi->s_blockgroup_lock); |
3213 | kfree(sbi); | 3207 | kfree(sbi); |
3214 | lock_kernel(); | ||
3215 | out_free_orig: | 3208 | out_free_orig: |
3216 | kfree(orig_data); | 3209 | kfree(orig_data); |
3217 | return ret; | 3210 | return ret; |
@@ -3720,8 +3713,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3720 | #endif | 3713 | #endif |
3721 | char *orig_data = kstrdup(data, GFP_KERNEL); | 3714 | char *orig_data = kstrdup(data, GFP_KERNEL); |
3722 | 3715 | ||
3723 | lock_kernel(); | ||
3724 | |||
3725 | /* Store the original options */ | 3716 | /* Store the original options */ |
3726 | lock_super(sb); | 3717 | lock_super(sb); |
3727 | old_sb_flags = sb->s_flags; | 3718 | old_sb_flags = sb->s_flags; |
@@ -3856,7 +3847,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3856 | kfree(old_opts.s_qf_names[i]); | 3847 | kfree(old_opts.s_qf_names[i]); |
3857 | #endif | 3848 | #endif |
3858 | unlock_super(sb); | 3849 | unlock_super(sb); |
3859 | unlock_kernel(); | ||
3860 | if (enable_quota) | 3850 | if (enable_quota) |
3861 | dquot_resume(sb, -1); | 3851 | dquot_resume(sb, -1); |
3862 | 3852 | ||
@@ -3882,7 +3872,6 @@ restore_opts: | |||
3882 | } | 3872 | } |
3883 | #endif | 3873 | #endif |
3884 | unlock_super(sb); | 3874 | unlock_super(sb); |
3885 | unlock_kernel(); | ||
3886 | kfree(orig_data); | 3875 | kfree(orig_data); |
3887 | return err; | 3876 | return err; |
3888 | } | 3877 | } |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 830058057d33..ad6998a92c30 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/time.h> | 15 | #include <linux/time.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/smp_lock.h> | ||
18 | #include <linux/seq_file.h> | 17 | #include <linux/seq_file.h> |
19 | #include <linux/pagemap.h> | 18 | #include <linux/pagemap.h> |
20 | #include <linux/mpage.h> | 19 | #include <linux/mpage.h> |
@@ -489,8 +488,6 @@ static void fat_put_super(struct super_block *sb) | |||
489 | { | 488 | { |
490 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | 489 | struct msdos_sb_info *sbi = MSDOS_SB(sb); |
491 | 490 | ||
492 | lock_kernel(); | ||
493 | |||
494 | if (sb->s_dirt) | 491 | if (sb->s_dirt) |
495 | fat_write_super(sb); | 492 | fat_write_super(sb); |
496 | 493 | ||
@@ -504,8 +501,6 @@ static void fat_put_super(struct super_block *sb) | |||
504 | 501 | ||
505 | sb->s_fs_info = NULL; | 502 | sb->s_fs_info = NULL; |
506 | kfree(sbi); | 503 | kfree(sbi); |
507 | |||
508 | unlock_kernel(); | ||
509 | } | 504 | } |
510 | 505 | ||
511 | static struct kmem_cache *fat_inode_cachep; | 506 | static struct kmem_cache *fat_inode_cachep; |
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c index bbc94ae4fd77..bbca5c186ae7 100644 --- a/fs/fat/namei_msdos.c +++ b/fs/fat/namei_msdos.c | |||
@@ -662,12 +662,16 @@ static int msdos_fill_super(struct super_block *sb, void *data, int silent) | |||
662 | { | 662 | { |
663 | int res; | 663 | int res; |
664 | 664 | ||
665 | lock_super(sb); | ||
665 | res = fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, 0); | 666 | res = fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, 0); |
666 | if (res) | 667 | if (res) { |
668 | unlock_super(sb); | ||
667 | return res; | 669 | return res; |
670 | } | ||
668 | 671 | ||
669 | sb->s_flags |= MS_NOATIME; | 672 | sb->s_flags |= MS_NOATIME; |
670 | sb->s_root->d_op = &msdos_dentry_operations; | 673 | sb->s_root->d_op = &msdos_dentry_operations; |
674 | unlock_super(sb); | ||
671 | return 0; | 675 | return 0; |
672 | } | 676 | } |
673 | 677 | ||
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index 6fcc7e71fbaa..6f0f6c9a0152 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
@@ -1055,15 +1055,19 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent) | |||
1055 | { | 1055 | { |
1056 | int res; | 1056 | int res; |
1057 | 1057 | ||
1058 | lock_super(sb); | ||
1058 | res = fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, 1); | 1059 | res = fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, 1); |
1059 | if (res) | 1060 | if (res) { |
1061 | unlock_super(sb); | ||
1060 | return res; | 1062 | return res; |
1063 | } | ||
1061 | 1064 | ||
1062 | if (MSDOS_SB(sb)->options.name_check != 's') | 1065 | if (MSDOS_SB(sb)->options.name_check != 's') |
1063 | sb->s_root->d_op = &vfat_ci_dentry_ops; | 1066 | sb->s_root->d_op = &vfat_ci_dentry_ops; |
1064 | else | 1067 | else |
1065 | sb->s_root->d_op = &vfat_dentry_ops; | 1068 | sb->s_root->d_op = &vfat_dentry_ops; |
1066 | 1069 | ||
1070 | unlock_super(sb); | ||
1067 | return 0; | 1071 | return 0; |
1068 | } | 1072 | } |
1069 | 1073 | ||
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c index 0ec7bb2c95c6..6c5131d592f0 100644 --- a/fs/freevxfs/vxfs_lookup.c +++ b/fs/freevxfs/vxfs_lookup.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <linux/highmem.h> | 36 | #include <linux/highmem.h> |
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/pagemap.h> | 38 | #include <linux/pagemap.h> |
39 | #include <linux/smp_lock.h> | ||
40 | 39 | ||
41 | #include "vxfs.h" | 40 | #include "vxfs.h" |
42 | #include "vxfs_dir.h" | 41 | #include "vxfs_dir.h" |
@@ -212,16 +211,12 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, struct nameidata *nd) | |||
212 | if (dp->d_name.len > VXFS_NAMELEN) | 211 | if (dp->d_name.len > VXFS_NAMELEN) |
213 | return ERR_PTR(-ENAMETOOLONG); | 212 | return ERR_PTR(-ENAMETOOLONG); |
214 | 213 | ||
215 | lock_kernel(); | ||
216 | ino = vxfs_inode_by_name(dip, dp); | 214 | ino = vxfs_inode_by_name(dip, dp); |
217 | if (ino) { | 215 | if (ino) { |
218 | ip = vxfs_iget(dip->i_sb, ino); | 216 | ip = vxfs_iget(dip->i_sb, ino); |
219 | if (IS_ERR(ip)) { | 217 | if (IS_ERR(ip)) |
220 | unlock_kernel(); | ||
221 | return ERR_CAST(ip); | 218 | return ERR_CAST(ip); |
222 | } | ||
223 | } | 219 | } |
224 | unlock_kernel(); | ||
225 | d_add(dp, ip); | 220 | d_add(dp, ip); |
226 | return NULL; | 221 | return NULL; |
227 | } | 222 | } |
@@ -248,8 +243,6 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler) | |||
248 | u_long page, npages, block, pblocks, nblocks, offset; | 243 | u_long page, npages, block, pblocks, nblocks, offset; |
249 | loff_t pos; | 244 | loff_t pos; |
250 | 245 | ||
251 | lock_kernel(); | ||
252 | |||
253 | switch ((long)fp->f_pos) { | 246 | switch ((long)fp->f_pos) { |
254 | case 0: | 247 | case 0: |
255 | if (filler(retp, ".", 1, fp->f_pos, ip->i_ino, DT_DIR) < 0) | 248 | if (filler(retp, ".", 1, fp->f_pos, ip->i_ino, DT_DIR) < 0) |
@@ -265,10 +258,8 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler) | |||
265 | 258 | ||
266 | pos = fp->f_pos - 2; | 259 | pos = fp->f_pos - 2; |
267 | 260 | ||
268 | if (pos > VXFS_DIRROUND(ip->i_size)) { | 261 | if (pos > VXFS_DIRROUND(ip->i_size)) |
269 | unlock_kernel(); | ||
270 | return 0; | 262 | return 0; |
271 | } | ||
272 | 263 | ||
273 | npages = dir_pages(ip); | 264 | npages = dir_pages(ip); |
274 | nblocks = dir_blocks(ip); | 265 | nblocks = dir_blocks(ip); |
@@ -327,6 +318,5 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler) | |||
327 | done: | 318 | done: |
328 | fp->f_pos = ((page << PAGE_CACHE_SHIFT) | offset) + 2; | 319 | fp->f_pos = ((page << PAGE_CACHE_SHIFT) | offset) + 2; |
329 | out: | 320 | out: |
330 | unlock_kernel(); | ||
331 | return 0; | 321 | return 0; |
332 | } | 322 | } |
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c index dc0c041e85cb..71b0148b8784 100644 --- a/fs/freevxfs/vxfs_super.c +++ b/fs/freevxfs/vxfs_super.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/buffer_head.h> | 38 | #include <linux/buffer_head.h> |
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/smp_lock.h> | ||
42 | #include <linux/stat.h> | 41 | #include <linux/stat.h> |
43 | #include <linux/vfs.h> | 42 | #include <linux/vfs.h> |
44 | #include <linux/mount.h> | 43 | #include <linux/mount.h> |
@@ -81,16 +80,12 @@ vxfs_put_super(struct super_block *sbp) | |||
81 | { | 80 | { |
82 | struct vxfs_sb_info *infp = VXFS_SBI(sbp); | 81 | struct vxfs_sb_info *infp = VXFS_SBI(sbp); |
83 | 82 | ||
84 | lock_kernel(); | ||
85 | |||
86 | vxfs_put_fake_inode(infp->vsi_fship); | 83 | vxfs_put_fake_inode(infp->vsi_fship); |
87 | vxfs_put_fake_inode(infp->vsi_ilist); | 84 | vxfs_put_fake_inode(infp->vsi_ilist); |
88 | vxfs_put_fake_inode(infp->vsi_stilist); | 85 | vxfs_put_fake_inode(infp->vsi_stilist); |
89 | 86 | ||
90 | brelse(infp->vsi_bp); | 87 | brelse(infp->vsi_bp); |
91 | kfree(infp); | 88 | kfree(infp); |
92 | |||
93 | unlock_kernel(); | ||
94 | } | 89 | } |
95 | 90 | ||
96 | /** | 91 | /** |
@@ -148,7 +143,7 @@ static int vxfs_remount(struct super_block *sb, int *flags, char *data) | |||
148 | * The superblock on success, else %NULL. | 143 | * The superblock on success, else %NULL. |
149 | * | 144 | * |
150 | * Locking: | 145 | * Locking: |
151 | * We are under the bkl and @sbp->s_lock. | 146 | * We are under @sbp->s_lock. |
152 | */ | 147 | */ |
153 | static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) | 148 | static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) |
154 | { | 149 | { |
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 237ee6a940df..a51079bd4af1 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -622,6 +622,8 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
622 | * cluster; until we do, disable leases (by just returning -EINVAL), | 622 | * cluster; until we do, disable leases (by just returning -EINVAL), |
623 | * unless the administrator has requested purely local locking. | 623 | * unless the administrator has requested purely local locking. |
624 | * | 624 | * |
625 | * Locking: called under lock_flocks | ||
626 | * | ||
625 | * Returns: errno | 627 | * Returns: errno |
626 | */ | 628 | */ |
627 | 629 | ||
diff --git a/fs/hfs/super.c b/fs/hfs/super.c index 34235d4bf08b..33254160f650 100644 --- a/fs/hfs/super.c +++ b/fs/hfs/super.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/parser.h> | 20 | #include <linux/parser.h> |
21 | #include <linux/seq_file.h> | 21 | #include <linux/seq_file.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/smp_lock.h> | ||
24 | #include <linux/vfs.h> | 23 | #include <linux/vfs.h> |
25 | 24 | ||
26 | #include "hfs_fs.h" | 25 | #include "hfs_fs.h" |
@@ -79,15 +78,11 @@ static int hfs_sync_fs(struct super_block *sb, int wait) | |||
79 | */ | 78 | */ |
80 | static void hfs_put_super(struct super_block *sb) | 79 | static void hfs_put_super(struct super_block *sb) |
81 | { | 80 | { |
82 | lock_kernel(); | ||
83 | |||
84 | if (sb->s_dirt) | 81 | if (sb->s_dirt) |
85 | hfs_write_super(sb); | 82 | hfs_write_super(sb); |
86 | hfs_mdb_close(sb); | 83 | hfs_mdb_close(sb); |
87 | /* release the MDB's resources */ | 84 | /* release the MDB's resources */ |
88 | hfs_mdb_put(sb); | 85 | hfs_mdb_put(sb); |
89 | |||
90 | unlock_kernel(); | ||
91 | } | 86 | } |
92 | 87 | ||
93 | /* | 88 | /* |
@@ -385,6 +380,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent) | |||
385 | sbi = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL); | 380 | sbi = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL); |
386 | if (!sbi) | 381 | if (!sbi) |
387 | return -ENOMEM; | 382 | return -ENOMEM; |
383 | |||
388 | sb->s_fs_info = sbi; | 384 | sb->s_fs_info = sbi; |
389 | INIT_HLIST_HEAD(&sbi->rsrc_inodes); | 385 | INIT_HLIST_HEAD(&sbi->rsrc_inodes); |
390 | 386 | ||
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index 2607010be2fe..c969a1aa163a 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -477,11 +477,15 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
477 | 477 | ||
478 | int o; | 478 | int o; |
479 | 479 | ||
480 | lock_kernel(); | ||
481 | |||
480 | save_mount_options(s, options); | 482 | save_mount_options(s, options); |
481 | 483 | ||
482 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 484 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
483 | if (!sbi) | 485 | if (!sbi) { |
486 | unlock_kernel(); | ||
484 | return -ENOMEM; | 487 | return -ENOMEM; |
488 | } | ||
485 | s->s_fs_info = sbi; | 489 | s->s_fs_info = sbi; |
486 | 490 | ||
487 | sbi->sb_bmp_dir = NULL; | 491 | sbi->sb_bmp_dir = NULL; |
@@ -666,6 +670,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
666 | root->i_blocks = 5; | 670 | root->i_blocks = 5; |
667 | hpfs_brelse4(&qbh); | 671 | hpfs_brelse4(&qbh); |
668 | } | 672 | } |
673 | unlock_kernel(); | ||
669 | return 0; | 674 | return 0; |
670 | 675 | ||
671 | bail4: brelse(bh2); | 676 | bail4: brelse(bh2); |
@@ -677,6 +682,7 @@ bail0: | |||
677 | kfree(sbi->sb_cp_table); | 682 | kfree(sbi->sb_cp_table); |
678 | s->s_fs_info = NULL; | 683 | s->s_fs_info = NULL; |
679 | kfree(sbi); | 684 | kfree(sbi); |
685 | unlock_kernel(); | ||
680 | return -EINVAL; | 686 | return -EINVAL; |
681 | } | 687 | } |
682 | 688 | ||
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c index e0aca9a0ac68..0542b6eedf80 100644 --- a/fs/isofs/dir.c +++ b/fs/isofs/dir.c | |||
@@ -10,7 +10,6 @@ | |||
10 | * | 10 | * |
11 | * isofs directory handling functions | 11 | * isofs directory handling functions |
12 | */ | 12 | */ |
13 | #include <linux/smp_lock.h> | ||
14 | #include <linux/gfp.h> | 13 | #include <linux/gfp.h> |
15 | #include "isofs.h" | 14 | #include "isofs.h" |
16 | 15 | ||
@@ -255,18 +254,19 @@ static int isofs_readdir(struct file *filp, | |||
255 | char *tmpname; | 254 | char *tmpname; |
256 | struct iso_directory_record *tmpde; | 255 | struct iso_directory_record *tmpde; |
257 | struct inode *inode = filp->f_path.dentry->d_inode; | 256 | struct inode *inode = filp->f_path.dentry->d_inode; |
257 | struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb); | ||
258 | 258 | ||
259 | tmpname = (char *)__get_free_page(GFP_KERNEL); | 259 | tmpname = (char *)__get_free_page(GFP_KERNEL); |
260 | if (tmpname == NULL) | 260 | if (tmpname == NULL) |
261 | return -ENOMEM; | 261 | return -ENOMEM; |
262 | 262 | ||
263 | lock_kernel(); | 263 | mutex_lock(&sbi->s_mutex); |
264 | tmpde = (struct iso_directory_record *) (tmpname+1024); | 264 | tmpde = (struct iso_directory_record *) (tmpname+1024); |
265 | 265 | ||
266 | result = do_isofs_readdir(inode, filp, dirent, filldir, tmpname, tmpde); | 266 | result = do_isofs_readdir(inode, filp, dirent, filldir, tmpname, tmpde); |
267 | 267 | ||
268 | free_page((unsigned long) tmpname); | 268 | free_page((unsigned long) tmpname); |
269 | unlock_kernel(); | 269 | mutex_unlock(&sbi->s_mutex); |
270 | return result; | 270 | return result; |
271 | } | 271 | } |
272 | 272 | ||
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 5a44811b5027..09ff41a752a0 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/nls.h> | 18 | #include <linux/nls.h> |
19 | #include <linux/ctype.h> | 19 | #include <linux/ctype.h> |
20 | #include <linux/smp_lock.h> | ||
21 | #include <linux/statfs.h> | 20 | #include <linux/statfs.h> |
22 | #include <linux/cdrom.h> | 21 | #include <linux/cdrom.h> |
23 | #include <linux/parser.h> | 22 | #include <linux/parser.h> |
@@ -44,11 +43,7 @@ static void isofs_put_super(struct super_block *sb) | |||
44 | struct isofs_sb_info *sbi = ISOFS_SB(sb); | 43 | struct isofs_sb_info *sbi = ISOFS_SB(sb); |
45 | 44 | ||
46 | #ifdef CONFIG_JOLIET | 45 | #ifdef CONFIG_JOLIET |
47 | lock_kernel(); | ||
48 | |||
49 | unload_nls(sbi->s_nls_iocharset); | 46 | unload_nls(sbi->s_nls_iocharset); |
50 | |||
51 | unlock_kernel(); | ||
52 | #endif | 47 | #endif |
53 | 48 | ||
54 | kfree(sbi); | 49 | kfree(sbi); |
@@ -823,6 +818,7 @@ root_found: | |||
823 | sbi->s_utf8 = opt.utf8; | 818 | sbi->s_utf8 = opt.utf8; |
824 | sbi->s_nocompress = opt.nocompress; | 819 | sbi->s_nocompress = opt.nocompress; |
825 | sbi->s_overriderockperm = opt.overriderockperm; | 820 | sbi->s_overriderockperm = opt.overriderockperm; |
821 | mutex_init(&sbi->s_mutex); | ||
826 | /* | 822 | /* |
827 | * It would be incredibly stupid to allow people to mark every file | 823 | * It would be incredibly stupid to allow people to mark every file |
828 | * on the disk as suid, so we merely allow them to set the default | 824 | * on the disk as suid, so we merely allow them to set the default |
@@ -977,8 +973,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s, | |||
977 | int section, rv, error; | 973 | int section, rv, error; |
978 | struct iso_inode_info *ei = ISOFS_I(inode); | 974 | struct iso_inode_info *ei = ISOFS_I(inode); |
979 | 975 | ||
980 | lock_kernel(); | ||
981 | |||
982 | error = -EIO; | 976 | error = -EIO; |
983 | rv = 0; | 977 | rv = 0; |
984 | if (iblock < 0 || iblock != iblock_s) { | 978 | if (iblock < 0 || iblock != iblock_s) { |
@@ -1054,7 +1048,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s, | |||
1054 | 1048 | ||
1055 | error = 0; | 1049 | error = 0; |
1056 | abort: | 1050 | abort: |
1057 | unlock_kernel(); | ||
1058 | return rv != 0 ? rv : error; | 1051 | return rv != 0 ? rv : error; |
1059 | } | 1052 | } |
1060 | 1053 | ||
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h index 7d33de84f52a..2882dc089f87 100644 --- a/fs/isofs/isofs.h +++ b/fs/isofs/isofs.h | |||
@@ -55,6 +55,7 @@ struct isofs_sb_info { | |||
55 | gid_t s_gid; | 55 | gid_t s_gid; |
56 | uid_t s_uid; | 56 | uid_t s_uid; |
57 | struct nls_table *s_nls_iocharset; /* Native language support table */ | 57 | struct nls_table *s_nls_iocharset; /* Native language support table */ |
58 | struct mutex s_mutex; /* replaces BKL, please remove if possible */ | ||
58 | }; | 59 | }; |
59 | 60 | ||
60 | #define ISOFS_INVALID_MODE ((mode_t) -1) | 61 | #define ISOFS_INVALID_MODE ((mode_t) -1) |
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c index ab438beb867c..0d23abfd4280 100644 --- a/fs/isofs/namei.c +++ b/fs/isofs/namei.c | |||
@@ -6,7 +6,6 @@ | |||
6 | * (C) 1991 Linus Torvalds - minix filesystem | 6 | * (C) 1991 Linus Torvalds - minix filesystem |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/smp_lock.h> | ||
10 | #include <linux/gfp.h> | 9 | #include <linux/gfp.h> |
11 | #include "isofs.h" | 10 | #include "isofs.h" |
12 | 11 | ||
@@ -168,6 +167,7 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam | |||
168 | int found; | 167 | int found; |
169 | unsigned long uninitialized_var(block); | 168 | unsigned long uninitialized_var(block); |
170 | unsigned long uninitialized_var(offset); | 169 | unsigned long uninitialized_var(offset); |
170 | struct isofs_sb_info *sbi = ISOFS_SB(dir->i_sb); | ||
171 | struct inode *inode; | 171 | struct inode *inode; |
172 | struct page *page; | 172 | struct page *page; |
173 | 173 | ||
@@ -177,7 +177,7 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam | |||
177 | if (!page) | 177 | if (!page) |
178 | return ERR_PTR(-ENOMEM); | 178 | return ERR_PTR(-ENOMEM); |
179 | 179 | ||
180 | lock_kernel(); | 180 | mutex_lock(&sbi->s_mutex); |
181 | found = isofs_find_entry(dir, dentry, | 181 | found = isofs_find_entry(dir, dentry, |
182 | &block, &offset, | 182 | &block, &offset, |
183 | page_address(page), | 183 | page_address(page), |
@@ -188,10 +188,10 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam | |||
188 | if (found) { | 188 | if (found) { |
189 | inode = isofs_iget(dir->i_sb, block, offset); | 189 | inode = isofs_iget(dir->i_sb, block, offset); |
190 | if (IS_ERR(inode)) { | 190 | if (IS_ERR(inode)) { |
191 | unlock_kernel(); | 191 | mutex_unlock(&sbi->s_mutex); |
192 | return ERR_CAST(inode); | 192 | return ERR_CAST(inode); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | unlock_kernel(); | 195 | mutex_unlock(&sbi->s_mutex); |
196 | return d_splice_alias(inode, dentry); | 196 | return d_splice_alias(inode, dentry); |
197 | } | 197 | } |
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c index 96a685c550fd..f9cd04db6eab 100644 --- a/fs/isofs/rock.c +++ b/fs/isofs/rock.c | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include <linux/pagemap.h> | 10 | #include <linux/pagemap.h> |
11 | #include <linux/smp_lock.h> | ||
12 | 11 | ||
13 | #include "isofs.h" | 12 | #include "isofs.h" |
14 | #include "rock.h" | 13 | #include "rock.h" |
@@ -661,6 +660,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page) | |||
661 | { | 660 | { |
662 | struct inode *inode = page->mapping->host; | 661 | struct inode *inode = page->mapping->host; |
663 | struct iso_inode_info *ei = ISOFS_I(inode); | 662 | struct iso_inode_info *ei = ISOFS_I(inode); |
663 | struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb); | ||
664 | char *link = kmap(page); | 664 | char *link = kmap(page); |
665 | unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); | 665 | unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); |
666 | struct buffer_head *bh; | 666 | struct buffer_head *bh; |
@@ -673,12 +673,12 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page) | |||
673 | struct rock_state rs; | 673 | struct rock_state rs; |
674 | int ret; | 674 | int ret; |
675 | 675 | ||
676 | if (!ISOFS_SB(inode->i_sb)->s_rock) | 676 | if (!sbi->s_rock) |
677 | goto error; | 677 | goto error; |
678 | 678 | ||
679 | init_rock_state(&rs, inode); | 679 | init_rock_state(&rs, inode); |
680 | block = ei->i_iget5_block; | 680 | block = ei->i_iget5_block; |
681 | lock_kernel(); | 681 | mutex_lock(&sbi->s_mutex); |
682 | bh = sb_bread(inode->i_sb, block); | 682 | bh = sb_bread(inode->i_sb, block); |
683 | if (!bh) | 683 | if (!bh) |
684 | goto out_noread; | 684 | goto out_noread; |
@@ -748,7 +748,7 @@ repeat: | |||
748 | goto fail; | 748 | goto fail; |
749 | brelse(bh); | 749 | brelse(bh); |
750 | *rpnt = '\0'; | 750 | *rpnt = '\0'; |
751 | unlock_kernel(); | 751 | mutex_unlock(&sbi->s_mutex); |
752 | SetPageUptodate(page); | 752 | SetPageUptodate(page); |
753 | kunmap(page); | 753 | kunmap(page); |
754 | unlock_page(page); | 754 | unlock_page(page); |
@@ -765,7 +765,7 @@ out_bad_span: | |||
765 | printk("symlink spans iso9660 blocks\n"); | 765 | printk("symlink spans iso9660 blocks\n"); |
766 | fail: | 766 | fail: |
767 | brelse(bh); | 767 | brelse(bh); |
768 | unlock_kernel(); | 768 | mutex_unlock(&sbi->s_mutex); |
769 | error: | 769 | error: |
770 | SetPageError(page); | 770 | SetPageError(page); |
771 | kunmap(page); | 771 | kunmap(page); |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 6b2964a19850..d9beb06e6fca 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/vmalloc.h> | 21 | #include <linux/vmalloc.h> |
22 | #include <linux/vfs.h> | 22 | #include <linux/vfs.h> |
23 | #include <linux/crc32.h> | 23 | #include <linux/crc32.h> |
24 | #include <linux/smp_lock.h> | ||
25 | #include "nodelist.h" | 24 | #include "nodelist.h" |
26 | 25 | ||
27 | static int jffs2_flash_setup(struct jffs2_sb_info *c); | 26 | static int jffs2_flash_setup(struct jffs2_sb_info *c); |
@@ -391,7 +390,6 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data) | |||
391 | This also catches the case where it was stopped and this | 390 | This also catches the case where it was stopped and this |
392 | is just a remount to restart it. | 391 | is just a remount to restart it. |
393 | Flush the writebuffer, if neccecary, else we loose it */ | 392 | Flush the writebuffer, if neccecary, else we loose it */ |
394 | lock_kernel(); | ||
395 | if (!(sb->s_flags & MS_RDONLY)) { | 393 | if (!(sb->s_flags & MS_RDONLY)) { |
396 | jffs2_stop_garbage_collect_thread(c); | 394 | jffs2_stop_garbage_collect_thread(c); |
397 | mutex_lock(&c->alloc_sem); | 395 | mutex_lock(&c->alloc_sem); |
@@ -403,8 +401,6 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data) | |||
403 | jffs2_start_garbage_collect_thread(c); | 401 | jffs2_start_garbage_collect_thread(c); |
404 | 402 | ||
405 | *flags |= MS_NOATIME; | 403 | *flags |= MS_NOATIME; |
406 | |||
407 | unlock_kernel(); | ||
408 | return 0; | 404 | return 0; |
409 | } | 405 | } |
410 | 406 | ||
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 662bba099501..d1ae5dfc22b9 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/smp_lock.h> | ||
16 | #include <linux/init.h> | 15 | #include <linux/init.h> |
17 | #include <linux/list.h> | 16 | #include <linux/list.h> |
18 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
@@ -146,6 +145,7 @@ static const struct super_operations jffs2_super_operations = | |||
146 | static int jffs2_fill_super(struct super_block *sb, void *data, int silent) | 145 | static int jffs2_fill_super(struct super_block *sb, void *data, int silent) |
147 | { | 146 | { |
148 | struct jffs2_sb_info *c; | 147 | struct jffs2_sb_info *c; |
148 | int ret; | ||
149 | 149 | ||
150 | D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():" | 150 | D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():" |
151 | " New superblock for device %d (\"%s\")\n", | 151 | " New superblock for device %d (\"%s\")\n", |
@@ -175,7 +175,8 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) | |||
175 | #ifdef CONFIG_JFFS2_FS_POSIX_ACL | 175 | #ifdef CONFIG_JFFS2_FS_POSIX_ACL |
176 | sb->s_flags |= MS_POSIXACL; | 176 | sb->s_flags |= MS_POSIXACL; |
177 | #endif | 177 | #endif |
178 | return jffs2_do_fill_super(sb, data, silent); | 178 | ret = jffs2_do_fill_super(sb, data, silent); |
179 | return ret; | ||
179 | } | 180 | } |
180 | 181 | ||
181 | static int jffs2_get_sb(struct file_system_type *fs_type, | 182 | static int jffs2_get_sb(struct file_system_type *fs_type, |
@@ -192,8 +193,6 @@ static void jffs2_put_super (struct super_block *sb) | |||
192 | 193 | ||
193 | D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); | 194 | D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); |
194 | 195 | ||
195 | lock_kernel(); | ||
196 | |||
197 | if (sb->s_dirt) | 196 | if (sb->s_dirt) |
198 | jffs2_write_super(sb); | 197 | jffs2_write_super(sb); |
199 | 198 | ||
@@ -215,8 +214,6 @@ static void jffs2_put_super (struct super_block *sb) | |||
215 | if (c->mtd->sync) | 214 | if (c->mtd->sync) |
216 | c->mtd->sync(c->mtd); | 215 | c->mtd->sync(c->mtd); |
217 | 216 | ||
218 | unlock_kernel(); | ||
219 | |||
220 | D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); | 217 | D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); |
221 | } | 218 | } |
222 | 219 | ||
diff --git a/fs/jfs/super.c b/fs/jfs/super.c index ec8c3e4baca3..68eee2bf629e 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
35 | #include <linux/seq_file.h> | 35 | #include <linux/seq_file.h> |
36 | #include <linux/smp_lock.h> | ||
37 | 36 | ||
38 | #include "jfs_incore.h" | 37 | #include "jfs_incore.h" |
39 | #include "jfs_filsys.h" | 38 | #include "jfs_filsys.h" |
@@ -176,8 +175,6 @@ static void jfs_put_super(struct super_block *sb) | |||
176 | 175 | ||
177 | dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); | 176 | dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); |
178 | 177 | ||
179 | lock_kernel(); | ||
180 | |||
181 | rc = jfs_umount(sb); | 178 | rc = jfs_umount(sb); |
182 | if (rc) | 179 | if (rc) |
183 | jfs_err("jfs_umount failed with return code %d", rc); | 180 | jfs_err("jfs_umount failed with return code %d", rc); |
@@ -188,8 +185,6 @@ static void jfs_put_super(struct super_block *sb) | |||
188 | iput(sbi->direct_inode); | 185 | iput(sbi->direct_inode); |
189 | 186 | ||
190 | kfree(sbi); | 187 | kfree(sbi); |
191 | |||
192 | unlock_kernel(); | ||
193 | } | 188 | } |
194 | 189 | ||
195 | enum { | 190 | enum { |
@@ -369,19 +364,16 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data) | |||
369 | if (!parse_options(data, sb, &newLVSize, &flag)) { | 364 | if (!parse_options(data, sb, &newLVSize, &flag)) { |
370 | return -EINVAL; | 365 | return -EINVAL; |
371 | } | 366 | } |
372 | lock_kernel(); | 367 | |
373 | if (newLVSize) { | 368 | if (newLVSize) { |
374 | if (sb->s_flags & MS_RDONLY) { | 369 | if (sb->s_flags & MS_RDONLY) { |
375 | printk(KERN_ERR | 370 | printk(KERN_ERR |
376 | "JFS: resize requires volume to be mounted read-write\n"); | 371 | "JFS: resize requires volume to be mounted read-write\n"); |
377 | unlock_kernel(); | ||
378 | return -EROFS; | 372 | return -EROFS; |
379 | } | 373 | } |
380 | rc = jfs_extendfs(sb, newLVSize, 0); | 374 | rc = jfs_extendfs(sb, newLVSize, 0); |
381 | if (rc) { | 375 | if (rc) |
382 | unlock_kernel(); | ||
383 | return rc; | 376 | return rc; |
384 | } | ||
385 | } | 377 | } |
386 | 378 | ||
387 | if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { | 379 | if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { |
@@ -397,36 +389,30 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data) | |||
397 | /* mark the fs r/w for quota activity */ | 389 | /* mark the fs r/w for quota activity */ |
398 | sb->s_flags &= ~MS_RDONLY; | 390 | sb->s_flags &= ~MS_RDONLY; |
399 | 391 | ||
400 | unlock_kernel(); | ||
401 | dquot_resume(sb, -1); | 392 | dquot_resume(sb, -1); |
402 | return ret; | 393 | return ret; |
403 | } | 394 | } |
404 | if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) { | 395 | if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) { |
405 | rc = dquot_suspend(sb, -1); | 396 | rc = dquot_suspend(sb, -1); |
406 | if (rc < 0) { | 397 | if (rc < 0) { |
407 | unlock_kernel(); | ||
408 | return rc; | 398 | return rc; |
409 | } | 399 | } |
410 | rc = jfs_umount_rw(sb); | 400 | rc = jfs_umount_rw(sb); |
411 | JFS_SBI(sb)->flag = flag; | 401 | JFS_SBI(sb)->flag = flag; |
412 | unlock_kernel(); | ||
413 | return rc; | 402 | return rc; |
414 | } | 403 | } |
415 | if ((JFS_SBI(sb)->flag & JFS_NOINTEGRITY) != (flag & JFS_NOINTEGRITY)) | 404 | if ((JFS_SBI(sb)->flag & JFS_NOINTEGRITY) != (flag & JFS_NOINTEGRITY)) |
416 | if (!(sb->s_flags & MS_RDONLY)) { | 405 | if (!(sb->s_flags & MS_RDONLY)) { |
417 | rc = jfs_umount_rw(sb); | 406 | rc = jfs_umount_rw(sb); |
418 | if (rc) { | 407 | if (rc) |
419 | unlock_kernel(); | ||
420 | return rc; | 408 | return rc; |
421 | } | 409 | |
422 | JFS_SBI(sb)->flag = flag; | 410 | JFS_SBI(sb)->flag = flag; |
423 | ret = jfs_mount_rw(sb, 1); | 411 | ret = jfs_mount_rw(sb, 1); |
424 | unlock_kernel(); | ||
425 | return ret; | 412 | return ret; |
426 | } | 413 | } |
427 | JFS_SBI(sb)->flag = flag; | 414 | JFS_SBI(sb)->flag = flag; |
428 | 415 | ||
429 | unlock_kernel(); | ||
430 | return 0; | 416 | return 0; |
431 | } | 417 | } |
432 | 418 | ||
@@ -446,6 +432,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) | |||
446 | sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); | 432 | sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); |
447 | if (!sbi) | 433 | if (!sbi) |
448 | return -ENOMEM; | 434 | return -ENOMEM; |
435 | |||
449 | sb->s_fs_info = sbi; | 436 | sb->s_fs_info = sbi; |
450 | sbi->sb = sb; | 437 | sbi->sb = sb; |
451 | sbi->uid = sbi->gid = sbi->umask = -1; | 438 | sbi->uid = sbi->gid = sbi->umask = -1; |
diff --git a/fs/locks.c b/fs/locks.c index ab24d49fc048..8b2b6ad56a09 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -143,6 +143,22 @@ int lease_break_time = 45; | |||
143 | static LIST_HEAD(file_lock_list); | 143 | static LIST_HEAD(file_lock_list); |
144 | static LIST_HEAD(blocked_list); | 144 | static LIST_HEAD(blocked_list); |
145 | 145 | ||
146 | /* | ||
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 | */ | ||
150 | void lock_flocks(void) | ||
151 | { | ||
152 | lock_kernel(); | ||
153 | } | ||
154 | EXPORT_SYMBOL_GPL(lock_flocks); | ||
155 | |||
156 | void unlock_flocks(void) | ||
157 | { | ||
158 | unlock_kernel(); | ||
159 | } | ||
160 | EXPORT_SYMBOL_GPL(unlock_flocks); | ||
161 | |||
146 | static struct kmem_cache *filelock_cache __read_mostly; | 162 | static struct kmem_cache *filelock_cache __read_mostly; |
147 | 163 | ||
148 | /* Allocate an empty lock structure. */ | 164 | /* Allocate an empty lock structure. */ |
@@ -511,9 +527,9 @@ static void __locks_delete_block(struct file_lock *waiter) | |||
511 | */ | 527 | */ |
512 | static void locks_delete_block(struct file_lock *waiter) | 528 | static void locks_delete_block(struct file_lock *waiter) |
513 | { | 529 | { |
514 | lock_kernel(); | 530 | lock_flocks(); |
515 | __locks_delete_block(waiter); | 531 | __locks_delete_block(waiter); |
516 | unlock_kernel(); | 532 | unlock_flocks(); |
517 | } | 533 | } |
518 | 534 | ||
519 | /* Insert waiter into blocker's block list. | 535 | /* Insert waiter into blocker's block list. |
@@ -644,7 +660,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl) | |||
644 | { | 660 | { |
645 | struct file_lock *cfl; | 661 | struct file_lock *cfl; |
646 | 662 | ||
647 | lock_kernel(); | 663 | lock_flocks(); |
648 | for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) { | 664 | for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) { |
649 | if (!IS_POSIX(cfl)) | 665 | if (!IS_POSIX(cfl)) |
650 | continue; | 666 | continue; |
@@ -657,7 +673,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl) | |||
657 | fl->fl_pid = pid_vnr(cfl->fl_nspid); | 673 | fl->fl_pid = pid_vnr(cfl->fl_nspid); |
658 | } else | 674 | } else |
659 | fl->fl_type = F_UNLCK; | 675 | fl->fl_type = F_UNLCK; |
660 | unlock_kernel(); | 676 | unlock_flocks(); |
661 | return; | 677 | return; |
662 | } | 678 | } |
663 | EXPORT_SYMBOL(posix_test_lock); | 679 | EXPORT_SYMBOL(posix_test_lock); |
@@ -730,18 +746,16 @@ static int flock_lock_file(struct file *filp, struct file_lock *request) | |||
730 | int error = 0; | 746 | int error = 0; |
731 | int found = 0; | 747 | int found = 0; |
732 | 748 | ||
733 | lock_kernel(); | 749 | if (!(request->fl_flags & FL_ACCESS) && (request->fl_type != F_UNLCK)) { |
734 | if (request->fl_flags & FL_ACCESS) | ||
735 | goto find_conflict; | ||
736 | |||
737 | if (request->fl_type != F_UNLCK) { | ||
738 | error = -ENOMEM; | ||
739 | new_fl = locks_alloc_lock(); | 750 | new_fl = locks_alloc_lock(); |
740 | if (new_fl == NULL) | 751 | if (!new_fl) |
741 | goto out; | 752 | return -ENOMEM; |
742 | error = 0; | ||
743 | } | 753 | } |
744 | 754 | ||
755 | lock_flocks(); | ||
756 | if (request->fl_flags & FL_ACCESS) | ||
757 | goto find_conflict; | ||
758 | |||
745 | for_each_lock(inode, before) { | 759 | for_each_lock(inode, before) { |
746 | struct file_lock *fl = *before; | 760 | struct file_lock *fl = *before; |
747 | if (IS_POSIX(fl)) | 761 | if (IS_POSIX(fl)) |
@@ -767,8 +781,11 @@ static int flock_lock_file(struct file *filp, struct file_lock *request) | |||
767 | * If a higher-priority process was blocked on the old file lock, | 781 | * If a higher-priority process was blocked on the old file lock, |
768 | * give it the opportunity to lock the file. | 782 | * give it the opportunity to lock the file. |
769 | */ | 783 | */ |
770 | if (found) | 784 | if (found) { |
785 | unlock_flocks(); | ||
771 | cond_resched(); | 786 | cond_resched(); |
787 | lock_flocks(); | ||
788 | } | ||
772 | 789 | ||
773 | find_conflict: | 790 | find_conflict: |
774 | for_each_lock(inode, before) { | 791 | for_each_lock(inode, before) { |
@@ -794,7 +811,7 @@ find_conflict: | |||
794 | error = 0; | 811 | error = 0; |
795 | 812 | ||
796 | out: | 813 | out: |
797 | unlock_kernel(); | 814 | unlock_flocks(); |
798 | if (new_fl) | 815 | if (new_fl) |
799 | locks_free_lock(new_fl); | 816 | locks_free_lock(new_fl); |
800 | return error; | 817 | return error; |
@@ -823,7 +840,7 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str | |||
823 | new_fl2 = locks_alloc_lock(); | 840 | new_fl2 = locks_alloc_lock(); |
824 | } | 841 | } |
825 | 842 | ||
826 | lock_kernel(); | 843 | lock_flocks(); |
827 | if (request->fl_type != F_UNLCK) { | 844 | if (request->fl_type != F_UNLCK) { |
828 | for_each_lock(inode, before) { | 845 | for_each_lock(inode, before) { |
829 | fl = *before; | 846 | fl = *before; |
@@ -991,7 +1008,7 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str | |||
991 | locks_wake_up_blocks(left); | 1008 | locks_wake_up_blocks(left); |
992 | } | 1009 | } |
993 | out: | 1010 | out: |
994 | unlock_kernel(); | 1011 | unlock_flocks(); |
995 | /* | 1012 | /* |
996 | * Free any unused locks. | 1013 | * Free any unused locks. |
997 | */ | 1014 | */ |
@@ -1066,14 +1083,14 @@ int locks_mandatory_locked(struct inode *inode) | |||
1066 | /* | 1083 | /* |
1067 | * Search the lock list for this inode for any POSIX locks. | 1084 | * Search the lock list for this inode for any POSIX locks. |
1068 | */ | 1085 | */ |
1069 | lock_kernel(); | 1086 | lock_flocks(); |
1070 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { | 1087 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { |
1071 | if (!IS_POSIX(fl)) | 1088 | if (!IS_POSIX(fl)) |
1072 | continue; | 1089 | continue; |
1073 | if (fl->fl_owner != owner) | 1090 | if (fl->fl_owner != owner) |
1074 | break; | 1091 | break; |
1075 | } | 1092 | } |
1076 | unlock_kernel(); | 1093 | unlock_flocks(); |
1077 | return fl ? -EAGAIN : 0; | 1094 | return fl ? -EAGAIN : 0; |
1078 | } | 1095 | } |
1079 | 1096 | ||
@@ -1186,7 +1203,7 @@ int __break_lease(struct inode *inode, unsigned int mode) | |||
1186 | 1203 | ||
1187 | new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); | 1204 | new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); |
1188 | 1205 | ||
1189 | lock_kernel(); | 1206 | lock_flocks(); |
1190 | 1207 | ||
1191 | time_out_leases(inode); | 1208 | time_out_leases(inode); |
1192 | 1209 | ||
@@ -1247,8 +1264,10 @@ restart: | |||
1247 | break_time++; | 1264 | break_time++; |
1248 | } | 1265 | } |
1249 | locks_insert_block(flock, new_fl); | 1266 | locks_insert_block(flock, new_fl); |
1267 | unlock_flocks(); | ||
1250 | error = wait_event_interruptible_timeout(new_fl->fl_wait, | 1268 | error = wait_event_interruptible_timeout(new_fl->fl_wait, |
1251 | !new_fl->fl_next, break_time); | 1269 | !new_fl->fl_next, break_time); |
1270 | lock_flocks(); | ||
1252 | __locks_delete_block(new_fl); | 1271 | __locks_delete_block(new_fl); |
1253 | if (error >= 0) { | 1272 | if (error >= 0) { |
1254 | if (error == 0) | 1273 | if (error == 0) |
@@ -1263,7 +1282,7 @@ restart: | |||
1263 | } | 1282 | } |
1264 | 1283 | ||
1265 | out: | 1284 | out: |
1266 | unlock_kernel(); | 1285 | unlock_flocks(); |
1267 | if (!IS_ERR(new_fl)) | 1286 | if (!IS_ERR(new_fl)) |
1268 | locks_free_lock(new_fl); | 1287 | locks_free_lock(new_fl); |
1269 | return error; | 1288 | return error; |
@@ -1319,7 +1338,7 @@ int fcntl_getlease(struct file *filp) | |||
1319 | struct file_lock *fl; | 1338 | struct file_lock *fl; |
1320 | int type = F_UNLCK; | 1339 | int type = F_UNLCK; |
1321 | 1340 | ||
1322 | lock_kernel(); | 1341 | lock_flocks(); |
1323 | time_out_leases(filp->f_path.dentry->d_inode); | 1342 | time_out_leases(filp->f_path.dentry->d_inode); |
1324 | for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl); | 1343 | for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl); |
1325 | fl = fl->fl_next) { | 1344 | fl = fl->fl_next) { |
@@ -1328,7 +1347,7 @@ int fcntl_getlease(struct file *filp) | |||
1328 | break; | 1347 | break; |
1329 | } | 1348 | } |
1330 | } | 1349 | } |
1331 | unlock_kernel(); | 1350 | unlock_flocks(); |
1332 | return type; | 1351 | return type; |
1333 | } | 1352 | } |
1334 | 1353 | ||
@@ -1341,7 +1360,7 @@ int fcntl_getlease(struct file *filp) | |||
1341 | * The (input) flp->fl_lmops->fl_break function is required | 1360 | * The (input) flp->fl_lmops->fl_break function is required |
1342 | * by break_lease(). | 1361 | * by break_lease(). |
1343 | * | 1362 | * |
1344 | * Called with kernel lock held. | 1363 | * Called with file_lock_lock held. |
1345 | */ | 1364 | */ |
1346 | int generic_setlease(struct file *filp, long arg, struct file_lock **flp) | 1365 | int generic_setlease(struct file *filp, long arg, struct file_lock **flp) |
1347 | { | 1366 | { |
@@ -1436,7 +1455,15 @@ out: | |||
1436 | } | 1455 | } |
1437 | EXPORT_SYMBOL(generic_setlease); | 1456 | EXPORT_SYMBOL(generic_setlease); |
1438 | 1457 | ||
1439 | /** | 1458 | static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease) |
1459 | { | ||
1460 | if (filp->f_op && filp->f_op->setlease) | ||
1461 | return filp->f_op->setlease(filp, arg, lease); | ||
1462 | else | ||
1463 | return generic_setlease(filp, arg, lease); | ||
1464 | } | ||
1465 | |||
1466 | /** | ||
1440 | * vfs_setlease - sets a lease on an open file | 1467 | * vfs_setlease - sets a lease on an open file |
1441 | * @filp: file pointer | 1468 | * @filp: file pointer |
1442 | * @arg: type of lease to obtain | 1469 | * @arg: type of lease to obtain |
@@ -1467,12 +1494,9 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease) | |||
1467 | { | 1494 | { |
1468 | int error; | 1495 | int error; |
1469 | 1496 | ||
1470 | lock_kernel(); | 1497 | lock_flocks(); |
1471 | if (filp->f_op && filp->f_op->setlease) | 1498 | error = __vfs_setlease(filp, arg, lease); |
1472 | error = filp->f_op->setlease(filp, arg, lease); | 1499 | unlock_flocks(); |
1473 | else | ||
1474 | error = generic_setlease(filp, arg, lease); | ||
1475 | unlock_kernel(); | ||
1476 | 1500 | ||
1477 | return error; | 1501 | return error; |
1478 | } | 1502 | } |
@@ -1499,9 +1523,9 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg) | |||
1499 | if (error) | 1523 | if (error) |
1500 | return error; | 1524 | return error; |
1501 | 1525 | ||
1502 | lock_kernel(); | 1526 | lock_flocks(); |
1503 | 1527 | ||
1504 | error = vfs_setlease(filp, arg, &flp); | 1528 | error = __vfs_setlease(filp, arg, &flp); |
1505 | if (error || arg == F_UNLCK) | 1529 | if (error || arg == F_UNLCK) |
1506 | goto out_unlock; | 1530 | goto out_unlock; |
1507 | 1531 | ||
@@ -1516,7 +1540,7 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg) | |||
1516 | 1540 | ||
1517 | error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); | 1541 | error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); |
1518 | out_unlock: | 1542 | out_unlock: |
1519 | unlock_kernel(); | 1543 | unlock_flocks(); |
1520 | return error; | 1544 | return error; |
1521 | } | 1545 | } |
1522 | 1546 | ||
@@ -2020,7 +2044,7 @@ void locks_remove_flock(struct file *filp) | |||
2020 | fl.fl_ops->fl_release_private(&fl); | 2044 | fl.fl_ops->fl_release_private(&fl); |
2021 | } | 2045 | } |
2022 | 2046 | ||
2023 | lock_kernel(); | 2047 | lock_flocks(); |
2024 | before = &inode->i_flock; | 2048 | before = &inode->i_flock; |
2025 | 2049 | ||
2026 | while ((fl = *before) != NULL) { | 2050 | while ((fl = *before) != NULL) { |
@@ -2038,7 +2062,7 @@ void locks_remove_flock(struct file *filp) | |||
2038 | } | 2062 | } |
2039 | before = &fl->fl_next; | 2063 | before = &fl->fl_next; |
2040 | } | 2064 | } |
2041 | unlock_kernel(); | 2065 | unlock_flocks(); |
2042 | } | 2066 | } |
2043 | 2067 | ||
2044 | /** | 2068 | /** |
@@ -2053,12 +2077,12 @@ posix_unblock_lock(struct file *filp, struct file_lock *waiter) | |||
2053 | { | 2077 | { |
2054 | int status = 0; | 2078 | int status = 0; |
2055 | 2079 | ||
2056 | lock_kernel(); | 2080 | lock_flocks(); |
2057 | if (waiter->fl_next) | 2081 | if (waiter->fl_next) |
2058 | __locks_delete_block(waiter); | 2082 | __locks_delete_block(waiter); |
2059 | else | 2083 | else |
2060 | status = -ENOENT; | 2084 | status = -ENOENT; |
2061 | unlock_kernel(); | 2085 | unlock_flocks(); |
2062 | return status; | 2086 | return status; |
2063 | } | 2087 | } |
2064 | 2088 | ||
@@ -2172,7 +2196,7 @@ static int locks_show(struct seq_file *f, void *v) | |||
2172 | 2196 | ||
2173 | static void *locks_start(struct seq_file *f, loff_t *pos) | 2197 | static void *locks_start(struct seq_file *f, loff_t *pos) |
2174 | { | 2198 | { |
2175 | lock_kernel(); | 2199 | lock_flocks(); |
2176 | f->private = (void *)1; | 2200 | f->private = (void *)1; |
2177 | return seq_list_start(&file_lock_list, *pos); | 2201 | return seq_list_start(&file_lock_list, *pos); |
2178 | } | 2202 | } |
@@ -2184,7 +2208,7 @@ static void *locks_next(struct seq_file *f, void *v, loff_t *pos) | |||
2184 | 2208 | ||
2185 | static void locks_stop(struct seq_file *f, void *v) | 2209 | static void locks_stop(struct seq_file *f, void *v) |
2186 | { | 2210 | { |
2187 | unlock_kernel(); | 2211 | unlock_flocks(); |
2188 | } | 2212 | } |
2189 | 2213 | ||
2190 | static const struct seq_operations locks_seq_operations = { | 2214 | static const struct seq_operations locks_seq_operations = { |
@@ -2231,7 +2255,7 @@ int lock_may_read(struct inode *inode, loff_t start, unsigned long len) | |||
2231 | { | 2255 | { |
2232 | struct file_lock *fl; | 2256 | struct file_lock *fl; |
2233 | int result = 1; | 2257 | int result = 1; |
2234 | lock_kernel(); | 2258 | lock_flocks(); |
2235 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { | 2259 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { |
2236 | if (IS_POSIX(fl)) { | 2260 | if (IS_POSIX(fl)) { |
2237 | if (fl->fl_type == F_RDLCK) | 2261 | if (fl->fl_type == F_RDLCK) |
@@ -2248,7 +2272,7 @@ int lock_may_read(struct inode *inode, loff_t start, unsigned long len) | |||
2248 | result = 0; | 2272 | result = 0; |
2249 | break; | 2273 | break; |
2250 | } | 2274 | } |
2251 | unlock_kernel(); | 2275 | unlock_flocks(); |
2252 | return result; | 2276 | return result; |
2253 | } | 2277 | } |
2254 | 2278 | ||
@@ -2271,7 +2295,7 @@ int lock_may_write(struct inode *inode, loff_t start, unsigned long len) | |||
2271 | { | 2295 | { |
2272 | struct file_lock *fl; | 2296 | struct file_lock *fl; |
2273 | int result = 1; | 2297 | int result = 1; |
2274 | lock_kernel(); | 2298 | lock_flocks(); |
2275 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { | 2299 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { |
2276 | if (IS_POSIX(fl)) { | 2300 | if (IS_POSIX(fl)) { |
2277 | if ((fl->fl_end < start) || (fl->fl_start > (start + len))) | 2301 | if ((fl->fl_end < start) || (fl->fl_start > (start + len))) |
@@ -2286,7 +2310,7 @@ int lock_may_write(struct inode *inode, loff_t start, unsigned long len) | |||
2286 | result = 0; | 2310 | result = 0; |
2287 | break; | 2311 | break; |
2288 | } | 2312 | } |
2289 | unlock_kernel(); | 2313 | unlock_flocks(); |
2290 | return result; | 2314 | return result; |
2291 | } | 2315 | } |
2292 | 2316 | ||
diff --git a/fs/namespace.c b/fs/namespace.c index a72eaabfe8f2..7ca5182c0bed 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -1744,9 +1744,7 @@ static int do_new_mount(struct path *path, char *type, int flags, | |||
1744 | if (!capable(CAP_SYS_ADMIN)) | 1744 | if (!capable(CAP_SYS_ADMIN)) |
1745 | return -EPERM; | 1745 | return -EPERM; |
1746 | 1746 | ||
1747 | lock_kernel(); | ||
1748 | mnt = do_kern_mount(type, flags, name, data); | 1747 | mnt = do_kern_mount(type, flags, name, data); |
1749 | unlock_kernel(); | ||
1750 | if (IS_ERR(mnt)) | 1748 | if (IS_ERR(mnt)) |
1751 | return PTR_ERR(mnt); | 1749 | return PTR_ERR(mnt); |
1752 | 1750 | ||
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 9578cbe0cd58..aac8832e919e 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c | |||
@@ -95,6 +95,34 @@ const struct dentry_operations ncp_root_dentry_operations = | |||
95 | }; | 95 | }; |
96 | 96 | ||
97 | 97 | ||
98 | #define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber]) | ||
99 | |||
100 | static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator) | ||
101 | { | ||
102 | #ifdef CONFIG_NCPFS_SMALLDOS | ||
103 | int ns = ncp_namespace(i); | ||
104 | |||
105 | if ((ns == NW_NS_DOS) | ||
106 | #ifdef CONFIG_NCPFS_OS2_NS | ||
107 | || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS)) | ||
108 | #endif /* CONFIG_NCPFS_OS2_NS */ | ||
109 | ) | ||
110 | return 0; | ||
111 | #endif /* CONFIG_NCPFS_SMALLDOS */ | ||
112 | return 1; | ||
113 | } | ||
114 | |||
115 | #define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS) | ||
116 | |||
117 | static inline int ncp_case_sensitive(struct dentry *dentry) | ||
118 | { | ||
119 | #ifdef CONFIG_NCPFS_NFS_NS | ||
120 | return ncp_namespace(dentry->d_inode) == NW_NS_NFS; | ||
121 | #else | ||
122 | return 0; | ||
123 | #endif /* CONFIG_NCPFS_NFS_NS */ | ||
124 | } | ||
125 | |||
98 | /* | 126 | /* |
99 | * Note: leave the hash unchanged if the directory | 127 | * Note: leave the hash unchanged if the directory |
100 | * is case-sensitive. | 128 | * is case-sensitive. |
@@ -102,13 +130,12 @@ const struct dentry_operations ncp_root_dentry_operations = | |||
102 | static int | 130 | static int |
103 | ncp_hash_dentry(struct dentry *dentry, struct qstr *this) | 131 | ncp_hash_dentry(struct dentry *dentry, struct qstr *this) |
104 | { | 132 | { |
105 | struct nls_table *t; | 133 | if (!ncp_case_sensitive(dentry)) { |
106 | unsigned long hash; | 134 | struct nls_table *t; |
107 | int i; | 135 | unsigned long hash; |
108 | 136 | int i; | |
109 | t = NCP_IO_TABLE(dentry); | ||
110 | 137 | ||
111 | if (!ncp_case_sensitive(dentry->d_inode)) { | 138 | t = NCP_IO_TABLE(dentry); |
112 | hash = init_name_hash(); | 139 | hash = init_name_hash(); |
113 | for (i=0; i<this->len ; i++) | 140 | for (i=0; i<this->len ; i++) |
114 | hash = partial_name_hash(ncp_tolower(t, this->name[i]), | 141 | hash = partial_name_hash(ncp_tolower(t, this->name[i]), |
@@ -124,7 +151,7 @@ ncp_compare_dentry(struct dentry *dentry, struct qstr *a, struct qstr *b) | |||
124 | if (a->len != b->len) | 151 | if (a->len != b->len) |
125 | return 1; | 152 | return 1; |
126 | 153 | ||
127 | if (ncp_case_sensitive(dentry->d_inode)) | 154 | if (ncp_case_sensitive(dentry)) |
128 | return strncmp(a->name, b->name, a->len); | 155 | return strncmp(a->name, b->name, a->len); |
129 | 156 | ||
130 | return ncp_strnicmp(NCP_IO_TABLE(dentry), a->name, b->name, a->len); | 157 | return ncp_strnicmp(NCP_IO_TABLE(dentry), a->name, b->name, a->len); |
@@ -266,7 +293,7 @@ leave_me:; | |||
266 | 293 | ||
267 | 294 | ||
268 | static int | 295 | static int |
269 | __ncp_lookup_validate(struct dentry *dentry) | 296 | ncp_lookup_validate(struct dentry *dentry, struct nameidata *nd) |
270 | { | 297 | { |
271 | struct ncp_server *server; | 298 | struct ncp_server *server; |
272 | struct dentry *parent; | 299 | struct dentry *parent; |
@@ -283,9 +310,6 @@ __ncp_lookup_validate(struct dentry *dentry) | |||
283 | 310 | ||
284 | server = NCP_SERVER(dir); | 311 | server = NCP_SERVER(dir); |
285 | 312 | ||
286 | if (!ncp_conn_valid(server)) | ||
287 | goto finished; | ||
288 | |||
289 | /* | 313 | /* |
290 | * Inspired by smbfs: | 314 | * Inspired by smbfs: |
291 | * The default validation is based on dentry age: | 315 | * The default validation is based on dentry age: |
@@ -304,8 +328,11 @@ __ncp_lookup_validate(struct dentry *dentry) | |||
304 | if (ncp_is_server_root(dir)) { | 328 | if (ncp_is_server_root(dir)) { |
305 | res = ncp_io2vol(server, __name, &len, dentry->d_name.name, | 329 | res = ncp_io2vol(server, __name, &len, dentry->d_name.name, |
306 | dentry->d_name.len, 1); | 330 | dentry->d_name.len, 1); |
307 | if (!res) | 331 | if (!res) { |
308 | res = ncp_lookup_volume(server, __name, &(finfo.i)); | 332 | res = ncp_lookup_volume(server, __name, &(finfo.i)); |
333 | if (!res) | ||
334 | ncp_update_known_namespace(server, finfo.i.volNumber, NULL); | ||
335 | } | ||
309 | } else { | 336 | } else { |
310 | res = ncp_io2vol(server, __name, &len, dentry->d_name.name, | 337 | res = ncp_io2vol(server, __name, &len, dentry->d_name.name, |
311 | dentry->d_name.len, !ncp_preserve_case(dir)); | 338 | dentry->d_name.len, !ncp_preserve_case(dir)); |
@@ -320,13 +347,17 @@ __ncp_lookup_validate(struct dentry *dentry) | |||
320 | * what we remember, it's not valid any more. | 347 | * what we remember, it's not valid any more. |
321 | */ | 348 | */ |
322 | if (!res) { | 349 | if (!res) { |
323 | if (finfo.i.dirEntNum == NCP_FINFO(dentry->d_inode)->dirEntNum) { | 350 | struct inode *inode = dentry->d_inode; |
351 | |||
352 | mutex_lock(&inode->i_mutex); | ||
353 | if (finfo.i.dirEntNum == NCP_FINFO(inode)->dirEntNum) { | ||
324 | ncp_new_dentry(dentry); | 354 | ncp_new_dentry(dentry); |
325 | val=1; | 355 | val=1; |
326 | } else | 356 | } else |
327 | DDPRINTK("ncp_lookup_validate: found, but dirEntNum changed\n"); | 357 | DDPRINTK("ncp_lookup_validate: found, but dirEntNum changed\n"); |
328 | 358 | ||
329 | ncp_update_inode2(dentry->d_inode, &finfo); | 359 | ncp_update_inode2(inode, &finfo); |
360 | mutex_unlock(&inode->i_mutex); | ||
330 | } | 361 | } |
331 | 362 | ||
332 | finished: | 363 | finished: |
@@ -335,16 +366,6 @@ finished: | |||
335 | return val; | 366 | return val; |
336 | } | 367 | } |
337 | 368 | ||
338 | static int | ||
339 | ncp_lookup_validate(struct dentry * dentry, struct nameidata *nd) | ||
340 | { | ||
341 | int res; | ||
342 | lock_kernel(); | ||
343 | res = __ncp_lookup_validate(dentry); | ||
344 | unlock_kernel(); | ||
345 | return res; | ||
346 | } | ||
347 | |||
348 | static struct dentry * | 369 | static struct dentry * |
349 | ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos) | 370 | ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos) |
350 | { | 371 | { |
@@ -411,8 +432,6 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
411 | int result, mtime_valid = 0; | 432 | int result, mtime_valid = 0; |
412 | time_t mtime = 0; | 433 | time_t mtime = 0; |
413 | 434 | ||
414 | lock_kernel(); | ||
415 | |||
416 | ctl.page = NULL; | 435 | ctl.page = NULL; |
417 | ctl.cache = NULL; | 436 | ctl.cache = NULL; |
418 | 437 | ||
@@ -421,6 +440,7 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
421 | (int) filp->f_pos); | 440 | (int) filp->f_pos); |
422 | 441 | ||
423 | result = -EIO; | 442 | result = -EIO; |
443 | /* Do not generate '.' and '..' when server is dead. */ | ||
424 | if (!ncp_conn_valid(server)) | 444 | if (!ncp_conn_valid(server)) |
425 | goto out; | 445 | goto out; |
426 | 446 | ||
@@ -532,6 +552,12 @@ read_really: | |||
532 | ctl.head.end = ctl.fpos - 1; | 552 | ctl.head.end = ctl.fpos - 1; |
533 | ctl.head.eof = ctl.valid; | 553 | ctl.head.eof = ctl.valid; |
534 | finished: | 554 | finished: |
555 | if (ctl.page) { | ||
556 | kunmap(ctl.page); | ||
557 | SetPageUptodate(ctl.page); | ||
558 | unlock_page(ctl.page); | ||
559 | page_cache_release(ctl.page); | ||
560 | } | ||
535 | if (page) { | 561 | if (page) { |
536 | cache->head = ctl.head; | 562 | cache->head = ctl.head; |
537 | kunmap(page); | 563 | kunmap(page); |
@@ -539,23 +565,17 @@ finished: | |||
539 | unlock_page(page); | 565 | unlock_page(page); |
540 | page_cache_release(page); | 566 | page_cache_release(page); |
541 | } | 567 | } |
542 | if (ctl.page) { | ||
543 | kunmap(ctl.page); | ||
544 | SetPageUptodate(ctl.page); | ||
545 | unlock_page(ctl.page); | ||
546 | page_cache_release(ctl.page); | ||
547 | } | ||
548 | out: | 568 | out: |
549 | unlock_kernel(); | ||
550 | return result; | 569 | return result; |
551 | } | 570 | } |
552 | 571 | ||
553 | static int | 572 | static int |
554 | ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, | 573 | ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, |
555 | struct ncp_cache_control *ctrl, struct ncp_entry_info *entry) | 574 | struct ncp_cache_control *ctrl, struct ncp_entry_info *entry, |
575 | int inval_childs) | ||
556 | { | 576 | { |
557 | struct dentry *newdent, *dentry = filp->f_path.dentry; | 577 | struct dentry *newdent, *dentry = filp->f_path.dentry; |
558 | struct inode *newino, *inode = dentry->d_inode; | 578 | struct inode *dir = dentry->d_inode; |
559 | struct ncp_cache_control ctl = *ctrl; | 579 | struct ncp_cache_control ctl = *ctrl; |
560 | struct qstr qname; | 580 | struct qstr qname; |
561 | int valid = 0; | 581 | int valid = 0; |
@@ -564,9 +584,9 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, | |||
564 | __u8 __name[NCP_MAXPATHLEN + 1]; | 584 | __u8 __name[NCP_MAXPATHLEN + 1]; |
565 | 585 | ||
566 | qname.len = sizeof(__name); | 586 | qname.len = sizeof(__name); |
567 | if (ncp_vol2io(NCP_SERVER(inode), __name, &qname.len, | 587 | if (ncp_vol2io(NCP_SERVER(dir), __name, &qname.len, |
568 | entry->i.entryName, entry->i.nameLen, | 588 | entry->i.entryName, entry->i.nameLen, |
569 | !ncp_preserve_entry_case(inode, entry->i.NSCreator))) | 589 | !ncp_preserve_entry_case(dir, entry->i.NSCreator))) |
570 | return 1; /* I'm not sure */ | 590 | return 1; /* I'm not sure */ |
571 | 591 | ||
572 | qname.name = __name; | 592 | qname.name = __name; |
@@ -584,22 +604,64 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, | |||
584 | goto end_advance; | 604 | goto end_advance; |
585 | } else { | 605 | } else { |
586 | hashed = 1; | 606 | hashed = 1; |
587 | memcpy((char *) newdent->d_name.name, qname.name, | 607 | |
588 | newdent->d_name.len); | 608 | /* If case sensitivity changed for this volume, all entries below this one |
609 | should be thrown away. This entry itself is not affected, as its case | ||
610 | sensitivity is controlled by its own parent. */ | ||
611 | if (inval_childs) | ||
612 | shrink_dcache_parent(newdent); | ||
613 | |||
614 | /* | ||
615 | * It is not as dangerous as it looks. NetWare's OS2 namespace is | ||
616 | * case preserving yet case insensitive. So we update dentry's name | ||
617 | * as received from server. We found dentry via d_lookup with our | ||
618 | * hash, so we know that hash does not change, and so replacing name | ||
619 | * should be reasonably safe. | ||
620 | */ | ||
621 | if (qname.len == newdent->d_name.len && | ||
622 | memcmp(newdent->d_name.name, qname.name, newdent->d_name.len)) { | ||
623 | struct inode *inode = newdent->d_inode; | ||
624 | |||
625 | /* | ||
626 | * Inside ncpfs all uses of d_name are either for debugging, | ||
627 | * or on functions which acquire inode mutex (mknod, creat, | ||
628 | * lookup). So grab i_mutex here, to be sure. d_path | ||
629 | * uses dcache_lock when generating path, so we should too. | ||
630 | * And finally d_compare is protected by dentry's d_lock, so | ||
631 | * here we go. | ||
632 | */ | ||
633 | if (inode) | ||
634 | mutex_lock(&inode->i_mutex); | ||
635 | spin_lock(&dcache_lock); | ||
636 | spin_lock(&newdent->d_lock); | ||
637 | memcpy((char *) newdent->d_name.name, qname.name, | ||
638 | newdent->d_name.len); | ||
639 | spin_unlock(&newdent->d_lock); | ||
640 | spin_unlock(&dcache_lock); | ||
641 | if (inode) | ||
642 | mutex_unlock(&inode->i_mutex); | ||
643 | } | ||
589 | } | 644 | } |
590 | 645 | ||
591 | if (!newdent->d_inode) { | 646 | if (!newdent->d_inode) { |
647 | struct inode *inode; | ||
648 | |||
592 | entry->opened = 0; | 649 | entry->opened = 0; |
593 | entry->ino = iunique(inode->i_sb, 2); | 650 | entry->ino = iunique(dir->i_sb, 2); |
594 | newino = ncp_iget(inode->i_sb, entry); | 651 | inode = ncp_iget(dir->i_sb, entry); |
595 | if (newino) { | 652 | if (inode) { |
596 | newdent->d_op = &ncp_dentry_operations; | 653 | newdent->d_op = &ncp_dentry_operations; |
597 | d_instantiate(newdent, newino); | 654 | d_instantiate(newdent, inode); |
598 | if (!hashed) | 655 | if (!hashed) |
599 | d_rehash(newdent); | 656 | d_rehash(newdent); |
600 | } | 657 | } |
601 | } else | 658 | } else { |
602 | ncp_update_inode2(newdent->d_inode, entry); | 659 | struct inode *inode = newdent->d_inode; |
660 | |||
661 | mutex_lock(&inode->i_mutex); | ||
662 | ncp_update_inode2(inode, entry); | ||
663 | mutex_unlock(&inode->i_mutex); | ||
664 | } | ||
603 | 665 | ||
604 | if (newdent->d_inode) { | 666 | if (newdent->d_inode) { |
605 | ino = newdent->d_inode->i_ino; | 667 | ino = newdent->d_inode->i_ino; |
@@ -617,7 +679,7 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, | |||
617 | ctl.cache = NULL; | 679 | ctl.cache = NULL; |
618 | ctl.idx -= NCP_DIRCACHE_SIZE; | 680 | ctl.idx -= NCP_DIRCACHE_SIZE; |
619 | ctl.ofs += 1; | 681 | ctl.ofs += 1; |
620 | ctl.page = grab_cache_page(&inode->i_data, ctl.ofs); | 682 | ctl.page = grab_cache_page(&dir->i_data, ctl.ofs); |
621 | if (ctl.page) | 683 | if (ctl.page) |
622 | ctl.cache = kmap(ctl.page); | 684 | ctl.cache = kmap(ctl.page); |
623 | } | 685 | } |
@@ -633,7 +695,7 @@ end_advance: | |||
633 | if (!ino) | 695 | if (!ino) |
634 | ino = find_inode_number(dentry, &qname); | 696 | ino = find_inode_number(dentry, &qname); |
635 | if (!ino) | 697 | if (!ino) |
636 | ino = iunique(inode->i_sb, 2); | 698 | ino = iunique(dir->i_sb, 2); |
637 | ctl.filled = filldir(dirent, qname.name, qname.len, | 699 | ctl.filled = filldir(dirent, qname.name, qname.len, |
638 | filp->f_pos, ino, DT_UNKNOWN); | 700 | filp->f_pos, ino, DT_UNKNOWN); |
639 | if (!ctl.filled) | 701 | if (!ctl.filled) |
@@ -660,6 +722,7 @@ ncp_read_volume_list(struct file *filp, void *dirent, filldir_t filldir, | |||
660 | (unsigned long) filp->f_pos); | 722 | (unsigned long) filp->f_pos); |
661 | 723 | ||
662 | for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) { | 724 | for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) { |
725 | int inval_dentry; | ||
663 | 726 | ||
664 | if (ncp_get_volume_info_with_number(server, i, &info) != 0) | 727 | if (ncp_get_volume_info_with_number(server, i, &info) != 0) |
665 | return; | 728 | return; |
@@ -675,8 +738,9 @@ ncp_read_volume_list(struct file *filp, void *dirent, filldir_t filldir, | |||
675 | info.volume_name); | 738 | info.volume_name); |
676 | continue; | 739 | continue; |
677 | } | 740 | } |
741 | inval_dentry = ncp_update_known_namespace(server, entry.i.volNumber, NULL); | ||
678 | entry.volume = entry.i.volNumber; | 742 | entry.volume = entry.i.volNumber; |
679 | if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry)) | 743 | if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry, inval_dentry)) |
680 | return; | 744 | return; |
681 | } | 745 | } |
682 | } | 746 | } |
@@ -739,7 +803,7 @@ ncp_do_readdir(struct file *filp, void *dirent, filldir_t filldir, | |||
739 | rpl += onerpl; | 803 | rpl += onerpl; |
740 | rpls -= onerpl; | 804 | rpls -= onerpl; |
741 | entry.volume = entry.i.volNumber; | 805 | entry.volume = entry.i.volNumber; |
742 | if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry)) | 806 | if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry, 0)) |
743 | break; | 807 | break; |
744 | } | 808 | } |
745 | } while (more); | 809 | } while (more); |
@@ -775,17 +839,19 @@ int ncp_conn_logged_in(struct super_block *sb) | |||
775 | if (dent) { | 839 | if (dent) { |
776 | struct inode* ino = dent->d_inode; | 840 | struct inode* ino = dent->d_inode; |
777 | if (ino) { | 841 | if (ino) { |
842 | ncp_update_known_namespace(server, volNumber, NULL); | ||
778 | NCP_FINFO(ino)->volNumber = volNumber; | 843 | NCP_FINFO(ino)->volNumber = volNumber; |
779 | NCP_FINFO(ino)->dirEntNum = dirEntNum; | 844 | NCP_FINFO(ino)->dirEntNum = dirEntNum; |
780 | NCP_FINFO(ino)->DosDirNum = DosDirNum; | 845 | NCP_FINFO(ino)->DosDirNum = DosDirNum; |
846 | result = 0; | ||
781 | } else { | 847 | } else { |
782 | DPRINTK("ncpfs: sb->s_root->d_inode == NULL!\n"); | 848 | DPRINTK("ncpfs: sb->s_root->d_inode == NULL!\n"); |
783 | } | 849 | } |
784 | } else { | 850 | } else { |
785 | DPRINTK("ncpfs: sb->s_root == NULL!\n"); | 851 | DPRINTK("ncpfs: sb->s_root == NULL!\n"); |
786 | } | 852 | } |
787 | } | 853 | } else |
788 | result = 0; | 854 | result = 0; |
789 | 855 | ||
790 | out: | 856 | out: |
791 | return result; | 857 | return result; |
@@ -799,7 +865,6 @@ static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, struc | |||
799 | int error, res, len; | 865 | int error, res, len; |
800 | __u8 __name[NCP_MAXPATHLEN + 1]; | 866 | __u8 __name[NCP_MAXPATHLEN + 1]; |
801 | 867 | ||
802 | lock_kernel(); | ||
803 | error = -EIO; | 868 | error = -EIO; |
804 | if (!ncp_conn_valid(server)) | 869 | if (!ncp_conn_valid(server)) |
805 | goto finished; | 870 | goto finished; |
@@ -813,6 +878,8 @@ static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, struc | |||
813 | dentry->d_name.len, 1); | 878 | dentry->d_name.len, 1); |
814 | if (!res) | 879 | if (!res) |
815 | res = ncp_lookup_volume(server, __name, &(finfo.i)); | 880 | res = ncp_lookup_volume(server, __name, &(finfo.i)); |
881 | if (!res) | ||
882 | ncp_update_known_namespace(server, finfo.i.volNumber, NULL); | ||
816 | } else { | 883 | } else { |
817 | res = ncp_io2vol(server, __name, &len, dentry->d_name.name, | 884 | res = ncp_io2vol(server, __name, &len, dentry->d_name.name, |
818 | dentry->d_name.len, !ncp_preserve_case(dir)); | 885 | dentry->d_name.len, !ncp_preserve_case(dir)); |
@@ -846,7 +913,6 @@ add_entry: | |||
846 | 913 | ||
847 | finished: | 914 | finished: |
848 | PPRINTK("ncp_lookup: result=%d\n", error); | 915 | PPRINTK("ncp_lookup: result=%d\n", error); |
849 | unlock_kernel(); | ||
850 | return ERR_PTR(error); | 916 | return ERR_PTR(error); |
851 | } | 917 | } |
852 | 918 | ||
@@ -887,11 +953,6 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode, | |||
887 | PPRINTK("ncp_create_new: creating %s/%s, mode=%x\n", | 953 | PPRINTK("ncp_create_new: creating %s/%s, mode=%x\n", |
888 | dentry->d_parent->d_name.name, dentry->d_name.name, mode); | 954 | dentry->d_parent->d_name.name, dentry->d_name.name, mode); |
889 | 955 | ||
890 | error = -EIO; | ||
891 | lock_kernel(); | ||
892 | if (!ncp_conn_valid(server)) | ||
893 | goto out; | ||
894 | |||
895 | ncp_age_dentry(server, dentry); | 956 | ncp_age_dentry(server, dentry); |
896 | len = sizeof(__name); | 957 | len = sizeof(__name); |
897 | error = ncp_io2vol(server, __name, &len, dentry->d_name.name, | 958 | error = ncp_io2vol(server, __name, &len, dentry->d_name.name, |
@@ -917,6 +978,8 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode, | |||
917 | if (result) { | 978 | if (result) { |
918 | if (result == 0x87) | 979 | if (result == 0x87) |
919 | error = -ENAMETOOLONG; | 980 | error = -ENAMETOOLONG; |
981 | else if (result < 0) | ||
982 | error = result; | ||
920 | DPRINTK("ncp_create: %s/%s failed\n", | 983 | DPRINTK("ncp_create: %s/%s failed\n", |
921 | dentry->d_parent->d_name.name, dentry->d_name.name); | 984 | dentry->d_parent->d_name.name, dentry->d_name.name); |
922 | goto out; | 985 | goto out; |
@@ -935,7 +998,6 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode, | |||
935 | 998 | ||
936 | error = ncp_instantiate(dir, dentry, &finfo); | 999 | error = ncp_instantiate(dir, dentry, &finfo); |
937 | out: | 1000 | out: |
938 | unlock_kernel(); | ||
939 | return error; | 1001 | return error; |
940 | } | 1002 | } |
941 | 1003 | ||
@@ -955,11 +1017,6 @@ static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
955 | DPRINTK("ncp_mkdir: making %s/%s\n", | 1017 | DPRINTK("ncp_mkdir: making %s/%s\n", |
956 | dentry->d_parent->d_name.name, dentry->d_name.name); | 1018 | dentry->d_parent->d_name.name, dentry->d_name.name); |
957 | 1019 | ||
958 | error = -EIO; | ||
959 | lock_kernel(); | ||
960 | if (!ncp_conn_valid(server)) | ||
961 | goto out; | ||
962 | |||
963 | ncp_age_dentry(server, dentry); | 1020 | ncp_age_dentry(server, dentry); |
964 | len = sizeof(__name); | 1021 | len = sizeof(__name); |
965 | error = ncp_io2vol(server, __name, &len, dentry->d_name.name, | 1022 | error = ncp_io2vol(server, __name, &len, dentry->d_name.name, |
@@ -967,12 +1024,11 @@ static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
967 | if (error) | 1024 | if (error) |
968 | goto out; | 1025 | goto out; |
969 | 1026 | ||
970 | error = -EACCES; | 1027 | error = ncp_open_create_file_or_subdir(server, dir, __name, |
971 | if (ncp_open_create_file_or_subdir(server, dir, __name, | ||
972 | OC_MODE_CREATE, aDIR, | 1028 | OC_MODE_CREATE, aDIR, |
973 | cpu_to_le16(0xffff), | 1029 | cpu_to_le16(0xffff), |
974 | &finfo) == 0) | 1030 | &finfo); |
975 | { | 1031 | if (error == 0) { |
976 | if (ncp_is_nfs_extras(server, finfo.volume)) { | 1032 | if (ncp_is_nfs_extras(server, finfo.volume)) { |
977 | mode |= S_IFDIR; | 1033 | mode |= S_IFDIR; |
978 | finfo.i.nfs.mode = mode; | 1034 | finfo.i.nfs.mode = mode; |
@@ -983,9 +1039,10 @@ static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
983 | goto out; | 1039 | goto out; |
984 | } | 1040 | } |
985 | error = ncp_instantiate(dir, dentry, &finfo); | 1041 | error = ncp_instantiate(dir, dentry, &finfo); |
1042 | } else if (error > 0) { | ||
1043 | error = -EACCES; | ||
986 | } | 1044 | } |
987 | out: | 1045 | out: |
988 | unlock_kernel(); | ||
989 | return error; | 1046 | return error; |
990 | } | 1047 | } |
991 | 1048 | ||
@@ -998,11 +1055,6 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry) | |||
998 | DPRINTK("ncp_rmdir: removing %s/%s\n", | 1055 | DPRINTK("ncp_rmdir: removing %s/%s\n", |
999 | dentry->d_parent->d_name.name, dentry->d_name.name); | 1056 | dentry->d_parent->d_name.name, dentry->d_name.name); |
1000 | 1057 | ||
1001 | error = -EIO; | ||
1002 | lock_kernel(); | ||
1003 | if (!ncp_conn_valid(server)) | ||
1004 | goto out; | ||
1005 | |||
1006 | error = -EBUSY; | 1058 | error = -EBUSY; |
1007 | if (!d_unhashed(dentry)) | 1059 | if (!d_unhashed(dentry)) |
1008 | goto out; | 1060 | goto out; |
@@ -1036,11 +1088,10 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry) | |||
1036 | error = -ENOENT; | 1088 | error = -ENOENT; |
1037 | break; | 1089 | break; |
1038 | default: | 1090 | default: |
1039 | error = -EACCES; | 1091 | error = result < 0 ? result : -EACCES; |
1040 | break; | 1092 | break; |
1041 | } | 1093 | } |
1042 | out: | 1094 | out: |
1043 | unlock_kernel(); | ||
1044 | return error; | 1095 | return error; |
1045 | } | 1096 | } |
1046 | 1097 | ||
@@ -1050,15 +1101,10 @@ static int ncp_unlink(struct inode *dir, struct dentry *dentry) | |||
1050 | struct ncp_server *server; | 1101 | struct ncp_server *server; |
1051 | int error; | 1102 | int error; |
1052 | 1103 | ||
1053 | lock_kernel(); | ||
1054 | server = NCP_SERVER(dir); | 1104 | server = NCP_SERVER(dir); |
1055 | DPRINTK("ncp_unlink: unlinking %s/%s\n", | 1105 | DPRINTK("ncp_unlink: unlinking %s/%s\n", |
1056 | dentry->d_parent->d_name.name, dentry->d_name.name); | 1106 | dentry->d_parent->d_name.name, dentry->d_name.name); |
1057 | 1107 | ||
1058 | error = -EIO; | ||
1059 | if (!ncp_conn_valid(server)) | ||
1060 | goto out; | ||
1061 | |||
1062 | /* | 1108 | /* |
1063 | * Check whether to close the file ... | 1109 | * Check whether to close the file ... |
1064 | */ | 1110 | */ |
@@ -1097,12 +1143,9 @@ static int ncp_unlink(struct inode *dir, struct dentry *dentry) | |||
1097 | error = -ENOENT; | 1143 | error = -ENOENT; |
1098 | break; | 1144 | break; |
1099 | default: | 1145 | default: |
1100 | error = -EACCES; | 1146 | error = error < 0 ? error : -EACCES; |
1101 | break; | 1147 | break; |
1102 | } | 1148 | } |
1103 | |||
1104 | out: | ||
1105 | unlock_kernel(); | ||
1106 | return error; | 1149 | return error; |
1107 | } | 1150 | } |
1108 | 1151 | ||
@@ -1118,11 +1161,6 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1118 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, | 1161 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, |
1119 | new_dentry->d_parent->d_name.name, new_dentry->d_name.name); | 1162 | new_dentry->d_parent->d_name.name, new_dentry->d_name.name); |
1120 | 1163 | ||
1121 | error = -EIO; | ||
1122 | lock_kernel(); | ||
1123 | if (!ncp_conn_valid(server)) | ||
1124 | goto out; | ||
1125 | |||
1126 | ncp_age_dentry(server, old_dentry); | 1164 | ncp_age_dentry(server, old_dentry); |
1127 | ncp_age_dentry(server, new_dentry); | 1165 | ncp_age_dentry(server, new_dentry); |
1128 | 1166 | ||
@@ -1161,11 +1199,10 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1161 | error = -ENOENT; | 1199 | error = -ENOENT; |
1162 | break; | 1200 | break; |
1163 | default: | 1201 | default: |
1164 | error = -EACCES; | 1202 | error = error < 0 ? error : -EACCES; |
1165 | break; | 1203 | break; |
1166 | } | 1204 | } |
1167 | out: | 1205 | out: |
1168 | unlock_kernel(); | ||
1169 | return error; | 1206 | return error; |
1170 | } | 1207 | } |
1171 | 1208 | ||
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c index 3639cc5cbdae..6c754f70c529 100644 --- a/fs/ncpfs/file.c +++ b/fs/ncpfs/file.c | |||
@@ -113,9 +113,6 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
113 | DPRINTK("ncp_file_read: enter %s/%s\n", | 113 | DPRINTK("ncp_file_read: enter %s/%s\n", |
114 | dentry->d_parent->d_name.name, dentry->d_name.name); | 114 | dentry->d_parent->d_name.name, dentry->d_name.name); |
115 | 115 | ||
116 | if (!ncp_conn_valid(NCP_SERVER(inode))) | ||
117 | return -EIO; | ||
118 | |||
119 | pos = *ppos; | 116 | pos = *ppos; |
120 | 117 | ||
121 | if ((ssize_t) count < 0) { | 118 | if ((ssize_t) count < 0) { |
@@ -192,13 +189,11 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t * | |||
192 | 189 | ||
193 | DPRINTK("ncp_file_write: enter %s/%s\n", | 190 | DPRINTK("ncp_file_write: enter %s/%s\n", |
194 | dentry->d_parent->d_name.name, dentry->d_name.name); | 191 | dentry->d_parent->d_name.name, dentry->d_name.name); |
195 | if (!ncp_conn_valid(NCP_SERVER(inode))) | ||
196 | return -EIO; | ||
197 | if ((ssize_t) count < 0) | 192 | if ((ssize_t) count < 0) |
198 | return -EINVAL; | 193 | return -EINVAL; |
199 | pos = *ppos; | 194 | pos = *ppos; |
200 | if (file->f_flags & O_APPEND) { | 195 | if (file->f_flags & O_APPEND) { |
201 | pos = inode->i_size; | 196 | pos = i_size_read(inode); |
202 | } | 197 | } |
203 | 198 | ||
204 | if (pos + count > MAX_NON_LFS && !(file->f_flags&O_LARGEFILE)) { | 199 | if (pos + count > MAX_NON_LFS && !(file->f_flags&O_LARGEFILE)) { |
@@ -264,8 +259,11 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t * | |||
264 | 259 | ||
265 | *ppos = pos; | 260 | *ppos = pos; |
266 | 261 | ||
267 | if (pos > inode->i_size) { | 262 | if (pos > i_size_read(inode)) { |
268 | inode->i_size = pos; | 263 | mutex_lock(&inode->i_mutex); |
264 | if (pos > i_size_read(inode)) | ||
265 | i_size_write(inode, pos); | ||
266 | mutex_unlock(&inode->i_mutex); | ||
269 | } | 267 | } |
270 | DPRINTK("ncp_file_write: exit %s/%s\n", | 268 | DPRINTK("ncp_file_write: exit %s/%s\n", |
271 | dentry->d_parent->d_name.name, dentry->d_name.name); | 269 | dentry->d_parent->d_name.name, dentry->d_name.name); |
@@ -281,18 +279,9 @@ static int ncp_release(struct inode *inode, struct file *file) { | |||
281 | return 0; | 279 | return 0; |
282 | } | 280 | } |
283 | 281 | ||
284 | static loff_t ncp_remote_llseek(struct file *file, loff_t offset, int origin) | ||
285 | { | ||
286 | loff_t ret; | ||
287 | lock_kernel(); | ||
288 | ret = generic_file_llseek_unlocked(file, offset, origin); | ||
289 | unlock_kernel(); | ||
290 | return ret; | ||
291 | } | ||
292 | |||
293 | const struct file_operations ncp_file_operations = | 282 | const struct file_operations ncp_file_operations = |
294 | { | 283 | { |
295 | .llseek = ncp_remote_llseek, | 284 | .llseek = generic_file_llseek, |
296 | .read = ncp_file_read, | 285 | .read = ncp_file_read, |
297 | .write = ncp_file_write, | 286 | .write = ncp_file_write, |
298 | .unlocked_ioctl = ncp_ioctl, | 287 | .unlocked_ioctl = ncp_ioctl, |
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index b4de38cf49f5..985fabb26aca 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c | |||
@@ -139,7 +139,7 @@ static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi) | |||
139 | inode->i_mode = nwi->nfs.mode; | 139 | inode->i_mode = nwi->nfs.mode; |
140 | } | 140 | } |
141 | 141 | ||
142 | inode->i_blocks = (inode->i_size + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT; | 142 | inode->i_blocks = (i_size_read(inode) + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT; |
143 | 143 | ||
144 | inode->i_mtime.tv_sec = ncp_date_dos2unix(nwi->modifyTime, nwi->modifyDate); | 144 | inode->i_mtime.tv_sec = ncp_date_dos2unix(nwi->modifyTime, nwi->modifyDate); |
145 | inode->i_ctime.tv_sec = ncp_date_dos2unix(nwi->creationTime, nwi->creationDate); | 145 | inode->i_ctime.tv_sec = ncp_date_dos2unix(nwi->creationTime, nwi->creationDate); |
@@ -158,18 +158,21 @@ static void ncp_update_attrs(struct inode *inode, struct ncp_entry_info *nwinfo) | |||
158 | inode->i_mode = server->m.dir_mode; | 158 | inode->i_mode = server->m.dir_mode; |
159 | /* for directories dataStreamSize seems to be some | 159 | /* for directories dataStreamSize seems to be some |
160 | Object ID ??? */ | 160 | Object ID ??? */ |
161 | inode->i_size = NCP_BLOCK_SIZE; | 161 | i_size_write(inode, NCP_BLOCK_SIZE); |
162 | } else { | 162 | } else { |
163 | u32 size; | ||
164 | |||
163 | inode->i_mode = server->m.file_mode; | 165 | inode->i_mode = server->m.file_mode; |
164 | inode->i_size = le32_to_cpu(nwi->dataStreamSize); | 166 | size = le32_to_cpu(nwi->dataStreamSize); |
167 | i_size_write(inode, size); | ||
165 | #ifdef CONFIG_NCPFS_EXTRAS | 168 | #ifdef CONFIG_NCPFS_EXTRAS |
166 | if ((server->m.flags & (NCP_MOUNT_EXTRAS|NCP_MOUNT_SYMLINKS)) | 169 | if ((server->m.flags & (NCP_MOUNT_EXTRAS|NCP_MOUNT_SYMLINKS)) |
167 | && (nwi->attributes & aSHARED)) { | 170 | && (nwi->attributes & aSHARED)) { |
168 | switch (nwi->attributes & (aHIDDEN|aSYSTEM)) { | 171 | switch (nwi->attributes & (aHIDDEN|aSYSTEM)) { |
169 | case aHIDDEN: | 172 | case aHIDDEN: |
170 | if (server->m.flags & NCP_MOUNT_SYMLINKS) { | 173 | if (server->m.flags & NCP_MOUNT_SYMLINKS) { |
171 | if (/* (inode->i_size >= NCP_MIN_SYMLINK_SIZE) | 174 | if (/* (size >= NCP_MIN_SYMLINK_SIZE) |
172 | && */ (inode->i_size <= NCP_MAX_SYMLINK_SIZE)) { | 175 | && */ (size <= NCP_MAX_SYMLINK_SIZE)) { |
173 | inode->i_mode = (inode->i_mode & ~S_IFMT) | S_IFLNK; | 176 | inode->i_mode = (inode->i_mode & ~S_IFMT) | S_IFLNK; |
174 | NCP_FINFO(inode)->flags |= NCPI_KLUDGE_SYMLINK; | 177 | NCP_FINFO(inode)->flags |= NCPI_KLUDGE_SYMLINK; |
175 | break; | 178 | break; |
@@ -208,7 +211,7 @@ void ncp_update_inode2(struct inode* inode, struct ncp_entry_info *nwinfo) | |||
208 | } | 211 | } |
209 | 212 | ||
210 | /* | 213 | /* |
211 | * Fill in the inode based on the ncp_entry_info structure. | 214 | * Fill in the inode based on the ncp_entry_info structure. Used only for brand new inodes. |
212 | */ | 215 | */ |
213 | static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo) | 216 | static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo) |
214 | { | 217 | { |
@@ -254,6 +257,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info) | |||
254 | if (inode) { | 257 | if (inode) { |
255 | atomic_set(&NCP_FINFO(inode)->opened, info->opened); | 258 | atomic_set(&NCP_FINFO(inode)->opened, info->opened); |
256 | 259 | ||
260 | inode->i_mapping->backing_dev_info = sb->s_bdi; | ||
257 | inode->i_ino = info->ino; | 261 | inode->i_ino = info->ino; |
258 | ncp_set_attr(inode, info); | 262 | ncp_set_attr(inode, info); |
259 | if (S_ISREG(inode->i_mode)) { | 263 | if (S_ISREG(inode->i_mode)) { |
@@ -299,10 +303,12 @@ ncp_evict_inode(struct inode *inode) | |||
299 | 303 | ||
300 | static void ncp_stop_tasks(struct ncp_server *server) { | 304 | static void ncp_stop_tasks(struct ncp_server *server) { |
301 | struct sock* sk = server->ncp_sock->sk; | 305 | struct sock* sk = server->ncp_sock->sk; |
302 | 306 | ||
307 | lock_sock(sk); | ||
303 | sk->sk_error_report = server->error_report; | 308 | sk->sk_error_report = server->error_report; |
304 | sk->sk_data_ready = server->data_ready; | 309 | sk->sk_data_ready = server->data_ready; |
305 | sk->sk_write_space = server->write_space; | 310 | sk->sk_write_space = server->write_space; |
311 | release_sock(sk); | ||
306 | del_timer_sync(&server->timeout_tm); | 312 | del_timer_sync(&server->timeout_tm); |
307 | flush_scheduled_work(); | 313 | flush_scheduled_work(); |
308 | } | 314 | } |
@@ -565,10 +571,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
565 | /* server->conn_status = 0; */ | 571 | /* server->conn_status = 0; */ |
566 | /* server->root_dentry = NULL; */ | 572 | /* server->root_dentry = NULL; */ |
567 | /* server->root_setuped = 0; */ | 573 | /* server->root_setuped = 0; */ |
574 | mutex_init(&server->root_setup_lock); | ||
568 | #ifdef CONFIG_NCPFS_PACKET_SIGNING | 575 | #ifdef CONFIG_NCPFS_PACKET_SIGNING |
569 | /* server->sign_wanted = 0; */ | 576 | /* server->sign_wanted = 0; */ |
570 | /* server->sign_active = 0; */ | 577 | /* server->sign_active = 0; */ |
571 | #endif | 578 | #endif |
579 | init_rwsem(&server->auth_rwsem); | ||
572 | server->auth.auth_type = NCP_AUTH_NONE; | 580 | server->auth.auth_type = NCP_AUTH_NONE; |
573 | /* server->auth.object_name_len = 0; */ | 581 | /* server->auth.object_name_len = 0; */ |
574 | /* server->auth.object_name = NULL; */ | 582 | /* server->auth.object_name = NULL; */ |
@@ -593,16 +601,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
593 | server->nls_io = load_nls_default(); | 601 | server->nls_io = load_nls_default(); |
594 | #endif /* CONFIG_NCPFS_NLS */ | 602 | #endif /* CONFIG_NCPFS_NLS */ |
595 | 603 | ||
596 | server->dentry_ttl = 0; /* no caching */ | 604 | atomic_set(&server->dentry_ttl, 0); /* no caching */ |
597 | 605 | ||
598 | INIT_LIST_HEAD(&server->tx.requests); | 606 | INIT_LIST_HEAD(&server->tx.requests); |
599 | mutex_init(&server->rcv.creq_mutex); | 607 | mutex_init(&server->rcv.creq_mutex); |
600 | server->tx.creq = NULL; | 608 | server->tx.creq = NULL; |
601 | server->rcv.creq = NULL; | 609 | server->rcv.creq = NULL; |
602 | server->data_ready = sock->sk->sk_data_ready; | ||
603 | server->write_space = sock->sk->sk_write_space; | ||
604 | server->error_report = sock->sk->sk_error_report; | ||
605 | sock->sk->sk_user_data = server; | ||
606 | 610 | ||
607 | init_timer(&server->timeout_tm); | 611 | init_timer(&server->timeout_tm); |
608 | #undef NCP_PACKET_SIZE | 612 | #undef NCP_PACKET_SIZE |
@@ -619,6 +623,11 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
619 | if (server->rxbuf == NULL) | 623 | if (server->rxbuf == NULL) |
620 | goto out_txbuf; | 624 | goto out_txbuf; |
621 | 625 | ||
626 | lock_sock(sock->sk); | ||
627 | server->data_ready = sock->sk->sk_data_ready; | ||
628 | server->write_space = sock->sk->sk_write_space; | ||
629 | server->error_report = sock->sk->sk_error_report; | ||
630 | sock->sk->sk_user_data = server; | ||
622 | sock->sk->sk_data_ready = ncp_tcp_data_ready; | 631 | sock->sk->sk_data_ready = ncp_tcp_data_ready; |
623 | sock->sk->sk_error_report = ncp_tcp_error_report; | 632 | sock->sk->sk_error_report = ncp_tcp_error_report; |
624 | if (sock->type == SOCK_STREAM) { | 633 | if (sock->type == SOCK_STREAM) { |
@@ -634,6 +643,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
634 | server->timeout_tm.data = (unsigned long)server; | 643 | server->timeout_tm.data = (unsigned long)server; |
635 | server->timeout_tm.function = ncpdgram_timeout_call; | 644 | server->timeout_tm.function = ncpdgram_timeout_call; |
636 | } | 645 | } |
646 | release_sock(sock->sk); | ||
637 | 647 | ||
638 | ncp_lock_server(server); | 648 | ncp_lock_server(server); |
639 | error = ncp_connect(server); | 649 | error = ncp_connect(server); |
@@ -658,8 +668,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
658 | goto out_disconnect; | 668 | goto out_disconnect; |
659 | } | 669 | } |
660 | } | 670 | } |
671 | ncp_lock_server(server); | ||
661 | if (options & 2) | 672 | if (options & 2) |
662 | server->sign_wanted = 1; | 673 | server->sign_wanted = 1; |
674 | ncp_unlock_server(server); | ||
663 | } | 675 | } |
664 | else | 676 | else |
665 | #endif /* CONFIG_NCPFS_PACKET_SIGNING */ | 677 | #endif /* CONFIG_NCPFS_PACKET_SIGNING */ |
@@ -720,6 +732,9 @@ out_nls: | |||
720 | unload_nls(server->nls_io); | 732 | unload_nls(server->nls_io); |
721 | unload_nls(server->nls_vol); | 733 | unload_nls(server->nls_vol); |
722 | #endif | 734 | #endif |
735 | mutex_destroy(&server->rcv.creq_mutex); | ||
736 | mutex_destroy(&server->root_setup_lock); | ||
737 | mutex_destroy(&server->mutex); | ||
723 | out_fput2: | 738 | out_fput2: |
724 | if (server->info_filp) | 739 | if (server->info_filp) |
725 | fput(server->info_filp); | 740 | fput(server->info_filp); |
@@ -743,8 +758,6 @@ static void ncp_put_super(struct super_block *sb) | |||
743 | { | 758 | { |
744 | struct ncp_server *server = NCP_SBP(sb); | 759 | struct ncp_server *server = NCP_SBP(sb); |
745 | 760 | ||
746 | lock_kernel(); | ||
747 | |||
748 | ncp_lock_server(server); | 761 | ncp_lock_server(server); |
749 | ncp_disconnect(server); | 762 | ncp_disconnect(server); |
750 | ncp_unlock_server(server); | 763 | ncp_unlock_server(server); |
@@ -756,6 +769,9 @@ static void ncp_put_super(struct super_block *sb) | |||
756 | unload_nls(server->nls_vol); | 769 | unload_nls(server->nls_vol); |
757 | unload_nls(server->nls_io); | 770 | unload_nls(server->nls_io); |
758 | #endif /* CONFIG_NCPFS_NLS */ | 771 | #endif /* CONFIG_NCPFS_NLS */ |
772 | mutex_destroy(&server->rcv.creq_mutex); | ||
773 | mutex_destroy(&server->root_setup_lock); | ||
774 | mutex_destroy(&server->mutex); | ||
759 | 775 | ||
760 | if (server->info_filp) | 776 | if (server->info_filp) |
761 | fput(server->info_filp); | 777 | fput(server->info_filp); |
@@ -771,8 +787,6 @@ static void ncp_put_super(struct super_block *sb) | |||
771 | vfree(server->packet); | 787 | vfree(server->packet); |
772 | sb->s_fs_info = NULL; | 788 | sb->s_fs_info = NULL; |
773 | kfree(server); | 789 | kfree(server); |
774 | |||
775 | unlock_kernel(); | ||
776 | } | 790 | } |
777 | 791 | ||
778 | static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf) | 792 | static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf) |
@@ -851,10 +865,8 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr) | |||
851 | 865 | ||
852 | result = -EIO; | 866 | result = -EIO; |
853 | 867 | ||
854 | lock_kernel(); | ||
855 | |||
856 | server = NCP_SERVER(inode); | 868 | server = NCP_SERVER(inode); |
857 | if ((!server) || !ncp_conn_valid(server)) | 869 | if (!server) /* How this could happen? */ |
858 | goto out; | 870 | goto out; |
859 | 871 | ||
860 | /* ageing the dentry to force validation */ | 872 | /* ageing the dentry to force validation */ |
@@ -981,8 +993,6 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr) | |||
981 | result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode), | 993 | result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode), |
982 | inode, info_mask, &info); | 994 | inode, info_mask, &info); |
983 | if (result != 0) { | 995 | if (result != 0) { |
984 | result = -EACCES; | ||
985 | |||
986 | if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE)) { | 996 | if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE)) { |
987 | /* NetWare seems not to allow this. I | 997 | /* NetWare seems not to allow this. I |
988 | do not know why. So, just tell the | 998 | do not know why. So, just tell the |
@@ -1005,7 +1015,8 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr) | |||
1005 | mark_inode_dirty(inode); | 1015 | mark_inode_dirty(inode); |
1006 | 1016 | ||
1007 | out: | 1017 | out: |
1008 | unlock_kernel(); | 1018 | if (result > 0) |
1019 | result = -EACCES; | ||
1009 | return result; | 1020 | return result; |
1010 | } | 1021 | } |
1011 | 1022 | ||
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c index 84a8cfc4e38e..c2a1f9a155c3 100644 --- a/fs/ncpfs/ioctl.c +++ b/fs/ncpfs/ioctl.c | |||
@@ -35,16 +35,11 @@ | |||
35 | #define NCP_PACKET_SIZE_INTERNAL 65536 | 35 | #define NCP_PACKET_SIZE_INTERNAL 65536 |
36 | 36 | ||
37 | static int | 37 | static int |
38 | ncp_get_fs_info(struct ncp_server * server, struct file *file, | 38 | ncp_get_fs_info(struct ncp_server * server, struct inode *inode, |
39 | struct ncp_fs_info __user *arg) | 39 | struct ncp_fs_info __user *arg) |
40 | { | 40 | { |
41 | struct inode *inode = file->f_path.dentry->d_inode; | ||
42 | struct ncp_fs_info info; | 41 | struct ncp_fs_info info; |
43 | 42 | ||
44 | if (file_permission(file, MAY_WRITE) != 0 | ||
45 | && current_uid() != server->m.mounted_uid) | ||
46 | return -EACCES; | ||
47 | |||
48 | if (copy_from_user(&info, arg, sizeof(info))) | 43 | if (copy_from_user(&info, arg, sizeof(info))) |
49 | return -EFAULT; | 44 | return -EFAULT; |
50 | 45 | ||
@@ -65,16 +60,11 @@ ncp_get_fs_info(struct ncp_server * server, struct file *file, | |||
65 | } | 60 | } |
66 | 61 | ||
67 | static int | 62 | static int |
68 | ncp_get_fs_info_v2(struct ncp_server * server, struct file *file, | 63 | ncp_get_fs_info_v2(struct ncp_server * server, struct inode *inode, |
69 | struct ncp_fs_info_v2 __user * arg) | 64 | struct ncp_fs_info_v2 __user * arg) |
70 | { | 65 | { |
71 | struct inode *inode = file->f_path.dentry->d_inode; | ||
72 | struct ncp_fs_info_v2 info2; | 66 | struct ncp_fs_info_v2 info2; |
73 | 67 | ||
74 | if (file_permission(file, MAY_WRITE) != 0 | ||
75 | && current_uid() != server->m.mounted_uid) | ||
76 | return -EACCES; | ||
77 | |||
78 | if (copy_from_user(&info2, arg, sizeof(info2))) | 68 | if (copy_from_user(&info2, arg, sizeof(info2))) |
79 | return -EFAULT; | 69 | return -EFAULT; |
80 | 70 | ||
@@ -136,16 +126,11 @@ struct compat_ncp_privatedata_ioctl | |||
136 | #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl) | 126 | #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl) |
137 | 127 | ||
138 | static int | 128 | static int |
139 | ncp_get_compat_fs_info_v2(struct ncp_server * server, struct file *file, | 129 | ncp_get_compat_fs_info_v2(struct ncp_server * server, struct inode *inode, |
140 | struct compat_ncp_fs_info_v2 __user * arg) | 130 | struct compat_ncp_fs_info_v2 __user * arg) |
141 | { | 131 | { |
142 | struct inode *inode = file->f_path.dentry->d_inode; | ||
143 | struct compat_ncp_fs_info_v2 info2; | 132 | struct compat_ncp_fs_info_v2 info2; |
144 | 133 | ||
145 | if (file_permission(file, MAY_WRITE) != 0 | ||
146 | && current_uid() != server->m.mounted_uid) | ||
147 | return -EACCES; | ||
148 | |||
149 | if (copy_from_user(&info2, arg, sizeof(info2))) | 134 | if (copy_from_user(&info2, arg, sizeof(info2))) |
150 | return -EFAULT; | 135 | return -EFAULT; |
151 | 136 | ||
@@ -182,11 +167,8 @@ ncp_set_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg) | |||
182 | struct nls_table *iocharset; | 167 | struct nls_table *iocharset; |
183 | struct nls_table *oldset_io; | 168 | struct nls_table *oldset_io; |
184 | struct nls_table *oldset_cp; | 169 | struct nls_table *oldset_cp; |
185 | 170 | int utf8; | |
186 | if (!capable(CAP_SYS_ADMIN)) | 171 | int err; |
187 | return -EACCES; | ||
188 | if (server->root_setuped) | ||
189 | return -EBUSY; | ||
190 | 172 | ||
191 | if (copy_from_user(&user, arg, sizeof(user))) | 173 | if (copy_from_user(&user, arg, sizeof(user))) |
192 | return -EFAULT; | 174 | return -EFAULT; |
@@ -206,28 +188,40 @@ ncp_set_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg) | |||
206 | user.iocharset[NCP_IOCSNAME_LEN] = 0; | 188 | user.iocharset[NCP_IOCSNAME_LEN] = 0; |
207 | if (!user.iocharset[0] || !strcmp(user.iocharset, "default")) { | 189 | if (!user.iocharset[0] || !strcmp(user.iocharset, "default")) { |
208 | iocharset = load_nls_default(); | 190 | iocharset = load_nls_default(); |
209 | NCP_CLR_FLAG(server, NCP_FLAG_UTF8); | 191 | utf8 = 0; |
210 | } else if (!strcmp(user.iocharset, "utf8")) { | 192 | } else if (!strcmp(user.iocharset, "utf8")) { |
211 | iocharset = load_nls_default(); | 193 | iocharset = load_nls_default(); |
212 | NCP_SET_FLAG(server, NCP_FLAG_UTF8); | 194 | utf8 = 1; |
213 | } else { | 195 | } else { |
214 | iocharset = load_nls(user.iocharset); | 196 | iocharset = load_nls(user.iocharset); |
215 | if (!iocharset) { | 197 | if (!iocharset) { |
216 | unload_nls(codepage); | 198 | unload_nls(codepage); |
217 | return -EBADRQC; | 199 | return -EBADRQC; |
218 | } | 200 | } |
219 | NCP_CLR_FLAG(server, NCP_FLAG_UTF8); | 201 | utf8 = 0; |
220 | } | 202 | } |
221 | 203 | ||
222 | oldset_cp = server->nls_vol; | 204 | mutex_lock(&server->root_setup_lock); |
223 | server->nls_vol = codepage; | 205 | if (server->root_setuped) { |
224 | oldset_io = server->nls_io; | 206 | oldset_cp = codepage; |
225 | server->nls_io = iocharset; | 207 | oldset_io = iocharset; |
226 | 208 | err = -EBUSY; | |
209 | } else { | ||
210 | if (utf8) | ||
211 | NCP_SET_FLAG(server, NCP_FLAG_UTF8); | ||
212 | else | ||
213 | NCP_CLR_FLAG(server, NCP_FLAG_UTF8); | ||
214 | oldset_cp = server->nls_vol; | ||
215 | server->nls_vol = codepage; | ||
216 | oldset_io = server->nls_io; | ||
217 | server->nls_io = iocharset; | ||
218 | err = 0; | ||
219 | } | ||
220 | mutex_unlock(&server->root_setup_lock); | ||
227 | unload_nls(oldset_cp); | 221 | unload_nls(oldset_cp); |
228 | unload_nls(oldset_io); | 222 | unload_nls(oldset_io); |
229 | 223 | ||
230 | return 0; | 224 | return err; |
231 | } | 225 | } |
232 | 226 | ||
233 | static int | 227 | static int |
@@ -237,6 +231,7 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg) | |||
237 | int len; | 231 | int len; |
238 | 232 | ||
239 | memset(&user, 0, sizeof(user)); | 233 | memset(&user, 0, sizeof(user)); |
234 | mutex_lock(&server->root_setup_lock); | ||
240 | if (server->nls_vol && server->nls_vol->charset) { | 235 | if (server->nls_vol && server->nls_vol->charset) { |
241 | len = strlen(server->nls_vol->charset); | 236 | len = strlen(server->nls_vol->charset); |
242 | if (len > NCP_IOCSNAME_LEN) | 237 | if (len > NCP_IOCSNAME_LEN) |
@@ -254,6 +249,7 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg) | |||
254 | strncpy(user.iocharset, server->nls_io->charset, len); | 249 | strncpy(user.iocharset, server->nls_io->charset, len); |
255 | user.iocharset[len] = 0; | 250 | user.iocharset[len] = 0; |
256 | } | 251 | } |
252 | mutex_unlock(&server->root_setup_lock); | ||
257 | 253 | ||
258 | if (copy_to_user(arg, &user, sizeof(user))) | 254 | if (copy_to_user(arg, &user, sizeof(user))) |
259 | return -EFAULT; | 255 | return -EFAULT; |
@@ -261,25 +257,19 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg) | |||
261 | } | 257 | } |
262 | #endif /* CONFIG_NCPFS_NLS */ | 258 | #endif /* CONFIG_NCPFS_NLS */ |
263 | 259 | ||
264 | static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 260 | static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg) |
265 | { | 261 | { |
266 | struct inode *inode = filp->f_dentry->d_inode; | ||
267 | struct ncp_server *server = NCP_SERVER(inode); | 262 | struct ncp_server *server = NCP_SERVER(inode); |
268 | int result; | 263 | int result; |
269 | struct ncp_ioctl_request request; | 264 | struct ncp_ioctl_request request; |
270 | char* bouncebuffer; | 265 | char* bouncebuffer; |
271 | void __user *argp = (void __user *)arg; | 266 | void __user *argp = (void __user *)arg; |
272 | uid_t uid = current_uid(); | ||
273 | 267 | ||
274 | switch (cmd) { | 268 | switch (cmd) { |
275 | #ifdef CONFIG_COMPAT | 269 | #ifdef CONFIG_COMPAT |
276 | case NCP_IOC_NCPREQUEST_32: | 270 | case NCP_IOC_NCPREQUEST_32: |
277 | #endif | 271 | #endif |
278 | case NCP_IOC_NCPREQUEST: | 272 | case NCP_IOC_NCPREQUEST: |
279 | if (file_permission(filp, MAY_WRITE) != 0 | ||
280 | && uid != server->m.mounted_uid) | ||
281 | return -EACCES; | ||
282 | |||
283 | #ifdef CONFIG_COMPAT | 273 | #ifdef CONFIG_COMPAT |
284 | if (cmd == NCP_IOC_NCPREQUEST_32) { | 274 | if (cmd == NCP_IOC_NCPREQUEST_32) { |
285 | struct compat_ncp_ioctl_request request32; | 275 | struct compat_ncp_ioctl_request request32; |
@@ -314,7 +304,7 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
314 | server->current_size = request.size; | 304 | server->current_size = request.size; |
315 | memcpy(server->packet, bouncebuffer, request.size); | 305 | memcpy(server->packet, bouncebuffer, request.size); |
316 | 306 | ||
317 | result = ncp_request2(server, request.function, | 307 | result = ncp_request2(server, request.function, |
318 | bouncebuffer, NCP_PACKET_SIZE_INTERNAL); | 308 | bouncebuffer, NCP_PACKET_SIZE_INTERNAL); |
319 | if (result < 0) | 309 | if (result < 0) |
320 | result = -EIO; | 310 | result = -EIO; |
@@ -331,69 +321,69 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
331 | 321 | ||
332 | case NCP_IOC_CONN_LOGGED_IN: | 322 | case NCP_IOC_CONN_LOGGED_IN: |
333 | 323 | ||
334 | if (!capable(CAP_SYS_ADMIN)) | ||
335 | return -EACCES; | ||
336 | if (!(server->m.int_flags & NCP_IMOUNT_LOGGEDIN_POSSIBLE)) | 324 | if (!(server->m.int_flags & NCP_IMOUNT_LOGGEDIN_POSSIBLE)) |
337 | return -EINVAL; | 325 | return -EINVAL; |
326 | mutex_lock(&server->root_setup_lock); | ||
338 | if (server->root_setuped) | 327 | if (server->root_setuped) |
339 | return -EBUSY; | 328 | result = -EBUSY; |
340 | server->root_setuped = 1; | 329 | else { |
341 | return ncp_conn_logged_in(inode->i_sb); | 330 | result = ncp_conn_logged_in(inode->i_sb); |
331 | if (result == 0) | ||
332 | server->root_setuped = 1; | ||
333 | } | ||
334 | mutex_unlock(&server->root_setup_lock); | ||
335 | return result; | ||
342 | 336 | ||
343 | case NCP_IOC_GET_FS_INFO: | 337 | case NCP_IOC_GET_FS_INFO: |
344 | return ncp_get_fs_info(server, filp, argp); | 338 | return ncp_get_fs_info(server, inode, argp); |
345 | 339 | ||
346 | case NCP_IOC_GET_FS_INFO_V2: | 340 | case NCP_IOC_GET_FS_INFO_V2: |
347 | return ncp_get_fs_info_v2(server, filp, argp); | 341 | return ncp_get_fs_info_v2(server, inode, argp); |
348 | 342 | ||
349 | #ifdef CONFIG_COMPAT | 343 | #ifdef CONFIG_COMPAT |
350 | case NCP_IOC_GET_FS_INFO_V2_32: | 344 | case NCP_IOC_GET_FS_INFO_V2_32: |
351 | return ncp_get_compat_fs_info_v2(server, filp, argp); | 345 | return ncp_get_compat_fs_info_v2(server, inode, argp); |
352 | #endif | 346 | #endif |
353 | /* we have too many combinations of CONFIG_COMPAT, | 347 | /* we have too many combinations of CONFIG_COMPAT, |
354 | * CONFIG_64BIT and CONFIG_UID16, so just handle | 348 | * CONFIG_64BIT and CONFIG_UID16, so just handle |
355 | * any of the possible ioctls */ | 349 | * any of the possible ioctls */ |
356 | case NCP_IOC_GETMOUNTUID16: | 350 | case NCP_IOC_GETMOUNTUID16: |
357 | case NCP_IOC_GETMOUNTUID32: | 351 | { |
358 | case NCP_IOC_GETMOUNTUID64: | ||
359 | if (file_permission(filp, MAY_READ) != 0 | ||
360 | && uid != server->m.mounted_uid) | ||
361 | return -EACCES; | ||
362 | |||
363 | if (cmd == NCP_IOC_GETMOUNTUID16) { | ||
364 | u16 uid; | 352 | u16 uid; |
353 | |||
365 | SET_UID(uid, server->m.mounted_uid); | 354 | SET_UID(uid, server->m.mounted_uid); |
366 | if (put_user(uid, (u16 __user *)argp)) | 355 | if (put_user(uid, (u16 __user *)argp)) |
367 | return -EFAULT; | 356 | return -EFAULT; |
368 | } else if (cmd == NCP_IOC_GETMOUNTUID32) { | 357 | return 0; |
369 | if (put_user(server->m.mounted_uid, | ||
370 | (u32 __user *)argp)) | ||
371 | return -EFAULT; | ||
372 | } else { | ||
373 | if (put_user(server->m.mounted_uid, | ||
374 | (u64 __user *)argp)) | ||
375 | return -EFAULT; | ||
376 | } | 358 | } |
359 | case NCP_IOC_GETMOUNTUID32: | ||
360 | if (put_user(server->m.mounted_uid, | ||
361 | (u32 __user *)argp)) | ||
362 | return -EFAULT; | ||
363 | return 0; | ||
364 | case NCP_IOC_GETMOUNTUID64: | ||
365 | if (put_user(server->m.mounted_uid, | ||
366 | (u64 __user *)argp)) | ||
367 | return -EFAULT; | ||
377 | return 0; | 368 | return 0; |
378 | 369 | ||
379 | case NCP_IOC_GETROOT: | 370 | case NCP_IOC_GETROOT: |
380 | { | 371 | { |
381 | struct ncp_setroot_ioctl sr; | 372 | struct ncp_setroot_ioctl sr; |
382 | 373 | ||
383 | if (file_permission(filp, MAY_READ) != 0 | 374 | result = -EACCES; |
384 | && uid != server->m.mounted_uid) | 375 | mutex_lock(&server->root_setup_lock); |
385 | return -EACCES; | ||
386 | |||
387 | if (server->m.mounted_vol[0]) { | 376 | if (server->m.mounted_vol[0]) { |
388 | struct dentry* dentry = inode->i_sb->s_root; | 377 | struct dentry* dentry = inode->i_sb->s_root; |
389 | 378 | ||
390 | if (dentry) { | 379 | if (dentry) { |
391 | struct inode* s_inode = dentry->d_inode; | 380 | struct inode* s_inode = dentry->d_inode; |
392 | 381 | ||
393 | if (s_inode) { | 382 | if (s_inode) { |
394 | sr.volNumber = NCP_FINFO(s_inode)->volNumber; | 383 | sr.volNumber = NCP_FINFO(s_inode)->volNumber; |
395 | sr.dirEntNum = NCP_FINFO(s_inode)->dirEntNum; | 384 | sr.dirEntNum = NCP_FINFO(s_inode)->dirEntNum; |
396 | sr.namespace = server->name_space[sr.volNumber]; | 385 | sr.namespace = server->name_space[sr.volNumber]; |
386 | result = 0; | ||
397 | } else | 387 | } else |
398 | DPRINTK("ncpfs: s_root->d_inode==NULL\n"); | 388 | DPRINTK("ncpfs: s_root->d_inode==NULL\n"); |
399 | } else | 389 | } else |
@@ -402,10 +392,12 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
402 | sr.volNumber = -1; | 392 | sr.volNumber = -1; |
403 | sr.namespace = 0; | 393 | sr.namespace = 0; |
404 | sr.dirEntNum = 0; | 394 | sr.dirEntNum = 0; |
395 | result = 0; | ||
405 | } | 396 | } |
406 | if (copy_to_user(argp, &sr, sizeof(sr))) | 397 | mutex_unlock(&server->root_setup_lock); |
407 | return -EFAULT; | 398 | if (!result && copy_to_user(argp, &sr, sizeof(sr))) |
408 | return 0; | 399 | result = -EFAULT; |
400 | return result; | ||
409 | } | 401 | } |
410 | 402 | ||
411 | case NCP_IOC_SETROOT: | 403 | case NCP_IOC_SETROOT: |
@@ -416,103 +408,114 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
416 | __le32 dosde; | 408 | __le32 dosde; |
417 | struct dentry* dentry; | 409 | struct dentry* dentry; |
418 | 410 | ||
419 | if (!capable(CAP_SYS_ADMIN)) | ||
420 | { | ||
421 | return -EACCES; | ||
422 | } | ||
423 | if (server->root_setuped) return -EBUSY; | ||
424 | if (copy_from_user(&sr, argp, sizeof(sr))) | 411 | if (copy_from_user(&sr, argp, sizeof(sr))) |
425 | return -EFAULT; | 412 | return -EFAULT; |
426 | if (sr.volNumber < 0) { | 413 | mutex_lock(&server->root_setup_lock); |
427 | server->m.mounted_vol[0] = 0; | 414 | if (server->root_setuped) |
428 | vnum = NCP_NUMBER_OF_VOLUMES; | 415 | result = -EBUSY; |
429 | de = 0; | 416 | else { |
430 | dosde = 0; | 417 | if (sr.volNumber < 0) { |
431 | } else if (sr.volNumber >= NCP_NUMBER_OF_VOLUMES) { | 418 | server->m.mounted_vol[0] = 0; |
432 | return -EINVAL; | 419 | vnum = NCP_NUMBER_OF_VOLUMES; |
433 | } else if (ncp_mount_subdir(server, sr.volNumber, | 420 | de = 0; |
434 | sr.namespace, sr.dirEntNum, | 421 | dosde = 0; |
435 | &vnum, &de, &dosde)) { | 422 | result = 0; |
436 | return -ENOENT; | 423 | } else if (sr.volNumber >= NCP_NUMBER_OF_VOLUMES) { |
437 | } | 424 | result = -EINVAL; |
438 | 425 | } else if (ncp_mount_subdir(server, sr.volNumber, | |
439 | dentry = inode->i_sb->s_root; | 426 | sr.namespace, sr.dirEntNum, |
440 | server->root_setuped = 1; | 427 | &vnum, &de, &dosde)) { |
441 | if (dentry) { | 428 | result = -ENOENT; |
442 | struct inode* s_inode = dentry->d_inode; | ||
443 | |||
444 | if (s_inode) { | ||
445 | NCP_FINFO(s_inode)->volNumber = vnum; | ||
446 | NCP_FINFO(s_inode)->dirEntNum = de; | ||
447 | NCP_FINFO(s_inode)->DosDirNum = dosde; | ||
448 | } else | 429 | } else |
449 | DPRINTK("ncpfs: s_root->d_inode==NULL\n"); | 430 | result = 0; |
450 | } else | 431 | |
451 | DPRINTK("ncpfs: s_root==NULL\n"); | 432 | if (result == 0) { |
433 | dentry = inode->i_sb->s_root; | ||
434 | if (dentry) { | ||
435 | struct inode* s_inode = dentry->d_inode; | ||
436 | |||
437 | if (s_inode) { | ||
438 | NCP_FINFO(s_inode)->volNumber = vnum; | ||
439 | NCP_FINFO(s_inode)->dirEntNum = de; | ||
440 | NCP_FINFO(s_inode)->DosDirNum = dosde; | ||
441 | server->root_setuped = 1; | ||
442 | } else { | ||
443 | DPRINTK("ncpfs: s_root->d_inode==NULL\n"); | ||
444 | result = -EIO; | ||
445 | } | ||
446 | } else { | ||
447 | DPRINTK("ncpfs: s_root==NULL\n"); | ||
448 | result = -EIO; | ||
449 | } | ||
450 | } | ||
451 | result = 0; | ||
452 | } | ||
453 | mutex_unlock(&server->root_setup_lock); | ||
452 | 454 | ||
453 | return 0; | 455 | return result; |
454 | } | 456 | } |
455 | 457 | ||
456 | #ifdef CONFIG_NCPFS_PACKET_SIGNING | 458 | #ifdef CONFIG_NCPFS_PACKET_SIGNING |
457 | case NCP_IOC_SIGN_INIT: | 459 | case NCP_IOC_SIGN_INIT: |
458 | if (file_permission(filp, MAY_WRITE) != 0 | 460 | { |
459 | && uid != server->m.mounted_uid) | 461 | struct ncp_sign_init sign; |
460 | return -EACCES; | ||
461 | |||
462 | if (argp) { | ||
463 | if (server->sign_wanted) | ||
464 | { | ||
465 | struct ncp_sign_init sign; | ||
466 | 462 | ||
463 | if (argp) | ||
467 | if (copy_from_user(&sign, argp, sizeof(sign))) | 464 | if (copy_from_user(&sign, argp, sizeof(sign))) |
468 | return -EFAULT; | 465 | return -EFAULT; |
469 | memcpy(server->sign_root,sign.sign_root,8); | 466 | ncp_lock_server(server); |
470 | memcpy(server->sign_last,sign.sign_last,16); | 467 | mutex_lock(&server->rcv.creq_mutex); |
471 | server->sign_active = 1; | 468 | if (argp) { |
469 | if (server->sign_wanted) { | ||
470 | memcpy(server->sign_root,sign.sign_root,8); | ||
471 | memcpy(server->sign_last,sign.sign_last,16); | ||
472 | server->sign_active = 1; | ||
473 | } | ||
474 | /* ignore when signatures not wanted */ | ||
475 | } else { | ||
476 | server->sign_active = 0; | ||
472 | } | 477 | } |
473 | /* ignore when signatures not wanted */ | 478 | mutex_unlock(&server->rcv.creq_mutex); |
474 | } else { | 479 | ncp_unlock_server(server); |
475 | server->sign_active = 0; | 480 | return 0; |
476 | } | 481 | } |
477 | return 0; | 482 | |
478 | |||
479 | case NCP_IOC_SIGN_WANTED: | 483 | case NCP_IOC_SIGN_WANTED: |
480 | if (file_permission(filp, MAY_READ) != 0 | 484 | { |
481 | && uid != server->m.mounted_uid) | 485 | int state; |
482 | return -EACCES; | 486 | |
483 | 487 | ncp_lock_server(server); | |
484 | if (put_user(server->sign_wanted, (int __user *)argp)) | 488 | state = server->sign_wanted; |
485 | return -EFAULT; | 489 | ncp_unlock_server(server); |
486 | return 0; | 490 | if (put_user(state, (int __user *)argp)) |
491 | return -EFAULT; | ||
492 | return 0; | ||
493 | } | ||
487 | 494 | ||
488 | case NCP_IOC_SET_SIGN_WANTED: | 495 | case NCP_IOC_SET_SIGN_WANTED: |
489 | { | 496 | { |
490 | int newstate; | 497 | int newstate; |
491 | 498 | ||
492 | if (file_permission(filp, MAY_WRITE) != 0 | ||
493 | && uid != server->m.mounted_uid) | ||
494 | return -EACCES; | ||
495 | |||
496 | /* get only low 8 bits... */ | 499 | /* get only low 8 bits... */ |
497 | if (get_user(newstate, (unsigned char __user *)argp)) | 500 | if (get_user(newstate, (unsigned char __user *)argp)) |
498 | return -EFAULT; | 501 | return -EFAULT; |
502 | result = 0; | ||
503 | ncp_lock_server(server); | ||
499 | if (server->sign_active) { | 504 | if (server->sign_active) { |
500 | /* cannot turn signatures OFF when active */ | 505 | /* cannot turn signatures OFF when active */ |
501 | if (!newstate) return -EINVAL; | 506 | if (!newstate) |
507 | result = -EINVAL; | ||
502 | } else { | 508 | } else { |
503 | server->sign_wanted = newstate != 0; | 509 | server->sign_wanted = newstate != 0; |
504 | } | 510 | } |
505 | return 0; | 511 | ncp_unlock_server(server); |
512 | return result; | ||
506 | } | 513 | } |
507 | 514 | ||
508 | #endif /* CONFIG_NCPFS_PACKET_SIGNING */ | 515 | #endif /* CONFIG_NCPFS_PACKET_SIGNING */ |
509 | 516 | ||
510 | #ifdef CONFIG_NCPFS_IOCTL_LOCKING | 517 | #ifdef CONFIG_NCPFS_IOCTL_LOCKING |
511 | case NCP_IOC_LOCKUNLOCK: | 518 | case NCP_IOC_LOCKUNLOCK: |
512 | if (file_permission(filp, MAY_WRITE) != 0 | ||
513 | && uid != server->m.mounted_uid) | ||
514 | return -EACCES; | ||
515 | |||
516 | { | 519 | { |
517 | struct ncp_lock_ioctl rqdata; | 520 | struct ncp_lock_ioctl rqdata; |
518 | 521 | ||
@@ -541,16 +544,13 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
541 | { | 544 | { |
542 | return result; | 545 | return result; |
543 | } | 546 | } |
544 | result = -EIO; | ||
545 | if (!ncp_conn_valid(server)) | ||
546 | goto outrel; | ||
547 | result = -EISDIR; | 547 | result = -EISDIR; |
548 | if (!S_ISREG(inode->i_mode)) | 548 | if (!S_ISREG(inode->i_mode)) |
549 | goto outrel; | 549 | goto outrel; |
550 | if (rqdata.cmd == NCP_LOCK_CLEAR) | 550 | if (rqdata.cmd == NCP_LOCK_CLEAR) |
551 | { | 551 | { |
552 | result = ncp_ClearPhysicalRecord(NCP_SERVER(inode), | 552 | result = ncp_ClearPhysicalRecord(NCP_SERVER(inode), |
553 | NCP_FINFO(inode)->file_handle, | 553 | NCP_FINFO(inode)->file_handle, |
554 | rqdata.offset, | 554 | rqdata.offset, |
555 | rqdata.length); | 555 | rqdata.length); |
556 | if (result > 0) result = 0; /* no such lock */ | 556 | if (result > 0) result = 0; /* no such lock */ |
@@ -573,7 +573,7 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
573 | rqdata.timeout); | 573 | rqdata.timeout); |
574 | if (result > 0) result = -EAGAIN; | 574 | if (result > 0) result = -EAGAIN; |
575 | } | 575 | } |
576 | outrel: | 576 | outrel: |
577 | ncp_inode_close(inode); | 577 | ncp_inode_close(inode); |
578 | return result; | 578 | return result; |
579 | } | 579 | } |
@@ -581,60 +581,62 @@ outrel: | |||
581 | 581 | ||
582 | #ifdef CONFIG_COMPAT | 582 | #ifdef CONFIG_COMPAT |
583 | case NCP_IOC_GETOBJECTNAME_32: | 583 | case NCP_IOC_GETOBJECTNAME_32: |
584 | if (uid != server->m.mounted_uid) | ||
585 | return -EACCES; | ||
586 | { | 584 | { |
587 | struct compat_ncp_objectname_ioctl user; | 585 | struct compat_ncp_objectname_ioctl user; |
588 | size_t outl; | 586 | size_t outl; |
589 | 587 | ||
590 | if (copy_from_user(&user, argp, sizeof(user))) | 588 | if (copy_from_user(&user, argp, sizeof(user))) |
591 | return -EFAULT; | 589 | return -EFAULT; |
590 | down_read(&server->auth_rwsem); | ||
592 | user.auth_type = server->auth.auth_type; | 591 | user.auth_type = server->auth.auth_type; |
593 | outl = user.object_name_len; | 592 | outl = user.object_name_len; |
594 | user.object_name_len = server->auth.object_name_len; | 593 | user.object_name_len = server->auth.object_name_len; |
595 | if (outl > user.object_name_len) | 594 | if (outl > user.object_name_len) |
596 | outl = user.object_name_len; | 595 | outl = user.object_name_len; |
596 | result = 0; | ||
597 | if (outl) { | 597 | if (outl) { |
598 | if (copy_to_user(compat_ptr(user.object_name), | 598 | if (copy_to_user(compat_ptr(user.object_name), |
599 | server->auth.object_name, | 599 | server->auth.object_name, |
600 | outl)) return -EFAULT; | 600 | outl)) |
601 | result = -EFAULT; | ||
601 | } | 602 | } |
602 | if (copy_to_user(argp, &user, sizeof(user))) | 603 | up_read(&server->auth_rwsem); |
603 | return -EFAULT; | 604 | if (!result && copy_to_user(argp, &user, sizeof(user))) |
604 | return 0; | 605 | result = -EFAULT; |
606 | return result; | ||
605 | } | 607 | } |
606 | #endif | 608 | #endif |
607 | 609 | ||
608 | case NCP_IOC_GETOBJECTNAME: | 610 | case NCP_IOC_GETOBJECTNAME: |
609 | if (uid != server->m.mounted_uid) | ||
610 | return -EACCES; | ||
611 | { | 611 | { |
612 | struct ncp_objectname_ioctl user; | 612 | struct ncp_objectname_ioctl user; |
613 | size_t outl; | 613 | size_t outl; |
614 | 614 | ||
615 | if (copy_from_user(&user, argp, sizeof(user))) | 615 | if (copy_from_user(&user, argp, sizeof(user))) |
616 | return -EFAULT; | 616 | return -EFAULT; |
617 | down_read(&server->auth_rwsem); | ||
617 | user.auth_type = server->auth.auth_type; | 618 | user.auth_type = server->auth.auth_type; |
618 | outl = user.object_name_len; | 619 | outl = user.object_name_len; |
619 | user.object_name_len = server->auth.object_name_len; | 620 | user.object_name_len = server->auth.object_name_len; |
620 | if (outl > user.object_name_len) | 621 | if (outl > user.object_name_len) |
621 | outl = user.object_name_len; | 622 | outl = user.object_name_len; |
623 | result = 0; | ||
622 | if (outl) { | 624 | if (outl) { |
623 | if (copy_to_user(user.object_name, | 625 | if (copy_to_user(user.object_name, |
624 | server->auth.object_name, | 626 | server->auth.object_name, |
625 | outl)) return -EFAULT; | 627 | outl)) |
628 | result = -EFAULT; | ||
626 | } | 629 | } |
627 | if (copy_to_user(argp, &user, sizeof(user))) | 630 | up_read(&server->auth_rwsem); |
628 | return -EFAULT; | 631 | if (!result && copy_to_user(argp, &user, sizeof(user))) |
629 | return 0; | 632 | result = -EFAULT; |
633 | return result; | ||
630 | } | 634 | } |
631 | 635 | ||
632 | #ifdef CONFIG_COMPAT | 636 | #ifdef CONFIG_COMPAT |
633 | case NCP_IOC_SETOBJECTNAME_32: | 637 | case NCP_IOC_SETOBJECTNAME_32: |
634 | #endif | 638 | #endif |
635 | case NCP_IOC_SETOBJECTNAME: | 639 | case NCP_IOC_SETOBJECTNAME: |
636 | if (uid != server->m.mounted_uid) | ||
637 | return -EACCES; | ||
638 | { | 640 | { |
639 | struct ncp_objectname_ioctl user; | 641 | struct ncp_objectname_ioctl user; |
640 | void* newname; | 642 | void* newname; |
@@ -666,9 +668,7 @@ outrel: | |||
666 | } else { | 668 | } else { |
667 | newname = NULL; | 669 | newname = NULL; |
668 | } | 670 | } |
669 | /* enter critical section */ | 671 | down_write(&server->auth_rwsem); |
670 | /* maybe that kfree can sleep so do that this way */ | ||
671 | /* it is at least more SMP friendly (in future...) */ | ||
672 | oldname = server->auth.object_name; | 672 | oldname = server->auth.object_name; |
673 | oldnamelen = server->auth.object_name_len; | 673 | oldnamelen = server->auth.object_name_len; |
674 | oldprivate = server->priv.data; | 674 | oldprivate = server->priv.data; |
@@ -678,7 +678,7 @@ outrel: | |||
678 | server->auth.object_name = newname; | 678 | server->auth.object_name = newname; |
679 | server->priv.len = 0; | 679 | server->priv.len = 0; |
680 | server->priv.data = NULL; | 680 | server->priv.data = NULL; |
681 | /* leave critical section */ | 681 | up_write(&server->auth_rwsem); |
682 | kfree(oldprivate); | 682 | kfree(oldprivate); |
683 | kfree(oldname); | 683 | kfree(oldname); |
684 | return 0; | 684 | return 0; |
@@ -688,8 +688,6 @@ outrel: | |||
688 | case NCP_IOC_GETPRIVATEDATA_32: | 688 | case NCP_IOC_GETPRIVATEDATA_32: |
689 | #endif | 689 | #endif |
690 | case NCP_IOC_GETPRIVATEDATA: | 690 | case NCP_IOC_GETPRIVATEDATA: |
691 | if (uid != server->m.mounted_uid) | ||
692 | return -EACCES; | ||
693 | { | 691 | { |
694 | struct ncp_privatedata_ioctl user; | 692 | struct ncp_privatedata_ioctl user; |
695 | size_t outl; | 693 | size_t outl; |
@@ -706,14 +704,20 @@ outrel: | |||
706 | if (copy_from_user(&user, argp, sizeof(user))) | 704 | if (copy_from_user(&user, argp, sizeof(user))) |
707 | return -EFAULT; | 705 | return -EFAULT; |
708 | 706 | ||
707 | down_read(&server->auth_rwsem); | ||
709 | outl = user.len; | 708 | outl = user.len; |
710 | user.len = server->priv.len; | 709 | user.len = server->priv.len; |
711 | if (outl > user.len) outl = user.len; | 710 | if (outl > user.len) outl = user.len; |
711 | result = 0; | ||
712 | if (outl) { | 712 | if (outl) { |
713 | if (copy_to_user(user.data, | 713 | if (copy_to_user(user.data, |
714 | server->priv.data, | 714 | server->priv.data, |
715 | outl)) return -EFAULT; | 715 | outl)) |
716 | result = -EFAULT; | ||
716 | } | 717 | } |
718 | up_read(&server->auth_rwsem); | ||
719 | if (result) | ||
720 | return result; | ||
717 | #ifdef CONFIG_COMPAT | 721 | #ifdef CONFIG_COMPAT |
718 | if (cmd == NCP_IOC_GETPRIVATEDATA_32) { | 722 | if (cmd == NCP_IOC_GETPRIVATEDATA_32) { |
719 | struct compat_ncp_privatedata_ioctl user32; | 723 | struct compat_ncp_privatedata_ioctl user32; |
@@ -733,8 +737,6 @@ outrel: | |||
733 | case NCP_IOC_SETPRIVATEDATA_32: | 737 | case NCP_IOC_SETPRIVATEDATA_32: |
734 | #endif | 738 | #endif |
735 | case NCP_IOC_SETPRIVATEDATA: | 739 | case NCP_IOC_SETPRIVATEDATA: |
736 | if (uid != server->m.mounted_uid) | ||
737 | return -EACCES; | ||
738 | { | 740 | { |
739 | struct ncp_privatedata_ioctl user; | 741 | struct ncp_privatedata_ioctl user; |
740 | void* new; | 742 | void* new; |
@@ -762,12 +764,12 @@ outrel: | |||
762 | } else { | 764 | } else { |
763 | new = NULL; | 765 | new = NULL; |
764 | } | 766 | } |
765 | /* enter critical section */ | 767 | down_write(&server->auth_rwsem); |
766 | old = server->priv.data; | 768 | old = server->priv.data; |
767 | oldlen = server->priv.len; | 769 | oldlen = server->priv.len; |
768 | server->priv.len = user.len; | 770 | server->priv.len = user.len; |
769 | server->priv.data = new; | 771 | server->priv.data = new; |
770 | /* leave critical section */ | 772 | up_write(&server->auth_rwsem); |
771 | kfree(old); | 773 | kfree(old); |
772 | return 0; | 774 | return 0; |
773 | } | 775 | } |
@@ -775,17 +777,13 @@ outrel: | |||
775 | #ifdef CONFIG_NCPFS_NLS | 777 | #ifdef CONFIG_NCPFS_NLS |
776 | case NCP_IOC_SETCHARSETS: | 778 | case NCP_IOC_SETCHARSETS: |
777 | return ncp_set_charsets(server, argp); | 779 | return ncp_set_charsets(server, argp); |
778 | 780 | ||
779 | case NCP_IOC_GETCHARSETS: | 781 | case NCP_IOC_GETCHARSETS: |
780 | return ncp_get_charsets(server, argp); | 782 | return ncp_get_charsets(server, argp); |
781 | 783 | ||
782 | #endif /* CONFIG_NCPFS_NLS */ | 784 | #endif /* CONFIG_NCPFS_NLS */ |
783 | 785 | ||
784 | case NCP_IOC_SETDENTRYTTL: | 786 | case NCP_IOC_SETDENTRYTTL: |
785 | if (file_permission(filp, MAY_WRITE) != 0 && | ||
786 | uid != server->m.mounted_uid) | ||
787 | return -EACCES; | ||
788 | |||
789 | { | 787 | { |
790 | u_int32_t user; | 788 | u_int32_t user; |
791 | 789 | ||
@@ -795,13 +793,13 @@ outrel: | |||
795 | if (user > 20000) | 793 | if (user > 20000) |
796 | return -EINVAL; | 794 | return -EINVAL; |
797 | user = (user * HZ) / 1000; | 795 | user = (user * HZ) / 1000; |
798 | server->dentry_ttl = user; | 796 | atomic_set(&server->dentry_ttl, user); |
799 | return 0; | 797 | return 0; |
800 | } | 798 | } |
801 | 799 | ||
802 | case NCP_IOC_GETDENTRYTTL: | 800 | case NCP_IOC_GETDENTRYTTL: |
803 | { | 801 | { |
804 | u_int32_t user = (server->dentry_ttl * 1000) / HZ; | 802 | u_int32_t user = (atomic_read(&server->dentry_ttl) * 1000) / HZ; |
805 | if (copy_to_user(argp, &user, sizeof(user))) | 803 | if (copy_to_user(argp, &user, sizeof(user))) |
806 | return -EFAULT; | 804 | return -EFAULT; |
807 | return 0; | 805 | return 0; |
@@ -811,59 +809,103 @@ outrel: | |||
811 | return -EINVAL; | 809 | return -EINVAL; |
812 | } | 810 | } |
813 | 811 | ||
814 | static int ncp_ioctl_need_write(unsigned int cmd) | 812 | long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
815 | { | 813 | { |
814 | struct inode *inode = filp->f_dentry->d_inode; | ||
815 | struct ncp_server *server = NCP_SERVER(inode); | ||
816 | uid_t uid = current_uid(); | ||
817 | int need_drop_write = 0; | ||
818 | long ret; | ||
819 | |||
816 | switch (cmd) { | 820 | switch (cmd) { |
817 | case NCP_IOC_GET_FS_INFO: | ||
818 | case NCP_IOC_GET_FS_INFO_V2: | ||
819 | case NCP_IOC_NCPREQUEST: | ||
820 | case NCP_IOC_SETDENTRYTTL: | ||
821 | case NCP_IOC_SIGN_INIT: | ||
822 | case NCP_IOC_LOCKUNLOCK: | ||
823 | case NCP_IOC_SET_SIGN_WANTED: | ||
824 | return 1; | ||
825 | case NCP_IOC_GETOBJECTNAME: | ||
826 | case NCP_IOC_SETOBJECTNAME: | ||
827 | case NCP_IOC_GETPRIVATEDATA: | ||
828 | case NCP_IOC_SETPRIVATEDATA: | ||
829 | case NCP_IOC_SETCHARSETS: | 821 | case NCP_IOC_SETCHARSETS: |
830 | case NCP_IOC_GETCHARSETS: | ||
831 | case NCP_IOC_CONN_LOGGED_IN: | 822 | case NCP_IOC_CONN_LOGGED_IN: |
832 | case NCP_IOC_GETDENTRYTTL: | ||
833 | case NCP_IOC_GETMOUNTUID2: | ||
834 | case NCP_IOC_SIGN_WANTED: | ||
835 | case NCP_IOC_GETROOT: | ||
836 | case NCP_IOC_SETROOT: | 823 | case NCP_IOC_SETROOT: |
837 | return 0; | 824 | if (!capable(CAP_SYS_ADMIN)) { |
838 | default: | 825 | ret = -EACCES; |
839 | /* unknown IOCTL command, assume write */ | 826 | goto out; |
840 | return 1; | 827 | } |
828 | break; | ||
841 | } | 829 | } |
842 | } | 830 | if (server->m.mounted_uid != uid) { |
843 | 831 | switch (cmd) { | |
844 | long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | ||
845 | { | ||
846 | long ret; | ||
847 | |||
848 | lock_kernel(); | ||
849 | if (ncp_ioctl_need_write(cmd)) { | ||
850 | /* | 832 | /* |
851 | * inside the ioctl(), any failures which | 833 | * Only mount owner can issue these ioctls. Information |
852 | * are because of file_permission() are | 834 | * necessary to authenticate to other NDS servers are |
853 | * -EACCESS, so it seems consistent to keep | 835 | * stored here. |
854 | * that here. | ||
855 | */ | 836 | */ |
856 | if (mnt_want_write(filp->f_path.mnt)) { | 837 | case NCP_IOC_GETOBJECTNAME: |
838 | case NCP_IOC_SETOBJECTNAME: | ||
839 | case NCP_IOC_GETPRIVATEDATA: | ||
840 | case NCP_IOC_SETPRIVATEDATA: | ||
841 | #ifdef CONFIG_COMPAT | ||
842 | case NCP_IOC_GETOBJECTNAME_32: | ||
843 | case NCP_IOC_SETOBJECTNAME_32: | ||
844 | case NCP_IOC_GETPRIVATEDATA_32: | ||
845 | case NCP_IOC_SETPRIVATEDATA_32: | ||
846 | #endif | ||
857 | ret = -EACCES; | 847 | ret = -EACCES; |
858 | goto out; | 848 | goto out; |
849 | /* | ||
850 | * These require write access on the inode if user id | ||
851 | * does not match. Note that they do not write to the | ||
852 | * file... But old code did mnt_want_write, so I keep | ||
853 | * it as is. Of course not for mountpoint owner, as | ||
854 | * that breaks read-only mounts altogether as ncpmount | ||
855 | * needs working NCP_IOC_NCPREQUEST and | ||
856 | * NCP_IOC_GET_FS_INFO. Some of these codes (setdentryttl, | ||
857 | * signinit, setsignwanted) should be probably restricted | ||
858 | * to owner only, or even more to CAP_SYS_ADMIN). | ||
859 | */ | ||
860 | case NCP_IOC_GET_FS_INFO: | ||
861 | case NCP_IOC_GET_FS_INFO_V2: | ||
862 | case NCP_IOC_NCPREQUEST: | ||
863 | case NCP_IOC_SETDENTRYTTL: | ||
864 | case NCP_IOC_SIGN_INIT: | ||
865 | case NCP_IOC_LOCKUNLOCK: | ||
866 | case NCP_IOC_SET_SIGN_WANTED: | ||
867 | #ifdef CONFIG_COMPAT | ||
868 | case NCP_IOC_GET_FS_INFO_V2_32: | ||
869 | case NCP_IOC_NCPREQUEST_32: | ||
870 | #endif | ||
871 | ret = mnt_want_write_file(filp); | ||
872 | if (ret) | ||
873 | goto out; | ||
874 | need_drop_write = 1; | ||
875 | ret = inode_permission(inode, MAY_WRITE); | ||
876 | if (ret) | ||
877 | goto outDropWrite; | ||
878 | break; | ||
879 | /* | ||
880 | * Read access required. | ||
881 | */ | ||
882 | case NCP_IOC_GETMOUNTUID16: | ||
883 | case NCP_IOC_GETMOUNTUID32: | ||
884 | case NCP_IOC_GETMOUNTUID64: | ||
885 | case NCP_IOC_GETROOT: | ||
886 | case NCP_IOC_SIGN_WANTED: | ||
887 | ret = inode_permission(inode, MAY_READ); | ||
888 | if (ret) | ||
889 | goto out; | ||
890 | break; | ||
891 | /* | ||
892 | * Anybody can read these. | ||
893 | */ | ||
894 | case NCP_IOC_GETCHARSETS: | ||
895 | case NCP_IOC_GETDENTRYTTL: | ||
896 | default: | ||
897 | /* Three codes below are protected by CAP_SYS_ADMIN above. */ | ||
898 | case NCP_IOC_SETCHARSETS: | ||
899 | case NCP_IOC_CONN_LOGGED_IN: | ||
900 | case NCP_IOC_SETROOT: | ||
901 | break; | ||
859 | } | 902 | } |
860 | } | 903 | } |
861 | ret = __ncp_ioctl(filp, cmd, arg); | 904 | ret = __ncp_ioctl(inode, cmd, arg); |
862 | if (ncp_ioctl_need_write(cmd)) | 905 | outDropWrite: |
906 | if (need_drop_write) | ||
863 | mnt_drop_write(filp->f_path.mnt); | 907 | mnt_drop_write(filp->f_path.mnt); |
864 | |||
865 | out: | 908 | out: |
866 | unlock_kernel(); | ||
867 | return ret; | 909 | return ret; |
868 | } | 910 | } |
869 | 911 | ||
@@ -872,10 +914,8 @@ long ncp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
872 | { | 914 | { |
873 | long ret; | 915 | long ret; |
874 | 916 | ||
875 | lock_kernel(); | ||
876 | arg = (unsigned long) compat_ptr(arg); | 917 | arg = (unsigned long) compat_ptr(arg); |
877 | ret = ncp_ioctl(file, cmd, arg); | 918 | ret = ncp_ioctl(file, cmd, arg); |
878 | unlock_kernel(); | ||
879 | return ret; | 919 | return ret; |
880 | } | 920 | } |
881 | #endif | 921 | #endif |
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c index 0ec6237a5970..a95615a0b6ac 100644 --- a/fs/ncpfs/ncplib_kernel.c +++ b/fs/ncpfs/ncplib_kernel.c | |||
@@ -107,17 +107,17 @@ ncp_reply_data(struct ncp_server *server, int offset) | |||
107 | return &(server->packet[sizeof(struct ncp_reply_header) + offset]); | 107 | return &(server->packet[sizeof(struct ncp_reply_header) + offset]); |
108 | } | 108 | } |
109 | 109 | ||
110 | static inline u8 BVAL(void *data) | 110 | static inline u8 BVAL(const void *data) |
111 | { | 111 | { |
112 | return *(u8 *)data; | 112 | return *(const u8 *)data; |
113 | } | 113 | } |
114 | 114 | ||
115 | static u8 ncp_reply_byte(struct ncp_server *server, int offset) | 115 | static u8 ncp_reply_byte(struct ncp_server *server, int offset) |
116 | { | 116 | { |
117 | return *(u8 *)ncp_reply_data(server, offset); | 117 | return *(const u8 *)ncp_reply_data(server, offset); |
118 | } | 118 | } |
119 | 119 | ||
120 | static inline u16 WVAL_LH(void *data) | 120 | static inline u16 WVAL_LH(const void *data) |
121 | { | 121 | { |
122 | return get_unaligned_le16(data); | 122 | return get_unaligned_le16(data); |
123 | } | 123 | } |
@@ -134,7 +134,7 @@ ncp_reply_be16(struct ncp_server *server, int offset) | |||
134 | return get_unaligned_be16(ncp_reply_data(server, offset)); | 134 | return get_unaligned_be16(ncp_reply_data(server, offset)); |
135 | } | 135 | } |
136 | 136 | ||
137 | static inline u32 DVAL_LH(void *data) | 137 | static inline u32 DVAL_LH(const void *data) |
138 | { | 138 | { |
139 | return get_unaligned_le32(data); | 139 | return get_unaligned_le32(data); |
140 | } | 140 | } |
@@ -349,9 +349,9 @@ int ncp_dirhandle_free(struct ncp_server* server, __u8 dirhandle) { | |||
349 | return result; | 349 | return result; |
350 | } | 350 | } |
351 | 351 | ||
352 | void ncp_extract_file_info(void *structure, struct nw_info_struct *target) | 352 | void ncp_extract_file_info(const void *structure, struct nw_info_struct *target) |
353 | { | 353 | { |
354 | __u8 *name_len; | 354 | const __u8 *name_len; |
355 | const int info_struct_size = offsetof(struct nw_info_struct, nameLen); | 355 | const int info_struct_size = offsetof(struct nw_info_struct, nameLen); |
356 | 356 | ||
357 | memcpy(target, structure, info_struct_size); | 357 | memcpy(target, structure, info_struct_size); |
@@ -364,7 +364,7 @@ void ncp_extract_file_info(void *structure, struct nw_info_struct *target) | |||
364 | } | 364 | } |
365 | 365 | ||
366 | #ifdef CONFIG_NCPFS_NFS_NS | 366 | #ifdef CONFIG_NCPFS_NFS_NS |
367 | static inline void ncp_extract_nfs_info(unsigned char *structure, | 367 | static inline void ncp_extract_nfs_info(const unsigned char *structure, |
368 | struct nw_nfs_info *target) | 368 | struct nw_nfs_info *target) |
369 | { | 369 | { |
370 | target->mode = DVAL_LH(structure); | 370 | target->mode = DVAL_LH(structure); |
@@ -417,7 +417,7 @@ int ncp_obtain_nfs_info(struct ncp_server *server, | |||
417 | * Returns information for a (one-component) name relative to | 417 | * Returns information for a (one-component) name relative to |
418 | * the specified directory. | 418 | * the specified directory. |
419 | */ | 419 | */ |
420 | int ncp_obtain_info(struct ncp_server *server, struct inode *dir, char *path, | 420 | int ncp_obtain_info(struct ncp_server *server, struct inode *dir, const char *path, |
421 | struct nw_info_struct *target) | 421 | struct nw_info_struct *target) |
422 | { | 422 | { |
423 | __u8 volnum = NCP_FINFO(dir)->volNumber; | 423 | __u8 volnum = NCP_FINFO(dir)->volNumber; |
@@ -452,16 +452,16 @@ out: | |||
452 | #ifdef CONFIG_NCPFS_NFS_NS | 452 | #ifdef CONFIG_NCPFS_NFS_NS |
453 | static int | 453 | static int |
454 | ncp_obtain_DOS_dir_base(struct ncp_server *server, | 454 | ncp_obtain_DOS_dir_base(struct ncp_server *server, |
455 | __u8 volnum, __le32 dirent, | 455 | __u8 ns, __u8 volnum, __le32 dirent, |
456 | char *path, /* At most 1 component */ | 456 | const char *path, /* At most 1 component */ |
457 | __le32 *DOS_dir_base) | 457 | __le32 *DOS_dir_base) |
458 | { | 458 | { |
459 | int result; | 459 | int result; |
460 | 460 | ||
461 | ncp_init_request(server); | 461 | ncp_init_request(server); |
462 | ncp_add_byte(server, 6); /* subfunction */ | 462 | ncp_add_byte(server, 6); /* subfunction */ |
463 | ncp_add_byte(server, server->name_space[volnum]); | 463 | ncp_add_byte(server, ns); |
464 | ncp_add_byte(server, server->name_space[volnum]); | 464 | ncp_add_byte(server, ns); |
465 | ncp_add_word(server, cpu_to_le16(0x8006)); /* get all */ | 465 | ncp_add_word(server, cpu_to_le16(0x8006)); /* get all */ |
466 | ncp_add_dword(server, RIM_DIRECTORY); | 466 | ncp_add_dword(server, RIM_DIRECTORY); |
467 | ncp_add_handle_path(server, volnum, dirent, 1, path); | 467 | ncp_add_handle_path(server, volnum, dirent, 1, path); |
@@ -523,10 +523,27 @@ ncp_get_known_namespace(struct ncp_server *server, __u8 volume) | |||
523 | #endif /* defined(CONFIG_NCPFS_OS2_NS) || defined(CONFIG_NCPFS_NFS_NS) */ | 523 | #endif /* defined(CONFIG_NCPFS_OS2_NS) || defined(CONFIG_NCPFS_NFS_NS) */ |
524 | } | 524 | } |
525 | 525 | ||
526 | int | ||
527 | ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns) | ||
528 | { | ||
529 | int ns = ncp_get_known_namespace(server, volume); | ||
530 | |||
531 | if (ret_ns) | ||
532 | *ret_ns = ns; | ||
533 | |||
534 | DPRINTK("lookup_vol: namespace[%d] = %d\n", | ||
535 | volume, server->name_space[volume]); | ||
536 | |||
537 | if (server->name_space[volume] == ns) | ||
538 | return 0; | ||
539 | server->name_space[volume] = ns; | ||
540 | return 1; | ||
541 | } | ||
542 | |||
526 | static int | 543 | static int |
527 | ncp_ObtainSpecificDirBase(struct ncp_server *server, | 544 | ncp_ObtainSpecificDirBase(struct ncp_server *server, |
528 | __u8 nsSrc, __u8 nsDst, __u8 vol_num, __le32 dir_base, | 545 | __u8 nsSrc, __u8 nsDst, __u8 vol_num, __le32 dir_base, |
529 | char *path, /* At most 1 component */ | 546 | const char *path, /* At most 1 component */ |
530 | __le32 *dirEntNum, __le32 *DosDirNum) | 547 | __le32 *dirEntNum, __le32 *DosDirNum) |
531 | { | 548 | { |
532 | int result; | 549 | int result; |
@@ -560,14 +577,13 @@ ncp_mount_subdir(struct ncp_server *server, | |||
560 | { | 577 | { |
561 | int dstNS; | 578 | int dstNS; |
562 | int result; | 579 | int result; |
563 | 580 | ||
564 | dstNS = ncp_get_known_namespace(server, volNumber); | 581 | ncp_update_known_namespace(server, volNumber, &dstNS); |
565 | if ((result = ncp_ObtainSpecificDirBase(server, srcNS, dstNS, volNumber, | 582 | if ((result = ncp_ObtainSpecificDirBase(server, srcNS, dstNS, volNumber, |
566 | dirEntNum, NULL, newDirEnt, newDosEnt)) != 0) | 583 | dirEntNum, NULL, newDirEnt, newDosEnt)) != 0) |
567 | { | 584 | { |
568 | return result; | 585 | return result; |
569 | } | 586 | } |
570 | server->name_space[volNumber] = dstNS; | ||
571 | *volume = volNumber; | 587 | *volume = volNumber; |
572 | server->m.mounted_vol[1] = 0; | 588 | server->m.mounted_vol[1] = 0; |
573 | server->m.mounted_vol[0] = 'X'; | 589 | server->m.mounted_vol[0] = 'X'; |
@@ -575,11 +591,10 @@ ncp_mount_subdir(struct ncp_server *server, | |||
575 | } | 591 | } |
576 | 592 | ||
577 | int | 593 | int |
578 | ncp_get_volume_root(struct ncp_server *server, const char *volname, | 594 | ncp_get_volume_root(struct ncp_server *server, |
579 | __u32* volume, __le32* dirent, __le32* dosdirent) | 595 | const char *volname, __u32* volume, __le32* dirent, __le32* dosdirent) |
580 | { | 596 | { |
581 | int result; | 597 | int result; |
582 | __u8 volnum; | ||
583 | 598 | ||
584 | DPRINTK("ncp_get_volume_root: looking up vol %s\n", volname); | 599 | DPRINTK("ncp_get_volume_root: looking up vol %s\n", volname); |
585 | 600 | ||
@@ -601,21 +616,14 @@ ncp_get_volume_root(struct ncp_server *server, const char *volname, | |||
601 | return result; | 616 | return result; |
602 | } | 617 | } |
603 | *dirent = *dosdirent = ncp_reply_dword(server, 4); | 618 | *dirent = *dosdirent = ncp_reply_dword(server, 4); |
604 | volnum = ncp_reply_byte(server, 8); | 619 | *volume = ncp_reply_byte(server, 8); |
605 | ncp_unlock_server(server); | 620 | ncp_unlock_server(server); |
606 | *volume = volnum; | ||
607 | |||
608 | server->name_space[volnum] = ncp_get_known_namespace(server, volnum); | ||
609 | |||
610 | DPRINTK("lookup_vol: namespace[%d] = %d\n", | ||
611 | volnum, server->name_space[volnum]); | ||
612 | |||
613 | return 0; | 621 | return 0; |
614 | } | 622 | } |
615 | 623 | ||
616 | int | 624 | int |
617 | ncp_lookup_volume(struct ncp_server *server, const char *volname, | 625 | ncp_lookup_volume(struct ncp_server *server, |
618 | struct nw_info_struct *target) | 626 | const char *volname, struct nw_info_struct *target) |
619 | { | 627 | { |
620 | int result; | 628 | int result; |
621 | 629 | ||
@@ -625,6 +633,7 @@ ncp_lookup_volume(struct ncp_server *server, const char *volname, | |||
625 | if (result) { | 633 | if (result) { |
626 | return result; | 634 | return result; |
627 | } | 635 | } |
636 | ncp_update_known_namespace(server, target->volNumber, NULL); | ||
628 | target->nameLen = strlen(volname); | 637 | target->nameLen = strlen(volname); |
629 | memcpy(target->entryName, volname, target->nameLen+1); | 638 | memcpy(target->entryName, volname, target->nameLen+1); |
630 | target->attributes = aDIR; | 639 | target->attributes = aDIR; |
@@ -676,8 +685,8 @@ int ncp_modify_nfs_info(struct ncp_server *server, __u8 volnum, __le32 dirent, | |||
676 | { | 685 | { |
677 | int result = 0; | 686 | int result = 0; |
678 | 687 | ||
688 | ncp_init_request(server); | ||
679 | if (server->name_space[volnum] == NW_NS_NFS) { | 689 | if (server->name_space[volnum] == NW_NS_NFS) { |
680 | ncp_init_request(server); | ||
681 | ncp_add_byte(server, 25); /* subfunction */ | 690 | ncp_add_byte(server, 25); /* subfunction */ |
682 | ncp_add_byte(server, server->name_space[volnum]); | 691 | ncp_add_byte(server, server->name_space[volnum]); |
683 | ncp_add_byte(server, NW_NS_NFS); | 692 | ncp_add_byte(server, NW_NS_NFS); |
@@ -690,8 +699,8 @@ int ncp_modify_nfs_info(struct ncp_server *server, __u8 volnum, __le32 dirent, | |||
690 | ncp_add_dword_lh(server, 1); /* nlinks */ | 699 | ncp_add_dword_lh(server, 1); /* nlinks */ |
691 | ncp_add_dword_lh(server, rdev); | 700 | ncp_add_dword_lh(server, rdev); |
692 | result = ncp_request(server, 87); | 701 | result = ncp_request(server, 87); |
693 | ncp_unlock_server(server); | ||
694 | } | 702 | } |
703 | ncp_unlock_server(server); | ||
695 | return result; | 704 | return result; |
696 | } | 705 | } |
697 | #endif | 706 | #endif |
@@ -700,7 +709,7 @@ int ncp_modify_nfs_info(struct ncp_server *server, __u8 volnum, __le32 dirent, | |||
700 | static int | 709 | static int |
701 | ncp_DeleteNSEntry(struct ncp_server *server, | 710 | ncp_DeleteNSEntry(struct ncp_server *server, |
702 | __u8 have_dir_base, __u8 volnum, __le32 dirent, | 711 | __u8 have_dir_base, __u8 volnum, __le32 dirent, |
703 | char* name, __u8 ns, __le16 attr) | 712 | const char* name, __u8 ns, __le16 attr) |
704 | { | 713 | { |
705 | int result; | 714 | int result; |
706 | 715 | ||
@@ -734,23 +743,25 @@ ncp_del_file_or_subdir2(struct ncp_server *server, | |||
734 | 743 | ||
735 | int | 744 | int |
736 | ncp_del_file_or_subdir(struct ncp_server *server, | 745 | ncp_del_file_or_subdir(struct ncp_server *server, |
737 | struct inode *dir, char *name) | 746 | struct inode *dir, const char *name) |
738 | { | 747 | { |
739 | __u8 volnum = NCP_FINFO(dir)->volNumber; | 748 | __u8 volnum = NCP_FINFO(dir)->volNumber; |
740 | __le32 dirent = NCP_FINFO(dir)->dirEntNum; | 749 | __le32 dirent = NCP_FINFO(dir)->dirEntNum; |
750 | int name_space; | ||
741 | 751 | ||
752 | name_space = server->name_space[volnum]; | ||
742 | #ifdef CONFIG_NCPFS_NFS_NS | 753 | #ifdef CONFIG_NCPFS_NFS_NS |
743 | if (server->name_space[volnum]==NW_NS_NFS) | 754 | if (name_space == NW_NS_NFS) |
744 | { | 755 | { |
745 | int result; | 756 | int result; |
746 | 757 | ||
747 | result=ncp_obtain_DOS_dir_base(server, volnum, dirent, name, &dirent); | 758 | result=ncp_obtain_DOS_dir_base(server, name_space, volnum, dirent, name, &dirent); |
748 | if (result) return result; | 759 | if (result) return result; |
749 | return ncp_DeleteNSEntry(server, 1, volnum, dirent, NULL, NW_NS_DOS, cpu_to_le16(0x8006)); | 760 | name = NULL; |
761 | name_space = NW_NS_DOS; | ||
750 | } | 762 | } |
751 | else | ||
752 | #endif /* CONFIG_NCPFS_NFS_NS */ | 763 | #endif /* CONFIG_NCPFS_NFS_NS */ |
753 | return ncp_DeleteNSEntry(server, 1, volnum, dirent, name, server->name_space[volnum], cpu_to_le16(0x8006)); | 764 | return ncp_DeleteNSEntry(server, 1, volnum, dirent, name, name_space, cpu_to_le16(0x8006)); |
754 | } | 765 | } |
755 | 766 | ||
756 | static inline void ConvertToNWfromDWORD(__u16 v0, __u16 v1, __u8 ret[6]) | 767 | static inline void ConvertToNWfromDWORD(__u16 v0, __u16 v1, __u8 ret[6]) |
@@ -765,7 +776,7 @@ static inline void ConvertToNWfromDWORD(__u16 v0, __u16 v1, __u8 ret[6]) | |||
765 | /* If both dir and name are NULL, then in target there's already a | 776 | /* If both dir and name are NULL, then in target there's already a |
766 | looked-up entry that wants to be opened. */ | 777 | looked-up entry that wants to be opened. */ |
767 | int ncp_open_create_file_or_subdir(struct ncp_server *server, | 778 | int ncp_open_create_file_or_subdir(struct ncp_server *server, |
768 | struct inode *dir, char *name, | 779 | struct inode *dir, const char *name, |
769 | int open_create_mode, | 780 | int open_create_mode, |
770 | __le32 create_attributes, | 781 | __le32 create_attributes, |
771 | __le16 desired_acc_rights, | 782 | __le16 desired_acc_rights, |
@@ -890,8 +901,8 @@ int ncp_search_for_fileset(struct ncp_server *server, | |||
890 | 901 | ||
891 | static int | 902 | static int |
892 | ncp_RenameNSEntry(struct ncp_server *server, | 903 | ncp_RenameNSEntry(struct ncp_server *server, |
893 | struct inode *old_dir, char *old_name, __le16 old_type, | 904 | struct inode *old_dir, const char *old_name, __le16 old_type, |
894 | struct inode *new_dir, char *new_name) | 905 | struct inode *new_dir, const char *new_name) |
895 | { | 906 | { |
896 | int result = -EINVAL; | 907 | int result = -EINVAL; |
897 | 908 | ||
@@ -929,8 +940,8 @@ out: | |||
929 | } | 940 | } |
930 | 941 | ||
931 | int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, | 942 | int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, |
932 | struct inode *old_dir, char *old_name, | 943 | struct inode *old_dir, const char *old_name, |
933 | struct inode *new_dir, char *new_name) | 944 | struct inode *new_dir, const char *new_name) |
934 | { | 945 | { |
935 | int result; | 946 | int result; |
936 | __le16 old_type = cpu_to_le16(0x06); | 947 | __le16 old_type = cpu_to_le16(0x06); |
@@ -958,7 +969,7 @@ int | |||
958 | ncp_read_kernel(struct ncp_server *server, const char *file_id, | 969 | ncp_read_kernel(struct ncp_server *server, const char *file_id, |
959 | __u32 offset, __u16 to_read, char *target, int *bytes_read) | 970 | __u32 offset, __u16 to_read, char *target, int *bytes_read) |
960 | { | 971 | { |
961 | char *source; | 972 | const char *source; |
962 | int result; | 973 | int result; |
963 | 974 | ||
964 | ncp_init_request(server); | 975 | ncp_init_request(server); |
diff --git a/fs/ncpfs/ncplib_kernel.h b/fs/ncpfs/ncplib_kernel.h index 2441d1ab57dc..3c57eca634ce 100644 --- a/fs/ncpfs/ncplib_kernel.h +++ b/fs/ncpfs/ncplib_kernel.h | |||
@@ -65,10 +65,11 @@ static inline void ncp_inode_close(struct inode *inode) { | |||
65 | atomic_dec(&NCP_FINFO(inode)->opened); | 65 | atomic_dec(&NCP_FINFO(inode)->opened); |
66 | } | 66 | } |
67 | 67 | ||
68 | void ncp_extract_file_info(void* src, struct nw_info_struct* target); | 68 | void ncp_extract_file_info(const void* src, struct nw_info_struct* target); |
69 | int ncp_obtain_info(struct ncp_server *server, struct inode *, char *, | 69 | int ncp_obtain_info(struct ncp_server *server, struct inode *, const char *, |
70 | struct nw_info_struct *target); | 70 | struct nw_info_struct *target); |
71 | int ncp_obtain_nfs_info(struct ncp_server *server, struct nw_info_struct *target); | 71 | int ncp_obtain_nfs_info(struct ncp_server *server, struct nw_info_struct *target); |
72 | int ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns); | ||
72 | int ncp_get_volume_root(struct ncp_server *server, const char *volname, | 73 | int ncp_get_volume_root(struct ncp_server *server, const char *volname, |
73 | __u32 *volume, __le32 *dirent, __le32 *dosdirent); | 74 | __u32 *volume, __le32 *dirent, __le32 *dosdirent); |
74 | int ncp_lookup_volume(struct ncp_server *, const char *, struct nw_info_struct *); | 75 | int ncp_lookup_volume(struct ncp_server *, const char *, struct nw_info_struct *); |
@@ -80,8 +81,8 @@ int ncp_modify_nfs_info(struct ncp_server *, __u8 volnum, __le32 dirent, | |||
80 | __u32 mode, __u32 rdev); | 81 | __u32 mode, __u32 rdev); |
81 | 82 | ||
82 | int ncp_del_file_or_subdir2(struct ncp_server *, struct dentry*); | 83 | int ncp_del_file_or_subdir2(struct ncp_server *, struct dentry*); |
83 | int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, char *); | 84 | int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, const char *); |
84 | int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, char *, | 85 | int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, const char *, |
85 | int, __le32, __le16, struct ncp_entry_info *); | 86 | int, __le32, __le16, struct ncp_entry_info *); |
86 | 87 | ||
87 | int ncp_initialize_search(struct ncp_server *, struct inode *, | 88 | int ncp_initialize_search(struct ncp_server *, struct inode *, |
@@ -93,7 +94,7 @@ int ncp_search_for_fileset(struct ncp_server *server, | |||
93 | char** rbuf, size_t* rsize); | 94 | char** rbuf, size_t* rsize); |
94 | 95 | ||
95 | int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, | 96 | int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, |
96 | struct inode *, char *, struct inode *, char *); | 97 | struct inode *, const char *, struct inode *, const char *); |
97 | 98 | ||
98 | 99 | ||
99 | int | 100 | int |
@@ -170,13 +171,13 @@ static inline int ncp_strnicmp(struct nls_table *t, const unsigned char *s1, | |||
170 | #endif /* CONFIG_NCPFS_NLS */ | 171 | #endif /* CONFIG_NCPFS_NLS */ |
171 | 172 | ||
172 | #define NCP_GET_AGE(dentry) (jiffies - (dentry)->d_time) | 173 | #define NCP_GET_AGE(dentry) (jiffies - (dentry)->d_time) |
173 | #define NCP_MAX_AGE(server) ((server)->dentry_ttl) | 174 | #define NCP_MAX_AGE(server) atomic_read(&(server)->dentry_ttl) |
174 | #define NCP_TEST_AGE(server,dentry) (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server)) | 175 | #define NCP_TEST_AGE(server,dentry) (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server)) |
175 | 176 | ||
176 | static inline void | 177 | static inline void |
177 | ncp_age_dentry(struct ncp_server* server, struct dentry* dentry) | 178 | ncp_age_dentry(struct ncp_server* server, struct dentry* dentry) |
178 | { | 179 | { |
179 | dentry->d_time = jiffies - server->dentry_ttl; | 180 | dentry->d_time = jiffies - NCP_MAX_AGE(server); |
180 | } | 181 | } |
181 | 182 | ||
182 | static inline void | 183 | static inline void |
diff --git a/fs/ncpfs/ncpsign_kernel.c b/fs/ncpfs/ncpsign_kernel.c index 7c0b5c21e6cf..d8b2d7e6910b 100644 --- a/fs/ncpfs/ncpsign_kernel.c +++ b/fs/ncpfs/ncpsign_kernel.c | |||
@@ -15,21 +15,21 @@ | |||
15 | 15 | ||
16 | /* i386: 32-bit, little endian, handles mis-alignment */ | 16 | /* i386: 32-bit, little endian, handles mis-alignment */ |
17 | #ifdef __i386__ | 17 | #ifdef __i386__ |
18 | #define GET_LE32(p) (*(int *)(p)) | 18 | #define GET_LE32(p) (*(const int *)(p)) |
19 | #define PUT_LE32(p,v) { *(int *)(p)=v; } | 19 | #define PUT_LE32(p,v) { *(int *)(p)=v; } |
20 | #else | 20 | #else |
21 | /* from include/ncplib.h */ | 21 | /* from include/ncplib.h */ |
22 | #define BVAL(buf,pos) (((__u8 *)(buf))[pos]) | 22 | #define BVAL(buf,pos) (((const __u8 *)(buf))[pos]) |
23 | #define PVAL(buf,pos) ((unsigned)BVAL(buf,pos)) | 23 | #define PVAL(buf,pos) ((unsigned)BVAL(buf,pos)) |
24 | #define BSET(buf,pos,val) (BVAL(buf,pos) = (val)) | 24 | #define BSET(buf,pos,val) (((__u8 *)(buf))[pos] = (val)) |
25 | 25 | ||
26 | static inline __u16 | 26 | static inline __u16 |
27 | WVAL_LH(__u8 * buf, int pos) | 27 | WVAL_LH(const __u8 * buf, int pos) |
28 | { | 28 | { |
29 | return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8; | 29 | return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8; |
30 | } | 30 | } |
31 | static inline __u32 | 31 | static inline __u32 |
32 | DVAL_LH(__u8 * buf, int pos) | 32 | DVAL_LH(const __u8 * buf, int pos) |
33 | { | 33 | { |
34 | return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16; | 34 | return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16; |
35 | } | 35 | } |
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c index c7ff6c700a6e..668bd267346e 100644 --- a/fs/ncpfs/sock.c +++ b/fs/ncpfs/sock.c | |||
@@ -746,7 +746,6 @@ static int ncp_do_request(struct ncp_server *server, int size, | |||
746 | return -EIO; | 746 | return -EIO; |
747 | } | 747 | } |
748 | if (!ncp_conn_valid(server)) { | 748 | if (!ncp_conn_valid(server)) { |
749 | printk(KERN_ERR "ncpfs: Connection invalid!\n"); | ||
750 | return -EIO; | 749 | return -EIO; |
751 | } | 750 | } |
752 | { | 751 | { |
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index b9c3c43cea1d..232a7eead33a 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -71,20 +71,20 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_ | |||
71 | if (inode->i_flock == NULL) | 71 | if (inode->i_flock == NULL) |
72 | goto out; | 72 | goto out; |
73 | 73 | ||
74 | /* Protect inode->i_flock using the BKL */ | 74 | /* Protect inode->i_flock using the file locks lock */ |
75 | lock_kernel(); | 75 | lock_flocks(); |
76 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { | 76 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { |
77 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) | 77 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) |
78 | continue; | 78 | continue; |
79 | if (nfs_file_open_context(fl->fl_file) != ctx) | 79 | if (nfs_file_open_context(fl->fl_file) != ctx) |
80 | continue; | 80 | continue; |
81 | unlock_kernel(); | 81 | unlock_flocks(); |
82 | status = nfs4_lock_delegation_recall(state, fl); | 82 | status = nfs4_lock_delegation_recall(state, fl); |
83 | if (status < 0) | 83 | if (status < 0) |
84 | goto out; | 84 | goto out; |
85 | lock_kernel(); | 85 | lock_flocks(); |
86 | } | 86 | } |
87 | unlock_kernel(); | 87 | unlock_flocks(); |
88 | out: | 88 | out: |
89 | return status; | 89 | return status; |
90 | } | 90 | } |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 3e2f19b04c06..96524c5dca6b 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -40,7 +40,7 @@ | |||
40 | 40 | ||
41 | #include <linux/kernel.h> | 41 | #include <linux/kernel.h> |
42 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
43 | #include <linux/smp_lock.h> | 43 | #include <linux/fs.h> |
44 | #include <linux/nfs_fs.h> | 44 | #include <linux/nfs_fs.h> |
45 | #include <linux/nfs_idmap.h> | 45 | #include <linux/nfs_idmap.h> |
46 | #include <linux/kthread.h> | 46 | #include <linux/kthread.h> |
@@ -970,13 +970,13 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ | |||
970 | /* Guard against delegation returns and new lock/unlock calls */ | 970 | /* Guard against delegation returns and new lock/unlock calls */ |
971 | down_write(&nfsi->rwsem); | 971 | down_write(&nfsi->rwsem); |
972 | /* Protect inode->i_flock using the BKL */ | 972 | /* Protect inode->i_flock using the BKL */ |
973 | lock_kernel(); | 973 | lock_flocks(); |
974 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { | 974 | for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { |
975 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) | 975 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) |
976 | continue; | 976 | continue; |
977 | if (nfs_file_open_context(fl->fl_file)->state != state) | 977 | if (nfs_file_open_context(fl->fl_file)->state != state) |
978 | continue; | 978 | continue; |
979 | unlock_kernel(); | 979 | unlock_flocks(); |
980 | status = ops->recover_lock(state, fl); | 980 | status = ops->recover_lock(state, fl); |
981 | switch (status) { | 981 | switch (status) { |
982 | case 0: | 982 | case 0: |
@@ -1003,9 +1003,9 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ | |||
1003 | /* kill_proc(fl->fl_pid, SIGLOST, 1); */ | 1003 | /* kill_proc(fl->fl_pid, SIGLOST, 1); */ |
1004 | status = 0; | 1004 | status = 0; |
1005 | } | 1005 | } |
1006 | lock_kernel(); | 1006 | lock_flocks(); |
1007 | } | 1007 | } |
1008 | unlock_kernel(); | 1008 | unlock_flocks(); |
1009 | out: | 1009 | out: |
1010 | up_write(&nfsi->rwsem); | 1010 | up_write(&nfsi->rwsem); |
1011 | return status; | 1011 | return status; |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index cf0d2ffb3c84..a7292fcf7718 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/file.h> | 35 | #include <linux/file.h> |
36 | #include <linux/smp_lock.h> | 36 | #include <linux/fs.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/namei.h> | 38 | #include <linux/namei.h> |
39 | #include <linux/swap.h> | 39 | #include <linux/swap.h> |
@@ -3895,7 +3895,7 @@ check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner) | |||
3895 | struct inode *inode = filp->fi_inode; | 3895 | struct inode *inode = filp->fi_inode; |
3896 | int status = 0; | 3896 | int status = 0; |
3897 | 3897 | ||
3898 | lock_kernel(); | 3898 | lock_flocks(); |
3899 | for (flpp = &inode->i_flock; *flpp != NULL; flpp = &(*flpp)->fl_next) { | 3899 | for (flpp = &inode->i_flock; *flpp != NULL; flpp = &(*flpp)->fl_next) { |
3900 | if ((*flpp)->fl_owner == (fl_owner_t)lowner) { | 3900 | if ((*flpp)->fl_owner == (fl_owner_t)lowner) { |
3901 | status = 1; | 3901 | status = 1; |
@@ -3903,7 +3903,7 @@ check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner) | |||
3903 | } | 3903 | } |
3904 | } | 3904 | } |
3905 | out: | 3905 | out: |
3906 | unlock_kernel(); | 3906 | unlock_flocks(); |
3907 | return status; | 3907 | return status; |
3908 | } | 3908 | } |
3909 | 3909 | ||
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index f90a33d9a5b0..0442ee3b394f 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | #include <linux/fs.h> | 23 | #include <linux/fs.h> |
24 | #include <linux/wait.h> | 24 | #include <linux/wait.h> |
25 | #include <linux/smp_lock.h> /* lock_kernel(), unlock_kernel() */ | ||
26 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
27 | #include <linux/capability.h> /* capable() */ | 26 | #include <linux/capability.h> /* capable() */ |
28 | #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ | 27 | #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ |
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 922263393c76..9f4913f78408 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <linux/parser.h> | 45 | #include <linux/parser.h> |
46 | #include <linux/random.h> | 46 | #include <linux/random.h> |
47 | #include <linux/crc32.h> | 47 | #include <linux/crc32.h> |
48 | #include <linux/smp_lock.h> | ||
49 | #include <linux/vfs.h> | 48 | #include <linux/vfs.h> |
50 | #include <linux/writeback.h> | 49 | #include <linux/writeback.h> |
51 | #include <linux/kobject.h> | 50 | #include <linux/kobject.h> |
@@ -342,8 +341,6 @@ static void nilfs_put_super(struct super_block *sb) | |||
342 | struct nilfs_sb_info *sbi = NILFS_SB(sb); | 341 | struct nilfs_sb_info *sbi = NILFS_SB(sb); |
343 | struct the_nilfs *nilfs = sbi->s_nilfs; | 342 | struct the_nilfs *nilfs = sbi->s_nilfs; |
344 | 343 | ||
345 | lock_kernel(); | ||
346 | |||
347 | nilfs_detach_segment_constructor(sbi); | 344 | nilfs_detach_segment_constructor(sbi); |
348 | 345 | ||
349 | if (!(sb->s_flags & MS_RDONLY)) { | 346 | if (!(sb->s_flags & MS_RDONLY)) { |
@@ -361,8 +358,6 @@ static void nilfs_put_super(struct super_block *sb) | |||
361 | sbi->s_super = NULL; | 358 | sbi->s_super = NULL; |
362 | sb->s_fs_info = NULL; | 359 | sb->s_fs_info = NULL; |
363 | nilfs_put_sbinfo(sbi); | 360 | nilfs_put_sbinfo(sbi); |
364 | |||
365 | unlock_kernel(); | ||
366 | } | 361 | } |
367 | 362 | ||
368 | static int nilfs_sync_fs(struct super_block *sb, int wait) | 363 | static int nilfs_sync_fs(struct super_block *sb, int wait) |
@@ -949,8 +944,6 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) | |||
949 | struct nilfs_mount_options old_opts; | 944 | struct nilfs_mount_options old_opts; |
950 | int was_snapshot, err; | 945 | int was_snapshot, err; |
951 | 946 | ||
952 | lock_kernel(); | ||
953 | |||
954 | down_write(&nilfs->ns_super_sem); | 947 | down_write(&nilfs->ns_super_sem); |
955 | old_sb_flags = sb->s_flags; | 948 | old_sb_flags = sb->s_flags; |
956 | old_opts.mount_opt = sbi->s_mount_opt; | 949 | old_opts.mount_opt = sbi->s_mount_opt; |
@@ -1024,7 +1017,6 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) | |||
1024 | } | 1017 | } |
1025 | out: | 1018 | out: |
1026 | up_write(&nilfs->ns_super_sem); | 1019 | up_write(&nilfs->ns_super_sem); |
1027 | unlock_kernel(); | ||
1028 | return 0; | 1020 | return 0; |
1029 | 1021 | ||
1030 | restore_opts: | 1022 | restore_opts: |
@@ -1032,7 +1024,6 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data) | |||
1032 | sbi->s_mount_opt = old_opts.mount_opt; | 1024 | sbi->s_mount_opt = old_opts.mount_opt; |
1033 | sbi->s_snapshot_cno = old_opts.snapshot_cno; | 1025 | sbi->s_snapshot_cno = old_opts.snapshot_cno; |
1034 | up_write(&nilfs->ns_super_sem); | 1026 | up_write(&nilfs->ns_super_sem); |
1035 | unlock_kernel(); | ||
1036 | return err; | 1027 | return err; |
1037 | } | 1028 | } |
1038 | 1029 | ||
@@ -1205,7 +1196,6 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags, | |||
1205 | put_nilfs(nilfs); | 1196 | put_nilfs(nilfs); |
1206 | failed: | 1197 | failed: |
1207 | close_bdev_exclusive(sd.bdev, mode); | 1198 | close_bdev_exclusive(sd.bdev, mode); |
1208 | |||
1209 | return err; | 1199 | return err; |
1210 | 1200 | ||
1211 | cancel_new: | 1201 | cancel_new: |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 512806171bfa..19c5180f8a28 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/buffer_head.h> | 30 | #include <linux/buffer_head.h> |
31 | #include <linux/vfs.h> | 31 | #include <linux/vfs.h> |
32 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
33 | #include <linux/smp_lock.h> | ||
34 | #include <linux/bitmap.h> | 33 | #include <linux/bitmap.h> |
35 | 34 | ||
36 | #include "sysctl.h" | 35 | #include "sysctl.h" |
@@ -445,7 +444,6 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
445 | 444 | ||
446 | ntfs_debug("Entering with remount options string: %s", opt); | 445 | ntfs_debug("Entering with remount options string: %s", opt); |
447 | 446 | ||
448 | lock_kernel(); | ||
449 | #ifndef NTFS_RW | 447 | #ifndef NTFS_RW |
450 | /* For read-only compiled driver, enforce read-only flag. */ | 448 | /* For read-only compiled driver, enforce read-only flag. */ |
451 | *flags |= MS_RDONLY; | 449 | *flags |= MS_RDONLY; |
@@ -469,18 +467,15 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
469 | if (NVolErrors(vol)) { | 467 | if (NVolErrors(vol)) { |
470 | ntfs_error(sb, "Volume has errors and is read-only%s", | 468 | ntfs_error(sb, "Volume has errors and is read-only%s", |
471 | es); | 469 | es); |
472 | unlock_kernel(); | ||
473 | return -EROFS; | 470 | return -EROFS; |
474 | } | 471 | } |
475 | if (vol->vol_flags & VOLUME_IS_DIRTY) { | 472 | if (vol->vol_flags & VOLUME_IS_DIRTY) { |
476 | ntfs_error(sb, "Volume is dirty and read-only%s", es); | 473 | ntfs_error(sb, "Volume is dirty and read-only%s", es); |
477 | unlock_kernel(); | ||
478 | return -EROFS; | 474 | return -EROFS; |
479 | } | 475 | } |
480 | if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { | 476 | if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { |
481 | ntfs_error(sb, "Volume has been modified by chkdsk " | 477 | ntfs_error(sb, "Volume has been modified by chkdsk " |
482 | "and is read-only%s", es); | 478 | "and is read-only%s", es); |
483 | unlock_kernel(); | ||
484 | return -EROFS; | 479 | return -EROFS; |
485 | } | 480 | } |
486 | if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { | 481 | if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { |
@@ -488,13 +483,11 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
488 | "(0x%x) and is read-only%s", | 483 | "(0x%x) and is read-only%s", |
489 | (unsigned)le16_to_cpu(vol->vol_flags), | 484 | (unsigned)le16_to_cpu(vol->vol_flags), |
490 | es); | 485 | es); |
491 | unlock_kernel(); | ||
492 | return -EROFS; | 486 | return -EROFS; |
493 | } | 487 | } |
494 | if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { | 488 | if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { |
495 | ntfs_error(sb, "Failed to set dirty bit in volume " | 489 | ntfs_error(sb, "Failed to set dirty bit in volume " |
496 | "information flags%s", es); | 490 | "information flags%s", es); |
497 | unlock_kernel(); | ||
498 | return -EROFS; | 491 | return -EROFS; |
499 | } | 492 | } |
500 | #if 0 | 493 | #if 0 |
@@ -514,21 +507,18 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
514 | ntfs_error(sb, "Failed to empty journal $LogFile%s", | 507 | ntfs_error(sb, "Failed to empty journal $LogFile%s", |
515 | es); | 508 | es); |
516 | NVolSetErrors(vol); | 509 | NVolSetErrors(vol); |
517 | unlock_kernel(); | ||
518 | return -EROFS; | 510 | return -EROFS; |
519 | } | 511 | } |
520 | if (!ntfs_mark_quotas_out_of_date(vol)) { | 512 | if (!ntfs_mark_quotas_out_of_date(vol)) { |
521 | ntfs_error(sb, "Failed to mark quotas out of date%s", | 513 | ntfs_error(sb, "Failed to mark quotas out of date%s", |
522 | es); | 514 | es); |
523 | NVolSetErrors(vol); | 515 | NVolSetErrors(vol); |
524 | unlock_kernel(); | ||
525 | return -EROFS; | 516 | return -EROFS; |
526 | } | 517 | } |
527 | if (!ntfs_stamp_usnjrnl(vol)) { | 518 | if (!ntfs_stamp_usnjrnl(vol)) { |
528 | ntfs_error(sb, "Failed to stamp transation log " | 519 | ntfs_error(sb, "Failed to stamp transation log " |
529 | "($UsnJrnl)%s", es); | 520 | "($UsnJrnl)%s", es); |
530 | NVolSetErrors(vol); | 521 | NVolSetErrors(vol); |
531 | unlock_kernel(); | ||
532 | return -EROFS; | 522 | return -EROFS; |
533 | } | 523 | } |
534 | } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { | 524 | } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { |
@@ -544,11 +534,9 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
544 | 534 | ||
545 | // TODO: Deal with *flags. | 535 | // TODO: Deal with *flags. |
546 | 536 | ||
547 | if (!parse_options(vol, opt)) { | 537 | if (!parse_options(vol, opt)) |
548 | unlock_kernel(); | ||
549 | return -EINVAL; | 538 | return -EINVAL; |
550 | } | 539 | |
551 | unlock_kernel(); | ||
552 | ntfs_debug("Done."); | 540 | ntfs_debug("Done."); |
553 | return 0; | 541 | return 0; |
554 | } | 542 | } |
@@ -2261,8 +2249,6 @@ static void ntfs_put_super(struct super_block *sb) | |||
2261 | 2249 | ||
2262 | ntfs_debug("Entering."); | 2250 | ntfs_debug("Entering."); |
2263 | 2251 | ||
2264 | lock_kernel(); | ||
2265 | |||
2266 | #ifdef NTFS_RW | 2252 | #ifdef NTFS_RW |
2267 | /* | 2253 | /* |
2268 | * Commit all inodes while they are still open in case some of them | 2254 | * Commit all inodes while they are still open in case some of them |
@@ -2433,8 +2419,6 @@ static void ntfs_put_super(struct super_block *sb) | |||
2433 | 2419 | ||
2434 | sb->s_fs_info = NULL; | 2420 | sb->s_fs_info = NULL; |
2435 | kfree(vol); | 2421 | kfree(vol); |
2436 | |||
2437 | unlock_kernel(); | ||
2438 | } | 2422 | } |
2439 | 2423 | ||
2440 | /** | 2424 | /** |
@@ -2772,8 +2756,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2772 | init_rwsem(&vol->mftbmp_lock); | 2756 | init_rwsem(&vol->mftbmp_lock); |
2773 | init_rwsem(&vol->lcnbmp_lock); | 2757 | init_rwsem(&vol->lcnbmp_lock); |
2774 | 2758 | ||
2775 | unlock_kernel(); | ||
2776 | |||
2777 | /* By default, enable sparse support. */ | 2759 | /* By default, enable sparse support. */ |
2778 | NVolSetSparseEnabled(vol); | 2760 | NVolSetSparseEnabled(vol); |
2779 | 2761 | ||
@@ -2940,7 +2922,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2940 | } | 2922 | } |
2941 | mutex_unlock(&ntfs_lock); | 2923 | mutex_unlock(&ntfs_lock); |
2942 | sb->s_export_op = &ntfs_export_ops; | 2924 | sb->s_export_op = &ntfs_export_ops; |
2943 | lock_kernel(); | ||
2944 | lockdep_on(); | 2925 | lockdep_on(); |
2945 | return 0; | 2926 | return 0; |
2946 | } | 2927 | } |
@@ -3057,7 +3038,6 @@ iput_tmp_ino_err_out_now: | |||
3057 | } | 3038 | } |
3058 | /* Errors at this stage are irrelevant. */ | 3039 | /* Errors at this stage are irrelevant. */ |
3059 | err_out_now: | 3040 | err_out_now: |
3060 | lock_kernel(); | ||
3061 | sb->s_fs_info = NULL; | 3041 | sb->s_fs_info = NULL; |
3062 | kfree(vol); | 3042 | kfree(vol); |
3063 | ntfs_debug("Failed, returning -EINVAL."); | 3043 | ntfs_debug("Failed, returning -EINVAL."); |
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index 2dc57bca0688..0e68f542ef2e 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/smp_lock.h> | ||
26 | #include <linux/reboot.h> | 25 | #include <linux/reboot.h> |
27 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
28 | 27 | ||
@@ -612,12 +611,10 @@ static int ocfs2_control_open(struct inode *inode, struct file *file) | |||
612 | return -ENOMEM; | 611 | return -ENOMEM; |
613 | p->op_this_node = -1; | 612 | p->op_this_node = -1; |
614 | 613 | ||
615 | lock_kernel(); | ||
616 | mutex_lock(&ocfs2_control_lock); | 614 | mutex_lock(&ocfs2_control_lock); |
617 | file->private_data = p; | 615 | file->private_data = p; |
618 | list_add(&p->op_list, &ocfs2_control_private_list); | 616 | list_add(&p->op_list, &ocfs2_control_private_list); |
619 | mutex_unlock(&ocfs2_control_lock); | 617 | mutex_unlock(&ocfs2_control_lock); |
620 | unlock_kernel(); | ||
621 | 618 | ||
622 | return 0; | 619 | return 0; |
623 | } | 620 | } |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index a8a0ca44f88f..56f0cb395820 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -630,8 +630,6 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) | |||
630 | struct ocfs2_super *osb = OCFS2_SB(sb); | 630 | struct ocfs2_super *osb = OCFS2_SB(sb); |
631 | u32 tmp; | 631 | u32 tmp; |
632 | 632 | ||
633 | lock_kernel(); | ||
634 | |||
635 | if (!ocfs2_parse_options(sb, data, &parsed_options, 1) || | 633 | if (!ocfs2_parse_options(sb, data, &parsed_options, 1) || |
636 | !ocfs2_check_set_options(sb, &parsed_options)) { | 634 | !ocfs2_check_set_options(sb, &parsed_options)) { |
637 | ret = -EINVAL; | 635 | ret = -EINVAL; |
@@ -739,7 +737,6 @@ unlock_osb: | |||
739 | MS_POSIXACL : 0); | 737 | MS_POSIXACL : 0); |
740 | } | 738 | } |
741 | out: | 739 | out: |
742 | unlock_kernel(); | ||
743 | return ret; | 740 | return ret; |
744 | } | 741 | } |
745 | 742 | ||
@@ -1696,13 +1693,9 @@ static void ocfs2_put_super(struct super_block *sb) | |||
1696 | { | 1693 | { |
1697 | mlog_entry("(0x%p)\n", sb); | 1694 | mlog_entry("(0x%p)\n", sb); |
1698 | 1695 | ||
1699 | lock_kernel(); | ||
1700 | |||
1701 | ocfs2_sync_blockdev(sb); | 1696 | ocfs2_sync_blockdev(sb); |
1702 | ocfs2_dismount_volume(sb, 0); | 1697 | ocfs2_dismount_volume(sb, 0); |
1703 | 1698 | ||
1704 | unlock_kernel(); | ||
1705 | |||
1706 | mlog_exit_void(); | 1699 | mlog_exit_void(); |
1707 | } | 1700 | } |
1708 | 1701 | ||
diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c index 6e8fc62b40a8..7b0329468a5d 100644 --- a/fs/qnx4/dir.c +++ b/fs/qnx4/dir.c | |||
@@ -11,7 +11,6 @@ | |||
11 | * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support. | 11 | * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/smp_lock.h> | ||
15 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
16 | #include "qnx4.h" | 15 | #include "qnx4.h" |
17 | 16 | ||
@@ -29,8 +28,6 @@ static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
29 | QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size)); | 28 | QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size)); |
30 | QNX4DEBUG((KERN_INFO "filp->f_pos = %ld\n", (long) filp->f_pos)); | 29 | QNX4DEBUG((KERN_INFO "filp->f_pos = %ld\n", (long) filp->f_pos)); |
31 | 30 | ||
32 | lock_kernel(); | ||
33 | |||
34 | while (filp->f_pos < inode->i_size) { | 31 | while (filp->f_pos < inode->i_size) { |
35 | blknum = qnx4_block_map( inode, filp->f_pos >> QNX4_BLOCK_SIZE_BITS ); | 32 | blknum = qnx4_block_map( inode, filp->f_pos >> QNX4_BLOCK_SIZE_BITS ); |
36 | bh = sb_bread(inode->i_sb, blknum); | 33 | bh = sb_bread(inode->i_sb, blknum); |
@@ -71,7 +68,6 @@ static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
71 | brelse(bh); | 68 | brelse(bh); |
72 | } | 69 | } |
73 | out: | 70 | out: |
74 | unlock_kernel(); | ||
75 | return 0; | 71 | return 0; |
76 | } | 72 | } |
77 | 73 | ||
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index 16829722be93..01bad30026fc 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/highuid.h> | 18 | #include <linux/highuid.h> |
19 | #include <linux/smp_lock.h> | ||
20 | #include <linux/pagemap.h> | 19 | #include <linux/pagemap.h> |
21 | #include <linux/buffer_head.h> | 20 | #include <linux/buffer_head.h> |
22 | #include <linux/writeback.h> | 21 | #include <linux/writeback.h> |
@@ -157,8 +156,6 @@ static int qnx4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
157 | struct super_block *sb = dentry->d_sb; | 156 | struct super_block *sb = dentry->d_sb; |
158 | u64 id = huge_encode_dev(sb->s_bdev->bd_dev); | 157 | u64 id = huge_encode_dev(sb->s_bdev->bd_dev); |
159 | 158 | ||
160 | lock_kernel(); | ||
161 | |||
162 | buf->f_type = sb->s_magic; | 159 | buf->f_type = sb->s_magic; |
163 | buf->f_bsize = sb->s_blocksize; | 160 | buf->f_bsize = sb->s_blocksize; |
164 | buf->f_blocks = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size) * 8; | 161 | buf->f_blocks = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size) * 8; |
@@ -168,8 +165,6 @@ static int qnx4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
168 | buf->f_fsid.val[0] = (u32)id; | 165 | buf->f_fsid.val[0] = (u32)id; |
169 | buf->f_fsid.val[1] = (u32)(id >> 32); | 166 | buf->f_fsid.val[1] = (u32)(id >> 32); |
170 | 167 | ||
171 | unlock_kernel(); | ||
172 | |||
173 | return 0; | 168 | return 0; |
174 | } | 169 | } |
175 | 170 | ||
@@ -283,7 +278,6 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent) | |||
283 | goto outi; | 278 | goto outi; |
284 | 279 | ||
285 | brelse(bh); | 280 | brelse(bh); |
286 | |||
287 | return 0; | 281 | return 0; |
288 | 282 | ||
289 | outi: | 283 | outi: |
diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c index 58703ebba879..275327b5615e 100644 --- a/fs/qnx4/namei.c +++ b/fs/qnx4/namei.c | |||
@@ -12,7 +12,6 @@ | |||
12 | * 04-07-1998 by Frank Denis : first step for rmdir/unlink. | 12 | * 04-07-1998 by Frank Denis : first step for rmdir/unlink. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/smp_lock.h> | ||
16 | #include <linux/buffer_head.h> | 15 | #include <linux/buffer_head.h> |
17 | #include "qnx4.h" | 16 | #include "qnx4.h" |
18 | 17 | ||
@@ -109,7 +108,6 @@ struct dentry * qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nam | |||
109 | int len = dentry->d_name.len; | 108 | int len = dentry->d_name.len; |
110 | struct inode *foundinode = NULL; | 109 | struct inode *foundinode = NULL; |
111 | 110 | ||
112 | lock_kernel(); | ||
113 | if (!(bh = qnx4_find_entry(len, dir, name, &de, &ino))) | 111 | if (!(bh = qnx4_find_entry(len, dir, name, &de, &ino))) |
114 | goto out; | 112 | goto out; |
115 | /* The entry is linked, let's get the real info */ | 113 | /* The entry is linked, let's get the real info */ |
@@ -123,13 +121,11 @@ struct dentry * qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nam | |||
123 | 121 | ||
124 | foundinode = qnx4_iget(dir->i_sb, ino); | 122 | foundinode = qnx4_iget(dir->i_sb, ino); |
125 | if (IS_ERR(foundinode)) { | 123 | if (IS_ERR(foundinode)) { |
126 | unlock_kernel(); | ||
127 | QNX4DEBUG((KERN_ERR "qnx4: lookup->iget -> error %ld\n", | 124 | QNX4DEBUG((KERN_ERR "qnx4: lookup->iget -> error %ld\n", |
128 | PTR_ERR(foundinode))); | 125 | PTR_ERR(foundinode))); |
129 | return ERR_CAST(foundinode); | 126 | return ERR_CAST(foundinode); |
130 | } | 127 | } |
131 | out: | 128 | out: |
132 | unlock_kernel(); | ||
133 | d_add(dentry, foundinode); | 129 | d_add(dentry, foundinode); |
134 | 130 | ||
135 | return NULL; | 131 | return NULL; |
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c index 450c91941988..8fc5e50e142f 100644 --- a/fs/smbfs/inode.c +++ b/fs/smbfs/inode.c | |||
@@ -501,6 +501,8 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
501 | void *mem; | 501 | void *mem; |
502 | static int warn_count; | 502 | static int warn_count; |
503 | 503 | ||
504 | lock_kernel(); | ||
505 | |||
504 | if (warn_count < 5) { | 506 | if (warn_count < 5) { |
505 | warn_count++; | 507 | warn_count++; |
506 | printk(KERN_EMERG "smbfs is deprecated and will be removed" | 508 | printk(KERN_EMERG "smbfs is deprecated and will be removed" |
@@ -621,6 +623,7 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent) | |||
621 | 623 | ||
622 | smb_new_dentry(sb->s_root); | 624 | smb_new_dentry(sb->s_root); |
623 | 625 | ||
626 | unlock_kernel(); | ||
624 | return 0; | 627 | return 0; |
625 | 628 | ||
626 | out_no_root: | 629 | out_no_root: |
@@ -643,9 +646,11 @@ out_wrong_data: | |||
643 | out_no_data: | 646 | out_no_data: |
644 | printk(KERN_ERR "smb_fill_super: missing data argument\n"); | 647 | printk(KERN_ERR "smb_fill_super: missing data argument\n"); |
645 | out_fail: | 648 | out_fail: |
649 | unlock_kernel(); | ||
646 | return -EINVAL; | 650 | return -EINVAL; |
647 | out_no_server: | 651 | out_no_server: |
648 | printk(KERN_ERR "smb_fill_super: cannot allocate struct smb_sb_info\n"); | 652 | printk(KERN_ERR "smb_fill_super: cannot allocate struct smb_sb_info\n"); |
653 | unlock_kernel(); | ||
649 | return -ENOMEM; | 654 | return -ENOMEM; |
650 | } | 655 | } |
651 | 656 | ||
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index 88b4f8606652..07a4f1156048 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/fs.h> | 30 | #include <linux/fs.h> |
31 | #include <linux/vfs.h> | 31 | #include <linux/vfs.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/smp_lock.h> | ||
34 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
35 | #include <linux/pagemap.h> | 34 | #include <linux/pagemap.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
@@ -354,8 +353,6 @@ static int squashfs_remount(struct super_block *sb, int *flags, char *data) | |||
354 | 353 | ||
355 | static void squashfs_put_super(struct super_block *sb) | 354 | static void squashfs_put_super(struct super_block *sb) |
356 | { | 355 | { |
357 | lock_kernel(); | ||
358 | |||
359 | if (sb->s_fs_info) { | 356 | if (sb->s_fs_info) { |
360 | struct squashfs_sb_info *sbi = sb->s_fs_info; | 357 | struct squashfs_sb_info *sbi = sb->s_fs_info; |
361 | squashfs_cache_delete(sbi->block_cache); | 358 | squashfs_cache_delete(sbi->block_cache); |
@@ -370,8 +367,6 @@ static void squashfs_put_super(struct super_block *sb) | |||
370 | kfree(sb->s_fs_info); | 367 | kfree(sb->s_fs_info); |
371 | sb->s_fs_info = NULL; | 368 | sb->s_fs_info = NULL; |
372 | } | 369 | } |
373 | |||
374 | unlock_kernel(); | ||
375 | } | 370 | } |
376 | 371 | ||
377 | 372 | ||
diff --git a/fs/udf/super.c b/fs/udf/super.c index 65412d84a45d..76f3d6d97b40 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -1880,6 +1880,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1880 | struct kernel_lb_addr rootdir, fileset; | 1880 | struct kernel_lb_addr rootdir, fileset; |
1881 | struct udf_sb_info *sbi; | 1881 | struct udf_sb_info *sbi; |
1882 | 1882 | ||
1883 | lock_kernel(); | ||
1884 | |||
1883 | uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); | 1885 | uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); |
1884 | uopt.uid = -1; | 1886 | uopt.uid = -1; |
1885 | uopt.gid = -1; | 1887 | uopt.gid = -1; |
@@ -1888,8 +1890,10 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1888 | uopt.dmode = UDF_INVALID_MODE; | 1890 | uopt.dmode = UDF_INVALID_MODE; |
1889 | 1891 | ||
1890 | sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); | 1892 | sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); |
1891 | if (!sbi) | 1893 | if (!sbi) { |
1894 | unlock_kernel(); | ||
1892 | return -ENOMEM; | 1895 | return -ENOMEM; |
1896 | } | ||
1893 | 1897 | ||
1894 | sb->s_fs_info = sbi; | 1898 | sb->s_fs_info = sbi; |
1895 | 1899 | ||
@@ -2035,6 +2039,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
2035 | goto error_out; | 2039 | goto error_out; |
2036 | } | 2040 | } |
2037 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 2041 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
2042 | unlock_kernel(); | ||
2038 | return 0; | 2043 | return 0; |
2039 | 2044 | ||
2040 | error_out: | 2045 | error_out: |
@@ -2055,6 +2060,7 @@ error_out: | |||
2055 | kfree(sbi); | 2060 | kfree(sbi); |
2056 | sb->s_fs_info = NULL; | 2061 | sb->s_fs_info = NULL; |
2057 | 2062 | ||
2063 | unlock_kernel(); | ||
2058 | return -EINVAL; | 2064 | return -EINVAL; |
2059 | } | 2065 | } |
2060 | 2066 | ||
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index d510c1b91817..6b9be90dae7d 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -696,6 +696,8 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
696 | unsigned maxsymlen; | 696 | unsigned maxsymlen; |
697 | int ret = -EINVAL; | 697 | int ret = -EINVAL; |
698 | 698 | ||
699 | lock_kernel(); | ||
700 | |||
699 | uspi = NULL; | 701 | uspi = NULL; |
700 | ubh = NULL; | 702 | ubh = NULL; |
701 | flags = 0; | 703 | flags = 0; |
@@ -1163,6 +1165,7 @@ magic_found: | |||
1163 | goto failed; | 1165 | goto failed; |
1164 | 1166 | ||
1165 | UFSD("EXIT\n"); | 1167 | UFSD("EXIT\n"); |
1168 | unlock_kernel(); | ||
1166 | return 0; | 1169 | return 0; |
1167 | 1170 | ||
1168 | dalloc_failed: | 1171 | dalloc_failed: |
@@ -1174,10 +1177,12 @@ failed: | |||
1174 | kfree(sbi); | 1177 | kfree(sbi); |
1175 | sb->s_fs_info = NULL; | 1178 | sb->s_fs_info = NULL; |
1176 | UFSD("EXIT (FAILED)\n"); | 1179 | UFSD("EXIT (FAILED)\n"); |
1180 | unlock_kernel(); | ||
1177 | return ret; | 1181 | return ret; |
1178 | 1182 | ||
1179 | failed_nomem: | 1183 | failed_nomem: |
1180 | UFSD("EXIT (NOMEM)\n"); | 1184 | UFSD("EXIT (NOMEM)\n"); |
1185 | unlock_kernel(); | ||
1181 | return -ENOMEM; | 1186 | return -ENOMEM; |
1182 | } | 1187 | } |
1183 | 1188 | ||