aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/Kconfig13
-rw-r--r--fs/Makefile1
-rw-r--r--fs/adfs/super.c2
-rw-r--r--fs/affs/affs.h3
-rw-r--r--fs/affs/bitmap.c18
-rw-r--r--fs/affs/super.c4
-rw-r--r--fs/afs/super.c4
-rw-r--r--fs/befs/linuxvfs.c2
-rw-r--r--fs/bfs/bfs.h5
-rw-r--r--fs/bfs/dir.c46
-rw-r--r--fs/bfs/file.c4
-rw-r--r--fs/bfs/inode.c29
-rw-r--r--fs/binfmt_aout.c6
-rw-r--r--fs/binfmt_elf.c6
-rw-r--r--fs/binfmt_elf_fdpic.c7
-rw-r--r--fs/binfmt_flat.c3
-rw-r--r--fs/binfmt_som.c2
-rw-r--r--fs/bio.c8
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/buffer.c9
-rw-r--r--fs/cifs/asn1.c4
-rw-r--r--fs/cifs/cifs_debug.c645
-rw-r--r--fs/cifs/cifsacl.c41
-rw-r--r--fs/cifs/cifsencrypt.c3
-rw-r--r--fs/cifs/cifsfs.c2
-rw-r--r--fs/cifs/cifsglob.h6
-rw-r--r--fs/cifs/cifspdu.h8
-rw-r--r--fs/cifs/cifssmb.c10
-rw-r--r--fs/cifs/connect.c37
-rw-r--r--fs/cifs/inode.c151
-rw-r--r--fs/cifs/readdir.c1
-rw-r--r--fs/coda/inode.c2
-rw-r--r--fs/dcache.c1
-rw-r--r--fs/direct-io.c10
-rw-r--r--fs/ecryptfs/main.c4
-rw-r--r--fs/efs/super.c2
-rw-r--r--fs/exec.c12
-rw-r--r--fs/ext2/super.c2
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext4/super.c2
-rw-r--r--fs/fat/cache.c2
-rw-r--r--fs/fat/inode.c2
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/gfs2/main.c4
-rw-r--r--fs/hfs/super.c2
-rw-r--r--fs/hfsplus/super.c2
-rw-r--r--fs/hpfs/super.c2
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/inode.c4
-rw-r--r--fs/isofs/inode.c2
-rw-r--r--fs/jffs2/super.c2
-rw-r--r--fs/jfs/jfs_metapage.c2
-rw-r--r--fs/jfs/super.c2
-rw-r--r--fs/locks.c2
-rw-r--r--fs/minix/inode.c2
-rw-r--r--fs/namespace.c3
-rw-r--r--fs/ncpfs/inode.c2
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/ntfs/super.c2
-rw-r--r--fs/ocfs2/dlm/dlmfs.c3
-rw-r--r--fs/ocfs2/super.c2
-rw-r--r--fs/omfs/Makefile4
-rw-r--r--fs/omfs/bitmap.c192
-rw-r--r--fs/omfs/dir.c504
-rw-r--r--fs/omfs/file.c346
-rw-r--r--fs/omfs/inode.c553
-rw-r--r--fs/omfs/omfs.h67
-rw-r--r--fs/omfs/omfs_fs.h80
-rw-r--r--fs/openpromfs/inode.c2
-rw-r--r--fs/proc/array.c9
-rw-r--r--fs/proc/base.c39
-rw-r--r--fs/proc/generic.c5
-rw-r--r--fs/proc/inode.c2
-rw-r--r--fs/qnx4/inode.c2
-rw-r--r--fs/reiserfs/super.c2
-rw-r--r--fs/romfs/inode.c2
-rw-r--r--fs/smbfs/inode.c2
-rw-r--r--fs/splice.c41
-rw-r--r--fs/sysfs/dir.c5
-rw-r--r--fs/sysfs/file.c3
-rw-r--r--fs/sysfs/group.c3
-rw-r--r--fs/sysv/inode.c2
-rw-r--r--fs/ubifs/super.c2
-rw-r--r--fs/udf/super.c2
-rw-r--r--fs/ufs/super.c2
-rw-r--r--fs/xfs/linux-2.6/kmem.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c1
87 files changed, 2329 insertions, 712 deletions
diff --git a/fs/Kconfig b/fs/Kconfig
index 97e3bdedb1e6..d3873583360b 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1383,6 +1383,19 @@ config MINIX_FS
1383 partition (the one containing the directory /) cannot be compiled as 1383 partition (the one containing the directory /) cannot be compiled as
1384 a module. 1384 a module.
1385 1385
1386config OMFS_FS
1387 tristate "SonicBlue Optimized MPEG File System support"
1388 depends on BLOCK
1389 select CRC_ITU_T
1390 help
1391 This is the proprietary file system used by the Rio Karma music
1392 player and ReplayTV DVR. Despite the name, this filesystem is not
1393 more efficient than a standard FS for MPEG files, in fact likely
1394 the opposite is true. Say Y if you have either of these devices
1395 and wish to mount its disk.
1396
1397 To compile this file system support as a module, choose M here: the
1398 module will be called omfs. If unsure, say N.
1386 1399
1387config HPFS_FS 1400config HPFS_FS
1388 tristate "OS/2 HPFS file system support" 1401 tristate "OS/2 HPFS file system support"
diff --git a/fs/Makefile b/fs/Makefile
index 3b2178b4bb66..a1482a5eff15 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -111,6 +111,7 @@ obj-$(CONFIG_ADFS_FS) += adfs/
111obj-$(CONFIG_FUSE_FS) += fuse/ 111obj-$(CONFIG_FUSE_FS) += fuse/
112obj-$(CONFIG_UDF_FS) += udf/ 112obj-$(CONFIG_UDF_FS) += udf/
113obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ 113obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/
114obj-$(CONFIG_OMFS_FS) += omfs/
114obj-$(CONFIG_JFS_FS) += jfs/ 115obj-$(CONFIG_JFS_FS) += jfs/
115obj-$(CONFIG_XFS_FS) += xfs/ 116obj-$(CONFIG_XFS_FS) += xfs/
116obj-$(CONFIG_9P_FS) += 9p/ 117obj-$(CONFIG_9P_FS) += 9p/
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 9e421eeb672b..26f3b43726bb 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -249,7 +249,7 @@ static void adfs_destroy_inode(struct inode *inode)
249 kmem_cache_free(adfs_inode_cachep, ADFS_I(inode)); 249 kmem_cache_free(adfs_inode_cachep, ADFS_I(inode));
250} 250}
251 251
252static void init_once(struct kmem_cache *cachep, void *foo) 252static void init_once(void *foo)
253{ 253{
254 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; 254 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo;
255 255
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 223b1917093e..e9ec915f7553 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -2,6 +2,7 @@
2#include <linux/fs.h> 2#include <linux/fs.h>
3#include <linux/buffer_head.h> 3#include <linux/buffer_head.h>
4#include <linux/amigaffs.h> 4#include <linux/amigaffs.h>
5#include <linux/mutex.h>
5 6
6/* AmigaOS allows file names with up to 30 characters length. 7/* AmigaOS allows file names with up to 30 characters length.
7 * Names longer than that will be silently truncated. If you 8 * Names longer than that will be silently truncated. If you
@@ -98,7 +99,7 @@ struct affs_sb_info {
98 gid_t s_gid; /* gid to override */ 99 gid_t s_gid; /* gid to override */
99 umode_t s_mode; /* mode to override */ 100 umode_t s_mode; /* mode to override */
100 struct buffer_head *s_root_bh; /* Cached root block. */ 101 struct buffer_head *s_root_bh; /* Cached root block. */
101 struct semaphore s_bmlock; /* Protects bitmap access. */ 102 struct mutex s_bmlock; /* Protects bitmap access. */
102 struct affs_bm_info *s_bitmap; /* Bitmap infos. */ 103 struct affs_bm_info *s_bitmap; /* Bitmap infos. */
103 u32 s_bmap_count; /* # of bitmap blocks. */ 104 u32 s_bmap_count; /* # of bitmap blocks. */
104 u32 s_bmap_bits; /* # of bits in one bitmap blocks */ 105 u32 s_bmap_bits; /* # of bits in one bitmap blocks */
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c
index c4a5ad09ddf2..dc5ef14bdc1c 100644
--- a/fs/affs/bitmap.c
+++ b/fs/affs/bitmap.c
@@ -45,14 +45,14 @@ affs_count_free_blocks(struct super_block *sb)
45 if (sb->s_flags & MS_RDONLY) 45 if (sb->s_flags & MS_RDONLY)
46 return 0; 46 return 0;
47 47
48 down(&AFFS_SB(sb)->s_bmlock); 48 mutex_lock(&AFFS_SB(sb)->s_bmlock);
49 49
50 bm = AFFS_SB(sb)->s_bitmap; 50 bm = AFFS_SB(sb)->s_bitmap;
51 free = 0; 51 free = 0;
52 for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--) 52 for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--)
53 free += bm->bm_free; 53 free += bm->bm_free;
54 54
55 up(&AFFS_SB(sb)->s_bmlock); 55 mutex_unlock(&AFFS_SB(sb)->s_bmlock);
56 56
57 return free; 57 return free;
58} 58}
@@ -76,7 +76,7 @@ affs_free_block(struct super_block *sb, u32 block)
76 bit = blk % sbi->s_bmap_bits; 76 bit = blk % sbi->s_bmap_bits;
77 bm = &sbi->s_bitmap[bmap]; 77 bm = &sbi->s_bitmap[bmap];
78 78
79 down(&sbi->s_bmlock); 79 mutex_lock(&sbi->s_bmlock);
80 80
81 bh = sbi->s_bmap_bh; 81 bh = sbi->s_bmap_bh;
82 if (sbi->s_last_bmap != bmap) { 82 if (sbi->s_last_bmap != bmap) {
@@ -105,19 +105,19 @@ affs_free_block(struct super_block *sb, u32 block)
105 sb->s_dirt = 1; 105 sb->s_dirt = 1;
106 bm->bm_free++; 106 bm->bm_free++;
107 107
108 up(&sbi->s_bmlock); 108 mutex_unlock(&sbi->s_bmlock);
109 return; 109 return;
110 110
111err_free: 111err_free:
112 affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block); 112 affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block);
113 up(&sbi->s_bmlock); 113 mutex_unlock(&sbi->s_bmlock);
114 return; 114 return;
115 115
116err_bh_read: 116err_bh_read:
117 affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key); 117 affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key);
118 sbi->s_bmap_bh = NULL; 118 sbi->s_bmap_bh = NULL;
119 sbi->s_last_bmap = ~0; 119 sbi->s_last_bmap = ~0;
120 up(&sbi->s_bmlock); 120 mutex_unlock(&sbi->s_bmlock);
121 return; 121 return;
122 122
123err_range: 123err_range:
@@ -168,7 +168,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
168 bmap = blk / sbi->s_bmap_bits; 168 bmap = blk / sbi->s_bmap_bits;
169 bm = &sbi->s_bitmap[bmap]; 169 bm = &sbi->s_bitmap[bmap];
170 170
171 down(&sbi->s_bmlock); 171 mutex_lock(&sbi->s_bmlock);
172 172
173 if (bm->bm_free) 173 if (bm->bm_free)
174 goto find_bmap_bit; 174 goto find_bmap_bit;
@@ -249,7 +249,7 @@ find_bit:
249 mark_buffer_dirty(bh); 249 mark_buffer_dirty(bh);
250 sb->s_dirt = 1; 250 sb->s_dirt = 1;
251 251
252 up(&sbi->s_bmlock); 252 mutex_unlock(&sbi->s_bmlock);
253 253
254 pr_debug("%d\n", blk); 254 pr_debug("%d\n", blk);
255 return blk; 255 return blk;
@@ -259,7 +259,7 @@ err_bh_read:
259 sbi->s_bmap_bh = NULL; 259 sbi->s_bmap_bh = NULL;
260 sbi->s_last_bmap = ~0; 260 sbi->s_last_bmap = ~0;
261err_full: 261err_full:
262 up(&sbi->s_bmlock); 262 mutex_unlock(&sbi->s_bmlock);
263 pr_debug("failed\n"); 263 pr_debug("failed\n");
264 return 0; 264 return 0;
265} 265}
diff --git a/fs/affs/super.c b/fs/affs/super.c
index d214837d5e42..3a89094f93d0 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -90,7 +90,7 @@ static void affs_destroy_inode(struct inode *inode)
90 kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); 90 kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
91} 91}
92 92
93static void init_once(struct kmem_cache *cachep, void *foo) 93static void init_once(void *foo)
94{ 94{
95 struct affs_inode_info *ei = (struct affs_inode_info *) foo; 95 struct affs_inode_info *ei = (struct affs_inode_info *) foo;
96 96
@@ -290,7 +290,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
290 if (!sbi) 290 if (!sbi)
291 return -ENOMEM; 291 return -ENOMEM;
292 sb->s_fs_info = sbi; 292 sb->s_fs_info = sbi;
293 init_MUTEX(&sbi->s_bmlock); 293 mutex_init(&sbi->s_bmlock);
294 294
295 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, 295 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
296 &blocksize,&sbi->s_prefix, 296 &blocksize,&sbi->s_prefix,
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 7e3faeef6818..250d8c4d66e4 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -27,7 +27,7 @@
27 27
28#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ 28#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */
29 29
30static void afs_i_init_once(struct kmem_cache *cachep, void *foo); 30static void afs_i_init_once(void *foo);
31static int afs_get_sb(struct file_system_type *fs_type, 31static int afs_get_sb(struct file_system_type *fs_type,
32 int flags, const char *dev_name, 32 int flags, const char *dev_name,
33 void *data, struct vfsmount *mnt); 33 void *data, struct vfsmount *mnt);
@@ -449,7 +449,7 @@ static void afs_put_super(struct super_block *sb)
449/* 449/*
450 * initialise an inode cache slab element prior to any use 450 * initialise an inode cache slab element prior to any use
451 */ 451 */
452static void afs_i_init_once(struct kmem_cache *cachep, void *_vnode) 452static void afs_i_init_once(void *_vnode)
453{ 453{
454 struct afs_vnode *vnode = _vnode; 454 struct afs_vnode *vnode = _vnode;
455 455
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index e8717de3bab3..02c6e62b72f8 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -289,7 +289,7 @@ befs_destroy_inode(struct inode *inode)
289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); 289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode));
290} 290}
291 291
292static void init_once(struct kmem_cache *cachep, void *foo) 292static void init_once(void *foo)
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
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h
index 70f5d3a8eede..7109e451abf7 100644
--- a/fs/bfs/bfs.h
+++ b/fs/bfs/bfs.h
@@ -16,8 +16,9 @@ struct bfs_sb_info {
16 unsigned long si_freei; 16 unsigned long si_freei;
17 unsigned long si_lf_eblk; 17 unsigned long si_lf_eblk;
18 unsigned long si_lasti; 18 unsigned long si_lasti;
19 unsigned long * si_imap; 19 unsigned long *si_imap;
20 struct buffer_head * si_sbh; /* buffer header w/superblock */ 20 struct buffer_head *si_sbh; /* buffer header w/superblock */
21 struct mutex bfs_lock;
21}; 22};
22 23
23/* 24/*
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 034950cb3cbe..87ee5ccee348 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -32,16 +32,17 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
32 struct inode *dir = f->f_path.dentry->d_inode; 32 struct inode *dir = f->f_path.dentry->d_inode;
33 struct buffer_head *bh; 33 struct buffer_head *bh;
34 struct bfs_dirent *de; 34 struct bfs_dirent *de;
35 struct bfs_sb_info *info = BFS_SB(dir->i_sb);
35 unsigned int offset; 36 unsigned int offset;
36 int block; 37 int block;
37 38
38 lock_kernel(); 39 mutex_lock(&info->bfs_lock);
39 40
40 if (f->f_pos & (BFS_DIRENT_SIZE - 1)) { 41 if (f->f_pos & (BFS_DIRENT_SIZE - 1)) {
41 printf("Bad f_pos=%08lx for %s:%08lx\n", 42 printf("Bad f_pos=%08lx for %s:%08lx\n",
42 (unsigned long)f->f_pos, 43 (unsigned long)f->f_pos,
43 dir->i_sb->s_id, dir->i_ino); 44 dir->i_sb->s_id, dir->i_ino);
44 unlock_kernel(); 45 mutex_unlock(&info->bfs_lock);
45 return -EBADF; 46 return -EBADF;
46 } 47 }
47 48
@@ -61,7 +62,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
61 le16_to_cpu(de->ino), 62 le16_to_cpu(de->ino),
62 DT_UNKNOWN) < 0) { 63 DT_UNKNOWN) < 0) {
63 brelse(bh); 64 brelse(bh);
64 unlock_kernel(); 65 mutex_unlock(&info->bfs_lock);
65 return 0; 66 return 0;
66 } 67 }
67 } 68 }
@@ -71,7 +72,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
71 brelse(bh); 72 brelse(bh);
72 } 73 }
73 74
74 unlock_kernel(); 75 mutex_unlock(&info->bfs_lock);
75 return 0; 76 return 0;
76} 77}
77 78
@@ -95,10 +96,10 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode,
95 inode = new_inode(s); 96 inode = new_inode(s);
96 if (!inode) 97 if (!inode)
97 return -ENOSPC; 98 return -ENOSPC;
98 lock_kernel(); 99 mutex_lock(&info->bfs_lock);
99 ino = find_first_zero_bit(info->si_imap, info->si_lasti); 100 ino = find_first_zero_bit(info->si_imap, info->si_lasti);
100 if (ino > info->si_lasti) { 101 if (ino > info->si_lasti) {
101 unlock_kernel(); 102 mutex_unlock(&info->bfs_lock);
102 iput(inode); 103 iput(inode);
103 return -ENOSPC; 104 return -ENOSPC;
104 } 105 }
@@ -125,10 +126,10 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, int mode,
125 if (err) { 126 if (err) {
126 inode_dec_link_count(inode); 127 inode_dec_link_count(inode);
127 iput(inode); 128 iput(inode);
128 unlock_kernel(); 129 mutex_unlock(&info->bfs_lock);
129 return err; 130 return err;
130 } 131 }
131 unlock_kernel(); 132 mutex_unlock(&info->bfs_lock);
132 d_instantiate(dentry, inode); 133 d_instantiate(dentry, inode);
133 return 0; 134 return 0;
134} 135}
@@ -139,22 +140,23 @@ static struct dentry *bfs_lookup(struct inode *dir, struct dentry *dentry,
139 struct inode *inode = NULL; 140 struct inode *inode = NULL;
140 struct buffer_head *bh; 141 struct buffer_head *bh;
141 struct bfs_dirent *de; 142 struct bfs_dirent *de;
143 struct bfs_sb_info *info = BFS_SB(dir->i_sb);
142 144
143 if (dentry->d_name.len > BFS_NAMELEN) 145 if (dentry->d_name.len > BFS_NAMELEN)
144 return ERR_PTR(-ENAMETOOLONG); 146 return ERR_PTR(-ENAMETOOLONG);
145 147
146 lock_kernel(); 148 mutex_lock(&info->bfs_lock);
147 bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); 149 bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de);
148 if (bh) { 150 if (bh) {
149 unsigned long ino = (unsigned long)le16_to_cpu(de->ino); 151 unsigned long ino = (unsigned long)le16_to_cpu(de->ino);
150 brelse(bh); 152 brelse(bh);
151 inode = bfs_iget(dir->i_sb, ino); 153 inode = bfs_iget(dir->i_sb, ino);
152 if (IS_ERR(inode)) { 154 if (IS_ERR(inode)) {
153 unlock_kernel(); 155 mutex_unlock(&info->bfs_lock);
154 return ERR_CAST(inode); 156 return ERR_CAST(inode);
155 } 157 }
156 } 158 }
157 unlock_kernel(); 159 mutex_unlock(&info->bfs_lock);
158 d_add(dentry, inode); 160 d_add(dentry, inode);
159 return NULL; 161 return NULL;
160} 162}
@@ -163,13 +165,14 @@ static int bfs_link(struct dentry *old, struct inode *dir,
163 struct dentry *new) 165 struct dentry *new)
164{ 166{
165 struct inode *inode = old->d_inode; 167 struct inode *inode = old->d_inode;
168 struct bfs_sb_info *info = BFS_SB(inode->i_sb);
166 int err; 169 int err;
167 170
168 lock_kernel(); 171 mutex_lock(&info->bfs_lock);
169 err = bfs_add_entry(dir, new->d_name.name, new->d_name.len, 172 err = bfs_add_entry(dir, new->d_name.name, new->d_name.len,
170 inode->i_ino); 173 inode->i_ino);
171 if (err) { 174 if (err) {
172 unlock_kernel(); 175 mutex_unlock(&info->bfs_lock);
173 return err; 176 return err;
174 } 177 }
175 inc_nlink(inode); 178 inc_nlink(inode);
@@ -177,19 +180,19 @@ static int bfs_link(struct dentry *old, struct inode *dir,
177 mark_inode_dirty(inode); 180 mark_inode_dirty(inode);
178 atomic_inc(&inode->i_count); 181 atomic_inc(&inode->i_count);
179 d_instantiate(new, inode); 182 d_instantiate(new, inode);
180 unlock_kernel(); 183 mutex_unlock(&info->bfs_lock);
181 return 0; 184 return 0;
182} 185}
183 186
184static int bfs_unlink(struct inode *dir, struct dentry *dentry) 187static int bfs_unlink(struct inode *dir, struct dentry *dentry)
185{ 188{
186 int error = -ENOENT; 189 int error = -ENOENT;
187 struct inode *inode; 190 struct inode *inode = dentry->d_inode;
188 struct buffer_head *bh; 191 struct buffer_head *bh;
189 struct bfs_dirent *de; 192 struct bfs_dirent *de;
193 struct bfs_sb_info *info = BFS_SB(inode->i_sb);
190 194
191 inode = dentry->d_inode; 195 mutex_lock(&info->bfs_lock);
192 lock_kernel();
193 bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); 196 bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de);
194 if (!bh || (le16_to_cpu(de->ino) != inode->i_ino)) 197 if (!bh || (le16_to_cpu(de->ino) != inode->i_ino))
195 goto out_brelse; 198 goto out_brelse;
@@ -210,7 +213,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
210 213
211out_brelse: 214out_brelse:
212 brelse(bh); 215 brelse(bh);
213 unlock_kernel(); 216 mutex_unlock(&info->bfs_lock);
214 return error; 217 return error;
215} 218}
216 219
@@ -220,6 +223,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
220 struct inode *old_inode, *new_inode; 223 struct inode *old_inode, *new_inode;
221 struct buffer_head *old_bh, *new_bh; 224 struct buffer_head *old_bh, *new_bh;
222 struct bfs_dirent *old_de, *new_de; 225 struct bfs_dirent *old_de, *new_de;
226 struct bfs_sb_info *info;
223 int error = -ENOENT; 227 int error = -ENOENT;
224 228
225 old_bh = new_bh = NULL; 229 old_bh = new_bh = NULL;
@@ -227,7 +231,9 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
227 if (S_ISDIR(old_inode->i_mode)) 231 if (S_ISDIR(old_inode->i_mode))
228 return -EINVAL; 232 return -EINVAL;
229 233
230 lock_kernel(); 234 info = BFS_SB(old_inode->i_sb);
235
236 mutex_lock(&info->bfs_lock);
231 old_bh = bfs_find_entry(old_dir, 237 old_bh = bfs_find_entry(old_dir,
232 old_dentry->d_name.name, 238 old_dentry->d_name.name,
233 old_dentry->d_name.len, &old_de); 239 old_dentry->d_name.len, &old_de);
@@ -264,7 +270,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
264 error = 0; 270 error = 0;
265 271
266end_rename: 272end_rename:
267 unlock_kernel(); 273 mutex_unlock(&info->bfs_lock);
268 brelse(old_bh); 274 brelse(old_bh);
269 brelse(new_bh); 275 brelse(new_bh);
270 return error; 276 return error;
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index b11e63e8fbcd..6a021265f018 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -99,7 +99,7 @@ static int bfs_get_block(struct inode *inode, sector_t block,
99 return -ENOSPC; 99 return -ENOSPC;
100 100
101 /* The rest has to be protected against itself. */ 101 /* The rest has to be protected against itself. */
102 lock_kernel(); 102 mutex_lock(&info->bfs_lock);
103 103
104 /* 104 /*
105 * If the last data block for this file is the last allocated 105 * If the last data block for this file is the last allocated
@@ -151,7 +151,7 @@ static int bfs_get_block(struct inode *inode, sector_t block,
151 mark_buffer_dirty(sbh); 151 mark_buffer_dirty(sbh);
152 map_bh(bh_result, sb, phys); 152 map_bh(bh_result, sb, phys);
153out: 153out:
154 unlock_kernel(); 154 mutex_unlock(&info->bfs_lock);
155 return err; 155 return err;
156} 156}
157 157
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 8db623838b50..0ed57b5ee012 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -104,6 +104,7 @@ static int bfs_write_inode(struct inode *inode, int unused)
104 struct bfs_inode *di; 104 struct bfs_inode *di;
105 struct buffer_head *bh; 105 struct buffer_head *bh;
106 int block, off; 106 int block, off;
107 struct bfs_sb_info *info = BFS_SB(inode->i_sb);
107 108
108 dprintf("ino=%08x\n", ino); 109 dprintf("ino=%08x\n", ino);
109 110
@@ -112,13 +113,13 @@ static int bfs_write_inode(struct inode *inode, int unused)
112 return -EIO; 113 return -EIO;
113 } 114 }
114 115
115 lock_kernel(); 116 mutex_lock(&info->bfs_lock);
116 block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; 117 block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
117 bh = sb_bread(inode->i_sb, block); 118 bh = sb_bread(inode->i_sb, block);
118 if (!bh) { 119 if (!bh) {
119 printf("Unable to read inode %s:%08x\n", 120 printf("Unable to read inode %s:%08x\n",
120 inode->i_sb->s_id, ino); 121 inode->i_sb->s_id, ino);
121 unlock_kernel(); 122 mutex_unlock(&info->bfs_lock);
122 return -EIO; 123 return -EIO;
123 } 124 }
124 125
@@ -145,7 +146,7 @@ static int bfs_write_inode(struct inode *inode, int unused)
145 146
146 mark_buffer_dirty(bh); 147 mark_buffer_dirty(bh);
147 brelse(bh); 148 brelse(bh);
148 unlock_kernel(); 149 mutex_unlock(&info->bfs_lock);
149 return 0; 150 return 0;
150} 151}
151 152
@@ -170,7 +171,7 @@ static void bfs_delete_inode(struct inode *inode)
170 171
171 inode->i_size = 0; 172 inode->i_size = 0;
172 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; 173 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
173 lock_kernel(); 174 mutex_lock(&info->bfs_lock);
174 mark_inode_dirty(inode); 175 mark_inode_dirty(inode);
175 176
176 block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; 177 block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
@@ -178,7 +179,7 @@ static void bfs_delete_inode(struct inode *inode)
178 if (!bh) { 179 if (!bh) {
179 printf("Unable to read inode %s:%08lx\n", 180 printf("Unable to read inode %s:%08lx\n",
180 inode->i_sb->s_id, ino); 181 inode->i_sb->s_id, ino);
181 unlock_kernel(); 182 mutex_unlock(&info->bfs_lock);
182 return; 183 return;
183 } 184 }
184 off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; 185 off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
@@ -204,14 +205,16 @@ static void bfs_delete_inode(struct inode *inode)
204 info->si_lf_eblk = bi->i_sblock - 1; 205 info->si_lf_eblk = bi->i_sblock - 1;
205 mark_buffer_dirty(info->si_sbh); 206 mark_buffer_dirty(info->si_sbh);
206 } 207 }
207 unlock_kernel(); 208 mutex_unlock(&info->bfs_lock);
208 clear_inode(inode); 209 clear_inode(inode);
209} 210}
210 211
211static void bfs_put_super(struct super_block *s) 212static void bfs_put_super(struct super_block *s)
212{ 213{
213 struct bfs_sb_info *info = BFS_SB(s); 214 struct bfs_sb_info *info = BFS_SB(s);
215
214 brelse(info->si_sbh); 216 brelse(info->si_sbh);
217 mutex_destroy(&info->bfs_lock);
215 kfree(info->si_imap); 218 kfree(info->si_imap);
216 kfree(info); 219 kfree(info);
217 s->s_fs_info = NULL; 220 s->s_fs_info = NULL;
@@ -236,11 +239,13 @@ static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf)
236 239
237static void bfs_write_super(struct super_block *s) 240static void bfs_write_super(struct super_block *s)
238{ 241{
239 lock_kernel(); 242 struct bfs_sb_info *info = BFS_SB(s);
243
244 mutex_lock(&info->bfs_lock);
240 if (!(s->s_flags & MS_RDONLY)) 245 if (!(s->s_flags & MS_RDONLY))
241 mark_buffer_dirty(BFS_SB(s)->si_sbh); 246 mark_buffer_dirty(info->si_sbh);
242 s->s_dirt = 0; 247 s->s_dirt = 0;
243 unlock_kernel(); 248 mutex_unlock(&info->bfs_lock);
244} 249}
245 250
246static struct kmem_cache *bfs_inode_cachep; 251static struct kmem_cache *bfs_inode_cachep;
@@ -259,7 +264,7 @@ static void bfs_destroy_inode(struct inode *inode)
259 kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); 264 kmem_cache_free(bfs_inode_cachep, BFS_I(inode));
260} 265}
261 266
262static void init_once(struct kmem_cache *cachep, void *foo) 267static void init_once(void *foo)
263{ 268{
264 struct bfs_inode_info *bi = foo; 269 struct bfs_inode_info *bi = foo;
265 270
@@ -380,7 +385,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
380 struct bfs_inode *di; 385 struct bfs_inode *di;
381 int block = (i - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; 386 int block = (i - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1;
382 int off = (i - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; 387 int off = (i - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
383 unsigned long sblock, eblock; 388 unsigned long eblock;
384 389
385 if (!off) { 390 if (!off) {
386 brelse(bh); 391 brelse(bh);
@@ -399,7 +404,6 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
399 set_bit(i, info->si_imap); 404 set_bit(i, info->si_imap);
400 info->si_freeb -= BFS_FILEBLOCKS(di); 405 info->si_freeb -= BFS_FILEBLOCKS(di);
401 406
402 sblock = le32_to_cpu(di->i_sblock);
403 eblock = le32_to_cpu(di->i_eblock); 407 eblock = le32_to_cpu(di->i_eblock);
404 if (eblock > info->si_lf_eblk) 408 if (eblock > info->si_lf_eblk)
405 info->si_lf_eblk = eblock; 409 info->si_lf_eblk = eblock;
@@ -410,6 +414,7 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
410 s->s_dirt = 1; 414 s->s_dirt = 1;
411 } 415 }
412 dump_imap("read_super", s); 416 dump_imap("read_super", s);
417 mutex_init(&info->bfs_lock);
413 return 0; 418 return 0;
414 419
415out: 420out:
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index ba4cddb92f1d..204cfd1d7676 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -444,12 +444,6 @@ beyond_if:
444 regs->gp = ex.a_gpvalue; 444 regs->gp = ex.a_gpvalue;
445#endif 445#endif
446 start_thread(regs, ex.a_entry, current->mm->start_stack); 446 start_thread(regs, ex.a_entry, current->mm->start_stack);
447 if (unlikely(current->ptrace & PT_PTRACED)) {
448 if (current->ptrace & PT_TRACE_EXEC)
449 ptrace_notify ((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
450 else
451 send_sig(SIGTRAP, current, 0);
452 }
453 return 0; 447 return 0;
454} 448}
455 449
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 3b6ff854d983..655ed8d30a86 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1003,12 +1003,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
1003#endif 1003#endif
1004 1004
1005 start_thread(regs, elf_entry, bprm->p); 1005 start_thread(regs, elf_entry, bprm->p);
1006 if (unlikely(current->ptrace & PT_PTRACED)) {
1007 if (current->ptrace & PT_TRACE_EXEC)
1008 ptrace_notify ((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
1009 else
1010 send_sig(SIGTRAP, current, 0);
1011 }
1012 retval = 0; 1006 retval = 0;
1013out: 1007out:
1014 kfree(loc); 1008 kfree(loc);
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 1b59b1edf26d..fdeadab2f18b 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -433,13 +433,6 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
433 entryaddr = interp_params.entry_addr ?: exec_params.entry_addr; 433 entryaddr = interp_params.entry_addr ?: exec_params.entry_addr;
434 start_thread(regs, entryaddr, current->mm->start_stack); 434 start_thread(regs, entryaddr, current->mm->start_stack);
435 435
436 if (unlikely(current->ptrace & PT_PTRACED)) {
437 if (current->ptrace & PT_TRACE_EXEC)
438 ptrace_notify((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
439 else
440 send_sig(SIGTRAP, current, 0);
441 }
442
443 retval = 0; 436 retval = 0;
444 437
445error: 438error:
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 2cb1acda3a82..56372ecf1690 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -920,9 +920,6 @@ static int load_flat_binary(struct linux_binprm * bprm, struct pt_regs * regs)
920 920
921 start_thread(regs, start_addr, current->mm->start_stack); 921 start_thread(regs, start_addr, current->mm->start_stack);
922 922
923 if (current->ptrace & PT_PTRACED)
924 send_sig(SIGTRAP, current, 0);
925
926 return 0; 923 return 0;
927} 924}
928 925
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c
index fdc36bfd6a7b..68be580ba289 100644
--- a/fs/binfmt_som.c
+++ b/fs/binfmt_som.c
@@ -274,8 +274,6 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
274 map_hpux_gateway_page(current,current->mm); 274 map_hpux_gateway_page(current,current->mm);
275 275
276 start_thread_som(regs, som_entry, bprm->p); 276 start_thread_som(regs, som_entry, bprm->p);
277 if (current->ptrace & PT_PTRACED)
278 send_sig(SIGTRAP, current, 0);
279 return 0; 277 return 0;
280 278
281 /* error cleanup */ 279 /* error cleanup */
diff --git a/fs/bio.c b/fs/bio.c
index 88322b066acb..25f1af0d81e5 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -721,12 +721,8 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
721 const int local_nr_pages = end - start; 721 const int local_nr_pages = end - start;
722 const int page_limit = cur_page + local_nr_pages; 722 const int page_limit = cur_page + local_nr_pages;
723 723
724 down_read(&current->mm->mmap_sem); 724 ret = get_user_pages_fast(uaddr, local_nr_pages,
725 ret = get_user_pages(current, current->mm, uaddr, 725 write_to_vm, &pages[cur_page]);
726 local_nr_pages,
727 write_to_vm, 0, &pages[cur_page], NULL);
728 up_read(&current->mm->mmap_sem);
729
730 if (ret < local_nr_pages) { 726 if (ret < local_nr_pages) {
731 ret = -EFAULT; 727 ret = -EFAULT;
732 goto out_unmap; 728 goto out_unmap;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 10d8a0aa871a..dcf37cada369 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -271,7 +271,7 @@ static void bdev_destroy_inode(struct inode *inode)
271 kmem_cache_free(bdev_cachep, bdi); 271 kmem_cache_free(bdev_cachep, bdi);
272} 272}
273 273
274static void init_once(struct kmem_cache * cachep, void *foo) 274static void init_once(void *foo)
275{ 275{
276 struct bdev_inode *ei = (struct bdev_inode *) foo; 276 struct bdev_inode *ei = (struct bdev_inode *) foo;
277 struct block_device *bdev = &ei->bdev; 277 struct block_device *bdev = &ei->bdev;
diff --git a/fs/buffer.c b/fs/buffer.c
index d48caee12e2a..f95805019639 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -706,7 +706,7 @@ static int __set_page_dirty(struct page *page,
706 if (TestSetPageDirty(page)) 706 if (TestSetPageDirty(page))
707 return 0; 707 return 0;
708 708
709 write_lock_irq(&mapping->tree_lock); 709 spin_lock_irq(&mapping->tree_lock);
710 if (page->mapping) { /* Race with truncate? */ 710 if (page->mapping) { /* Race with truncate? */
711 WARN_ON_ONCE(warn && !PageUptodate(page)); 711 WARN_ON_ONCE(warn && !PageUptodate(page));
712 712
@@ -719,7 +719,7 @@ static int __set_page_dirty(struct page *page,
719 radix_tree_tag_set(&mapping->page_tree, 719 radix_tree_tag_set(&mapping->page_tree,
720 page_index(page), PAGECACHE_TAG_DIRTY); 720 page_index(page), PAGECACHE_TAG_DIRTY);
721 } 721 }
722 write_unlock_irq(&mapping->tree_lock); 722 spin_unlock_irq(&mapping->tree_lock);
723 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 723 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
724 724
725 return 1; 725 return 1;
@@ -1214,8 +1214,7 @@ void __brelse(struct buffer_head * buf)
1214 put_bh(buf); 1214 put_bh(buf);
1215 return; 1215 return;
1216 } 1216 }
1217 printk(KERN_ERR "VFS: brelse: Trying to free free buffer\n"); 1217 WARN(1, KERN_ERR "VFS: brelse: Trying to free free buffer\n");
1218 WARN_ON(1);
1219} 1218}
1220 1219
1221/* 1220/*
@@ -3272,7 +3271,7 @@ int bh_submit_read(struct buffer_head *bh)
3272EXPORT_SYMBOL(bh_submit_read); 3271EXPORT_SYMBOL(bh_submit_read);
3273 3272
3274static void 3273static void
3275init_buffer_head(struct kmem_cache *cachep, void *data) 3274init_buffer_head(void *data)
3276{ 3275{
3277 struct buffer_head *bh = data; 3276 struct buffer_head *bh = data;
3278 3277
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
index f58e41d3ba48..6bb440b257b0 100644
--- a/fs/cifs/asn1.c
+++ b/fs/cifs/asn1.c
@@ -400,7 +400,7 @@ asn1_oid_decode(struct asn1_ctx *ctx,
400 size = eoc - ctx->pointer + 1; 400 size = eoc - ctx->pointer + 1;
401 401
402 /* first subid actually encodes first two subids */ 402 /* first subid actually encodes first two subids */
403 if (size < 2 || size > ULONG_MAX/sizeof(unsigned long)) 403 if (size < 2 || size > UINT_MAX/sizeof(unsigned long))
404 return 0; 404 return 0;
405 405
406 *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); 406 *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
@@ -494,7 +494,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
494 /* remember to free obj->oid */ 494 /* remember to free obj->oid */
495 rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); 495 rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
496 if (rc) { 496 if (rc) {
497 if ((tag == ASN1_OJI) && (cls == ASN1_PRI)) { 497 if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
498 rc = asn1_oid_decode(&ctx, end, &oid, &oidlen); 498 rc = asn1_oid_decode(&ctx, end, &oid, &oidlen);
499 if (rc) { 499 if (rc) {
500 rc = compare_oid(oid, oidlen, 500 rc = compare_oid(oid, oidlen,
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index cc950f69e51e..688a2d42153f 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -107,9 +107,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
107#endif /* CONFIG_CIFS_DEBUG2 */ 107#endif /* CONFIG_CIFS_DEBUG2 */
108 108
109#ifdef CONFIG_PROC_FS 109#ifdef CONFIG_PROC_FS
110static int 110static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
111cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
112 int count, int *eof, void *data)
113{ 111{
114 struct list_head *tmp; 112 struct list_head *tmp;
115 struct list_head *tmp1; 113 struct list_head *tmp1;
@@ -117,23 +115,13 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
117 struct cifsSesInfo *ses; 115 struct cifsSesInfo *ses;
118 struct cifsTconInfo *tcon; 116 struct cifsTconInfo *tcon;
119 int i; 117 int i;
120 int length = 0;
121 char *original_buf = buf;
122 118
123 *beginBuffer = buf + offset; 119 seq_puts(m,
124
125 length =
126 sprintf(buf,
127 "Display Internal CIFS Data Structures for Debugging\n" 120 "Display Internal CIFS Data Structures for Debugging\n"
128 "---------------------------------------------------\n"); 121 "---------------------------------------------------\n");
129 buf += length; 122 seq_printf(m, "CIFS Version %s\n", CIFS_VERSION);
130 length = sprintf(buf, "CIFS Version %s\n", CIFS_VERSION); 123 seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
131 buf += length; 124 seq_printf(m, "Servers:");
132 length = sprintf(buf,
133 "Active VFS Requests: %d\n", GlobalTotalActiveXid);
134 buf += length;
135 length = sprintf(buf, "Servers:");
136 buf += length;
137 125
138 i = 0; 126 i = 0;
139 read_lock(&GlobalSMBSeslock); 127 read_lock(&GlobalSMBSeslock);
@@ -142,11 +130,10 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
142 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 130 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
143 if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) || 131 if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
144 (ses->serverNOS == NULL)) { 132 (ses->serverNOS == NULL)) {
145 buf += sprintf(buf, "\nentry for %s not fully " 133 seq_printf(m, "\nentry for %s not fully "
146 "displayed\n\t", ses->serverName); 134 "displayed\n\t", ses->serverName);
147 } else { 135 } else {
148 length = 136 seq_printf(m,
149 sprintf(buf,
150 "\n%d) Name: %s Domain: %s Mounts: %d OS:" 137 "\n%d) Name: %s Domain: %s Mounts: %d OS:"
151 " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB" 138 " %s \n\tNOS: %s\tCapability: 0x%x\n\tSMB"
152 " session status: %d\t", 139 " session status: %d\t",
@@ -154,10 +141,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
154 atomic_read(&ses->inUse), 141 atomic_read(&ses->inUse),
155 ses->serverOS, ses->serverNOS, 142 ses->serverOS, ses->serverNOS,
156 ses->capabilities, ses->status); 143 ses->capabilities, ses->status);
157 buf += length;
158 } 144 }
159 if (ses->server) { 145 if (ses->server) {
160 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To " 146 seq_printf(m, "TCP status: %d\n\tLocal Users To "
161 "Server: %d SecMode: 0x%x Req On Wire: %d", 147 "Server: %d SecMode: 0x%x Req On Wire: %d",
162 ses->server->tcpStatus, 148 ses->server->tcpStatus,
163 atomic_read(&ses->server->socketUseCount), 149 atomic_read(&ses->server->socketUseCount),
@@ -165,13 +151,12 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
165 atomic_read(&ses->server->inFlight)); 151 atomic_read(&ses->server->inFlight));
166 152
167#ifdef CONFIG_CIFS_STATS2 153#ifdef CONFIG_CIFS_STATS2
168 buf += sprintf(buf, " In Send: %d In MaxReq Wait: %d", 154 seq_printf(m, " In Send: %d In MaxReq Wait: %d",
169 atomic_read(&ses->server->inSend), 155 atomic_read(&ses->server->inSend),
170 atomic_read(&ses->server->num_waiters)); 156 atomic_read(&ses->server->num_waiters));
171#endif 157#endif
172 158
173 length = sprintf(buf, "\nMIDs:\n"); 159 seq_puts(m, "\nMIDs:\n");
174 buf += length;
175 160
176 spin_lock(&GlobalMid_Lock); 161 spin_lock(&GlobalMid_Lock);
177 list_for_each(tmp1, &ses->server->pending_mid_q) { 162 list_for_each(tmp1, &ses->server->pending_mid_q) {
@@ -179,7 +164,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
179 mid_q_entry, 164 mid_q_entry,
180 qhead); 165 qhead);
181 if (mid_entry) { 166 if (mid_entry) {
182 length = sprintf(buf, 167 seq_printf(m,
183 "State: %d com: %d pid:" 168 "State: %d com: %d pid:"
184 " %d tsk: %p mid %d\n", 169 " %d tsk: %p mid %d\n",
185 mid_entry->midState, 170 mid_entry->midState,
@@ -187,7 +172,6 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
187 mid_entry->pid, 172 mid_entry->pid,
188 mid_entry->tsk, 173 mid_entry->tsk,
189 mid_entry->mid); 174 mid_entry->mid);
190 buf += length;
191 } 175 }
192 } 176 }
193 spin_unlock(&GlobalMid_Lock); 177 spin_unlock(&GlobalMid_Lock);
@@ -195,11 +179,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
195 179
196 } 180 }
197 read_unlock(&GlobalSMBSeslock); 181 read_unlock(&GlobalSMBSeslock);
198 sprintf(buf, "\n"); 182 seq_putc(m, '\n');
199 buf++;
200 183
201 length = sprintf(buf, "Shares:"); 184 seq_puts(m, "Shares:");
202 buf += length;
203 185
204 i = 0; 186 i = 0;
205 read_lock(&GlobalSMBSeslock); 187 read_lock(&GlobalSMBSeslock);
@@ -208,62 +190,52 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
208 i++; 190 i++;
209 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 191 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
210 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); 192 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
211 length = sprintf(buf, "\n%d) %s Uses: %d ", i, 193 seq_printf(m, "\n%d) %s Uses: %d ", i,
212 tcon->treeName, atomic_read(&tcon->useCount)); 194 tcon->treeName, atomic_read(&tcon->useCount));
213 buf += length;
214 if (tcon->nativeFileSystem) { 195 if (tcon->nativeFileSystem) {
215 length = sprintf(buf, "Type: %s ", 196 seq_printf(m, "Type: %s ",
216 tcon->nativeFileSystem); 197 tcon->nativeFileSystem);
217 buf += length;
218 } 198 }
219 length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x" 199 seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x"
220 "\nPathComponentMax: %d Status: %d", 200 "\nPathComponentMax: %d Status: %d",
221 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), 201 le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
222 le32_to_cpu(tcon->fsAttrInfo.Attributes), 202 le32_to_cpu(tcon->fsAttrInfo.Attributes),
223 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), 203 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
224 tcon->tidStatus); 204 tcon->tidStatus);
225 buf += length;
226 if (dev_type == FILE_DEVICE_DISK) 205 if (dev_type == FILE_DEVICE_DISK)
227 length = sprintf(buf, " type: DISK "); 206 seq_puts(m, " type: DISK ");
228 else if (dev_type == FILE_DEVICE_CD_ROM) 207 else if (dev_type == FILE_DEVICE_CD_ROM)
229 length = sprintf(buf, " type: CDROM "); 208 seq_puts(m, " type: CDROM ");
230 else 209 else
231 length = 210 seq_printf(m, " type: %d ", dev_type);
232 sprintf(buf, " type: %d ", dev_type); 211
233 buf += length; 212 if (tcon->tidStatus == CifsNeedReconnect)
234 if (tcon->tidStatus == CifsNeedReconnect) { 213 seq_puts(m, "\tDISCONNECTED ");
235 buf += sprintf(buf, "\tDISCONNECTED ");
236 length += 14;
237 }
238 } 214 }
239 read_unlock(&GlobalSMBSeslock); 215 read_unlock(&GlobalSMBSeslock);
240 216
241 length = sprintf(buf, "\n"); 217 seq_putc(m, '\n');
242 buf += length;
243 218
244 /* BB add code to dump additional info such as TCP session info now */ 219 /* BB add code to dump additional info such as TCP session info now */
245 /* Now calculate total size of returned data */ 220 return 0;
246 length = buf - original_buf; 221}
247
248 if (offset + count >= length)
249 *eof = 1;
250 if (length < offset) {
251 *eof = 1;
252 return 0;
253 } else {
254 length = length - offset;
255 }
256 if (length > count)
257 length = count;
258 222
259 return length; 223static int cifs_debug_data_proc_open(struct inode *inode, struct file *file)
224{
225 return single_open(file, cifs_debug_data_proc_show, NULL);
260} 226}
261 227
262#ifdef CONFIG_CIFS_STATS 228static const struct file_operations cifs_debug_data_proc_fops = {
229 .owner = THIS_MODULE,
230 .open = cifs_debug_data_proc_open,
231 .read = seq_read,
232 .llseek = seq_lseek,
233 .release = single_release,
234};
263 235
264static int 236#ifdef CONFIG_CIFS_STATS
265cifs_stats_write(struct file *file, const char __user *buffer, 237static ssize_t cifs_stats_proc_write(struct file *file,
266 unsigned long count, void *data) 238 const char __user *buffer, size_t count, loff_t *ppos)
267{ 239{
268 char c; 240 char c;
269 int rc; 241 int rc;
@@ -307,236 +279,132 @@ cifs_stats_write(struct file *file, const char __user *buffer,
307 return count; 279 return count;
308} 280}
309 281
310static int 282static int cifs_stats_proc_show(struct seq_file *m, void *v)
311cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
312 int count, int *eof, void *data)
313{ 283{
314 int item_length, i, length; 284 int i;
315 struct list_head *tmp; 285 struct list_head *tmp;
316 struct cifsTconInfo *tcon; 286 struct cifsTconInfo *tcon;
317 287
318 *beginBuffer = buf + offset; 288 seq_printf(m,
319
320 length = sprintf(buf,
321 "Resources in use\nCIFS Session: %d\n", 289 "Resources in use\nCIFS Session: %d\n",
322 sesInfoAllocCount.counter); 290 sesInfoAllocCount.counter);
323 buf += length; 291 seq_printf(m, "Share (unique mount targets): %d\n",
324 item_length =
325 sprintf(buf, "Share (unique mount targets): %d\n",
326 tconInfoAllocCount.counter); 292 tconInfoAllocCount.counter);
327 length += item_length; 293 seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n",
328 buf += item_length;
329 item_length =
330 sprintf(buf, "SMB Request/Response Buffer: %d Pool size: %d\n",
331 bufAllocCount.counter, 294 bufAllocCount.counter,
332 cifs_min_rcv + tcpSesAllocCount.counter); 295 cifs_min_rcv + tcpSesAllocCount.counter);
333 length += item_length; 296 seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
334 buf += item_length;
335 item_length =
336 sprintf(buf, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
337 smBufAllocCount.counter, cifs_min_small); 297 smBufAllocCount.counter, cifs_min_small);
338 length += item_length;
339 buf += item_length;
340#ifdef CONFIG_CIFS_STATS2 298#ifdef CONFIG_CIFS_STATS2
341 item_length = sprintf(buf, "Total Large %d Small %d Allocations\n", 299 seq_printf(m, "Total Large %d Small %d Allocations\n",
342 atomic_read(&totBufAllocCount), 300 atomic_read(&totBufAllocCount),
343 atomic_read(&totSmBufAllocCount)); 301 atomic_read(&totSmBufAllocCount));
344 length += item_length;
345 buf += item_length;
346#endif /* CONFIG_CIFS_STATS2 */ 302#endif /* CONFIG_CIFS_STATS2 */
347 303
348 item_length = 304 seq_printf(m, "Operations (MIDs): %d\n", midCount.counter);
349 sprintf(buf, "Operations (MIDs): %d\n", 305 seq_printf(m,
350 midCount.counter);
351 length += item_length;
352 buf += item_length;
353 item_length = sprintf(buf,
354 "\n%d session %d share reconnects\n", 306 "\n%d session %d share reconnects\n",
355 tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); 307 tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
356 length += item_length;
357 buf += item_length;
358 308
359 item_length = sprintf(buf, 309 seq_printf(m,
360 "Total vfs operations: %d maximum at one time: %d\n", 310 "Total vfs operations: %d maximum at one time: %d\n",
361 GlobalCurrentXid, GlobalMaxActiveXid); 311 GlobalCurrentXid, GlobalMaxActiveXid);
362 length += item_length;
363 buf += item_length;
364 312
365 i = 0; 313 i = 0;
366 read_lock(&GlobalSMBSeslock); 314 read_lock(&GlobalSMBSeslock);
367 list_for_each(tmp, &GlobalTreeConnectionList) { 315 list_for_each(tmp, &GlobalTreeConnectionList) {
368 i++; 316 i++;
369 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 317 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
370 item_length = sprintf(buf, "\n%d) %s", i, tcon->treeName); 318 seq_printf(m, "\n%d) %s", i, tcon->treeName);
371 buf += item_length; 319 if (tcon->tidStatus == CifsNeedReconnect)
372 length += item_length; 320 seq_puts(m, "\tDISCONNECTED ");
373 if (tcon->tidStatus == CifsNeedReconnect) { 321 seq_printf(m, "\nSMBs: %d Oplock Breaks: %d",
374 buf += sprintf(buf, "\tDISCONNECTED ");
375 length += 14;
376 }
377 item_length = sprintf(buf, "\nSMBs: %d Oplock Breaks: %d",
378 atomic_read(&tcon->num_smbs_sent), 322 atomic_read(&tcon->num_smbs_sent),
379 atomic_read(&tcon->num_oplock_brks)); 323 atomic_read(&tcon->num_oplock_brks));
380 buf += item_length; 324 seq_printf(m, "\nReads: %d Bytes: %lld",
381 length += item_length;
382 item_length = sprintf(buf, "\nReads: %d Bytes: %lld",
383 atomic_read(&tcon->num_reads), 325 atomic_read(&tcon->num_reads),
384 (long long)(tcon->bytes_read)); 326 (long long)(tcon->bytes_read));
385 buf += item_length; 327 seq_printf(m, "\nWrites: %d Bytes: %lld",
386 length += item_length;
387 item_length = sprintf(buf, "\nWrites: %d Bytes: %lld",
388 atomic_read(&tcon->num_writes), 328 atomic_read(&tcon->num_writes),
389 (long long)(tcon->bytes_written)); 329 (long long)(tcon->bytes_written));
390 buf += item_length; 330 seq_printf(m,
391 length += item_length;
392 item_length = sprintf(buf,
393 "\nLocks: %d HardLinks: %d Symlinks: %d", 331 "\nLocks: %d HardLinks: %d Symlinks: %d",
394 atomic_read(&tcon->num_locks), 332 atomic_read(&tcon->num_locks),
395 atomic_read(&tcon->num_hardlinks), 333 atomic_read(&tcon->num_hardlinks),
396 atomic_read(&tcon->num_symlinks)); 334 atomic_read(&tcon->num_symlinks));
397 buf += item_length;
398 length += item_length;
399 335
400 item_length = sprintf(buf, "\nOpens: %d Closes: %d Deletes: %d", 336 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
401 atomic_read(&tcon->num_opens), 337 atomic_read(&tcon->num_opens),
402 atomic_read(&tcon->num_closes), 338 atomic_read(&tcon->num_closes),
403 atomic_read(&tcon->num_deletes)); 339 atomic_read(&tcon->num_deletes));
404 buf += item_length; 340 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
405 length += item_length;
406 item_length = sprintf(buf, "\nMkdirs: %d Rmdirs: %d",
407 atomic_read(&tcon->num_mkdirs), 341 atomic_read(&tcon->num_mkdirs),
408 atomic_read(&tcon->num_rmdirs)); 342 atomic_read(&tcon->num_rmdirs));
409 buf += item_length; 343 seq_printf(m, "\nRenames: %d T2 Renames %d",
410 length += item_length;
411 item_length = sprintf(buf, "\nRenames: %d T2 Renames %d",
412 atomic_read(&tcon->num_renames), 344 atomic_read(&tcon->num_renames),
413 atomic_read(&tcon->num_t2renames)); 345 atomic_read(&tcon->num_t2renames));
414 buf += item_length; 346 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
415 length += item_length;
416 item_length = sprintf(buf, "\nFindFirst: %d FNext %d FClose %d",
417 atomic_read(&tcon->num_ffirst), 347 atomic_read(&tcon->num_ffirst),
418 atomic_read(&tcon->num_fnext), 348 atomic_read(&tcon->num_fnext),
419 atomic_read(&tcon->num_fclose)); 349 atomic_read(&tcon->num_fclose));
420 buf += item_length;
421 length += item_length;
422 } 350 }
423 read_unlock(&GlobalSMBSeslock); 351 read_unlock(&GlobalSMBSeslock);
424 352
425 buf += sprintf(buf, "\n"); 353 seq_putc(m, '\n');
426 length++; 354 return 0;
427 355}
428 if (offset + count >= length)
429 *eof = 1;
430 if (length < offset) {
431 *eof = 1;
432 return 0;
433 } else {
434 length = length - offset;
435 }
436 if (length > count)
437 length = count;
438 356
439 return length; 357static int cifs_stats_proc_open(struct inode *inode, struct file *file)
358{
359 return single_open(file, cifs_stats_proc_show, NULL);
440} 360}
361
362static const struct file_operations cifs_stats_proc_fops = {
363 .owner = THIS_MODULE,
364 .open = cifs_stats_proc_open,
365 .read = seq_read,
366 .llseek = seq_lseek,
367 .release = single_release,
368 .write = cifs_stats_proc_write,
369};
441#endif /* STATS */ 370#endif /* STATS */
442 371
443static struct proc_dir_entry *proc_fs_cifs; 372static struct proc_dir_entry *proc_fs_cifs;
444read_proc_t cifs_txanchor_read; 373static const struct file_operations cifsFYI_proc_fops;
445static read_proc_t cifsFYI_read; 374static const struct file_operations cifs_oplock_proc_fops;
446static write_proc_t cifsFYI_write; 375static const struct file_operations cifs_lookup_cache_proc_fops;
447static read_proc_t oplockEnabled_read; 376static const struct file_operations traceSMB_proc_fops;
448static write_proc_t oplockEnabled_write; 377static const struct file_operations cifs_multiuser_mount_proc_fops;
449static read_proc_t lookupFlag_read; 378static const struct file_operations cifs_security_flags_proc_fops;
450static write_proc_t lookupFlag_write; 379static const struct file_operations cifs_experimental_proc_fops;
451static read_proc_t traceSMB_read; 380static const struct file_operations cifs_linux_ext_proc_fops;
452static write_proc_t traceSMB_write;
453static read_proc_t multiuser_mount_read;
454static write_proc_t multiuser_mount_write;
455static read_proc_t security_flags_read;
456static write_proc_t security_flags_write;
457/* static read_proc_t ntlmv2_enabled_read;
458static write_proc_t ntlmv2_enabled_write;
459static read_proc_t packet_signing_enabled_read;
460static write_proc_t packet_signing_enabled_write;*/
461static read_proc_t experimEnabled_read;
462static write_proc_t experimEnabled_write;
463static read_proc_t linuxExtensionsEnabled_read;
464static write_proc_t linuxExtensionsEnabled_write;
465 381
466void 382void
467cifs_proc_init(void) 383cifs_proc_init(void)
468{ 384{
469 struct proc_dir_entry *pde;
470
471 proc_fs_cifs = proc_mkdir("fs/cifs", NULL); 385 proc_fs_cifs = proc_mkdir("fs/cifs", NULL);
472 if (proc_fs_cifs == NULL) 386 if (proc_fs_cifs == NULL)
473 return; 387 return;
474 388
475 proc_fs_cifs->owner = THIS_MODULE; 389 proc_fs_cifs->owner = THIS_MODULE;
476 create_proc_read_entry("DebugData", 0, proc_fs_cifs, 390 proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops);
477 cifs_debug_data_read, NULL);
478 391
479#ifdef CONFIG_CIFS_STATS 392#ifdef CONFIG_CIFS_STATS
480 pde = create_proc_read_entry("Stats", 0, proc_fs_cifs, 393 proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops);
481 cifs_stats_read, NULL);
482 if (pde)
483 pde->write_proc = cifs_stats_write;
484#endif /* STATS */ 394#endif /* STATS */
485 pde = create_proc_read_entry("cifsFYI", 0, proc_fs_cifs, 395 proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops);
486 cifsFYI_read, NULL); 396 proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops);
487 if (pde) 397 proc_create("OplockEnabled", 0, proc_fs_cifs, &cifs_oplock_proc_fops);
488 pde->write_proc = cifsFYI_write; 398 proc_create("Experimental", 0, proc_fs_cifs,
489 399 &cifs_experimental_proc_fops);
490 pde = 400 proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs,
491 create_proc_read_entry("traceSMB", 0, proc_fs_cifs, 401 &cifs_linux_ext_proc_fops);
492 traceSMB_read, NULL); 402 proc_create("MultiuserMount", 0, proc_fs_cifs,
493 if (pde) 403 &cifs_multiuser_mount_proc_fops);
494 pde->write_proc = traceSMB_write; 404 proc_create("SecurityFlags", 0, proc_fs_cifs,
495 405 &cifs_security_flags_proc_fops);
496 pde = create_proc_read_entry("OplockEnabled", 0, proc_fs_cifs, 406 proc_create("LookupCacheEnabled", 0, proc_fs_cifs,
497 oplockEnabled_read, NULL); 407 &cifs_lookup_cache_proc_fops);
498 if (pde)
499 pde->write_proc = oplockEnabled_write;
500
501 pde = create_proc_read_entry("Experimental", 0, proc_fs_cifs,
502 experimEnabled_read, NULL);
503 if (pde)
504 pde->write_proc = experimEnabled_write;
505
506 pde = create_proc_read_entry("LinuxExtensionsEnabled", 0, proc_fs_cifs,
507 linuxExtensionsEnabled_read, NULL);
508 if (pde)
509 pde->write_proc = linuxExtensionsEnabled_write;
510
511 pde =
512 create_proc_read_entry("MultiuserMount", 0, proc_fs_cifs,
513 multiuser_mount_read, NULL);
514 if (pde)
515 pde->write_proc = multiuser_mount_write;
516
517 pde =
518 create_proc_read_entry("SecurityFlags", 0, proc_fs_cifs,
519 security_flags_read, NULL);
520 if (pde)
521 pde->write_proc = security_flags_write;
522
523 pde =
524 create_proc_read_entry("LookupCacheEnabled", 0, proc_fs_cifs,
525 lookupFlag_read, NULL);
526 if (pde)
527 pde->write_proc = lookupFlag_write;
528
529/* pde =
530 create_proc_read_entry("NTLMV2Enabled", 0, proc_fs_cifs,
531 ntlmv2_enabled_read, NULL);
532 if (pde)
533 pde->write_proc = ntlmv2_enabled_write;
534
535 pde =
536 create_proc_read_entry("PacketSigningEnabled", 0, proc_fs_cifs,
537 packet_signing_enabled_read, NULL);
538 if (pde)
539 pde->write_proc = packet_signing_enabled_write;*/
540} 408}
541 409
542void 410void
@@ -553,39 +421,26 @@ cifs_proc_clean(void)
553#endif 421#endif
554 remove_proc_entry("MultiuserMount", proc_fs_cifs); 422 remove_proc_entry("MultiuserMount", proc_fs_cifs);
555 remove_proc_entry("OplockEnabled", proc_fs_cifs); 423 remove_proc_entry("OplockEnabled", proc_fs_cifs);
556/* remove_proc_entry("NTLMV2Enabled",proc_fs_cifs); */
557 remove_proc_entry("SecurityFlags", proc_fs_cifs); 424 remove_proc_entry("SecurityFlags", proc_fs_cifs);
558/* remove_proc_entry("PacketSigningEnabled", proc_fs_cifs); */
559 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); 425 remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
560 remove_proc_entry("Experimental", proc_fs_cifs); 426 remove_proc_entry("Experimental", proc_fs_cifs);
561 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); 427 remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
562 remove_proc_entry("fs/cifs", NULL); 428 remove_proc_entry("fs/cifs", NULL);
563} 429}
564 430
565static int 431static int cifsFYI_proc_show(struct seq_file *m, void *v)
566cifsFYI_read(char *page, char **start, off_t off, int count,
567 int *eof, void *data)
568{ 432{
569 int len; 433 seq_printf(m, "%d\n", cifsFYI);
570 434 return 0;
571 len = sprintf(page, "%d\n", cifsFYI); 435}
572
573 len -= off;
574 *start = page + off;
575
576 if (len > count)
577 len = count;
578 else
579 *eof = 1;
580
581 if (len < 0)
582 len = 0;
583 436
584 return len; 437static int cifsFYI_proc_open(struct inode *inode, struct file *file)
438{
439 return single_open(file, cifsFYI_proc_show, NULL);
585} 440}
586static int 441
587cifsFYI_write(struct file *file, const char __user *buffer, 442static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
588 unsigned long count, void *data) 443 size_t count, loff_t *ppos)
589{ 444{
590 char c; 445 char c;
591 int rc; 446 int rc;
@@ -603,30 +458,28 @@ cifsFYI_write(struct file *file, const char __user *buffer,
603 return count; 458 return count;
604} 459}
605 460
606static int 461static const struct file_operations cifsFYI_proc_fops = {
607oplockEnabled_read(char *page, char **start, off_t off, 462 .owner = THIS_MODULE,
608 int count, int *eof, void *data) 463 .open = cifsFYI_proc_open,
609{ 464 .read = seq_read,
610 int len; 465 .llseek = seq_lseek,
611 466 .release = single_release,
612 len = sprintf(page, "%d\n", oplockEnabled); 467 .write = cifsFYI_proc_write,
613 468};
614 len -= off;
615 *start = page + off;
616
617 if (len > count)
618 len = count;
619 else
620 *eof = 1;
621 469
622 if (len < 0) 470static int cifs_oplock_proc_show(struct seq_file *m, void *v)
623 len = 0; 471{
472 seq_printf(m, "%d\n", oplockEnabled);
473 return 0;
474}
624 475
625 return len; 476static int cifs_oplock_proc_open(struct inode *inode, struct file *file)
477{
478 return single_open(file, cifs_oplock_proc_show, NULL);
626} 479}
627static int 480
628oplockEnabled_write(struct file *file, const char __user *buffer, 481static ssize_t cifs_oplock_proc_write(struct file *file,
629 unsigned long count, void *data) 482 const char __user *buffer, size_t count, loff_t *ppos)
630{ 483{
631 char c; 484 char c;
632 int rc; 485 int rc;
@@ -642,30 +495,28 @@ oplockEnabled_write(struct file *file, const char __user *buffer,
642 return count; 495 return count;
643} 496}
644 497
645static int 498static const struct file_operations cifs_oplock_proc_fops = {
646experimEnabled_read(char *page, char **start, off_t off, 499 .owner = THIS_MODULE,
647 int count, int *eof, void *data) 500 .open = cifs_oplock_proc_open,
648{ 501 .read = seq_read,
649 int len; 502 .llseek = seq_lseek,
650 503 .release = single_release,
651 len = sprintf(page, "%d\n", experimEnabled); 504 .write = cifs_oplock_proc_write,
652 505};
653 len -= off;
654 *start = page + off;
655 506
656 if (len > count) 507static int cifs_experimental_proc_show(struct seq_file *m, void *v)
657 len = count; 508{
658 else 509 seq_printf(m, "%d\n", experimEnabled);
659 *eof = 1; 510 return 0;
660 511}
661 if (len < 0)
662 len = 0;
663 512
664 return len; 513static int cifs_experimental_proc_open(struct inode *inode, struct file *file)
514{
515 return single_open(file, cifs_experimental_proc_show, NULL);
665} 516}
666static int 517
667experimEnabled_write(struct file *file, const char __user *buffer, 518static ssize_t cifs_experimental_proc_write(struct file *file,
668 unsigned long count, void *data) 519 const char __user *buffer, size_t count, loff_t *ppos)
669{ 520{
670 char c; 521 char c;
671 int rc; 522 int rc;
@@ -683,29 +534,28 @@ experimEnabled_write(struct file *file, const char __user *buffer,
683 return count; 534 return count;
684} 535}
685 536
686static int 537static const struct file_operations cifs_experimental_proc_fops = {
687linuxExtensionsEnabled_read(char *page, char **start, off_t off, 538 .owner = THIS_MODULE,
688 int count, int *eof, void *data) 539 .open = cifs_experimental_proc_open,
689{ 540 .read = seq_read,
690 int len; 541 .llseek = seq_lseek,
691 542 .release = single_release,
692 len = sprintf(page, "%d\n", linuxExtEnabled); 543 .write = cifs_experimental_proc_write,
693 len -= off; 544};
694 *start = page + off;
695 545
696 if (len > count) 546static int cifs_linux_ext_proc_show(struct seq_file *m, void *v)
697 len = count; 547{
698 else 548 seq_printf(m, "%d\n", linuxExtEnabled);
699 *eof = 1; 549 return 0;
700 550}
701 if (len < 0)
702 len = 0;
703 551
704 return len; 552static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file)
553{
554 return single_open(file, cifs_linux_ext_proc_show, NULL);
705} 555}
706static int 556
707linuxExtensionsEnabled_write(struct file *file, const char __user *buffer, 557static ssize_t cifs_linux_ext_proc_write(struct file *file,
708 unsigned long count, void *data) 558 const char __user *buffer, size_t count, loff_t *ppos)
709{ 559{
710 char c; 560 char c;
711 int rc; 561 int rc;
@@ -721,31 +571,28 @@ linuxExtensionsEnabled_write(struct file *file, const char __user *buffer,
721 return count; 571 return count;
722} 572}
723 573
574static const struct file_operations cifs_linux_ext_proc_fops = {
575 .owner = THIS_MODULE,
576 .open = cifs_linux_ext_proc_open,
577 .read = seq_read,
578 .llseek = seq_lseek,
579 .release = single_release,
580 .write = cifs_linux_ext_proc_write,
581};
724 582
725static int 583static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v)
726lookupFlag_read(char *page, char **start, off_t off,
727 int count, int *eof, void *data)
728{ 584{
729 int len; 585 seq_printf(m, "%d\n", lookupCacheEnabled);
730 586 return 0;
731 len = sprintf(page, "%d\n", lookupCacheEnabled); 587}
732
733 len -= off;
734 *start = page + off;
735
736 if (len > count)
737 len = count;
738 else
739 *eof = 1;
740
741 if (len < 0)
742 len = 0;
743 588
744 return len; 589static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file)
590{
591 return single_open(file, cifs_lookup_cache_proc_show, NULL);
745} 592}
746static int 593
747lookupFlag_write(struct file *file, const char __user *buffer, 594static ssize_t cifs_lookup_cache_proc_write(struct file *file,
748 unsigned long count, void *data) 595 const char __user *buffer, size_t count, loff_t *ppos)
749{ 596{
750 char c; 597 char c;
751 int rc; 598 int rc;
@@ -760,30 +607,29 @@ lookupFlag_write(struct file *file, const char __user *buffer,
760 607
761 return count; 608 return count;
762} 609}
763static int
764traceSMB_read(char *page, char **start, off_t off, int count,
765 int *eof, void *data)
766{
767 int len;
768
769 len = sprintf(page, "%d\n", traceSMB);
770
771 len -= off;
772 *start = page + off;
773 610
774 if (len > count) 611static const struct file_operations cifs_lookup_cache_proc_fops = {
775 len = count; 612 .owner = THIS_MODULE,
776 else 613 .open = cifs_lookup_cache_proc_open,
777 *eof = 1; 614 .read = seq_read,
615 .llseek = seq_lseek,
616 .release = single_release,
617 .write = cifs_lookup_cache_proc_write,
618};
778 619
779 if (len < 0) 620static int traceSMB_proc_show(struct seq_file *m, void *v)
780 len = 0; 621{
622 seq_printf(m, "%d\n", traceSMB);
623 return 0;
624}
781 625
782 return len; 626static int traceSMB_proc_open(struct inode *inode, struct file *file)
627{
628 return single_open(file, traceSMB_proc_show, NULL);
783} 629}
784static int 630
785traceSMB_write(struct file *file, const char __user *buffer, 631static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
786 unsigned long count, void *data) 632 size_t count, loff_t *ppos)
787{ 633{
788 char c; 634 char c;
789 int rc; 635 int rc;
@@ -799,30 +645,28 @@ traceSMB_write(struct file *file, const char __user *buffer,
799 return count; 645 return count;
800} 646}
801 647
802static int 648static const struct file_operations traceSMB_proc_fops = {
803multiuser_mount_read(char *page, char **start, off_t off, 649 .owner = THIS_MODULE,
804 int count, int *eof, void *data) 650 .open = traceSMB_proc_open,
805{ 651 .read = seq_read,
806 int len; 652 .llseek = seq_lseek,
807 653 .release = single_release,
808 len = sprintf(page, "%d\n", multiuser_mount); 654 .write = traceSMB_proc_write,
809 655};
810 len -= off;
811 *start = page + off;
812 656
813 if (len > count) 657static int cifs_multiuser_mount_proc_show(struct seq_file *m, void *v)
814 len = count; 658{
815 else 659 seq_printf(m, "%d\n", multiuser_mount);
816 *eof = 1; 660 return 0;
817 661}
818 if (len < 0)
819 len = 0;
820 662
821 return len; 663static int cifs_multiuser_mount_proc_open(struct inode *inode, struct file *fh)
664{
665 return single_open(fh, cifs_multiuser_mount_proc_show, NULL);
822} 666}
823static int 667
824multiuser_mount_write(struct file *file, const char __user *buffer, 668static ssize_t cifs_multiuser_mount_proc_write(struct file *file,
825 unsigned long count, void *data) 669 const char __user *buffer, size_t count, loff_t *ppos)
826{ 670{
827 char c; 671 char c;
828 int rc; 672 int rc;
@@ -838,30 +682,28 @@ multiuser_mount_write(struct file *file, const char __user *buffer,
838 return count; 682 return count;
839} 683}
840 684
841static int 685static const struct file_operations cifs_multiuser_mount_proc_fops = {
842security_flags_read(char *page, char **start, off_t off, 686 .owner = THIS_MODULE,
843 int count, int *eof, void *data) 687 .open = cifs_multiuser_mount_proc_open,
844{ 688 .read = seq_read,
845 int len; 689 .llseek = seq_lseek,
846 690 .release = single_release,
847 len = sprintf(page, "0x%x\n", extended_security); 691 .write = cifs_multiuser_mount_proc_write,
848 692};
849 len -= off;
850 *start = page + off;
851 693
852 if (len > count) 694static int cifs_security_flags_proc_show(struct seq_file *m, void *v)
853 len = count; 695{
854 else 696 seq_printf(m, "0x%x\n", extended_security);
855 *eof = 1; 697 return 0;
856 698}
857 if (len < 0)
858 len = 0;
859 699
860 return len; 700static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
701{
702 return single_open(file, cifs_security_flags_proc_show, NULL);
861} 703}
862static int 704
863security_flags_write(struct file *file, const char __user *buffer, 705static ssize_t cifs_security_flags_proc_write(struct file *file,
864 unsigned long count, void *data) 706 const char __user *buffer, size_t count, loff_t *ppos)
865{ 707{
866 unsigned int flags; 708 unsigned int flags;
867 char flags_string[12]; 709 char flags_string[12];
@@ -917,6 +759,15 @@ security_flags_write(struct file *file, const char __user *buffer,
917 /* BB should we turn on MAY flags for other MUST options? */ 759 /* BB should we turn on MAY flags for other MUST options? */
918 return count; 760 return count;
919} 761}
762
763static const struct file_operations cifs_security_flags_proc_fops = {
764 .owner = THIS_MODULE,
765 .open = cifs_security_flags_proc_open,
766 .read = seq_read,
767 .llseek = seq_lseek,
768 .release = single_release,
769 .write = cifs_security_flags_proc_write,
770};
920#else 771#else
921inline void cifs_proc_init(void) 772inline void cifs_proc_init(void)
922{ 773{
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 0e9fc2ba90ee..57ecdc83c26f 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -56,7 +56,7 @@ int match_sid(struct cifs_sid *ctsid)
56 struct cifs_sid *cwsid; 56 struct cifs_sid *cwsid;
57 57
58 if (!ctsid) 58 if (!ctsid)
59 return (-1); 59 return -1;
60 60
61 for (i = 0; i < NUM_WK_SIDS; ++i) { 61 for (i = 0; i < NUM_WK_SIDS; ++i) {
62 cwsid = &(wksidarr[i].cifssid); 62 cwsid = &(wksidarr[i].cifssid);
@@ -87,11 +87,11 @@ int match_sid(struct cifs_sid *ctsid)
87 } 87 }
88 88
89 cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname)); 89 cFYI(1, ("matching sid: %s\n", wksidarr[i].sidname));
90 return (0); /* sids compare/match */ 90 return 0; /* sids compare/match */
91 } 91 }
92 92
93 cFYI(1, ("No matching sid")); 93 cFYI(1, ("No matching sid"));
94 return (-1); 94 return -1;
95} 95}
96 96
97/* if the two SIDs (roughly equivalent to a UUID for a user or group) are 97/* if the two SIDs (roughly equivalent to a UUID for a user or group) are
@@ -102,16 +102,16 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
102 int num_subauth, num_sat, num_saw; 102 int num_subauth, num_sat, num_saw;
103 103
104 if ((!ctsid) || (!cwsid)) 104 if ((!ctsid) || (!cwsid))
105 return (0); 105 return 0;
106 106
107 /* compare the revision */ 107 /* compare the revision */
108 if (ctsid->revision != cwsid->revision) 108 if (ctsid->revision != cwsid->revision)
109 return (0); 109 return 0;
110 110
111 /* compare all of the six auth values */ 111 /* compare all of the six auth values */
112 for (i = 0; i < 6; ++i) { 112 for (i = 0; i < 6; ++i) {
113 if (ctsid->authority[i] != cwsid->authority[i]) 113 if (ctsid->authority[i] != cwsid->authority[i])
114 return (0); 114 return 0;
115 } 115 }
116 116
117 /* compare all of the subauth values if any */ 117 /* compare all of the subauth values if any */
@@ -121,11 +121,11 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
121 if (num_subauth) { 121 if (num_subauth) {
122 for (i = 0; i < num_subauth; ++i) { 122 for (i = 0; i < num_subauth; ++i) {
123 if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) 123 if (ctsid->sub_auth[i] != cwsid->sub_auth[i])
124 return (0); 124 return 0;
125 } 125 }
126 } 126 }
127 127
128 return (1); /* sids compare/match */ 128 return 1; /* sids compare/match */
129} 129}
130 130
131 131
@@ -169,8 +169,7 @@ static void copy_sec_desc(const struct cifs_ntsd *pntsd,
169 for (i = 0; i < 6; i++) 169 for (i = 0; i < 6; i++)
170 ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; 170 ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i];
171 for (i = 0; i < 5; i++) 171 for (i = 0; i < 5; i++)
172 ngroup_sid_ptr->sub_auth[i] = 172 ngroup_sid_ptr->sub_auth[i] = group_sid_ptr->sub_auth[i];
173 cpu_to_le32(group_sid_ptr->sub_auth[i]);
174 173
175 return; 174 return;
176} 175}
@@ -285,7 +284,7 @@ static __u16 fill_ace_for_sid(struct cifs_ace *pntace,
285 size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4); 284 size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4);
286 pntace->size = cpu_to_le16(size); 285 pntace->size = cpu_to_le16(size);
287 286
288 return (size); 287 return size;
289} 288}
290 289
291 290
@@ -426,7 +425,7 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
426 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); 425 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl));
427 pndacl->num_aces = cpu_to_le32(3); 426 pndacl->num_aces = cpu_to_le32(3);
428 427
429 return (0); 428 return 0;
430} 429}
431 430
432 431
@@ -510,7 +509,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
510 sizeof(struct cifs_sid)); */ 509 sizeof(struct cifs_sid)); */
511 510
512 511
513 return (0); 512 return 0;
514} 513}
515 514
516 515
@@ -527,7 +526,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
527 struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */ 526 struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */
528 527
529 if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL)) 528 if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL))
530 return (-EIO); 529 return -EIO;
531 530
532 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + 531 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd +
533 le32_to_cpu(pntsd->osidoffset)); 532 le32_to_cpu(pntsd->osidoffset));
@@ -550,7 +549,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
550 /* copy security descriptor control portion and owner and group sid */ 549 /* copy security descriptor control portion and owner and group sid */
551 copy_sec_desc(pntsd, pnntsd, sidsoffset); 550 copy_sec_desc(pntsd, pnntsd, sidsoffset);
552 551
553 return (rc); 552 return rc;
554} 553}
555 554
556 555
@@ -629,11 +628,11 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
629 cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); 628 cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
630 629
631 if (!inode) 630 if (!inode)
632 return (rc); 631 return rc;
633 632
634 sb = inode->i_sb; 633 sb = inode->i_sb;
635 if (sb == NULL) 634 if (sb == NULL)
636 return (rc); 635 return rc;
637 636
638 cifs_sb = CIFS_SB(sb); 637 cifs_sb = CIFS_SB(sb);
639 xid = GetXid(); 638 xid = GetXid();
@@ -652,7 +651,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
652 if (rc != 0) { 651 if (rc != 0) {
653 cERROR(1, ("Unable to open file to set ACL")); 652 cERROR(1, ("Unable to open file to set ACL"));
654 FreeXid(xid); 653 FreeXid(xid);
655 return (rc); 654 return rc;
656 } 655 }
657 } 656 }
658 657
@@ -665,7 +664,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
665 664
666 FreeXid(xid); 665 FreeXid(xid);
667 666
668 return (rc); 667 return rc;
669} 668}
670 669
671/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ 670/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
@@ -715,7 +714,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
715 if (!pnntsd) { 714 if (!pnntsd) {
716 cERROR(1, ("Unable to allocate security descriptor")); 715 cERROR(1, ("Unable to allocate security descriptor"));
717 kfree(pntsd); 716 kfree(pntsd);
718 return (-ENOMEM); 717 return -ENOMEM;
719 } 718 }
720 719
721 rc = build_sec_desc(pntsd, pnntsd, inode, nmode); 720 rc = build_sec_desc(pntsd, pnntsd, inode, nmode);
@@ -732,6 +731,6 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
732 kfree(pntsd); 731 kfree(pntsd);
733 } 732 }
734 733
735 return (rc); 734 return rc;
736} 735}
737#endif /* CONFIG_CIFS_EXPERIMENTAL */ 736#endif /* CONFIG_CIFS_EXPERIMENTAL */
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 4ff8939c6cc7..83fd40dc1ef0 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -310,9 +310,8 @@ void calc_lanman_hash(struct cifsSesInfo *ses, char *lnm_session_key)
310 utf8 and other multibyte codepages each need their own strupper 310 utf8 and other multibyte codepages each need their own strupper
311 function since a byte at a time will ont work. */ 311 function since a byte at a time will ont work. */
312 312
313 for (i = 0; i < CIFS_ENCPWD_SIZE; i++) { 313 for (i = 0; i < CIFS_ENCPWD_SIZE; i++)
314 password_with_pad[i] = toupper(password_with_pad[i]); 314 password_with_pad[i] = toupper(password_with_pad[i]);
315 }
316 315
317 SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key); 316 SMBencrypt(password_with_pad, ses->server->cryptKey, lnm_session_key);
318 /* clear password before we return/free memory */ 317 /* clear password before we return/free memory */
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 22857c639df5..fe5f6809cba6 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -766,7 +766,7 @@ const struct file_operations cifs_dir_ops = {
766}; 766};
767 767
768static void 768static void
769cifs_init_once(struct kmem_cache *cachep, void *inode) 769cifs_init_once(void *inode)
770{ 770{
771 struct cifsInodeInfo *cifsi = inode; 771 struct cifsInodeInfo *cifsi = inode;
772 772
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 9cfcf326ead3..7e1cf262effe 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -27,7 +27,7 @@
27#define MAX_SES_INFO 2 27#define MAX_SES_INFO 2
28#define MAX_TCON_INFO 4 28#define MAX_TCON_INFO 4
29 29
30#define MAX_TREE_SIZE 2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1 30#define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
31#define MAX_SERVER_SIZE 15 31#define MAX_SERVER_SIZE 15
32#define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */ 32#define MAX_SHARE_SIZE 64 /* used to be 20, this should still be enough */
33#define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null 33#define MAX_USERNAME_SIZE 32 /* 32 is to allow for 15 char names + null
@@ -537,8 +537,8 @@ require use of the stronger protocol */
537#endif /* WEAK_PW_HASH */ 537#endif /* WEAK_PW_HASH */
538#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */ 538#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */
539 539
540#define CIFSSEC_DEF CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 540#define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)
541#define CIFSSEC_MAX CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2 541#define CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
542#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5) 542#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5)
543/* 543/*
544 ***************************************************************** 544 *****************************************************************
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index 0f327c224da3..409abce12732 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -31,7 +31,7 @@
31#else 31#else
32#define CIFS_PROT 0 32#define CIFS_PROT 0
33#endif 33#endif
34#define POSIX_PROT CIFS_PROT+1 34#define POSIX_PROT (CIFS_PROT+1)
35#define BAD_PROT 0xFFFF 35#define BAD_PROT 0xFFFF
36 36
37/* SMB command codes */ 37/* SMB command codes */
@@ -341,7 +341,7 @@
341#define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ 341#define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */
342#define CREATE_NO_EA_KNOWLEDGE 0x00000200 342#define CREATE_NO_EA_KNOWLEDGE 0x00000200
343#define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete 343#define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete
344 "open for recovery" flag - should 344 "open for recovery" flag should
345 be zero in any case */ 345 be zero in any case */
346#define CREATE_OPEN_FOR_RECOVERY 0x00000400 346#define CREATE_OPEN_FOR_RECOVERY 0x00000400
347#define CREATE_RANDOM_ACCESS 0x00000800 347#define CREATE_RANDOM_ACCESS 0x00000800
@@ -414,8 +414,8 @@ struct smb_hdr {
414 __u8 WordCount; 414 __u8 WordCount;
415} __attribute__((packed)); 415} __attribute__((packed));
416/* given a pointer to an smb_hdr retrieve the value of byte count */ 416/* given a pointer to an smb_hdr retrieve the value of byte count */
417#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) 417#define BCC(smb_var) (*(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
418#define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount))) 418#define BCC_LE(smb_var) (*(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
419/* given a pointer to an smb_hdr retrieve the pointer to the byte area */ 419/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
420#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2) 420#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2)
421 421
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 4511b708f0f3..c621ffa2ca90 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -686,11 +686,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
686 SecurityBlob, 686 SecurityBlob,
687 count - 16, 687 count - 16,
688 &server->secType); 688 &server->secType);
689 if (rc == 1) { 689 if (rc == 1)
690 rc = 0; 690 rc = 0;
691 } else { 691 else
692 rc = -EINVAL; 692 rc = -EINVAL;
693 }
694 } 693 }
695 } else 694 } else
696 server->capabilities &= ~CAP_EXTENDED_SECURITY; 695 server->capabilities &= ~CAP_EXTENDED_SECURITY;
@@ -3914,7 +3913,10 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
3914 bool is_unicode; 3913 bool is_unicode;
3915 struct dfs_referral_level_3 *ref; 3914 struct dfs_referral_level_3 *ref;
3916 3915
3917 is_unicode = pSMBr->hdr.Flags2 & SMBFLG2_UNICODE; 3916 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3917 is_unicode = true;
3918 else
3919 is_unicode = false;
3918 *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals); 3920 *num_of_nodes = le16_to_cpu(pSMBr->NumberOfReferrals);
3919 3921
3920 if (*num_of_nodes < 1) { 3922 if (*num_of_nodes < 1) {
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index e8fa46c7cff2..b51d5777cde6 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -455,7 +455,7 @@ incomplete_rcv:
455 /* Note that FC 1001 length is big endian on the wire, 455 /* Note that FC 1001 length is big endian on the wire,
456 but we convert it here so it is always manipulated 456 but we convert it here so it is always manipulated
457 as host byte order */ 457 as host byte order */
458 pdu_length = ntohl(smb_buffer->smb_buf_length); 458 pdu_length = be32_to_cpu((__force __be32)smb_buffer->smb_buf_length);
459 smb_buffer->smb_buf_length = pdu_length; 459 smb_buffer->smb_buf_length = pdu_length;
460 460
461 cFYI(1, ("rfc1002 length 0x%x", pdu_length+4)); 461 cFYI(1, ("rfc1002 length 0x%x", pdu_length+4));
@@ -1461,6 +1461,39 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, const char *old_path,
1461 return rc; 1461 return rc;
1462} 1462}
1463 1463
1464#ifdef CONFIG_DEBUG_LOCK_ALLOC
1465static struct lock_class_key cifs_key[2];
1466static struct lock_class_key cifs_slock_key[2];
1467
1468static inline void
1469cifs_reclassify_socket4(struct socket *sock)
1470{
1471 struct sock *sk = sock->sk;
1472 BUG_ON(sock_owned_by_user(sk));
1473 sock_lock_init_class_and_name(sk, "slock-AF_INET-CIFS",
1474 &cifs_slock_key[0], "sk_lock-AF_INET-CIFS", &cifs_key[0]);
1475}
1476
1477static inline void
1478cifs_reclassify_socket6(struct socket *sock)
1479{
1480 struct sock *sk = sock->sk;
1481 BUG_ON(sock_owned_by_user(sk));
1482 sock_lock_init_class_and_name(sk, "slock-AF_INET6-CIFS",
1483 &cifs_slock_key[1], "sk_lock-AF_INET6-CIFS", &cifs_key[1]);
1484}
1485#else
1486static inline void
1487cifs_reclassify_socket4(struct socket *sock)
1488{
1489}
1490
1491static inline void
1492cifs_reclassify_socket6(struct socket *sock)
1493{
1494}
1495#endif
1496
1464/* See RFC1001 section 14 on representation of Netbios names */ 1497/* See RFC1001 section 14 on representation of Netbios names */
1465static void rfc1002mangle(char *target, char *source, unsigned int length) 1498static void rfc1002mangle(char *target, char *source, unsigned int length)
1466{ 1499{
@@ -1495,6 +1528,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
1495 /* BB other socket options to set KEEPALIVE, NODELAY? */ 1528 /* BB other socket options to set KEEPALIVE, NODELAY? */
1496 cFYI(1, ("Socket created")); 1529 cFYI(1, ("Socket created"));
1497 (*csocket)->sk->sk_allocation = GFP_NOFS; 1530 (*csocket)->sk->sk_allocation = GFP_NOFS;
1531 cifs_reclassify_socket4(*csocket);
1498 } 1532 }
1499 } 1533 }
1500 1534
@@ -1627,6 +1661,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
1627 /* BB other socket options to set KEEPALIVE, NODELAY? */ 1661 /* BB other socket options to set KEEPALIVE, NODELAY? */
1628 cFYI(1, ("ipv6 Socket created")); 1662 cFYI(1, ("ipv6 Socket created"));
1629 (*csocket)->sk->sk_allocation = GFP_NOFS; 1663 (*csocket)->sk->sk_allocation = GFP_NOFS;
1664 cifs_reclassify_socket6(*csocket);
1630 } 1665 }
1631 } 1666 }
1632 1667
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 2e904bd111c8..46e54d39461d 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1413,6 +1413,82 @@ out_busy:
1413 return -ETXTBSY; 1413 return -ETXTBSY;
1414} 1414}
1415 1415
1416static int
1417cifs_set_file_size(struct inode *inode, struct iattr *attrs,
1418 int xid, char *full_path)
1419{
1420 int rc;
1421 struct cifsFileInfo *open_file;
1422 struct cifsInodeInfo *cifsInode = CIFS_I(inode);
1423 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1424 struct cifsTconInfo *pTcon = cifs_sb->tcon;
1425
1426 /*
1427 * To avoid spurious oplock breaks from server, in the case of
1428 * inodes that we already have open, avoid doing path based
1429 * setting of file size if we can do it by handle.
1430 * This keeps our caching token (oplock) and avoids timeouts
1431 * when the local oplock break takes longer to flush
1432 * writebehind data than the SMB timeout for the SetPathInfo
1433 * request would allow
1434 */
1435 open_file = find_writable_file(cifsInode);
1436 if (open_file) {
1437 __u16 nfid = open_file->netfid;
1438 __u32 npid = open_file->pid;
1439 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, nfid,
1440 npid, false);
1441 atomic_dec(&open_file->wrtPending);
1442 cFYI(1, ("SetFSize for attrs rc = %d", rc));
1443 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1444 unsigned int bytes_written;
1445 rc = CIFSSMBWrite(xid, pTcon, nfid, 0, attrs->ia_size,
1446 &bytes_written, NULL, NULL, 1);
1447 cFYI(1, ("Wrt seteof rc %d", rc));
1448 }
1449 } else
1450 rc = -EINVAL;
1451
1452 if (rc != 0) {
1453 /* Set file size by pathname rather than by handle
1454 either because no valid, writeable file handle for
1455 it was found or because there was an error setting
1456 it by handle */
1457 rc = CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size,
1458 false, cifs_sb->local_nls,
1459 cifs_sb->mnt_cifs_flags &
1460 CIFS_MOUNT_MAP_SPECIAL_CHR);
1461 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
1462 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1463 __u16 netfid;
1464 int oplock = 0;
1465
1466 rc = SMBLegacyOpen(xid, pTcon, full_path,
1467 FILE_OPEN, GENERIC_WRITE,
1468 CREATE_NOT_DIR, &netfid, &oplock, NULL,
1469 cifs_sb->local_nls,
1470 cifs_sb->mnt_cifs_flags &
1471 CIFS_MOUNT_MAP_SPECIAL_CHR);
1472 if (rc == 0) {
1473 unsigned int bytes_written;
1474 rc = CIFSSMBWrite(xid, pTcon, netfid, 0,
1475 attrs->ia_size,
1476 &bytes_written, NULL,
1477 NULL, 1);
1478 cFYI(1, ("wrt seteof rc %d", rc));
1479 CIFSSMBClose(xid, pTcon, netfid);
1480 }
1481 }
1482 }
1483
1484 if (rc == 0) {
1485 rc = cifs_vmtruncate(inode, attrs->ia_size);
1486 cifs_truncate_page(inode->i_mapping, inode->i_size);
1487 }
1488
1489 return rc;
1490}
1491
1416int cifs_setattr(struct dentry *direntry, struct iattr *attrs) 1492int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1417{ 1493{
1418 int xid; 1494 int xid;
@@ -1420,7 +1496,6 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1420 struct cifsTconInfo *pTcon; 1496 struct cifsTconInfo *pTcon;
1421 char *full_path = NULL; 1497 char *full_path = NULL;
1422 int rc = -EACCES; 1498 int rc = -EACCES;
1423 struct cifsFileInfo *open_file = NULL;
1424 FILE_BASIC_INFO time_buf; 1499 FILE_BASIC_INFO time_buf;
1425 bool set_time = false; 1500 bool set_time = false;
1426 bool set_dosattr = false; 1501 bool set_dosattr = false;
@@ -1472,78 +1547,8 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1472 } 1547 }
1473 1548
1474 if (attrs->ia_valid & ATTR_SIZE) { 1549 if (attrs->ia_valid & ATTR_SIZE) {
1475 /* To avoid spurious oplock breaks from server, in the case of 1550 rc = cifs_set_file_size(inode, attrs, xid, full_path);
1476 inodes that we already have open, avoid doing path based 1551 if (rc != 0)
1477 setting of file size if we can do it by handle.
1478 This keeps our caching token (oplock) and avoids timeouts
1479 when the local oplock break takes longer to flush
1480 writebehind data than the SMB timeout for the SetPathInfo
1481 request would allow */
1482
1483 open_file = find_writable_file(cifsInode);
1484 if (open_file) {
1485 __u16 nfid = open_file->netfid;
1486 __u32 npid = open_file->pid;
1487 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size,
1488 nfid, npid, false);
1489 atomic_dec(&open_file->wrtPending);
1490 cFYI(1, ("SetFSize for attrs rc = %d", rc));
1491 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1492 unsigned int bytes_written;
1493 rc = CIFSSMBWrite(xid, pTcon,
1494 nfid, 0, attrs->ia_size,
1495 &bytes_written, NULL, NULL,
1496 1 /* 45 seconds */);
1497 cFYI(1, ("Wrt seteof rc %d", rc));
1498 }
1499 } else
1500 rc = -EINVAL;
1501
1502 if (rc != 0) {
1503 /* Set file size by pathname rather than by handle
1504 either because no valid, writeable file handle for
1505 it was found or because there was an error setting
1506 it by handle */
1507 rc = CIFSSMBSetEOF(xid, pTcon, full_path,
1508 attrs->ia_size, false,
1509 cifs_sb->local_nls,
1510 cifs_sb->mnt_cifs_flags &
1511 CIFS_MOUNT_MAP_SPECIAL_CHR);
1512 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
1513 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1514 __u16 netfid;
1515 int oplock = 0;
1516
1517 rc = SMBLegacyOpen(xid, pTcon, full_path,
1518 FILE_OPEN, GENERIC_WRITE,
1519 CREATE_NOT_DIR, &netfid, &oplock,
1520 NULL, cifs_sb->local_nls,
1521 cifs_sb->mnt_cifs_flags &
1522 CIFS_MOUNT_MAP_SPECIAL_CHR);
1523 if (rc == 0) {
1524 unsigned int bytes_written;
1525 rc = CIFSSMBWrite(xid, pTcon,
1526 netfid, 0,
1527 attrs->ia_size,
1528 &bytes_written, NULL,
1529 NULL, 1 /* 45 sec */);
1530 cFYI(1, ("wrt seteof rc %d", rc));
1531 CIFSSMBClose(xid, pTcon, netfid);
1532 }
1533
1534 }
1535 }
1536
1537 /* Server is ok setting allocation size implicitly - no need
1538 to call:
1539 CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, true,
1540 cifs_sb->local_nls);
1541 */
1542
1543 if (rc == 0) {
1544 rc = cifs_vmtruncate(inode, attrs->ia_size);
1545 cifs_truncate_page(inode->i_mapping, inode->i_size);
1546 } else
1547 goto cifs_setattr_exit; 1552 goto cifs_setattr_exit;
1548 } 1553 }
1549 1554
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 83f306954883..5f40ed3473f5 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -690,6 +690,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
690 else 690 else
691 cifs_buf_release(cifsFile->srch_inf. 691 cifs_buf_release(cifsFile->srch_inf.
692 ntwrk_buf_start); 692 ntwrk_buf_start);
693 cifsFile->srch_inf.ntwrk_buf_start = NULL;
693 } 694 }
694 rc = initiate_cifs_search(xid, file); 695 rc = initiate_cifs_search(xid, file);
695 if (rc) { 696 if (rc) {
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 2f58dfc70083..830f51abb971 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -58,7 +58,7 @@ static void coda_destroy_inode(struct inode *inode)
58 kmem_cache_free(coda_inode_cachep, ITOC(inode)); 58 kmem_cache_free(coda_inode_cachep, ITOC(inode));
59} 59}
60 60
61static void init_once(struct kmem_cache * cachep, void *foo) 61static void init_once(void *foo)
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
diff --git a/fs/dcache.c b/fs/dcache.c
index 3818d6ab76ca..f2584d22cb45 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -487,6 +487,7 @@ restart:
487 if (!cnt) 487 if (!cnt)
488 break; 488 break;
489 } 489 }
490 cond_resched_lock(&dcache_lock);
490 } 491 }
491 } 492 }
492 while (!list_empty(&tmp)) { 493 while (!list_empty(&tmp)) {
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 9e81addbd6ea..9606ee848fd8 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -150,17 +150,11 @@ static int dio_refill_pages(struct dio *dio)
150 int nr_pages; 150 int nr_pages;
151 151
152 nr_pages = min(dio->total_pages - dio->curr_page, DIO_PAGES); 152 nr_pages = min(dio->total_pages - dio->curr_page, DIO_PAGES);
153 down_read(&current->mm->mmap_sem); 153 ret = get_user_pages_fast(
154 ret = get_user_pages(
155 current, /* Task for fault acounting */
156 current->mm, /* whose pages? */
157 dio->curr_user_address, /* Where from? */ 154 dio->curr_user_address, /* Where from? */
158 nr_pages, /* How many pages? */ 155 nr_pages, /* How many pages? */
159 dio->rw == READ, /* Write to memory? */ 156 dio->rw == READ, /* Write to memory? */
160 0, /* force (?) */ 157 &dio->pages[0]); /* Put results here */
161 &dio->pages[0],
162 NULL); /* vmas */
163 up_read(&current->mm->mmap_sem);
164 158
165 if (ret < 0 && dio->blocks_available && (dio->rw & WRITE)) { 159 if (ret < 0 && dio->blocks_available && (dio->rw & WRITE)) {
166 struct page *page = ZERO_PAGE(0); 160 struct page *page = ZERO_PAGE(0);
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 6f403cfba14f..448dfd597b5f 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -578,7 +578,7 @@ static struct file_system_type ecryptfs_fs_type = {
578 * Initializes the ecryptfs_inode_info_cache when it is created 578 * Initializes the ecryptfs_inode_info_cache when it is created
579 */ 579 */
580static void 580static void
581inode_info_init_once(struct kmem_cache *cachep, void *vptr) 581inode_info_init_once(void *vptr)
582{ 582{
583 struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; 583 struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr;
584 584
@@ -589,7 +589,7 @@ static struct ecryptfs_cache_info {
589 struct kmem_cache **cache; 589 struct kmem_cache **cache;
590 const char *name; 590 const char *name;
591 size_t size; 591 size_t size;
592 void (*ctor)(struct kmem_cache *cache, void *obj); 592 void (*ctor)(void *obj);
593} ecryptfs_cache_infos[] = { 593} ecryptfs_cache_infos[] = {
594 { 594 {
595 .cache = &ecryptfs_auth_tok_list_item_cache, 595 .cache = &ecryptfs_auth_tok_list_item_cache,
diff --git a/fs/efs/super.c b/fs/efs/super.c
index d733531b55e2..567b134fa1f1 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -70,7 +70,7 @@ static void efs_destroy_inode(struct inode *inode)
70 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); 70 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
71} 71}
72 72
73static void init_once(struct kmem_cache *cachep, void *foo) 73static void init_once(void *foo)
74{ 74{
75 struct efs_inode_info *ei = (struct efs_inode_info *) foo; 75 struct efs_inode_info *ei = (struct efs_inode_info *) foo;
76 76
diff --git a/fs/exec.c b/fs/exec.c
index 5e559013e303..b8792a131533 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -42,13 +42,13 @@
42#include <linux/module.h> 42#include <linux/module.h>
43#include <linux/namei.h> 43#include <linux/namei.h>
44#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
45#include <linux/ptrace.h>
46#include <linux/mount.h> 45#include <linux/mount.h>
47#include <linux/security.h> 46#include <linux/security.h>
48#include <linux/syscalls.h> 47#include <linux/syscalls.h>
49#include <linux/tsacct_kern.h> 48#include <linux/tsacct_kern.h>
50#include <linux/cn_proc.h> 49#include <linux/cn_proc.h>
51#include <linux/audit.h> 50#include <linux/audit.h>
51#include <linux/tracehook.h>
52 52
53#include <asm/uaccess.h> 53#include <asm/uaccess.h>
54#include <asm/mmu_context.h> 54#include <asm/mmu_context.h>
@@ -1071,13 +1071,8 @@ EXPORT_SYMBOL(prepare_binprm);
1071 1071
1072static int unsafe_exec(struct task_struct *p) 1072static int unsafe_exec(struct task_struct *p)
1073{ 1073{
1074 int unsafe = 0; 1074 int unsafe = tracehook_unsafe_exec(p);
1075 if (p->ptrace & PT_PTRACED) { 1075
1076 if (p->ptrace & PT_PTRACE_CAP)
1077 unsafe |= LSM_UNSAFE_PTRACE_CAP;
1078 else
1079 unsafe |= LSM_UNSAFE_PTRACE;
1080 }
1081 if (atomic_read(&p->fs->count) > 1 || 1076 if (atomic_read(&p->fs->count) > 1 ||
1082 atomic_read(&p->files->count) > 1 || 1077 atomic_read(&p->files->count) > 1 ||
1083 atomic_read(&p->sighand->count) > 1) 1078 atomic_read(&p->sighand->count) > 1)
@@ -1214,6 +1209,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1214 read_unlock(&binfmt_lock); 1209 read_unlock(&binfmt_lock);
1215 retval = fn(bprm, regs); 1210 retval = fn(bprm, regs);
1216 if (retval >= 0) { 1211 if (retval >= 0) {
1212 tracehook_report_exec(fmt, bprm, regs);
1217 put_binfmt(fmt); 1213 put_binfmt(fmt);
1218 allow_write_access(bprm->file); 1214 allow_write_access(bprm->file);
1219 if (bprm->file) 1215 if (bprm->file)
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 31308a3b0b8b..fd88c7b43e66 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -159,7 +159,7 @@ static void ext2_destroy_inode(struct inode *inode)
159 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); 159 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
160} 160}
161 161
162static void init_once(struct kmem_cache * cachep, void *foo) 162static void init_once(void *foo)
163{ 163{
164 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo; 164 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
165 165
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 615788c6843a..8ddced384674 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -472,7 +472,7 @@ static void ext3_destroy_inode(struct inode *inode)
472 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 472 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode));
473} 473}
474 474
475static void init_once(struct kmem_cache * cachep, void *foo) 475static void init_once(void *foo)
476{ 476{
477 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; 477 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo;
478 478
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1cb371dcd609..b5479b1dff14 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -595,7 +595,7 @@ static void ext4_destroy_inode(struct inode *inode)
595 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); 595 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
596} 596}
597 597
598static void init_once(struct kmem_cache *cachep, void *foo) 598static void init_once(void *foo)
599{ 599{
600 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; 600 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
601 601
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 3a9ecac8d61f..3222f51c41cf 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -36,7 +36,7 @@ static inline int fat_max_cache(struct inode *inode)
36 36
37static struct kmem_cache *fat_cache_cachep; 37static struct kmem_cache *fat_cache_cachep;
38 38
39static void init_once(struct kmem_cache *cachep, void *foo) 39static void init_once(void *foo)
40{ 40{
41 struct fat_cache *cache = (struct fat_cache *)foo; 41 struct fat_cache *cache = (struct fat_cache *)foo;
42 42
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 23676f9d79ce..6d266d793e2c 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -498,7 +498,7 @@ static void fat_destroy_inode(struct inode *inode)
498 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); 498 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode));
499} 499}
500 500
501static void init_once(struct kmem_cache *cachep, void *foo) 501static void init_once(void *foo)
502{ 502{
503 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo; 503 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo;
504 504
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 7d2f7d6e22e2..d2249f174e20 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -956,7 +956,7 @@ static inline void unregister_fuseblk(void)
956} 956}
957#endif 957#endif
958 958
959static void fuse_inode_init_once(struct kmem_cache *cachep, void *foo) 959static void fuse_inode_init_once(void *foo)
960{ 960{
961 struct inode * inode = foo; 961 struct inode * inode = foo;
962 962
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index bcc668d0fadd..bb2cc303ac29 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -24,7 +24,7 @@
24#include "util.h" 24#include "util.h"
25#include "glock.h" 25#include "glock.h"
26 26
27static void gfs2_init_inode_once(struct kmem_cache *cachep, void *foo) 27static void gfs2_init_inode_once(void *foo)
28{ 28{
29 struct gfs2_inode *ip = foo; 29 struct gfs2_inode *ip = foo;
30 30
@@ -33,7 +33,7 @@ static void gfs2_init_inode_once(struct kmem_cache *cachep, void *foo)
33 ip->i_alloc = NULL; 33 ip->i_alloc = NULL;
34} 34}
35 35
36static void gfs2_init_glock_once(struct kmem_cache *cachep, void *foo) 36static void gfs2_init_glock_once(void *foo)
37{ 37{
38 struct gfs2_glock *gl = foo; 38 struct gfs2_glock *gl = foo;
39 39
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index ac2ec5ef66e4..4abb1047c689 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -432,7 +432,7 @@ static struct file_system_type hfs_fs_type = {
432 .fs_flags = FS_REQUIRES_DEV, 432 .fs_flags = FS_REQUIRES_DEV,
433}; 433};
434 434
435static void hfs_init_once(struct kmem_cache *cachep, void *p) 435static void hfs_init_once(void *p)
436{ 436{
437 struct hfs_inode_info *i = p; 437 struct hfs_inode_info *i = p;
438 438
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 3859118531c7..e834e578c93f 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -485,7 +485,7 @@ static struct file_system_type hfsplus_fs_type = {
485 .fs_flags = FS_REQUIRES_DEV, 485 .fs_flags = FS_REQUIRES_DEV,
486}; 486};
487 487
488static void hfsplus_init_once(struct kmem_cache *cachep, void *p) 488static void hfsplus_init_once(void *p)
489{ 489{
490 struct hfsplus_inode_info *i = p; 490 struct hfsplus_inode_info *i = p;
491 491
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index f63a699ec659..b8ae9c90ada0 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -173,7 +173,7 @@ static void hpfs_destroy_inode(struct inode *inode)
173 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); 173 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode));
174} 174}
175 175
176static void init_once(struct kmem_cache *cachep, void *foo) 176static void init_once(void *foo)
177{ 177{
178 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; 178 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo;
179 179
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index dbd01d262ca4..3f58923fb39b 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -705,7 +705,7 @@ static const struct address_space_operations hugetlbfs_aops = {
705}; 705};
706 706
707 707
708static void init_once(struct kmem_cache *cachep, void *foo) 708static void init_once(void *foo)
709{ 709{
710 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo; 710 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo;
711 711
diff --git a/fs/inode.c b/fs/inode.c
index c36d9480335c..b6726f644530 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -209,7 +209,7 @@ void inode_init_once(struct inode *inode)
209 INIT_LIST_HEAD(&inode->i_dentry); 209 INIT_LIST_HEAD(&inode->i_dentry);
210 INIT_LIST_HEAD(&inode->i_devices); 210 INIT_LIST_HEAD(&inode->i_devices);
211 INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC); 211 INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC);
212 rwlock_init(&inode->i_data.tree_lock); 212 spin_lock_init(&inode->i_data.tree_lock);
213 spin_lock_init(&inode->i_data.i_mmap_lock); 213 spin_lock_init(&inode->i_data.i_mmap_lock);
214 INIT_LIST_HEAD(&inode->i_data.private_list); 214 INIT_LIST_HEAD(&inode->i_data.private_list);
215 spin_lock_init(&inode->i_data.private_lock); 215 spin_lock_init(&inode->i_data.private_lock);
@@ -224,7 +224,7 @@ void inode_init_once(struct inode *inode)
224 224
225EXPORT_SYMBOL(inode_init_once); 225EXPORT_SYMBOL(inode_init_once);
226 226
227static void init_once(struct kmem_cache * cachep, void *foo) 227static void init_once(void *foo)
228{ 228{
229 struct inode * inode = (struct inode *) foo; 229 struct inode * inode = (struct inode *) foo;
230 230
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 044a254d526b..26948a6033b6 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -73,7 +73,7 @@ static void isofs_destroy_inode(struct inode *inode)
73 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 73 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
74} 74}
75 75
76static void init_once(struct kmem_cache *cachep, void *foo) 76static void init_once(void *foo)
77{ 77{
78 struct iso_inode_info *ei = foo; 78 struct iso_inode_info *ei = foo;
79 79
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 7da69eae49e4..efd401257ed9 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -44,7 +44,7 @@ static void jffs2_destroy_inode(struct inode *inode)
44 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); 44 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
45} 45}
46 46
47static void jffs2_i_init_once(struct kmem_cache *cachep, void *foo) 47static void jffs2_i_init_once(void *foo)
48{ 48{
49 struct jffs2_inode_info *f = foo; 49 struct jffs2_inode_info *f = foo;
50 50
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 854ff0ec574f..c350057087dd 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -182,7 +182,7 @@ static inline void remove_metapage(struct page *page, struct metapage *mp)
182 182
183#endif 183#endif
184 184
185static void init_once(struct kmem_cache *cachep, void *foo) 185static void init_once(void *foo)
186{ 186{
187 struct metapage *mp = (struct metapage *)foo; 187 struct metapage *mp = (struct metapage *)foo;
188 188
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 359c091d8965..3630718be395 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -760,7 +760,7 @@ static struct file_system_type jfs_fs_type = {
760 .fs_flags = FS_REQUIRES_DEV, 760 .fs_flags = FS_REQUIRES_DEV,
761}; 761};
762 762
763static void init_once(struct kmem_cache *cachep, void *foo) 763static void init_once(void *foo)
764{ 764{
765 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo; 765 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
766 766
diff --git a/fs/locks.c b/fs/locks.c
index 01490300f7cb..5eb259e3cd38 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -201,7 +201,7 @@ EXPORT_SYMBOL(locks_init_lock);
201 * Initialises the fields of the file lock which are invariant for 201 * Initialises the fields of the file lock which are invariant for
202 * free file_locks. 202 * free file_locks.
203 */ 203 */
204static void init_once(struct kmem_cache *cache, void *foo) 204static void init_once(void *foo)
205{ 205{
206 struct file_lock *lock = (struct file_lock *) foo; 206 struct file_lock *lock = (struct file_lock *) foo;
207 207
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 523d73713418..d1d1eb84679d 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -68,7 +68,7 @@ static void minix_destroy_inode(struct inode *inode)
68 kmem_cache_free(minix_inode_cachep, minix_i(inode)); 68 kmem_cache_free(minix_inode_cachep, minix_i(inode));
69} 69}
70 70
71static void init_once(struct kmem_cache * cachep, void *foo) 71static void init_once(void *foo)
72{ 72{
73 struct minix_inode_info *ei = (struct minix_inode_info *) foo; 73 struct minix_inode_info *ei = (struct minix_inode_info *) foo;
74 74
diff --git a/fs/namespace.c b/fs/namespace.c
index 4f6f7635b59c..f30b11e2240e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -309,10 +309,9 @@ static void handle_write_count_underflow(struct vfsmount *mnt)
309 */ 309 */
310 if ((atomic_read(&mnt->__mnt_writers) < 0) && 310 if ((atomic_read(&mnt->__mnt_writers) < 0) &&
311 !(mnt->mnt_flags & MNT_IMBALANCED_WRITE_COUNT)) { 311 !(mnt->mnt_flags & MNT_IMBALANCED_WRITE_COUNT)) {
312 printk(KERN_DEBUG "leak detected on mount(%p) writers " 312 WARN(1, KERN_DEBUG "leak detected on mount(%p) writers "
313 "count: %d\n", 313 "count: %d\n",
314 mnt, atomic_read(&mnt->__mnt_writers)); 314 mnt, atomic_read(&mnt->__mnt_writers));
315 WARN_ON(1);
316 /* use the flag to keep the dmesg spam down */ 315 /* use the flag to keep the dmesg spam down */
317 mnt->mnt_flags |= MNT_IMBALANCED_WRITE_COUNT; 316 mnt->mnt_flags |= MNT_IMBALANCED_WRITE_COUNT;
318 } 317 }
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 2e5ab1204dec..d642f0e5b365 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -64,7 +64,7 @@ static void ncp_destroy_inode(struct inode *inode)
64 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); 64 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode));
65} 65}
66 66
67static void init_once(struct kmem_cache *cachep, void *foo) 67static void init_once(void *foo)
68{ 68{
69 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo; 69 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo;
70 70
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index df23f987da6b..52daefa2f521 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1242,7 +1242,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)
1242#endif 1242#endif
1243} 1243}
1244 1244
1245static void init_once(struct kmem_cache * cachep, void *foo) 1245static void init_once(void *foo)
1246{ 1246{
1247 struct nfs_inode *nfsi = (struct nfs_inode *) foo; 1247 struct nfs_inode *nfsi = (struct nfs_inode *) foo;
1248 1248
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 3e76f3b216bc..4a46743b5077 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3080,7 +3080,7 @@ struct kmem_cache *ntfs_inode_cache;
3080struct kmem_cache *ntfs_big_inode_cache; 3080struct kmem_cache *ntfs_big_inode_cache;
3081 3081
3082/* Init once constructor for the inode slab cache. */ 3082/* Init once constructor for the inode slab cache. */
3083static void ntfs_big_inode_init_once(struct kmem_cache *cachep, void *foo) 3083static void ntfs_big_inode_init_once(void *foo)
3084{ 3084{
3085 ntfs_inode *ni = (ntfs_inode *)foo; 3085 ntfs_inode *ni = (ntfs_inode *)foo;
3086 3086
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index e48aba698b77..533a789c3ef8 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -267,8 +267,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
267 return writelen; 267 return writelen;
268} 268}
269 269
270static void dlmfs_init_once(struct kmem_cache *cachep, 270static void dlmfs_init_once(void *foo)
271 void *foo)
272{ 271{
273 struct dlmfs_inode_private *ip = 272 struct dlmfs_inode_private *ip =
274 (struct dlmfs_inode_private *) foo; 273 (struct dlmfs_inode_private *) foo;
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index ccecfe5094fa..2560b33889aa 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1118,7 +1118,7 @@ bail:
1118 return status; 1118 return status;
1119} 1119}
1120 1120
1121static void ocfs2_inode_init_once(struct kmem_cache *cachep, void *data) 1121static void ocfs2_inode_init_once(void *data)
1122{ 1122{
1123 struct ocfs2_inode_info *oi = data; 1123 struct ocfs2_inode_info *oi = data;
1124 1124
diff --git a/fs/omfs/Makefile b/fs/omfs/Makefile
new file mode 100644
index 000000000000..8b82b63f1129
--- /dev/null
+++ b/fs/omfs/Makefile
@@ -0,0 +1,4 @@
1
2obj-$(CONFIG_OMFS_FS) += omfs.o
3
4omfs-y := bitmap.o dir.o file.o inode.o
diff --git a/fs/omfs/bitmap.c b/fs/omfs/bitmap.c
new file mode 100644
index 000000000000..dc75f22be3f2
--- /dev/null
+++ b/fs/omfs/bitmap.c
@@ -0,0 +1,192 @@
1#include <linux/kernel.h>
2#include <linux/fs.h>
3#include <linux/buffer_head.h>
4#include <asm/div64.h>
5#include "omfs.h"
6
7unsigned long omfs_count_free(struct super_block *sb)
8{
9 unsigned int i;
10 unsigned long sum = 0;
11 struct omfs_sb_info *sbi = OMFS_SB(sb);
12 int nbits = sb->s_blocksize * 8;
13
14 for (i = 0; i < sbi->s_imap_size; i++)
15 sum += nbits - bitmap_weight(sbi->s_imap[i], nbits);
16
17 return sum;
18}
19
20/*
21 * Counts the run of zero bits starting at bit up to max.
22 * It handles the case where a run might spill over a buffer.
23 * Called with bitmap lock.
24 */
25static int count_run(unsigned long **addr, int nbits,
26 int addrlen, int bit, int max)
27{
28 int count = 0;
29 int x;
30
31 for (; addrlen > 0; addrlen--, addr++) {
32 x = find_next_bit(*addr, nbits, bit);
33 count += x - bit;
34
35 if (x < nbits || count > max)
36 return min(count, max);
37
38 bit = 0;
39 }
40 return min(count, max);
41}
42
43/*
44 * Sets or clears the run of count bits starting with bit.
45 * Called with bitmap lock.
46 */
47static int set_run(struct super_block *sb, int map,
48 int nbits, int bit, int count, int set)
49{
50 int i;
51 int err;
52 struct buffer_head *bh;
53 struct omfs_sb_info *sbi = OMFS_SB(sb);
54
55 err = -ENOMEM;
56 bh = sb_bread(sb, clus_to_blk(sbi, sbi->s_bitmap_ino) + map);
57 if (!bh)
58 goto out;
59
60 for (i = 0; i < count; i++, bit++) {
61 if (bit >= nbits) {
62 bit = 0;
63 map++;
64
65 mark_buffer_dirty(bh);
66 brelse(bh);
67 bh = sb_bread(sb,
68 clus_to_blk(sbi, sbi->s_bitmap_ino) + map);
69 if (!bh)
70 goto out;
71 }
72 if (set) {
73 set_bit(bit, sbi->s_imap[map]);
74 set_bit(bit, (long *) bh->b_data);
75 } else {
76 clear_bit(bit, sbi->s_imap[map]);
77 clear_bit(bit, (long *) bh->b_data);
78 }
79 }
80 mark_buffer_dirty(bh);
81 brelse(bh);
82 err = 0;
83out:
84 return err;
85}
86
87/*
88 * Tries to allocate exactly one block. Returns true if sucessful.
89 */
90int omfs_allocate_block(struct super_block *sb, u64 block)
91{
92 struct buffer_head *bh;
93 struct omfs_sb_info *sbi = OMFS_SB(sb);
94 int bits_per_entry = 8 * sb->s_blocksize;
95 int map, bit;
96 int ret = 0;
97 u64 tmp;
98
99 tmp = block;
100 bit = do_div(tmp, bits_per_entry);
101 map = tmp;
102
103 mutex_lock(&sbi->s_bitmap_lock);
104 if (map >= sbi->s_imap_size || test_and_set_bit(bit, sbi->s_imap[map]))
105 goto out;
106
107 if (sbi->s_bitmap_ino > 0) {
108 bh = sb_bread(sb, clus_to_blk(sbi, sbi->s_bitmap_ino) + map);
109 if (!bh)
110 goto out;
111
112 set_bit(bit, (long *) bh->b_data);
113 mark_buffer_dirty(bh);
114 brelse(bh);
115 }
116 ret = 1;
117out:
118 mutex_unlock(&sbi->s_bitmap_lock);
119 return ret;
120}
121
122
123/*
124 * Tries to allocate a set of blocks. The request size depends on the
125 * type: for inodes, we must allocate sbi->s_mirrors blocks, and for file
126 * blocks, we try to allocate sbi->s_clustersize, but can always get away
127 * with just one block.
128 */
129int omfs_allocate_range(struct super_block *sb,
130 int min_request,
131 int max_request,
132 u64 *return_block,
133 int *return_size)
134{
135 struct omfs_sb_info *sbi = OMFS_SB(sb);
136 int bits_per_entry = 8 * sb->s_blocksize;
137 int ret = 0;
138 int i, run, bit;
139
140 mutex_lock(&sbi->s_bitmap_lock);
141 for (i = 0; i < sbi->s_imap_size; i++) {
142 bit = 0;
143 while (bit < bits_per_entry) {
144 bit = find_next_zero_bit(sbi->s_imap[i], bits_per_entry,
145 bit);
146
147 if (bit == bits_per_entry)
148 break;
149
150 run = count_run(&sbi->s_imap[i], bits_per_entry,
151 sbi->s_imap_size-i, bit, max_request);
152
153 if (run >= min_request)
154 goto found;
155 bit += run;
156 }
157 }
158 ret = -ENOSPC;
159 goto out;
160
161found:
162 *return_block = i * bits_per_entry + bit;
163 *return_size = run;
164 ret = set_run(sb, i, bits_per_entry, bit, run, 1);
165
166out:
167 mutex_unlock(&sbi->s_bitmap_lock);
168 return ret;
169}
170
171/*
172 * Clears count bits starting at a given block.
173 */
174int omfs_clear_range(struct super_block *sb, u64 block, int count)
175{
176 struct omfs_sb_info *sbi = OMFS_SB(sb);
177 int bits_per_entry = 8 * sb->s_blocksize;
178 u64 tmp;
179 int map, bit, ret;
180
181 tmp = block;
182 bit = do_div(tmp, bits_per_entry);
183 map = tmp;
184
185 if (map >= sbi->s_imap_size)
186 return 0;
187
188 mutex_lock(&sbi->s_bitmap_lock);
189 ret = set_run(sb, map, bits_per_entry, bit, count, 0);
190 mutex_unlock(&sbi->s_bitmap_lock);
191 return ret;
192}
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
new file mode 100644
index 000000000000..05a5bc31e4bd
--- /dev/null
+++ b/fs/omfs/dir.c
@@ -0,0 +1,504 @@
1/*
2 * OMFS (as used by RIO Karma) directory operations.
3 * Copyright (C) 2005 Bob Copeland <me@bobcopeland.com>
4 * Released under GPL v2.
5 */
6
7#include <linux/fs.h>
8#include <linux/ctype.h>
9#include <linux/buffer_head.h>
10#include "omfs.h"
11
12static int omfs_hash(const char *name, int namelen, int mod)
13{
14 int i, hash = 0;
15 for (i = 0; i < namelen; i++)
16 hash ^= tolower(name[i]) << (i % 24);
17 return hash % mod;
18}
19
20/*
21 * Finds the bucket for a given name and reads the containing block;
22 * *ofs is set to the offset of the first list entry.
23 */
24static struct buffer_head *omfs_get_bucket(struct inode *dir,
25 const char *name, int namelen, int *ofs)
26{
27 int nbuckets = (dir->i_size - OMFS_DIR_START)/8;
28 int block = clus_to_blk(OMFS_SB(dir->i_sb), dir->i_ino);
29 int bucket = omfs_hash(name, namelen, nbuckets);
30
31 *ofs = OMFS_DIR_START + bucket * 8;
32 return sb_bread(dir->i_sb, block);
33}
34
35static struct buffer_head *omfs_scan_list(struct inode *dir, u64 block,
36 const char *name, int namelen,
37 u64 *prev_block)
38{
39 struct buffer_head *bh;
40 struct omfs_inode *oi;
41 int err = -ENOENT;
42 *prev_block = ~0;
43
44 while (block != ~0) {
45 bh = sb_bread(dir->i_sb,
46 clus_to_blk(OMFS_SB(dir->i_sb), block));
47 if (!bh) {
48 err = -EIO;
49 goto err;
50 }
51
52 oi = (struct omfs_inode *) bh->b_data;
53 if (omfs_is_bad(OMFS_SB(dir->i_sb), &oi->i_head, block)) {
54 brelse(bh);
55 goto err;
56 }
57
58 if (strncmp(oi->i_name, name, namelen) == 0)
59 return bh;
60
61 *prev_block = block;
62 block = be64_to_cpu(oi->i_sibling);
63 brelse(bh);
64 }
65err:
66 return ERR_PTR(err);
67}
68
69static struct buffer_head *omfs_find_entry(struct inode *dir,
70 const char *name, int namelen)
71{
72 struct buffer_head *bh;
73 int ofs;
74 u64 block, dummy;
75
76 bh = omfs_get_bucket(dir, name, namelen, &ofs);
77 if (!bh)
78 return ERR_PTR(-EIO);
79
80 block = be64_to_cpu(*((__be64 *) &bh->b_data[ofs]));
81 brelse(bh);
82
83 return omfs_scan_list(dir, block, name, namelen, &dummy);
84}
85
86int omfs_make_empty(struct inode *inode, struct super_block *sb)
87{
88 struct omfs_sb_info *sbi = OMFS_SB(sb);
89 int block = clus_to_blk(sbi, inode->i_ino);
90 struct buffer_head *bh;
91 struct omfs_inode *oi;
92
93 bh = sb_bread(sb, block);
94 if (!bh)
95 return -ENOMEM;
96
97 memset(bh->b_data, 0, sizeof(struct omfs_inode));
98
99 if (inode->i_mode & S_IFDIR) {
100 memset(&bh->b_data[OMFS_DIR_START], 0xff,
101 sbi->s_sys_blocksize - OMFS_DIR_START);
102 } else
103 omfs_make_empty_table(bh, OMFS_EXTENT_START);
104
105 oi = (struct omfs_inode *) bh->b_data;
106 oi->i_head.h_self = cpu_to_be64(inode->i_ino);
107 oi->i_sibling = ~0ULL;
108
109 mark_buffer_dirty(bh);
110 brelse(bh);
111 return 0;
112}
113
114static int omfs_add_link(struct dentry *dentry, struct inode *inode)
115{
116 struct inode *dir = dentry->d_parent->d_inode;
117 const char *name = dentry->d_name.name;
118 int namelen = dentry->d_name.len;
119 struct omfs_inode *oi;
120 struct buffer_head *bh;
121 u64 block;
122 __be64 *entry;
123 int ofs;
124
125 /* just prepend to head of queue in proper bucket */
126 bh = omfs_get_bucket(dir, name, namelen, &ofs);
127 if (!bh)
128 goto out;
129
130 entry = (__be64 *) &bh->b_data[ofs];
131 block = be64_to_cpu(*entry);
132 *entry = cpu_to_be64(inode->i_ino);
133 mark_buffer_dirty(bh);
134 brelse(bh);
135
136 /* now set the sibling and parent pointers on the new inode */
137 bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb), inode->i_ino));
138 if (!bh)
139 goto out;
140
141 oi = (struct omfs_inode *) bh->b_data;
142 memcpy(oi->i_name, name, namelen);
143 memset(oi->i_name + namelen, 0, OMFS_NAMELEN - namelen);
144 oi->i_sibling = cpu_to_be64(block);
145 oi->i_parent = cpu_to_be64(dir->i_ino);
146 mark_buffer_dirty(bh);
147 brelse(bh);
148
149 dir->i_ctime = CURRENT_TIME_SEC;
150
151 /* mark affected inodes dirty to rebuild checksums */
152 mark_inode_dirty(dir);
153 mark_inode_dirty(inode);
154 return 0;
155out:
156 return -ENOMEM;
157}
158
159static int omfs_delete_entry(struct dentry *dentry)
160{
161 struct inode *dir = dentry->d_parent->d_inode;
162 struct inode *dirty;
163 const char *name = dentry->d_name.name;
164 int namelen = dentry->d_name.len;
165 struct omfs_inode *oi;
166 struct buffer_head *bh, *bh2;
167 __be64 *entry, next;
168 u64 block, prev;
169 int ofs;
170 int err = -ENOMEM;
171
172 /* delete the proper node in the bucket's linked list */
173 bh = omfs_get_bucket(dir, name, namelen, &ofs);
174 if (!bh)
175 goto out;
176
177 entry = (__be64 *) &bh->b_data[ofs];
178 block = be64_to_cpu(*entry);
179
180 bh2 = omfs_scan_list(dir, block, name, namelen, &prev);
181 if (IS_ERR(bh2)) {
182 err = PTR_ERR(bh2);
183 goto out_free_bh;
184 }
185
186 oi = (struct omfs_inode *) bh2->b_data;
187 next = oi->i_sibling;
188 brelse(bh2);
189
190 if (prev != ~0) {
191 /* found in middle of list, get list ptr */
192 brelse(bh);
193 bh = sb_bread(dir->i_sb,
194 clus_to_blk(OMFS_SB(dir->i_sb), prev));
195 if (!bh)
196 goto out;
197
198 oi = (struct omfs_inode *) bh->b_data;
199 entry = &oi->i_sibling;
200 }
201
202 *entry = next;
203 mark_buffer_dirty(bh);
204
205 if (prev != ~0) {
206 dirty = omfs_iget(dir->i_sb, prev);
207 if (!IS_ERR(dirty)) {
208 mark_inode_dirty(dirty);
209 iput(dirty);
210 }
211 }
212
213 err = 0;
214out_free_bh:
215 brelse(bh);
216out:
217 return err;
218}
219
220static int omfs_dir_is_empty(struct inode *inode)
221{
222 int nbuckets = (inode->i_size - OMFS_DIR_START) / 8;
223 struct buffer_head *bh;
224 u64 *ptr;
225 int i;
226
227 bh = sb_bread(inode->i_sb, clus_to_blk(OMFS_SB(inode->i_sb),
228 inode->i_ino));
229
230 if (!bh)
231 return 0;
232
233 ptr = (u64 *) &bh->b_data[OMFS_DIR_START];
234
235 for (i = 0; i < nbuckets; i++, ptr++)
236 if (*ptr != ~0)
237 break;
238
239 brelse(bh);
240 return *ptr != ~0;
241}
242
243static int omfs_unlink(struct inode *dir, struct dentry *dentry)
244{
245 int ret;
246 struct inode *inode = dentry->d_inode;
247
248 ret = omfs_delete_entry(dentry);
249 if (ret)
250 goto end_unlink;
251
252 inode_dec_link_count(inode);
253 mark_inode_dirty(dir);
254
255end_unlink:
256 return ret;
257}
258
259static int omfs_rmdir(struct inode *dir, struct dentry *dentry)
260{
261 int err = -ENOTEMPTY;
262 struct inode *inode = dentry->d_inode;
263
264 if (omfs_dir_is_empty(inode)) {
265 err = omfs_unlink(dir, dentry);
266 if (!err)
267 inode_dec_link_count(inode);
268 }
269 return err;
270}
271
272static int omfs_add_node(struct inode *dir, struct dentry *dentry, int mode)
273{
274 int err;
275 struct inode *inode = omfs_new_inode(dir, mode);
276
277 if (IS_ERR(inode))
278 return PTR_ERR(inode);
279
280 err = omfs_make_empty(inode, dir->i_sb);
281 if (err)
282 goto out_free_inode;
283
284 err = omfs_add_link(dentry, inode);
285 if (err)
286 goto out_free_inode;
287
288 d_instantiate(dentry, inode);
289 return 0;
290
291out_free_inode:
292 iput(inode);
293 return err;
294}
295
296static int omfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
297{
298 return omfs_add_node(dir, dentry, mode | S_IFDIR);
299}
300
301static int omfs_create(struct inode *dir, struct dentry *dentry, int mode,
302 struct nameidata *nd)
303{
304 return omfs_add_node(dir, dentry, mode | S_IFREG);
305}
306
307static struct dentry *omfs_lookup(struct inode *dir, struct dentry *dentry,
308 struct nameidata *nd)
309{
310 struct buffer_head *bh;
311 struct inode *inode = NULL;
312
313 if (dentry->d_name.len > OMFS_NAMELEN)
314 return ERR_PTR(-ENAMETOOLONG);
315
316 bh = omfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len);
317 if (!IS_ERR(bh)) {
318 struct omfs_inode *oi = (struct omfs_inode *)bh->b_data;
319 ino_t ino = be64_to_cpu(oi->i_head.h_self);
320 brelse(bh);
321 inode = omfs_iget(dir->i_sb, ino);
322 if (IS_ERR(inode))
323 return ERR_CAST(inode);
324 }
325 d_add(dentry, inode);
326 return NULL;
327}
328
329/* sanity check block's self pointer */
330int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header,
331 u64 fsblock)
332{
333 int is_bad;
334 u64 ino = be64_to_cpu(header->h_self);
335 is_bad = ((ino != fsblock) || (ino < sbi->s_root_ino) ||
336 (ino > sbi->s_num_blocks));
337
338 if (is_bad)
339 printk(KERN_WARNING "omfs: bad hash chain detected\n");
340
341 return is_bad;
342}
343
344static int omfs_fill_chain(struct file *filp, void *dirent, filldir_t filldir,
345 u64 fsblock, int hindex)
346{
347 struct inode *dir = filp->f_dentry->d_inode;
348 struct buffer_head *bh;
349 struct omfs_inode *oi;
350 u64 self;
351 int res = 0;
352 unsigned char d_type;
353
354 /* follow chain in this bucket */
355 while (fsblock != ~0) {
356 bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb),
357 fsblock));
358 if (!bh)
359 goto out;
360
361 oi = (struct omfs_inode *) bh->b_data;
362 if (omfs_is_bad(OMFS_SB(dir->i_sb), &oi->i_head, fsblock)) {
363 brelse(bh);
364 goto out;
365 }
366
367 self = fsblock;
368 fsblock = be64_to_cpu(oi->i_sibling);
369
370 /* skip visited nodes */
371 if (hindex) {
372 hindex--;
373 brelse(bh);
374 continue;
375 }
376
377 d_type = (oi->i_type == OMFS_DIR) ? DT_DIR : DT_REG;
378
379 res = filldir(dirent, oi->i_name, strnlen(oi->i_name,
380 OMFS_NAMELEN), filp->f_pos, self, d_type);
381 if (res == 0)
382 filp->f_pos++;
383 brelse(bh);
384 }
385out:
386 return res;
387}
388
389static int omfs_rename(struct inode *old_dir, struct dentry *old_dentry,
390 struct inode *new_dir, struct dentry *new_dentry)
391{
392 struct inode *new_inode = new_dentry->d_inode;
393 struct inode *old_inode = old_dentry->d_inode;
394 struct buffer_head *bh;
395 int is_dir;
396 int err;
397
398 is_dir = S_ISDIR(old_inode->i_mode);
399
400 if (new_inode) {
401 /* overwriting existing file/dir */
402 err = -ENOTEMPTY;
403 if (is_dir && !omfs_dir_is_empty(new_inode))
404 goto out;
405
406 err = -ENOENT;
407 bh = omfs_find_entry(new_dir, new_dentry->d_name.name,
408 new_dentry->d_name.len);
409 if (IS_ERR(bh))
410 goto out;
411 brelse(bh);
412
413 err = omfs_unlink(new_dir, new_dentry);
414 if (err)
415 goto out;
416 }
417
418 /* since omfs locates files by name, we need to unlink _before_
419 * adding the new link or we won't find the old one */
420 inode_inc_link_count(old_inode);
421 err = omfs_unlink(old_dir, old_dentry);
422 if (err) {
423 inode_dec_link_count(old_inode);
424 goto out;
425 }
426
427 err = omfs_add_link(new_dentry, old_inode);
428 if (err)
429 goto out;
430
431 old_inode->i_ctime = CURRENT_TIME_SEC;
432out:
433 return err;
434}
435
436static int omfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
437{
438 struct inode *dir = filp->f_dentry->d_inode;
439 struct buffer_head *bh;
440 loff_t offset, res;
441 unsigned int hchain, hindex;
442 int nbuckets;
443 u64 fsblock;
444 int ret = -EINVAL;
445
446 if (filp->f_pos >> 32)
447 goto success;
448
449 switch ((unsigned long) filp->f_pos) {
450 case 0:
451 if (filldir(dirent, ".", 1, 0, dir->i_ino, DT_DIR) < 0)
452 goto success;
453 filp->f_pos++;
454 /* fall through */
455 case 1:
456 if (filldir(dirent, "..", 2, 1,
457 parent_ino(filp->f_dentry), DT_DIR) < 0)
458 goto success;
459 filp->f_pos = 1 << 20;
460 /* fall through */
461 }
462
463 nbuckets = (dir->i_size - OMFS_DIR_START) / 8;
464
465 /* high 12 bits store bucket + 1 and low 20 bits store hash index */
466 hchain = (filp->f_pos >> 20) - 1;
467 hindex = filp->f_pos & 0xfffff;
468
469 bh = sb_bread(dir->i_sb, clus_to_blk(OMFS_SB(dir->i_sb), dir->i_ino));
470 if (!bh)
471 goto out;
472
473 offset = OMFS_DIR_START + hchain * 8;
474
475 for (; hchain < nbuckets; hchain++, offset += 8) {
476 fsblock = be64_to_cpu(*((__be64 *) &bh->b_data[offset]));
477
478 res = omfs_fill_chain(filp, dirent, filldir, fsblock, hindex);
479 hindex = 0;
480 if (res < 0)
481 break;
482
483 filp->f_pos = (hchain+2) << 20;
484 }
485 brelse(bh);
486success:
487 ret = 0;
488out:
489 return ret;
490}
491
492struct inode_operations omfs_dir_inops = {
493 .lookup = omfs_lookup,
494 .mkdir = omfs_mkdir,
495 .rename = omfs_rename,
496 .create = omfs_create,
497 .unlink = omfs_unlink,
498 .rmdir = omfs_rmdir,
499};
500
501struct file_operations omfs_dir_operations = {
502 .read = generic_read_dir,
503 .readdir = omfs_readdir,
504};
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
new file mode 100644
index 000000000000..66e01fae4384
--- /dev/null
+++ b/fs/omfs/file.c
@@ -0,0 +1,346 @@
1/*
2 * OMFS (as used by RIO Karma) file operations.
3 * Copyright (C) 2005 Bob Copeland <me@bobcopeland.com>
4 * Released under GPL v2.
5 */
6
7#include <linux/version.h>
8#include <linux/module.h>
9#include <linux/fs.h>
10#include <linux/buffer_head.h>
11#include <linux/mpage.h>
12#include "omfs.h"
13
14static int omfs_sync_file(struct file *file, struct dentry *dentry,
15 int datasync)
16{
17 struct inode *inode = dentry->d_inode;
18 int err;
19
20 err = sync_mapping_buffers(inode->i_mapping);
21 if (!(inode->i_state & I_DIRTY))
22 return err;
23 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
24 return err;
25 err |= omfs_sync_inode(inode);
26 return err ? -EIO : 0;
27}
28
29void omfs_make_empty_table(struct buffer_head *bh, int offset)
30{
31 struct omfs_extent *oe = (struct omfs_extent *) &bh->b_data[offset];
32
33 oe->e_next = ~0ULL;
34 oe->e_extent_count = cpu_to_be32(1),
35 oe->e_fill = cpu_to_be32(0x22),
36 oe->e_entry.e_cluster = ~0ULL;
37 oe->e_entry.e_blocks = ~0ULL;
38}
39
40int omfs_shrink_inode(struct inode *inode)
41{
42 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
43 struct omfs_extent *oe;
44 struct omfs_extent_entry *entry;
45 struct buffer_head *bh;
46 u64 next, last;
47 u32 extent_count;
48 int ret;
49
50 /* traverse extent table, freeing each entry that is greater
51 * than inode->i_size;
52 */
53 next = inode->i_ino;
54
55 /* only support truncate -> 0 for now */
56 ret = -EIO;
57 if (inode->i_size != 0)
58 goto out;
59
60 bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
61 if (!bh)
62 goto out;
63
64 oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]);
65
66 for (;;) {
67
68 if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next)) {
69 brelse(bh);
70 goto out;
71 }
72
73 extent_count = be32_to_cpu(oe->e_extent_count);
74 last = next;
75 next = be64_to_cpu(oe->e_next);
76 entry = &oe->e_entry;
77
78 /* ignore last entry as it is the terminator */
79 for (; extent_count > 1; extent_count--) {
80 u64 start, count;
81 start = be64_to_cpu(entry->e_cluster);
82 count = be64_to_cpu(entry->e_blocks);
83
84 omfs_clear_range(inode->i_sb, start, (int) count);
85 entry++;
86 }
87 omfs_make_empty_table(bh, (char *) oe - bh->b_data);
88 mark_buffer_dirty(bh);
89 brelse(bh);
90
91 if (last != inode->i_ino)
92 omfs_clear_range(inode->i_sb, last, sbi->s_mirrors);
93
94 if (next == ~0)
95 break;
96
97 bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
98 if (!bh)
99 goto out;
100 oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
101 }
102 ret = 0;
103out:
104 return ret;
105}
106
107static void omfs_truncate(struct inode *inode)
108{
109 omfs_shrink_inode(inode);
110 mark_inode_dirty(inode);
111}
112
113/*
114 * Add new blocks to the current extent, or create new entries/continuations
115 * as necessary.
116 */
117static int omfs_grow_extent(struct inode *inode, struct omfs_extent *oe,
118 u64 *ret_block)
119{
120 struct omfs_extent_entry *terminator;
121 struct omfs_extent_entry *entry = &oe->e_entry;
122 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
123 u32 extent_count = be32_to_cpu(oe->e_extent_count);
124 u64 new_block = 0;
125 u32 max_count;
126 int new_count;
127 int ret = 0;
128
129 /* reached the end of the extent table with no blocks mapped.
130 * there are three possibilities for adding: grow last extent,
131 * add a new extent to the current extent table, and add a
132 * continuation inode. in last two cases need an allocator for
133 * sbi->s_cluster_size
134 */
135
136 /* TODO: handle holes */
137
138 /* should always have a terminator */
139 if (extent_count < 1)
140 return -EIO;
141
142 /* trivially grow current extent, if next block is not taken */
143 terminator = entry + extent_count - 1;
144 if (extent_count > 1) {
145 entry = terminator-1;
146 new_block = be64_to_cpu(entry->e_cluster) +
147 be64_to_cpu(entry->e_blocks);
148
149 if (omfs_allocate_block(inode->i_sb, new_block)) {
150 entry->e_blocks =
151 cpu_to_be64(be64_to_cpu(entry->e_blocks) + 1);
152 terminator->e_blocks = ~(cpu_to_be64(
153 be64_to_cpu(~terminator->e_blocks) + 1));
154 goto out;
155 }
156 }
157 max_count = (sbi->s_sys_blocksize - OMFS_EXTENT_START -
158 sizeof(struct omfs_extent)) /
159 sizeof(struct omfs_extent_entry) + 1;
160
161 /* TODO: add a continuation block here */
162 if (be32_to_cpu(oe->e_extent_count) > max_count-1)
163 return -EIO;
164
165 /* try to allocate a new cluster */
166 ret = omfs_allocate_range(inode->i_sb, 1, sbi->s_clustersize,
167 &new_block, &new_count);
168 if (ret)
169 goto out_fail;
170
171 /* copy terminator down an entry */
172 entry = terminator;
173 terminator++;
174 memcpy(terminator, entry, sizeof(struct omfs_extent_entry));
175
176 entry->e_cluster = cpu_to_be64(new_block);
177 entry->e_blocks = cpu_to_be64((u64) new_count);
178
179 terminator->e_blocks = ~(cpu_to_be64(
180 be64_to_cpu(~terminator->e_blocks) + (u64) new_count));
181
182 /* write in new entry */
183 oe->e_extent_count = cpu_to_be32(1 + be32_to_cpu(oe->e_extent_count));
184
185out:
186 *ret_block = new_block;
187out_fail:
188 return ret;
189}
190
191/*
192 * Scans across the directory table for a given file block number.
193 * If block not found, return 0.
194 */
195static sector_t find_block(struct inode *inode, struct omfs_extent_entry *ent,
196 sector_t block, int count, int *left)
197{
198 /* count > 1 because of terminator */
199 sector_t searched = 0;
200 for (; count > 1; count--) {
201 int numblocks = clus_to_blk(OMFS_SB(inode->i_sb),
202 be64_to_cpu(ent->e_blocks));
203
204 if (block >= searched &&
205 block < searched + numblocks) {
206 /*
207 * found it at cluster + (block - searched)
208 * numblocks - (block - searched) is remainder
209 */
210 *left = numblocks - (block - searched);
211 return clus_to_blk(OMFS_SB(inode->i_sb),
212 be64_to_cpu(ent->e_cluster)) +
213 block - searched;
214 }
215 searched += numblocks;
216 ent++;
217 }
218 return 0;
219}
220
221static int omfs_get_block(struct inode *inode, sector_t block,
222 struct buffer_head *bh_result, int create)
223{
224 struct buffer_head *bh;
225 sector_t next, offset;
226 int ret;
227 u64 new_block;
228 int extent_count;
229 struct omfs_extent *oe;
230 struct omfs_extent_entry *entry;
231 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
232 int max_blocks = bh_result->b_size >> inode->i_blkbits;
233 int remain;
234
235 ret = -EIO;
236 bh = sb_bread(inode->i_sb, clus_to_blk(sbi, inode->i_ino));
237 if (!bh)
238 goto out;
239
240 oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]);
241 next = inode->i_ino;
242
243 for (;;) {
244
245 if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next))
246 goto out_brelse;
247
248 extent_count = be32_to_cpu(oe->e_extent_count);
249 next = be64_to_cpu(oe->e_next);
250 entry = &oe->e_entry;
251
252 offset = find_block(inode, entry, block, extent_count, &remain);
253 if (offset > 0) {
254 ret = 0;
255 map_bh(bh_result, inode->i_sb, offset);
256 if (remain > max_blocks)
257 remain = max_blocks;
258 bh_result->b_size = (remain << inode->i_blkbits);
259 goto out_brelse;
260 }
261 if (next == ~0)
262 break;
263
264 brelse(bh);
265 bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
266 if (!bh)
267 goto out;
268 oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
269 }
270 if (create) {
271 ret = omfs_grow_extent(inode, oe, &new_block);
272 if (ret == 0) {
273 mark_buffer_dirty(bh);
274 mark_inode_dirty(inode);
275 map_bh(bh_result, inode->i_sb,
276 clus_to_blk(sbi, new_block));
277 }
278 }
279out_brelse:
280 brelse(bh);
281out:
282 return ret;
283}
284
285static int omfs_readpage(struct file *file, struct page *page)
286{
287 return block_read_full_page(page, omfs_get_block);
288}
289
290static int omfs_readpages(struct file *file, struct address_space *mapping,
291 struct list_head *pages, unsigned nr_pages)
292{
293 return mpage_readpages(mapping, pages, nr_pages, omfs_get_block);
294}
295
296static int omfs_writepage(struct page *page, struct writeback_control *wbc)
297{
298 return block_write_full_page(page, omfs_get_block, wbc);
299}
300
301static int
302omfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
303{
304 return mpage_writepages(mapping, wbc, omfs_get_block);
305}
306
307static int omfs_write_begin(struct file *file, struct address_space *mapping,
308 loff_t pos, unsigned len, unsigned flags,
309 struct page **pagep, void **fsdata)
310{
311 *pagep = NULL;
312 return block_write_begin(file, mapping, pos, len, flags,
313 pagep, fsdata, omfs_get_block);
314}
315
316static sector_t omfs_bmap(struct address_space *mapping, sector_t block)
317{
318 return generic_block_bmap(mapping, block, omfs_get_block);
319}
320
321struct file_operations omfs_file_operations = {
322 .llseek = generic_file_llseek,
323 .read = do_sync_read,
324 .write = do_sync_write,
325 .aio_read = generic_file_aio_read,
326 .aio_write = generic_file_aio_write,
327 .mmap = generic_file_mmap,
328 .fsync = omfs_sync_file,
329 .splice_read = generic_file_splice_read,
330};
331
332struct inode_operations omfs_file_inops = {
333 .truncate = omfs_truncate
334};
335
336struct address_space_operations omfs_aops = {
337 .readpage = omfs_readpage,
338 .readpages = omfs_readpages,
339 .writepage = omfs_writepage,
340 .writepages = omfs_writepages,
341 .sync_page = block_sync_page,
342 .write_begin = omfs_write_begin,
343 .write_end = generic_write_end,
344 .bmap = omfs_bmap,
345};
346
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
new file mode 100644
index 000000000000..d865f5535436
--- /dev/null
+++ b/fs/omfs/inode.c
@@ -0,0 +1,553 @@
1/*
2 * Optimized MPEG FS - inode and super operations.
3 * Copyright (C) 2006 Bob Copeland <me@bobcopeland.com>
4 * Released under GPL v2.
5 */
6#include <linux/version.h>
7#include <linux/module.h>
8#include <linux/sched.h>
9#include <linux/fs.h>
10#include <linux/vfs.h>
11#include <linux/parser.h>
12#include <linux/buffer_head.h>
13#include <linux/vmalloc.h>
14#include <linux/crc-itu-t.h>
15#include "omfs.h"
16
17MODULE_AUTHOR("Bob Copeland <me@bobcopeland.com>");
18MODULE_DESCRIPTION("OMFS (ReplayTV/Karma) Filesystem for Linux");
19MODULE_LICENSE("GPL");
20
21struct inode *omfs_new_inode(struct inode *dir, int mode)
22{
23 struct inode *inode;
24 u64 new_block;
25 int err;
26 int len;
27 struct omfs_sb_info *sbi = OMFS_SB(dir->i_sb);
28
29 inode = new_inode(dir->i_sb);
30 if (!inode)
31 return ERR_PTR(-ENOMEM);
32
33 err = omfs_allocate_range(dir->i_sb, sbi->s_mirrors, sbi->s_mirrors,
34 &new_block, &len);
35 if (err)
36 goto fail;
37
38 inode->i_ino = new_block;
39 inode->i_mode = mode;
40 inode->i_uid = current->fsuid;
41 inode->i_gid = current->fsgid;
42 inode->i_blocks = 0;
43 inode->i_mapping->a_ops = &omfs_aops;
44
45 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
46 switch (mode & S_IFMT) {
47 case S_IFDIR:
48 inode->i_op = &omfs_dir_inops;
49 inode->i_fop = &omfs_dir_operations;
50 inode->i_size = sbi->s_sys_blocksize;
51 inc_nlink(inode);
52 break;
53 case S_IFREG:
54 inode->i_op = &omfs_file_inops;
55 inode->i_fop = &omfs_file_operations;
56 inode->i_size = 0;
57 break;
58 }
59
60 insert_inode_hash(inode);
61 mark_inode_dirty(inode);
62 return inode;
63fail:
64 make_bad_inode(inode);
65 iput(inode);
66 return ERR_PTR(err);
67}
68
69/*
70 * Update the header checksums for a dirty inode based on its contents.
71 * Caller is expected to hold the buffer head underlying oi and mark it
72 * dirty.
73 */
74static void omfs_update_checksums(struct omfs_inode *oi)
75{
76 int xor, i, ofs = 0, count;
77 u16 crc = 0;
78 unsigned char *ptr = (unsigned char *) oi;
79
80 count = be32_to_cpu(oi->i_head.h_body_size);
81 ofs = sizeof(struct omfs_header);
82
83 crc = crc_itu_t(crc, ptr + ofs, count);
84 oi->i_head.h_crc = cpu_to_be16(crc);
85
86 xor = ptr[0];
87 for (i = 1; i < OMFS_XOR_COUNT; i++)
88 xor ^= ptr[i];
89
90 oi->i_head.h_check_xor = xor;
91}
92
93static int omfs_write_inode(struct inode *inode, int wait)
94{
95 struct omfs_inode *oi;
96 struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
97 struct buffer_head *bh, *bh2;
98 unsigned int block;
99 u64 ctime;
100 int i;
101 int ret = -EIO;
102 int sync_failed = 0;
103
104 /* get current inode since we may have written sibling ptrs etc. */
105 block = clus_to_blk(sbi, inode->i_ino);
106 bh = sb_bread(inode->i_sb, block);
107 if (!bh)
108 goto out;
109
110 oi = (struct omfs_inode *) bh->b_data;
111
112 oi->i_head.h_self = cpu_to_be64(inode->i_ino);
113 if (S_ISDIR(inode->i_mode))
114 oi->i_type = OMFS_DIR;
115 else if (S_ISREG(inode->i_mode))
116 oi->i_type = OMFS_FILE;
117 else {
118 printk(KERN_WARNING "omfs: unknown file type: %d\n",
119 inode->i_mode);
120 goto out_brelse;
121 }
122
123 oi->i_head.h_body_size = cpu_to_be32(sbi->s_sys_blocksize -
124 sizeof(struct omfs_header));
125 oi->i_head.h_version = 1;
126 oi->i_head.h_type = OMFS_INODE_NORMAL;
127 oi->i_head.h_magic = OMFS_IMAGIC;
128 oi->i_size = cpu_to_be64(inode->i_size);
129
130 ctime = inode->i_ctime.tv_sec * 1000LL +
131 ((inode->i_ctime.tv_nsec + 999)/1000);
132 oi->i_ctime = cpu_to_be64(ctime);
133
134 omfs_update_checksums(oi);
135
136 mark_buffer_dirty(bh);
137 if (wait) {
138 sync_dirty_buffer(bh);
139 if (buffer_req(bh) && !buffer_uptodate(bh))
140 sync_failed = 1;
141 }
142
143 /* if mirroring writes, copy to next fsblock */
144 for (i = 1; i < sbi->s_mirrors; i++) {
145 bh2 = sb_bread(inode->i_sb, block + i *
146 (sbi->s_blocksize / sbi->s_sys_blocksize));
147 if (!bh2)
148 goto out_brelse;
149
150 memcpy(bh2->b_data, bh->b_data, bh->b_size);
151 mark_buffer_dirty(bh2);
152 if (wait) {
153 sync_dirty_buffer(bh2);
154 if (buffer_req(bh2) && !buffer_uptodate(bh2))
155 sync_failed = 1;
156 }
157 brelse(bh2);
158 }
159 ret = (sync_failed) ? -EIO : 0;
160out_brelse:
161 brelse(bh);
162out:
163 return ret;
164}
165
166int omfs_sync_inode(struct inode *inode)
167{
168 return omfs_write_inode(inode, 1);
169}
170
171/*
172 * called when an entry is deleted, need to clear the bits in the
173 * bitmaps.
174 */
175static void omfs_delete_inode(struct inode *inode)
176{
177 truncate_inode_pages(&inode->i_data, 0);
178
179 if (S_ISREG(inode->i_mode)) {
180 inode->i_size = 0;
181 omfs_shrink_inode(inode);
182 }
183
184 omfs_clear_range(inode->i_sb, inode->i_ino, 2);
185 clear_inode(inode);
186}
187
188struct inode *omfs_iget(struct super_block *sb, ino_t ino)
189{
190 struct omfs_sb_info *sbi = OMFS_SB(sb);
191 struct omfs_inode *oi;
192 struct buffer_head *bh;
193 unsigned int block;
194 u64 ctime;
195 unsigned long nsecs;
196 struct inode *inode;
197
198 inode = iget_locked(sb, ino);
199 if (!inode)
200 return ERR_PTR(-ENOMEM);
201 if (!(inode->i_state & I_NEW))
202 return inode;
203
204 block = clus_to_blk(sbi, ino);
205 bh = sb_bread(inode->i_sb, block);
206 if (!bh)
207 goto iget_failed;
208
209 oi = (struct omfs_inode *)bh->b_data;
210
211 /* check self */
212 if (ino != be64_to_cpu(oi->i_head.h_self))
213 goto fail_bh;
214
215 inode->i_uid = sbi->s_uid;
216 inode->i_gid = sbi->s_gid;
217
218 ctime = be64_to_cpu(oi->i_ctime);
219 nsecs = do_div(ctime, 1000) * 1000L;
220
221 inode->i_atime.tv_sec = ctime;
222 inode->i_mtime.tv_sec = ctime;
223 inode->i_ctime.tv_sec = ctime;
224 inode->i_atime.tv_nsec = nsecs;
225 inode->i_mtime.tv_nsec = nsecs;
226 inode->i_ctime.tv_nsec = nsecs;
227
228 inode->i_mapping->a_ops = &omfs_aops;
229
230 switch (oi->i_type) {
231 case OMFS_DIR:
232 inode->i_mode = S_IFDIR | (S_IRWXUGO & ~sbi->s_dmask);
233 inode->i_op = &omfs_dir_inops;
234 inode->i_fop = &omfs_dir_operations;
235 inode->i_size = be32_to_cpu(oi->i_head.h_body_size) +
236 sizeof(struct omfs_header);
237 inc_nlink(inode);
238 break;
239 case OMFS_FILE:
240 inode->i_mode = S_IFREG | (S_IRWXUGO & ~sbi->s_fmask);
241 inode->i_fop = &omfs_file_operations;
242 inode->i_size = be64_to_cpu(oi->i_size);
243 break;
244 }
245 brelse(bh);
246 unlock_new_inode(inode);
247 return inode;
248fail_bh:
249 brelse(bh);
250iget_failed:
251 iget_failed(inode);
252 return ERR_PTR(-EIO);
253}
254
255static void omfs_put_super(struct super_block *sb)
256{
257 struct omfs_sb_info *sbi = OMFS_SB(sb);
258 kfree(sbi->s_imap);
259 kfree(sbi);
260 sb->s_fs_info = NULL;
261}
262
263static int omfs_statfs(struct dentry *dentry, struct kstatfs *buf)
264{
265 struct super_block *s = dentry->d_sb;
266 struct omfs_sb_info *sbi = OMFS_SB(s);
267 buf->f_type = OMFS_MAGIC;
268 buf->f_bsize = sbi->s_blocksize;
269 buf->f_blocks = sbi->s_num_blocks;
270 buf->f_files = sbi->s_num_blocks;
271 buf->f_namelen = OMFS_NAMELEN;
272
273 buf->f_bfree = buf->f_bavail = buf->f_ffree =
274 omfs_count_free(s);
275 return 0;
276}
277
278static struct super_operations omfs_sops = {
279 .write_inode = omfs_write_inode,
280 .delete_inode = omfs_delete_inode,
281 .put_super = omfs_put_super,
282 .statfs = omfs_statfs,
283 .show_options = generic_show_options,
284};
285
286/*
287 * For Rio Karma, there is an on-disk free bitmap whose location is
288 * stored in the root block. For ReplayTV, there is no such free bitmap
289 * so we have to walk the tree. Both inodes and file data are allocated
290 * from the same map. This array can be big (300k) so we allocate
291 * in units of the blocksize.
292 */
293static int omfs_get_imap(struct super_block *sb)
294{
295 int bitmap_size;
296 int array_size;
297 int count;
298 struct omfs_sb_info *sbi = OMFS_SB(sb);
299 struct buffer_head *bh;
300 unsigned long **ptr;
301 sector_t block;
302
303 bitmap_size = DIV_ROUND_UP(sbi->s_num_blocks, 8);
304 array_size = DIV_ROUND_UP(bitmap_size, sb->s_blocksize);
305
306 if (sbi->s_bitmap_ino == ~0ULL)
307 goto out;
308
309 sbi->s_imap_size = array_size;
310 sbi->s_imap = kzalloc(array_size * sizeof(unsigned long *), GFP_KERNEL);
311 if (!sbi->s_imap)
312 goto nomem;
313
314 block = clus_to_blk(sbi, sbi->s_bitmap_ino);
315 ptr = sbi->s_imap;
316 for (count = bitmap_size; count > 0; count -= sb->s_blocksize) {
317 bh = sb_bread(sb, block++);
318 if (!bh)
319 goto nomem_free;
320 *ptr = kmalloc(sb->s_blocksize, GFP_KERNEL);
321 if (!*ptr) {
322 brelse(bh);
323 goto nomem_free;
324 }
325 memcpy(*ptr, bh->b_data, sb->s_blocksize);
326 if (count < sb->s_blocksize)
327 memset((void *)*ptr + count, 0xff,
328 sb->s_blocksize - count);
329 brelse(bh);
330 ptr++;
331 }
332out:
333 return 0;
334
335nomem_free:
336 for (count = 0; count < array_size; count++)
337 kfree(sbi->s_imap[count]);
338
339 kfree(sbi->s_imap);
340nomem:
341 sbi->s_imap = NULL;
342 sbi->s_imap_size = 0;
343 return -ENOMEM;
344}
345
346enum {
347 Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask
348};
349
350static match_table_t tokens = {
351 {Opt_uid, "uid=%u"},
352 {Opt_gid, "gid=%u"},
353 {Opt_umask, "umask=%o"},
354 {Opt_dmask, "dmask=%o"},
355 {Opt_fmask, "fmask=%o"},
356};
357
358static int parse_options(char *options, struct omfs_sb_info *sbi)
359{
360 char *p;
361 substring_t args[MAX_OPT_ARGS];
362 int option;
363
364 if (!options)
365 return 1;
366
367 while ((p = strsep(&options, ",")) != NULL) {
368 int token;
369 if (!*p)
370 continue;
371
372 token = match_token(p, tokens, args);
373 switch (token) {
374 case Opt_uid:
375 if (match_int(&args[0], &option))
376 return 0;
377 sbi->s_uid = option;
378 break;
379 case Opt_gid:
380 if (match_int(&args[0], &option))
381 return 0;
382 sbi->s_gid = option;
383 break;
384 case Opt_umask:
385 if (match_octal(&args[0], &option))
386 return 0;
387 sbi->s_fmask = sbi->s_dmask = option;
388 break;
389 case Opt_dmask:
390 if (match_octal(&args[0], &option))
391 return 0;
392 sbi->s_dmask = option;
393 break;
394 case Opt_fmask:
395 if (match_octal(&args[0], &option))
396 return 0;
397 sbi->s_fmask = option;
398 break;
399 default:
400 return 0;
401 }
402 }
403 return 1;
404}
405
406static int omfs_fill_super(struct super_block *sb, void *data, int silent)
407{
408 struct buffer_head *bh, *bh2;
409 struct omfs_super_block *omfs_sb;
410 struct omfs_root_block *omfs_rb;
411 struct omfs_sb_info *sbi;
412 struct inode *root;
413 sector_t start;
414 int ret = -EINVAL;
415
416 save_mount_options(sb, (char *) data);
417
418 sbi = kzalloc(sizeof(struct omfs_sb_info), GFP_KERNEL);
419 if (!sbi)
420 return -ENOMEM;
421
422 sb->s_fs_info = sbi;
423
424 sbi->s_uid = current->uid;
425 sbi->s_gid = current->gid;
426 sbi->s_dmask = sbi->s_fmask = current->fs->umask;
427
428 if (!parse_options((char *) data, sbi))
429 goto end;
430
431 sb->s_maxbytes = 0xffffffff;
432
433 sb_set_blocksize(sb, 0x200);
434
435 bh = sb_bread(sb, 0);
436 if (!bh)
437 goto end;
438
439 omfs_sb = (struct omfs_super_block *)bh->b_data;
440
441 if (omfs_sb->s_magic != cpu_to_be32(OMFS_MAGIC)) {
442 if (!silent)
443 printk(KERN_ERR "omfs: Invalid superblock (%x)\n",
444 omfs_sb->s_magic);
445 goto out_brelse_bh;
446 }
447 sb->s_magic = OMFS_MAGIC;
448
449 sbi->s_num_blocks = be64_to_cpu(omfs_sb->s_num_blocks);
450 sbi->s_blocksize = be32_to_cpu(omfs_sb->s_blocksize);
451 sbi->s_mirrors = be32_to_cpu(omfs_sb->s_mirrors);
452 sbi->s_root_ino = be64_to_cpu(omfs_sb->s_root_block);
453 sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize);
454 mutex_init(&sbi->s_bitmap_lock);
455
456 if (sbi->s_sys_blocksize > PAGE_SIZE) {
457 printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n",
458 sbi->s_sys_blocksize);
459 goto out_brelse_bh;
460 }
461
462 if (sbi->s_blocksize < sbi->s_sys_blocksize ||
463 sbi->s_blocksize > OMFS_MAX_BLOCK_SIZE) {
464 printk(KERN_ERR "omfs: block size (%d) is out of range\n",
465 sbi->s_blocksize);
466 goto out_brelse_bh;
467 }
468
469 /*
470 * Use sys_blocksize as the fs block since it is smaller than a
471 * page while the fs blocksize can be larger.
472 */
473 sb_set_blocksize(sb, sbi->s_sys_blocksize);
474
475 /*
476 * ...and the difference goes into a shift. sys_blocksize is always
477 * a power of two factor of blocksize.
478 */
479 sbi->s_block_shift = get_bitmask_order(sbi->s_blocksize) -
480 get_bitmask_order(sbi->s_sys_blocksize);
481
482 start = clus_to_blk(sbi, be64_to_cpu(omfs_sb->s_root_block));
483 bh2 = sb_bread(sb, start);
484 if (!bh2)
485 goto out_brelse_bh;
486
487 omfs_rb = (struct omfs_root_block *)bh2->b_data;
488
489 sbi->s_bitmap_ino = be64_to_cpu(omfs_rb->r_bitmap);
490 sbi->s_clustersize = be32_to_cpu(omfs_rb->r_clustersize);
491
492 if (sbi->s_num_blocks != be64_to_cpu(omfs_rb->r_num_blocks)) {
493 printk(KERN_ERR "omfs: block count discrepancy between "
494 "super and root blocks (%llx, %llx)\n",
495 sbi->s_num_blocks, be64_to_cpu(omfs_rb->r_num_blocks));
496 goto out_brelse_bh2;
497 }
498
499 ret = omfs_get_imap(sb);
500 if (ret)
501 goto out_brelse_bh2;
502
503 sb->s_op = &omfs_sops;
504
505 root = omfs_iget(sb, be64_to_cpu(omfs_rb->r_root_dir));
506 if (IS_ERR(root)) {
507 ret = PTR_ERR(root);
508 goto out_brelse_bh2;
509 }
510
511 sb->s_root = d_alloc_root(root);
512 if (!sb->s_root) {
513 iput(root);
514 goto out_brelse_bh2;
515 }
516 printk(KERN_DEBUG "omfs: Mounted volume %s\n", omfs_rb->r_name);
517
518 ret = 0;
519out_brelse_bh2:
520 brelse(bh2);
521out_brelse_bh:
522 brelse(bh);
523end:
524 return ret;
525}
526
527static int omfs_get_sb(struct file_system_type *fs_type,
528 int flags, const char *dev_name,
529 void *data, struct vfsmount *m)
530{
531 return get_sb_bdev(fs_type, flags, dev_name, data, omfs_fill_super, m);
532}
533
534static struct file_system_type omfs_fs_type = {
535 .owner = THIS_MODULE,
536 .name = "omfs",
537 .get_sb = omfs_get_sb,
538 .kill_sb = kill_block_super,
539 .fs_flags = FS_REQUIRES_DEV,
540};
541
542static int __init init_omfs_fs(void)
543{
544 return register_filesystem(&omfs_fs_type);
545}
546
547static void __exit exit_omfs_fs(void)
548{
549 unregister_filesystem(&omfs_fs_type);
550}
551
552module_init(init_omfs_fs);
553module_exit(exit_omfs_fs);
diff --git a/fs/omfs/omfs.h b/fs/omfs/omfs.h
new file mode 100644
index 000000000000..2bc0f0670406
--- /dev/null
+++ b/fs/omfs/omfs.h
@@ -0,0 +1,67 @@
1#ifndef _OMFS_H
2#define _OMFS_H
3
4#include <linux/module.h>
5#include <linux/fs.h>
6
7#include "omfs_fs.h"
8
9/* In-memory structures */
10struct omfs_sb_info {
11 u64 s_num_blocks;
12 u64 s_bitmap_ino;
13 u64 s_root_ino;
14 u32 s_blocksize;
15 u32 s_mirrors;
16 u32 s_sys_blocksize;
17 u32 s_clustersize;
18 int s_block_shift;
19 unsigned long **s_imap;
20 int s_imap_size;
21 struct mutex s_bitmap_lock;
22 int s_uid;
23 int s_gid;
24 int s_dmask;
25 int s_fmask;
26};
27
28/* convert a cluster number to a scaled block number */
29static inline sector_t clus_to_blk(struct omfs_sb_info *sbi, sector_t block)
30{
31 return block << sbi->s_block_shift;
32}
33
34static inline struct omfs_sb_info *OMFS_SB(struct super_block *sb)
35{
36 return sb->s_fs_info;
37}
38
39/* bitmap.c */
40extern unsigned long omfs_count_free(struct super_block *sb);
41extern int omfs_allocate_block(struct super_block *sb, u64 block);
42extern int omfs_allocate_range(struct super_block *sb, int min_request,
43 int max_request, u64 *return_block, int *return_size);
44extern int omfs_clear_range(struct super_block *sb, u64 block, int count);
45
46/* dir.c */
47extern struct file_operations omfs_dir_operations;
48extern struct inode_operations omfs_dir_inops;
49extern int omfs_make_empty(struct inode *inode, struct super_block *sb);
50extern int omfs_is_bad(struct omfs_sb_info *sbi, struct omfs_header *header,
51 u64 fsblock);
52
53/* file.c */
54extern struct file_operations omfs_file_operations;
55extern struct inode_operations omfs_file_inops;
56extern struct address_space_operations omfs_aops;
57extern void omfs_make_empty_table(struct buffer_head *bh, int offset);
58extern int omfs_shrink_inode(struct inode *inode);
59
60/* inode.c */
61extern struct inode *omfs_iget(struct super_block *sb, ino_t inode);
62extern struct inode *omfs_new_inode(struct inode *dir, int mode);
63extern int omfs_reserve_block(struct super_block *sb, sector_t block);
64extern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino);
65extern int omfs_sync_inode(struct inode *inode);
66
67#endif
diff --git a/fs/omfs/omfs_fs.h b/fs/omfs/omfs_fs.h
new file mode 100644
index 000000000000..12cca245d6e8
--- /dev/null
+++ b/fs/omfs/omfs_fs.h
@@ -0,0 +1,80 @@
1#ifndef _OMFS_FS_H
2#define _OMFS_FS_H
3
4/* OMFS On-disk structures */
5
6#define OMFS_MAGIC 0xC2993D87
7#define OMFS_IMAGIC 0xD2
8
9#define OMFS_DIR 'D'
10#define OMFS_FILE 'F'
11#define OMFS_INODE_NORMAL 'e'
12#define OMFS_INODE_CONTINUATION 'c'
13#define OMFS_INODE_SYSTEM 's'
14#define OMFS_NAMELEN 256
15#define OMFS_DIR_START 0x1b8
16#define OMFS_EXTENT_START 0x1d0
17#define OMFS_EXTENT_CONT 0x40
18#define OMFS_XOR_COUNT 19
19#define OMFS_MAX_BLOCK_SIZE 8192
20
21struct omfs_super_block {
22 char s_fill1[256];
23 __be64 s_root_block; /* block number of omfs_root_block */
24 __be64 s_num_blocks; /* total number of FS blocks */
25 __be32 s_magic; /* OMFS_MAGIC */
26 __be32 s_blocksize; /* size of a block */
27 __be32 s_mirrors; /* # of mirrors of system blocks */
28 __be32 s_sys_blocksize; /* size of non-data blocks */
29};
30
31struct omfs_header {
32 __be64 h_self; /* FS block where this is located */
33 __be32 h_body_size; /* size of useful data after header */
34 __be16 h_crc; /* crc-ccitt of body_size bytes */
35 char h_fill1[2];
36 u8 h_version; /* version, always 1 */
37 char h_type; /* OMFS_INODE_X */
38 u8 h_magic; /* OMFS_IMAGIC */
39 u8 h_check_xor; /* XOR of header bytes before this */
40 __be32 h_fill2;
41};
42
43struct omfs_root_block {
44 struct omfs_header r_head; /* header */
45 __be64 r_fill1;
46 __be64 r_num_blocks; /* total number of FS blocks */
47 __be64 r_root_dir; /* block # of root directory */
48 __be64 r_bitmap; /* block # of free space bitmap */
49 __be32 r_blocksize; /* size of a block */
50 __be32 r_clustersize; /* size allocated for data blocks */
51 __be64 r_mirrors; /* # of mirrors of system blocks */
52 char r_name[OMFS_NAMELEN]; /* partition label */
53};
54
55struct omfs_inode {
56 struct omfs_header i_head; /* header */
57 __be64 i_parent; /* parent containing this inode */
58 __be64 i_sibling; /* next inode in hash bucket */
59 __be64 i_ctime; /* ctime, in milliseconds */
60 char i_fill1[35];
61 char i_type; /* OMFS_[DIR,FILE] */
62 __be32 i_fill2;
63 char i_fill3[64];
64 char i_name[OMFS_NAMELEN]; /* filename */
65 __be64 i_size; /* size of file, in bytes */
66};
67
68struct omfs_extent_entry {
69 __be64 e_cluster; /* start location of a set of blocks */
70 __be64 e_blocks; /* number of blocks after e_cluster */
71};
72
73struct omfs_extent {
74 __be64 e_next; /* next extent table location */
75 __be32 e_extent_count; /* total # extents in this table */
76 __be32 e_fill;
77 struct omfs_extent_entry e_entry; /* start of extent entries */
78};
79
80#endif
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index d17b4fd204e1..9f5b054f06b9 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -430,7 +430,7 @@ static struct file_system_type openprom_fs_type = {
430 .kill_sb = kill_anon_super, 430 .kill_sb = kill_anon_super,
431}; 431};
432 432
433static void op_inode_init_once(struct kmem_cache * cachep, void *data) 433static void op_inode_init_once(void *data)
434{ 434{
435 struct op_inode_info *oi = (struct op_inode_info *) data; 435 struct op_inode_info *oi = (struct op_inode_info *) data;
436 436
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 797d775e0354..0d6eb33597c6 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -80,6 +80,7 @@
80#include <linux/delayacct.h> 80#include <linux/delayacct.h>
81#include <linux/seq_file.h> 81#include <linux/seq_file.h>
82#include <linux/pid_namespace.h> 82#include <linux/pid_namespace.h>
83#include <linux/tracehook.h>
83 84
84#include <asm/pgtable.h> 85#include <asm/pgtable.h>
85#include <asm/processor.h> 86#include <asm/processor.h>
@@ -168,8 +169,12 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
168 rcu_read_lock(); 169 rcu_read_lock();
169 ppid = pid_alive(p) ? 170 ppid = pid_alive(p) ?
170 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; 171 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
171 tpid = pid_alive(p) && p->ptrace ? 172 tpid = 0;
172 task_pid_nr_ns(rcu_dereference(p->parent), ns) : 0; 173 if (pid_alive(p)) {
174 struct task_struct *tracer = tracehook_tracer_task(p);
175 if (tracer)
176 tpid = task_pid_nr_ns(tracer, ns);
177 }
173 seq_printf(m, 178 seq_printf(m,
174 "State:\t%s\n" 179 "State:\t%s\n"
175 "Tgid:\t%d\n" 180 "Tgid:\t%d\n"
diff --git a/fs/proc/base.c b/fs/proc/base.c
index a891fe4cb43b..81bce6791bfc 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -69,6 +69,7 @@
69#include <linux/mount.h> 69#include <linux/mount.h>
70#include <linux/security.h> 70#include <linux/security.h>
71#include <linux/ptrace.h> 71#include <linux/ptrace.h>
72#include <linux/tracehook.h>
72#include <linux/cgroup.h> 73#include <linux/cgroup.h>
73#include <linux/cpuset.h> 74#include <linux/cpuset.h>
74#include <linux/audit.h> 75#include <linux/audit.h>
@@ -231,10 +232,14 @@ static int check_mem_permission(struct task_struct *task)
231 * If current is actively ptrace'ing, and would also be 232 * If current is actively ptrace'ing, and would also be
232 * permitted to freshly attach with ptrace now, permit it. 233 * permitted to freshly attach with ptrace now, permit it.
233 */ 234 */
234 if (task->parent == current && (task->ptrace & PT_PTRACED) && 235 if (task_is_stopped_or_traced(task)) {
235 task_is_stopped_or_traced(task) && 236 int match;
236 ptrace_may_access(task, PTRACE_MODE_ATTACH)) 237 rcu_read_lock();
237 return 0; 238 match = (tracehook_tracer_task(task) == current);
239 rcu_read_unlock();
240 if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH))
241 return 0;
242 }
238 243
239 /* 244 /*
240 * Noone else is allowed. 245 * Noone else is allowed.
@@ -504,6 +509,26 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
504 return count; 509 return count;
505} 510}
506 511
512#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
513static int proc_pid_syscall(struct task_struct *task, char *buffer)
514{
515 long nr;
516 unsigned long args[6], sp, pc;
517
518 if (task_current_syscall(task, &nr, args, 6, &sp, &pc))
519 return sprintf(buffer, "running\n");
520
521 if (nr < 0)
522 return sprintf(buffer, "%ld 0x%lx 0x%lx\n", nr, sp, pc);
523
524 return sprintf(buffer,
525 "%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
526 nr,
527 args[0], args[1], args[2], args[3], args[4], args[5],
528 sp, pc);
529}
530#endif /* CONFIG_HAVE_ARCH_TRACEHOOK */
531
507/************************************************************************/ 532/************************************************************************/
508/* Here the fs part begins */ 533/* Here the fs part begins */
509/************************************************************************/ 534/************************************************************************/
@@ -2473,6 +2498,9 @@ static const struct pid_entry tgid_base_stuff[] = {
2473#ifdef CONFIG_SCHED_DEBUG 2498#ifdef CONFIG_SCHED_DEBUG
2474 REG("sched", S_IRUGO|S_IWUSR, pid_sched), 2499 REG("sched", S_IRUGO|S_IWUSR, pid_sched),
2475#endif 2500#endif
2501#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
2502 INF("syscall", S_IRUSR, pid_syscall),
2503#endif
2476 INF("cmdline", S_IRUGO, pid_cmdline), 2504 INF("cmdline", S_IRUGO, pid_cmdline),
2477 ONE("stat", S_IRUGO, tgid_stat), 2505 ONE("stat", S_IRUGO, tgid_stat),
2478 ONE("statm", S_IRUGO, pid_statm), 2506 ONE("statm", S_IRUGO, pid_statm),
@@ -2805,6 +2833,9 @@ static const struct pid_entry tid_base_stuff[] = {
2805#ifdef CONFIG_SCHED_DEBUG 2833#ifdef CONFIG_SCHED_DEBUG
2806 REG("sched", S_IRUGO|S_IWUSR, pid_sched), 2834 REG("sched", S_IRUGO|S_IWUSR, pid_sched),
2807#endif 2835#endif
2836#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
2837 INF("syscall", S_IRUSR, pid_syscall),
2838#endif
2808 INF("cmdline", S_IRUGO, pid_cmdline), 2839 INF("cmdline", S_IRUGO, pid_cmdline),
2809 ONE("stat", S_IRUGO, tid_stat), 2840 ONE("stat", S_IRUGO, tid_stat),
2810 ONE("statm", S_IRUGO, pid_statm), 2841 ONE("statm", S_IRUGO, pid_statm),
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index bc0a0dd2d844..cb4096cc3fb7 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -806,12 +806,9 @@ continue_removing:
806 if (S_ISDIR(de->mode)) 806 if (S_ISDIR(de->mode))
807 parent->nlink--; 807 parent->nlink--;
808 de->nlink = 0; 808 de->nlink = 0;
809 if (de->subdir) { 809 WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory "
810 printk(KERN_WARNING "%s: removing non-empty directory "
811 "'%s/%s', leaking at least '%s'\n", __func__, 810 "'%s/%s', leaking at least '%s'\n", __func__,
812 de->parent->name, de->name, de->subdir->name); 811 de->parent->name, de->name, de->subdir->name);
813 WARN_ON(1);
814 }
815 if (atomic_dec_and_test(&de->count)) 812 if (atomic_dec_and_test(&de->count))
816 free_proc_entry(de); 813 free_proc_entry(de);
817} 814}
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 02eca2ed9dd7..b37f25dc45a5 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -94,7 +94,7 @@ static void proc_destroy_inode(struct inode *inode)
94 kmem_cache_free(proc_inode_cachep, PROC_I(inode)); 94 kmem_cache_free(proc_inode_cachep, PROC_I(inode));
95} 95}
96 96
97static void init_once(struct kmem_cache * cachep, void *foo) 97static void init_once(void *foo)
98{ 98{
99 struct proc_inode *ei = (struct proc_inode *) foo; 99 struct proc_inode *ei = (struct proc_inode *) foo;
100 100
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index b31ab78052b3..2aad1044b84c 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -553,7 +553,7 @@ static void qnx4_destroy_inode(struct inode *inode)
553 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); 553 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode));
554} 554}
555 555
556static void init_once(struct kmem_cache *cachep, void *foo) 556static void init_once(void *foo)
557{ 557{
558 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo; 558 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo;
559 559
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 2ec748ba0bd3..879e54d35c2d 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -521,7 +521,7 @@ static void reiserfs_destroy_inode(struct inode *inode)
521 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); 521 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
522} 522}
523 523
524static void init_once(struct kmem_cache * cachep, void *foo) 524static void init_once(void *foo)
525{ 525{
526 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; 526 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
527 527
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 3f13d491c7c7..8e51a2aaa977 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -577,7 +577,7 @@ static void romfs_destroy_inode(struct inode *inode)
577 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); 577 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
578} 578}
579 579
580static void init_once(struct kmem_cache *cachep, void *foo) 580static void init_once(void *foo)
581{ 581{
582 struct romfs_inode_info *ei = foo; 582 struct romfs_inode_info *ei = foo;
583 583
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 376ef3ee6ed7..3528f40ffb0f 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -67,7 +67,7 @@ static void smb_destroy_inode(struct inode *inode)
67 kmem_cache_free(smb_inode_cachep, SMB_I(inode)); 67 kmem_cache_free(smb_inode_cachep, SMB_I(inode));
68} 68}
69 69
70static void init_once(struct kmem_cache *cachep, void *foo) 70static void init_once(void *foo)
71{ 71{
72 struct smb_inode_info *ei = (struct smb_inode_info *) foo; 72 struct smb_inode_info *ei = (struct smb_inode_info *) foo;
73 73
diff --git a/fs/splice.c b/fs/splice.c
index 399442179d89..47dc1a445d1f 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1161,36 +1161,6 @@ static long do_splice(struct file *in, loff_t __user *off_in,
1161} 1161}
1162 1162
1163/* 1163/*
1164 * Do a copy-from-user while holding the mmap_semaphore for reading, in a
1165 * manner safe from deadlocking with simultaneous mmap() (grabbing mmap_sem
1166 * for writing) and page faulting on the user memory pointed to by src.
1167 * This assumes that we will very rarely hit the partial != 0 path, or this
1168 * will not be a win.
1169 */
1170static int copy_from_user_mmap_sem(void *dst, const void __user *src, size_t n)
1171{
1172 int partial;
1173
1174 if (!access_ok(VERIFY_READ, src, n))
1175 return -EFAULT;
1176
1177 pagefault_disable();
1178 partial = __copy_from_user_inatomic(dst, src, n);
1179 pagefault_enable();
1180
1181 /*
1182 * Didn't copy everything, drop the mmap_sem and do a faulting copy
1183 */
1184 if (unlikely(partial)) {
1185 up_read(&current->mm->mmap_sem);
1186 partial = copy_from_user(dst, src, n);
1187 down_read(&current->mm->mmap_sem);
1188 }
1189
1190 return partial;
1191}
1192
1193/*
1194 * Map an iov into an array of pages and offset/length tupples. With the 1164 * Map an iov into an array of pages and offset/length tupples. With the
1195 * partial_page structure, we can map several non-contiguous ranges into 1165 * partial_page structure, we can map several non-contiguous ranges into
1196 * our ones pages[] map instead of splitting that operation into pieces. 1166 * our ones pages[] map instead of splitting that operation into pieces.
@@ -1203,8 +1173,6 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1203{ 1173{
1204 int buffers = 0, error = 0; 1174 int buffers = 0, error = 0;
1205 1175
1206 down_read(&current->mm->mmap_sem);
1207
1208 while (nr_vecs) { 1176 while (nr_vecs) {
1209 unsigned long off, npages; 1177 unsigned long off, npages;
1210 struct iovec entry; 1178 struct iovec entry;
@@ -1213,7 +1181,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1213 int i; 1181 int i;
1214 1182
1215 error = -EFAULT; 1183 error = -EFAULT;
1216 if (copy_from_user_mmap_sem(&entry, iov, sizeof(entry))) 1184 if (copy_from_user(&entry, iov, sizeof(entry)))
1217 break; 1185 break;
1218 1186
1219 base = entry.iov_base; 1187 base = entry.iov_base;
@@ -1247,9 +1215,8 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1247 if (npages > PIPE_BUFFERS - buffers) 1215 if (npages > PIPE_BUFFERS - buffers)
1248 npages = PIPE_BUFFERS - buffers; 1216 npages = PIPE_BUFFERS - buffers;
1249 1217
1250 error = get_user_pages(current, current->mm, 1218 error = get_user_pages_fast((unsigned long)base, npages,
1251 (unsigned long) base, npages, 0, 0, 1219 0, &pages[buffers]);
1252 &pages[buffers], NULL);
1253 1220
1254 if (unlikely(error <= 0)) 1221 if (unlikely(error <= 0))
1255 break; 1222 break;
@@ -1288,8 +1255,6 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1288 iov++; 1255 iov++;
1289 } 1256 }
1290 1257
1291 up_read(&current->mm->mmap_sem);
1292
1293 if (buffers) 1258 if (buffers)
1294 return buffers; 1259 return buffers;
1295 1260
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index c1a7efb310bf..aedaeba82ae5 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -459,11 +459,8 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
459 int ret; 459 int ret;
460 460
461 ret = __sysfs_add_one(acxt, sd); 461 ret = __sysfs_add_one(acxt, sd);
462 if (ret == -EEXIST) { 462 WARN(ret == -EEXIST, KERN_WARNING "sysfs: duplicate filename '%s' "
463 printk(KERN_WARNING "sysfs: duplicate filename '%s' "
464 "can not be created\n", sd->s_name); 463 "can not be created\n", sd->s_name);
465 WARN_ON(1);
466 }
467 return ret; 464 return ret;
468} 465}
469 466
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 3f07893ff896..c9e4e5091da1 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -337,9 +337,8 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
337 if (kobj->ktype && kobj->ktype->sysfs_ops) 337 if (kobj->ktype && kobj->ktype->sysfs_ops)
338 ops = kobj->ktype->sysfs_ops; 338 ops = kobj->ktype->sysfs_ops;
339 else { 339 else {
340 printk(KERN_ERR "missing sysfs attribute operations for " 340 WARN(1, KERN_ERR "missing sysfs attribute operations for "
341 "kobject: %s\n", kobject_name(kobj)); 341 "kobject: %s\n", kobject_name(kobj));
342 WARN_ON(1);
343 goto err_out; 342 goto err_out;
344 } 343 }
345 344
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index eeba38417b1d..fe611949a7f7 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -134,9 +134,8 @@ void sysfs_remove_group(struct kobject * kobj,
134 if (grp->name) { 134 if (grp->name) {
135 sd = sysfs_get_dirent(dir_sd, grp->name); 135 sd = sysfs_get_dirent(dir_sd, grp->name);
136 if (!sd) { 136 if (!sd) {
137 printk(KERN_WARNING "sysfs group %p not found for " 137 WARN(!sd, KERN_WARNING "sysfs group %p not found for "
138 "kobject '%s'\n", grp, kobject_name(kobj)); 138 "kobject '%s'\n", grp, kobject_name(kobj));
139 WARN_ON(!sd);
140 return; 139 return;
141 } 140 }
142 } else 141 } else
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index c5d60de0658f..df0d435baa48 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -326,7 +326,7 @@ static void sysv_destroy_inode(struct inode *inode)
326 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); 326 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode));
327} 327}
328 328
329static void init_once(struct kmem_cache *cachep, void *p) 329static void init_once(void *p)
330{ 330{
331 struct sysv_inode_info *si = (struct sysv_inode_info *)p; 331 struct sysv_inode_info *si = (struct sysv_inode_info *)p;
332 332
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 00eb9c68ad03..ca1e2d4e03cc 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1841,7 +1841,7 @@ static struct file_system_type ubifs_fs_type = {
1841/* 1841/*
1842 * Inode slab cache constructor. 1842 * Inode slab cache constructor.
1843 */ 1843 */
1844static void inode_slab_ctor(struct kmem_cache *cachep, void *obj) 1844static void inode_slab_ctor(void *obj)
1845{ 1845{
1846 struct ubifs_inode *ui = obj; 1846 struct ubifs_inode *ui = obj;
1847 inode_init_once(&ui->vfs_inode); 1847 inode_init_once(&ui->vfs_inode);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 44cc702f96cc..5698bbf83bbf 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -148,7 +148,7 @@ static void udf_destroy_inode(struct inode *inode)
148 kmem_cache_free(udf_inode_cachep, UDF_I(inode)); 148 kmem_cache_free(udf_inode_cachep, UDF_I(inode));
149} 149}
150 150
151static void init_once(struct kmem_cache *cachep, void *foo) 151static void init_once(void *foo)
152{ 152{
153 struct udf_inode_info *ei = (struct udf_inode_info *)foo; 153 struct udf_inode_info *ei = (struct udf_inode_info *)foo;
154 154
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 227c9d700040..3e30e40aa24d 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -1302,7 +1302,7 @@ static void ufs_destroy_inode(struct inode *inode)
1302 kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); 1302 kmem_cache_free(ufs_inode_cachep, UFS_I(inode));
1303} 1303}
1304 1304
1305static void init_once(struct kmem_cache * cachep, void *foo) 1305static void init_once(void *foo)
1306{ 1306{
1307 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; 1307 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo;
1308 1308
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index 5e9564902976..a20683cf74dd 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -79,7 +79,7 @@ kmem_zone_init(int size, char *zone_name)
79 79
80static inline kmem_zone_t * 80static inline kmem_zone_t *
81kmem_zone_init_flags(int size, char *zone_name, unsigned long flags, 81kmem_zone_init_flags(int size, char *zone_name, unsigned long flags,
82 void (*construct)(kmem_zone_t *, void *)) 82 void (*construct)(void *))
83{ 83{
84 return kmem_cache_create(zone_name, size, 0, flags, construct); 84 return kmem_cache_create(zone_name, size, 0, flags, construct);
85} 85}
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 742b2c7852c1..943381284e2e 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -843,7 +843,6 @@ xfs_fs_destroy_inode(
843 843
844STATIC void 844STATIC void
845xfs_fs_inode_init_once( 845xfs_fs_inode_init_once(
846 kmem_zone_t *zonep,
847 void *vnode) 846 void *vnode)
848{ 847{
849 inode_init_once(vn_to_inode((bhv_vnode_t *)vnode)); 848 inode_init_once(vn_to_inode((bhv_vnode_t *)vnode));