aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-06-08 07:21:27 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-06-08 07:21:27 -0400
commite635a01ea0a16cf7cd31ecd2305870385dca9be6 (patch)
treec7153e7dee5caf6ac90d85694ff27e4d0b606290 /fs
parent143070e74630b9557e1bb64d899ff2cc5a1dcb48 (diff)
parent947391cfbaa3b08558844c0b187bcd0223c3f660 (diff)
Merge branch 'next-mtd' of git://aeryn.fluff.org.uk/bjdooks/linux
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/vfs_super.c12
-rw-r--r--fs/affs/super.c3
-rw-r--r--fs/afs/super.c7
-rw-r--r--fs/binfmt_flat.c46
-rw-r--r--fs/btrfs/ctree.c39
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/btrfs/extent-tree.c2
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/btrfs/ioctl.c4
-rw-r--r--fs/btrfs/super.c16
-rw-r--r--fs/cachefiles/internal.h18
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/cifs/cifssmb.c14
-rw-r--r--fs/cifs/dir.c51
-rw-r--r--fs/cifs/file.c66
-rw-r--r--fs/cifs/link.c52
-rw-r--r--fs/dcache.c2
-rw-r--r--fs/devpts/inode.c23
-rw-r--r--fs/ecryptfs/main.c5
-rw-r--r--fs/eventpoll.c2
-rw-r--r--fs/exec.c79
-rw-r--r--fs/ext4/extents.c19
-rw-r--r--fs/ext4/inode.c26
-rw-r--r--fs/fcntl.c6
-rw-r--r--fs/fscache/internal.h18
-rw-r--r--fs/fuse/inode.c4
-rw-r--r--fs/gfs2/glock.c1
-rw-r--r--fs/gfs2/ops_fstype.c8
-rw-r--r--fs/hpfs/super.c3
-rw-r--r--fs/hugetlbfs/inode.c11
-rw-r--r--fs/inode.c81
-rw-r--r--fs/jffs2/erase.c7
-rw-r--r--fs/libfs.c3
-rw-r--r--fs/lockd/svc.c15
-rw-r--r--fs/namei.c13
-rw-r--r--fs/namespace.c23
-rw-r--r--fs/nfs/dir.c3
-rw-r--r--fs/nfs/nfs4proc.c9
-rw-r--r--fs/nfs/nfsroot.c2
-rw-r--r--fs/nfs/super.c22
-rw-r--r--fs/nfsd/nfs4recover.c4
-rw-r--r--fs/nfsd/nfs4state.c1
-rw-r--r--fs/nfsd/nfs4xdr.c16
-rw-r--r--fs/nfsd/vfs.c6
-rw-r--r--fs/nilfs2/ioctl.c281
-rw-r--r--fs/nilfs2/mdt.c15
-rw-r--r--fs/nilfs2/nilfs.h3
-rw-r--r--fs/nilfs2/page.c3
-rw-r--r--fs/nilfs2/recovery.c6
-rw-r--r--fs/nilfs2/segment.c5
-rw-r--r--fs/nilfs2/segment.h3
-rw-r--r--fs/ocfs2/symlink.c77
-rw-r--r--fs/open.c2
-rw-r--r--fs/proc/base.c2
-rw-r--r--fs/proc/root.c3
-rw-r--r--fs/reiserfs/dir.c24
-rw-r--r--fs/reiserfs/namei.c17
-rw-r--r--fs/reiserfs/super.c11
-rw-r--r--fs/reiserfs/xattr.c260
-rw-r--r--fs/reiserfs/xattr_security.c12
-rw-r--r--fs/romfs/super.c3
-rw-r--r--fs/squashfs/Makefile1
-rw-r--r--fs/squashfs/cache.c1
-rw-r--r--fs/squashfs/super.c10
-rw-r--r--fs/super.c48
-rw-r--r--fs/sysfs/file.c2
-rw-r--r--fs/ubifs/super.c3
-rw-r--r--fs/ufs/dir.c2
-rw-r--r--fs/ufs/file.c2
-rw-r--r--fs/ufs/ufs.h2
70 files changed, 831 insertions, 719 deletions
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 5f8ab8adb5f5..ab5547ff29a1 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -37,6 +37,7 @@
37#include <linux/mount.h> 37#include <linux/mount.h>
38#include <linux/idr.h> 38#include <linux/idr.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <linux/smp_lock.h>
40#include <net/9p/9p.h> 41#include <net/9p/9p.h>
41#include <net/9p/client.h> 42#include <net/9p/client.h>
42 43
@@ -155,6 +156,7 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
155 156
156 root = d_alloc_root(inode); 157 root = d_alloc_root(inode);
157 if (!root) { 158 if (!root) {
159 iput(inode);
158 retval = -ENOMEM; 160 retval = -ENOMEM;
159 goto release_sb; 161 goto release_sb;
160 } 162 }
@@ -173,10 +175,7 @@ P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n");
173 return 0; 175 return 0;
174 176
175release_sb: 177release_sb:
176 if (sb) { 178 deactivate_locked_super(sb);
177 up_write(&sb->s_umount);
178 deactivate_super(sb);
179 }
180 179
181free_stat: 180free_stat:
182 kfree(st); 181 kfree(st);
@@ -230,9 +229,12 @@ static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt)
230static void 229static void
231v9fs_umount_begin(struct super_block *sb) 230v9fs_umount_begin(struct super_block *sb)
232{ 231{
233 struct v9fs_session_info *v9ses = sb->s_fs_info; 232 struct v9fs_session_info *v9ses;
234 233
234 lock_kernel();
235 v9ses = sb->s_fs_info;
235 v9fs_session_cancel(v9ses); 236 v9fs_session_cancel(v9ses);
237 unlock_kernel();
236} 238}
237 239
238static const struct super_operations v9fs_super_ops = { 240static const struct super_operations v9fs_super_ops = {
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 5ce695e707fe..63f5183f263b 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -507,8 +507,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
507 kfree(new_opts); 507 kfree(new_opts);
508 return -EINVAL; 508 return -EINVAL;
509 } 509 }
510 kfree(sb->s_options); 510 replace_mount_options(sb, new_opts);
511 sb->s_options = new_opts;
512 511
513 sbi->s_flags = mount_flags; 512 sbi->s_flags = mount_flags;
514 sbi->s_mode = mode; 513 sbi->s_mode = mode;
diff --git a/fs/afs/super.c b/fs/afs/super.c
index aee239a048cb..76828e5f8a39 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -405,21 +405,20 @@ static int afs_get_sb(struct file_system_type *fs_type,
405 sb->s_flags = flags; 405 sb->s_flags = flags;
406 ret = afs_fill_super(sb, &params); 406 ret = afs_fill_super(sb, &params);
407 if (ret < 0) { 407 if (ret < 0) {
408 up_write(&sb->s_umount); 408 deactivate_locked_super(sb);
409 deactivate_super(sb);
410 goto error; 409 goto error;
411 } 410 }
412 sb->s_options = new_opts; 411 save_mount_options(sb, new_opts);
413 sb->s_flags |= MS_ACTIVE; 412 sb->s_flags |= MS_ACTIVE;
414 } else { 413 } else {
415 _debug("reuse"); 414 _debug("reuse");
416 kfree(new_opts);
417 ASSERTCMP(sb->s_flags, &, MS_ACTIVE); 415 ASSERTCMP(sb->s_flags, &, MS_ACTIVE);
418 } 416 }
419 417
420 simple_set_mnt(mnt, sb); 418 simple_set_mnt(mnt, sb);
421 afs_put_volume(params.volume); 419 afs_put_volume(params.volume);
422 afs_put_cell(params.cell); 420 afs_put_cell(params.cell);
421 kfree(new_opts);
423 _leave(" = 0 [%p]", sb); 422 _leave(" = 0 [%p]", sb);
424 return 0; 423 return 0;
425 424
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 5cebf0b37798..697f6b5f1313 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -41,6 +41,7 @@
41#include <asm/uaccess.h> 41#include <asm/uaccess.h>
42#include <asm/unaligned.h> 42#include <asm/unaligned.h>
43#include <asm/cacheflush.h> 43#include <asm/cacheflush.h>
44#include <asm/page.h>
44 45
45/****************************************************************************/ 46/****************************************************************************/
46 47
@@ -54,6 +55,18 @@
54#define DBG_FLT(a...) 55#define DBG_FLT(a...)
55#endif 56#endif
56 57
58/*
59 * User data (stack, data section and bss) needs to be aligned
60 * for the same reasons as SLAB memory is, and to the same amount.
61 * Avoid duplicating architecture specific code by using the same
62 * macro as with SLAB allocation:
63 */
64#ifdef ARCH_SLAB_MINALIGN
65#define FLAT_DATA_ALIGN (ARCH_SLAB_MINALIGN)
66#else
67#define FLAT_DATA_ALIGN (sizeof(void *))
68#endif
69
57#define RELOC_FAILED 0xff00ff01 /* Relocation incorrect somewhere */ 70#define RELOC_FAILED 0xff00ff01 /* Relocation incorrect somewhere */
58#define UNLOADED_LIB 0x7ff000ff /* Placeholder for unused library */ 71#define UNLOADED_LIB 0x7ff000ff /* Placeholder for unused library */
59 72
@@ -114,20 +127,18 @@ static unsigned long create_flat_tables(
114 int envc = bprm->envc; 127 int envc = bprm->envc;
115 char uninitialized_var(dummy); 128 char uninitialized_var(dummy);
116 129
117 sp = (unsigned long *) ((-(unsigned long)sizeof(char *))&(unsigned long) p); 130 sp = (unsigned long *)p;
131 sp -= (envc + argc + 2) + 1 + (flat_argvp_envp_on_stack() ? 2 : 0);
132 sp = (unsigned long *) ((unsigned long)sp & -FLAT_DATA_ALIGN);
133 argv = sp + 1 + (flat_argvp_envp_on_stack() ? 2 : 0);
134 envp = argv + (argc + 1);
118 135
119 sp -= envc+1;
120 envp = sp;
121 sp -= argc+1;
122 argv = sp;
123
124 flat_stack_align(sp);
125 if (flat_argvp_envp_on_stack()) { 136 if (flat_argvp_envp_on_stack()) {
126 --sp; put_user((unsigned long) envp, sp); 137 put_user((unsigned long) envp, sp + 2);
127 --sp; put_user((unsigned long) argv, sp); 138 put_user((unsigned long) argv, sp + 1);
128 } 139 }
129 140
130 put_user(argc,--sp); 141 put_user(argc, sp);
131 current->mm->arg_start = (unsigned long) p; 142 current->mm->arg_start = (unsigned long) p;
132 while (argc-->0) { 143 while (argc-->0) {
133 put_user((unsigned long) p, argv++); 144 put_user((unsigned long) p, argv++);
@@ -558,7 +569,9 @@ static int load_flat_file(struct linux_binprm * bprm,
558 ret = realdatastart; 569 ret = realdatastart;
559 goto err; 570 goto err;
560 } 571 }
561 datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long); 572 datapos = ALIGN(realdatastart +
573 MAX_SHARED_LIBS * sizeof(unsigned long),
574 FLAT_DATA_ALIGN);
562 575
563 DBG_FLT("BINFMT_FLAT: Allocated data+bss+stack (%d bytes): %x\n", 576 DBG_FLT("BINFMT_FLAT: Allocated data+bss+stack (%d bytes): %x\n",
564 (int)(data_len + bss_len + stack_len), (int)datapos); 577 (int)(data_len + bss_len + stack_len), (int)datapos);
@@ -604,9 +617,12 @@ static int load_flat_file(struct linux_binprm * bprm,
604 } 617 }
605 618
606 realdatastart = textpos + ntohl(hdr->data_start); 619 realdatastart = textpos + ntohl(hdr->data_start);
607 datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long); 620 datapos = ALIGN(realdatastart +
608 reloc = (unsigned long *) (textpos + ntohl(hdr->reloc_start) + 621 MAX_SHARED_LIBS * sizeof(unsigned long),
609 MAX_SHARED_LIBS * sizeof(unsigned long)); 622 FLAT_DATA_ALIGN);
623
624 reloc = (unsigned long *)
625 (datapos + (ntohl(hdr->reloc_start) - text_len));
610 memp = textpos; 626 memp = textpos;
611 memp_size = len; 627 memp_size = len;
612#ifdef CONFIG_BINFMT_ZFLAT 628#ifdef CONFIG_BINFMT_ZFLAT
@@ -854,7 +870,7 @@ static int load_flat_binary(struct linux_binprm * bprm, struct pt_regs * regs)
854 stack_len = TOP_OF_ARGS - bprm->p; /* the strings */ 870 stack_len = TOP_OF_ARGS - bprm->p; /* the strings */
855 stack_len += (bprm->argc + 1) * sizeof(char *); /* the argv array */ 871 stack_len += (bprm->argc + 1) * sizeof(char *); /* the argv array */
856 stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */ 872 stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */
857 873 stack_len += FLAT_DATA_ALIGN - 1; /* reserve for upcoming alignment */
858 874
859 res = load_flat_file(bprm, &libinfo, 0, &stack_len); 875 res = load_flat_file(bprm, &libinfo, 0, &stack_len);
860 if (res > (unsigned long)-4096) 876 if (res > (unsigned long)-4096)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index a99f1c2a710d..fedf8b9f03a2 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1469,6 +1469,7 @@ read_block_for_search(struct btrfs_trans_handle *trans,
1469 u32 blocksize; 1469 u32 blocksize;
1470 struct extent_buffer *b = *eb_ret; 1470 struct extent_buffer *b = *eb_ret;
1471 struct extent_buffer *tmp; 1471 struct extent_buffer *tmp;
1472 int ret;
1472 1473
1473 blocknr = btrfs_node_blockptr(b, slot); 1474 blocknr = btrfs_node_blockptr(b, slot);
1474 gen = btrfs_node_ptr_generation(b, slot); 1475 gen = btrfs_node_ptr_generation(b, slot);
@@ -1476,6 +1477,10 @@ read_block_for_search(struct btrfs_trans_handle *trans,
1476 1477
1477 tmp = btrfs_find_tree_block(root, blocknr, blocksize); 1478 tmp = btrfs_find_tree_block(root, blocknr, blocksize);
1478 if (tmp && btrfs_buffer_uptodate(tmp, gen)) { 1479 if (tmp && btrfs_buffer_uptodate(tmp, gen)) {
1480 /*
1481 * we found an up to date block without sleeping, return
1482 * right away
1483 */
1479 *eb_ret = tmp; 1484 *eb_ret = tmp;
1480 return 0; 1485 return 0;
1481 } 1486 }
@@ -1483,7 +1488,9 @@ read_block_for_search(struct btrfs_trans_handle *trans,
1483 /* 1488 /*
1484 * reduce lock contention at high levels 1489 * reduce lock contention at high levels
1485 * of the btree by dropping locks before 1490 * of the btree by dropping locks before
1486 * we read. 1491 * we read. Don't release the lock on the current
1492 * level because we need to walk this node to figure
1493 * out which blocks to read.
1487 */ 1494 */
1488 btrfs_unlock_up_safe(p, level + 1); 1495 btrfs_unlock_up_safe(p, level + 1);
1489 btrfs_set_path_blocking(p); 1496 btrfs_set_path_blocking(p);
@@ -1494,10 +1501,21 @@ read_block_for_search(struct btrfs_trans_handle *trans,
1494 reada_for_search(root, p, level, slot, key->objectid); 1501 reada_for_search(root, p, level, slot, key->objectid);
1495 1502
1496 btrfs_release_path(NULL, p); 1503 btrfs_release_path(NULL, p);
1504
1505 ret = -EAGAIN;
1497 tmp = read_tree_block(root, blocknr, blocksize, gen); 1506 tmp = read_tree_block(root, blocknr, blocksize, gen);
1498 if (tmp) 1507 if (tmp) {
1508 /*
1509 * If the read above didn't mark this buffer up to date,
1510 * it will never end up being up to date. Set ret to EIO now
1511 * and give up so that our caller doesn't loop forever
1512 * on our EAGAINs.
1513 */
1514 if (!btrfs_buffer_uptodate(tmp, 0))
1515 ret = -EIO;
1499 free_extent_buffer(tmp); 1516 free_extent_buffer(tmp);
1500 return -EAGAIN; 1517 }
1518 return ret;
1501} 1519}
1502 1520
1503/* 1521/*
@@ -1696,6 +1714,9 @@ cow_done:
1696 if (ret == -EAGAIN) 1714 if (ret == -EAGAIN)
1697 goto again; 1715 goto again;
1698 1716
1717 if (ret == -EIO)
1718 goto done;
1719
1699 if (!p->skip_locking) { 1720 if (!p->skip_locking) {
1700 int lret; 1721 int lret;
1701 1722
@@ -1738,6 +1759,8 @@ done:
1738 */ 1759 */
1739 if (!p->leave_spinning) 1760 if (!p->leave_spinning)
1740 btrfs_set_path_blocking(p); 1761 btrfs_set_path_blocking(p);
1762 if (ret < 0)
1763 btrfs_release_path(root, p);
1741 return ret; 1764 return ret;
1742} 1765}
1743 1766
@@ -4212,6 +4235,11 @@ again:
4212 if (ret == -EAGAIN) 4235 if (ret == -EAGAIN)
4213 goto again; 4236 goto again;
4214 4237
4238 if (ret < 0) {
4239 btrfs_release_path(root, path);
4240 goto done;
4241 }
4242
4215 if (!path->skip_locking) { 4243 if (!path->skip_locking) {
4216 ret = btrfs_try_spin_lock(next); 4244 ret = btrfs_try_spin_lock(next);
4217 if (!ret) { 4245 if (!ret) {
@@ -4246,6 +4274,11 @@ again:
4246 if (ret == -EAGAIN) 4274 if (ret == -EAGAIN)
4247 goto again; 4275 goto again;
4248 4276
4277 if (ret < 0) {
4278 btrfs_release_path(root, path);
4279 goto done;
4280 }
4281
4249 if (!path->skip_locking) { 4282 if (!path->skip_locking) {
4250 btrfs_assert_tree_locked(path->nodes[level]); 4283 btrfs_assert_tree_locked(path->nodes[level]);
4251 ret = btrfs_try_spin_lock(next); 4284 ret = btrfs_try_spin_lock(next);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0ff16d3331da..4b0ea0b80c23 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -848,8 +848,6 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
848 848
849 if (ret == 0) 849 if (ret == 0)
850 set_bit(EXTENT_BUFFER_UPTODATE, &buf->bflags); 850 set_bit(EXTENT_BUFFER_UPTODATE, &buf->bflags);
851 else
852 WARN_ON(1);
853 return buf; 851 return buf;
854 852
855} 853}
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e4966444811b..3e2c7c738f23 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -312,7 +312,7 @@ btrfs_lookup_first_block_group(struct btrfs_fs_info *info, u64 bytenr)
312} 312}
313 313
314/* 314/*
315 * return the block group that contains teh given bytenr 315 * return the block group that contains the given bytenr
316 */ 316 */
317struct btrfs_block_group_cache *btrfs_lookup_block_group( 317struct btrfs_block_group_cache *btrfs_lookup_block_group(
318 struct btrfs_fs_info *info, 318 struct btrfs_fs_info *info,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 90c23eb28829..1c8b0190d031 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3122,6 +3122,7 @@ static noinline void init_btrfs_i(struct inode *inode)
3122 bi->flags = 0; 3122 bi->flags = 0;
3123 bi->index_cnt = (u64)-1; 3123 bi->index_cnt = (u64)-1;
3124 bi->last_unlink_trans = 0; 3124 bi->last_unlink_trans = 0;
3125 bi->ordered_data_close = 0;
3125 extent_map_tree_init(&BTRFS_I(inode)->extent_tree, GFP_NOFS); 3126 extent_map_tree_init(&BTRFS_I(inode)->extent_tree, GFP_NOFS);
3126 extent_io_tree_init(&BTRFS_I(inode)->io_tree, 3127 extent_io_tree_init(&BTRFS_I(inode)->io_tree,
3127 inode->i_mapping, GFP_NOFS); 3128 inode->i_mapping, GFP_NOFS);
@@ -4295,7 +4296,6 @@ out:
4295 } 4296 }
4296 if (err) { 4297 if (err) {
4297 free_extent_map(em); 4298 free_extent_map(em);
4298 WARN_ON(1);
4299 return ERR_PTR(err); 4299 return ERR_PTR(err);
4300 } 4300 }
4301 return em; 4301 return em;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 5e94ea6e1cbe..2624b53ea783 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -437,10 +437,6 @@ out_unlock:
437 return 0; 437 return 0;
438} 438}
439 439
440/*
441 * Called inside transaction, so use GFP_NOFS
442 */
443
444static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg) 440static int btrfs_ioctl_resize(struct btrfs_root *root, void __user *arg)
445{ 441{
446 u64 new_size; 442 u64 new_size;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 3536bdb2d7cb..2ff7cd2db25f 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -436,9 +436,9 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
436 if (btrfs_test_opt(root, SSD)) 436 if (btrfs_test_opt(root, SSD))
437 seq_puts(seq, ",ssd"); 437 seq_puts(seq, ",ssd");
438 if (btrfs_test_opt(root, NOTREELOG)) 438 if (btrfs_test_opt(root, NOTREELOG))
439 seq_puts(seq, ",no-treelog"); 439 seq_puts(seq, ",notreelog");
440 if (btrfs_test_opt(root, FLUSHONCOMMIT)) 440 if (btrfs_test_opt(root, FLUSHONCOMMIT))
441 seq_puts(seq, ",flush-on-commit"); 441 seq_puts(seq, ",flushoncommit");
442 if (!(root->fs_info->sb->s_flags & MS_POSIXACL)) 442 if (!(root->fs_info->sb->s_flags & MS_POSIXACL))
443 seq_puts(seq, ",noacl"); 443 seq_puts(seq, ",noacl");
444 return 0; 444 return 0;
@@ -502,8 +502,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
502 502
503 if (s->s_root) { 503 if (s->s_root) {
504 if ((flags ^ s->s_flags) & MS_RDONLY) { 504 if ((flags ^ s->s_flags) & MS_RDONLY) {
505 up_write(&s->s_umount); 505 deactivate_locked_super(s);
506 deactivate_super(s);
507 error = -EBUSY; 506 error = -EBUSY;
508 goto error_close_devices; 507 goto error_close_devices;
509 } 508 }
@@ -517,8 +516,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
517 error = btrfs_fill_super(s, fs_devices, data, 516 error = btrfs_fill_super(s, fs_devices, data,
518 flags & MS_SILENT ? 1 : 0); 517 flags & MS_SILENT ? 1 : 0);
519 if (error) { 518 if (error) {
520 up_write(&s->s_umount); 519 deactivate_locked_super(s);
521 deactivate_super(s);
522 goto error_free_subvol_name; 520 goto error_free_subvol_name;
523 } 521 }
524 522
@@ -535,15 +533,13 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
535 mutex_unlock(&s->s_root->d_inode->i_mutex); 533 mutex_unlock(&s->s_root->d_inode->i_mutex);
536 534
537 if (IS_ERR(root)) { 535 if (IS_ERR(root)) {
538 up_write(&s->s_umount); 536 deactivate_locked_super(s);
539 deactivate_super(s);
540 error = PTR_ERR(root); 537 error = PTR_ERR(root);
541 goto error_free_subvol_name; 538 goto error_free_subvol_name;
542 } 539 }
543 if (!root->d_inode) { 540 if (!root->d_inode) {
544 dput(root); 541 dput(root);
545 up_write(&s->s_umount); 542 deactivate_locked_super(s);
546 deactivate_super(s);
547 error = -ENXIO; 543 error = -ENXIO;
548 goto error_free_subvol_name; 544 goto error_free_subvol_name;
549 } 545 }
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index 19218e1463d6..f7c255f9c624 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -122,13 +122,13 @@ static inline void cachefiles_state_changed(struct cachefiles_cache *cache)
122} 122}
123 123
124/* 124/*
125 * cf-bind.c 125 * bind.c
126 */ 126 */
127extern int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args); 127extern int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args);
128extern void cachefiles_daemon_unbind(struct cachefiles_cache *cache); 128extern void cachefiles_daemon_unbind(struct cachefiles_cache *cache);
129 129
130/* 130/*
131 * cf-daemon.c 131 * daemon.c
132 */ 132 */
133extern const struct file_operations cachefiles_daemon_fops; 133extern const struct file_operations cachefiles_daemon_fops;
134 134
@@ -136,17 +136,17 @@ extern int cachefiles_has_space(struct cachefiles_cache *cache,
136 unsigned fnr, unsigned bnr); 136 unsigned fnr, unsigned bnr);
137 137
138/* 138/*
139 * cf-interface.c 139 * interface.c
140 */ 140 */
141extern const struct fscache_cache_ops cachefiles_cache_ops; 141extern const struct fscache_cache_ops cachefiles_cache_ops;
142 142
143/* 143/*
144 * cf-key.c 144 * key.c
145 */ 145 */
146extern char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type); 146extern char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type);
147 147
148/* 148/*
149 * cf-namei.c 149 * namei.c
150 */ 150 */
151extern int cachefiles_delete_object(struct cachefiles_cache *cache, 151extern int cachefiles_delete_object(struct cachefiles_cache *cache,
152 struct cachefiles_object *object); 152 struct cachefiles_object *object);
@@ -165,7 +165,7 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
165 struct dentry *dir, char *filename); 165 struct dentry *dir, char *filename);
166 166
167/* 167/*
168 * cf-proc.c 168 * proc.c
169 */ 169 */
170#ifdef CONFIG_CACHEFILES_HISTOGRAM 170#ifdef CONFIG_CACHEFILES_HISTOGRAM
171extern atomic_t cachefiles_lookup_histogram[HZ]; 171extern atomic_t cachefiles_lookup_histogram[HZ];
@@ -190,7 +190,7 @@ void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
190#endif 190#endif
191 191
192/* 192/*
193 * cf-rdwr.c 193 * rdwr.c
194 */ 194 */
195extern int cachefiles_read_or_alloc_page(struct fscache_retrieval *, 195extern int cachefiles_read_or_alloc_page(struct fscache_retrieval *,
196 struct page *, gfp_t); 196 struct page *, gfp_t);
@@ -205,7 +205,7 @@ extern int cachefiles_write_page(struct fscache_storage *, struct page *);
205extern void cachefiles_uncache_page(struct fscache_object *, struct page *); 205extern void cachefiles_uncache_page(struct fscache_object *, struct page *);
206 206
207/* 207/*
208 * cf-security.c 208 * security.c
209 */ 209 */
210extern int cachefiles_get_security_ID(struct cachefiles_cache *cache); 210extern int cachefiles_get_security_ID(struct cachefiles_cache *cache);
211extern int cachefiles_determine_cache_security(struct cachefiles_cache *cache, 211extern int cachefiles_determine_cache_security(struct cachefiles_cache *cache,
@@ -225,7 +225,7 @@ static inline void cachefiles_end_secure(struct cachefiles_cache *cache,
225} 225}
226 226
227/* 227/*
228 * cf-xattr.c 228 * xattr.c
229 */ 229 */
230extern int cachefiles_check_object_type(struct cachefiles_object *object); 230extern int cachefiles_check_object_type(struct cachefiles_object *object);
231extern int cachefiles_set_object_xattr(struct cachefiles_object *object, 231extern int cachefiles_set_object_xattr(struct cachefiles_object *object,
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 0d6d8b573652..5e6d35804d73 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -35,6 +35,7 @@
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>
38#include "cifsfs.h" 39#include "cifsfs.h"
39#include "cifspdu.h" 40#include "cifspdu.h"
40#define DECLARE_GLOBALS_HERE 41#define DECLARE_GLOBALS_HERE
@@ -530,6 +531,7 @@ static void cifs_umount_begin(struct super_block *sb)
530 if (tcon == NULL) 531 if (tcon == NULL)
531 return; 532 return;
532 533
534 lock_kernel();
533 read_lock(&cifs_tcp_ses_lock); 535 read_lock(&cifs_tcp_ses_lock);
534 if (tcon->tc_count == 1) 536 if (tcon->tc_count == 1)
535 tcon->tidStatus = CifsExiting; 537 tcon->tidStatus = CifsExiting;
@@ -548,6 +550,7 @@ static void cifs_umount_begin(struct super_block *sb)
548 } 550 }
549/* BB FIXME - finish add checks for tidStatus BB */ 551/* BB FIXME - finish add checks for tidStatus BB */
550 552
553 unlock_kernel();
551 return; 554 return;
552} 555}
553 556
@@ -599,8 +602,7 @@ cifs_get_sb(struct file_system_type *fs_type,
599 602
600 rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0); 603 rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0);
601 if (rc) { 604 if (rc) {
602 up_write(&sb->s_umount); 605 deactivate_locked_super(sb);
603 deactivate_super(sb);
604 return rc; 606 return rc;
605 } 607 }
606 sb->s_flags |= MS_ACTIVE; 608 sb->s_flags |= MS_ACTIVE;
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 75e6623a8635..d06260251c30 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -2475,7 +2475,7 @@ querySymLinkRetry:
2475 /* BB FIXME investigate remapping reserved chars here */ 2475 /* BB FIXME investigate remapping reserved chars here */
2476 *symlinkinfo = cifs_strndup_from_ucs(data_start, count, 2476 *symlinkinfo = cifs_strndup_from_ucs(data_start, count,
2477 is_unicode, nls_codepage); 2477 is_unicode, nls_codepage);
2478 if (!symlinkinfo) 2478 if (!*symlinkinfo)
2479 rc = -ENOMEM; 2479 rc = -ENOMEM;
2480 } 2480 }
2481 } 2481 }
@@ -3976,9 +3976,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
3976 max_len = data_end - temp; 3976 max_len = data_end - temp;
3977 node->path_name = cifs_strndup_from_ucs(temp, max_len, 3977 node->path_name = cifs_strndup_from_ucs(temp, max_len,
3978 is_unicode, nls_codepage); 3978 is_unicode, nls_codepage);
3979 if (IS_ERR(node->path_name)) { 3979 if (!node->path_name) {
3980 rc = PTR_ERR(node->path_name); 3980 rc = -ENOMEM;
3981 node->path_name = NULL;
3982 goto parse_DFS_referrals_exit; 3981 goto parse_DFS_referrals_exit;
3983 } 3982 }
3984 3983
@@ -3987,11 +3986,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
3987 max_len = data_end - temp; 3986 max_len = data_end - temp;
3988 node->node_name = cifs_strndup_from_ucs(temp, max_len, 3987 node->node_name = cifs_strndup_from_ucs(temp, max_len,
3989 is_unicode, nls_codepage); 3988 is_unicode, nls_codepage);
3990 if (IS_ERR(node->node_name)) { 3989 if (!node->node_name)
3991 rc = PTR_ERR(node->node_name); 3990 rc = -ENOMEM;
3992 node->node_name = NULL;
3993 goto parse_DFS_referrals_exit;
3994 }
3995 } 3991 }
3996 3992
3997parse_DFS_referrals_exit: 3993parse_DFS_referrals_exit:
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 11431ed72a7f..3758965d73d5 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -225,6 +225,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
225 if (!(oflags & FMODE_READ)) 225 if (!(oflags & FMODE_READ))
226 write_only = true; 226 write_only = true;
227 227
228 mode &= ~current_umask();
228 rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode, 229 rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode,
229 pnetfid, presp_data, &oplock, full_path, 230 pnetfid, presp_data, &oplock, full_path,
230 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 231 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
@@ -310,7 +311,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
310 return -ENOMEM; 311 return -ENOMEM;
311 } 312 }
312 313
313 mode &= ~current_umask();
314 if (oplockEnabled) 314 if (oplockEnabled)
315 oplock = REQ_OPLOCK; 315 oplock = REQ_OPLOCK;
316 316
@@ -336,7 +336,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
336 else /* success, no need to query */ 336 else /* success, no need to query */
337 goto cifs_create_set_dentry; 337 goto cifs_create_set_dentry;
338 } else if ((rc != -EIO) && (rc != -EREMOTE) && 338 } else if ((rc != -EIO) && (rc != -EREMOTE) &&
339 (rc != -EOPNOTSUPP)) /* path not found or net err */ 339 (rc != -EOPNOTSUPP) && (rc != -EINVAL))
340 goto cifs_create_out; 340 goto cifs_create_out;
341 /* else fallthrough to retry, using older open call, this is 341 /* else fallthrough to retry, using older open call, this is
342 case where server does not support this SMB level, and 342 case where server does not support this SMB level, and
@@ -609,7 +609,6 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
609 int xid; 609 int xid;
610 int rc = 0; /* to get around spurious gcc warning, set to zero here */ 610 int rc = 0; /* to get around spurious gcc warning, set to zero here */
611 int oplock = 0; 611 int oplock = 0;
612 int mode;
613 __u16 fileHandle = 0; 612 __u16 fileHandle = 0;
614 bool posix_open = false; 613 bool posix_open = false;
615 struct cifs_sb_info *cifs_sb; 614 struct cifs_sb_info *cifs_sb;
@@ -658,30 +657,36 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
658 } 657 }
659 cFYI(1, ("Full path: %s inode = 0x%p", full_path, direntry->d_inode)); 658 cFYI(1, ("Full path: %s inode = 0x%p", full_path, direntry->d_inode));
660 659
660 /* Posix open is only called (at lookup time) for file create now.
661 * For opens (rather than creates), because we do not know if it
662 * is a file or directory yet, and current Samba no longer allows
663 * us to do posix open on dirs, we could end up wasting an open call
664 * on what turns out to be a dir. For file opens, we wait to call posix
665 * open till cifs_open. It could be added here (lookup) in the future
666 * but the performance tradeoff of the extra network request when EISDIR
667 * or EACCES is returned would have to be weighed against the 50%
668 * reduction in network traffic in the other paths.
669 */
661 if (pTcon->unix_ext) { 670 if (pTcon->unix_ext) {
662 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) && 671 if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) &&
663 (nd->flags & LOOKUP_OPEN)) { 672 (nd->flags & LOOKUP_OPEN) && !pTcon->broken_posix_open &&
664 if (!((nd->intent.open.flags & O_CREAT) && 673 (nd->intent.open.flags & O_CREAT)) {
665 (nd->intent.open.flags & O_EXCL))) { 674 rc = cifs_posix_open(full_path, &newInode,
666 mode = nd->intent.open.create_mode & 675 parent_dir_inode->i_sb,
667 ~current_umask(); 676 nd->intent.open.create_mode,
668 rc = cifs_posix_open(full_path, &newInode,
669 parent_dir_inode->i_sb, mode,
670 nd->intent.open.flags, &oplock, 677 nd->intent.open.flags, &oplock,
671 &fileHandle, xid); 678 &fileHandle, xid);
672 /* 679 /*
673 * This code works around a bug in 680 * The check below works around a bug in POSIX
674 * samba posix open in samba versions 3.3.1 681 * open in samba versions 3.3.1 and earlier where
675 * and earlier where create works 682 * open could incorrectly fail with invalid parameter.
676 * but open fails with invalid parameter. 683 * If either that or op not supported returned, follow
677 * If either of these error codes are 684 * the normal lookup.
678 * returned, follow the normal lookup. 685 */
679 * Otherwise, the error during posix open 686 if ((rc == 0) || (rc == -ENOENT))
680 * is handled. 687 posix_open = true;
681 */ 688 else if ((rc == -EINVAL) || (rc != -EOPNOTSUPP))
682 if ((rc != -EINVAL) && (rc != -EOPNOTSUPP)) 689 pTcon->broken_posix_open = true;
683 posix_open = true;
684 }
685 } 690 }
686 if (!posix_open) 691 if (!posix_open)
687 rc = cifs_get_inode_info_unix(&newInode, full_path, 692 rc = cifs_get_inode_info_unix(&newInode, full_path,
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 38c06f826575..302ea15f02e6 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -130,10 +130,6 @@ static inline int cifs_posix_open_inode_helper(struct inode *inode,
130 struct cifsFileInfo *pCifsFile, int oplock, u16 netfid) 130 struct cifsFileInfo *pCifsFile, int oplock, u16 netfid)
131{ 131{
132 132
133 file->private_data = kmalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
134 if (file->private_data == NULL)
135 return -ENOMEM;
136 pCifsFile = cifs_init_private(file->private_data, inode, file, netfid);
137 write_lock(&GlobalSMBSeslock); 133 write_lock(&GlobalSMBSeslock);
138 134
139 pCifsInode = CIFS_I(file->f_path.dentry->d_inode); 135 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
@@ -184,6 +180,38 @@ psx_client_can_cache:
184 return 0; 180 return 0;
185} 181}
186 182
183static struct cifsFileInfo *
184cifs_fill_filedata(struct file *file)
185{
186 struct list_head *tmp;
187 struct cifsFileInfo *pCifsFile = NULL;
188 struct cifsInodeInfo *pCifsInode = NULL;
189
190 /* search inode for this file and fill in file->private_data */
191 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
192 read_lock(&GlobalSMBSeslock);
193 list_for_each(tmp, &pCifsInode->openFileList) {
194 pCifsFile = list_entry(tmp, struct cifsFileInfo, flist);
195 if ((pCifsFile->pfile == NULL) &&
196 (pCifsFile->pid == current->tgid)) {
197 /* mode set in cifs_create */
198
199 /* needed for writepage */
200 pCifsFile->pfile = file;
201 file->private_data = pCifsFile;
202 break;
203 }
204 }
205 read_unlock(&GlobalSMBSeslock);
206
207 if (file->private_data != NULL) {
208 return pCifsFile;
209 } else if ((file->f_flags & O_CREAT) && (file->f_flags & O_EXCL))
210 cERROR(1, ("could not find file instance for "
211 "new file %p", file));
212 return NULL;
213}
214
187/* all arguments to this function must be checked for validity in caller */ 215/* all arguments to this function must be checked for validity in caller */
188static inline int cifs_open_inode_helper(struct inode *inode, struct file *file, 216static inline int cifs_open_inode_helper(struct inode *inode, struct file *file,
189 struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile, 217 struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile,
@@ -258,7 +286,6 @@ int cifs_open(struct inode *inode, struct file *file)
258 struct cifsTconInfo *tcon; 286 struct cifsTconInfo *tcon;
259 struct cifsFileInfo *pCifsFile; 287 struct cifsFileInfo *pCifsFile;
260 struct cifsInodeInfo *pCifsInode; 288 struct cifsInodeInfo *pCifsInode;
261 struct list_head *tmp;
262 char *full_path = NULL; 289 char *full_path = NULL;
263 int desiredAccess; 290 int desiredAccess;
264 int disposition; 291 int disposition;
@@ -270,32 +297,12 @@ int cifs_open(struct inode *inode, struct file *file)
270 cifs_sb = CIFS_SB(inode->i_sb); 297 cifs_sb = CIFS_SB(inode->i_sb);
271 tcon = cifs_sb->tcon; 298 tcon = cifs_sb->tcon;
272 299
273 /* search inode for this file and fill in file->private_data */
274 pCifsInode = CIFS_I(file->f_path.dentry->d_inode); 300 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
275 read_lock(&GlobalSMBSeslock); 301 pCifsFile = cifs_fill_filedata(file);
276 list_for_each(tmp, &pCifsInode->openFileList) { 302 if (pCifsFile) {
277 pCifsFile = list_entry(tmp, struct cifsFileInfo,
278 flist);
279 if ((pCifsFile->pfile == NULL) &&
280 (pCifsFile->pid == current->tgid)) {
281 /* mode set in cifs_create */
282
283 /* needed for writepage */
284 pCifsFile->pfile = file;
285
286 file->private_data = pCifsFile;
287 break;
288 }
289 }
290 read_unlock(&GlobalSMBSeslock);
291
292 if (file->private_data != NULL) {
293 rc = 0;
294 FreeXid(xid); 303 FreeXid(xid);
295 return rc; 304 return 0;
296 } else if ((file->f_flags & O_CREAT) && (file->f_flags & O_EXCL)) 305 }
297 cERROR(1, ("could not find file instance for "
298 "new file %p", file));
299 306
300 full_path = build_path_from_dentry(file->f_path.dentry); 307 full_path = build_path_from_dentry(file->f_path.dentry);
301 if (full_path == NULL) { 308 if (full_path == NULL) {
@@ -325,6 +332,7 @@ int cifs_open(struct inode *inode, struct file *file)
325 /* no need for special case handling of setting mode 332 /* no need for special case handling of setting mode
326 on read only files needed here */ 333 on read only files needed here */
327 334
335 pCifsFile = cifs_fill_filedata(file);
328 cifs_posix_open_inode_helper(inode, file, pCifsInode, 336 cifs_posix_open_inode_helper(inode, file, pCifsInode,
329 pCifsFile, oplock, netfid); 337 pCifsFile, oplock, netfid);
330 goto out; 338 goto out;
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index ea9d11e3dcbb..cd83c53fcbb5 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -107,48 +107,48 @@ void *
107cifs_follow_link(struct dentry *direntry, struct nameidata *nd) 107cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
108{ 108{
109 struct inode *inode = direntry->d_inode; 109 struct inode *inode = direntry->d_inode;
110 int rc = -EACCES; 110 int rc = -ENOMEM;
111 int xid; 111 int xid;
112 char *full_path = NULL; 112 char *full_path = NULL;
113 char *target_path = ERR_PTR(-ENOMEM); 113 char *target_path = NULL;
114 struct cifs_sb_info *cifs_sb; 114 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
115 struct cifsTconInfo *pTcon; 115 struct cifsTconInfo *tcon = cifs_sb->tcon;
116 116
117 xid = GetXid(); 117 xid = GetXid();
118 118
119 full_path = build_path_from_dentry(direntry); 119 /*
120 * For now, we just handle symlinks with unix extensions enabled.
121 * Eventually we should handle NTFS reparse points, and MacOS
122 * symlink support. For instance...
123 *
124 * rc = CIFSSMBQueryReparseLinkInfo(...)
125 *
126 * For now, just return -EACCES when the server doesn't support posix
127 * extensions. Note that we still allow querying symlinks when posix
128 * extensions are manually disabled. We could disable these as well
129 * but there doesn't seem to be any harm in allowing the client to
130 * read them.
131 */
132 if (!(tcon->ses->capabilities & CAP_UNIX)) {
133 rc = -EACCES;
134 goto out;
135 }
120 136
137 full_path = build_path_from_dentry(direntry);
121 if (!full_path) 138 if (!full_path)
122 goto out; 139 goto out;
123 140
124 cFYI(1, ("Full path: %s inode = 0x%p", full_path, inode)); 141 cFYI(1, ("Full path: %s inode = 0x%p", full_path, inode));
125 cifs_sb = CIFS_SB(inode->i_sb);
126 pTcon = cifs_sb->tcon;
127
128 /* We could change this to:
129 if (pTcon->unix_ext)
130 but there does not seem any point in refusing to
131 get symlink info if we can, even if unix extensions
132 turned off for this mount */
133
134 if (pTcon->ses->capabilities & CAP_UNIX)
135 rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path,
136 &target_path,
137 cifs_sb->local_nls);
138 else {
139 /* BB add read reparse point symlink code here */
140 /* rc = CIFSSMBQueryReparseLinkInfo */
141 /* BB Add code to Query ReparsePoint info */
142 /* BB Add MAC style xsymlink check here if enabled */
143 }
144 142
143 rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, &target_path,
144 cifs_sb->local_nls);
145 kfree(full_path);
146out:
145 if (rc != 0) { 147 if (rc != 0) {
146 kfree(target_path); 148 kfree(target_path);
147 target_path = ERR_PTR(rc); 149 target_path = ERR_PTR(rc);
148 } 150 }
149 151
150 kfree(full_path);
151out:
152 FreeXid(xid); 152 FreeXid(xid);
153 nd_set_link(nd, target_path); 153 nd_set_link(nd, target_path);
154 return NULL; 154 return NULL;
diff --git a/fs/dcache.c b/fs/dcache.c
index 1fcffebfb44f..75659a6fd1f8 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -481,7 +481,7 @@ restart:
481 if ((flags & DCACHE_REFERENCED) 481 if ((flags & DCACHE_REFERENCED)
482 && (dentry->d_flags & DCACHE_REFERENCED)) { 482 && (dentry->d_flags & DCACHE_REFERENCED)) {
483 dentry->d_flags &= ~DCACHE_REFERENCED; 483 dentry->d_flags &= ~DCACHE_REFERENCED;
484 list_move_tail(&dentry->d_lru, &referenced); 484 list_move(&dentry->d_lru, &referenced);
485 spin_unlock(&dentry->d_lock); 485 spin_unlock(&dentry->d_lock);
486 } else { 486 } else {
487 list_move_tail(&dentry->d_lru, &tmp); 487 list_move_tail(&dentry->d_lru, &tmp);
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 63a4a59e4148..c68edb969441 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -90,6 +90,15 @@ static inline struct super_block *pts_sb_from_inode(struct inode *inode)
90#define PARSE_MOUNT 0 90#define PARSE_MOUNT 0
91#define PARSE_REMOUNT 1 91#define PARSE_REMOUNT 1
92 92
93/*
94 * parse_mount_options():
95 * Set @opts to mount options specified in @data. If an option is not
96 * specified in @data, set it to its default value. The exception is
97 * 'newinstance' option which can only be set/cleared on a mount (i.e.
98 * cannot be changed during remount).
99 *
100 * Note: @data may be NULL (in which case all options are set to default).
101 */
93static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) 102static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts)
94{ 103{
95 char *p; 104 char *p;
@@ -355,12 +364,9 @@ static int devpts_get_sb(struct file_system_type *fs_type,
355 struct pts_mount_opts opts; 364 struct pts_mount_opts opts;
356 struct super_block *s; 365 struct super_block *s;
357 366
358 memset(&opts, 0, sizeof(opts)); 367 error = parse_mount_options(data, PARSE_MOUNT, &opts);
359 if (data) { 368 if (error)
360 error = parse_mount_options(data, PARSE_MOUNT, &opts); 369 return error;
361 if (error)
362 return error;
363 }
364 370
365 if (opts.newinstance) 371 if (opts.newinstance)
366 s = sget(fs_type, NULL, set_anon_super, NULL); 372 s = sget(fs_type, NULL, set_anon_super, NULL);
@@ -389,11 +395,10 @@ static int devpts_get_sb(struct file_system_type *fs_type,
389 return 0; 395 return 0;
390 396
391out_dput: 397out_dput:
392 dput(s->s_root); 398 dput(s->s_root); /* undo dget() in simple_set_mnt() */
393 399
394out_undo_sget: 400out_undo_sget:
395 up_write(&s->s_umount); 401 deactivate_locked_super(s);
396 deactivate_super(s);
397 return error; 402 return error;
398} 403}
399 404
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index ccabd5faa04d..9f0aa9883c28 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -614,9 +614,8 @@ static int ecryptfs_get_sb(struct file_system_type *fs_type, int flags,
614 } 614 }
615 goto out; 615 goto out;
616out_abort: 616out_abort:
617 dput(sb->s_root); 617 dput(sb->s_root); /* aka mnt->mnt_root, as set by get_sb_nodev() */
618 up_write(&sb->s_umount); 618 deactivate_locked_super(sb);
619 deactivate_super(sb);
620out: 619out:
621 return rc; 620 return rc;
622} 621}
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index a89f370fadb5..5458e80fc558 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1212,7 +1212,7 @@ SYSCALL_DEFINE1(epoll_create1, int, flags)
1212 1212
1213SYSCALL_DEFINE1(epoll_create, int, size) 1213SYSCALL_DEFINE1(epoll_create, int, size)
1214{ 1214{
1215 if (size < 0) 1215 if (size <= 0)
1216 return -EINVAL; 1216 return -EINVAL;
1217 1217
1218 return sys_epoll_create1(0); 1218 return sys_epoll_create1(0);
diff --git a/fs/exec.c b/fs/exec.c
index 639177b0eeac..895823d0149d 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -105,40 +105,28 @@ static inline void put_binfmt(struct linux_binfmt * fmt)
105SYSCALL_DEFINE1(uselib, const char __user *, library) 105SYSCALL_DEFINE1(uselib, const char __user *, library)
106{ 106{
107 struct file *file; 107 struct file *file;
108 struct nameidata nd;
109 char *tmp = getname(library); 108 char *tmp = getname(library);
110 int error = PTR_ERR(tmp); 109 int error = PTR_ERR(tmp);
111 110
112 if (!IS_ERR(tmp)) { 111 if (IS_ERR(tmp))
113 error = path_lookup_open(AT_FDCWD, tmp, 112 goto out;
114 LOOKUP_FOLLOW, &nd, 113
115 FMODE_READ|FMODE_EXEC); 114 file = do_filp_open(AT_FDCWD, tmp,
116 putname(tmp); 115 O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0,
117 } 116 MAY_READ | MAY_EXEC | MAY_OPEN);
118 if (error) 117 putname(tmp);
118 error = PTR_ERR(file);
119 if (IS_ERR(file))
119 goto out; 120 goto out;
120 121
121 error = -EINVAL; 122 error = -EINVAL;
122 if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) 123 if (!S_ISREG(file->f_path.dentry->d_inode->i_mode))
123 goto exit; 124 goto exit;
124 125
125 error = -EACCES; 126 error = -EACCES;
126 if (nd.path.mnt->mnt_flags & MNT_NOEXEC) 127 if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
127 goto exit;
128
129 error = inode_permission(nd.path.dentry->d_inode,
130 MAY_READ | MAY_EXEC | MAY_OPEN);
131 if (error)
132 goto exit;
133 error = ima_path_check(&nd.path, MAY_READ | MAY_EXEC | MAY_OPEN);
134 if (error)
135 goto exit; 128 goto exit;
136 129
137 file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
138 error = PTR_ERR(file);
139 if (IS_ERR(file))
140 goto out;
141
142 fsnotify_open(file->f_path.dentry); 130 fsnotify_open(file->f_path.dentry);
143 131
144 error = -ENOEXEC; 132 error = -ENOEXEC;
@@ -160,13 +148,10 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
160 } 148 }
161 read_unlock(&binfmt_lock); 149 read_unlock(&binfmt_lock);
162 } 150 }
151exit:
163 fput(file); 152 fput(file);
164out: 153out:
165 return error; 154 return error;
166exit:
167 release_open_intent(&nd);
168 path_put(&nd.path);
169 goto out;
170} 155}
171 156
172#ifdef CONFIG_MMU 157#ifdef CONFIG_MMU
@@ -661,47 +646,33 @@ EXPORT_SYMBOL(setup_arg_pages);
661 646
662struct file *open_exec(const char *name) 647struct file *open_exec(const char *name)
663{ 648{
664 struct nameidata nd;
665 struct file *file; 649 struct file *file;
666 int err; 650 int err;
667 651
668 err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, 652 file = do_filp_open(AT_FDCWD, name,
669 FMODE_READ|FMODE_EXEC); 653 O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0,
670 if (err) 654 MAY_EXEC | MAY_OPEN);
655 if (IS_ERR(file))
671 goto out; 656 goto out;
672 657
673 err = -EACCES; 658 err = -EACCES;
674 if (!S_ISREG(nd.path.dentry->d_inode->i_mode)) 659 if (!S_ISREG(file->f_path.dentry->d_inode->i_mode))
675 goto out_path_put; 660 goto exit;
676
677 if (nd.path.mnt->mnt_flags & MNT_NOEXEC)
678 goto out_path_put;
679
680 err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN);
681 if (err)
682 goto out_path_put;
683 err = ima_path_check(&nd.path, MAY_EXEC | MAY_OPEN);
684 if (err)
685 goto out_path_put;
686 661
687 file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE); 662 if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
688 if (IS_ERR(file)) 663 goto exit;
689 return file;
690 664
691 fsnotify_open(file->f_path.dentry); 665 fsnotify_open(file->f_path.dentry);
692 666
693 err = deny_write_access(file); 667 err = deny_write_access(file);
694 if (err) { 668 if (err)
695 fput(file); 669 goto exit;
696 goto out;
697 }
698 670
671out:
699 return file; 672 return file;
700 673
701 out_path_put: 674exit:
702 release_open_intent(&nd); 675 fput(file);
703 path_put(&nd.path);
704 out:
705 return ERR_PTR(err); 676 return ERR_PTR(err);
706} 677}
707EXPORT_SYMBOL(open_exec); 678EXPORT_SYMBOL(open_exec);
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e40332158340..e3a55eb8b26a 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1841,11 +1841,13 @@ ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block,
1841{ 1841{
1842 struct ext4_ext_cache *cex; 1842 struct ext4_ext_cache *cex;
1843 BUG_ON(len == 0); 1843 BUG_ON(len == 0);
1844 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
1844 cex = &EXT4_I(inode)->i_cached_extent; 1845 cex = &EXT4_I(inode)->i_cached_extent;
1845 cex->ec_type = type; 1846 cex->ec_type = type;
1846 cex->ec_block = block; 1847 cex->ec_block = block;
1847 cex->ec_len = len; 1848 cex->ec_len = len;
1848 cex->ec_start = start; 1849 cex->ec_start = start;
1850 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1849} 1851}
1850 1852
1851/* 1853/*
@@ -1902,12 +1904,17 @@ ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block,
1902 struct ext4_extent *ex) 1904 struct ext4_extent *ex)
1903{ 1905{
1904 struct ext4_ext_cache *cex; 1906 struct ext4_ext_cache *cex;
1907 int ret = EXT4_EXT_CACHE_NO;
1905 1908
1909 /*
1910 * We borrow i_block_reservation_lock to protect i_cached_extent
1911 */
1912 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
1906 cex = &EXT4_I(inode)->i_cached_extent; 1913 cex = &EXT4_I(inode)->i_cached_extent;
1907 1914
1908 /* has cache valid data? */ 1915 /* has cache valid data? */
1909 if (cex->ec_type == EXT4_EXT_CACHE_NO) 1916 if (cex->ec_type == EXT4_EXT_CACHE_NO)
1910 return EXT4_EXT_CACHE_NO; 1917 goto errout;
1911 1918
1912 BUG_ON(cex->ec_type != EXT4_EXT_CACHE_GAP && 1919 BUG_ON(cex->ec_type != EXT4_EXT_CACHE_GAP &&
1913 cex->ec_type != EXT4_EXT_CACHE_EXTENT); 1920 cex->ec_type != EXT4_EXT_CACHE_EXTENT);
@@ -1918,11 +1925,11 @@ ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block,
1918 ext_debug("%u cached by %u:%u:%llu\n", 1925 ext_debug("%u cached by %u:%u:%llu\n",
1919 block, 1926 block,
1920 cex->ec_block, cex->ec_len, cex->ec_start); 1927 cex->ec_block, cex->ec_len, cex->ec_start);
1921 return cex->ec_type; 1928 ret = cex->ec_type;
1922 } 1929 }
1923 1930errout:
1924 /* not in cache */ 1931 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1925 return EXT4_EXT_CACHE_NO; 1932 return ret;
1926} 1933}
1927 1934
1928/* 1935/*
@@ -2875,6 +2882,8 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2875 if (allocated > max_blocks) 2882 if (allocated > max_blocks)
2876 allocated = max_blocks; 2883 allocated = max_blocks;
2877 set_buffer_unwritten(bh_result); 2884 set_buffer_unwritten(bh_result);
2885 bh_result->b_bdev = inode->i_sb->s_bdev;
2886 bh_result->b_blocknr = newblock;
2878 goto out2; 2887 goto out2;
2879 } 2888 }
2880 2889
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e91f978c7f12..2a9ffd528dd1 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1149,6 +1149,7 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
1149 int retval; 1149 int retval;
1150 1150
1151 clear_buffer_mapped(bh); 1151 clear_buffer_mapped(bh);
1152 clear_buffer_unwritten(bh);
1152 1153
1153 /* 1154 /*
1154 * Try to see if we can get the block without requesting 1155 * Try to see if we can get the block without requesting
@@ -1179,6 +1180,18 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
1179 return retval; 1180 return retval;
1180 1181
1181 /* 1182 /*
1183 * When we call get_blocks without the create flag, the
1184 * BH_Unwritten flag could have gotten set if the blocks
1185 * requested were part of a uninitialized extent. We need to
1186 * clear this flag now that we are committed to convert all or
1187 * part of the uninitialized extent to be an initialized
1188 * extent. This is because we need to avoid the combination
1189 * of BH_Unwritten and BH_Mapped flags being simultaneously
1190 * set on the buffer_head.
1191 */
1192 clear_buffer_unwritten(bh);
1193
1194 /*
1182 * New blocks allocate and/or writing to uninitialized extent 1195 * New blocks allocate and/or writing to uninitialized extent
1183 * will possibly result in updating i_data, so we take 1196 * will possibly result in updating i_data, so we take
1184 * the write lock of i_data_sem, and call get_blocks() 1197 * the write lock of i_data_sem, and call get_blocks()
@@ -2297,6 +2310,10 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
2297 struct buffer_head *bh_result, int create) 2310 struct buffer_head *bh_result, int create)
2298{ 2311{
2299 int ret = 0; 2312 int ret = 0;
2313 sector_t invalid_block = ~((sector_t) 0xffff);
2314
2315 if (invalid_block < ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es))
2316 invalid_block = ~0;
2300 2317
2301 BUG_ON(create == 0); 2318 BUG_ON(create == 0);
2302 BUG_ON(bh_result->b_size != inode->i_sb->s_blocksize); 2319 BUG_ON(bh_result->b_size != inode->i_sb->s_blocksize);
@@ -2318,11 +2335,18 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
2318 /* not enough space to reserve */ 2335 /* not enough space to reserve */
2319 return ret; 2336 return ret;
2320 2337
2321 map_bh(bh_result, inode->i_sb, 0); 2338 map_bh(bh_result, inode->i_sb, invalid_block);
2322 set_buffer_new(bh_result); 2339 set_buffer_new(bh_result);
2323 set_buffer_delay(bh_result); 2340 set_buffer_delay(bh_result);
2324 } else if (ret > 0) { 2341 } else if (ret > 0) {
2325 bh_result->b_size = (ret << inode->i_blkbits); 2342 bh_result->b_size = (ret << inode->i_blkbits);
2343 /*
2344 * With sub-block writes into unwritten extents
2345 * we also need to mark the buffer as new so that
2346 * the unwritten parts of the buffer gets correctly zeroed.
2347 */
2348 if (buffer_unwritten(bh_result))
2349 set_buffer_new(bh_result);
2326 ret = 0; 2350 ret = 0;
2327 } 2351 }
2328 2352
diff --git a/fs/fcntl.c b/fs/fcntl.c
index cc8e4de2fee5..1ad703150dee 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -117,11 +117,13 @@ SYSCALL_DEFINE2(dup2, unsigned int, oldfd, unsigned int, newfd)
117{ 117{
118 if (unlikely(newfd == oldfd)) { /* corner case */ 118 if (unlikely(newfd == oldfd)) { /* corner case */
119 struct files_struct *files = current->files; 119 struct files_struct *files = current->files;
120 int retval = oldfd;
121
120 rcu_read_lock(); 122 rcu_read_lock();
121 if (!fcheck_files(files, oldfd)) 123 if (!fcheck_files(files, oldfd))
122 oldfd = -EBADF; 124 retval = -EBADF;
123 rcu_read_unlock(); 125 rcu_read_unlock();
124 return oldfd; 126 return retval;
125 } 127 }
126 return sys_dup3(oldfd, newfd, 0); 128 return sys_dup3(oldfd, newfd, 0);
127} 129}
diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
index e0cbd16f6dc9..1c341304621f 100644
--- a/fs/fscache/internal.h
+++ b/fs/fscache/internal.h
@@ -28,7 +28,7 @@
28#define FSCACHE_MAX_THREADS 32 28#define FSCACHE_MAX_THREADS 32
29 29
30/* 30/*
31 * fsc-cache.c 31 * cache.c
32 */ 32 */
33extern struct list_head fscache_cache_list; 33extern struct list_head fscache_cache_list;
34extern struct rw_semaphore fscache_addremove_sem; 34extern struct rw_semaphore fscache_addremove_sem;
@@ -37,7 +37,7 @@ extern struct fscache_cache *fscache_select_cache_for_object(
37 struct fscache_cookie *); 37 struct fscache_cookie *);
38 38
39/* 39/*
40 * fsc-cookie.c 40 * cookie.c
41 */ 41 */
42extern struct kmem_cache *fscache_cookie_jar; 42extern struct kmem_cache *fscache_cookie_jar;
43 43
@@ -45,13 +45,13 @@ extern void fscache_cookie_init_once(void *);
45extern void __fscache_cookie_put(struct fscache_cookie *); 45extern void __fscache_cookie_put(struct fscache_cookie *);
46 46
47/* 47/*
48 * fsc-fsdef.c 48 * fsdef.c
49 */ 49 */
50extern struct fscache_cookie fscache_fsdef_index; 50extern struct fscache_cookie fscache_fsdef_index;
51extern struct fscache_cookie_def fscache_fsdef_netfs_def; 51extern struct fscache_cookie_def fscache_fsdef_netfs_def;
52 52
53/* 53/*
54 * fsc-histogram.c 54 * histogram.c
55 */ 55 */
56#ifdef CONFIG_FSCACHE_HISTOGRAM 56#ifdef CONFIG_FSCACHE_HISTOGRAM
57extern atomic_t fscache_obj_instantiate_histogram[HZ]; 57extern atomic_t fscache_obj_instantiate_histogram[HZ];
@@ -75,7 +75,7 @@ extern const struct file_operations fscache_histogram_fops;
75#endif 75#endif
76 76
77/* 77/*
78 * fsc-main.c 78 * main.c
79 */ 79 */
80extern unsigned fscache_defer_lookup; 80extern unsigned fscache_defer_lookup;
81extern unsigned fscache_defer_create; 81extern unsigned fscache_defer_create;
@@ -86,14 +86,14 @@ extern int fscache_wait_bit(void *);
86extern int fscache_wait_bit_interruptible(void *); 86extern int fscache_wait_bit_interruptible(void *);
87 87
88/* 88/*
89 * fsc-object.c 89 * object.c
90 */ 90 */
91extern void fscache_withdrawing_object(struct fscache_cache *, 91extern void fscache_withdrawing_object(struct fscache_cache *,
92 struct fscache_object *); 92 struct fscache_object *);
93extern void fscache_enqueue_object(struct fscache_object *); 93extern void fscache_enqueue_object(struct fscache_object *);
94 94
95/* 95/*
96 * fsc-operation.c 96 * operation.c
97 */ 97 */
98extern int fscache_submit_exclusive_op(struct fscache_object *, 98extern int fscache_submit_exclusive_op(struct fscache_object *,
99 struct fscache_operation *); 99 struct fscache_operation *);
@@ -104,7 +104,7 @@ extern void fscache_start_operations(struct fscache_object *);
104extern void fscache_operation_gc(struct work_struct *); 104extern void fscache_operation_gc(struct work_struct *);
105 105
106/* 106/*
107 * fsc-proc.c 107 * proc.c
108 */ 108 */
109#ifdef CONFIG_PROC_FS 109#ifdef CONFIG_PROC_FS
110extern int __init fscache_proc_init(void); 110extern int __init fscache_proc_init(void);
@@ -115,7 +115,7 @@ extern void fscache_proc_cleanup(void);
115#endif 115#endif
116 116
117/* 117/*
118 * fsc-stats.c 118 * stats.c
119 */ 119 */
120#ifdef CONFIG_FSCACHE_STATS 120#ifdef CONFIG_FSCACHE_STATS
121extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS]; 121extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 459b73dd45e1..91f7c85f1ffd 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -19,6 +19,7 @@
19#include <linux/random.h> 19#include <linux/random.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/exportfs.h> 21#include <linux/exportfs.h>
22#include <linux/smp_lock.h>
22 23
23MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>"); 24MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
24MODULE_DESCRIPTION("Filesystem in Userspace"); 25MODULE_DESCRIPTION("Filesystem in Userspace");
@@ -259,7 +260,9 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
259 260
260static void fuse_umount_begin(struct super_block *sb) 261static void fuse_umount_begin(struct super_block *sb)
261{ 262{
263 lock_kernel();
262 fuse_abort_conn(get_fuse_conn_super(sb)); 264 fuse_abort_conn(get_fuse_conn_super(sb));
265 unlock_kernel();
263} 266}
264 267
265static void fuse_send_destroy(struct fuse_conn *fc) 268static void fuse_send_destroy(struct fuse_conn *fc)
@@ -908,6 +911,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
908 err_put_root: 911 err_put_root:
909 dput(root_dentry); 912 dput(root_dentry);
910 err_put_conn: 913 err_put_conn:
914 bdi_destroy(&fc->bdi);
911 fuse_conn_put(fc); 915 fuse_conn_put(fc);
912 err_fput: 916 err_fput:
913 fput(file); 917 fput(file);
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 1afd9f26bcb1..ff4981090489 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1304,6 +1304,7 @@ static int gfs2_shrink_glock_memory(int nr, gfp_t gfp_mask)
1304 nr--; 1304 nr--;
1305 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) 1305 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
1306 gfs2_glock_put(gl); 1306 gfs2_glock_put(gl);
1307 got_ref = 0;
1307 } 1308 }
1308 spin_lock(&lru_lock); 1309 spin_lock(&lru_lock);
1309 if (may_demote) 1310 if (may_demote)
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 650a730707b7..1ff9473ea753 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1282,21 +1282,21 @@ static int gfs2_get_sb(struct file_system_type *fs_type, int flags,
1282static struct super_block *get_gfs2_sb(const char *dev_name) 1282static struct super_block *get_gfs2_sb(const char *dev_name)
1283{ 1283{
1284 struct super_block *sb; 1284 struct super_block *sb;
1285 struct nameidata nd; 1285 struct path path;
1286 int error; 1286 int error;
1287 1287
1288 error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); 1288 error = kern_path(dev_name, LOOKUP_FOLLOW, &path);
1289 if (error) { 1289 if (error) {
1290 printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n", 1290 printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n",
1291 dev_name, error); 1291 dev_name, error);
1292 return NULL; 1292 return NULL;
1293 } 1293 }
1294 sb = nd.path.dentry->d_inode->i_sb; 1294 sb = path.dentry->d_inode->i_sb;
1295 if (sb && (sb->s_type == &gfs2_fs_type)) 1295 if (sb && (sb->s_type == &gfs2_fs_type))
1296 atomic_inc(&sb->s_active); 1296 atomic_inc(&sb->s_active);
1297 else 1297 else
1298 sb = NULL; 1298 sb = NULL;
1299 path_put(&nd.path); 1299 path_put(&path);
1300 return sb; 1300 return sb;
1301} 1301}
1302 1302
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index fecf402d7b8a..fc77965be841 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -423,8 +423,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
423 423
424 if (!(*flags & MS_RDONLY)) mark_dirty(s); 424 if (!(*flags & MS_RDONLY)) mark_dirty(s);
425 425
426 kfree(s->s_options); 426 replace_mount_options(s, new_opts);
427 s->s_options = new_opts;
428 427
429 return 0; 428 return 0;
430 429
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 153d9681192b..c1462d43e721 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -312,16 +312,6 @@ out:
312 return retval; 312 return retval;
313} 313}
314 314
315/*
316 * Read a page. Again trivial. If it didn't already exist
317 * in the page cache, it is zero-filled.
318 */
319static int hugetlbfs_readpage(struct file *file, struct page * page)
320{
321 unlock_page(page);
322 return -EINVAL;
323}
324
325static int hugetlbfs_write_begin(struct file *file, 315static int hugetlbfs_write_begin(struct file *file,
326 struct address_space *mapping, 316 struct address_space *mapping,
327 loff_t pos, unsigned len, unsigned flags, 317 loff_t pos, unsigned len, unsigned flags,
@@ -701,7 +691,6 @@ static void hugetlbfs_destroy_inode(struct inode *inode)
701} 691}
702 692
703static const struct address_space_operations hugetlbfs_aops = { 693static const struct address_space_operations hugetlbfs_aops = {
704 .readpage = hugetlbfs_readpage,
705 .write_begin = hugetlbfs_write_begin, 694 .write_begin = hugetlbfs_write_begin,
706 .write_end = hugetlbfs_write_end, 695 .write_end = hugetlbfs_write_end,
707 .set_page_dirty = hugetlbfs_set_page_dirty, 696 .set_page_dirty = hugetlbfs_set_page_dirty,
diff --git a/fs/inode.c b/fs/inode.c
index 6ad14a1cd8c9..0571983755dc 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -99,7 +99,7 @@ static DEFINE_MUTEX(iprune_mutex);
99 */ 99 */
100struct inodes_stat_t inodes_stat; 100struct inodes_stat_t inodes_stat;
101 101
102static struct kmem_cache * inode_cachep __read_mostly; 102static struct kmem_cache *inode_cachep __read_mostly;
103 103
104static void wake_up_inode(struct inode *inode) 104static void wake_up_inode(struct inode *inode)
105{ 105{
@@ -124,7 +124,7 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode)
124 static struct inode_operations empty_iops; 124 static struct inode_operations empty_iops;
125 static const struct file_operations empty_fops; 125 static const struct file_operations empty_fops;
126 126
127 struct address_space * const mapping = &inode->i_data; 127 struct address_space *const mapping = &inode->i_data;
128 128
129 inode->i_sb = sb; 129 inode->i_sb = sb;
130 inode->i_blkbits = sb->s_blocksize_bits; 130 inode->i_blkbits = sb->s_blocksize_bits;
@@ -216,7 +216,7 @@ static struct inode *alloc_inode(struct super_block *sb)
216 return NULL; 216 return NULL;
217} 217}
218 218
219void destroy_inode(struct inode *inode) 219void destroy_inode(struct inode *inode)
220{ 220{
221 BUG_ON(inode_has_buffers(inode)); 221 BUG_ON(inode_has_buffers(inode));
222 security_inode_free(inode); 222 security_inode_free(inode);
@@ -252,12 +252,11 @@ void inode_init_once(struct inode *inode)
252 mutex_init(&inode->inotify_mutex); 252 mutex_init(&inode->inotify_mutex);
253#endif 253#endif
254} 254}
255
256EXPORT_SYMBOL(inode_init_once); 255EXPORT_SYMBOL(inode_init_once);
257 256
258static void init_once(void *foo) 257static void init_once(void *foo)
259{ 258{
260 struct inode * inode = (struct inode *) foo; 259 struct inode *inode = (struct inode *) foo;
261 260
262 inode_init_once(inode); 261 inode_init_once(inode);
263} 262}
@@ -265,7 +264,7 @@ static void init_once(void *foo)
265/* 264/*
266 * inode_lock must be held 265 * inode_lock must be held
267 */ 266 */
268void __iget(struct inode * inode) 267void __iget(struct inode *inode)
269{ 268{
270 if (atomic_read(&inode->i_count)) { 269 if (atomic_read(&inode->i_count)) {
271 atomic_inc(&inode->i_count); 270 atomic_inc(&inode->i_count);
@@ -289,7 +288,7 @@ void clear_inode(struct inode *inode)
289{ 288{
290 might_sleep(); 289 might_sleep();
291 invalidate_inode_buffers(inode); 290 invalidate_inode_buffers(inode);
292 291
293 BUG_ON(inode->i_data.nrpages); 292 BUG_ON(inode->i_data.nrpages);
294 BUG_ON(!(inode->i_state & I_FREEING)); 293 BUG_ON(!(inode->i_state & I_FREEING));
295 BUG_ON(inode->i_state & I_CLEAR); 294 BUG_ON(inode->i_state & I_CLEAR);
@@ -303,7 +302,6 @@ void clear_inode(struct inode *inode)
303 cd_forget(inode); 302 cd_forget(inode);
304 inode->i_state = I_CLEAR; 303 inode->i_state = I_CLEAR;
305} 304}
306
307EXPORT_SYMBOL(clear_inode); 305EXPORT_SYMBOL(clear_inode);
308 306
309/* 307/*
@@ -351,8 +349,8 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose)
351 349
352 next = head->next; 350 next = head->next;
353 for (;;) { 351 for (;;) {
354 struct list_head * tmp = next; 352 struct list_head *tmp = next;
355 struct inode * inode; 353 struct inode *inode;
356 354
357 /* 355 /*
358 * We can reschedule here without worrying about the list's 356 * We can reschedule here without worrying about the list's
@@ -391,7 +389,7 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose)
391 * fails because there are busy inodes then a non zero value is returned. 389 * fails because there are busy inodes then a non zero value is returned.
392 * If the discard is successful all the inodes have been discarded. 390 * If the discard is successful all the inodes have been discarded.
393 */ 391 */
394int invalidate_inodes(struct super_block * sb) 392int invalidate_inodes(struct super_block *sb)
395{ 393{
396 int busy; 394 int busy;
397 LIST_HEAD(throw_away); 395 LIST_HEAD(throw_away);
@@ -407,7 +405,6 @@ int invalidate_inodes(struct super_block * sb)
407 405
408 return busy; 406 return busy;
409} 407}
410
411EXPORT_SYMBOL(invalidate_inodes); 408EXPORT_SYMBOL(invalidate_inodes);
412 409
413static int can_unuse(struct inode *inode) 410static int can_unuse(struct inode *inode)
@@ -504,7 +501,7 @@ static int shrink_icache_memory(int nr, gfp_t gfp_mask)
504 * Nasty deadlock avoidance. We may hold various FS locks, 501 * Nasty deadlock avoidance. We may hold various FS locks,
505 * and we don't want to recurse into the FS that called us 502 * and we don't want to recurse into the FS that called us
506 * in clear_inode() and friends.. 503 * in clear_inode() and friends..
507 */ 504 */
508 if (!(gfp_mask & __GFP_FS)) 505 if (!(gfp_mask & __GFP_FS))
509 return -1; 506 return -1;
510 prune_icache(nr); 507 prune_icache(nr);
@@ -524,10 +521,13 @@ static void __wait_on_freeing_inode(struct inode *inode);
524 * by hand after calling find_inode now! This simplifies iunique and won't 521 * by hand after calling find_inode now! This simplifies iunique and won't
525 * add any additional branch in the common code. 522 * add any additional branch in the common code.
526 */ 523 */
527static struct inode * find_inode(struct super_block * sb, struct hlist_head *head, int (*test)(struct inode *, void *), void *data) 524static struct inode *find_inode(struct super_block *sb,
525 struct hlist_head *head,
526 int (*test)(struct inode *, void *),
527 void *data)
528{ 528{
529 struct hlist_node *node; 529 struct hlist_node *node;
530 struct inode * inode = NULL; 530 struct inode *inode = NULL;
531 531
532repeat: 532repeat:
533 hlist_for_each_entry(inode, node, head, i_hash) { 533 hlist_for_each_entry(inode, node, head, i_hash) {
@@ -548,10 +548,11 @@ repeat:
548 * find_inode_fast is the fast path version of find_inode, see the comment at 548 * find_inode_fast is the fast path version of find_inode, see the comment at
549 * iget_locked for details. 549 * iget_locked for details.
550 */ 550 */
551static struct inode * find_inode_fast(struct super_block * sb, struct hlist_head *head, unsigned long ino) 551static struct inode *find_inode_fast(struct super_block *sb,
552 struct hlist_head *head, unsigned long ino)
552{ 553{
553 struct hlist_node *node; 554 struct hlist_node *node;
554 struct inode * inode = NULL; 555 struct inode *inode = NULL;
555 556
556repeat: 557repeat:
557 hlist_for_each_entry(inode, node, head, i_hash) { 558 hlist_for_each_entry(inode, node, head, i_hash) {
@@ -631,10 +632,10 @@ struct inode *new_inode(struct super_block *sb)
631 * here to attempt to avoid that. 632 * here to attempt to avoid that.
632 */ 633 */
633 static unsigned int last_ino; 634 static unsigned int last_ino;
634 struct inode * inode; 635 struct inode *inode;
635 636
636 spin_lock_prefetch(&inode_lock); 637 spin_lock_prefetch(&inode_lock);
637 638
638 inode = alloc_inode(sb); 639 inode = alloc_inode(sb);
639 if (inode) { 640 if (inode) {
640 spin_lock(&inode_lock); 641 spin_lock(&inode_lock);
@@ -645,7 +646,6 @@ struct inode *new_inode(struct super_block *sb)
645 } 646 }
646 return inode; 647 return inode;
647} 648}
648
649EXPORT_SYMBOL(new_inode); 649EXPORT_SYMBOL(new_inode);
650 650
651void unlock_new_inode(struct inode *inode) 651void unlock_new_inode(struct inode *inode)
@@ -674,7 +674,6 @@ void unlock_new_inode(struct inode *inode)
674 inode->i_state &= ~(I_LOCK|I_NEW); 674 inode->i_state &= ~(I_LOCK|I_NEW);
675 wake_up_inode(inode); 675 wake_up_inode(inode);
676} 676}
677
678EXPORT_SYMBOL(unlock_new_inode); 677EXPORT_SYMBOL(unlock_new_inode);
679 678
680/* 679/*
@@ -683,13 +682,17 @@ EXPORT_SYMBOL(unlock_new_inode);
683 * We no longer cache the sb_flags in i_flags - see fs.h 682 * We no longer cache the sb_flags in i_flags - see fs.h
684 * -- rmk@arm.uk.linux.org 683 * -- rmk@arm.uk.linux.org
685 */ 684 */
686static struct inode * get_new_inode(struct super_block *sb, struct hlist_head *head, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *data) 685static struct inode *get_new_inode(struct super_block *sb,
686 struct hlist_head *head,
687 int (*test)(struct inode *, void *),
688 int (*set)(struct inode *, void *),
689 void *data)
687{ 690{
688 struct inode * inode; 691 struct inode *inode;
689 692
690 inode = alloc_inode(sb); 693 inode = alloc_inode(sb);
691 if (inode) { 694 if (inode) {
692 struct inode * old; 695 struct inode *old;
693 696
694 spin_lock(&inode_lock); 697 spin_lock(&inode_lock);
695 /* We released the lock, so.. */ 698 /* We released the lock, so.. */
@@ -731,13 +734,14 @@ set_failed:
731 * get_new_inode_fast is the fast path version of get_new_inode, see the 734 * get_new_inode_fast is the fast path version of get_new_inode, see the
732 * comment at iget_locked for details. 735 * comment at iget_locked for details.
733 */ 736 */
734static struct inode * get_new_inode_fast(struct super_block *sb, struct hlist_head *head, unsigned long ino) 737static struct inode *get_new_inode_fast(struct super_block *sb,
738 struct hlist_head *head, unsigned long ino)
735{ 739{
736 struct inode * inode; 740 struct inode *inode;
737 741
738 inode = alloc_inode(sb); 742 inode = alloc_inode(sb);
739 if (inode) { 743 if (inode) {
740 struct inode * old; 744 struct inode *old;
741 745
742 spin_lock(&inode_lock); 746 spin_lock(&inode_lock);
743 /* We released the lock, so.. */ 747 /* We released the lock, so.. */
@@ -823,7 +827,6 @@ struct inode *igrab(struct inode *inode)
823 spin_unlock(&inode_lock); 827 spin_unlock(&inode_lock);
824 return inode; 828 return inode;
825} 829}
826
827EXPORT_SYMBOL(igrab); 830EXPORT_SYMBOL(igrab);
828 831
829/** 832/**
@@ -924,7 +927,6 @@ struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval,
924 927
925 return ifind(sb, head, test, data, 0); 928 return ifind(sb, head, test, data, 0);
926} 929}
927
928EXPORT_SYMBOL(ilookup5_nowait); 930EXPORT_SYMBOL(ilookup5_nowait);
929 931
930/** 932/**
@@ -953,7 +955,6 @@ struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
953 955
954 return ifind(sb, head, test, data, 1); 956 return ifind(sb, head, test, data, 1);
955} 957}
956
957EXPORT_SYMBOL(ilookup5); 958EXPORT_SYMBOL(ilookup5);
958 959
959/** 960/**
@@ -976,7 +977,6 @@ struct inode *ilookup(struct super_block *sb, unsigned long ino)
976 977
977 return ifind_fast(sb, head, ino); 978 return ifind_fast(sb, head, ino);
978} 979}
979
980EXPORT_SYMBOL(ilookup); 980EXPORT_SYMBOL(ilookup);
981 981
982/** 982/**
@@ -1015,7 +1015,6 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval,
1015 */ 1015 */
1016 return get_new_inode(sb, head, test, set, data); 1016 return get_new_inode(sb, head, test, set, data);
1017} 1017}
1018
1019EXPORT_SYMBOL(iget5_locked); 1018EXPORT_SYMBOL(iget5_locked);
1020 1019
1021/** 1020/**
@@ -1047,7 +1046,6 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino)
1047 */ 1046 */
1048 return get_new_inode_fast(sb, head, ino); 1047 return get_new_inode_fast(sb, head, ino);
1049} 1048}
1050
1051EXPORT_SYMBOL(iget_locked); 1049EXPORT_SYMBOL(iget_locked);
1052 1050
1053int insert_inode_locked(struct inode *inode) 1051int insert_inode_locked(struct inode *inode)
@@ -1076,7 +1074,6 @@ int insert_inode_locked(struct inode *inode)
1076 iput(old); 1074 iput(old);
1077 } 1075 }
1078} 1076}
1079
1080EXPORT_SYMBOL(insert_inode_locked); 1077EXPORT_SYMBOL(insert_inode_locked);
1081 1078
1082int insert_inode_locked4(struct inode *inode, unsigned long hashval, 1079int insert_inode_locked4(struct inode *inode, unsigned long hashval,
@@ -1106,7 +1103,6 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
1106 iput(old); 1103 iput(old);
1107 } 1104 }
1108} 1105}
1109
1110EXPORT_SYMBOL(insert_inode_locked4); 1106EXPORT_SYMBOL(insert_inode_locked4);
1111 1107
1112/** 1108/**
@@ -1124,7 +1120,6 @@ void __insert_inode_hash(struct inode *inode, unsigned long hashval)
1124 hlist_add_head(&inode->i_hash, head); 1120 hlist_add_head(&inode->i_hash, head);
1125 spin_unlock(&inode_lock); 1121 spin_unlock(&inode_lock);
1126} 1122}
1127
1128EXPORT_SYMBOL(__insert_inode_hash); 1123EXPORT_SYMBOL(__insert_inode_hash);
1129 1124
1130/** 1125/**
@@ -1139,7 +1134,6 @@ void remove_inode_hash(struct inode *inode)
1139 hlist_del_init(&inode->i_hash); 1134 hlist_del_init(&inode->i_hash);
1140 spin_unlock(&inode_lock); 1135 spin_unlock(&inode_lock);
1141} 1136}
1142
1143EXPORT_SYMBOL(remove_inode_hash); 1137EXPORT_SYMBOL(remove_inode_hash);
1144 1138
1145/* 1139/*
@@ -1187,7 +1181,6 @@ void generic_delete_inode(struct inode *inode)
1187 BUG_ON(inode->i_state != I_CLEAR); 1181 BUG_ON(inode->i_state != I_CLEAR);
1188 destroy_inode(inode); 1182 destroy_inode(inode);
1189} 1183}
1190
1191EXPORT_SYMBOL(generic_delete_inode); 1184EXPORT_SYMBOL(generic_delete_inode);
1192 1185
1193static void generic_forget_inode(struct inode *inode) 1186static void generic_forget_inode(struct inode *inode)
@@ -1237,12 +1230,11 @@ void generic_drop_inode(struct inode *inode)
1237 else 1230 else
1238 generic_forget_inode(inode); 1231 generic_forget_inode(inode);
1239} 1232}
1240
1241EXPORT_SYMBOL_GPL(generic_drop_inode); 1233EXPORT_SYMBOL_GPL(generic_drop_inode);
1242 1234
1243/* 1235/*
1244 * Called when we're dropping the last reference 1236 * Called when we're dropping the last reference
1245 * to an inode. 1237 * to an inode.
1246 * 1238 *
1247 * Call the FS "drop()" function, defaulting to 1239 * Call the FS "drop()" function, defaulting to
1248 * the legacy UNIX filesystem behaviour.. 1240 * the legacy UNIX filesystem behaviour..
@@ -1262,7 +1254,7 @@ static inline void iput_final(struct inode *inode)
1262} 1254}
1263 1255
1264/** 1256/**
1265 * iput - put an inode 1257 * iput - put an inode
1266 * @inode: inode to put 1258 * @inode: inode to put
1267 * 1259 *
1268 * Puts an inode, dropping its usage count. If the inode use count hits 1260 * Puts an inode, dropping its usage count. If the inode use count hits
@@ -1279,7 +1271,6 @@ void iput(struct inode *inode)
1279 iput_final(inode); 1271 iput_final(inode);
1280 } 1272 }
1281} 1273}
1282
1283EXPORT_SYMBOL(iput); 1274EXPORT_SYMBOL(iput);
1284 1275
1285/** 1276/**
@@ -1290,10 +1281,10 @@ EXPORT_SYMBOL(iput);
1290 * Returns the block number on the device holding the inode that 1281 * Returns the block number on the device holding the inode that
1291 * is the disk block number for the block of the file requested. 1282 * is the disk block number for the block of the file requested.
1292 * That is, asked for block 4 of inode 1 the function will return the 1283 * That is, asked for block 4 of inode 1 the function will return the
1293 * disk block relative to the disk start that holds that block of the 1284 * disk block relative to the disk start that holds that block of the
1294 * file. 1285 * file.
1295 */ 1286 */
1296sector_t bmap(struct inode * inode, sector_t block) 1287sector_t bmap(struct inode *inode, sector_t block)
1297{ 1288{
1298 sector_t res = 0; 1289 sector_t res = 0;
1299 if (inode->i_mapping->a_ops->bmap) 1290 if (inode->i_mapping->a_ops->bmap)
@@ -1425,7 +1416,6 @@ void file_update_time(struct file *file)
1425 mark_inode_dirty_sync(inode); 1416 mark_inode_dirty_sync(inode);
1426 mnt_drop_write(file->f_path.mnt); 1417 mnt_drop_write(file->f_path.mnt);
1427} 1418}
1428
1429EXPORT_SYMBOL(file_update_time); 1419EXPORT_SYMBOL(file_update_time);
1430 1420
1431int inode_needs_sync(struct inode *inode) 1421int inode_needs_sync(struct inode *inode)
@@ -1436,7 +1426,6 @@ int inode_needs_sync(struct inode *inode)
1436 return 1; 1426 return 1;
1437 return 0; 1427 return 0;
1438} 1428}
1439
1440EXPORT_SYMBOL(inode_needs_sync); 1429EXPORT_SYMBOL(inode_needs_sync);
1441 1430
1442int inode_wait(void *word) 1431int inode_wait(void *word)
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index c32b4a1ad6cf..a0244740b75a 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -480,13 +480,6 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
480 return; 480 return;
481 481
482filebad: 482filebad:
483 mutex_lock(&c->erase_free_sem);
484 spin_lock(&c->erase_completion_lock);
485 /* Stick it on a list (any list) so erase_failed can take it
486 right off again. Silly, but shouldn't happen often. */
487 list_move(&jeb->list, &c->erasing_list);
488 spin_unlock(&c->erase_completion_lock);
489 mutex_unlock(&c->erase_free_sem);
490 jffs2_erase_failed(c, jeb, bad_offset); 483 jffs2_erase_failed(c, jeb, bad_offset);
491 return; 484 return;
492 485
diff --git a/fs/libfs.c b/fs/libfs.c
index cd223190c4e9..80046ddf5063 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -246,8 +246,7 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name,
246 return 0; 246 return 0;
247 247
248Enomem: 248Enomem:
249 up_write(&s->s_umount); 249 deactivate_locked_super(s);
250 deactivate_super(s);
251 return -ENOMEM; 250 return -ENOMEM;
252} 251}
253 252
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index abf83881f68a..1a54ae14a192 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -104,6 +104,16 @@ static void set_grace_period(void)
104 schedule_delayed_work(&grace_period_end, grace_period); 104 schedule_delayed_work(&grace_period_end, grace_period);
105} 105}
106 106
107static void restart_grace(void)
108{
109 if (nlmsvc_ops) {
110 cancel_delayed_work_sync(&grace_period_end);
111 locks_end_grace(&lockd_manager);
112 nlmsvc_invalidate_all();
113 set_grace_period();
114 }
115}
116
107/* 117/*
108 * This is the lockd kernel thread 118 * This is the lockd kernel thread
109 */ 119 */
@@ -149,10 +159,7 @@ lockd(void *vrqstp)
149 159
150 if (signalled()) { 160 if (signalled()) {
151 flush_signals(current); 161 flush_signals(current);
152 if (nlmsvc_ops) { 162 restart_grace();
153 nlmsvc_invalidate_all();
154 set_grace_period();
155 }
156 continue; 163 continue;
157 } 164 }
158 165
diff --git a/fs/namei.c b/fs/namei.c
index 78f253cd2d4f..967c3db92724 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1130,8 +1130,8 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
1130 * @nd: pointer to nameidata 1130 * @nd: pointer to nameidata
1131 * @open_flags: open intent flags 1131 * @open_flags: open intent flags
1132 */ 1132 */
1133int path_lookup_open(int dfd, const char *name, unsigned int lookup_flags, 1133static int path_lookup_open(int dfd, const char *name,
1134 struct nameidata *nd, int open_flags) 1134 unsigned int lookup_flags, struct nameidata *nd, int open_flags)
1135{ 1135{
1136 struct file *filp = get_empty_filp(); 1136 struct file *filp = get_empty_filp();
1137 int err; 1137 int err;
@@ -1637,18 +1637,19 @@ static int open_will_write_to_fs(int flag, struct inode *inode)
1637 * open_to_namei_flags() for more details. 1637 * open_to_namei_flags() for more details.
1638 */ 1638 */
1639struct file *do_filp_open(int dfd, const char *pathname, 1639struct file *do_filp_open(int dfd, const char *pathname,
1640 int open_flag, int mode) 1640 int open_flag, int mode, int acc_mode)
1641{ 1641{
1642 struct file *filp; 1642 struct file *filp;
1643 struct nameidata nd; 1643 struct nameidata nd;
1644 int acc_mode, error; 1644 int error;
1645 struct path path; 1645 struct path path;
1646 struct dentry *dir; 1646 struct dentry *dir;
1647 int count = 0; 1647 int count = 0;
1648 int will_write; 1648 int will_write;
1649 int flag = open_to_namei_flags(open_flag); 1649 int flag = open_to_namei_flags(open_flag);
1650 1650
1651 acc_mode = MAY_OPEN | ACC_MODE(flag); 1651 if (!acc_mode)
1652 acc_mode = MAY_OPEN | ACC_MODE(flag);
1652 1653
1653 /* O_TRUNC implies we need access checks for write permissions */ 1654 /* O_TRUNC implies we need access checks for write permissions */
1654 if (flag & O_TRUNC) 1655 if (flag & O_TRUNC)
@@ -1869,7 +1870,7 @@ do_link:
1869 */ 1870 */
1870struct file *filp_open(const char *filename, int flags, int mode) 1871struct file *filp_open(const char *filename, int flags, int mode)
1871{ 1872{
1872 return do_filp_open(AT_FDCWD, filename, flags, mode); 1873 return do_filp_open(AT_FDCWD, filename, flags, mode, 0);
1873} 1874}
1874EXPORT_SYMBOL(filp_open); 1875EXPORT_SYMBOL(filp_open);
1875 1876
diff --git a/fs/namespace.c b/fs/namespace.c
index 41196209a906..134d494158d9 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -695,12 +695,16 @@ static inline void mangle(struct seq_file *m, const char *s)
695 */ 695 */
696int generic_show_options(struct seq_file *m, struct vfsmount *mnt) 696int generic_show_options(struct seq_file *m, struct vfsmount *mnt)
697{ 697{
698 const char *options = mnt->mnt_sb->s_options; 698 const char *options;
699
700 rcu_read_lock();
701 options = rcu_dereference(mnt->mnt_sb->s_options);
699 702
700 if (options != NULL && options[0]) { 703 if (options != NULL && options[0]) {
701 seq_putc(m, ','); 704 seq_putc(m, ',');
702 mangle(m, options); 705 mangle(m, options);
703 } 706 }
707 rcu_read_unlock();
704 708
705 return 0; 709 return 0;
706} 710}
@@ -721,11 +725,22 @@ EXPORT_SYMBOL(generic_show_options);
721 */ 725 */
722void save_mount_options(struct super_block *sb, char *options) 726void save_mount_options(struct super_block *sb, char *options)
723{ 727{
724 kfree(sb->s_options); 728 BUG_ON(sb->s_options);
725 sb->s_options = kstrdup(options, GFP_KERNEL); 729 rcu_assign_pointer(sb->s_options, kstrdup(options, GFP_KERNEL));
726} 730}
727EXPORT_SYMBOL(save_mount_options); 731EXPORT_SYMBOL(save_mount_options);
728 732
733void replace_mount_options(struct super_block *sb, char *options)
734{
735 char *old = sb->s_options;
736 rcu_assign_pointer(sb->s_options, options);
737 if (old) {
738 synchronize_rcu();
739 kfree(old);
740 }
741}
742EXPORT_SYMBOL(replace_mount_options);
743
729#ifdef CONFIG_PROC_FS 744#ifdef CONFIG_PROC_FS
730/* iterator */ 745/* iterator */
731static void *m_start(struct seq_file *m, loff_t *pos) 746static void *m_start(struct seq_file *m, loff_t *pos)
@@ -1073,9 +1088,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
1073 */ 1088 */
1074 1089
1075 if (flags & MNT_FORCE && sb->s_op->umount_begin) { 1090 if (flags & MNT_FORCE && sb->s_op->umount_begin) {
1076 lock_kernel();
1077 sb->s_op->umount_begin(sb); 1091 sb->s_op->umount_begin(sb);
1078 unlock_kernel();
1079 } 1092 }
1080 1093
1081 /* 1094 /*
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 370b190a09d1..89f98e9a024b 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1943,7 +1943,8 @@ int nfs_permission(struct inode *inode, int mask)
1943 case S_IFREG: 1943 case S_IFREG:
1944 /* NFSv4 has atomic_open... */ 1944 /* NFSv4 has atomic_open... */
1945 if (nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN) 1945 if (nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN)
1946 && (mask & MAY_OPEN)) 1946 && (mask & MAY_OPEN)
1947 && !(mask & MAY_EXEC))
1947 goto out; 1948 goto out;
1948 break; 1949 break;
1949 case S_IFDIR: 1950 case S_IFDIR:
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a4d242680299..4674f8092da8 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2594,12 +2594,9 @@ static void nfs4_renew_done(struct rpc_task *task, void *data)
2594 unsigned long timestamp = (unsigned long)data; 2594 unsigned long timestamp = (unsigned long)data;
2595 2595
2596 if (task->tk_status < 0) { 2596 if (task->tk_status < 0) {
2597 switch (task->tk_status) { 2597 /* Unless we're shutting down, schedule state recovery! */
2598 case -NFS4ERR_STALE_CLIENTID: 2598 if (test_bit(NFS_CS_RENEWD, &clp->cl_res_state) != 0)
2599 case -NFS4ERR_EXPIRED: 2599 nfs4_schedule_state_recovery(clp);
2600 case -NFS4ERR_CB_PATH_DOWN:
2601 nfs4_schedule_state_recovery(clp);
2602 }
2603 return; 2600 return;
2604 } 2601 }
2605 spin_lock(&clp->cl_lock); 2602 spin_lock(&clp->cl_lock);
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index d9ef602fbc5a..e3ed5908820b 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -129,7 +129,7 @@ enum {
129 Opt_err 129 Opt_err
130}; 130};
131 131
132static match_table_t __initconst tokens = { 132static const match_table_t tokens __initconst = {
133 {Opt_port, "port=%u"}, 133 {Opt_port, "port=%u"},
134 {Opt_rsize, "rsize=%u"}, 134 {Opt_rsize, "rsize=%u"},
135 {Opt_wsize, "wsize=%u"}, 135 {Opt_wsize, "wsize=%u"},
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 6717200923fe..d2d67781c579 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -683,9 +683,12 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
683 */ 683 */
684static void nfs_umount_begin(struct super_block *sb) 684static void nfs_umount_begin(struct super_block *sb)
685{ 685{
686 struct nfs_server *server = NFS_SB(sb); 686 struct nfs_server *server;
687 struct rpc_clnt *rpc; 687 struct rpc_clnt *rpc;
688 688
689 lock_kernel();
690
691 server = NFS_SB(sb);
689 /* -EIO all pending I/O */ 692 /* -EIO all pending I/O */
690 rpc = server->client_acl; 693 rpc = server->client_acl;
691 if (!IS_ERR(rpc)) 694 if (!IS_ERR(rpc))
@@ -693,6 +696,8 @@ static void nfs_umount_begin(struct super_block *sb)
693 rpc = server->client; 696 rpc = server->client;
694 if (!IS_ERR(rpc)) 697 if (!IS_ERR(rpc))
695 rpc_killall_tasks(rpc); 698 rpc_killall_tasks(rpc);
699
700 unlock_kernel();
696} 701}
697 702
698/* 703/*
@@ -2106,8 +2111,7 @@ out_err_nosb:
2106error_splat_root: 2111error_splat_root:
2107 dput(mntroot); 2112 dput(mntroot);
2108error_splat_super: 2113error_splat_super:
2109 up_write(&s->s_umount); 2114 deactivate_locked_super(s);
2110 deactivate_super(s);
2111 goto out; 2115 goto out;
2112} 2116}
2113 2117
@@ -2203,8 +2207,7 @@ out_err_noserver:
2203 return error; 2207 return error;
2204 2208
2205error_splat_super: 2209error_splat_super:
2206 up_write(&s->s_umount); 2210 deactivate_locked_super(s);
2207 deactivate_super(s);
2208 dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error); 2211 dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error);
2209 return error; 2212 return error;
2210} 2213}
@@ -2464,8 +2467,7 @@ out_free:
2464error_splat_root: 2467error_splat_root:
2465 dput(mntroot); 2468 dput(mntroot);
2466error_splat_super: 2469error_splat_super:
2467 up_write(&s->s_umount); 2470 deactivate_locked_super(s);
2468 deactivate_super(s);
2469 goto out; 2471 goto out;
2470} 2472}
2471 2473
@@ -2559,8 +2561,7 @@ out_err_noserver:
2559 return error; 2561 return error;
2560 2562
2561error_splat_super: 2563error_splat_super:
2562 up_write(&s->s_umount); 2564 deactivate_locked_super(s);
2563 deactivate_super(s);
2564 dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error); 2565 dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error);
2565 return error; 2566 return error;
2566} 2567}
@@ -2644,8 +2645,7 @@ out_err_noserver:
2644 return error; 2645 return error;
2645 2646
2646error_splat_super: 2647error_splat_super:
2647 up_write(&s->s_umount); 2648 deactivate_locked_super(s);
2648 deactivate_super(s);
2649 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error); 2649 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
2650 return error; 2650 return error;
2651} 2651}
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 5275097a7565..b5348405046b 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -229,7 +229,7 @@ nfsd4_list_rec_dir(struct dentry *dir, recdir_func *f)
229 goto out; 229 goto out;
230 status = vfs_readdir(filp, nfsd4_build_namelist, &names); 230 status = vfs_readdir(filp, nfsd4_build_namelist, &names);
231 fput(filp); 231 fput(filp);
232 mutex_lock(&dir->d_inode->i_mutex); 232 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
233 while (!list_empty(&names)) { 233 while (!list_empty(&names)) {
234 entry = list_entry(names.next, struct name_list, list); 234 entry = list_entry(names.next, struct name_list, list);
235 235
@@ -264,7 +264,7 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
264 264
265 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); 265 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name);
266 266
267 mutex_lock(&rec_dir.dentry->d_inode->i_mutex); 267 mutex_lock_nested(&rec_dir.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
268 dentry = lookup_one_len(name, rec_dir.dentry, namlen); 268 dentry = lookup_one_len(name, rec_dir.dentry, namlen);
269 if (IS_ERR(dentry)) { 269 if (IS_ERR(dentry)) {
270 status = PTR_ERR(dentry); 270 status = PTR_ERR(dentry);
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index c65a27b76a9d..3b711f5147a7 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -580,7 +580,6 @@ free_session(struct kref *kref)
580 struct nfsd4_cache_entry *e = &ses->se_slots[i].sl_cache_entry; 580 struct nfsd4_cache_entry *e = &ses->se_slots[i].sl_cache_entry;
581 nfsd4_release_respages(e->ce_respages, e->ce_resused); 581 nfsd4_release_respages(e->ce_respages, e->ce_resused);
582 } 582 }
583 kfree(ses->se_slots);
584 kfree(ses); 583 kfree(ses);
585} 584}
586 585
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index b820c311931c..b73549d293be 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2214,6 +2214,15 @@ nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd,
2214 dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen); 2214 dentry = lookup_one_len(name, cd->rd_fhp->fh_dentry, namlen);
2215 if (IS_ERR(dentry)) 2215 if (IS_ERR(dentry))
2216 return nfserrno(PTR_ERR(dentry)); 2216 return nfserrno(PTR_ERR(dentry));
2217 if (!dentry->d_inode) {
2218 /*
2219 * nfsd_buffered_readdir drops the i_mutex between
2220 * readdir and calling this callback, leaving a window
2221 * where this directory entry could have gone away.
2222 */
2223 dput(dentry);
2224 return nfserr_noent;
2225 }
2217 2226
2218 exp_get(exp); 2227 exp_get(exp);
2219 /* 2228 /*
@@ -2276,6 +2285,7 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
2276 struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common); 2285 struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common);
2277 int buflen; 2286 int buflen;
2278 __be32 *p = cd->buffer; 2287 __be32 *p = cd->buffer;
2288 __be32 *cookiep;
2279 __be32 nfserr = nfserr_toosmall; 2289 __be32 nfserr = nfserr_toosmall;
2280 2290
2281 /* In nfsv4, "." and ".." never make it onto the wire.. */ 2291 /* In nfsv4, "." and ".." never make it onto the wire.. */
@@ -2292,7 +2302,7 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
2292 goto fail; 2302 goto fail;
2293 2303
2294 *p++ = xdr_one; /* mark entry present */ 2304 *p++ = xdr_one; /* mark entry present */
2295 cd->offset = p; /* remember pointer */ 2305 cookiep = p;
2296 p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */ 2306 p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */
2297 p = xdr_encode_array(p, name, namlen); /* name length & name */ 2307 p = xdr_encode_array(p, name, namlen); /* name length & name */
2298 2308
@@ -2306,6 +2316,8 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
2306 goto fail; 2316 goto fail;
2307 case nfserr_dropit: 2317 case nfserr_dropit:
2308 goto fail; 2318 goto fail;
2319 case nfserr_noent:
2320 goto skip_entry;
2309 default: 2321 default:
2310 /* 2322 /*
2311 * If the client requested the RDATTR_ERROR attribute, 2323 * If the client requested the RDATTR_ERROR attribute,
@@ -2324,6 +2336,8 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
2324 } 2336 }
2325 cd->buflen -= (p - cd->buffer); 2337 cd->buflen -= (p - cd->buffer);
2326 cd->buffer = p; 2338 cd->buffer = p;
2339 cd->offset = cookiep;
2340skip_entry:
2327 cd->common.err = nfs_ok; 2341 cd->common.err = nfs_ok;
2328 return 0; 2342 return 0;
2329fail: 2343fail:
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 6c68ffd6b4bb..b660435978d2 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1015,6 +1015,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
1015 host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset); 1015 host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
1016 set_fs(oldfs); 1016 set_fs(oldfs);
1017 if (host_err >= 0) { 1017 if (host_err >= 0) {
1018 *cnt = host_err;
1018 nfsdstats.io_write += host_err; 1019 nfsdstats.io_write += host_err;
1019 fsnotify_modify(file->f_path.dentry); 1020 fsnotify_modify(file->f_path.dentry);
1020 } 1021 }
@@ -1060,10 +1061,9 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
1060 } 1061 }
1061 1062
1062 dprintk("nfsd: write complete host_err=%d\n", host_err); 1063 dprintk("nfsd: write complete host_err=%d\n", host_err);
1063 if (host_err >= 0) { 1064 if (host_err >= 0)
1064 err = 0; 1065 err = 0;
1065 *cnt = host_err; 1066 else
1066 } else
1067 err = nfserrno(host_err); 1067 err = nfserrno(host_err);
1068out: 1068out:
1069 return err; 1069 return err;
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 108d281ebca5..d6759b92006f 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -25,6 +25,7 @@
25#include <linux/smp_lock.h> /* lock_kernel(), unlock_kernel() */ 25#include <linux/smp_lock.h> /* lock_kernel(), unlock_kernel() */
26#include <linux/capability.h> /* capable() */ 26#include <linux/capability.h> /* capable() */
27#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ 27#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
28#include <linux/vmalloc.h>
28#include <linux/nilfs2_fs.h> 29#include <linux/nilfs2_fs.h>
29#include "nilfs.h" 30#include "nilfs.h"
30#include "segment.h" 31#include "segment.h"
@@ -147,29 +148,12 @@ static ssize_t
147nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, 148nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
148 void *buf, size_t size, size_t nmembs) 149 void *buf, size_t size, size_t nmembs)
149{ 150{
150 return nilfs_cpfile_get_cpinfo(nilfs->ns_cpfile, posp, flags, buf,
151 nmembs);
152}
153
154static int nilfs_ioctl_get_cpinfo(struct inode *inode, struct file *filp,
155 unsigned int cmd, void __user *argp)
156{
157 struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
158 struct nilfs_argv argv;
159 int ret; 151 int ret;
160 152
161 if (copy_from_user(&argv, argp, sizeof(argv)))
162 return -EFAULT;
163
164 down_read(&nilfs->ns_segctor_sem); 153 down_read(&nilfs->ns_segctor_sem);
165 ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), 154 ret = nilfs_cpfile_get_cpinfo(nilfs->ns_cpfile, posp, flags, buf,
166 nilfs_ioctl_do_get_cpinfo); 155 nmembs);
167 up_read(&nilfs->ns_segctor_sem); 156 up_read(&nilfs->ns_segctor_sem);
168 if (ret < 0)
169 return ret;
170
171 if (copy_to_user(argp, &argv, sizeof(argv)))
172 ret = -EFAULT;
173 return ret; 157 return ret;
174} 158}
175 159
@@ -195,28 +179,11 @@ static ssize_t
195nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, 179nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
196 void *buf, size_t size, size_t nmembs) 180 void *buf, size_t size, size_t nmembs)
197{ 181{
198 return nilfs_sufile_get_suinfo(nilfs->ns_sufile, *posp, buf, nmembs);
199}
200
201static int nilfs_ioctl_get_suinfo(struct inode *inode, struct file *filp,
202 unsigned int cmd, void __user *argp)
203{
204 struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
205 struct nilfs_argv argv;
206 int ret; 182 int ret;
207 183
208 if (copy_from_user(&argv, argp, sizeof(argv)))
209 return -EFAULT;
210
211 down_read(&nilfs->ns_segctor_sem); 184 down_read(&nilfs->ns_segctor_sem);
212 ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), 185 ret = nilfs_sufile_get_suinfo(nilfs->ns_sufile, *posp, buf, nmembs);
213 nilfs_ioctl_do_get_suinfo);
214 up_read(&nilfs->ns_segctor_sem); 186 up_read(&nilfs->ns_segctor_sem);
215 if (ret < 0)
216 return ret;
217
218 if (copy_to_user(argp, &argv, sizeof(argv)))
219 ret = -EFAULT;
220 return ret; 187 return ret;
221} 188}
222 189
@@ -242,28 +209,11 @@ static ssize_t
242nilfs_ioctl_do_get_vinfo(struct the_nilfs *nilfs, __u64 *posp, int flags, 209nilfs_ioctl_do_get_vinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
243 void *buf, size_t size, size_t nmembs) 210 void *buf, size_t size, size_t nmembs)
244{ 211{
245 return nilfs_dat_get_vinfo(nilfs_dat_inode(nilfs), buf, nmembs);
246}
247
248static int nilfs_ioctl_get_vinfo(struct inode *inode, struct file *filp,
249 unsigned int cmd, void __user *argp)
250{
251 struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
252 struct nilfs_argv argv;
253 int ret; 212 int ret;
254 213
255 if (copy_from_user(&argv, argp, sizeof(argv)))
256 return -EFAULT;
257
258 down_read(&nilfs->ns_segctor_sem); 214 down_read(&nilfs->ns_segctor_sem);
259 ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), 215 ret = nilfs_dat_get_vinfo(nilfs_dat_inode(nilfs), buf, nmembs);
260 nilfs_ioctl_do_get_vinfo);
261 up_read(&nilfs->ns_segctor_sem); 216 up_read(&nilfs->ns_segctor_sem);
262 if (ret < 0)
263 return ret;
264
265 if (copy_to_user(argp, &argv, sizeof(argv)))
266 ret = -EFAULT;
267 return ret; 217 return ret;
268} 218}
269 219
@@ -276,17 +226,21 @@ nilfs_ioctl_do_get_bdescs(struct the_nilfs *nilfs, __u64 *posp, int flags,
276 struct nilfs_bdesc *bdescs = buf; 226 struct nilfs_bdesc *bdescs = buf;
277 int ret, i; 227 int ret, i;
278 228
229 down_read(&nilfs->ns_segctor_sem);
279 for (i = 0; i < nmembs; i++) { 230 for (i = 0; i < nmembs; i++) {
280 ret = nilfs_bmap_lookup_at_level(bmap, 231 ret = nilfs_bmap_lookup_at_level(bmap,
281 bdescs[i].bd_offset, 232 bdescs[i].bd_offset,
282 bdescs[i].bd_level + 1, 233 bdescs[i].bd_level + 1,
283 &bdescs[i].bd_blocknr); 234 &bdescs[i].bd_blocknr);
284 if (ret < 0) { 235 if (ret < 0) {
285 if (ret != -ENOENT) 236 if (ret != -ENOENT) {
237 up_read(&nilfs->ns_segctor_sem);
286 return ret; 238 return ret;
239 }
287 bdescs[i].bd_blocknr = 0; 240 bdescs[i].bd_blocknr = 0;
288 } 241 }
289 } 242 }
243 up_read(&nilfs->ns_segctor_sem);
290 return nmembs; 244 return nmembs;
291} 245}
292 246
@@ -300,10 +254,11 @@ static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp,
300 if (copy_from_user(&argv, argp, sizeof(argv))) 254 if (copy_from_user(&argv, argp, sizeof(argv)))
301 return -EFAULT; 255 return -EFAULT;
302 256
303 down_read(&nilfs->ns_segctor_sem); 257 if (argv.v_size != sizeof(struct nilfs_bdesc))
258 return -EINVAL;
259
304 ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), 260 ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd),
305 nilfs_ioctl_do_get_bdescs); 261 nilfs_ioctl_do_get_bdescs);
306 up_read(&nilfs->ns_segctor_sem);
307 if (ret < 0) 262 if (ret < 0)
308 return ret; 263 return ret;
309 264
@@ -346,10 +301,10 @@ static int nilfs_ioctl_move_inode_block(struct inode *inode,
346 return 0; 301 return 0;
347} 302}
348 303
349static ssize_t 304static int nilfs_ioctl_move_blocks(struct the_nilfs *nilfs,
350nilfs_ioctl_do_move_blocks(struct the_nilfs *nilfs, __u64 *posp, int flags, 305 struct nilfs_argv *argv, void *buf)
351 void *buf, size_t size, size_t nmembs)
352{ 306{
307 size_t nmembs = argv->v_nmembs;
353 struct inode *inode; 308 struct inode *inode;
354 struct nilfs_vdesc *vdesc; 309 struct nilfs_vdesc *vdesc;
355 struct buffer_head *bh, *n; 310 struct buffer_head *bh, *n;
@@ -410,19 +365,10 @@ nilfs_ioctl_do_move_blocks(struct the_nilfs *nilfs, __u64 *posp, int flags,
410 return ret; 365 return ret;
411} 366}
412 367
413static inline int nilfs_ioctl_move_blocks(struct the_nilfs *nilfs, 368static int nilfs_ioctl_delete_checkpoints(struct the_nilfs *nilfs,
414 struct nilfs_argv *argv, 369 struct nilfs_argv *argv, void *buf)
415 int dir)
416{
417 return nilfs_ioctl_wrap_copy(nilfs, argv, dir,
418 nilfs_ioctl_do_move_blocks);
419}
420
421static ssize_t
422nilfs_ioctl_do_delete_checkpoints(struct the_nilfs *nilfs, __u64 *posp,
423 int flags, void *buf, size_t size,
424 size_t nmembs)
425{ 370{
371 size_t nmembs = argv->v_nmembs;
426 struct inode *cpfile = nilfs->ns_cpfile; 372 struct inode *cpfile = nilfs->ns_cpfile;
427 struct nilfs_period *periods = buf; 373 struct nilfs_period *periods = buf;
428 int ret, i; 374 int ret, i;
@@ -436,36 +382,21 @@ nilfs_ioctl_do_delete_checkpoints(struct the_nilfs *nilfs, __u64 *posp,
436 return nmembs; 382 return nmembs;
437} 383}
438 384
439static inline int nilfs_ioctl_delete_checkpoints(struct the_nilfs *nilfs, 385static int nilfs_ioctl_free_vblocknrs(struct the_nilfs *nilfs,
440 struct nilfs_argv *argv, 386 struct nilfs_argv *argv, void *buf)
441 int dir)
442{ 387{
443 return nilfs_ioctl_wrap_copy(nilfs, argv, dir, 388 size_t nmembs = argv->v_nmembs;
444 nilfs_ioctl_do_delete_checkpoints); 389 int ret;
445}
446 390
447static ssize_t 391 ret = nilfs_dat_freev(nilfs_dat_inode(nilfs), buf, nmembs);
448nilfs_ioctl_do_free_vblocknrs(struct the_nilfs *nilfs, __u64 *posp, int flags,
449 void *buf, size_t size, size_t nmembs)
450{
451 int ret = nilfs_dat_freev(nilfs_dat_inode(nilfs), buf, nmembs);
452 392
453 return (ret < 0) ? ret : nmembs; 393 return (ret < 0) ? ret : nmembs;
454} 394}
455 395
456static inline int nilfs_ioctl_free_vblocknrs(struct the_nilfs *nilfs, 396static int nilfs_ioctl_mark_blocks_dirty(struct the_nilfs *nilfs,
457 struct nilfs_argv *argv, 397 struct nilfs_argv *argv, void *buf)
458 int dir)
459{
460 return nilfs_ioctl_wrap_copy(nilfs, argv, dir,
461 nilfs_ioctl_do_free_vblocknrs);
462}
463
464static ssize_t
465nilfs_ioctl_do_mark_blocks_dirty(struct the_nilfs *nilfs, __u64 *posp,
466 int flags, void *buf, size_t size,
467 size_t nmembs)
468{ 398{
399 size_t nmembs = argv->v_nmembs;
469 struct inode *dat = nilfs_dat_inode(nilfs); 400 struct inode *dat = nilfs_dat_inode(nilfs);
470 struct nilfs_bmap *bmap = NILFS_I(dat)->i_bmap; 401 struct nilfs_bmap *bmap = NILFS_I(dat)->i_bmap;
471 struct nilfs_bdesc *bdescs = buf; 402 struct nilfs_bdesc *bdescs = buf;
@@ -504,55 +435,37 @@ nilfs_ioctl_do_mark_blocks_dirty(struct the_nilfs *nilfs, __u64 *posp,
504 return nmembs; 435 return nmembs;
505} 436}
506 437
507static inline int nilfs_ioctl_mark_blocks_dirty(struct the_nilfs *nilfs, 438static int nilfs_ioctl_free_segments(struct the_nilfs *nilfs,
508 struct nilfs_argv *argv, 439 struct nilfs_argv *argv, void *buf)
509 int dir)
510{ 440{
511 return nilfs_ioctl_wrap_copy(nilfs, argv, dir, 441 size_t nmembs = argv->v_nmembs;
512 nilfs_ioctl_do_mark_blocks_dirty); 442 struct nilfs_sb_info *sbi = nilfs->ns_writer;
513}
514
515static ssize_t
516nilfs_ioctl_do_free_segments(struct the_nilfs *nilfs, __u64 *posp, int flags,
517 void *buf, size_t size, size_t nmembs)
518{
519 struct nilfs_sb_info *sbi = nilfs_get_writer(nilfs);
520 int ret; 443 int ret;
521 444
522 if (unlikely(!sbi)) 445 if (unlikely(!sbi)) {
446 /* never happens because called for a writable mount */
447 WARN_ON(1);
523 return -EROFS; 448 return -EROFS;
449 }
524 ret = nilfs_segctor_add_segments_to_be_freed( 450 ret = nilfs_segctor_add_segments_to_be_freed(
525 NILFS_SC(sbi), buf, nmembs); 451 NILFS_SC(sbi), buf, nmembs);
526 nilfs_put_writer(nilfs);
527 452
528 return (ret < 0) ? ret : nmembs; 453 return (ret < 0) ? ret : nmembs;
529} 454}
530 455
531static inline int nilfs_ioctl_free_segments(struct the_nilfs *nilfs,
532 struct nilfs_argv *argv,
533 int dir)
534{
535 return nilfs_ioctl_wrap_copy(nilfs, argv, dir,
536 nilfs_ioctl_do_free_segments);
537}
538
539int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs, 456int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs,
540 void __user *argp) 457 struct nilfs_argv *argv, void **kbufs)
541{ 458{
542 struct nilfs_argv argv[5];
543 const char *msg; 459 const char *msg;
544 int dir, ret; 460 int ret;
545
546 if (copy_from_user(argv, argp, sizeof(argv)))
547 return -EFAULT;
548 461
549 dir = _IOC_WRITE; 462 ret = nilfs_ioctl_move_blocks(nilfs, &argv[0], kbufs[0]);
550 ret = nilfs_ioctl_move_blocks(nilfs, &argv[0], dir);
551 if (ret < 0) { 463 if (ret < 0) {
552 msg = "cannot read source blocks"; 464 msg = "cannot read source blocks";
553 goto failed; 465 goto failed;
554 } 466 }
555 ret = nilfs_ioctl_delete_checkpoints(nilfs, &argv[1], dir); 467
468 ret = nilfs_ioctl_delete_checkpoints(nilfs, &argv[1], kbufs[1]);
556 if (ret < 0) { 469 if (ret < 0) {
557 /* 470 /*
558 * can safely abort because checkpoints can be removed 471 * can safely abort because checkpoints can be removed
@@ -561,7 +474,7 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs,
561 msg = "cannot delete checkpoints"; 474 msg = "cannot delete checkpoints";
562 goto failed; 475 goto failed;
563 } 476 }
564 ret = nilfs_ioctl_free_vblocknrs(nilfs, &argv[2], dir); 477 ret = nilfs_ioctl_free_vblocknrs(nilfs, &argv[2], kbufs[2]);
565 if (ret < 0) { 478 if (ret < 0) {
566 /* 479 /*
567 * can safely abort because DAT file is updated atomically 480 * can safely abort because DAT file is updated atomically
@@ -570,7 +483,7 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs,
570 msg = "cannot delete virtual blocks from DAT file"; 483 msg = "cannot delete virtual blocks from DAT file";
571 goto failed; 484 goto failed;
572 } 485 }
573 ret = nilfs_ioctl_mark_blocks_dirty(nilfs, &argv[3], dir); 486 ret = nilfs_ioctl_mark_blocks_dirty(nilfs, &argv[3], kbufs[3]);
574 if (ret < 0) { 487 if (ret < 0) {
575 /* 488 /*
576 * can safely abort because the operation is nondestructive. 489 * can safely abort because the operation is nondestructive.
@@ -578,7 +491,7 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs,
578 msg = "cannot mark copying blocks dirty"; 491 msg = "cannot mark copying blocks dirty";
579 goto failed; 492 goto failed;
580 } 493 }
581 ret = nilfs_ioctl_free_segments(nilfs, &argv[4], dir); 494 ret = nilfs_ioctl_free_segments(nilfs, &argv[4], kbufs[4]);
582 if (ret < 0) { 495 if (ret < 0) {
583 /* 496 /*
584 * can safely abort because this operation is atomic. 497 * can safely abort because this operation is atomic.
@@ -598,9 +511,75 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs,
598static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp, 511static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
599 unsigned int cmd, void __user *argp) 512 unsigned int cmd, void __user *argp)
600{ 513{
514 struct nilfs_argv argv[5];
515 const static size_t argsz[5] = {
516 sizeof(struct nilfs_vdesc),
517 sizeof(struct nilfs_period),
518 sizeof(__u64),
519 sizeof(struct nilfs_bdesc),
520 sizeof(__u64),
521 };
522 void __user *base;
523 void *kbufs[5];
524 struct the_nilfs *nilfs;
525 size_t len, nsegs;
526 int n, ret;
527
601 if (!capable(CAP_SYS_ADMIN)) 528 if (!capable(CAP_SYS_ADMIN))
602 return -EPERM; 529 return -EPERM;
603 return nilfs_clean_segments(inode->i_sb, argp); 530
531 if (copy_from_user(argv, argp, sizeof(argv)))
532 return -EFAULT;
533
534 nsegs = argv[4].v_nmembs;
535 if (argv[4].v_size != argsz[4])
536 return -EINVAL;
537 /*
538 * argv[4] points to segment numbers this ioctl cleans. We
539 * use kmalloc() for its buffer because memory used for the
540 * segment numbers is enough small.
541 */
542 kbufs[4] = memdup_user((void __user *)(unsigned long)argv[4].v_base,
543 nsegs * sizeof(__u64));
544 if (IS_ERR(kbufs[4]))
545 return PTR_ERR(kbufs[4]);
546
547 nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
548
549 for (n = 0; n < 4; n++) {
550 ret = -EINVAL;
551 if (argv[n].v_size != argsz[n])
552 goto out_free;
553
554 if (argv[n].v_nmembs > nsegs * nilfs->ns_blocks_per_segment)
555 goto out_free;
556
557 len = argv[n].v_size * argv[n].v_nmembs;
558 base = (void __user *)(unsigned long)argv[n].v_base;
559 if (len == 0) {
560 kbufs[n] = NULL;
561 continue;
562 }
563
564 kbufs[n] = vmalloc(len);
565 if (!kbufs[n]) {
566 ret = -ENOMEM;
567 goto out_free;
568 }
569 if (copy_from_user(kbufs[n], base, len)) {
570 ret = -EFAULT;
571 vfree(kbufs[n]);
572 goto out_free;
573 }
574 }
575
576 ret = nilfs_clean_segments(inode->i_sb, argv, kbufs);
577
578 out_free:
579 while (--n >= 0)
580 vfree(kbufs[n]);
581 kfree(kbufs[4]);
582 return ret;
604} 583}
605 584
606static int nilfs_ioctl_sync(struct inode *inode, struct file *filp, 585static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
@@ -621,6 +600,33 @@ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
621 return 0; 600 return 0;
622} 601}
623 602
603static int nilfs_ioctl_get_info(struct inode *inode, struct file *filp,
604 unsigned int cmd, void __user *argp,
605 size_t membsz,
606 ssize_t (*dofunc)(struct the_nilfs *,
607 __u64 *, int,
608 void *, size_t, size_t))
609
610{
611 struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
612 struct nilfs_argv argv;
613 int ret;
614
615 if (copy_from_user(&argv, argp, sizeof(argv)))
616 return -EFAULT;
617
618 if (argv.v_size != membsz)
619 return -EINVAL;
620
621 ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), dofunc);
622 if (ret < 0)
623 return ret;
624
625 if (copy_to_user(argp, &argv, sizeof(argv)))
626 ret = -EFAULT;
627 return ret;
628}
629
624long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 630long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
625{ 631{
626 struct inode *inode = filp->f_dentry->d_inode; 632 struct inode *inode = filp->f_dentry->d_inode;
@@ -632,16 +638,21 @@ long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
632 case NILFS_IOCTL_DELETE_CHECKPOINT: 638 case NILFS_IOCTL_DELETE_CHECKPOINT:
633 return nilfs_ioctl_delete_checkpoint(inode, filp, cmd, argp); 639 return nilfs_ioctl_delete_checkpoint(inode, filp, cmd, argp);
634 case NILFS_IOCTL_GET_CPINFO: 640 case NILFS_IOCTL_GET_CPINFO:
635 return nilfs_ioctl_get_cpinfo(inode, filp, cmd, argp); 641 return nilfs_ioctl_get_info(inode, filp, cmd, argp,
642 sizeof(struct nilfs_cpinfo),
643 nilfs_ioctl_do_get_cpinfo);
636 case NILFS_IOCTL_GET_CPSTAT: 644 case NILFS_IOCTL_GET_CPSTAT:
637 return nilfs_ioctl_get_cpstat(inode, filp, cmd, argp); 645 return nilfs_ioctl_get_cpstat(inode, filp, cmd, argp);
638 case NILFS_IOCTL_GET_SUINFO: 646 case NILFS_IOCTL_GET_SUINFO:
639 return nilfs_ioctl_get_suinfo(inode, filp, cmd, argp); 647 return nilfs_ioctl_get_info(inode, filp, cmd, argp,
648 sizeof(struct nilfs_suinfo),
649 nilfs_ioctl_do_get_suinfo);
640 case NILFS_IOCTL_GET_SUSTAT: 650 case NILFS_IOCTL_GET_SUSTAT:
641 return nilfs_ioctl_get_sustat(inode, filp, cmd, argp); 651 return nilfs_ioctl_get_sustat(inode, filp, cmd, argp);
642 case NILFS_IOCTL_GET_VINFO: 652 case NILFS_IOCTL_GET_VINFO:
643 /* XXX: rename to ??? */ 653 return nilfs_ioctl_get_info(inode, filp, cmd, argp,
644 return nilfs_ioctl_get_vinfo(inode, filp, cmd, argp); 654 sizeof(struct nilfs_vinfo),
655 nilfs_ioctl_do_get_vinfo);
645 case NILFS_IOCTL_GET_BDESCS: 656 case NILFS_IOCTL_GET_BDESCS:
646 return nilfs_ioctl_get_bdescs(inode, filp, cmd, argp); 657 return nilfs_ioctl_get_bdescs(inode, filp, cmd, argp);
647 case NILFS_IOCTL_CLEAN_SEGMENTS: 658 case NILFS_IOCTL_CLEAN_SEGMENTS:
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index 47dd815433fd..bb78745a0e30 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -77,19 +77,22 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block,
77 void *)) 77 void *))
78{ 78{
79 struct the_nilfs *nilfs = NILFS_MDT(inode)->mi_nilfs; 79 struct the_nilfs *nilfs = NILFS_MDT(inode)->mi_nilfs;
80 struct nilfs_sb_info *writer = NULL;
81 struct super_block *sb = inode->i_sb; 80 struct super_block *sb = inode->i_sb;
82 struct nilfs_transaction_info ti; 81 struct nilfs_transaction_info ti;
83 struct buffer_head *bh; 82 struct buffer_head *bh;
84 int err; 83 int err;
85 84
86 if (!sb) { 85 if (!sb) {
87 writer = nilfs_get_writer(nilfs); 86 /*
88 if (!writer) { 87 * Make sure this function is not called from any
88 * read-only context.
89 */
90 if (!nilfs->ns_writer) {
91 WARN_ON(1);
89 err = -EROFS; 92 err = -EROFS;
90 goto out; 93 goto out;
91 } 94 }
92 sb = writer->s_super; 95 sb = nilfs->ns_writer->s_super;
93 } 96 }
94 97
95 nilfs_transaction_begin(sb, &ti, 0); 98 nilfs_transaction_begin(sb, &ti, 0);
@@ -127,8 +130,6 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block,
127 err = nilfs_transaction_commit(sb); 130 err = nilfs_transaction_commit(sb);
128 else 131 else
129 nilfs_transaction_abort(sb); 132 nilfs_transaction_abort(sb);
130 if (writer)
131 nilfs_put_writer(nilfs);
132 out: 133 out:
133 return err; 134 return err;
134} 135}
@@ -299,7 +300,7 @@ int nilfs_mdt_delete_block(struct inode *inode, unsigned long block)
299 int err; 300 int err;
300 301
301 err = nilfs_bmap_delete(ii->i_bmap, block); 302 err = nilfs_bmap_delete(ii->i_bmap, block);
302 if (likely(!err)) { 303 if (!err || err == -ENOENT) {
303 nilfs_mdt_mark_dirty(inode); 304 nilfs_mdt_mark_dirty(inode);
304 nilfs_mdt_forget_block(inode, block); 305 nilfs_mdt_forget_block(inode, block);
305 } 306 }
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 3d0c18a16db1..da6fc0bba2e5 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -236,7 +236,8 @@ extern int nilfs_sync_file(struct file *, struct dentry *, int);
236 236
237/* ioctl.c */ 237/* ioctl.c */
238long nilfs_ioctl(struct file *, unsigned int, unsigned long); 238long nilfs_ioctl(struct file *, unsigned int, unsigned long);
239int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, void __user *); 239int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *,
240 void **);
240 241
241/* inode.c */ 242/* inode.c */
242extern struct inode *nilfs_new_inode(struct inode *, int); 243extern struct inode *nilfs_new_inode(struct inode *, int);
diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 1bfbba9c0e9a..a2692bbc7b50 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -128,7 +128,8 @@ void nilfs_forget_buffer(struct buffer_head *bh)
128 128
129 lock_buffer(bh); 129 lock_buffer(bh);
130 clear_buffer_nilfs_volatile(bh); 130 clear_buffer_nilfs_volatile(bh);
131 if (test_clear_buffer_dirty(bh) && nilfs_page_buffers_clean(page)) 131 clear_buffer_dirty(bh);
132 if (nilfs_page_buffers_clean(page))
132 __nilfs_clear_page_dirty(page); 133 __nilfs_clear_page_dirty(page);
133 134
134 clear_buffer_uptodate(bh); 135 clear_buffer_uptodate(bh);
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index 4fc081e47d70..57afa9d24061 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -407,6 +407,7 @@ void nilfs_dispose_segment_list(struct list_head *head)
407} 407}
408 408
409static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs, 409static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
410 struct nilfs_sb_info *sbi,
410 struct nilfs_recovery_info *ri) 411 struct nilfs_recovery_info *ri)
411{ 412{
412 struct list_head *head = &ri->ri_used_segments; 413 struct list_head *head = &ri->ri_used_segments;
@@ -421,6 +422,7 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
421 segnum[2] = ri->ri_segnum; 422 segnum[2] = ri->ri_segnum;
422 segnum[3] = ri->ri_nextnum; 423 segnum[3] = ri->ri_nextnum;
423 424
425 nilfs_attach_writer(nilfs, sbi);
424 /* 426 /*
425 * Releasing the next segment of the latest super root. 427 * Releasing the next segment of the latest super root.
426 * The next segment is invalidated by this recovery. 428 * The next segment is invalidated by this recovery.
@@ -459,10 +461,10 @@ static int nilfs_prepare_segment_for_recovery(struct the_nilfs *nilfs,
459 nilfs->ns_pseg_offset = 0; 461 nilfs->ns_pseg_offset = 0;
460 nilfs->ns_seg_seq = ri->ri_seq + 2; 462 nilfs->ns_seg_seq = ri->ri_seq + 2;
461 nilfs->ns_nextnum = nilfs->ns_segnum = segnum[0]; 463 nilfs->ns_nextnum = nilfs->ns_segnum = segnum[0];
462 return 0;
463 464
464 failed: 465 failed:
465 /* No need to recover sufile because it will be destroyed on error */ 466 /* No need to recover sufile because it will be destroyed on error */
467 nilfs_detach_writer(nilfs, sbi);
466 return err; 468 return err;
467} 469}
468 470
@@ -728,7 +730,7 @@ int nilfs_recover_logical_segments(struct the_nilfs *nilfs,
728 goto failed; 730 goto failed;
729 731
730 if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) { 732 if (ri->ri_need_recovery == NILFS_RECOVERY_ROLLFORWARD_DONE) {
731 err = nilfs_prepare_segment_for_recovery(nilfs, ri); 733 err = nilfs_prepare_segment_for_recovery(nilfs, sbi, ri);
732 if (unlikely(err)) { 734 if (unlikely(err)) {
733 printk(KERN_ERR "NILFS: Error preparing segments for " 735 printk(KERN_ERR "NILFS: Error preparing segments for "
734 "recovery.\n"); 736 "recovery.\n");
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index fb70ec3be20e..22c7f65c2403 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -2589,7 +2589,8 @@ nilfs_remove_written_gcinodes(struct the_nilfs *nilfs, struct list_head *head)
2589 } 2589 }
2590} 2590}
2591 2591
2592int nilfs_clean_segments(struct super_block *sb, void __user *argp) 2592int nilfs_clean_segments(struct super_block *sb, struct nilfs_argv *argv,
2593 void **kbufs)
2593{ 2594{
2594 struct nilfs_sb_info *sbi = NILFS_SB(sb); 2595 struct nilfs_sb_info *sbi = NILFS_SB(sb);
2595 struct nilfs_sc_info *sci = NILFS_SC(sbi); 2596 struct nilfs_sc_info *sci = NILFS_SC(sbi);
@@ -2606,7 +2607,7 @@ int nilfs_clean_segments(struct super_block *sb, void __user *argp)
2606 err = nilfs_init_gcdat_inode(nilfs); 2607 err = nilfs_init_gcdat_inode(nilfs);
2607 if (unlikely(err)) 2608 if (unlikely(err))
2608 goto out_unlock; 2609 goto out_unlock;
2609 err = nilfs_ioctl_prepare_clean_segments(nilfs, argp); 2610 err = nilfs_ioctl_prepare_clean_segments(nilfs, argv, kbufs);
2610 if (unlikely(err)) 2611 if (unlikely(err))
2611 goto out_unlock; 2612 goto out_unlock;
2612 2613
diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h
index a98fc1ed0bbb..476bdd5df5be 100644
--- a/fs/nilfs2/segment.h
+++ b/fs/nilfs2/segment.h
@@ -222,7 +222,8 @@ extern int nilfs_construct_segment(struct super_block *);
222extern int nilfs_construct_dsync_segment(struct super_block *, struct inode *, 222extern int nilfs_construct_dsync_segment(struct super_block *, struct inode *,
223 loff_t, loff_t); 223 loff_t, loff_t);
224extern void nilfs_flush_segment(struct super_block *, ino_t); 224extern void nilfs_flush_segment(struct super_block *, ino_t);
225extern int nilfs_clean_segments(struct super_block *, void __user *); 225extern int nilfs_clean_segments(struct super_block *, struct nilfs_argv *,
226 void **);
226 227
227extern int nilfs_segctor_add_segments_to_be_freed(struct nilfs_sc_info *, 228extern int nilfs_segctor_add_segments_to_be_freed(struct nilfs_sc_info *,
228 __u64 *, size_t); 229 __u64 *, size_t);
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
index ed0a0cfd68d2..579dd1b1110f 100644
--- a/fs/ocfs2/symlink.c
+++ b/fs/ocfs2/symlink.c
@@ -39,6 +39,7 @@
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/pagemap.h> 40#include <linux/pagemap.h>
41#include <linux/utsname.h> 41#include <linux/utsname.h>
42#include <linux/namei.h>
42 43
43#define MLOG_MASK_PREFIX ML_NAMEI 44#define MLOG_MASK_PREFIX ML_NAMEI
44#include <cluster/masklog.h> 45#include <cluster/masklog.h>
@@ -54,26 +55,6 @@
54 55
55#include "buffer_head_io.h" 56#include "buffer_head_io.h"
56 57
57static char *ocfs2_page_getlink(struct dentry * dentry,
58 struct page **ppage);
59static char *ocfs2_fast_symlink_getlink(struct inode *inode,
60 struct buffer_head **bh);
61
62/* get the link contents into pagecache */
63static char *ocfs2_page_getlink(struct dentry * dentry,
64 struct page **ppage)
65{
66 struct page * page;
67 struct address_space *mapping = dentry->d_inode->i_mapping;
68 page = read_mapping_page(mapping, 0, NULL);
69 if (IS_ERR(page))
70 goto sync_fail;
71 *ppage = page;
72 return kmap(page);
73
74sync_fail:
75 return (char*)page;
76}
77 58
78static char *ocfs2_fast_symlink_getlink(struct inode *inode, 59static char *ocfs2_fast_symlink_getlink(struct inode *inode,
79 struct buffer_head **bh) 60 struct buffer_head **bh)
@@ -128,40 +109,55 @@ out:
128 return ret; 109 return ret;
129} 110}
130 111
131static void *ocfs2_follow_link(struct dentry *dentry, 112static void *ocfs2_fast_follow_link(struct dentry *dentry,
132 struct nameidata *nd) 113 struct nameidata *nd)
133{ 114{
134 int status; 115 int status = 0;
135 char *link; 116 int len;
117 char *target, *link = ERR_PTR(-ENOMEM);
136 struct inode *inode = dentry->d_inode; 118 struct inode *inode = dentry->d_inode;
137 struct page *page = NULL;
138 struct buffer_head *bh = NULL; 119 struct buffer_head *bh = NULL;
139 120
140 if (ocfs2_inode_is_fast_symlink(inode)) 121 mlog_entry_void();
141 link = ocfs2_fast_symlink_getlink(inode, &bh); 122
142 else 123 BUG_ON(!ocfs2_inode_is_fast_symlink(inode));
143 link = ocfs2_page_getlink(dentry, &page); 124 target = ocfs2_fast_symlink_getlink(inode, &bh);
144 if (IS_ERR(link)) { 125 if (IS_ERR(target)) {
145 status = PTR_ERR(link); 126 status = PTR_ERR(target);
146 mlog_errno(status); 127 mlog_errno(status);
147 goto bail; 128 goto bail;
148 } 129 }
149 130
150 status = vfs_follow_link(nd, link); 131 /* Fast symlinks can't be large */
132 len = strlen(target);
133 link = kzalloc(len + 1, GFP_NOFS);
134 if (!link) {
135 status = -ENOMEM;
136 mlog_errno(status);
137 goto bail;
138 }
139
140 memcpy(link, target, len);
141 nd_set_link(nd, link);
151 142
152bail: 143bail:
153 if (page) {
154 kunmap(page);
155 page_cache_release(page);
156 }
157 brelse(bh); 144 brelse(bh);
158 145
159 return ERR_PTR(status); 146 mlog_exit(status);
147 return status ? ERR_PTR(status) : link;
148}
149
150static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
151{
152 char *link = cookie;
153
154 kfree(link);
160} 155}
161 156
162const struct inode_operations ocfs2_symlink_inode_operations = { 157const struct inode_operations ocfs2_symlink_inode_operations = {
163 .readlink = page_readlink, 158 .readlink = page_readlink,
164 .follow_link = ocfs2_follow_link, 159 .follow_link = page_follow_link_light,
160 .put_link = page_put_link,
165 .getattr = ocfs2_getattr, 161 .getattr = ocfs2_getattr,
166 .setattr = ocfs2_setattr, 162 .setattr = ocfs2_setattr,
167 .setxattr = generic_setxattr, 163 .setxattr = generic_setxattr,
@@ -171,7 +167,8 @@ const struct inode_operations ocfs2_symlink_inode_operations = {
171}; 167};
172const struct inode_operations ocfs2_fast_symlink_inode_operations = { 168const struct inode_operations ocfs2_fast_symlink_inode_operations = {
173 .readlink = ocfs2_readlink, 169 .readlink = ocfs2_readlink,
174 .follow_link = ocfs2_follow_link, 170 .follow_link = ocfs2_fast_follow_link,
171 .put_link = ocfs2_fast_put_link,
175 .getattr = ocfs2_getattr, 172 .getattr = ocfs2_getattr,
176 .setattr = ocfs2_setattr, 173 .setattr = ocfs2_setattr,
177 .setxattr = generic_setxattr, 174 .setxattr = generic_setxattr,
diff --git a/fs/open.c b/fs/open.c
index 377eb25b6abf..bdfbf03615a4 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1033,7 +1033,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
1033 if (!IS_ERR(tmp)) { 1033 if (!IS_ERR(tmp)) {
1034 fd = get_unused_fd_flags(flags); 1034 fd = get_unused_fd_flags(flags);
1035 if (fd >= 0) { 1035 if (fd >= 0) {
1036 struct file *f = do_filp_open(dfd, tmp, flags, mode); 1036 struct file *f = do_filp_open(dfd, tmp, flags, mode, 0);
1037 if (IS_ERR(f)) { 1037 if (IS_ERR(f)) {
1038 put_unused_fd(fd); 1038 put_unused_fd(fd);
1039 fd = PTR_ERR(f); 1039 fd = PTR_ERR(f);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index fb45615943c2..3326bbf9ab95 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1956,7 +1956,7 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,
1956 const struct pid_entry *p = ptr; 1956 const struct pid_entry *p = ptr;
1957 struct inode *inode; 1957 struct inode *inode;
1958 struct proc_inode *ei; 1958 struct proc_inode *ei;
1959 struct dentry *error = ERR_PTR(-EINVAL); 1959 struct dentry *error = ERR_PTR(-ENOENT);
1960 1960
1961 inode = proc_pid_make_inode(dir->i_sb, task); 1961 inode = proc_pid_make_inode(dir->i_sb, task);
1962 if (!inode) 1962 if (!inode)
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 1e15a2b176e8..b080b791d9e3 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -67,8 +67,7 @@ static int proc_get_sb(struct file_system_type *fs_type,
67 sb->s_flags = flags; 67 sb->s_flags = flags;
68 err = proc_fill_super(sb); 68 err = proc_fill_super(sb);
69 if (err) { 69 if (err) {
70 up_write(&sb->s_umount); 70 deactivate_locked_super(sb);
71 deactivate_super(sb);
72 return err; 71 return err;
73 } 72 }
74 73
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index 67a80d7e59e2..45ee3d357c70 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -41,6 +41,18 @@ static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,
41 41
42#define store_ih(where,what) copy_item_head (where, what) 42#define store_ih(where,what) copy_item_head (where, what)
43 43
44static inline bool is_privroot_deh(struct dentry *dir,
45 struct reiserfs_de_head *deh)
46{
47 int ret = 0;
48#ifdef CONFIG_REISERFS_FS_XATTR
49 struct dentry *privroot = REISERFS_SB(dir->d_sb)->priv_root;
50 ret = (dir == dir->d_parent && privroot->d_inode &&
51 deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid);
52#endif
53 return ret;
54}
55
44int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent, 56int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
45 filldir_t filldir, loff_t *pos) 57 filldir_t filldir, loff_t *pos)
46{ 58{
@@ -138,18 +150,8 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
138 } 150 }
139 151
140 /* Ignore the .reiserfs_priv entry */ 152 /* Ignore the .reiserfs_priv entry */
141 if (reiserfs_xattrs(inode->i_sb) && 153 if (is_privroot_deh(dentry, deh))
142 !old_format_only(inode->i_sb) &&
143 dentry == inode->i_sb->s_root &&
144 REISERFS_SB(inode->i_sb)->priv_root &&
145 REISERFS_SB(inode->i_sb)->priv_root->d_inode
146 && deh_objectid(deh) ==
147 le32_to_cpu(INODE_PKEY
148 (REISERFS_SB(inode->i_sb)->
149 priv_root->d_inode)->
150 k_objectid)) {
151 continue; 154 continue;
152 }
153 155
154 d_off = deh_offset(deh); 156 d_off = deh_offset(deh);
155 *pos = d_off; 157 *pos = d_off;
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index efd4d720718e..271579128634 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -338,21 +338,8 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
338 &path_to_entry, &de); 338 &path_to_entry, &de);
339 pathrelse(&path_to_entry); 339 pathrelse(&path_to_entry);
340 if (retval == NAME_FOUND) { 340 if (retval == NAME_FOUND) {
341 /* Hide the .reiserfs_priv directory */ 341 inode = reiserfs_iget(dir->i_sb,
342 if (reiserfs_xattrs(dir->i_sb) && 342 (struct cpu_key *)&(de.de_dir_id));
343 !old_format_only(dir->i_sb) &&
344 REISERFS_SB(dir->i_sb)->priv_root &&
345 REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
346 de.de_objectid ==
347 le32_to_cpu(INODE_PKEY
348 (REISERFS_SB(dir->i_sb)->priv_root->d_inode)->
349 k_objectid)) {
350 reiserfs_write_unlock(dir->i_sb);
351 return ERR_PTR(-EACCES);
352 }
353
354 inode =
355 reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
356 if (!inode || IS_ERR(inode)) { 343 if (!inode || IS_ERR(inode)) {
357 reiserfs_write_unlock(dir->i_sb); 344 reiserfs_write_unlock(dir->i_sb);
358 return ERR_PTR(-EACCES); 345 return ERR_PTR(-EACCES);
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 0ae6486d9046..3567fb9e3fb1 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -448,13 +448,11 @@ int remove_save_link(struct inode *inode, int truncate)
448static void reiserfs_kill_sb(struct super_block *s) 448static void reiserfs_kill_sb(struct super_block *s)
449{ 449{
450 if (REISERFS_SB(s)) { 450 if (REISERFS_SB(s)) {
451#ifdef CONFIG_REISERFS_FS_XATTR
452 if (REISERFS_SB(s)->xattr_root) { 451 if (REISERFS_SB(s)->xattr_root) {
453 d_invalidate(REISERFS_SB(s)->xattr_root); 452 d_invalidate(REISERFS_SB(s)->xattr_root);
454 dput(REISERFS_SB(s)->xattr_root); 453 dput(REISERFS_SB(s)->xattr_root);
455 REISERFS_SB(s)->xattr_root = NULL; 454 REISERFS_SB(s)->xattr_root = NULL;
456 } 455 }
457#endif
458 if (REISERFS_SB(s)->priv_root) { 456 if (REISERFS_SB(s)->priv_root) {
459 d_invalidate(REISERFS_SB(s)->priv_root); 457 d_invalidate(REISERFS_SB(s)->priv_root);
460 dput(REISERFS_SB(s)->priv_root); 458 dput(REISERFS_SB(s)->priv_root);
@@ -1316,8 +1314,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1316 } 1314 }
1317 1315
1318out_ok: 1316out_ok:
1319 kfree(s->s_options); 1317 replace_mount_options(s, new_opts);
1320 s->s_options = new_opts;
1321 return 0; 1318 return 0;
1322 1319
1323out_err: 1320out_err:
@@ -1842,7 +1839,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1842 goto error; 1839 goto error;
1843 } 1840 }
1844 1841
1845 if ((errval = reiserfs_xattr_init(s, s->s_flags))) { 1842 if ((errval = reiserfs_lookup_privroot(s)) ||
1843 (errval = reiserfs_xattr_init(s, s->s_flags))) {
1846 dput(s->s_root); 1844 dput(s->s_root);
1847 s->s_root = NULL; 1845 s->s_root = NULL;
1848 goto error; 1846 goto error;
@@ -1855,7 +1853,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1855 reiserfs_info(s, "using 3.5.x disk format\n"); 1853 reiserfs_info(s, "using 3.5.x disk format\n");
1856 } 1854 }
1857 1855
1858 if ((errval = reiserfs_xattr_init(s, s->s_flags))) { 1856 if ((errval = reiserfs_lookup_privroot(s)) ||
1857 (errval = reiserfs_xattr_init(s, s->s_flags))) {
1859 dput(s->s_root); 1858 dput(s->s_root);
1860 s->s_root = NULL; 1859 s->s_root = NULL;
1861 goto error; 1860 goto error;
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index f83f52bae390..8e7deb0e6964 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -113,41 +113,30 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry)
113 113
114#define xattr_may_create(flags) (!flags || flags & XATTR_CREATE) 114#define xattr_may_create(flags) (!flags || flags & XATTR_CREATE)
115 115
116/* Returns and possibly creates the xattr dir. */ 116static struct dentry *open_xa_root(struct super_block *sb, int flags)
117static struct dentry *lookup_or_create_dir(struct dentry *parent,
118 const char *name, int flags)
119{ 117{
120 struct dentry *dentry; 118 struct dentry *privroot = REISERFS_SB(sb)->priv_root;
121 BUG_ON(!parent); 119 struct dentry *xaroot;
122 120 if (!privroot->d_inode)
123 dentry = lookup_one_len(name, parent, strlen(name)); 121 return ERR_PTR(-ENODATA);
124 if (IS_ERR(dentry))
125 return dentry;
126 else if (!dentry->d_inode) {
127 int err = -ENODATA;
128 122
129 if (xattr_may_create(flags)) { 123 mutex_lock_nested(&privroot->d_inode->i_mutex, I_MUTEX_XATTR);
130 mutex_lock_nested(&parent->d_inode->i_mutex,
131 I_MUTEX_XATTR);
132 err = xattr_mkdir(parent->d_inode, dentry, 0700);
133 mutex_unlock(&parent->d_inode->i_mutex);
134 }
135 124
125 xaroot = dget(REISERFS_SB(sb)->xattr_root);
126 if (!xaroot)
127 xaroot = ERR_PTR(-ENODATA);
128 else if (!xaroot->d_inode) {
129 int err = -ENODATA;
130 if (xattr_may_create(flags))
131 err = xattr_mkdir(privroot->d_inode, xaroot, 0700);
136 if (err) { 132 if (err) {
137 dput(dentry); 133 dput(xaroot);
138 dentry = ERR_PTR(err); 134 xaroot = ERR_PTR(err);
139 } 135 }
140 } 136 }
141 137
142 return dentry; 138 mutex_unlock(&privroot->d_inode->i_mutex);
143} 139 return xaroot;
144
145static struct dentry *open_xa_root(struct super_block *sb, int flags)
146{
147 struct dentry *privroot = REISERFS_SB(sb)->priv_root;
148 if (!privroot)
149 return ERR_PTR(-ENODATA);
150 return lookup_or_create_dir(privroot, XAROOT_NAME, flags);
151} 140}
152 141
153static struct dentry *open_xa_dir(const struct inode *inode, int flags) 142static struct dentry *open_xa_dir(const struct inode *inode, int flags)
@@ -163,10 +152,22 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags)
163 le32_to_cpu(INODE_PKEY(inode)->k_objectid), 152 le32_to_cpu(INODE_PKEY(inode)->k_objectid),
164 inode->i_generation); 153 inode->i_generation);
165 154
166 xadir = lookup_or_create_dir(xaroot, namebuf, flags); 155 mutex_lock_nested(&xaroot->d_inode->i_mutex, I_MUTEX_XATTR);
156
157 xadir = lookup_one_len(namebuf, xaroot, strlen(namebuf));
158 if (!IS_ERR(xadir) && !xadir->d_inode) {
159 int err = -ENODATA;
160 if (xattr_may_create(flags))
161 err = xattr_mkdir(xaroot->d_inode, xadir, 0700);
162 if (err) {
163 dput(xadir);
164 xadir = ERR_PTR(err);
165 }
166 }
167
168 mutex_unlock(&xaroot->d_inode->i_mutex);
167 dput(xaroot); 169 dput(xaroot);
168 return xadir; 170 return xadir;
169
170} 171}
171 172
172/* The following are side effects of other operations that aren't explicitly 173/* The following are side effects of other operations that aren't explicitly
@@ -184,6 +185,7 @@ fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
184{ 185{
185 struct reiserfs_dentry_buf *dbuf = buf; 186 struct reiserfs_dentry_buf *dbuf = buf;
186 struct dentry *dentry; 187 struct dentry *dentry;
188 WARN_ON_ONCE(!mutex_is_locked(&dbuf->xadir->d_inode->i_mutex));
187 189
188 if (dbuf->count == ARRAY_SIZE(dbuf->dentries)) 190 if (dbuf->count == ARRAY_SIZE(dbuf->dentries))
189 return -ENOSPC; 191 return -ENOSPC;
@@ -349,6 +351,7 @@ static struct dentry *xattr_lookup(struct inode *inode, const char *name,
349 if (IS_ERR(xadir)) 351 if (IS_ERR(xadir))
350 return ERR_CAST(xadir); 352 return ERR_CAST(xadir);
351 353
354 mutex_lock_nested(&xadir->d_inode->i_mutex, I_MUTEX_XATTR);
352 xafile = lookup_one_len(name, xadir, strlen(name)); 355 xafile = lookup_one_len(name, xadir, strlen(name));
353 if (IS_ERR(xafile)) { 356 if (IS_ERR(xafile)) {
354 err = PTR_ERR(xafile); 357 err = PTR_ERR(xafile);
@@ -360,18 +363,15 @@ static struct dentry *xattr_lookup(struct inode *inode, const char *name,
360 363
361 if (!xafile->d_inode) { 364 if (!xafile->d_inode) {
362 err = -ENODATA; 365 err = -ENODATA;
363 if (xattr_may_create(flags)) { 366 if (xattr_may_create(flags))
364 mutex_lock_nested(&xadir->d_inode->i_mutex,
365 I_MUTEX_XATTR);
366 err = xattr_create(xadir->d_inode, xafile, 367 err = xattr_create(xadir->d_inode, xafile,
367 0700|S_IFREG); 368 0700|S_IFREG);
368 mutex_unlock(&xadir->d_inode->i_mutex);
369 }
370 } 369 }
371 370
372 if (err) 371 if (err)
373 dput(xafile); 372 dput(xafile);
374out: 373out:
374 mutex_unlock(&xadir->d_inode->i_mutex);
375 dput(xadir); 375 dput(xadir);
376 if (err) 376 if (err)
377 return ERR_PTR(err); 377 return ERR_PTR(err);
@@ -435,6 +435,7 @@ static int lookup_and_delete_xattr(struct inode *inode, const char *name)
435 if (IS_ERR(xadir)) 435 if (IS_ERR(xadir))
436 return PTR_ERR(xadir); 436 return PTR_ERR(xadir);
437 437
438 mutex_lock_nested(&xadir->d_inode->i_mutex, I_MUTEX_XATTR);
438 dentry = lookup_one_len(name, xadir, strlen(name)); 439 dentry = lookup_one_len(name, xadir, strlen(name));
439 if (IS_ERR(dentry)) { 440 if (IS_ERR(dentry)) {
440 err = PTR_ERR(dentry); 441 err = PTR_ERR(dentry);
@@ -442,14 +443,13 @@ static int lookup_and_delete_xattr(struct inode *inode, const char *name)
442 } 443 }
443 444
444 if (dentry->d_inode) { 445 if (dentry->d_inode) {
445 mutex_lock_nested(&xadir->d_inode->i_mutex, I_MUTEX_XATTR);
446 err = xattr_unlink(xadir->d_inode, dentry); 446 err = xattr_unlink(xadir->d_inode, dentry);
447 mutex_unlock(&xadir->d_inode->i_mutex);
448 update_ctime(inode); 447 update_ctime(inode);
449 } 448 }
450 449
451 dput(dentry); 450 dput(dentry);
452out_dput: 451out_dput:
452 mutex_unlock(&xadir->d_inode->i_mutex);
453 dput(xadir); 453 dput(xadir);
454 return err; 454 return err;
455} 455}
@@ -687,20 +687,6 @@ out:
687 return err; 687 return err;
688} 688}
689 689
690/* Actual operations that are exported to VFS-land */
691struct xattr_handler *reiserfs_xattr_handlers[] = {
692 &reiserfs_xattr_user_handler,
693 &reiserfs_xattr_trusted_handler,
694#ifdef CONFIG_REISERFS_FS_SECURITY
695 &reiserfs_xattr_security_handler,
696#endif
697#ifdef CONFIG_REISERFS_FS_POSIX_ACL
698 &reiserfs_posix_acl_access_handler,
699 &reiserfs_posix_acl_default_handler,
700#endif
701 NULL
702};
703
704/* 690/*
705 * In order to implement different sets of xattr operations for each xattr 691 * In order to implement different sets of xattr operations for each xattr
706 * prefix with the generic xattr API, a filesystem should create a 692 * prefix with the generic xattr API, a filesystem should create a
@@ -843,7 +829,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
843 if (!dentry->d_inode) 829 if (!dentry->d_inode)
844 return -EINVAL; 830 return -EINVAL;
845 831
846 if (!reiserfs_xattrs(dentry->d_sb) || 832 if (!dentry->d_sb->s_xattr ||
847 get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) 833 get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
848 return -EOPNOTSUPP; 834 return -EOPNOTSUPP;
849 835
@@ -885,42 +871,50 @@ static int reiserfs_check_acl(struct inode *inode, int mask)
885 return error; 871 return error;
886} 872}
887 873
888int reiserfs_permission(struct inode *inode, int mask)
889{
890 /*
891 * We don't do permission checks on the internal objects.
892 * Permissions are determined by the "owning" object.
893 */
894 if (IS_PRIVATE(inode))
895 return 0;
896 /*
897 * Stat data v1 doesn't support ACLs.
898 */
899 if (get_inode_sd_version(inode) == STAT_DATA_V1)
900 return generic_permission(inode, mask, NULL);
901 else
902 return generic_permission(inode, mask, reiserfs_check_acl);
903}
904
905static int create_privroot(struct dentry *dentry) 874static int create_privroot(struct dentry *dentry)
906{ 875{
907 int err; 876 int err;
908 struct inode *inode = dentry->d_parent->d_inode; 877 struct inode *inode = dentry->d_parent->d_inode;
909 mutex_lock_nested(&inode->i_mutex, I_MUTEX_XATTR); 878 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
879
910 err = xattr_mkdir(inode, dentry, 0700); 880 err = xattr_mkdir(inode, dentry, 0700);
911 mutex_unlock(&inode->i_mutex); 881 if (err || !dentry->d_inode) {
912 if (err) { 882 reiserfs_warning(dentry->d_sb, "jdm-20006",
913 dput(dentry); 883 "xattrs/ACLs enabled and couldn't "
914 dentry = NULL; 884 "find/create .reiserfs_priv. "
885 "Failing mount.");
886 return -EOPNOTSUPP;
915 } 887 }
916 888
917 if (dentry && dentry->d_inode) 889 dentry->d_inode->i_flags |= S_PRIVATE;
918 reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr " 890 reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
919 "storage.\n", PRIVROOT_NAME); 891 "storage.\n", PRIVROOT_NAME);
920 892
921 return err; 893 return 0;
922} 894}
923 895
896#else
897int __init reiserfs_xattr_register_handlers(void) { return 0; }
898void reiserfs_xattr_unregister_handlers(void) {}
899static int create_privroot(struct dentry *dentry) { return 0; }
900#endif
901
902/* Actual operations that are exported to VFS-land */
903struct xattr_handler *reiserfs_xattr_handlers[] = {
904#ifdef CONFIG_REISERFS_FS_XATTR
905 &reiserfs_xattr_user_handler,
906 &reiserfs_xattr_trusted_handler,
907#endif
908#ifdef CONFIG_REISERFS_FS_SECURITY
909 &reiserfs_xattr_security_handler,
910#endif
911#ifdef CONFIG_REISERFS_FS_POSIX_ACL
912 &reiserfs_posix_acl_access_handler,
913 &reiserfs_posix_acl_default_handler,
914#endif
915 NULL
916};
917
924static int xattr_mount_check(struct super_block *s) 918static int xattr_mount_check(struct super_block *s)
925{ 919{
926 /* We need generation numbers to ensure that the oid mapping is correct 920 /* We need generation numbers to ensure that the oid mapping is correct
@@ -940,21 +934,33 @@ static int xattr_mount_check(struct super_block *s)
940 return 0; 934 return 0;
941} 935}
942 936
943#else 937int reiserfs_permission(struct inode *inode, int mask)
944int __init reiserfs_xattr_register_handlers(void) { return 0; } 938{
945void reiserfs_xattr_unregister_handlers(void) {} 939 /*
940 * We don't do permission checks on the internal objects.
941 * Permissions are determined by the "owning" object.
942 */
943 if (IS_PRIVATE(inode))
944 return 0;
945
946#ifdef CONFIG_REISERFS_FS_XATTR
947 /*
948 * Stat data v1 doesn't support ACLs.
949 */
950 if (get_inode_sd_version(inode) != STAT_DATA_V1)
951 return generic_permission(inode, mask, reiserfs_check_acl);
946#endif 952#endif
953 return generic_permission(inode, mask, NULL);
954}
947 955
948/* This will catch lookups from the fs root to .reiserfs_priv */ 956/* This will catch lookups from the fs root to .reiserfs_priv */
949static int 957static int
950xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name) 958xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name)
951{ 959{
952 struct dentry *priv_root = REISERFS_SB(dentry->d_sb)->priv_root; 960 struct dentry *priv_root = REISERFS_SB(dentry->d_sb)->priv_root;
953 if (name->len == priv_root->d_name.len && 961 if (container_of(q1, struct dentry, d_name) == priv_root)
954 name->hash == priv_root->d_name.hash &&
955 !memcmp(name->name, priv_root->d_name.name, name->len)) {
956 return -ENOENT; 962 return -ENOENT;
957 } else if (q1->len == name->len && 963 if (q1->len == name->len &&
958 !memcmp(q1->name, name->name, name->len)) 964 !memcmp(q1->name, name->name, name->len))
959 return 0; 965 return 0;
960 return 1; 966 return 1;
@@ -964,73 +970,71 @@ static const struct dentry_operations xattr_lookup_poison_ops = {
964 .d_compare = xattr_lookup_poison, 970 .d_compare = xattr_lookup_poison,
965}; 971};
966 972
973int reiserfs_lookup_privroot(struct super_block *s)
974{
975 struct dentry *dentry;
976 int err = 0;
977
978 /* If we don't have the privroot located yet - go find it */
979 mutex_lock(&s->s_root->d_inode->i_mutex);
980 dentry = lookup_one_len(PRIVROOT_NAME, s->s_root,
981 strlen(PRIVROOT_NAME));
982 if (!IS_ERR(dentry)) {
983 REISERFS_SB(s)->priv_root = dentry;
984 s->s_root->d_op = &xattr_lookup_poison_ops;
985 if (dentry->d_inode)
986 dentry->d_inode->i_flags |= S_PRIVATE;
987 } else
988 err = PTR_ERR(dentry);
989 mutex_unlock(&s->s_root->d_inode->i_mutex);
990
991 return err;
992}
993
967/* We need to take a copy of the mount flags since things like 994/* We need to take a copy of the mount flags since things like
968 * MS_RDONLY don't get set until *after* we're called. 995 * MS_RDONLY don't get set until *after* we're called.
969 * mount_flags != mount_options */ 996 * mount_flags != mount_options */
970int reiserfs_xattr_init(struct super_block *s, int mount_flags) 997int reiserfs_xattr_init(struct super_block *s, int mount_flags)
971{ 998{
972 int err = 0; 999 int err = 0;
1000 struct dentry *privroot = REISERFS_SB(s)->priv_root;
973 1001
974#ifdef CONFIG_REISERFS_FS_XATTR
975 err = xattr_mount_check(s); 1002 err = xattr_mount_check(s);
976 if (err) 1003 if (err)
977 goto error; 1004 goto error;
978#endif
979 1005
980 /* If we don't have the privroot located yet - go find it */ 1006 if (!privroot->d_inode && !(mount_flags & MS_RDONLY)) {
981 if (!REISERFS_SB(s)->priv_root) { 1007 mutex_lock(&s->s_root->d_inode->i_mutex);
982 struct dentry *dentry; 1008 err = create_privroot(REISERFS_SB(s)->priv_root);
983 dentry = lookup_one_len(PRIVROOT_NAME, s->s_root, 1009 mutex_unlock(&s->s_root->d_inode->i_mutex);
984 strlen(PRIVROOT_NAME));
985 if (!IS_ERR(dentry)) {
986#ifdef CONFIG_REISERFS_FS_XATTR
987 if (!(mount_flags & MS_RDONLY) && !dentry->d_inode)
988 err = create_privroot(dentry);
989#endif
990 if (!dentry->d_inode) {
991 dput(dentry);
992 dentry = NULL;
993 }
994 } else
995 err = PTR_ERR(dentry);
996
997 if (!err && dentry) {
998 s->s_root->d_op = &xattr_lookup_poison_ops;
999 dentry->d_inode->i_flags |= S_PRIVATE;
1000 REISERFS_SB(s)->priv_root = dentry;
1001#ifdef CONFIG_REISERFS_FS_XATTR
1002 /* xattrs are unavailable */
1003 } else if (!(mount_flags & MS_RDONLY)) {
1004 /* If we're read-only it just means that the dir
1005 * hasn't been created. Not an error -- just no
1006 * xattrs on the fs. We'll check again if we
1007 * go read-write */
1008 reiserfs_warning(s, "jdm-20006",
1009 "xattrs/ACLs enabled and couldn't "
1010 "find/create .reiserfs_priv. "
1011 "Failing mount.");
1012 err = -EOPNOTSUPP;
1013#endif
1014 }
1015 } 1010 }
1016 1011
1017#ifdef CONFIG_REISERFS_FS_XATTR 1012 if (privroot->d_inode) {
1018 if (!err)
1019 s->s_xattr = reiserfs_xattr_handlers; 1013 s->s_xattr = reiserfs_xattr_handlers;
1014 mutex_lock(&privroot->d_inode->i_mutex);
1015 if (!REISERFS_SB(s)->xattr_root) {
1016 struct dentry *dentry;
1017 dentry = lookup_one_len(XAROOT_NAME, privroot,
1018 strlen(XAROOT_NAME));
1019 if (!IS_ERR(dentry))
1020 REISERFS_SB(s)->xattr_root = dentry;
1021 else
1022 err = PTR_ERR(dentry);
1023 }
1024 mutex_unlock(&privroot->d_inode->i_mutex);
1025 }
1020 1026
1021error: 1027error:
1022 if (err) { 1028 if (err) {
1023 clear_bit(REISERFS_XATTRS_USER, &(REISERFS_SB(s)->s_mount_opt)); 1029 clear_bit(REISERFS_XATTRS_USER, &(REISERFS_SB(s)->s_mount_opt));
1024 clear_bit(REISERFS_POSIXACL, &(REISERFS_SB(s)->s_mount_opt)); 1030 clear_bit(REISERFS_POSIXACL, &(REISERFS_SB(s)->s_mount_opt));
1025 } 1031 }
1026#endif
1027 1032
1028 /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */ 1033 /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */
1029 s->s_flags = s->s_flags & ~MS_POSIXACL;
1030#ifdef CONFIG_REISERFS_FS_POSIX_ACL
1031 if (reiserfs_posixacl(s)) 1034 if (reiserfs_posixacl(s))
1032 s->s_flags |= MS_POSIXACL; 1035 s->s_flags |= MS_POSIXACL;
1033#endif 1036 else
1037 s->s_flags &= ~MS_POSIXACL;
1034 1038
1035 return err; 1039 return err;
1036} 1040}
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c
index 4d3c20e787c3..a92c8792c0f6 100644
--- a/fs/reiserfs/xattr_security.c
+++ b/fs/reiserfs/xattr_security.c
@@ -55,8 +55,16 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode,
55 struct reiserfs_security_handle *sec) 55 struct reiserfs_security_handle *sec)
56{ 56{
57 int blocks = 0; 57 int blocks = 0;
58 int error = security_inode_init_security(inode, dir, &sec->name, 58 int error;
59 &sec->value, &sec->length); 59
60 sec->name = NULL;
61
62 /* Don't add selinux attributes on xattrs - they'll never get used */
63 if (IS_PRIVATE(dir))
64 return 0;
65
66 error = security_inode_init_security(inode, dir, &sec->name,
67 &sec->value, &sec->length);
60 if (error) { 68 if (error) {
61 if (error == -EOPNOTSUPP) 69 if (error == -EOPNOTSUPP)
62 error = 0; 70 error = 0;
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index c53b5ef8a02f..4ab3c03d8f95 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -298,7 +298,8 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)
298 struct romfs_inode ri; 298 struct romfs_inode ri;
299 struct inode *i; 299 struct inode *i;
300 unsigned long nlen; 300 unsigned long nlen;
301 unsigned nextfh, ret; 301 unsigned nextfh;
302 int ret;
302 umode_t mode; 303 umode_t mode;
303 304
304 /* we might have to traverse a chain of "hard link" file entries to get 305 /* we might have to traverse a chain of "hard link" file entries to get
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index 8258cf9a0317..70e3244fa30f 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -5,4 +5,3 @@
5obj-$(CONFIG_SQUASHFS) += squashfs.o 5obj-$(CONFIG_SQUASHFS) += squashfs.o
6squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o 6squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
7squashfs-y += namei.o super.o symlink.o 7squashfs-y += namei.o super.o symlink.o
8#squashfs-y += squashfs2_0.o
diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c
index 1c4739e33af6..40c98fa6b5d6 100644
--- a/fs/squashfs/cache.c
+++ b/fs/squashfs/cache.c
@@ -252,6 +252,7 @@ struct squashfs_cache *squashfs_cache_init(char *name, int entries,
252 cache->entries = entries; 252 cache->entries = entries;
253 cache->block_size = block_size; 253 cache->block_size = block_size;
254 cache->pages = block_size >> PAGE_CACHE_SHIFT; 254 cache->pages = block_size >> PAGE_CACHE_SHIFT;
255 cache->pages = cache->pages ? cache->pages : 1;
255 cache->name = name; 256 cache->name = name;
256 cache->num_waiters = 0; 257 cache->num_waiters = 0;
257 spin_lock_init(&cache->lock); 258 spin_lock_init(&cache->lock);
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index ffa6edcd2d0c..0adc624c956f 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -157,6 +157,16 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
157 if (msblk->block_size > SQUASHFS_FILE_MAX_SIZE) 157 if (msblk->block_size > SQUASHFS_FILE_MAX_SIZE)
158 goto failed_mount; 158 goto failed_mount;
159 159
160 /*
161 * Check the system page size is not larger than the filesystem
162 * block size (by default 128K). This is currently not supported.
163 */
164 if (PAGE_CACHE_SIZE > msblk->block_size) {
165 ERROR("Page size > filesystem block size (%d). This is "
166 "currently not supported!\n", msblk->block_size);
167 goto failed_mount;
168 }
169
160 msblk->block_log = le16_to_cpu(sblk->block_log); 170 msblk->block_log = le16_to_cpu(sblk->block_log);
161 if (msblk->block_log > SQUASHFS_FILE_MAX_LOG) 171 if (msblk->block_log > SQUASHFS_FILE_MAX_LOG)
162 goto failed_mount; 172 goto failed_mount;
diff --git a/fs/super.c b/fs/super.c
index 786fe7d72790..1943fdf655fa 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -208,6 +208,34 @@ void deactivate_super(struct super_block *s)
208EXPORT_SYMBOL(deactivate_super); 208EXPORT_SYMBOL(deactivate_super);
209 209
210/** 210/**
211 * deactivate_locked_super - drop an active reference to superblock
212 * @s: superblock to deactivate
213 *
214 * Equivalent of up_write(&s->s_umount); deactivate_super(s);, except that
215 * it does not unlock it until it's all over. As the result, it's safe to
216 * use to dispose of new superblock on ->get_sb() failure exits - nobody
217 * will see the sucker until it's all over. Equivalent using up_write +
218 * deactivate_super is safe for that purpose only if superblock is either
219 * safe to use or has NULL ->s_root when we unlock.
220 */
221void deactivate_locked_super(struct super_block *s)
222{
223 struct file_system_type *fs = s->s_type;
224 if (atomic_dec_and_lock(&s->s_active, &sb_lock)) {
225 s->s_count -= S_BIAS-1;
226 spin_unlock(&sb_lock);
227 vfs_dq_off(s, 0);
228 fs->kill_sb(s);
229 put_filesystem(fs);
230 put_super(s);
231 } else {
232 up_write(&s->s_umount);
233 }
234}
235
236EXPORT_SYMBOL(deactivate_locked_super);
237
238/**
211 * grab_super - acquire an active reference 239 * grab_super - acquire an active reference
212 * @s: reference we are trying to make active 240 * @s: reference we are trying to make active
213 * 241 *
@@ -797,8 +825,7 @@ int get_sb_ns(struct file_system_type *fs_type, int flags, void *data,
797 sb->s_flags = flags; 825 sb->s_flags = flags;
798 err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 826 err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
799 if (err) { 827 if (err) {
800 up_write(&sb->s_umount); 828 deactivate_locked_super(sb);
801 deactivate_super(sb);
802 return err; 829 return err;
803 } 830 }
804 831
@@ -854,8 +881,7 @@ int get_sb_bdev(struct file_system_type *fs_type,
854 881
855 if (s->s_root) { 882 if (s->s_root) {
856 if ((flags ^ s->s_flags) & MS_RDONLY) { 883 if ((flags ^ s->s_flags) & MS_RDONLY) {
857 up_write(&s->s_umount); 884 deactivate_locked_super(s);
858 deactivate_super(s);
859 error = -EBUSY; 885 error = -EBUSY;
860 goto error_bdev; 886 goto error_bdev;
861 } 887 }
@@ -870,8 +896,7 @@ int get_sb_bdev(struct file_system_type *fs_type,
870 sb_set_blocksize(s, block_size(bdev)); 896 sb_set_blocksize(s, block_size(bdev));
871 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 897 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
872 if (error) { 898 if (error) {
873 up_write(&s->s_umount); 899 deactivate_locked_super(s);
874 deactivate_super(s);
875 goto error; 900 goto error;
876 } 901 }
877 902
@@ -897,7 +922,7 @@ void kill_block_super(struct super_block *sb)
897 struct block_device *bdev = sb->s_bdev; 922 struct block_device *bdev = sb->s_bdev;
898 fmode_t mode = sb->s_mode; 923 fmode_t mode = sb->s_mode;
899 924
900 bdev->bd_super = 0; 925 bdev->bd_super = NULL;
901 generic_shutdown_super(sb); 926 generic_shutdown_super(sb);
902 sync_blockdev(bdev); 927 sync_blockdev(bdev);
903 close_bdev_exclusive(bdev, mode); 928 close_bdev_exclusive(bdev, mode);
@@ -921,8 +946,7 @@ int get_sb_nodev(struct file_system_type *fs_type,
921 946
922 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 947 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
923 if (error) { 948 if (error) {
924 up_write(&s->s_umount); 949 deactivate_locked_super(s);
925 deactivate_super(s);
926 return error; 950 return error;
927 } 951 }
928 s->s_flags |= MS_ACTIVE; 952 s->s_flags |= MS_ACTIVE;
@@ -952,8 +976,7 @@ int get_sb_single(struct file_system_type *fs_type,
952 s->s_flags = flags; 976 s->s_flags = flags;
953 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 977 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
954 if (error) { 978 if (error) {
955 up_write(&s->s_umount); 979 deactivate_locked_super(s);
956 deactivate_super(s);
957 return error; 980 return error;
958 } 981 }
959 s->s_flags |= MS_ACTIVE; 982 s->s_flags |= MS_ACTIVE;
@@ -1006,8 +1029,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
1006 return mnt; 1029 return mnt;
1007out_sb: 1030out_sb:
1008 dput(mnt->mnt_root); 1031 dput(mnt->mnt_root);
1009 up_write(&mnt->mnt_sb->s_umount); 1032 deactivate_locked_super(mnt->mnt_sb);
1010 deactivate_super(mnt->mnt_sb);
1011out_free_secdata: 1033out_free_secdata:
1012 free_secdata(secdata); 1034 free_secdata(secdata);
1013out_mnt: 1035out_mnt:
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index b1606e07b7a3..561a9c050cef 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -723,7 +723,7 @@ int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
723 mutex_unlock(&sysfs_workq_mutex); 723 mutex_unlock(&sysfs_workq_mutex);
724 724
725 if (sysfs_workqueue == NULL) { 725 if (sysfs_workqueue == NULL) {
726 sysfs_workqueue = create_workqueue("sysfsd"); 726 sysfs_workqueue = create_singlethread_workqueue("sysfsd");
727 if (sysfs_workqueue == NULL) { 727 if (sysfs_workqueue == NULL) {
728 module_put(owner); 728 module_put(owner);
729 return -ENOMEM; 729 return -ENOMEM;
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index faa44f90608a..e9f7a754c4f7 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -2055,8 +2055,7 @@ static int ubifs_get_sb(struct file_system_type *fs_type, int flags,
2055 return 0; 2055 return 0;
2056 2056
2057out_deact: 2057out_deact:
2058 up_write(&sb->s_umount); 2058 deactivate_locked_super(sb);
2059 deactivate_super(sb);
2060out_close: 2059out_close:
2061 ubi_close_volume(ubi); 2060 ubi_close_volume(ubi);
2062 return err; 2061 return err;
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index dbbbc4668769..6321b797061b 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -666,6 +666,6 @@ not_empty:
666const struct file_operations ufs_dir_operations = { 666const struct file_operations ufs_dir_operations = {
667 .read = generic_read_dir, 667 .read = generic_read_dir,
668 .readdir = ufs_readdir, 668 .readdir = ufs_readdir,
669 .fsync = file_fsync, 669 .fsync = ufs_sync_file,
670 .llseek = generic_file_llseek, 670 .llseek = generic_file_llseek,
671}; 671};
diff --git a/fs/ufs/file.c b/fs/ufs/file.c
index 625ef17c6f83..2bd3a1615714 100644
--- a/fs/ufs/file.c
+++ b/fs/ufs/file.c
@@ -30,7 +30,7 @@
30#include "ufs.h" 30#include "ufs.h"
31 31
32 32
33static int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync) 33int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync)
34{ 34{
35 struct inode *inode = dentry->d_inode; 35 struct inode *inode = dentry->d_inode;
36 int err; 36 int err;
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 69b3427d7885..d0c4acd4f1f3 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -98,8 +98,8 @@ extern void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
98/* file.c */ 98/* file.c */
99extern const struct inode_operations ufs_file_inode_operations; 99extern const struct inode_operations ufs_file_inode_operations;
100extern const struct file_operations ufs_file_operations; 100extern const struct file_operations ufs_file_operations;
101
102extern const struct address_space_operations ufs_aops; 101extern const struct address_space_operations ufs_aops;
102extern int ufs_sync_file(struct file *, struct dentry *, int);
103 103
104/* ialloc.c */ 104/* ialloc.c */
105extern void ufs_free_inode (struct inode *inode); 105extern void ufs_free_inode (struct inode *inode);