aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-05-31 00:57:05 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-05-31 00:57:05 -0400
commit5bc65793cbf8da0d35f19ef025dda22887e79e80 (patch)
tree8291998abd73055de6f487fafa174ee2a5d3afee /fs
parent6edae708bf77e012d855a7e2c7766f211d234f4f (diff)
parent3f0a6766e0cc5a577805732e5adb50a585c58175 (diff)
[SCSI] Merge up to linux-2.6 head
Conflicts: drivers/scsi/jazz_esp.c Same changes made by both SCSI and SPARC trees: problem with UTF-8 conversion in the copyright. Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/vfs_addr.c1
-rw-r--r--fs/9p/vfs_dentry.c1
-rw-r--r--fs/9p/vfs_inode.c1
-rw-r--r--fs/9p/vfs_super.c1
-rw-r--r--fs/Kconfig.binfmt2
-rw-r--r--fs/adfs/super.c3
-rw-r--r--fs/affs/inode.c2
-rw-r--r--fs/affs/super.c9
-rw-r--r--fs/afs/callback.c1
-rw-r--r--fs/afs/cell.c1
-rw-r--r--fs/afs/dir.c1
-rw-r--r--fs/afs/inode.c1
-rw-r--r--fs/afs/internal.h1
-rw-r--r--fs/afs/main.c1
-rw-r--r--fs/afs/proc.c1
-rw-r--r--fs/afs/security.c1
-rw-r--r--fs/afs/super.c22
-rw-r--r--fs/afs/vlocation.c1
-rw-r--r--fs/afs/vnode.c1
-rw-r--r--fs/afs/volume.c1
-rw-r--r--fs/afs/write.c3
-rw-r--r--fs/befs/linuxvfs.c6
-rw-r--r--fs/bfs/inode.c3
-rw-r--r--fs/binfmt_misc.c2
-rw-r--r--fs/block_dev.c16
-rw-r--r--fs/buffer.c27
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/coda/cache.c1
-rw-r--r--fs/coda/inode.c3
-rw-r--r--fs/coda/upcall.c2
-rw-r--r--fs/compat.c30
-rw-r--r--fs/compat_ioctl.c33
-rw-r--r--fs/configfs/inode.c1
-rw-r--r--fs/dquot.c2
-rw-r--r--fs/ecryptfs/file.c59
-rw-r--r--fs/ecryptfs/main.c3
-rw-r--r--fs/ecryptfs/messaging.c2
-rw-r--r--fs/ecryptfs/mmap.c52
-rw-r--r--fs/efs/super.c3
-rw-r--r--fs/eventfd.c26
-rw-r--r--fs/exec.c7
-rw-r--r--fs/ext2/super.c8
-rw-r--r--fs/ext3/super.c10
-rw-r--r--fs/ext4/super.c10
-rw-r--r--fs/fat/cache.c3
-rw-r--r--fs/fat/inode.c14
-rw-r--r--fs/fifo.c1
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/fuse/file.c5
-rw-r--r--fs/fuse/inode.c5
-rw-r--r--fs/gfs2/glock.h1
-rw-r--r--fs/gfs2/main.c34
-rw-r--r--fs/hfs/inode.c1
-rw-r--r--fs/hfs/super.c3
-rw-r--r--fs/hfsplus/inode.c1
-rw-r--r--fs/hfsplus/super.c3
-rw-r--r--fs/hpfs/buffer.c2
-rw-r--r--fs/hpfs/namei.c2
-rw-r--r--fs/hpfs/super.c9
-rw-r--r--fs/hugetlbfs/inode.c3
-rw-r--r--fs/inode.c3
-rw-r--r--fs/isofs/inode.c3
-rw-r--r--fs/jffs2/super.c6
-rw-r--r--fs/jfs/jfs_metapage.c18
-rw-r--r--fs/jfs/super.c22
-rw-r--r--fs/lockd/clntlock.c2
-rw-r--r--fs/lockd/host.c2
-rw-r--r--fs/lockd/xdr.c4
-rw-r--r--fs/lockd/xdr4.c6
-rw-r--r--fs/locks.c3
-rw-r--r--fs/minix/bitmap.c1
-rw-r--r--fs/minix/inode.c3
-rw-r--r--fs/ncpfs/file.c1
-rw-r--r--fs/ncpfs/inode.c6
-rw-r--r--fs/ncpfs/ioctl.c1
-rw-r--r--fs/nfs/callback.h4
-rw-r--r--fs/nfs/client.c2
-rw-r--r--fs/nfs/delegation.c2
-rw-r--r--fs/nfs/dir.c5
-rw-r--r--fs/nfs/direct.c65
-rw-r--r--fs/nfs/file.c1
-rw-r--r--fs/nfs/inode.c30
-rw-r--r--fs/nfs/nfs4proc.c4
-rw-r--r--fs/nfs/nfs4state.c2
-rw-r--r--fs/nfs/nfs4xdr.c96
-rw-r--r--fs/nfs/pagelist.c21
-rw-r--r--fs/nfs/read.c10
-rw-r--r--fs/nfs/write.c12
-rw-r--r--fs/nfsd/nfs4callback.c1
-rw-r--r--fs/nfsd/nfs4recover.c2
-rw-r--r--fs/nfsd/nfssvc.c2
-rw-r--r--fs/ntfs/file.c1
-rw-r--r--fs/ntfs/super.c3
-rw-r--r--fs/ocfs2/aops.c11
-rw-r--r--fs/ocfs2/dlm/dlmfs.c8
-rw-r--r--fs/ocfs2/file.c33
-rw-r--r--fs/ocfs2/localalloc.c7
-rw-r--r--fs/ocfs2/super.c38
-rw-r--r--fs/openpromfs/inode.c3
-rw-r--r--fs/partitions/Kconfig12
-rw-r--r--fs/partitions/ldm.c206
-rw-r--r--fs/partitions/ldm.h6
-rw-r--r--fs/proc/inode.c3
-rw-r--r--fs/qnx4/inode.c3
-rw-r--r--fs/quota.c23
-rw-r--r--fs/ramfs/file-nommu.c2
-rw-r--r--fs/ramfs/inode.c2
-rw-r--r--fs/reiserfs/dir.c2
-rw-r--r--fs/reiserfs/super.c10
-rw-r--r--fs/romfs/inode.c7
-rw-r--r--fs/signalfd.c120
-rw-r--r--fs/smbfs/dir.c1
-rw-r--r--fs/smbfs/file.c1
-rw-r--r--fs/smbfs/inode.c4
-rw-r--r--fs/smbfs/request.c1
-rw-r--r--fs/sysfs/inode.c1
-rw-r--r--fs/sysv/inode.c3
-rw-r--r--fs/timerfd.c24
-rw-r--r--fs/udf/file.c1
-rw-r--r--fs/udf/namei.c1
-rw-r--r--fs/udf/super.c6
-rw-r--r--fs/ufs/super.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c26
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c3
124 files changed, 694 insertions, 678 deletions
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 3128aa948a4e..9ac4ffe9ac7d 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -32,6 +32,7 @@
32#include <linux/inet.h> 32#include <linux/inet.h>
33#include <linux/pagemap.h> 33#include <linux/pagemap.h>
34#include <linux/idr.h> 34#include <linux/idr.h>
35#include <linux/sched.h>
35 36
36#include "debug.h" 37#include "debug.h"
37#include "v9fs.h" 38#include "v9fs.h"
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index 775e26e82cbc..d93960429c09 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -33,6 +33,7 @@
33#include <linux/inet.h> 33#include <linux/inet.h>
34#include <linux/namei.h> 34#include <linux/namei.h>
35#include <linux/idr.h> 35#include <linux/idr.h>
36#include <linux/sched.h>
36 37
37#include "debug.h" 38#include "debug.h"
38#include "v9fs.h" 39#include "v9fs.h"
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 7624821729a0..c76cd8fa3f6c 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -33,6 +33,7 @@
33#include <linux/inet.h> 33#include <linux/inet.h>
34#include <linux/namei.h> 34#include <linux/namei.h>
35#include <linux/idr.h> 35#include <linux/idr.h>
36#include <linux/sched.h>
36 37
37#include "debug.h" 38#include "debug.h"
38#include "v9fs.h" 39#include "v9fs.h"
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 8eb9263a67b9..7bdf8b326841 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -36,6 +36,7 @@
36#include <linux/seq_file.h> 36#include <linux/seq_file.h>
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 40
40#include "debug.h" 41#include "debug.h"
41#include "v9fs.h" 42#include "v9fs.h"
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 74c64409ddbc..d4fc6095466d 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -38,7 +38,7 @@ config BINFMT_ELF_FDPIC
38 38
39config BINFMT_FLAT 39config BINFMT_FLAT
40 tristate "Kernel support for flat binaries" 40 tristate "Kernel support for flat binaries"
41 depends on !MMU || SUPERH 41 depends on !MMU
42 help 42 help
43 Support uClinux FLAT format binaries. 43 Support uClinux FLAT format binaries.
44 44
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 30c296508497..de2ed5ca3351 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -232,8 +232,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
232{ 232{
233 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; 233 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo;
234 234
235 if (flags & SLAB_CTOR_CONSTRUCTOR) 235 inode_init_once(&ei->vfs_inode);
236 inode_init_once(&ei->vfs_inode);
237} 236}
238 237
239static int init_inodecache(void) 238static int init_inodecache(void)
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index c5b9d73c084a..4609a6c13fe9 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * (C) 1991 Linus Torvalds - minix filesystem 10 * (C) 1991 Linus Torvalds - minix filesystem
11 */ 11 */
12 12#include <linux/sched.h>
13#include "affs.h" 13#include "affs.h"
14 14
15extern const struct inode_operations affs_symlink_inode_operations; 15extern const struct inode_operations affs_symlink_inode_operations;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index beff7d21e6e2..6d0ebc321530 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -15,6 +15,7 @@
15#include <linux/statfs.h> 15#include <linux/statfs.h>
16#include <linux/parser.h> 16#include <linux/parser.h>
17#include <linux/magic.h> 17#include <linux/magic.h>
18#include <linux/sched.h>
18#include "affs.h" 19#include "affs.h"
19 20
20extern struct timezone sys_tz; 21extern struct timezone sys_tz;
@@ -87,11 +88,9 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
87{ 88{
88 struct affs_inode_info *ei = (struct affs_inode_info *) foo; 89 struct affs_inode_info *ei = (struct affs_inode_info *) foo;
89 90
90 if (flags & SLAB_CTOR_CONSTRUCTOR) { 91 init_MUTEX(&ei->i_link_lock);
91 init_MUTEX(&ei->i_link_lock); 92 init_MUTEX(&ei->i_ext_lock);
92 init_MUTEX(&ei->i_ext_lock); 93 inode_init_once(&ei->vfs_inode);
93 inode_init_once(&ei->vfs_inode);
94 }
95} 94}
96 95
97static int init_inodecache(void) 96static int init_inodecache(void)
diff --git a/fs/afs/callback.c b/fs/afs/callback.c
index f64e40fefc02..bacf518c6fa8 100644
--- a/fs/afs/callback.c
+++ b/fs/afs/callback.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/circ_buf.h> 19#include <linux/circ_buf.h>
20#include <linux/sched.h>
20#include "internal.h" 21#include "internal.h"
21 22
22unsigned afs_vnode_update_timeout = 10; 23unsigned afs_vnode_update_timeout = 10;
diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index 9b1311a1df51..175a567db78c 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/key.h> 14#include <linux/key.h>
15#include <linux/ctype.h> 15#include <linux/ctype.h>
16#include <linux/sched.h>
16#include <keys/rxrpc-type.h> 17#include <keys/rxrpc-type.h>
17#include "internal.h" 18#include "internal.h"
18 19
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 719af4fb15dc..546c59522eb1 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -16,6 +16,7 @@
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/pagemap.h> 17#include <linux/pagemap.h>
18#include <linux/ctype.h> 18#include <linux/ctype.h>
19#include <linux/sched.h>
19#include "internal.h" 20#include "internal.h"
20 21
21static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, 22static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 47f5fed7195d..d196840127c6 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -19,6 +19,7 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/pagemap.h> 21#include <linux/pagemap.h>
22#include <linux/sched.h>
22#include "internal.h" 23#include "internal.h"
23 24
24struct afs_iget_data { 25struct afs_iget_data {
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 4953ba5a6f44..2dac3ad2c44b 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -16,6 +16,7 @@
16#include <linux/skbuff.h> 16#include <linux/skbuff.h>
17#include <linux/rxrpc.h> 17#include <linux/rxrpc.h>
18#include <linux/key.h> 18#include <linux/key.h>
19#include <linux/workqueue.h>
19#include "afs.h" 20#include "afs.h"
20#include "afs_vl.h" 21#include "afs_vl.h"
21 22
diff --git a/fs/afs/main.c b/fs/afs/main.c
index f1f71ff7d5c6..cd21195bbb24 100644
--- a/fs/afs/main.c
+++ b/fs/afs/main.c
@@ -13,6 +13,7 @@
13#include <linux/moduleparam.h> 13#include <linux/moduleparam.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/completion.h> 15#include <linux/completion.h>
16#include <linux/sched.h>
16#include "internal.h" 17#include "internal.h"
17 18
18MODULE_DESCRIPTION("AFS Client File System"); 19MODULE_DESCRIPTION("AFS Client File System");
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index d5601f617cdb..13df512aea9e 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/proc_fs.h> 14#include <linux/proc_fs.h>
15#include <linux/seq_file.h> 15#include <linux/seq_file.h>
16#include <linux/sched.h>
16#include <asm/uaccess.h> 17#include <asm/uaccess.h>
17#include "internal.h" 18#include "internal.h"
18 19
diff --git a/fs/afs/security.c b/fs/afs/security.c
index e0ea88b63ebf..566fe712c682 100644
--- a/fs/afs/security.c
+++ b/fs/afs/security.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/fs.h> 14#include <linux/fs.h>
15#include <linux/ctype.h> 15#include <linux/ctype.h>
16#include <linux/sched.h>
16#include <keys/rxrpc-type.h> 17#include <keys/rxrpc-type.h>
17#include "internal.h" 18#include "internal.h"
18 19
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 579af632c8e8..2e8496ba1205 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -22,6 +22,7 @@
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/parser.h> 23#include <linux/parser.h>
24#include <linux/statfs.h> 24#include <linux/statfs.h>
25#include <linux/sched.h>
25#include "internal.h" 26#include "internal.h"
26 27
27#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ 28#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */
@@ -47,7 +48,6 @@ struct file_system_type afs_fs_type = {
47static const struct super_operations afs_super_ops = { 48static const struct super_operations afs_super_ops = {
48 .statfs = afs_statfs, 49 .statfs = afs_statfs,
49 .alloc_inode = afs_alloc_inode, 50 .alloc_inode = afs_alloc_inode,
50 .drop_inode = generic_delete_inode,
51 .write_inode = afs_write_inode, 51 .write_inode = afs_write_inode,
52 .destroy_inode = afs_destroy_inode, 52 .destroy_inode = afs_destroy_inode,
53 .clear_inode = afs_clear_inode, 53 .clear_inode = afs_clear_inode,
@@ -452,17 +452,15 @@ static void afs_i_init_once(void *_vnode, struct kmem_cache *cachep,
452{ 452{
453 struct afs_vnode *vnode = _vnode; 453 struct afs_vnode *vnode = _vnode;
454 454
455 if (flags & SLAB_CTOR_CONSTRUCTOR) { 455 memset(vnode, 0, sizeof(*vnode));
456 memset(vnode, 0, sizeof(*vnode)); 456 inode_init_once(&vnode->vfs_inode);
457 inode_init_once(&vnode->vfs_inode); 457 init_waitqueue_head(&vnode->update_waitq);
458 init_waitqueue_head(&vnode->update_waitq); 458 mutex_init(&vnode->permits_lock);
459 mutex_init(&vnode->permits_lock); 459 mutex_init(&vnode->validate_lock);
460 mutex_init(&vnode->validate_lock); 460 spin_lock_init(&vnode->writeback_lock);
461 spin_lock_init(&vnode->writeback_lock); 461 spin_lock_init(&vnode->lock);
462 spin_lock_init(&vnode->lock); 462 INIT_LIST_HEAD(&vnode->writebacks);
463 INIT_LIST_HEAD(&vnode->writebacks); 463 INIT_WORK(&vnode->cb_broken_work, afs_broken_callback_work);
464 INIT_WORK(&vnode->cb_broken_work, afs_broken_callback_work);
465 }
466} 464}
467 465
468/* 466/*
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c
index 3370cdb72566..09e3ad0fc7cc 100644
--- a/fs/afs/vlocation.c
+++ b/fs/afs/vlocation.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/sched.h>
15#include "internal.h" 16#include "internal.h"
16 17
17unsigned afs_vlocation_timeout = 10; /* volume location timeout in seconds */ 18unsigned afs_vlocation_timeout = 10; /* volume location timeout in seconds */
diff --git a/fs/afs/vnode.c b/fs/afs/vnode.c
index c36c98ce2c3c..232c55dc245d 100644
--- a/fs/afs/vnode.c
+++ b/fs/afs/vnode.c
@@ -14,6 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/sched.h>
17#include "internal.h" 18#include "internal.h"
18 19
19#if 0 20#if 0
diff --git a/fs/afs/volume.c b/fs/afs/volume.c
index dd160cada45d..8bab0e3437f9 100644
--- a/fs/afs/volume.c
+++ b/fs/afs/volume.c
@@ -15,6 +15,7 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/pagemap.h> 17#include <linux/pagemap.h>
18#include <linux/sched.h>
18#include "internal.h" 19#include "internal.h"
19 20
20static const char *afs_voltypes[] = { "R/W", "R/O", "BAK" }; 21static const char *afs_voltypes[] = { "R/W", "R/O", "BAK" };
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 28f37516c126..a03b92a0fe1d 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -206,7 +206,6 @@ int afs_prepare_write(struct file *file, struct page *page,
206 _leave(" = %d [prep]", ret); 206 _leave(" = %d [prep]", ret);
207 return ret; 207 return ret;
208 } 208 }
209 SetPageUptodate(page);
210 } 209 }
211 210
212try_again: 211try_again:
@@ -311,8 +310,8 @@ int afs_commit_write(struct file *file, struct page *page,
311 spin_unlock(&vnode->writeback_lock); 310 spin_unlock(&vnode->writeback_lock);
312 } 311 }
313 312
313 SetPageUptodate(page);
314 set_page_dirty(page); 314 set_page_dirty(page);
315
316 if (PageDirty(page)) 315 if (PageDirty(page))
317 _debug("dirtied"); 316 _debug("dirtied");
318 317
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index fe96108a788d..a5c5171c2828 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -292,10 +292,8 @@ befs_destroy_inode(struct inode *inode)
292static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags) 292static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
293{ 293{
294 struct befs_inode_info *bi = (struct befs_inode_info *) foo; 294 struct befs_inode_info *bi = (struct befs_inode_info *) foo;
295 295
296 if (flags & SLAB_CTOR_CONSTRUCTOR) { 296 inode_init_once(&bi->vfs_inode);
297 inode_init_once(&bi->vfs_inode);
298 }
299} 297}
300 298
301static void 299static void
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index edc08d89aabc..58c7bd9f5301 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -248,8 +248,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
248{ 248{
249 struct bfs_inode_info *bi = foo; 249 struct bfs_inode_info *bi = foo;
250 250
251 if (flags & SLAB_CTOR_CONSTRUCTOR) 251 inode_init_once(&bi->vfs_inode);
252 inode_init_once(&bi->vfs_inode);
253} 252}
254 253
255static int init_inodecache(void) 254static int init_inodecache(void)
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 72d0b412c376..330fd3fe8546 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -18,7 +18,7 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/init.h> 20#include <linux/init.h>
21 21#include <linux/sched.h>
22#include <linux/binfmts.h> 22#include <linux/binfmts.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/ctype.h> 24#include <linux/ctype.h>
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 742899240872..ea1480a16f51 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -458,17 +458,15 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
458 struct bdev_inode *ei = (struct bdev_inode *) foo; 458 struct bdev_inode *ei = (struct bdev_inode *) foo;
459 struct block_device *bdev = &ei->bdev; 459 struct block_device *bdev = &ei->bdev;
460 460
461 if (flags & SLAB_CTOR_CONSTRUCTOR) { 461 memset(bdev, 0, sizeof(*bdev));
462 memset(bdev, 0, sizeof(*bdev)); 462 mutex_init(&bdev->bd_mutex);
463 mutex_init(&bdev->bd_mutex); 463 sema_init(&bdev->bd_mount_sem, 1);
464 sema_init(&bdev->bd_mount_sem, 1); 464 INIT_LIST_HEAD(&bdev->bd_inodes);
465 INIT_LIST_HEAD(&bdev->bd_inodes); 465 INIT_LIST_HEAD(&bdev->bd_list);
466 INIT_LIST_HEAD(&bdev->bd_list);
467#ifdef CONFIG_SYSFS 466#ifdef CONFIG_SYSFS
468 INIT_LIST_HEAD(&bdev->bd_holder_list); 467 INIT_LIST_HEAD(&bdev->bd_holder_list);
469#endif 468#endif
470 inode_init_once(&ei->vfs_inode); 469 inode_init_once(&ei->vfs_inode);
471 }
472} 470}
473 471
474static inline void __bd_forget(struct inode *inode) 472static inline void __bd_forget(struct inode *inode)
diff --git a/fs/buffer.c b/fs/buffer.c
index aecd057cd0e0..aa68206bd517 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -981,7 +981,8 @@ grow_dev_page(struct block_device *bdev, sector_t block,
981 struct page *page; 981 struct page *page;
982 struct buffer_head *bh; 982 struct buffer_head *bh;
983 983
984 page = find_or_create_page(inode->i_mapping, index, GFP_NOFS); 984 page = find_or_create_page(inode->i_mapping, index,
985 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
985 if (!page) 986 if (!page)
986 return NULL; 987 return NULL;
987 988
@@ -2100,7 +2101,7 @@ int cont_prepare_write(struct page *page, unsigned offset,
2100 PAGE_CACHE_SIZE, get_block); 2101 PAGE_CACHE_SIZE, get_block);
2101 if (status) 2102 if (status)
2102 goto out_unmap; 2103 goto out_unmap;
2103 zero_user_page(page, zerofrom, PAGE_CACHE_SIZE - zerofrom, 2104 zero_user_page(new_page, zerofrom, PAGE_CACHE_SIZE - zerofrom,
2104 KM_USER0); 2105 KM_USER0);
2105 generic_commit_write(NULL, new_page, zerofrom, PAGE_CACHE_SIZE); 2106 generic_commit_write(NULL, new_page, zerofrom, PAGE_CACHE_SIZE);
2106 unlock_page(new_page); 2107 unlock_page(new_page);
@@ -2898,8 +2899,9 @@ static void recalc_bh_state(void)
2898 2899
2899struct buffer_head *alloc_buffer_head(gfp_t gfp_flags) 2900struct buffer_head *alloc_buffer_head(gfp_t gfp_flags)
2900{ 2901{
2901 struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags); 2902 struct buffer_head *ret = kmem_cache_zalloc(bh_cachep, gfp_flags);
2902 if (ret) { 2903 if (ret) {
2904 INIT_LIST_HEAD(&ret->b_assoc_buffers);
2903 get_cpu_var(bh_accounting).nr++; 2905 get_cpu_var(bh_accounting).nr++;
2904 recalc_bh_state(); 2906 recalc_bh_state();
2905 put_cpu_var(bh_accounting); 2907 put_cpu_var(bh_accounting);
@@ -2918,17 +2920,6 @@ void free_buffer_head(struct buffer_head *bh)
2918} 2920}
2919EXPORT_SYMBOL(free_buffer_head); 2921EXPORT_SYMBOL(free_buffer_head);
2920 2922
2921static void
2922init_buffer_head(void *data, struct kmem_cache *cachep, unsigned long flags)
2923{
2924 if (flags & SLAB_CTOR_CONSTRUCTOR) {
2925 struct buffer_head * bh = (struct buffer_head *)data;
2926
2927 memset(bh, 0, sizeof(*bh));
2928 INIT_LIST_HEAD(&bh->b_assoc_buffers);
2929 }
2930}
2931
2932static void buffer_exit_cpu(int cpu) 2923static void buffer_exit_cpu(int cpu)
2933{ 2924{
2934 int i; 2925 int i;
@@ -2955,12 +2946,8 @@ void __init buffer_init(void)
2955{ 2946{
2956 int nrpages; 2947 int nrpages;
2957 2948
2958 bh_cachep = kmem_cache_create("buffer_head", 2949 bh_cachep = KMEM_CACHE(buffer_head,
2959 sizeof(struct buffer_head), 0, 2950 SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD);
2960 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
2961 SLAB_MEM_SPREAD),
2962 init_buffer_head,
2963 NULL);
2964 2951
2965 /* 2952 /*
2966 * Limit the bh occupancy to 10% of ZONE_NORMAL 2953 * Limit the bh occupancy to 10% of ZONE_NORMAL
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 8568e100953c..d38c69b591cf 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -701,10 +701,8 @@ cifs_init_once(void *inode, struct kmem_cache * cachep, unsigned long flags)
701{ 701{
702 struct cifsInodeInfo *cifsi = inode; 702 struct cifsInodeInfo *cifsi = inode;
703 703
704 if (flags & SLAB_CTOR_CONSTRUCTOR) { 704 inode_init_once(&cifsi->vfs_inode);
705 inode_init_once(&cifsi->vfs_inode); 705 INIT_LIST_HEAD(&cifsi->lockList);
706 INIT_LIST_HEAD(&cifsi->lockList);
707 }
708} 706}
709 707
710static int 708static int
diff --git a/fs/coda/cache.c b/fs/coda/cache.c
index 5d0527133266..fcb88fa8d2f2 100644
--- a/fs/coda/cache.c
+++ b/fs/coda/cache.c
@@ -16,6 +16,7 @@
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/sched.h>
19 20
20#include <linux/coda.h> 21#include <linux/coda.h>
21#include <linux/coda_linux.h> 22#include <linux/coda_linux.h>
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 0aaff3651d14..dbff1bd4fb96 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -62,8 +62,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
62{ 62{
63 struct coda_inode_info *ei = (struct coda_inode_info *) foo; 63 struct coda_inode_info *ei = (struct coda_inode_info *) foo;
64 64
65 if (flags & SLAB_CTOR_CONSTRUCTOR) 65 inode_init_once(&ei->vfs_inode);
66 inode_init_once(&ei->vfs_inode);
67} 66}
68 67
69int coda_init_inodecache(void) 68int coda_init_inodecache(void)
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index a5b5e631ba61..5faacdb1a479 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -16,7 +16,7 @@
16 16
17#include <asm/system.h> 17#include <asm/system.h>
18#include <linux/signal.h> 18#include <linux/signal.h>
19 19#include <linux/sched.h>
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
diff --git a/fs/compat.c b/fs/compat.c
index 7b21b0a82596..4db6216e5266 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1544,9 +1544,10 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
1544 compat_ulong_t __user *outp, compat_ulong_t __user *exp, s64 *timeout) 1544 compat_ulong_t __user *outp, compat_ulong_t __user *exp, s64 *timeout)
1545{ 1545{
1546 fd_set_bits fds; 1546 fd_set_bits fds;
1547 char *bits; 1547 void *bits;
1548 int size, max_fds, ret = -EINVAL; 1548 int size, max_fds, ret = -EINVAL;
1549 struct fdtable *fdt; 1549 struct fdtable *fdt;
1550 long stack_fds[SELECT_STACK_ALLOC/sizeof(long)];
1550 1551
1551 if (n < 0) 1552 if (n < 0)
1552 goto out_nofds; 1553 goto out_nofds;
@@ -1564,11 +1565,14 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
1564 * since we used fdset we need to allocate memory in units of 1565 * since we used fdset we need to allocate memory in units of
1565 * long-words. 1566 * long-words.
1566 */ 1567 */
1567 ret = -ENOMEM;
1568 size = FDS_BYTES(n); 1568 size = FDS_BYTES(n);
1569 bits = kmalloc(6 * size, GFP_KERNEL); 1569 bits = stack_fds;
1570 if (!bits) 1570 if (size > sizeof(stack_fds) / 6) {
1571 goto out_nofds; 1571 bits = kmalloc(6 * size, GFP_KERNEL);
1572 ret = -ENOMEM;
1573 if (!bits)
1574 goto out_nofds;
1575 }
1572 fds.in = (unsigned long *) bits; 1576 fds.in = (unsigned long *) bits;
1573 fds.out = (unsigned long *) (bits + size); 1577 fds.out = (unsigned long *) (bits + size);
1574 fds.ex = (unsigned long *) (bits + 2*size); 1578 fds.ex = (unsigned long *) (bits + 2*size);
@@ -1600,7 +1604,8 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
1600 compat_set_fd_set(n, exp, fds.res_ex)) 1604 compat_set_fd_set(n, exp, fds.res_ex))
1601 ret = -EFAULT; 1605 ret = -EFAULT;
1602out: 1606out:
1603 kfree(bits); 1607 if (bits != stack_fds)
1608 kfree(bits);
1604out_nofds: 1609out_nofds:
1605 return ret; 1610 return ret;
1606} 1611}
@@ -2230,21 +2235,16 @@ asmlinkage long compat_sys_signalfd(int ufd,
2230asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags, 2235asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags,
2231 const struct compat_itimerspec __user *utmr) 2236 const struct compat_itimerspec __user *utmr)
2232{ 2237{
2233 long res;
2234 struct itimerspec t; 2238 struct itimerspec t;
2235 struct itimerspec __user *ut; 2239 struct itimerspec __user *ut;
2236 2240
2237 res = -EFAULT;
2238 if (get_compat_itimerspec(&t, utmr)) 2241 if (get_compat_itimerspec(&t, utmr))
2239 goto err_exit; 2242 return -EFAULT;
2240 ut = compat_alloc_user_space(sizeof(*ut)); 2243 ut = compat_alloc_user_space(sizeof(*ut));
2241 if (copy_to_user(ut, &t, sizeof(t)) ) 2244 if (copy_to_user(ut, &t, sizeof(t)))
2242 goto err_exit; 2245 return -EFAULT;
2243 2246
2244 res = sys_timerfd(ufd, clockid, flags, ut); 2247 return sys_timerfd(ufd, clockid, flags, ut);
2245err_exit:
2246 return res;
2247} 2248}
2248 2249
2249#endif /* CONFIG_TIMERFD */ 2250#endif /* CONFIG_TIMERFD */
2250
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 65643def3182..6b44cdc96fac 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1194,6 +1194,7 @@ static int vt_check(struct file *file)
1194{ 1194{
1195 struct tty_struct *tty; 1195 struct tty_struct *tty;
1196 struct inode *inode = file->f_path.dentry->d_inode; 1196 struct inode *inode = file->f_path.dentry->d_inode;
1197 struct vc_data *vc;
1197 1198
1198 if (file->f_op->ioctl != tty_ioctl) 1199 if (file->f_op->ioctl != tty_ioctl)
1199 return -EINVAL; 1200 return -EINVAL;
@@ -1204,12 +1205,16 @@ static int vt_check(struct file *file)
1204 1205
1205 if (tty->driver->ioctl != vt_ioctl) 1206 if (tty->driver->ioctl != vt_ioctl)
1206 return -EINVAL; 1207 return -EINVAL;
1207 1208
1209 vc = (struct vc_data *)tty->driver_data;
1210 if (!vc_cons_allocated(vc->vc_num)) /* impossible? */
1211 return -ENOIOCTLCMD;
1212
1208 /* 1213 /*
1209 * To have permissions to do most of the vt ioctls, we either have 1214 * To have permissions to do most of the vt ioctls, we either have
1210 * to be the owner of the tty, or super-user. 1215 * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
1211 */ 1216 */
1212 if (current->signal->tty == tty || capable(CAP_SYS_ADMIN)) 1217 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG))
1213 return 1; 1218 return 1;
1214 return 0; 1219 return 0;
1215} 1220}
@@ -1310,16 +1315,28 @@ static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
1310 struct unimapdesc32 tmp; 1315 struct unimapdesc32 tmp;
1311 struct unimapdesc32 __user *user_ud = compat_ptr(arg); 1316 struct unimapdesc32 __user *user_ud = compat_ptr(arg);
1312 int perm = vt_check(file); 1317 int perm = vt_check(file);
1313 1318 struct vc_data *vc;
1314 if (perm < 0) return perm; 1319
1320 if (perm < 0)
1321 return perm;
1315 if (copy_from_user(&tmp, user_ud, sizeof tmp)) 1322 if (copy_from_user(&tmp, user_ud, sizeof tmp))
1316 return -EFAULT; 1323 return -EFAULT;
1324 if (tmp.entries)
1325 if (!access_ok(VERIFY_WRITE, compat_ptr(tmp.entries),
1326 tmp.entry_ct*sizeof(struct unipair)))
1327 return -EFAULT;
1328 vc = ((struct tty_struct *)file->private_data)->driver_data;
1317 switch (cmd) { 1329 switch (cmd) {
1318 case PIO_UNIMAP: 1330 case PIO_UNIMAP:
1319 if (!perm) return -EPERM; 1331 if (!perm)
1320 return con_set_unimap(vc_cons[fg_console].d, tmp.entry_ct, compat_ptr(tmp.entries)); 1332 return -EPERM;
1333 return con_set_unimap(vc, tmp.entry_ct,
1334 compat_ptr(tmp.entries));
1321 case GIO_UNIMAP: 1335 case GIO_UNIMAP:
1322 return con_get_unimap(vc_cons[fg_console].d, tmp.entry_ct, &(user_ud->entry_ct), compat_ptr(tmp.entries)); 1336 if (!perm && fg_console != vc->vc_num)
1337 return -EPERM;
1338 return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct),
1339 compat_ptr(tmp.entries));
1323 } 1340 }
1324 return 0; 1341 return 0;
1325} 1342}
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 2ec9beac17cf..ddc003a9d214 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -32,6 +32,7 @@
32#include <linux/namei.h> 32#include <linux/namei.h>
33#include <linux/backing-dev.h> 33#include <linux/backing-dev.h>
34#include <linux/capability.h> 34#include <linux/capability.h>
35#include <linux/sched.h>
35 36
36#include <linux/configfs.h> 37#include <linux/configfs.h>
37#include "configfs_internal.h" 38#include "configfs_internal.h"
diff --git a/fs/dquot.c b/fs/dquot.c
index 3a995841de90..8819d281500c 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1421,7 +1421,7 @@ int vfs_quota_off(struct super_block *sb, int type)
1421 /* If quota was reenabled in the meantime, we have 1421 /* If quota was reenabled in the meantime, we have
1422 * nothing to do */ 1422 * nothing to do */
1423 if (!sb_has_quota_enabled(sb, cnt)) { 1423 if (!sb_has_quota_enabled(sb, cnt)) {
1424 mutex_lock(&toputinode[cnt]->i_mutex); 1424 mutex_lock_nested(&toputinode[cnt]->i_mutex, I_MUTEX_QUOTA);
1425 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | 1425 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
1426 S_NOATIME | S_NOQUOTA); 1426 S_NOATIME | S_NOQUOTA);
1427 truncate_inode_pages(&toputinode[cnt]->i_data, 0); 1427 truncate_inode_pages(&toputinode[cnt]->i_data, 0);
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 9881b5c5de59..59288d817078 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -33,63 +33,6 @@
33#include "ecryptfs_kernel.h" 33#include "ecryptfs_kernel.h"
34 34
35/** 35/**
36 * ecryptfs_llseek
37 * @file: File we are seeking in
38 * @offset: The offset to seek to
39 * @origin: 2 - offset from i_size; 1 - offset from f_pos
40 *
41 * Returns the position we have seeked to, or negative on error
42 */
43static loff_t ecryptfs_llseek(struct file *file, loff_t offset, int origin)
44{
45 loff_t rv;
46 loff_t new_end_pos;
47 int rc;
48 int expanding_file = 0;
49 struct inode *inode = file->f_mapping->host;
50
51 /* If our offset is past the end of our file, we're going to
52 * need to grow it so we have a valid length of 0's */
53 new_end_pos = offset;
54 switch (origin) {
55 case 2:
56 new_end_pos += i_size_read(inode);
57 expanding_file = 1;
58 break;
59 case 1:
60 new_end_pos += file->f_pos;
61 if (new_end_pos > i_size_read(inode)) {
62 ecryptfs_printk(KERN_DEBUG, "new_end_pos(=[0x%.16x]) "
63 "> i_size_read(inode)(=[0x%.16x])\n",
64 new_end_pos, i_size_read(inode));
65 expanding_file = 1;
66 }
67 break;
68 default:
69 if (new_end_pos > i_size_read(inode)) {
70 ecryptfs_printk(KERN_DEBUG, "new_end_pos(=[0x%.16x]) "
71 "> i_size_read(inode)(=[0x%.16x])\n",
72 new_end_pos, i_size_read(inode));
73 expanding_file = 1;
74 }
75 }
76 ecryptfs_printk(KERN_DEBUG, "new_end_pos = [0x%.16x]\n", new_end_pos);
77 if (expanding_file) {
78 rc = ecryptfs_truncate(file->f_path.dentry, new_end_pos);
79 if (rc) {
80 rv = rc;
81 ecryptfs_printk(KERN_ERR, "Error on attempt to "
82 "truncate to (higher) offset [0x%.16x];"
83 " rc = [%d]\n", new_end_pos, rc);
84 goto out;
85 }
86 }
87 rv = generic_file_llseek(file, offset, origin);
88out:
89 return rv;
90}
91
92/**
93 * ecryptfs_read_update_atime 36 * ecryptfs_read_update_atime
94 * 37 *
95 * generic_file_read updates the atime of upper layer inode. But, it 38 * generic_file_read updates the atime of upper layer inode. But, it
@@ -425,7 +368,7 @@ const struct file_operations ecryptfs_dir_fops = {
425}; 368};
426 369
427const struct file_operations ecryptfs_main_fops = { 370const struct file_operations ecryptfs_main_fops = {
428 .llseek = ecryptfs_llseek, 371 .llseek = generic_file_llseek,
429 .read = do_sync_read, 372 .read = do_sync_read,
430 .aio_read = ecryptfs_read_update_atime, 373 .aio_read = ecryptfs_read_update_atime,
431 .write = do_sync_write, 374 .write = do_sync_write,
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 8cbf3f69ebe5..606128f5c927 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -583,8 +583,7 @@ inode_info_init_once(void *vptr, struct kmem_cache *cachep, unsigned long flags)
583{ 583{
584 struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; 584 struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr;
585 585
586 if (flags & SLAB_CTOR_CONSTRUCTOR) 586 inode_init_once(&ei->vfs_inode);
587 inode_init_once(&ei->vfs_inode);
588} 587}
589 588
590static struct ecryptfs_cache_info { 589static struct ecryptfs_cache_info {
diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c
index 3baf253be95a..a9d87c47f72d 100644
--- a/fs/ecryptfs/messaging.c
+++ b/fs/ecryptfs/messaging.c
@@ -19,7 +19,7 @@
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA. 20 * 02111-1307, USA.
21 */ 21 */
22 22#include <linux/sched.h>
23#include "ecryptfs_kernel.h" 23#include "ecryptfs_kernel.h"
24 24
25static LIST_HEAD(ecryptfs_msg_ctx_free_list); 25static LIST_HEAD(ecryptfs_msg_ctx_free_list);
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 0770c4b66f53..55cec98a84e7 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -364,25 +364,43 @@ static int fill_zeros_to_end_of_page(struct page *page, unsigned int to)
364{ 364{
365 struct inode *inode = page->mapping->host; 365 struct inode *inode = page->mapping->host;
366 int end_byte_in_page; 366 int end_byte_in_page;
367 char *page_virt;
368 367
369 if ((i_size_read(inode) / PAGE_CACHE_SIZE) != page->index) 368 if ((i_size_read(inode) / PAGE_CACHE_SIZE) != page->index)
370 goto out; 369 goto out;
371 end_byte_in_page = i_size_read(inode) % PAGE_CACHE_SIZE; 370 end_byte_in_page = i_size_read(inode) % PAGE_CACHE_SIZE;
372 if (to > end_byte_in_page) 371 if (to > end_byte_in_page)
373 end_byte_in_page = to; 372 end_byte_in_page = to;
374 page_virt = kmap_atomic(page, KM_USER0); 373 zero_user_page(page, end_byte_in_page,
375 memset((page_virt + end_byte_in_page), 0, 374 PAGE_CACHE_SIZE - end_byte_in_page, KM_USER0);
376 (PAGE_CACHE_SIZE - end_byte_in_page));
377 kunmap_atomic(page_virt, KM_USER0);
378 flush_dcache_page(page);
379out: 375out:
380 return 0; 376 return 0;
381} 377}
382 378
379/**
380 * eCryptfs does not currently support holes. When writing after a
381 * seek past the end of the file, eCryptfs fills in 0's through to the
382 * current location. The code to fill in the 0's to all the
383 * intermediate pages calls ecryptfs_prepare_write_no_truncate().
384 */
385static int
386ecryptfs_prepare_write_no_truncate(struct file *file, struct page *page,
387 unsigned from, unsigned to)
388{
389 int rc = 0;
390
391 if (from == 0 && to == PAGE_CACHE_SIZE)
392 goto out; /* If we are writing a full page, it will be
393 up to date. */
394 if (!PageUptodate(page))
395 rc = ecryptfs_do_readpage(file, page, page->index);
396out:
397 return rc;
398}
399
383static int ecryptfs_prepare_write(struct file *file, struct page *page, 400static int ecryptfs_prepare_write(struct file *file, struct page *page,
384 unsigned from, unsigned to) 401 unsigned from, unsigned to)
385{ 402{
403 loff_t pos;
386 int rc = 0; 404 int rc = 0;
387 405
388 if (from == 0 && to == PAGE_CACHE_SIZE) 406 if (from == 0 && to == PAGE_CACHE_SIZE)
@@ -390,6 +408,16 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
390 up to date. */ 408 up to date. */
391 if (!PageUptodate(page)) 409 if (!PageUptodate(page))
392 rc = ecryptfs_do_readpage(file, page, page->index); 410 rc = ecryptfs_do_readpage(file, page, page->index);
411 pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
412 if (pos > i_size_read(page->mapping->host)) {
413 rc = ecryptfs_truncate(file->f_path.dentry, pos);
414 if (rc) {
415 printk(KERN_ERR "Error on attempt to "
416 "truncate to (higher) offset [%lld];"
417 " rc = [%d]\n", pos, rc);
418 goto out;
419 }
420 }
393out: 421out:
394 return rc; 422 return rc;
395} 423}
@@ -740,7 +768,6 @@ int write_zeros(struct file *file, pgoff_t index, int start, int num_zeros)
740{ 768{
741 int rc = 0; 769 int rc = 0;
742 struct page *tmp_page; 770 struct page *tmp_page;
743 char *tmp_page_virt;
744 771
745 tmp_page = ecryptfs_get1page(file, index); 772 tmp_page = ecryptfs_get1page(file, index);
746 if (IS_ERR(tmp_page)) { 773 if (IS_ERR(tmp_page)) {
@@ -749,18 +776,15 @@ int write_zeros(struct file *file, pgoff_t index, int start, int num_zeros)
749 rc = PTR_ERR(tmp_page); 776 rc = PTR_ERR(tmp_page);
750 goto out; 777 goto out;
751 } 778 }
752 rc = ecryptfs_prepare_write(file, tmp_page, start, start + num_zeros); 779 if ((rc = ecryptfs_prepare_write_no_truncate(file, tmp_page, start,
753 if (rc) { 780 (start + num_zeros)))) {
754 ecryptfs_printk(KERN_ERR, "Error preparing to write zero's " 781 ecryptfs_printk(KERN_ERR, "Error preparing to write zero's "
755 "to remainder of page at index [0x%.16x]\n", 782 "to page at index [0x%.16x]\n",
756 index); 783 index);
757 page_cache_release(tmp_page); 784 page_cache_release(tmp_page);
758 goto out; 785 goto out;
759 } 786 }
760 tmp_page_virt = kmap_atomic(tmp_page, KM_USER0); 787 zero_user_page(tmp_page, start, num_zeros, KM_USER0);
761 memset(((char *)tmp_page_virt + start), 0, num_zeros);
762 kunmap_atomic(tmp_page_virt, KM_USER0);
763 flush_dcache_page(tmp_page);
764 rc = ecryptfs_commit_write(file, tmp_page, start, start + num_zeros); 788 rc = ecryptfs_commit_write(file, tmp_page, start, start + num_zeros);
765 if (rc < 0) { 789 if (rc < 0) {
766 ecryptfs_printk(KERN_ERR, "Error attempting to write zero's " 790 ecryptfs_printk(KERN_ERR, "Error attempting to write zero's "
diff --git a/fs/efs/super.c b/fs/efs/super.c
index ba7a8b9da0c1..e0a6839e68ae 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -72,8 +72,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
72{ 72{
73 struct efs_inode_info *ei = (struct efs_inode_info *) foo; 73 struct efs_inode_info *ei = (struct efs_inode_info *) foo;
74 74
75 if (flags & SLAB_CTOR_CONSTRUCTOR) 75 inode_init_once(&ei->vfs_inode);
76 inode_init_once(&ei->vfs_inode);
77} 76}
78 77
79static int init_inodecache(void) 78static int init_inodecache(void)
diff --git a/fs/eventfd.c b/fs/eventfd.c
index 480e2b3c4166..2ce19c000d2a 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -17,7 +17,6 @@
17#include <linux/eventfd.h> 17#include <linux/eventfd.h>
18 18
19struct eventfd_ctx { 19struct eventfd_ctx {
20 spinlock_t lock;
21 wait_queue_head_t wqh; 20 wait_queue_head_t wqh;
22 /* 21 /*
23 * Every time that a write(2) is performed on an eventfd, the 22 * Every time that a write(2) is performed on an eventfd, the
@@ -45,13 +44,13 @@ int eventfd_signal(struct file *file, int n)
45 44
46 if (n < 0) 45 if (n < 0)
47 return -EINVAL; 46 return -EINVAL;
48 spin_lock_irqsave(&ctx->lock, flags); 47 spin_lock_irqsave(&ctx->wqh.lock, flags);
49 if (ULLONG_MAX - ctx->count < n) 48 if (ULLONG_MAX - ctx->count < n)
50 n = (int) (ULLONG_MAX - ctx->count); 49 n = (int) (ULLONG_MAX - ctx->count);
51 ctx->count += n; 50 ctx->count += n;
52 if (waitqueue_active(&ctx->wqh)) 51 if (waitqueue_active(&ctx->wqh))
53 wake_up_locked(&ctx->wqh); 52 wake_up_locked(&ctx->wqh);
54 spin_unlock_irqrestore(&ctx->lock, flags); 53 spin_unlock_irqrestore(&ctx->wqh.lock, flags);
55 54
56 return n; 55 return n;
57} 56}
@@ -70,14 +69,14 @@ static unsigned int eventfd_poll(struct file *file, poll_table *wait)
70 69
71 poll_wait(file, &ctx->wqh, wait); 70 poll_wait(file, &ctx->wqh, wait);
72 71
73 spin_lock_irqsave(&ctx->lock, flags); 72 spin_lock_irqsave(&ctx->wqh.lock, flags);
74 if (ctx->count > 0) 73 if (ctx->count > 0)
75 events |= POLLIN; 74 events |= POLLIN;
76 if (ctx->count == ULLONG_MAX) 75 if (ctx->count == ULLONG_MAX)
77 events |= POLLERR; 76 events |= POLLERR;
78 if (ULLONG_MAX - 1 > ctx->count) 77 if (ULLONG_MAX - 1 > ctx->count)
79 events |= POLLOUT; 78 events |= POLLOUT;
80 spin_unlock_irqrestore(&ctx->lock, flags); 79 spin_unlock_irqrestore(&ctx->wqh.lock, flags);
81 80
82 return events; 81 return events;
83} 82}
@@ -92,7 +91,7 @@ static ssize_t eventfd_read(struct file *file, char __user *buf, size_t count,
92 91
93 if (count < sizeof(ucnt)) 92 if (count < sizeof(ucnt))
94 return -EINVAL; 93 return -EINVAL;
95 spin_lock_irq(&ctx->lock); 94 spin_lock_irq(&ctx->wqh.lock);
96 res = -EAGAIN; 95 res = -EAGAIN;
97 ucnt = ctx->count; 96 ucnt = ctx->count;
98 if (ucnt > 0) 97 if (ucnt > 0)
@@ -110,9 +109,9 @@ static ssize_t eventfd_read(struct file *file, char __user *buf, size_t count,
110 res = -ERESTARTSYS; 109 res = -ERESTARTSYS;
111 break; 110 break;
112 } 111 }
113 spin_unlock_irq(&ctx->lock); 112 spin_unlock_irq(&ctx->wqh.lock);
114 schedule(); 113 schedule();
115 spin_lock_irq(&ctx->lock); 114 spin_lock_irq(&ctx->wqh.lock);
116 } 115 }
117 __remove_wait_queue(&ctx->wqh, &wait); 116 __remove_wait_queue(&ctx->wqh, &wait);
118 __set_current_state(TASK_RUNNING); 117 __set_current_state(TASK_RUNNING);
@@ -122,7 +121,7 @@ static ssize_t eventfd_read(struct file *file, char __user *buf, size_t count,
122 if (waitqueue_active(&ctx->wqh)) 121 if (waitqueue_active(&ctx->wqh))
123 wake_up_locked(&ctx->wqh); 122 wake_up_locked(&ctx->wqh);
124 } 123 }
125 spin_unlock_irq(&ctx->lock); 124 spin_unlock_irq(&ctx->wqh.lock);
126 if (res > 0 && put_user(ucnt, (__u64 __user *) buf)) 125 if (res > 0 && put_user(ucnt, (__u64 __user *) buf))
127 return -EFAULT; 126 return -EFAULT;
128 127
@@ -143,7 +142,7 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
143 return -EFAULT; 142 return -EFAULT;
144 if (ucnt == ULLONG_MAX) 143 if (ucnt == ULLONG_MAX)
145 return -EINVAL; 144 return -EINVAL;
146 spin_lock_irq(&ctx->lock); 145 spin_lock_irq(&ctx->wqh.lock);
147 res = -EAGAIN; 146 res = -EAGAIN;
148 if (ULLONG_MAX - ctx->count > ucnt) 147 if (ULLONG_MAX - ctx->count > ucnt)
149 res = sizeof(ucnt); 148 res = sizeof(ucnt);
@@ -159,9 +158,9 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
159 res = -ERESTARTSYS; 158 res = -ERESTARTSYS;
160 break; 159 break;
161 } 160 }
162 spin_unlock_irq(&ctx->lock); 161 spin_unlock_irq(&ctx->wqh.lock);
163 schedule(); 162 schedule();
164 spin_lock_irq(&ctx->lock); 163 spin_lock_irq(&ctx->wqh.lock);
165 } 164 }
166 __remove_wait_queue(&ctx->wqh, &wait); 165 __remove_wait_queue(&ctx->wqh, &wait);
167 __set_current_state(TASK_RUNNING); 166 __set_current_state(TASK_RUNNING);
@@ -171,7 +170,7 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
171 if (waitqueue_active(&ctx->wqh)) 170 if (waitqueue_active(&ctx->wqh))
172 wake_up_locked(&ctx->wqh); 171 wake_up_locked(&ctx->wqh);
173 } 172 }
174 spin_unlock_irq(&ctx->lock); 173 spin_unlock_irq(&ctx->wqh.lock);
175 174
176 return res; 175 return res;
177} 176}
@@ -210,7 +209,6 @@ asmlinkage long sys_eventfd(unsigned int count)
210 return -ENOMEM; 209 return -ENOMEM;
211 210
212 init_waitqueue_head(&ctx->wqh); 211 init_waitqueue_head(&ctx->wqh);
213 spin_lock_init(&ctx->lock);
214 ctx->count = count; 212 ctx->count = count;
215 213
216 /* 214 /*
diff --git a/fs/exec.c b/fs/exec.c
index 70fa36554c14..f20561ff4528 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -60,7 +60,7 @@
60#endif 60#endif
61 61
62int core_uses_pid; 62int core_uses_pid;
63char core_pattern[128] = "core"; 63char core_pattern[CORENAME_MAX_SIZE] = "core";
64int suid_dumpable = 0; 64int suid_dumpable = 0;
65 65
66EXPORT_SYMBOL(suid_dumpable); 66EXPORT_SYMBOL(suid_dumpable);
@@ -134,6 +134,9 @@ asmlinkage long sys_uselib(const char __user * library)
134 if (error) 134 if (error)
135 goto out; 135 goto out;
136 136
137 error = -EACCES;
138 if (nd.mnt->mnt_flags & MNT_NOEXEC)
139 goto exit;
137 error = -EINVAL; 140 error = -EINVAL;
138 if (!S_ISREG(nd.dentry->d_inode->i_mode)) 141 if (!S_ISREG(nd.dentry->d_inode->i_mode))
139 goto exit; 142 goto exit;
@@ -1264,8 +1267,6 @@ int set_binfmt(struct linux_binfmt *new)
1264 1267
1265EXPORT_SYMBOL(set_binfmt); 1268EXPORT_SYMBOL(set_binfmt);
1266 1269
1267#define CORENAME_MAX_SIZE 64
1268
1269/* format_corename will inspect the pattern parameter, and output a 1270/* format_corename will inspect the pattern parameter, and output a
1270 * name into corename, which must have space for at least 1271 * name into corename, which must have space for at least
1271 * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. 1272 * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 685a1c287177..16337bff0272 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -160,13 +160,11 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
160{ 160{
161 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo; 161 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
162 162
163 if (flags & SLAB_CTOR_CONSTRUCTOR) { 163 rwlock_init(&ei->i_meta_lock);
164 rwlock_init(&ei->i_meta_lock);
165#ifdef CONFIG_EXT2_FS_XATTR 164#ifdef CONFIG_EXT2_FS_XATTR
166 init_rwsem(&ei->xattr_sem); 165 init_rwsem(&ei->xattr_sem);
167#endif 166#endif
168 inode_init_once(&ei->vfs_inode); 167 inode_init_once(&ei->vfs_inode);
169 }
170} 168}
171 169
172static int init_inodecache(void) 170static int init_inodecache(void)
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 54d3c9041259..6e3062913a92 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -466,14 +466,12 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
466{ 466{
467 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; 467 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo;
468 468
469 if (flags & SLAB_CTOR_CONSTRUCTOR) { 469 INIT_LIST_HEAD(&ei->i_orphan);
470 INIT_LIST_HEAD(&ei->i_orphan);
471#ifdef CONFIG_EXT3_FS_XATTR 470#ifdef CONFIG_EXT3_FS_XATTR
472 init_rwsem(&ei->xattr_sem); 471 init_rwsem(&ei->xattr_sem);
473#endif 472#endif
474 mutex_init(&ei->truncate_mutex); 473 mutex_init(&ei->truncate_mutex);
475 inode_init_once(&ei->vfs_inode); 474 inode_init_once(&ei->vfs_inode);
476 }
477} 475}
478 476
479static int init_inodecache(void) 477static int init_inodecache(void)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 719126932354..cb9afdd0e26e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -517,14 +517,12 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
517{ 517{
518 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; 518 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
519 519
520 if (flags & SLAB_CTOR_CONSTRUCTOR) { 520 INIT_LIST_HEAD(&ei->i_orphan);
521 INIT_LIST_HEAD(&ei->i_orphan);
522#ifdef CONFIG_EXT4DEV_FS_XATTR 521#ifdef CONFIG_EXT4DEV_FS_XATTR
523 init_rwsem(&ei->xattr_sem); 522 init_rwsem(&ei->xattr_sem);
524#endif 523#endif
525 mutex_init(&ei->truncate_mutex); 524 mutex_init(&ei->truncate_mutex);
526 inode_init_once(&ei->vfs_inode); 525 inode_init_once(&ei->vfs_inode);
527 }
528} 526}
529 527
530static int init_inodecache(void) 528static int init_inodecache(void)
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 1959143c1d27..3c9c8a15ec73 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -40,8 +40,7 @@ static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
40{ 40{
41 struct fat_cache *cache = (struct fat_cache *)foo; 41 struct fat_cache *cache = (struct fat_cache *)foo;
42 42
43 if (flags & SLAB_CTOR_CONSTRUCTOR) 43 INIT_LIST_HEAD(&cache->cache_list);
44 INIT_LIST_HEAD(&cache->cache_list);
45} 44}
46 45
47int __init fat_cache_init(void) 46int __init fat_cache_init(void)
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 2c55e8dce793..479722d89667 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -500,14 +500,12 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
500{ 500{
501 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo; 501 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo;
502 502
503 if (flags & SLAB_CTOR_CONSTRUCTOR) { 503 spin_lock_init(&ei->cache_lru_lock);
504 spin_lock_init(&ei->cache_lru_lock); 504 ei->nr_caches = 0;
505 ei->nr_caches = 0; 505 ei->cache_valid_id = FAT_CACHE_VALID + 1;
506 ei->cache_valid_id = FAT_CACHE_VALID + 1; 506 INIT_LIST_HEAD(&ei->cache_lru);
507 INIT_LIST_HEAD(&ei->cache_lru); 507 INIT_HLIST_NODE(&ei->i_fat_hash);
508 INIT_HLIST_NODE(&ei->i_fat_hash); 508 inode_init_once(&ei->vfs_inode);
509 inode_init_once(&ei->vfs_inode);
510 }
511} 509}
512 510
513static int __init fat_init_inodecache(void) 511static int __init fat_init_inodecache(void)
diff --git a/fs/fifo.c b/fs/fifo.c
index 6e7df7256782..9785e36f81e7 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -12,6 +12,7 @@
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/fs.h> 14#include <linux/fs.h>
15#include <linux/sched.h>
15#include <linux/pipe_fs_i.h> 16#include <linux/pipe_fs_i.h>
16 17
17static void wait_for_partner(struct inode* inode, unsigned int *cnt) 18static void wait_for_partner(struct inode* inode, unsigned int *cnt)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 8890eba1db52..bd5a772d8ccf 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -485,7 +485,7 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode,
485static int fuse_create(struct inode *dir, struct dentry *entry, int mode, 485static int fuse_create(struct inode *dir, struct dentry *entry, int mode,
486 struct nameidata *nd) 486 struct nameidata *nd)
487{ 487{
488 if (nd && (nd->flags & LOOKUP_CREATE)) { 488 if (nd && (nd->flags & LOOKUP_OPEN)) {
489 int err = fuse_create_open(dir, entry, mode, nd); 489 int err = fuse_create_open(dir, entry, mode, nd);
490 if (err != -ENOSYS) 490 if (err != -ENOSYS)
491 return err; 491 return err;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index acfad65a6e8e..adf7995232b8 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -11,6 +11,7 @@
11#include <linux/pagemap.h> 11#include <linux/pagemap.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/sched.h>
14 15
15static const struct file_operations fuse_direct_io_file_operations; 16static const struct file_operations fuse_direct_io_file_operations;
16 17
@@ -609,7 +610,9 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
609 ssize_t res; 610 ssize_t res;
610 /* Don't allow parallel writes to the same file */ 611 /* Don't allow parallel writes to the same file */
611 mutex_lock(&inode->i_mutex); 612 mutex_lock(&inode->i_mutex);
612 res = fuse_direct_io(file, buf, count, ppos, 1); 613 res = generic_write_checks(file, ppos, &count, 0);
614 if (!res)
615 res = fuse_direct_io(file, buf, count, ppos, 1);
613 mutex_unlock(&inode->i_mutex); 616 mutex_unlock(&inode->i_mutex);
614 return res; 617 return res;
615} 618}
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 1397018ff476..9804c0cdcb42 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -17,6 +17,7 @@
17#include <linux/parser.h> 17#include <linux/parser.h>
18#include <linux/statfs.h> 18#include <linux/statfs.h>
19#include <linux/random.h> 19#include <linux/random.h>
20#include <linux/sched.h>
20 21
21MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>"); 22MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
22MODULE_DESCRIPTION("Filesystem in Userspace"); 23MODULE_DESCRIPTION("Filesystem in Userspace");
@@ -453,6 +454,7 @@ static const struct super_operations fuse_super_operations = {
453 .destroy_inode = fuse_destroy_inode, 454 .destroy_inode = fuse_destroy_inode,
454 .read_inode = fuse_read_inode, 455 .read_inode = fuse_read_inode,
455 .clear_inode = fuse_clear_inode, 456 .clear_inode = fuse_clear_inode,
457 .drop_inode = generic_delete_inode,
456 .remount_fs = fuse_remount_fs, 458 .remount_fs = fuse_remount_fs,
457 .put_super = fuse_put_super, 459 .put_super = fuse_put_super,
458 .umount_begin = fuse_umount_begin, 460 .umount_begin = fuse_umount_begin,
@@ -687,8 +689,7 @@ static void fuse_inode_init_once(void *foo, struct kmem_cache *cachep,
687{ 689{
688 struct inode * inode = foo; 690 struct inode * inode = foo;
689 691
690 if (flags & SLAB_CTOR_CONSTRUCTOR) 692 inode_init_once(inode);
691 inode_init_once(inode);
692} 693}
693 694
694static int __init fuse_fs_init(void) 695static int __init fuse_fs_init(void)
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index 11477ca3a3c0..b3e152db70c8 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -10,6 +10,7 @@
10#ifndef __GLOCK_DOT_H__ 10#ifndef __GLOCK_DOT_H__
11#define __GLOCK_DOT_H__ 11#define __GLOCK_DOT_H__
12 12
13#include <linux/sched.h>
13#include "incore.h" 14#include "incore.h"
14 15
15/* Flags for lock requests; used in gfs2_holder gh_flag field. 16/* Flags for lock requests; used in gfs2_holder gh_flag field.
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index e460487c0557..787a0edef100 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -27,29 +27,27 @@
27static void gfs2_init_inode_once(void *foo, struct kmem_cache *cachep, unsigned long flags) 27static void gfs2_init_inode_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
28{ 28{
29 struct gfs2_inode *ip = foo; 29 struct gfs2_inode *ip = foo;
30 if (flags & SLAB_CTOR_CONSTRUCTOR) { 30
31 inode_init_once(&ip->i_inode); 31 inode_init_once(&ip->i_inode);
32 spin_lock_init(&ip->i_spin); 32 spin_lock_init(&ip->i_spin);
33 init_rwsem(&ip->i_rw_mutex); 33 init_rwsem(&ip->i_rw_mutex);
34 memset(ip->i_cache, 0, sizeof(ip->i_cache)); 34 memset(ip->i_cache, 0, sizeof(ip->i_cache));
35 }
36} 35}
37 36
38static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned long flags) 37static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
39{ 38{
40 struct gfs2_glock *gl = foo; 39 struct gfs2_glock *gl = foo;
41 if (flags & SLAB_CTOR_CONSTRUCTOR) { 40
42 INIT_HLIST_NODE(&gl->gl_list); 41 INIT_HLIST_NODE(&gl->gl_list);
43 spin_lock_init(&gl->gl_spin); 42 spin_lock_init(&gl->gl_spin);
44 INIT_LIST_HEAD(&gl->gl_holders); 43 INIT_LIST_HEAD(&gl->gl_holders);
45 INIT_LIST_HEAD(&gl->gl_waiters1); 44 INIT_LIST_HEAD(&gl->gl_waiters1);
46 INIT_LIST_HEAD(&gl->gl_waiters3); 45 INIT_LIST_HEAD(&gl->gl_waiters3);
47 gl->gl_lvb = NULL; 46 gl->gl_lvb = NULL;
48 atomic_set(&gl->gl_lvb_count, 0); 47 atomic_set(&gl->gl_lvb_count, 0);
49 INIT_LIST_HEAD(&gl->gl_reclaim); 48 INIT_LIST_HEAD(&gl->gl_reclaim);
50 INIT_LIST_HEAD(&gl->gl_ail_list); 49 INIT_LIST_HEAD(&gl->gl_ail_list);
51 atomic_set(&gl->gl_ail_count, 0); 50 atomic_set(&gl->gl_ail_count, 0);
52 }
53} 51}
54 52
55/** 53/**
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index fafcba593871..9a934db0bd8a 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/pagemap.h> 14#include <linux/pagemap.h>
15#include <linux/mpage.h> 15#include <linux/mpage.h>
16#include <linux/sched.h>
16 17
17#include "hfs_fs.h" 18#include "hfs_fs.h"
18#include "btree.h" 19#include "btree.h"
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 4f1888f16cf0..92cf8751e428 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -434,8 +434,7 @@ static void hfs_init_once(void *p, struct kmem_cache *cachep, unsigned long flag
434{ 434{
435 struct hfs_inode_info *i = p; 435 struct hfs_inode_info *i = p;
436 436
437 if (flags & SLAB_CTOR_CONSTRUCTOR) 437 inode_init_once(&i->vfs_inode);
438 inode_init_once(&i->vfs_inode);
439} 438}
440 439
441static int __init init_hfs_fs(void) 440static int __init init_hfs_fs(void)
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 642012ac3370..45dab5d6cc10 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -12,6 +12,7 @@
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/pagemap.h> 13#include <linux/pagemap.h>
14#include <linux/mpage.h> 14#include <linux/mpage.h>
15#include <linux/sched.h>
15 16
16#include "hfsplus_fs.h" 17#include "hfsplus_fs.h"
17#include "hfsplus_raw.h" 18#include "hfsplus_raw.h"
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 37afbec8a761..ebd1b380cbbc 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -470,8 +470,7 @@ static void hfsplus_init_once(void *p, struct kmem_cache *cachep, unsigned long
470{ 470{
471 struct hfsplus_inode_info *i = p; 471 struct hfsplus_inode_info *i = p;
472 472
473 if (flags & SLAB_CTOR_CONSTRUCTOR) 473 inode_init_once(&i->vfs_inode);
474 inode_init_once(&i->vfs_inode);
475} 474}
476 475
477static int __init init_hfsplus_fs(void) 476static int __init init_hfsplus_fs(void)
diff --git a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c
index b52b7381d10f..b6fca543544c 100644
--- a/fs/hpfs/buffer.c
+++ b/fs/hpfs/buffer.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * general buffer i/o 6 * general buffer i/o
7 */ 7 */
8 8#include <linux/sched.h>
9#include "hpfs_fn.h" 9#include "hpfs_fn.h"
10 10
11void hpfs_lock_creation(struct super_block *s) 11void hpfs_lock_creation(struct super_block *s)
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 9953cf9a2f16..d256559b4104 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * adding & removing files & directories 6 * adding & removing files & directories
7 */ 7 */
8 8#include <linux/sched.h>
9#include "hpfs_fn.h" 9#include "hpfs_fn.h"
10 10
11static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 11static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 1b95f39fbc37..29cc34abb2ea 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/statfs.h> 13#include <linux/statfs.h>
14#include <linux/magic.h> 14#include <linux/magic.h>
15#include <linux/sched.h>
15 16
16/* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */ 17/* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */
17 18
@@ -176,11 +177,9 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
176{ 177{
177 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; 178 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo;
178 179
179 if (flags & SLAB_CTOR_CONSTRUCTOR) { 180 mutex_init(&ei->i_mutex);
180 mutex_init(&ei->i_mutex); 181 mutex_init(&ei->i_parent_mutex);
181 mutex_init(&ei->i_parent_mutex); 182 inode_init_once(&ei->vfs_inode);
182 inode_init_once(&ei->vfs_inode);
183 }
184} 183}
185 184
186static int init_inodecache(void) 185static int init_inodecache(void)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 98959b87cdf8..aa083dd34e92 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -556,8 +556,7 @@ static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
556{ 556{
557 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo; 557 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo;
558 558
559 if (flags & SLAB_CTOR_CONSTRUCTOR) 559 inode_init_once(&ei->vfs_inode);
560 inode_init_once(&ei->vfs_inode);
561} 560}
562 561
563const struct file_operations hugetlbfs_file_operations = { 562const struct file_operations hugetlbfs_file_operations = {
diff --git a/fs/inode.c b/fs/inode.c
index df2ef15d03d2..9a012cc5b6cd 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -213,8 +213,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
213{ 213{
214 struct inode * inode = (struct inode *) foo; 214 struct inode * inode = (struct inode *) foo;
215 215
216 if (flags & SLAB_CTOR_CONSTRUCTOR) 216 inode_init_once(inode);
217 inode_init_once(inode);
218} 217}
219 218
220/* 219/*
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index e99f7ff4ecb4..5c3eecf7542e 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -77,8 +77,7 @@ static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags
77{ 77{
78 struct iso_inode_info *ei = foo; 78 struct iso_inode_info *ei = foo;
79 79
80 if (flags & SLAB_CTOR_CONSTRUCTOR) 80 inode_init_once(&ei->vfs_inode);
81 inode_init_once(&ei->vfs_inode);
82} 81}
83 82
84static int init_inodecache(void) 83static int init_inodecache(void)
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 45368f8bbe72..6488af43bc9b 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -47,10 +47,8 @@ static void jffs2_i_init_once(void * foo, struct kmem_cache * cachep, unsigned l
47{ 47{
48 struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo; 48 struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo;
49 49
50 if (flags & SLAB_CTOR_CONSTRUCTOR) { 50 init_MUTEX(&ei->sem);
51 init_MUTEX(&ei->sem); 51 inode_init_once(&ei->vfs_inode);
52 inode_init_once(&ei->vfs_inode);
53 }
54} 52}
55 53
56static int jffs2_sync_fs(struct super_block *sb, int wait) 54static int jffs2_sync_fs(struct super_block *sb, int wait)
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 6b3acb0b5781..43d4f69afbec 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -184,16 +184,14 @@ static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
184{ 184{
185 struct metapage *mp = (struct metapage *)foo; 185 struct metapage *mp = (struct metapage *)foo;
186 186
187 if (flags & SLAB_CTOR_CONSTRUCTOR) { 187 mp->lid = 0;
188 mp->lid = 0; 188 mp->lsn = 0;
189 mp->lsn = 0; 189 mp->flag = 0;
190 mp->flag = 0; 190 mp->data = NULL;
191 mp->data = NULL; 191 mp->clsn = 0;
192 mp->clsn = 0; 192 mp->log = NULL;
193 mp->log = NULL; 193 set_bit(META_free, &mp->flag);
194 set_bit(META_free, &mp->flag); 194 init_waitqueue_head(&mp->wait);
195 init_waitqueue_head(&mp->wait);
196 }
197} 195}
198 196
199static inline struct metapage *alloc_metapage(gfp_t gfp_mask) 197static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index ea9dc3e65dcf..20e4ac1c79a3 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -752,20 +752,18 @@ static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags
752{ 752{
753 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo; 753 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
754 754
755 if (flags & SLAB_CTOR_CONSTRUCTOR) { 755 memset(jfs_ip, 0, sizeof(struct jfs_inode_info));
756 memset(jfs_ip, 0, sizeof(struct jfs_inode_info)); 756 INIT_LIST_HEAD(&jfs_ip->anon_inode_list);
757 INIT_LIST_HEAD(&jfs_ip->anon_inode_list); 757 init_rwsem(&jfs_ip->rdwrlock);
758 init_rwsem(&jfs_ip->rdwrlock); 758 mutex_init(&jfs_ip->commit_mutex);
759 mutex_init(&jfs_ip->commit_mutex); 759 init_rwsem(&jfs_ip->xattr_sem);
760 init_rwsem(&jfs_ip->xattr_sem); 760 spin_lock_init(&jfs_ip->ag_lock);
761 spin_lock_init(&jfs_ip->ag_lock); 761 jfs_ip->active_ag = -1;
762 jfs_ip->active_ag = -1;
763#ifdef CONFIG_JFS_POSIX_ACL 762#ifdef CONFIG_JFS_POSIX_ACL
764 jfs_ip->i_acl = JFS_ACL_NOT_CACHED; 763 jfs_ip->i_acl = JFS_ACL_NOT_CACHED;
765 jfs_ip->i_default_acl = JFS_ACL_NOT_CACHED; 764 jfs_ip->i_default_acl = JFS_ACL_NOT_CACHED;
766#endif 765#endif
767 inode_init_once(&jfs_ip->vfs_inode); 766 inode_init_once(&jfs_ip->vfs_inode);
768 }
769} 767}
770 768
771static int __init init_jfs_fs(void) 769static int __init init_jfs_fs(void)
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index f4d45d4d835b..d070b18e539d 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -153,7 +153,7 @@ nlmclnt_recovery(struct nlm_host *host)
153 if (!host->h_reclaiming++) { 153 if (!host->h_reclaiming++) {
154 nlm_get_host(host); 154 nlm_get_host(host);
155 __module_get(THIS_MODULE); 155 __module_get(THIS_MODULE);
156 if (kernel_thread(reclaimer, host, CLONE_KERNEL) < 0) 156 if (kernel_thread(reclaimer, host, CLONE_FS | CLONE_FILES) < 0)
157 module_put(THIS_MODULE); 157 module_put(THIS_MODULE);
158 } 158 }
159} 159}
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index ad21c0713efa..96070bff93fc 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -221,7 +221,7 @@ nlm_bind_host(struct nlm_host *host)
221 host->h_nextrebind - jiffies); 221 host->h_nextrebind - jiffies);
222 } 222 }
223 } else { 223 } else {
224 unsigned long increment = nlmsvc_timeout * HZ; 224 unsigned long increment = nlmsvc_timeout;
225 struct rpc_timeout timeparms = { 225 struct rpc_timeout timeparms = {
226 .to_initval = increment, 226 .to_initval = increment,
227 .to_increment = increment, 227 .to_increment = increment,
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 9702956d206c..5316e307a49d 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -586,10 +586,6 @@ static struct rpc_version nlm_version3 = {
586 .procs = nlm_procedures, 586 .procs = nlm_procedures,
587}; 587};
588 588
589#ifdef CONFIG_LOCKD_V4
590extern struct rpc_version nlm_version4;
591#endif
592
593static struct rpc_version * nlm_versions[] = { 589static struct rpc_version * nlm_versions[] = {
594 [1] = &nlm_version1, 590 [1] = &nlm_version1,
595 [3] = &nlm_version3, 591 [3] = &nlm_version3,
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
index ce1efdbe1b3a..846fc1d639dd 100644
--- a/fs/lockd/xdr4.c
+++ b/fs/lockd/xdr4.c
@@ -123,7 +123,8 @@ static __be32 *
123nlm4_decode_lock(__be32 *p, struct nlm_lock *lock) 123nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)
124{ 124{
125 struct file_lock *fl = &lock->fl; 125 struct file_lock *fl = &lock->fl;
126 __s64 len, start, end; 126 __u64 len, start;
127 __s64 end;
127 128
128 if (!(p = xdr_decode_string_inplace(p, &lock->caller, 129 if (!(p = xdr_decode_string_inplace(p, &lock->caller,
129 &lock->len, NLM_MAXSTRLEN)) 130 &lock->len, NLM_MAXSTRLEN))
@@ -417,7 +418,8 @@ nlm4clt_decode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
417 if (resp->status == nlm_lck_denied) { 418 if (resp->status == nlm_lck_denied) {
418 struct file_lock *fl = &resp->lock.fl; 419 struct file_lock *fl = &resp->lock.fl;
419 u32 excl; 420 u32 excl;
420 s64 start, end, len; 421 __u64 start, len;
422 __s64 end;
421 423
422 memset(&resp->lock, 0, sizeof(resp->lock)); 424 memset(&resp->lock, 0, sizeof(resp->lock));
423 locks_init_lock(fl); 425 locks_init_lock(fl);
diff --git a/fs/locks.c b/fs/locks.c
index 8ec16ab5ef74..431a8b871fce 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -203,9 +203,6 @@ static void init_once(void *foo, struct kmem_cache *cache, unsigned long flags)
203{ 203{
204 struct file_lock *lock = (struct file_lock *) foo; 204 struct file_lock *lock = (struct file_lock *) foo;
205 205
206 if (!(flags & SLAB_CTOR_CONSTRUCTOR))
207 return;
208
209 locks_init_lock(lock); 206 locks_init_lock(lock);
210} 207}
211 208
diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index c4a554df7b7e..99a12f127769 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -15,6 +15,7 @@
15#include <linux/smp_lock.h> 15#include <linux/smp_lock.h>
16#include <linux/buffer_head.h> 16#include <linux/buffer_head.h>
17#include <linux/bitops.h> 17#include <linux/bitops.h>
18#include <linux/sched.h>
18 19
19static int nibblemap[] = { 4,3,3,2,3,2,2,1,3,2,2,1,2,1,1,0 }; 20static int nibblemap[] = { 4,3,3,2,3,2,2,1,3,2,2,1,2,1,1,0 };
20 21
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 2f4d43a2a310..be4044614ac8 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -73,8 +73,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
73{ 73{
74 struct minix_inode_info *ei = (struct minix_inode_info *) foo; 74 struct minix_inode_info *ei = (struct minix_inode_info *) foo;
75 75
76 if (flags & SLAB_CTOR_CONSTRUCTOR) 76 inode_init_once(&ei->vfs_inode);
77 inode_init_once(&ei->vfs_inode);
78} 77}
79 78
80static int init_inodecache(void) 79static int init_inodecache(void)
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index addfd3147ea7..d3152f8d95c6 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -17,6 +17,7 @@
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/vmalloc.h> 19#include <linux/vmalloc.h>
20#include <linux/sched.h>
20 21
21#include <linux/ncp_fs.h> 22#include <linux/ncp_fs.h>
22#include "ncplib_kernel.h" 23#include "ncplib_kernel.h"
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index c29f00ad495d..cf06eb9f050e 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -60,10 +60,8 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
60{ 60{
61 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo; 61 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo;
62 62
63 if (flags & SLAB_CTOR_CONSTRUCTOR) { 63 mutex_init(&ei->open_mutex);
64 mutex_init(&ei->open_mutex); 64 inode_init_once(&ei->vfs_inode);
65 inode_init_once(&ei->vfs_inode);
66 }
67} 65}
68 66
69static int init_inodecache(void) 67static int init_inodecache(void)
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index 8843a83d4ef0..c67b4bdcf719 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -17,6 +17,7 @@
17#include <linux/highuid.h> 17#include <linux/highuid.h>
18#include <linux/smp_lock.h> 18#include <linux/smp_lock.h>
19#include <linux/vmalloc.h> 19#include <linux/vmalloc.h>
20#include <linux/sched.h>
20 21
21#include <linux/ncp_fs.h> 22#include <linux/ncp_fs.h>
22 23
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index db3d7919c601..c2bb14e053e1 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -24,7 +24,7 @@ enum nfs4_callback_opnum {
24}; 24};
25 25
26struct cb_compound_hdr_arg { 26struct cb_compound_hdr_arg {
27 int taglen; 27 unsigned int taglen;
28 const char *tag; 28 const char *tag;
29 unsigned int callback_ident; 29 unsigned int callback_ident;
30 unsigned nops; 30 unsigned nops;
@@ -32,7 +32,7 @@ struct cb_compound_hdr_arg {
32 32
33struct cb_compound_hdr_res { 33struct cb_compound_hdr_res {
34 __be32 *status; 34 __be32 *status;
35 int taglen; 35 unsigned int taglen;
36 const char *tag; 36 const char *tag;
37 __be32 *nops; 37 __be32 *nops;
38}; 38};
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 50c6821bad26..881fa4900923 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -12,7 +12,7 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h> 14#include <linux/init.h>
15 15#include <linux/sched.h>
16#include <linux/time.h> 16#include <linux/time.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 841c99a9b11c..7f37d1bea83f 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -226,7 +226,7 @@ restart:
226 spin_unlock(&clp->cl_lock); 226 spin_unlock(&clp->cl_lock);
227} 227}
228 228
229int nfs_do_expire_all_delegations(void *ptr) 229static int nfs_do_expire_all_delegations(void *ptr)
230{ 230{
231 struct nfs_client *clp = ptr; 231 struct nfs_client *clp = ptr;
232 struct nfs_delegation *delegation; 232 struct nfs_delegation *delegation;
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 3df428816559..c27258b5d3e1 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -33,6 +33,7 @@
33#include <linux/pagevec.h> 33#include <linux/pagevec.h>
34#include <linux/namei.h> 34#include <linux/namei.h>
35#include <linux/mount.h> 35#include <linux/mount.h>
36#include <linux/sched.h>
36 37
37#include "nfs4_fs.h" 38#include "nfs4_fs.h"
38#include "delegation.h" 39#include "delegation.h"
@@ -607,7 +608,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
607 return res; 608 return res;
608} 609}
609 610
610loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) 611static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
611{ 612{
612 mutex_lock(&filp->f_path.dentry->d_inode->i_mutex); 613 mutex_lock(&filp->f_path.dentry->d_inode->i_mutex);
613 switch (origin) { 614 switch (origin) {
@@ -633,7 +634,7 @@ out:
633 * All directory operations under NFS are synchronous, so fsync() 634 * All directory operations under NFS are synchronous, so fsync()
634 * is a dummy operation. 635 * is a dummy operation.
635 */ 636 */
636int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync) 637static int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync)
637{ 638{
638 dfprintk(VFS, "NFS: fsync_dir(%s/%s) datasync %d\n", 639 dfprintk(VFS, "NFS: fsync_dir(%s/%s) datasync %d\n",
639 dentry->d_parent->d_name.name, dentry->d_name.name, 640 dentry->d_parent->d_name.name, dentry->d_name.name,
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 345aa5c0f382..00eee87510fe 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -122,19 +122,25 @@ ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_
122 return -EINVAL; 122 return -EINVAL;
123} 123}
124 124
125static void nfs_direct_dirty_pages(struct page **pages, int npages) 125static void nfs_direct_dirty_pages(struct page **pages, unsigned int pgbase, size_t count)
126{ 126{
127 int i; 127 unsigned int npages;
128 unsigned int i;
129
130 if (count == 0)
131 return;
132 pages += (pgbase >> PAGE_SHIFT);
133 npages = (count + (pgbase & ~PAGE_MASK) + PAGE_SIZE - 1) >> PAGE_SHIFT;
128 for (i = 0; i < npages; i++) { 134 for (i = 0; i < npages; i++) {
129 struct page *page = pages[i]; 135 struct page *page = pages[i];
130 if (!PageCompound(page)) 136 if (!PageCompound(page))
131 set_page_dirty_lock(page); 137 set_page_dirty(page);
132 } 138 }
133} 139}
134 140
135static void nfs_direct_release_pages(struct page **pages, int npages) 141static void nfs_direct_release_pages(struct page **pages, unsigned int npages)
136{ 142{
137 int i; 143 unsigned int i;
138 for (i = 0; i < npages; i++) 144 for (i = 0; i < npages; i++)
139 page_cache_release(pages[i]); 145 page_cache_release(pages[i]);
140} 146}
@@ -162,7 +168,7 @@ static inline struct nfs_direct_req *nfs_direct_req_alloc(void)
162 return dreq; 168 return dreq;
163} 169}
164 170
165static void nfs_direct_req_release(struct kref *kref) 171static void nfs_direct_req_free(struct kref *kref)
166{ 172{
167 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref); 173 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref);
168 174
@@ -171,6 +177,11 @@ static void nfs_direct_req_release(struct kref *kref)
171 kmem_cache_free(nfs_direct_cachep, dreq); 177 kmem_cache_free(nfs_direct_cachep, dreq);
172} 178}
173 179
180static void nfs_direct_req_release(struct nfs_direct_req *dreq)
181{
182 kref_put(&dreq->kref, nfs_direct_req_free);
183}
184
174/* 185/*
175 * Collects and returns the final error value/byte-count. 186 * Collects and returns the final error value/byte-count.
176 */ 187 */
@@ -190,7 +201,6 @@ static ssize_t nfs_direct_wait(struct nfs_direct_req *dreq)
190 result = dreq->count; 201 result = dreq->count;
191 202
192out: 203out:
193 kref_put(&dreq->kref, nfs_direct_req_release);
194 return (ssize_t) result; 204 return (ssize_t) result;
195} 205}
196 206
@@ -208,7 +218,7 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq)
208 } 218 }
209 complete_all(&dreq->completion); 219 complete_all(&dreq->completion);
210 220
211 kref_put(&dreq->kref, nfs_direct_req_release); 221 nfs_direct_req_release(dreq);
212} 222}
213 223
214/* 224/*
@@ -224,17 +234,18 @@ static void nfs_direct_read_result(struct rpc_task *task, void *calldata)
224 if (nfs_readpage_result(task, data) != 0) 234 if (nfs_readpage_result(task, data) != 0)
225 return; 235 return;
226 236
227 nfs_direct_dirty_pages(data->pagevec, data->npages);
228 nfs_direct_release_pages(data->pagevec, data->npages);
229
230 spin_lock(&dreq->lock); 237 spin_lock(&dreq->lock);
231 238 if (unlikely(task->tk_status < 0)) {
232 if (likely(task->tk_status >= 0))
233 dreq->count += data->res.count;
234 else
235 dreq->error = task->tk_status; 239 dreq->error = task->tk_status;
236 240 spin_unlock(&dreq->lock);
237 spin_unlock(&dreq->lock); 241 } else {
242 dreq->count += data->res.count;
243 spin_unlock(&dreq->lock);
244 nfs_direct_dirty_pages(data->pagevec,
245 data->args.pgbase,
246 data->res.count);
247 }
248 nfs_direct_release_pages(data->pagevec, data->npages);
238 249
239 if (put_dreq(dreq)) 250 if (put_dreq(dreq))
240 nfs_direct_complete(dreq); 251 nfs_direct_complete(dreq);
@@ -279,9 +290,12 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo
279 result = get_user_pages(current, current->mm, user_addr, 290 result = get_user_pages(current, current->mm, user_addr,
280 data->npages, 1, 0, data->pagevec, NULL); 291 data->npages, 1, 0, data->pagevec, NULL);
281 up_read(&current->mm->mmap_sem); 292 up_read(&current->mm->mmap_sem);
282 if (unlikely(result < data->npages)) { 293 if (result < 0) {
283 if (result > 0) 294 nfs_readdata_release(data);
284 nfs_direct_release_pages(data->pagevec, result); 295 break;
296 }
297 if ((unsigned)result < data->npages) {
298 nfs_direct_release_pages(data->pagevec, result);
285 nfs_readdata_release(data); 299 nfs_readdata_release(data);
286 break; 300 break;
287 } 301 }
@@ -359,6 +373,7 @@ static ssize_t nfs_direct_read(struct kiocb *iocb, unsigned long user_addr, size
359 if (!result) 373 if (!result)
360 result = nfs_direct_wait(dreq); 374 result = nfs_direct_wait(dreq);
361 rpc_clnt_sigunmask(clnt, &oldset); 375 rpc_clnt_sigunmask(clnt, &oldset);
376 nfs_direct_req_release(dreq);
362 377
363 return result; 378 return result;
364} 379}
@@ -610,9 +625,12 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l
610 result = get_user_pages(current, current->mm, user_addr, 625 result = get_user_pages(current, current->mm, user_addr,
611 data->npages, 0, 0, data->pagevec, NULL); 626 data->npages, 0, 0, data->pagevec, NULL);
612 up_read(&current->mm->mmap_sem); 627 up_read(&current->mm->mmap_sem);
613 if (unlikely(result < data->npages)) { 628 if (result < 0) {
614 if (result > 0) 629 nfs_writedata_release(data);
615 nfs_direct_release_pages(data->pagevec, result); 630 break;
631 }
632 if ((unsigned)result < data->npages) {
633 nfs_direct_release_pages(data->pagevec, result);
616 nfs_writedata_release(data); 634 nfs_writedata_release(data);
617 break; 635 break;
618 } 636 }
@@ -703,6 +721,7 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, siz
703 if (!result) 721 if (!result)
704 result = nfs_direct_wait(dreq); 722 result = nfs_direct_wait(dreq);
705 rpc_clnt_sigunmask(clnt, &oldset); 723 rpc_clnt_sigunmask(clnt, &oldset);
724 nfs_direct_req_release(dreq);
706 725
707 return result; 726 return result;
708} 727}
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 5eaee6dd040b..9eb8eb4e4a08 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -27,6 +27,7 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/pagemap.h> 28#include <linux/pagemap.h>
29#include <linux/smp_lock.h> 29#include <linux/smp_lock.h>
30#include <linux/aio.h>
30 31
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/system.h> 33#include <asm/system.h>
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 2a3fd9573207..bd9f5a836592 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -15,7 +15,7 @@
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h> 17#include <linux/init.h>
18 18#include <linux/sched.h>
19#include <linux/time.h> 19#include <linux/time.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
@@ -1164,21 +1164,19 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
1164{ 1164{
1165 struct nfs_inode *nfsi = (struct nfs_inode *) foo; 1165 struct nfs_inode *nfsi = (struct nfs_inode *) foo;
1166 1166
1167 if (flags & SLAB_CTOR_CONSTRUCTOR) { 1167 inode_init_once(&nfsi->vfs_inode);
1168 inode_init_once(&nfsi->vfs_inode); 1168 spin_lock_init(&nfsi->req_lock);
1169 spin_lock_init(&nfsi->req_lock); 1169 INIT_LIST_HEAD(&nfsi->dirty);
1170 INIT_LIST_HEAD(&nfsi->dirty); 1170 INIT_LIST_HEAD(&nfsi->commit);
1171 INIT_LIST_HEAD(&nfsi->commit); 1171 INIT_LIST_HEAD(&nfsi->open_files);
1172 INIT_LIST_HEAD(&nfsi->open_files); 1172 INIT_LIST_HEAD(&nfsi->access_cache_entry_lru);
1173 INIT_LIST_HEAD(&nfsi->access_cache_entry_lru); 1173 INIT_LIST_HEAD(&nfsi->access_cache_inode_lru);
1174 INIT_LIST_HEAD(&nfsi->access_cache_inode_lru); 1174 INIT_RADIX_TREE(&nfsi->nfs_page_tree, GFP_ATOMIC);
1175 INIT_RADIX_TREE(&nfsi->nfs_page_tree, GFP_ATOMIC); 1175 atomic_set(&nfsi->data_updates, 0);
1176 atomic_set(&nfsi->data_updates, 0); 1176 nfsi->ndirty = 0;
1177 nfsi->ndirty = 0; 1177 nfsi->ncommit = 0;
1178 nfsi->ncommit = 0; 1178 nfsi->npages = 0;
1179 nfsi->npages = 0; 1179 nfs4_init_once(nfsi);
1180 nfs4_init_once(nfsi);
1181 }
1182} 1180}
1183 1181
1184static int __init nfs_init_inodecache(void) 1182static int __init nfs_init_inodecache(void)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index d6a30e965787..648e0ac0f90e 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -790,7 +790,7 @@ out:
790 return -EACCES; 790 return -EACCES;
791} 791}
792 792
793int nfs4_recover_expired_lease(struct nfs_server *server) 793static int nfs4_recover_expired_lease(struct nfs_server *server)
794{ 794{
795 struct nfs_client *clp = server->nfs_client; 795 struct nfs_client *clp = server->nfs_client;
796 int ret; 796 int ret;
@@ -2748,7 +2748,7 @@ static int nfs4_delay(struct rpc_clnt *clnt, long *timeout)
2748/* This is the error handling routine for processes that are allowed 2748/* This is the error handling routine for processes that are allowed
2749 * to sleep. 2749 * to sleep.
2750 */ 2750 */
2751int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception) 2751static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception)
2752{ 2752{
2753 struct nfs_client *clp = server->nfs_client; 2753 struct nfs_client *clp = server->nfs_client;
2754 int ret = errorcode; 2754 int ret = errorcode;
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 5fffbdfa971f..8ed79d5c54f9 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -104,7 +104,7 @@ struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp)
104 return cred; 104 return cred;
105} 105}
106 106
107struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp) 107static struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp)
108{ 108{
109 struct nfs4_state_owner *sp; 109 struct nfs4_state_owner *sp;
110 110
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 938f37166788..8003c91ccb9a 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -646,10 +646,10 @@ static int encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg)
646{ 646{
647 __be32 *p; 647 __be32 *p;
648 648
649 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 649 RESERVE_SPACE(8+NFS4_STATEID_SIZE);
650 WRITE32(OP_CLOSE); 650 WRITE32(OP_CLOSE);
651 WRITE32(arg->seqid->sequence->counter); 651 WRITE32(arg->seqid->sequence->counter);
652 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data)); 652 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
653 653
654 return 0; 654 return 0;
655} 655}
@@ -793,17 +793,17 @@ static int encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args)
793 WRITE64(nfs4_lock_length(args->fl)); 793 WRITE64(nfs4_lock_length(args->fl));
794 WRITE32(args->new_lock_owner); 794 WRITE32(args->new_lock_owner);
795 if (args->new_lock_owner){ 795 if (args->new_lock_owner){
796 RESERVE_SPACE(40); 796 RESERVE_SPACE(4+NFS4_STATEID_SIZE+20);
797 WRITE32(args->open_seqid->sequence->counter); 797 WRITE32(args->open_seqid->sequence->counter);
798 WRITEMEM(args->open_stateid->data, sizeof(args->open_stateid->data)); 798 WRITEMEM(args->open_stateid->data, NFS4_STATEID_SIZE);
799 WRITE32(args->lock_seqid->sequence->counter); 799 WRITE32(args->lock_seqid->sequence->counter);
800 WRITE64(args->lock_owner.clientid); 800 WRITE64(args->lock_owner.clientid);
801 WRITE32(4); 801 WRITE32(4);
802 WRITE32(args->lock_owner.id); 802 WRITE32(args->lock_owner.id);
803 } 803 }
804 else { 804 else {
805 RESERVE_SPACE(20); 805 RESERVE_SPACE(NFS4_STATEID_SIZE+4);
806 WRITEMEM(args->lock_stateid->data, sizeof(args->lock_stateid->data)); 806 WRITEMEM(args->lock_stateid->data, NFS4_STATEID_SIZE);
807 WRITE32(args->lock_seqid->sequence->counter); 807 WRITE32(args->lock_seqid->sequence->counter);
808 } 808 }
809 809
@@ -830,11 +830,11 @@ static int encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *arg
830{ 830{
831 __be32 *p; 831 __be32 *p;
832 832
833 RESERVE_SPACE(44); 833 RESERVE_SPACE(12+NFS4_STATEID_SIZE+16);
834 WRITE32(OP_LOCKU); 834 WRITE32(OP_LOCKU);
835 WRITE32(nfs4_lock_type(args->fl, 0)); 835 WRITE32(nfs4_lock_type(args->fl, 0));
836 WRITE32(args->seqid->sequence->counter); 836 WRITE32(args->seqid->sequence->counter);
837 WRITEMEM(args->stateid->data, sizeof(args->stateid->data)); 837 WRITEMEM(args->stateid->data, NFS4_STATEID_SIZE);
838 WRITE64(args->fl->fl_start); 838 WRITE64(args->fl->fl_start);
839 WRITE64(nfs4_lock_length(args->fl)); 839 WRITE64(nfs4_lock_length(args->fl));
840 840
@@ -966,9 +966,9 @@ static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struc
966{ 966{
967 __be32 *p; 967 __be32 *p;
968 968
969 RESERVE_SPACE(4+sizeof(stateid->data)); 969 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
970 WRITE32(NFS4_OPEN_CLAIM_DELEGATE_CUR); 970 WRITE32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
971 WRITEMEM(stateid->data, sizeof(stateid->data)); 971 WRITEMEM(stateid->data, NFS4_STATEID_SIZE);
972 encode_string(xdr, name->len, name->name); 972 encode_string(xdr, name->len, name->name);
973} 973}
974 974
@@ -996,9 +996,9 @@ static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_con
996{ 996{
997 __be32 *p; 997 __be32 *p;
998 998
999 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 999 RESERVE_SPACE(4+NFS4_STATEID_SIZE+4);
1000 WRITE32(OP_OPEN_CONFIRM); 1000 WRITE32(OP_OPEN_CONFIRM);
1001 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data)); 1001 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
1002 WRITE32(arg->seqid->sequence->counter); 1002 WRITE32(arg->seqid->sequence->counter);
1003 1003
1004 return 0; 1004 return 0;
@@ -1008,9 +1008,9 @@ static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closea
1008{ 1008{
1009 __be32 *p; 1009 __be32 *p;
1010 1010
1011 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 1011 RESERVE_SPACE(4+NFS4_STATEID_SIZE+4);
1012 WRITE32(OP_OPEN_DOWNGRADE); 1012 WRITE32(OP_OPEN_DOWNGRADE);
1013 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data)); 1013 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
1014 WRITE32(arg->seqid->sequence->counter); 1014 WRITE32(arg->seqid->sequence->counter);
1015 encode_share_access(xdr, arg->open_flags); 1015 encode_share_access(xdr, arg->open_flags);
1016 return 0; 1016 return 0;
@@ -1045,12 +1045,12 @@ static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context
1045 nfs4_stateid stateid; 1045 nfs4_stateid stateid;
1046 __be32 *p; 1046 __be32 *p;
1047 1047
1048 RESERVE_SPACE(16); 1048 RESERVE_SPACE(NFS4_STATEID_SIZE);
1049 if (ctx->state != NULL) { 1049 if (ctx->state != NULL) {
1050 nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner); 1050 nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner);
1051 WRITEMEM(stateid.data, sizeof(stateid.data)); 1051 WRITEMEM(stateid.data, NFS4_STATEID_SIZE);
1052 } else 1052 } else
1053 WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data)); 1053 WRITEMEM(zero_stateid.data, NFS4_STATEID_SIZE);
1054} 1054}
1055 1055
1056static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args) 1056static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args)
@@ -1079,10 +1079,10 @@ static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
1079 int replen; 1079 int replen;
1080 __be32 *p; 1080 __be32 *p;
1081 1081
1082 RESERVE_SPACE(32+sizeof(nfs4_verifier)); 1082 RESERVE_SPACE(12+NFS4_VERIFIER_SIZE+20);
1083 WRITE32(OP_READDIR); 1083 WRITE32(OP_READDIR);
1084 WRITE64(readdir->cookie); 1084 WRITE64(readdir->cookie);
1085 WRITEMEM(readdir->verifier.data, sizeof(readdir->verifier.data)); 1085 WRITEMEM(readdir->verifier.data, NFS4_VERIFIER_SIZE);
1086 WRITE32(readdir->count >> 1); /* We're not doing readdirplus */ 1086 WRITE32(readdir->count >> 1); /* We're not doing readdirplus */
1087 WRITE32(readdir->count); 1087 WRITE32(readdir->count);
1088 WRITE32(2); 1088 WRITE32(2);
@@ -1190,9 +1190,9 @@ encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg)
1190{ 1190{
1191 __be32 *p; 1191 __be32 *p;
1192 1192
1193 RESERVE_SPACE(4+sizeof(zero_stateid.data)); 1193 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1194 WRITE32(OP_SETATTR); 1194 WRITE32(OP_SETATTR);
1195 WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data)); 1195 WRITEMEM(zero_stateid.data, NFS4_STATEID_SIZE);
1196 RESERVE_SPACE(2*4); 1196 RESERVE_SPACE(2*4);
1197 WRITE32(1); 1197 WRITE32(1);
1198 WRITE32(FATTR4_WORD0_ACL); 1198 WRITE32(FATTR4_WORD0_ACL);
@@ -1220,9 +1220,9 @@ static int encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *
1220 int status; 1220 int status;
1221 __be32 *p; 1221 __be32 *p;
1222 1222
1223 RESERVE_SPACE(4+sizeof(arg->stateid.data)); 1223 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1224 WRITE32(OP_SETATTR); 1224 WRITE32(OP_SETATTR);
1225 WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data)); 1225 WRITEMEM(arg->stateid.data, NFS4_STATEID_SIZE);
1226 1226
1227 if ((status = encode_attrs(xdr, arg->iap, server))) 1227 if ((status = encode_attrs(xdr, arg->iap, server)))
1228 return status; 1228 return status;
@@ -1234,9 +1234,9 @@ static int encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclien
1234{ 1234{
1235 __be32 *p; 1235 __be32 *p;
1236 1236
1237 RESERVE_SPACE(4 + sizeof(setclientid->sc_verifier->data)); 1237 RESERVE_SPACE(4 + NFS4_VERIFIER_SIZE);
1238 WRITE32(OP_SETCLIENTID); 1238 WRITE32(OP_SETCLIENTID);
1239 WRITEMEM(setclientid->sc_verifier->data, sizeof(setclientid->sc_verifier->data)); 1239 WRITEMEM(setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE);
1240 1240
1241 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); 1241 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name);
1242 RESERVE_SPACE(4); 1242 RESERVE_SPACE(4);
@@ -1253,10 +1253,10 @@ static int encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_c
1253{ 1253{
1254 __be32 *p; 1254 __be32 *p;
1255 1255
1256 RESERVE_SPACE(12 + sizeof(client_state->cl_confirm.data)); 1256 RESERVE_SPACE(12 + NFS4_VERIFIER_SIZE);
1257 WRITE32(OP_SETCLIENTID_CONFIRM); 1257 WRITE32(OP_SETCLIENTID_CONFIRM);
1258 WRITE64(client_state->cl_clientid); 1258 WRITE64(client_state->cl_clientid);
1259 WRITEMEM(client_state->cl_confirm.data, sizeof(client_state->cl_confirm.data)); 1259 WRITEMEM(client_state->cl_confirm.data, NFS4_VERIFIER_SIZE);
1260 1260
1261 return 0; 1261 return 0;
1262} 1262}
@@ -1284,10 +1284,10 @@ static int encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *statei
1284{ 1284{
1285 __be32 *p; 1285 __be32 *p;
1286 1286
1287 RESERVE_SPACE(20); 1287 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1288 1288
1289 WRITE32(OP_DELEGRETURN); 1289 WRITE32(OP_DELEGRETURN);
1290 WRITEMEM(stateid->data, sizeof(stateid->data)); 1290 WRITEMEM(stateid->data, NFS4_STATEID_SIZE);
1291 return 0; 1291 return 0;
1292 1292
1293} 1293}
@@ -2494,7 +2494,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
2494 int i; 2494 int i;
2495 dprintk("%s: using first %d of %d servers returned for location %d\n", __FUNCTION__, NFS4_FS_LOCATION_MAXSERVERS, m, res->nlocations); 2495 dprintk("%s: using first %d of %d servers returned for location %d\n", __FUNCTION__, NFS4_FS_LOCATION_MAXSERVERS, m, res->nlocations);
2496 for (i = loc->nservers; i < m; i++) { 2496 for (i = loc->nservers; i < m; i++) {
2497 int len; 2497 unsigned int len;
2498 char *data; 2498 char *data;
2499 status = decode_opaque_inline(xdr, &len, &data); 2499 status = decode_opaque_inline(xdr, &len, &data);
2500 if (unlikely(status != 0)) 2500 if (unlikely(status != 0))
@@ -2642,7 +2642,7 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t
2642 return 0; 2642 return 0;
2643} 2643}
2644 2644
2645static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, int32_t *uid) 2645static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, uint32_t *uid)
2646{ 2646{
2647 uint32_t len; 2647 uint32_t len;
2648 __be32 *p; 2648 __be32 *p;
@@ -2667,7 +2667,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nf
2667 return 0; 2667 return 0;
2668} 2668}
2669 2669
2670static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, int32_t *gid) 2670static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_client *clp, uint32_t *gid)
2671{ 2671{
2672 uint32_t len; 2672 uint32_t len;
2673 __be32 *p; 2673 __be32 *p;
@@ -2897,8 +2897,8 @@ static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
2897 status = decode_op_hdr(xdr, OP_CLOSE); 2897 status = decode_op_hdr(xdr, OP_CLOSE);
2898 if (status) 2898 if (status)
2899 return status; 2899 return status;
2900 READ_BUF(sizeof(res->stateid.data)); 2900 READ_BUF(NFS4_STATEID_SIZE);
2901 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 2901 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
2902 return 0; 2902 return 0;
2903} 2903}
2904 2904
@@ -3186,8 +3186,8 @@ static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
3186 3186
3187 status = decode_op_hdr(xdr, OP_LOCK); 3187 status = decode_op_hdr(xdr, OP_LOCK);
3188 if (status == 0) { 3188 if (status == 0) {
3189 READ_BUF(sizeof(res->stateid.data)); 3189 READ_BUF(NFS4_STATEID_SIZE);
3190 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3190 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3191 } else if (status == -NFS4ERR_DENIED) 3191 } else if (status == -NFS4ERR_DENIED)
3192 return decode_lock_denied(xdr, NULL); 3192 return decode_lock_denied(xdr, NULL);
3193 return status; 3193 return status;
@@ -3209,8 +3209,8 @@ static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
3209 3209
3210 status = decode_op_hdr(xdr, OP_LOCKU); 3210 status = decode_op_hdr(xdr, OP_LOCKU);
3211 if (status == 0) { 3211 if (status == 0) {
3212 READ_BUF(sizeof(res->stateid.data)); 3212 READ_BUF(NFS4_STATEID_SIZE);
3213 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3213 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3214 } 3214 }
3215 return status; 3215 return status;
3216} 3216}
@@ -3251,8 +3251,8 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
3251 res->delegation_type = 0; 3251 res->delegation_type = 0;
3252 return 0; 3252 return 0;
3253 } 3253 }
3254 READ_BUF(20); 3254 READ_BUF(NFS4_STATEID_SIZE+4);
3255 COPYMEM(res->delegation.data, sizeof(res->delegation.data)); 3255 COPYMEM(res->delegation.data, NFS4_STATEID_SIZE);
3256 READ32(res->do_recall); 3256 READ32(res->do_recall);
3257 switch (delegation_type) { 3257 switch (delegation_type) {
3258 case NFS4_OPEN_DELEGATE_READ: 3258 case NFS4_OPEN_DELEGATE_READ:
@@ -3275,8 +3275,8 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
3275 status = decode_op_hdr(xdr, OP_OPEN); 3275 status = decode_op_hdr(xdr, OP_OPEN);
3276 if (status) 3276 if (status)
3277 return status; 3277 return status;
3278 READ_BUF(sizeof(res->stateid.data)); 3278 READ_BUF(NFS4_STATEID_SIZE);
3279 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3279 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3280 3280
3281 decode_change_info(xdr, &res->cinfo); 3281 decode_change_info(xdr, &res->cinfo);
3282 3282
@@ -3302,8 +3302,8 @@ static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmre
3302 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); 3302 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
3303 if (status) 3303 if (status)
3304 return status; 3304 return status;
3305 READ_BUF(sizeof(res->stateid.data)); 3305 READ_BUF(NFS4_STATEID_SIZE);
3306 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3306 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3307 return 0; 3307 return 0;
3308} 3308}
3309 3309
@@ -3315,8 +3315,8 @@ static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *re
3315 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); 3315 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
3316 if (status) 3316 if (status)
3317 return status; 3317 return status;
3318 READ_BUF(sizeof(res->stateid.data)); 3318 READ_BUF(NFS4_STATEID_SIZE);
3319 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3319 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3320 return 0; 3320 return 0;
3321} 3321}
3322 3322
@@ -3590,9 +3590,9 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp)
3590 } 3590 }
3591 READ32(nfserr); 3591 READ32(nfserr);
3592 if (nfserr == NFS_OK) { 3592 if (nfserr == NFS_OK) {
3593 READ_BUF(8 + sizeof(clp->cl_confirm.data)); 3593 READ_BUF(8 + NFS4_VERIFIER_SIZE);
3594 READ64(clp->cl_clientid); 3594 READ64(clp->cl_clientid);
3595 COPYMEM(clp->cl_confirm.data, sizeof(clp->cl_confirm.data)); 3595 COPYMEM(clp->cl_confirm.data, NFS4_VERIFIER_SIZE);
3596 } else if (nfserr == NFSERR_CLID_INUSE) { 3596 } else if (nfserr == NFSERR_CLID_INUSE) {
3597 uint32_t len; 3597 uint32_t len;
3598 3598
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index e12054c86d0d..c5bb51a29e80 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/file.h> 13#include <linux/file.h>
14#include <linux/sched.h>
14#include <linux/sunrpc/clnt.h> 15#include <linux/sunrpc/clnt.h>
15#include <linux/nfs3.h> 16#include <linux/nfs3.h>
16#include <linux/nfs4.h> 17#include <linux/nfs4.h>
@@ -354,6 +355,26 @@ void nfs_pageio_complete(struct nfs_pageio_descriptor *desc)
354 nfs_pageio_doio(desc); 355 nfs_pageio_doio(desc);
355} 356}
356 357
358/**
359 * nfs_pageio_cond_complete - Conditional I/O completion
360 * @desc: pointer to io descriptor
361 * @index: page index
362 *
363 * It is important to ensure that processes don't try to take locks
364 * on non-contiguous ranges of pages as that might deadlock. This
365 * function should be called before attempting to wait on a locked
366 * nfs_page. It will complete the I/O if the page index 'index'
367 * is not contiguous with the existing list of pages in 'desc'.
368 */
369void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *desc, pgoff_t index)
370{
371 if (!list_empty(&desc->pg_list)) {
372 struct nfs_page *prev = nfs_list_entry(desc->pg_list.prev);
373 if (index != prev->wb_index + 1)
374 nfs_pageio_doio(desc);
375 }
376}
377
357#define NFS_SCAN_MAXENTRIES 16 378#define NFS_SCAN_MAXENTRIES 16
358/** 379/**
359 * nfs_scan_list - Scan a list for matching requests 380 * nfs_scan_list - Scan a list for matching requests
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 9a55807b2a70..7bd7cb95c034 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -79,7 +79,7 @@ void nfs_readdata_release(void *data)
79static 79static
80int nfs_return_empty_page(struct page *page) 80int nfs_return_empty_page(struct page *page)
81{ 81{
82 memclear_highpage_flush(page, 0, PAGE_CACHE_SIZE); 82 zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
83 SetPageUptodate(page); 83 SetPageUptodate(page);
84 unlock_page(page); 84 unlock_page(page);
85 return 0; 85 return 0;
@@ -103,10 +103,10 @@ static void nfs_readpage_truncate_uninitialised_page(struct nfs_read_data *data)
103 pglen = PAGE_CACHE_SIZE - base; 103 pglen = PAGE_CACHE_SIZE - base;
104 for (;;) { 104 for (;;) {
105 if (remainder <= pglen) { 105 if (remainder <= pglen) {
106 memclear_highpage_flush(*pages, base, remainder); 106 zero_user_page(*pages, base, remainder, KM_USER0);
107 break; 107 break;
108 } 108 }
109 memclear_highpage_flush(*pages, base, pglen); 109 zero_user_page(*pages, base, pglen, KM_USER0);
110 pages++; 110 pages++;
111 remainder -= pglen; 111 remainder -= pglen;
112 pglen = PAGE_CACHE_SIZE; 112 pglen = PAGE_CACHE_SIZE;
@@ -130,7 +130,7 @@ static int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
130 return PTR_ERR(new); 130 return PTR_ERR(new);
131 } 131 }
132 if (len < PAGE_CACHE_SIZE) 132 if (len < PAGE_CACHE_SIZE)
133 memclear_highpage_flush(page, len, PAGE_CACHE_SIZE - len); 133 zero_user_page(page, len, PAGE_CACHE_SIZE - len, KM_USER0);
134 134
135 nfs_list_add_request(new, &one_request); 135 nfs_list_add_request(new, &one_request);
136 if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE) 136 if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE)
@@ -532,7 +532,7 @@ readpage_async_filler(void *data, struct page *page)
532 return PTR_ERR(new); 532 return PTR_ERR(new);
533 } 533 }
534 if (len < PAGE_CACHE_SIZE) 534 if (len < PAGE_CACHE_SIZE)
535 memclear_highpage_flush(page, len, PAGE_CACHE_SIZE - len); 535 zero_user_page(page, len, PAGE_CACHE_SIZE - len, KM_USER0);
536 nfs_pageio_add_request(desc->pgio, new); 536 nfs_pageio_add_request(desc->pgio, new);
537 return 0; 537 return 0;
538} 538}
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index de92b9509d94..af344a158e01 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -58,7 +58,7 @@ struct nfs_write_data *nfs_commit_alloc(void)
58 return p; 58 return p;
59} 59}
60 60
61void nfs_commit_rcu_free(struct rcu_head *head) 61static void nfs_commit_rcu_free(struct rcu_head *head)
62{ 62{
63 struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu); 63 struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu);
64 if (p && (p->pagevec != &p->page_array[0])) 64 if (p && (p->pagevec != &p->page_array[0]))
@@ -168,7 +168,7 @@ static void nfs_mark_uptodate(struct page *page, unsigned int base, unsigned int
168 if (count != nfs_page_length(page)) 168 if (count != nfs_page_length(page))
169 return; 169 return;
170 if (count != PAGE_CACHE_SIZE) 170 if (count != PAGE_CACHE_SIZE)
171 memclear_highpage_flush(page, count, PAGE_CACHE_SIZE - count); 171 zero_user_page(page, count, PAGE_CACHE_SIZE - count, KM_USER0);
172 SetPageUptodate(page); 172 SetPageUptodate(page);
173} 173}
174 174
@@ -273,8 +273,6 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
273 * request as dirty (in which case we don't care). 273 * request as dirty (in which case we don't care).
274 */ 274 */
275 spin_unlock(req_lock); 275 spin_unlock(req_lock);
276 /* Prevent deadlock! */
277 nfs_pageio_complete(pgio);
278 ret = nfs_wait_on_request(req); 276 ret = nfs_wait_on_request(req);
279 nfs_release_request(req); 277 nfs_release_request(req);
280 if (ret != 0) 278 if (ret != 0)
@@ -321,6 +319,8 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc
321 pgio = &mypgio; 319 pgio = &mypgio;
322 } 320 }
323 321
322 nfs_pageio_cond_complete(pgio, page->index);
323
324 err = nfs_page_async_flush(pgio, page); 324 err = nfs_page_async_flush(pgio, page);
325 if (err <= 0) 325 if (err <= 0)
326 goto out; 326 goto out;
@@ -329,6 +329,8 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc
329 if (!offset) 329 if (!offset)
330 goto out; 330 goto out;
331 331
332 nfs_pageio_cond_complete(pgio, page->index);
333
332 ctx = nfs_find_open_context(inode, NULL, FMODE_WRITE); 334 ctx = nfs_find_open_context(inode, NULL, FMODE_WRITE);
333 if (ctx == NULL) { 335 if (ctx == NULL) {
334 err = -EBADF; 336 err = -EBADF;
@@ -922,7 +924,7 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i
922 return 0; 924 return 0;
923 out_bad: 925 out_bad:
924 while (!list_empty(head)) { 926 while (!list_empty(head)) {
925 struct nfs_page *req = nfs_list_entry(head->next); 927 req = nfs_list_entry(head->next);
926 nfs_list_remove_request(req); 928 nfs_list_remove_request(req);
927 nfs_redirty_request(req); 929 nfs_redirty_request(req);
928 nfs_end_page_writeback(req->wb_page); 930 nfs_end_page_writeback(req->wb_page);
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 32ffea033c7a..864090edc28b 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -38,6 +38,7 @@
38#include <linux/inet.h> 38#include <linux/inet.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/sched.h>
41#include <linux/sunrpc/xdr.h> 42#include <linux/sunrpc/xdr.h>
42#include <linux/sunrpc/svc.h> 43#include <linux/sunrpc/svc.h>
43#include <linux/sunrpc/clnt.h> 44#include <linux/sunrpc/clnt.h>
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index c7774e3a9469..ebd03cc07479 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -45,7 +45,7 @@
45#include <asm/uaccess.h> 45#include <asm/uaccess.h>
46#include <asm/scatterlist.h> 46#include <asm/scatterlist.h>
47#include <linux/crypto.h> 47#include <linux/crypto.h>
48 48#include <linux/sched.h>
49 49
50#define NFSDDBG_FACILITY NFSDDBG_PROC 50#define NFSDDBG_FACILITY NFSDDBG_PROC
51 51
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index d7759ce6ed94..ff55950efb43 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -9,7 +9,7 @@
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12 12#include <linux/sched.h>
13#include <linux/time.h> 13#include <linux/time.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/nfs.h> 15#include <linux/nfs.h>
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 39a1669506bd..7ed56390b582 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -26,6 +26,7 @@
26#include <linux/swap.h> 26#include <linux/swap.h>
27#include <linux/uio.h> 27#include <linux/uio.h>
28#include <linux/writeback.h> 28#include <linux/writeback.h>
29#include <linux/sched.h>
29 30
30#include <asm/page.h> 31#include <asm/page.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 21d834e5ed73..4566b9182551 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3085,8 +3085,7 @@ static void ntfs_big_inode_init_once(void *foo, struct kmem_cache *cachep,
3085{ 3085{
3086 ntfs_inode *ni = (ntfs_inode *)foo; 3086 ntfs_inode *ni = (ntfs_inode *)foo;
3087 3087
3088 if (flags & SLAB_CTOR_CONSTRUCTOR) 3088 inode_init_once(VFS_I(ni));
3089 inode_init_once(VFS_I(ni));
3090} 3089}
3091 3090
3092/* 3091/*
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 8e7cafb5fc6c..0023b31e48a8 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -222,7 +222,10 @@ static int ocfs2_readpage(struct file *file, struct page *page)
222 goto out; 222 goto out;
223 } 223 }
224 224
225 down_read(&OCFS2_I(inode)->ip_alloc_sem); 225 if (down_read_trylock(&OCFS2_I(inode)->ip_alloc_sem) == 0) {
226 ret = AOP_TRUNCATED_PAGE;
227 goto out_meta_unlock;
228 }
226 229
227 /* 230 /*
228 * i_size might have just been updated as we grabed the meta lock. We 231 * i_size might have just been updated as we grabed the meta lock. We
@@ -235,10 +238,7 @@ static int ocfs2_readpage(struct file *file, struct page *page)
235 * XXX sys_readahead() seems to get that wrong? 238 * XXX sys_readahead() seems to get that wrong?
236 */ 239 */
237 if (start >= i_size_read(inode)) { 240 if (start >= i_size_read(inode)) {
238 char *addr = kmap(page); 241 zero_user_page(page, 0, PAGE_SIZE, KM_USER0);
239 memset(addr, 0, PAGE_SIZE);
240 flush_dcache_page(page);
241 kunmap(page);
242 SetPageUptodate(page); 242 SetPageUptodate(page);
243 ret = 0; 243 ret = 0;
244 goto out_alloc; 244 goto out_alloc;
@@ -258,6 +258,7 @@ static int ocfs2_readpage(struct file *file, struct page *page)
258 ocfs2_data_unlock(inode, 0); 258 ocfs2_data_unlock(inode, 0);
259out_alloc: 259out_alloc:
260 up_read(&OCFS2_I(inode)->ip_alloc_sem); 260 up_read(&OCFS2_I(inode)->ip_alloc_sem);
261out_meta_unlock:
261 ocfs2_meta_unlock(inode, 0); 262 ocfs2_meta_unlock(inode, 0);
262out: 263out:
263 if (unlock) 264 if (unlock)
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index 5671cf9d6383..fd8cb1badc9b 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -262,12 +262,10 @@ static void dlmfs_init_once(void *foo,
262 struct dlmfs_inode_private *ip = 262 struct dlmfs_inode_private *ip =
263 (struct dlmfs_inode_private *) foo; 263 (struct dlmfs_inode_private *) foo;
264 264
265 if (flags & SLAB_CTOR_CONSTRUCTOR) { 265 ip->ip_dlm = NULL;
266 ip->ip_dlm = NULL; 266 ip->ip_parent = NULL;
267 ip->ip_parent = NULL;
268 267
269 inode_init_once(&ip->ip_vfs_inode); 268 inode_init_once(&ip->ip_vfs_inode);
270 }
271} 269}
272 270
273static struct inode *dlmfs_alloc_inode(struct super_block *sb) 271static struct inode *dlmfs_alloc_inode(struct super_block *sb)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 9395b4fa547d..ac6c96431bbc 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -326,6 +326,7 @@ static int ocfs2_truncate_file(struct inode *inode,
326 (unsigned long long)OCFS2_I(inode)->ip_blkno, 326 (unsigned long long)OCFS2_I(inode)->ip_blkno,
327 (unsigned long long)new_i_size); 327 (unsigned long long)new_i_size);
328 328
329 unmap_mapping_range(inode->i_mapping, new_i_size + PAGE_SIZE - 1, 0, 1);
329 truncate_inode_pages(inode->i_mapping, new_i_size); 330 truncate_inode_pages(inode->i_mapping, new_i_size);
330 331
331 fe = (struct ocfs2_dinode *) di_bh->b_data; 332 fe = (struct ocfs2_dinode *) di_bh->b_data;
@@ -1418,36 +1419,6 @@ out:
1418 return total ? total : ret; 1419 return total ? total : ret;
1419} 1420}
1420 1421
1421static int ocfs2_check_iovec(const struct iovec *iov, size_t *counted,
1422 unsigned long *nr_segs)
1423{
1424 size_t ocount; /* original count */
1425 unsigned long seg;
1426
1427 ocount = 0;
1428 for (seg = 0; seg < *nr_segs; seg++) {
1429 const struct iovec *iv = &iov[seg];
1430
1431 /*
1432 * If any segment has a negative length, or the cumulative
1433 * length ever wraps negative then return -EINVAL.
1434 */
1435 ocount += iv->iov_len;
1436 if (unlikely((ssize_t)(ocount|iv->iov_len) < 0))
1437 return -EINVAL;
1438 if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len))
1439 continue;
1440 if (seg == 0)
1441 return -EFAULT;
1442 *nr_segs = seg;
1443 ocount -= iv->iov_len; /* This segment is no good */
1444 break;
1445 }
1446
1447 *counted = ocount;
1448 return 0;
1449}
1450
1451static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, 1422static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1452 const struct iovec *iov, 1423 const struct iovec *iov,
1453 unsigned long nr_segs, 1424 unsigned long nr_segs,
@@ -1470,7 +1441,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1470 if (iocb->ki_left == 0) 1441 if (iocb->ki_left == 0)
1471 return 0; 1442 return 0;
1472 1443
1473 ret = ocfs2_check_iovec(iov, &ocount, &nr_segs); 1444 ret = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ);
1474 if (ret) 1445 if (ret)
1475 return ret; 1446 return ret;
1476 1447
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 4dedd9789108..545f7892cdf3 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -471,9 +471,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
471 471
472 mutex_lock(&local_alloc_inode->i_mutex); 472 mutex_lock(&local_alloc_inode->i_mutex);
473 473
474 ac->ac_inode = local_alloc_inode;
475 ac->ac_which = OCFS2_AC_USE_LOCAL;
476
477 if (osb->local_alloc_state != OCFS2_LA_ENABLED) { 474 if (osb->local_alloc_state != OCFS2_LA_ENABLED) {
478 status = -ENOSPC; 475 status = -ENOSPC;
479 goto bail; 476 goto bail;
@@ -511,10 +508,14 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
511 } 508 }
512 } 509 }
513 510
511 ac->ac_inode = local_alloc_inode;
512 ac->ac_which = OCFS2_AC_USE_LOCAL;
514 get_bh(osb->local_alloc_bh); 513 get_bh(osb->local_alloc_bh);
515 ac->ac_bh = osb->local_alloc_bh; 514 ac->ac_bh = osb->local_alloc_bh;
516 status = 0; 515 status = 0;
517bail: 516bail:
517 if (status < 0 && local_alloc_inode)
518 iput(local_alloc_inode);
518 519
519 mlog_exit(status); 520 mlog_exit(status);
520 return status; 521 return status;
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 7c5e3f5d6634..86b559c7dce9 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -937,31 +937,29 @@ static void ocfs2_inode_init_once(void *data,
937{ 937{
938 struct ocfs2_inode_info *oi = data; 938 struct ocfs2_inode_info *oi = data;
939 939
940 if (flags & SLAB_CTOR_CONSTRUCTOR) { 940 oi->ip_flags = 0;
941 oi->ip_flags = 0; 941 oi->ip_open_count = 0;
942 oi->ip_open_count = 0; 942 spin_lock_init(&oi->ip_lock);
943 spin_lock_init(&oi->ip_lock); 943 ocfs2_extent_map_init(&oi->vfs_inode);
944 ocfs2_extent_map_init(&oi->vfs_inode); 944 INIT_LIST_HEAD(&oi->ip_io_markers);
945 INIT_LIST_HEAD(&oi->ip_io_markers); 945 oi->ip_created_trans = 0;
946 oi->ip_created_trans = 0; 946 oi->ip_last_trans = 0;
947 oi->ip_last_trans = 0; 947 oi->ip_dir_start_lookup = 0;
948 oi->ip_dir_start_lookup = 0;
949 948
950 init_rwsem(&oi->ip_alloc_sem); 949 init_rwsem(&oi->ip_alloc_sem);
951 mutex_init(&oi->ip_io_mutex); 950 mutex_init(&oi->ip_io_mutex);
952 951
953 oi->ip_blkno = 0ULL; 952 oi->ip_blkno = 0ULL;
954 oi->ip_clusters = 0; 953 oi->ip_clusters = 0;
955 954
956 ocfs2_lock_res_init_once(&oi->ip_rw_lockres); 955 ocfs2_lock_res_init_once(&oi->ip_rw_lockres);
957 ocfs2_lock_res_init_once(&oi->ip_meta_lockres); 956 ocfs2_lock_res_init_once(&oi->ip_meta_lockres);
958 ocfs2_lock_res_init_once(&oi->ip_data_lockres); 957 ocfs2_lock_res_init_once(&oi->ip_data_lockres);
959 ocfs2_lock_res_init_once(&oi->ip_open_lockres); 958 ocfs2_lock_res_init_once(&oi->ip_open_lockres);
960 959
961 ocfs2_metadata_cache_init(&oi->vfs_inode); 960 ocfs2_metadata_cache_init(&oi->vfs_inode);
962 961
963 inode_init_once(&oi->vfs_inode); 962 inode_init_once(&oi->vfs_inode);
964 }
965} 963}
966 964
967static int ocfs2_initialize_mem_caches(void) 965static int ocfs2_initialize_mem_caches(void)
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 731a90e9f0cd..e62397341c36 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -419,8 +419,7 @@ static void op_inode_init_once(void *data, struct kmem_cache * cachep, unsigned
419{ 419{
420 struct op_inode_info *oi = (struct op_inode_info *) data; 420 struct op_inode_info *oi = (struct op_inode_info *) data;
421 421
422 if (flags & SLAB_CTOR_CONSTRUCTOR) 422 inode_init_once(&oi->vfs_inode);
423 inode_init_once(&oi->vfs_inode);
424} 423}
425 424
426static int __init init_openprom_fs(void) 425static int __init init_openprom_fs(void)
diff --git a/fs/partitions/Kconfig b/fs/partitions/Kconfig
index 7638a1c42a7d..a99acd8de353 100644
--- a/fs/partitions/Kconfig
+++ b/fs/partitions/Kconfig
@@ -166,8 +166,12 @@ config LDM_PARTITION
166 depends on PARTITION_ADVANCED 166 depends on PARTITION_ADVANCED
167 ---help--- 167 ---help---
168 Say Y here if you would like to use hard disks under Linux which 168 Say Y here if you would like to use hard disks under Linux which
169 were partitioned using Windows 2000's or XP's Logical Disk Manager. 169 were partitioned using Windows 2000's/XP's or Vista's Logical Disk
170 They are also known as "Dynamic Disks". 170 Manager. They are also known as "Dynamic Disks".
171
172 Note this driver only supports Dynamic Disks with a protective MBR
173 label, i.e. DOS partition table. It does not support GPT labelled
174 Dynamic Disks yet as can be created with Vista.
171 175
172 Windows 2000 introduced the concept of Dynamic Disks to get around 176 Windows 2000 introduced the concept of Dynamic Disks to get around
173 the limitations of the PC's partitioning scheme. The Logical Disk 177 the limitations of the PC's partitioning scheme. The Logical Disk
@@ -175,8 +179,8 @@ config LDM_PARTITION
175 mirrored, striped or RAID volumes, all without the need for 179 mirrored, striped or RAID volumes, all without the need for
176 rebooting. 180 rebooting.
177 181
178 Normal partitions are now called Basic Disks under Windows 2000 and 182 Normal partitions are now called Basic Disks under Windows 2000, XP,
179 XP. 183 and Vista.
180 184
181 For a fuller description read <file:Documentation/ldm.txt>. 185 For a fuller description read <file:Documentation/ldm.txt>.
182 186
diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c
index 1a60926a4ccd..99873a2b4cbc 100644
--- a/fs/partitions/ldm.c
+++ b/fs/partitions/ldm.c
@@ -2,10 +2,10 @@
2 * ldm - Support for Windows Logical Disk Manager (Dynamic Disks) 2 * ldm - Support for Windows Logical Disk Manager (Dynamic Disks)
3 * 3 *
4 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org> 4 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
5 * Copyright (c) 2001-2004 Anton Altaparmakov 5 * Copyright (c) 2001-2007 Anton Altaparmakov
6 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com> 6 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
7 * 7 *
8 * Documentation is available at http://linux-ntfs.sf.net/ldm 8 * Documentation is available at http://www.linux-ntfs.org/content/view/19/37/
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License as published by the Free Software 11 * the terms of the GNU General Public License as published by the Free Software
@@ -62,7 +62,6 @@ static void _ldm_printk (const char *level, const char *function,
62 printk ("%s%s(): %s\n", level, function, buf); 62 printk ("%s%s(): %s\n", level, function, buf);
63} 63}
64 64
65
66/** 65/**
67 * ldm_parse_hexbyte - Convert a ASCII hex number to a byte 66 * ldm_parse_hexbyte - Convert a ASCII hex number to a byte
68 * @src: Pointer to at least 2 characters to convert. 67 * @src: Pointer to at least 2 characters to convert.
@@ -118,7 +117,6 @@ static bool ldm_parse_guid (const u8 *src, u8 *dest)
118 return true; 117 return true;
119} 118}
120 119
121
122/** 120/**
123 * ldm_parse_privhead - Read the LDM Database PRIVHEAD structure 121 * ldm_parse_privhead - Read the LDM Database PRIVHEAD structure
124 * @data: Raw database PRIVHEAD structure loaded from the device 122 * @data: Raw database PRIVHEAD structure loaded from the device
@@ -130,46 +128,48 @@ static bool ldm_parse_guid (const u8 *src, u8 *dest)
130 * Return: 'true' @ph contains the PRIVHEAD data 128 * Return: 'true' @ph contains the PRIVHEAD data
131 * 'false' @ph contents are undefined 129 * 'false' @ph contents are undefined
132 */ 130 */
133static bool ldm_parse_privhead (const u8 *data, struct privhead *ph) 131static bool ldm_parse_privhead(const u8 *data, struct privhead *ph)
134{ 132{
135 BUG_ON (!data || !ph); 133 bool is_vista = false;
136 134
137 if (MAGIC_PRIVHEAD != BE64 (data)) { 135 BUG_ON(!data || !ph);
138 ldm_error ("Cannot find PRIVHEAD structure. LDM database is" 136 if (MAGIC_PRIVHEAD != BE64(data)) {
137 ldm_error("Cannot find PRIVHEAD structure. LDM database is"
139 " corrupt. Aborting."); 138 " corrupt. Aborting.");
140 return false; 139 return false;
141 } 140 }
142 141 ph->ver_major = BE16(data + 0x000C);
143 ph->ver_major = BE16 (data + 0x000C); 142 ph->ver_minor = BE16(data + 0x000E);
144 ph->ver_minor = BE16 (data + 0x000E); 143 ph->logical_disk_start = BE64(data + 0x011B);
145 ph->logical_disk_start = BE64 (data + 0x011B); 144 ph->logical_disk_size = BE64(data + 0x0123);
146 ph->logical_disk_size = BE64 (data + 0x0123); 145 ph->config_start = BE64(data + 0x012B);
147 ph->config_start = BE64 (data + 0x012B); 146 ph->config_size = BE64(data + 0x0133);
148 ph->config_size = BE64 (data + 0x0133); 147 /* Version 2.11 is Win2k/XP and version 2.12 is Vista. */
149 148 if (ph->ver_major == 2 && ph->ver_minor == 12)
150 if ((ph->ver_major != 2) || (ph->ver_minor != 11)) { 149 is_vista = true;
151 ldm_error ("Expected PRIVHEAD version %d.%d, got %d.%d." 150 if (!is_vista && (ph->ver_major != 2 || ph->ver_minor != 11)) {
152 " Aborting.", 2, 11, ph->ver_major, ph->ver_minor); 151 ldm_error("Expected PRIVHEAD version 2.11 or 2.12, got %d.%d."
152 " Aborting.", ph->ver_major, ph->ver_minor);
153 return false; 153 return false;
154 } 154 }
155 ldm_debug("PRIVHEAD version %d.%d (Windows %s).", ph->ver_major,
156 ph->ver_minor, is_vista ? "Vista" : "2000/XP");
155 if (ph->config_size != LDM_DB_SIZE) { /* 1 MiB in sectors. */ 157 if (ph->config_size != LDM_DB_SIZE) { /* 1 MiB in sectors. */
156 /* Warn the user and continue, carefully */ 158 /* Warn the user and continue, carefully. */
157 ldm_info ("Database is normally %u bytes, it claims to " 159 ldm_info("Database is normally %u bytes, it claims to "
158 "be %llu bytes.", LDM_DB_SIZE, 160 "be %llu bytes.", LDM_DB_SIZE,
159 (unsigned long long)ph->config_size ); 161 (unsigned long long)ph->config_size);
160 } 162 }
161 if ((ph->logical_disk_size == 0) || 163 if ((ph->logical_disk_size == 0) || (ph->logical_disk_start +
162 (ph->logical_disk_start + ph->logical_disk_size > ph->config_start)) { 164 ph->logical_disk_size > ph->config_start)) {
163 ldm_error ("PRIVHEAD disk size doesn't match real disk size"); 165 ldm_error("PRIVHEAD disk size doesn't match real disk size");
164 return false; 166 return false;
165 } 167 }
166 168 if (!ldm_parse_guid(data + 0x0030, ph->disk_id)) {
167 if (!ldm_parse_guid (data + 0x0030, ph->disk_id)) { 169 ldm_error("PRIVHEAD contains an invalid GUID.");
168 ldm_error ("PRIVHEAD contains an invalid GUID.");
169 return false; 170 return false;
170 } 171 }
171 172 ldm_debug("Parsed PRIVHEAD successfully.");
172 ldm_debug ("Parsed PRIVHEAD successfully.");
173 return true; 173 return true;
174} 174}
175 175
@@ -409,7 +409,7 @@ out:
409 * Return: 'true' @toc1 contains validated TOCBLOCK info 409 * Return: 'true' @toc1 contains validated TOCBLOCK info
410 * 'false' @toc1 contents are undefined 410 * 'false' @toc1 contents are undefined
411 */ 411 */
412static bool ldm_validate_tocblocks (struct block_device *bdev, 412static bool ldm_validate_tocblocks(struct block_device *bdev,
413 unsigned long base, struct ldmdb *ldb) 413 unsigned long base, struct ldmdb *ldb)
414{ 414{
415 static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4}; 415 static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4};
@@ -417,54 +417,57 @@ static bool ldm_validate_tocblocks (struct block_device *bdev,
417 struct privhead *ph; 417 struct privhead *ph;
418 Sector sect; 418 Sector sect;
419 u8 *data; 419 u8 *data;
420 int i, nr_tbs;
420 bool result = false; 421 bool result = false;
421 int i;
422 422
423 BUG_ON (!bdev || !ldb); 423 BUG_ON(!bdev || !ldb);
424 424 ph = &ldb->ph;
425 ph = &ldb->ph;
426 tb[0] = &ldb->toc; 425 tb[0] = &ldb->toc;
427 tb[1] = kmalloc (sizeof (*tb[1]), GFP_KERNEL); 426 tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
428 tb[2] = kmalloc (sizeof (*tb[2]), GFP_KERNEL); 427 if (!tb[1]) {
429 tb[3] = kmalloc (sizeof (*tb[3]), GFP_KERNEL); 428 ldm_crit("Out of memory.");
430 if (!tb[1] || !tb[2] || !tb[3]) { 429 goto err;
431 ldm_crit ("Out of memory.");
432 goto out;
433 } 430 }
434 431 tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1]));
435 for (i = 0; i < 4; i++) /* Read and parse all four toc's. */ 432 tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2]));
436 { 433 /*
437 data = read_dev_sector (bdev, base + off[i], &sect); 434 * Try to read and parse all four TOCBLOCKs.
435 *
436 * Windows Vista LDM v2.12 does not always have all four TOCBLOCKs so
437 * skip any that fail as long as we get at least one valid TOCBLOCK.
438 */
439 for (nr_tbs = i = 0; i < 4; i++) {
440 data = read_dev_sector(bdev, base + off[i], &sect);
438 if (!data) { 441 if (!data) {
439 ldm_crit ("Disk read failed."); 442 ldm_error("Disk read failed for TOCBLOCK %d.", i);
440 goto out; 443 continue;
441 } 444 }
442 result = ldm_parse_tocblock (data, tb[i]); 445 if (ldm_parse_tocblock(data, tb[nr_tbs]))
443 put_dev_sector (sect); 446 nr_tbs++;
444 if (!result) 447 put_dev_sector(sect);
445 goto out; /* Already logged */
446 } 448 }
447 449 if (!nr_tbs) {
448 /* Range check the toc against a privhead. */ 450 ldm_crit("Failed to find a valid TOCBLOCK.");
451 goto err;
452 }
453 /* Range check the TOCBLOCK against a privhead. */
449 if (((tb[0]->bitmap1_start + tb[0]->bitmap1_size) > ph->config_size) || 454 if (((tb[0]->bitmap1_start + tb[0]->bitmap1_size) > ph->config_size) ||
450 ((tb[0]->bitmap2_start + tb[0]->bitmap2_size) > ph->config_size)) { 455 ((tb[0]->bitmap2_start + tb[0]->bitmap2_size) >
451 ldm_crit ("The bitmaps are out of range. Giving up."); 456 ph->config_size)) {
452 goto out; 457 ldm_crit("The bitmaps are out of range. Giving up.");
458 goto err;
453 } 459 }
454 460 /* Compare all loaded TOCBLOCKs. */
455 if (!ldm_compare_tocblocks (tb[0], tb[1]) || /* Compare all tocs. */ 461 for (i = 1; i < nr_tbs; i++) {
456 !ldm_compare_tocblocks (tb[0], tb[2]) || 462 if (!ldm_compare_tocblocks(tb[0], tb[i])) {
457 !ldm_compare_tocblocks (tb[0], tb[3])) { 463 ldm_crit("TOCBLOCKs 0 and %d do not match.", i);
458 ldm_crit ("The TOCBLOCKs don't match."); 464 goto err;
459 goto out; 465 }
460 } 466 }
461 467 ldm_debug("Validated %d TOCBLOCKs successfully.", nr_tbs);
462 ldm_debug ("Validated TOCBLOCKs successfully.");
463 result = true; 468 result = true;
464out: 469err:
465 kfree (tb[1]); 470 kfree(tb[1]);
466 kfree (tb[2]);
467 kfree (tb[3]);
468 return result; 471 return result;
469} 472}
470 473
@@ -566,7 +569,7 @@ static bool ldm_validate_partition_table (struct block_device *bdev)
566 569
567 p = (struct partition*)(data + 0x01BE); 570 p = (struct partition*)(data + 0x01BE);
568 for (i = 0; i < 4; i++, p++) 571 for (i = 0; i < 4; i++, p++)
569 if (SYS_IND (p) == WIN2K_DYNAMIC_PARTITION) { 572 if (SYS_IND (p) == LDM_PARTITION) {
570 result = true; 573 result = true;
571 break; 574 break;
572 } 575 }
@@ -975,44 +978,68 @@ static bool ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
975 * Return: 'true' @vb contains a Partition VBLK 978 * Return: 'true' @vb contains a Partition VBLK
976 * 'false' @vb contents are not defined 979 * 'false' @vb contents are not defined
977 */ 980 */
978static bool ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb) 981static bool ldm_parse_prt3(const u8 *buffer, int buflen, struct vblk *vb)
979{ 982{
980 int r_objid, r_name, r_size, r_parent, r_diskid, r_index, len; 983 int r_objid, r_name, r_size, r_parent, r_diskid, r_index, len;
981 struct vblk_part *part; 984 struct vblk_part *part;
982 985
983 BUG_ON (!buffer || !vb); 986 BUG_ON(!buffer || !vb);
984 987 r_objid = ldm_relative(buffer, buflen, 0x18, 0);
985 r_objid = ldm_relative (buffer, buflen, 0x18, 0); 988 if (r_objid < 0) {
986 r_name = ldm_relative (buffer, buflen, 0x18, r_objid); 989 ldm_error("r_objid %d < 0", r_objid);
987 r_size = ldm_relative (buffer, buflen, 0x34, r_name); 990 return false;
988 r_parent = ldm_relative (buffer, buflen, 0x34, r_size); 991 }
989 r_diskid = ldm_relative (buffer, buflen, 0x34, r_parent); 992 r_name = ldm_relative(buffer, buflen, 0x18, r_objid);
990 993 if (r_name < 0) {
994 ldm_error("r_name %d < 0", r_name);
995 return false;
996 }
997 r_size = ldm_relative(buffer, buflen, 0x34, r_name);
998 if (r_size < 0) {
999 ldm_error("r_size %d < 0", r_size);
1000 return false;
1001 }
1002 r_parent = ldm_relative(buffer, buflen, 0x34, r_size);
1003 if (r_parent < 0) {
1004 ldm_error("r_parent %d < 0", r_parent);
1005 return false;
1006 }
1007 r_diskid = ldm_relative(buffer, buflen, 0x34, r_parent);
1008 if (r_diskid < 0) {
1009 ldm_error("r_diskid %d < 0", r_diskid);
1010 return false;
1011 }
991 if (buffer[0x12] & VBLK_FLAG_PART_INDEX) { 1012 if (buffer[0x12] & VBLK_FLAG_PART_INDEX) {
992 r_index = ldm_relative (buffer, buflen, 0x34, r_diskid); 1013 r_index = ldm_relative(buffer, buflen, 0x34, r_diskid);
1014 if (r_index < 0) {
1015 ldm_error("r_index %d < 0", r_index);
1016 return false;
1017 }
993 len = r_index; 1018 len = r_index;
994 } else { 1019 } else {
995 r_index = 0; 1020 r_index = 0;
996 len = r_diskid; 1021 len = r_diskid;
997 } 1022 }
998 if (len < 0) 1023 if (len < 0) {
1024 ldm_error("len %d < 0", len);
999 return false; 1025 return false;
1000 1026 }
1001 len += VBLK_SIZE_PRT3; 1027 len += VBLK_SIZE_PRT3;
1002 if (len != BE32 (buffer + 0x14)) 1028 if (len > BE32(buffer + 0x14)) {
1029 ldm_error("len %d > BE32(buffer + 0x14) %d", len,
1030 BE32(buffer + 0x14));
1003 return false; 1031 return false;
1004 1032 }
1005 part = &vb->vblk.part; 1033 part = &vb->vblk.part;
1006 part->start = BE64 (buffer + 0x24 + r_name); 1034 part->start = BE64(buffer + 0x24 + r_name);
1007 part->volume_offset = BE64 (buffer + 0x2C + r_name); 1035 part->volume_offset = BE64(buffer + 0x2C + r_name);
1008 part->size = ldm_get_vnum (buffer + 0x34 + r_name); 1036 part->size = ldm_get_vnum(buffer + 0x34 + r_name);
1009 part->parent_id = ldm_get_vnum (buffer + 0x34 + r_size); 1037 part->parent_id = ldm_get_vnum(buffer + 0x34 + r_size);
1010 part->disk_id = ldm_get_vnum (buffer + 0x34 + r_parent); 1038 part->disk_id = ldm_get_vnum(buffer + 0x34 + r_parent);
1011 if (vb->flags & VBLK_FLAG_PART_INDEX) 1039 if (vb->flags & VBLK_FLAG_PART_INDEX)
1012 part->partnum = buffer[0x35 + r_diskid]; 1040 part->partnum = buffer[0x35 + r_diskid];
1013 else 1041 else
1014 part->partnum = 0; 1042 part->partnum = 0;
1015
1016 return true; 1043 return true;
1017} 1044}
1018 1045
@@ -1475,4 +1502,3 @@ out:
1475 kfree (ldb); 1502 kfree (ldb);
1476 return result; 1503 return result;
1477} 1504}
1478
diff --git a/fs/partitions/ldm.h b/fs/partitions/ldm.h
index 6e8d7952b8b5..d2e6a3046939 100644
--- a/fs/partitions/ldm.h
+++ b/fs/partitions/ldm.h
@@ -2,10 +2,10 @@
2 * ldm - Part of the Linux-NTFS project. 2 * ldm - Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org> 4 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
5 * Copyright (C) 2001 Anton Altaparmakov <aia21@cantab.net> 5 * Copyright (c) 2001-2007 Anton Altaparmakov
6 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com> 6 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
7 * 7 *
8 * Documentation is available at http://linux-ntfs.sf.net/ldm 8 * Documentation is available at http://www.linux-ntfs.org/content/view/19/37/
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free 11 * under the terms of the GNU General Public License as published by the Free
@@ -93,7 +93,7 @@ struct parsed_partitions;
93 93
94#define OFF_VMDB 17 /* List of partitions. */ 94#define OFF_VMDB 17 /* List of partitions. */
95 95
96#define WIN2K_DYNAMIC_PARTITION 0x42 /* Formerly SFS (Landis). */ 96#define LDM_PARTITION 0x42 /* Formerly SFS (Landis). */
97 97
98#define TOC_BITMAP1 "config" /* Names of the two defined */ 98#define TOC_BITMAP1 "config" /* Names of the two defined */
99#define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */ 99#define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index b8171907c83b..d5ce65c68d7b 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -109,8 +109,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
109{ 109{
110 struct proc_inode *ei = (struct proc_inode *) foo; 110 struct proc_inode *ei = (struct proc_inode *) foo;
111 111
112 if (flags & SLAB_CTOR_CONSTRUCTOR) 112 inode_init_once(&ei->vfs_inode);
113 inode_init_once(&ei->vfs_inode);
114} 113}
115 114
116int __init proc_init_inodecache(void) 115int __init proc_init_inodecache(void)
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 75fc8498f2e2..8d256eb11813 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -536,8 +536,7 @@ static void init_once(void *foo, struct kmem_cache * cachep,
536{ 536{
537 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo; 537 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo;
538 538
539 if (flags & SLAB_CTOR_CONSTRUCTOR) 539 inode_init_once(&ei->vfs_inode);
540 inode_init_once(&ei->vfs_inode);
541} 540}
542 541
543static int init_inodecache(void) 542static int init_inodecache(void)
diff --git a/fs/quota.c b/fs/quota.c
index e9d88fd0eca8..9f237d6182c9 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -157,7 +157,6 @@ static int check_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t
157static void quota_sync_sb(struct super_block *sb, int type) 157static void quota_sync_sb(struct super_block *sb, int type)
158{ 158{
159 int cnt; 159 int cnt;
160 struct inode *discard[MAXQUOTAS];
161 160
162 sb->s_qcop->quota_sync(sb, type); 161 sb->s_qcop->quota_sync(sb, type);
163 /* This is not very clever (and fast) but currently I don't know about 162 /* This is not very clever (and fast) but currently I don't know about
@@ -167,29 +166,21 @@ static void quota_sync_sb(struct super_block *sb, int type)
167 sb->s_op->sync_fs(sb, 1); 166 sb->s_op->sync_fs(sb, 1);
168 sync_blockdev(sb->s_bdev); 167 sync_blockdev(sb->s_bdev);
169 168
170 /* Now when everything is written we can discard the pagecache so 169 /*
171 * that userspace sees the changes. We need i_mutex and so we could 170 * Now when everything is written we can discard the pagecache so
172 * not do it inside dqonoff_mutex. Moreover we need to be carefull 171 * that userspace sees the changes.
173 * about races with quotaoff() (that is the reason why we have own 172 */
174 * reference to inode). */
175 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); 173 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
176 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 174 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
177 discard[cnt] = NULL;
178 if (type != -1 && cnt != type) 175 if (type != -1 && cnt != type)
179 continue; 176 continue;
180 if (!sb_has_quota_enabled(sb, cnt)) 177 if (!sb_has_quota_enabled(sb, cnt))
181 continue; 178 continue;
182 discard[cnt] = igrab(sb_dqopt(sb)->files[cnt]); 179 mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, I_MUTEX_QUOTA);
180 truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0);
181 mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex);
183 } 182 }
184 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); 183 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
185 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
186 if (discard[cnt]) {
187 mutex_lock(&discard[cnt]->i_mutex);
188 truncate_inode_pages(&discard[cnt]->i_data, 0);
189 mutex_unlock(&discard[cnt]->i_mutex);
190 iput(discard[cnt]);
191 }
192 }
193} 184}
194 185
195void sync_dquots(struct super_block *sb, int type) 186void sync_dquots(struct super_block *sb, int type)
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 3b481d557edb..9345a46ffb32 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -179,7 +179,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
179 return ret; 179 return ret;
180 } 180 }
181 181
182 ret = vmtruncate(inode, size); 182 ret = vmtruncate(inode, newsize);
183 183
184 return ret; 184 return ret;
185} 185}
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 4ace5d72eae1..d40d22b347b7 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -32,7 +32,7 @@
32#include <linux/string.h> 32#include <linux/string.h>
33#include <linux/backing-dev.h> 33#include <linux/backing-dev.h>
34#include <linux/ramfs.h> 34#include <linux/ramfs.h>
35 35#include <linux/sched.h>
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37#include "internal.h" 37#include "internal.h"
38 38
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index 9c23fee3bae9..ffbfc2caaf20 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -10,7 +10,7 @@
10#include <linux/buffer_head.h> 10#include <linux/buffer_head.h>
11#include <asm/uaccess.h> 11#include <asm/uaccess.h>
12 12
13extern struct reiserfs_key MIN_KEY; 13extern const struct reiserfs_key MIN_KEY;
14 14
15static int reiserfs_readdir(struct file *, void *, filldir_t); 15static int reiserfs_readdir(struct file *, void *, filldir_t);
16static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, 16static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index c7762140c425..b4ac9119200e 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -511,14 +511,12 @@ static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags
511{ 511{
512 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; 512 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
513 513
514 if (flags & SLAB_CTOR_CONSTRUCTOR) { 514 INIT_LIST_HEAD(&ei->i_prealloc_list);
515 INIT_LIST_HEAD(&ei->i_prealloc_list); 515 inode_init_once(&ei->vfs_inode);
516 inode_init_once(&ei->vfs_inode);
517#ifdef CONFIG_REISERFS_FS_POSIX_ACL 516#ifdef CONFIG_REISERFS_FS_POSIX_ACL
518 ei->i_acl_access = NULL; 517 ei->i_acl_access = NULL;
519 ei->i_acl_default = NULL; 518 ei->i_acl_default = NULL;
520#endif 519#endif
521 }
522} 520}
523 521
524static int init_inodecache(void) 522static int init_inodecache(void)
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 804285190271..2284e03342c6 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -566,12 +566,11 @@ static void romfs_destroy_inode(struct inode *inode)
566 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); 566 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
567} 567}
568 568
569static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags) 569static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
570{ 570{
571 struct romfs_inode_info *ei = (struct romfs_inode_info *) foo; 571 struct romfs_inode_info *ei = foo;
572 572
573 if (flags & SLAB_CTOR_CONSTRUCTOR) 573 inode_init_once(&ei->vfs_inode);
574 inode_init_once(&ei->vfs_inode);
575} 574}
576 575
577static int init_inodecache(void) 576static int init_inodecache(void)
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 7cfeab412b45..f1da89203a9a 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -11,6 +11,8 @@
11 * Now using anonymous inode source. 11 * Now using anonymous inode source.
12 * Thanks to Oleg Nesterov for useful code review and suggestions. 12 * Thanks to Oleg Nesterov for useful code review and suggestions.
13 * More comments and suggestions from Arnd Bergmann. 13 * More comments and suggestions from Arnd Bergmann.
14 * Sat May 19, 2007: Davi E. M. Arnaut <davi@haxent.com.br>
15 * Retrieve multiple signals with one read() call
14 */ 16 */
15 17
16#include <linux/file.h> 18#include <linux/file.h>
@@ -206,6 +208,59 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
206 return err ? -EFAULT: sizeof(*uinfo); 208 return err ? -EFAULT: sizeof(*uinfo);
207} 209}
208 210
211static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, siginfo_t *info,
212 int nonblock)
213{
214 ssize_t ret;
215 struct signalfd_lockctx lk;
216 DECLARE_WAITQUEUE(wait, current);
217
218 if (!signalfd_lock(ctx, &lk))
219 return 0;
220
221 ret = dequeue_signal(lk.tsk, &ctx->sigmask, info);
222 switch (ret) {
223 case 0:
224 if (!nonblock)
225 break;
226 ret = -EAGAIN;
227 default:
228 signalfd_unlock(&lk);
229 return ret;
230 }
231
232 add_wait_queue(&ctx->wqh, &wait);
233 for (;;) {
234 set_current_state(TASK_INTERRUPTIBLE);
235 ret = dequeue_signal(lk.tsk, &ctx->sigmask, info);
236 signalfd_unlock(&lk);
237 if (ret != 0)
238 break;
239 if (signal_pending(current)) {
240 ret = -ERESTARTSYS;
241 break;
242 }
243 schedule();
244 ret = signalfd_lock(ctx, &lk);
245 if (unlikely(!ret)) {
246 /*
247 * Let the caller read zero byte, ala socket
248 * recv() when the peer disconnect. This test
249 * must be done before doing a dequeue_signal(),
250 * because if the sighand has been orphaned,
251 * the dequeue_signal() call is going to crash
252 * because ->sighand will be long gone.
253 */
254 break;
255 }
256 }
257
258 remove_wait_queue(&ctx->wqh, &wait);
259 __set_current_state(TASK_RUNNING);
260
261 return ret;
262}
263
209/* 264/*
210 * Returns either the size of a "struct signalfd_siginfo", or zero if the 265 * Returns either the size of a "struct signalfd_siginfo", or zero if the
211 * sighand we are attached to, has been orphaned. The "count" parameter 266 * sighand we are attached to, has been orphaned. The "count" parameter
@@ -215,55 +270,30 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count,
215 loff_t *ppos) 270 loff_t *ppos)
216{ 271{
217 struct signalfd_ctx *ctx = file->private_data; 272 struct signalfd_ctx *ctx = file->private_data;
218 ssize_t res = 0; 273 struct signalfd_siginfo __user *siginfo;
219 int locked, signo; 274 int nonblock = file->f_flags & O_NONBLOCK;
275 ssize_t ret, total = 0;
220 siginfo_t info; 276 siginfo_t info;
221 struct signalfd_lockctx lk;
222 DECLARE_WAITQUEUE(wait, current);
223 277
224 if (count < sizeof(struct signalfd_siginfo)) 278 count /= sizeof(struct signalfd_siginfo);
279 if (!count)
225 return -EINVAL; 280 return -EINVAL;
226 locked = signalfd_lock(ctx, &lk);
227 if (!locked)
228 return 0;
229 res = -EAGAIN;
230 signo = dequeue_signal(lk.tsk, &ctx->sigmask, &info);
231 if (signo == 0 && !(file->f_flags & O_NONBLOCK)) {
232 add_wait_queue(&ctx->wqh, &wait);
233 for (;;) {
234 set_current_state(TASK_INTERRUPTIBLE);
235 signo = dequeue_signal(lk.tsk, &ctx->sigmask, &info);
236 if (signo != 0)
237 break;
238 if (signal_pending(current)) {
239 res = -ERESTARTSYS;
240 break;
241 }
242 signalfd_unlock(&lk);
243 schedule();
244 locked = signalfd_lock(ctx, &lk);
245 if (unlikely(!locked)) {
246 /*
247 * Let the caller read zero byte, ala socket
248 * recv() when the peer disconnect. This test
249 * must be done before doing a dequeue_signal(),
250 * because if the sighand has been orphaned,
251 * the dequeue_signal() call is going to crash.
252 */
253 res = 0;
254 break;
255 }
256 }
257 remove_wait_queue(&ctx->wqh, &wait);
258 __set_current_state(TASK_RUNNING);
259 }
260 if (likely(locked))
261 signalfd_unlock(&lk);
262 if (likely(signo))
263 res = signalfd_copyinfo((struct signalfd_siginfo __user *) buf,
264 &info);
265 281
266 return res; 282 siginfo = (struct signalfd_siginfo __user *) buf;
283
284 do {
285 ret = signalfd_dequeue(ctx, &info, nonblock);
286 if (unlikely(ret <= 0))
287 break;
288 ret = signalfd_copyinfo(siginfo, &info);
289 if (ret < 0)
290 break;
291 siginfo++;
292 total += ret;
293 nonblock = 1;
294 } while (--count);
295
296 return total ? total : ret;
267} 297}
268 298
269static const struct file_operations signalfd_fops = { 299static const struct file_operations signalfd_fops = {
diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index 50136b1a3eca..48da4fa6b7d4 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -13,6 +13,7 @@
13#include <linux/smp_lock.h> 13#include <linux/smp_lock.h>
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/net.h> 15#include <linux/net.h>
16#include <linux/sched.h>
16 17
17#include <linux/smb_fs.h> 18#include <linux/smb_fs.h>
18#include <linux/smb_mount.h> 19#include <linux/smb_mount.h>
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index f161797160c4..aea3f8aa54c0 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -17,6 +17,7 @@
17#include <linux/pagemap.h> 17#include <linux/pagemap.h>
18#include <linux/smp_lock.h> 18#include <linux/smp_lock.h>
19#include <linux/net.h> 19#include <linux/net.h>
20#include <linux/aio.h>
20 21
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
22#include <asm/system.h> 23#include <asm/system.h>
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 424a3ddf86dd..6724a6cf01ff 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -25,6 +25,7 @@
25#include <linux/net.h> 25#include <linux/net.h>
26#include <linux/vfs.h> 26#include <linux/vfs.h>
27#include <linux/highuid.h> 27#include <linux/highuid.h>
28#include <linux/sched.h>
28#include <linux/smb_fs.h> 29#include <linux/smb_fs.h>
29#include <linux/smbno.h> 30#include <linux/smbno.h>
30#include <linux/smb_mount.h> 31#include <linux/smb_mount.h>
@@ -70,8 +71,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
70{ 71{
71 struct smb_inode_info *ei = (struct smb_inode_info *) foo; 72 struct smb_inode_info *ei = (struct smb_inode_info *) foo;
72 73
73 if (flags & SLAB_CTOR_CONSTRUCTOR) 74 inode_init_once(&ei->vfs_inode);
74 inode_init_once(&ei->vfs_inode);
75} 75}
76 76
77static int init_inodecache(void) 77static int init_inodecache(void)
diff --git a/fs/smbfs/request.c b/fs/smbfs/request.c
index c288fbe7953d..3f54a0f80fae 100644
--- a/fs/smbfs/request.c
+++ b/fs/smbfs/request.c
@@ -11,6 +11,7 @@
11#include <linux/fs.h> 11#include <linux/fs.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/net.h> 13#include <linux/net.h>
14#include <linux/sched.h>
14 15
15#include <linux/smb_fs.h> 16#include <linux/smb_fs.h>
16#include <linux/smbno.h> 17#include <linux/smbno.h>
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 4de5c6b89918..bdd30e74de6b 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -13,6 +13,7 @@
13#include <linux/backing-dev.h> 13#include <linux/backing-dev.h>
14#include <linux/capability.h> 14#include <linux/capability.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/sched.h>
16#include <asm/semaphore.h> 17#include <asm/semaphore.h>
17#include "sysfs.h" 18#include "sysfs.h"
18 19
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index 3152d7415606..564411693394 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -322,8 +322,7 @@ static void init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
322{ 322{
323 struct sysv_inode_info *si = (struct sysv_inode_info *)p; 323 struct sysv_inode_info *si = (struct sysv_inode_info *)p;
324 324
325 if (flags & SLAB_CTOR_CONSTRUCTOR) 325 inode_init_once(&si->vfs_inode);
326 inode_init_once(&si->vfs_inode);
327} 326}
328 327
329const struct super_operations sysv_sops = { 328const struct super_operations sysv_sops = {
diff --git a/fs/timerfd.c b/fs/timerfd.c
index e329e37f15a8..af9eca5c0230 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -24,7 +24,6 @@
24struct timerfd_ctx { 24struct timerfd_ctx {
25 struct hrtimer tmr; 25 struct hrtimer tmr;
26 ktime_t tintv; 26 ktime_t tintv;
27 spinlock_t lock;
28 wait_queue_head_t wqh; 27 wait_queue_head_t wqh;
29 int expired; 28 int expired;
30}; 29};
@@ -39,10 +38,10 @@ static enum hrtimer_restart timerfd_tmrproc(struct hrtimer *htmr)
39 struct timerfd_ctx *ctx = container_of(htmr, struct timerfd_ctx, tmr); 38 struct timerfd_ctx *ctx = container_of(htmr, struct timerfd_ctx, tmr);
40 unsigned long flags; 39 unsigned long flags;
41 40
42 spin_lock_irqsave(&ctx->lock, flags); 41 spin_lock_irqsave(&ctx->wqh.lock, flags);
43 ctx->expired = 1; 42 ctx->expired = 1;
44 wake_up_locked(&ctx->wqh); 43 wake_up_locked(&ctx->wqh);
45 spin_unlock_irqrestore(&ctx->lock, flags); 44 spin_unlock_irqrestore(&ctx->wqh.lock, flags);
46 45
47 return HRTIMER_NORESTART; 46 return HRTIMER_NORESTART;
48} 47}
@@ -83,10 +82,10 @@ static unsigned int timerfd_poll(struct file *file, poll_table *wait)
83 82
84 poll_wait(file, &ctx->wqh, wait); 83 poll_wait(file, &ctx->wqh, wait);
85 84
86 spin_lock_irqsave(&ctx->lock, flags); 85 spin_lock_irqsave(&ctx->wqh.lock, flags);
87 if (ctx->expired) 86 if (ctx->expired)
88 events |= POLLIN; 87 events |= POLLIN;
89 spin_unlock_irqrestore(&ctx->lock, flags); 88 spin_unlock_irqrestore(&ctx->wqh.lock, flags);
90 89
91 return events; 90 return events;
92} 91}
@@ -101,7 +100,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
101 100
102 if (count < sizeof(ticks)) 101 if (count < sizeof(ticks))
103 return -EINVAL; 102 return -EINVAL;
104 spin_lock_irq(&ctx->lock); 103 spin_lock_irq(&ctx->wqh.lock);
105 res = -EAGAIN; 104 res = -EAGAIN;
106 if (!ctx->expired && !(file->f_flags & O_NONBLOCK)) { 105 if (!ctx->expired && !(file->f_flags & O_NONBLOCK)) {
107 __add_wait_queue(&ctx->wqh, &wait); 106 __add_wait_queue(&ctx->wqh, &wait);
@@ -115,9 +114,9 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
115 res = -ERESTARTSYS; 114 res = -ERESTARTSYS;
116 break; 115 break;
117 } 116 }
118 spin_unlock_irq(&ctx->lock); 117 spin_unlock_irq(&ctx->wqh.lock);
119 schedule(); 118 schedule();
120 spin_lock_irq(&ctx->lock); 119 spin_lock_irq(&ctx->wqh.lock);
121 } 120 }
122 __remove_wait_queue(&ctx->wqh, &wait); 121 __remove_wait_queue(&ctx->wqh, &wait);
123 __set_current_state(TASK_RUNNING); 122 __set_current_state(TASK_RUNNING);
@@ -139,7 +138,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
139 } else 138 } else
140 ticks = 1; 139 ticks = 1;
141 } 140 }
142 spin_unlock_irq(&ctx->lock); 141 spin_unlock_irq(&ctx->wqh.lock);
143 if (ticks) 142 if (ticks)
144 res = put_user(ticks, buf) ? -EFAULT: sizeof(ticks); 143 res = put_user(ticks, buf) ? -EFAULT: sizeof(ticks);
145 return res; 144 return res;
@@ -176,7 +175,6 @@ asmlinkage long sys_timerfd(int ufd, int clockid, int flags,
176 return -ENOMEM; 175 return -ENOMEM;
177 176
178 init_waitqueue_head(&ctx->wqh); 177 init_waitqueue_head(&ctx->wqh);
179 spin_lock_init(&ctx->lock);
180 178
181 timerfd_setup(ctx, clockid, flags, &ktmr); 179 timerfd_setup(ctx, clockid, flags, &ktmr);
182 180
@@ -202,10 +200,10 @@ asmlinkage long sys_timerfd(int ufd, int clockid, int flags,
202 * it to the new values. 200 * it to the new values.
203 */ 201 */
204 for (;;) { 202 for (;;) {
205 spin_lock_irq(&ctx->lock); 203 spin_lock_irq(&ctx->wqh.lock);
206 if (hrtimer_try_to_cancel(&ctx->tmr) >= 0) 204 if (hrtimer_try_to_cancel(&ctx->tmr) >= 0)
207 break; 205 break;
208 spin_unlock_irq(&ctx->lock); 206 spin_unlock_irq(&ctx->wqh.lock);
209 cpu_relax(); 207 cpu_relax();
210 } 208 }
211 /* 209 /*
@@ -213,7 +211,7 @@ asmlinkage long sys_timerfd(int ufd, int clockid, int flags,
213 */ 211 */
214 timerfd_setup(ctx, clockid, flags, &ktmr); 212 timerfd_setup(ctx, clockid, flags, &ktmr);
215 213
216 spin_unlock_irq(&ctx->lock); 214 spin_unlock_irq(&ctx->wqh.lock);
217 fput(file); 215 fput(file);
218 } 216 }
219 217
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 40d5047defea..51b5764685e7 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -36,6 +36,7 @@
36#include <linux/smp_lock.h> 36#include <linux/smp_lock.h>
37#include <linux/pagemap.h> 37#include <linux/pagemap.h>
38#include <linux/buffer_head.h> 38#include <linux/buffer_head.h>
39#include <linux/aio.h>
39 40
40#include "udf_i.h" 41#include "udf_i.h"
41#include "udf_sb.h" 42#include "udf_sb.h"
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 91df4928651c..51fe307dc0ec 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -30,6 +30,7 @@
30#include <linux/quotaops.h> 30#include <linux/quotaops.h>
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <linux/buffer_head.h> 32#include <linux/buffer_head.h>
33#include <linux/sched.h>
33 34
34static inline int udf_match(int len1, const char *name1, int len2, const char *name2) 35static inline int udf_match(int len1, const char *name1, int len2, const char *name2)
35{ 36{
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 9b8644a06e53..3a743d854c17 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -134,10 +134,8 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
134{ 134{
135 struct udf_inode_info *ei = (struct udf_inode_info *) foo; 135 struct udf_inode_info *ei = (struct udf_inode_info *) foo;
136 136
137 if (flags & SLAB_CTOR_CONSTRUCTOR) { 137 ei->i_ext.i_data = NULL;
138 ei->i_ext.i_data = NULL; 138 inode_init_once(&ei->vfs_inode);
139 inode_init_once(&ei->vfs_inode);
140 }
141} 139}
142 140
143static int init_inodecache(void) 141static int init_inodecache(void)
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index be7c48c5f203..22ff6ed55ce9 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -1237,8 +1237,7 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag
1237{ 1237{
1238 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; 1238 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo;
1239 1239
1240 if (flags & SLAB_CTOR_CONSTRUCTOR) 1240 inode_init_once(&ei->vfs_inode);
1241 inode_init_once(&ei->vfs_inode);
1242} 1241}
1243 1242
1244static int init_inodecache(void) 1243static int init_inodecache(void)
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 4475588e973a..7361861e3aac 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -701,7 +701,7 @@ xfs_is_delayed_page(
701 else if (buffer_delay(bh)) 701 else if (buffer_delay(bh))
702 acceptable = (type == IOMAP_DELAY); 702 acceptable = (type == IOMAP_DELAY);
703 else if (buffer_dirty(bh) && buffer_mapped(bh)) 703 else if (buffer_dirty(bh) && buffer_mapped(bh))
704 acceptable = (type == 0); 704 acceptable = (type == IOMAP_NEW);
705 else 705 else
706 break; 706 break;
707 } while ((bh = bh->b_this_page) != head); 707 } while ((bh = bh->b_this_page) != head);
@@ -810,7 +810,7 @@ xfs_convert_page(
810 page_dirty--; 810 page_dirty--;
811 count++; 811 count++;
812 } else { 812 } else {
813 type = 0; 813 type = IOMAP_NEW;
814 if (buffer_mapped(bh) && all_bh && startio) { 814 if (buffer_mapped(bh) && all_bh && startio) {
815 lock_buffer(bh); 815 lock_buffer(bh);
816 xfs_add_to_ioend(inode, bh, offset, 816 xfs_add_to_ioend(inode, bh, offset,
@@ -968,8 +968,8 @@ xfs_page_state_convert(
968 968
969 bh = head = page_buffers(page); 969 bh = head = page_buffers(page);
970 offset = page_offset(page); 970 offset = page_offset(page);
971 flags = -1; 971 flags = BMAPI_READ;
972 type = IOMAP_READ; 972 type = IOMAP_NEW;
973 973
974 /* TODO: cleanup count and page_dirty */ 974 /* TODO: cleanup count and page_dirty */
975 975
@@ -999,14 +999,14 @@ xfs_page_state_convert(
999 * 999 *
1000 * Third case, an unmapped buffer was found, and we are 1000 * Third case, an unmapped buffer was found, and we are
1001 * in a path where we need to write the whole page out. 1001 * in a path where we need to write the whole page out.
1002 */ 1002 */
1003 if (buffer_unwritten(bh) || buffer_delay(bh) || 1003 if (buffer_unwritten(bh) || buffer_delay(bh) ||
1004 ((buffer_uptodate(bh) || PageUptodate(page)) && 1004 ((buffer_uptodate(bh) || PageUptodate(page)) &&
1005 !buffer_mapped(bh) && (unmapped || startio))) { 1005 !buffer_mapped(bh) && (unmapped || startio))) {
1006 /* 1006 /*
1007 * Make sure we don't use a read-only iomap 1007 * Make sure we don't use a read-only iomap
1008 */ 1008 */
1009 if (flags == BMAPI_READ) 1009 if (flags == BMAPI_READ)
1010 iomap_valid = 0; 1010 iomap_valid = 0;
1011 1011
1012 if (buffer_unwritten(bh)) { 1012 if (buffer_unwritten(bh)) {
@@ -1055,7 +1055,7 @@ xfs_page_state_convert(
1055 * That means it must already have extents allocated 1055 * That means it must already have extents allocated
1056 * underneath it. Map the extent by reading it. 1056 * underneath it. Map the extent by reading it.
1057 */ 1057 */
1058 if (!iomap_valid || type != IOMAP_READ) { 1058 if (!iomap_valid || flags != BMAPI_READ) {
1059 flags = BMAPI_READ; 1059 flags = BMAPI_READ;
1060 size = xfs_probe_cluster(inode, page, bh, 1060 size = xfs_probe_cluster(inode, page, bh,
1061 head, 1); 1061 head, 1);
@@ -1066,7 +1066,15 @@ xfs_page_state_convert(
1066 iomap_valid = xfs_iomap_valid(&iomap, offset); 1066 iomap_valid = xfs_iomap_valid(&iomap, offset);
1067 } 1067 }
1068 1068
1069 type = IOMAP_READ; 1069 /*
1070 * We set the type to IOMAP_NEW in case we are doing a
1071 * small write at EOF that is extending the file but
1072 * without needing an allocation. We need to update the
1073 * file size on I/O completion in this case so it is
1074 * the same case as having just allocated a new extent
1075 * that we are writing into for the first time.
1076 */
1077 type = IOMAP_NEW;
1070 if (!test_and_set_bit(BH_Lock, &bh->b_state)) { 1078 if (!test_and_set_bit(BH_Lock, &bh->b_state)) {
1071 ASSERT(buffer_mapped(bh)); 1079 ASSERT(buffer_mapped(bh));
1072 if (iomap_valid) 1080 if (iomap_valid)
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 14e2cbe5a8d5..bf9a9d5909be 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -360,8 +360,7 @@ xfs_fs_inode_init_once(
360 kmem_zone_t *zonep, 360 kmem_zone_t *zonep,
361 unsigned long flags) 361 unsigned long flags)
362{ 362{
363 if (flags & SLAB_CTOR_CONSTRUCTOR) 363 inode_init_once(vn_to_inode((bhv_vnode_t *)vnode));
364 inode_init_once(vn_to_inode((bhv_vnode_t *)vnode));
365} 364}
366 365
367STATIC int 366STATIC int