aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/v9fs_vfs.h4
-rw-r--r--fs/9p/vfs_dentry.c4
-rw-r--r--fs/9p/vfs_super.c5
-rw-r--r--fs/adfs/adfs.h2
-rw-r--r--fs/adfs/dir.c2
-rw-r--r--fs/affs/affs.h3
-rw-r--r--fs/affs/amigaffs.c8
-rw-r--r--fs/affs/namei.c4
-rw-r--r--fs/afs/dir.c2
-rw-r--r--fs/anon_inodes.c2
-rw-r--r--fs/autofs/root.c2
-rw-r--r--fs/autofs4/inode.c2
-rw-r--r--fs/autofs4/root.c4
-rw-r--r--fs/block_dev.c146
-rw-r--r--fs/buffer.c145
-rw-r--r--fs/cifs/cifsfs.c3
-rw-r--r--fs/cifs/cifsfs.h4
-rw-r--r--fs/cifs/dir.c4
-rw-r--r--fs/coda/dir.c2
-rw-r--r--fs/compat.c28
-rw-r--r--fs/configfs/dir.c2
-rw-r--r--fs/dcache.c48
-rw-r--r--fs/devpts/inode.c188
-rw-r--r--fs/drop_caches.c2
-rw-r--r--fs/ecryptfs/dentry.c2
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h2
-rw-r--r--fs/fat/namei_msdos.c2
-rw-r--r--fs/fat/namei_vfat.c4
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/fuse/fuse_i.h2
-rw-r--r--fs/gfs2/ops_dentry.c2
-rw-r--r--fs/gfs2/super.h2
-rw-r--r--fs/hfs/hfs_fs.h2
-rw-r--r--fs/hfs/sysdep.c2
-rw-r--r--fs/hfsplus/hfsplus_fs.h2
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hostfs/hostfs_kern.c4
-rw-r--r--fs/hpfs/dentry.c2
-rw-r--r--fs/inode.c2
-rw-r--r--fs/isofs/inode.c2
-rw-r--r--fs/jfs/jfs_inode.h2
-rw-r--r--fs/jfs/namei.c4
-rw-r--r--fs/libfs.c5
-rw-r--r--fs/namei.c26
-rw-r--r--fs/namespace.c3
-rw-r--r--fs/ncpfs/dir.c4
-rw-r--r--fs/nfs/dir.c4
-rw-r--r--fs/nfs/nfs4_fs.h2
-rw-r--r--fs/notify/inotify/inotify.c16
-rw-r--r--fs/ocfs2/dcache.c2
-rw-r--r--fs/ocfs2/dcache.h2
-rw-r--r--fs/pipe.c7
-rw-r--r--fs/proc/base.c6
-rw-r--r--fs/proc/generic.c2
-rw-r--r--fs/proc/proc_sysctl.c4
-rw-r--r--fs/proc/root.c3
-rw-r--r--fs/quota/dquot.c10
-rw-r--r--fs/reiserfs/xattr.c2
-rw-r--r--fs/smbfs/dir.c4
-rw-r--r--fs/super.c9
-rw-r--r--fs/sysfs/dir.c2
-rw-r--r--fs/sysv/namei.c2
-rw-r--r--fs/sysv/sysv.h2
-rw-r--r--fs/ubifs/super.c3
-rw-r--r--fs/ufs/inode.c39
-rw-r--r--fs/ufs/namei.c2
-rw-r--r--fs/ufs/super.c11
-rw-r--r--fs/ufs/ufs.h2
68 files changed, 386 insertions, 446 deletions
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index c295ba786edd..f0c7de78e205 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -41,8 +41,8 @@ extern struct file_system_type v9fs_fs_type;
41extern const struct address_space_operations v9fs_addr_operations; 41extern const struct address_space_operations v9fs_addr_operations;
42extern const struct file_operations v9fs_file_operations; 42extern const struct file_operations v9fs_file_operations;
43extern const struct file_operations v9fs_dir_operations; 43extern const struct file_operations v9fs_dir_operations;
44extern struct dentry_operations v9fs_dentry_operations; 44extern const struct dentry_operations v9fs_dentry_operations;
45extern struct dentry_operations v9fs_cached_dentry_operations; 45extern const struct dentry_operations v9fs_cached_dentry_operations;
46 46
47struct inode *v9fs_get_inode(struct super_block *sb, int mode); 47struct inode *v9fs_get_inode(struct super_block *sb, int mode);
48ino_t v9fs_qid2ino(struct p9_qid *qid); 48ino_t v9fs_qid2ino(struct p9_qid *qid);
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index 06dcc7c4f234..d74325295b1e 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -104,12 +104,12 @@ void v9fs_dentry_release(struct dentry *dentry)
104 } 104 }
105} 105}
106 106
107struct dentry_operations v9fs_cached_dentry_operations = { 107const struct dentry_operations v9fs_cached_dentry_operations = {
108 .d_delete = v9fs_cached_dentry_delete, 108 .d_delete = v9fs_cached_dentry_delete,
109 .d_release = v9fs_dentry_release, 109 .d_release = v9fs_dentry_release,
110}; 110};
111 111
112struct dentry_operations v9fs_dentry_operations = { 112const struct dentry_operations v9fs_dentry_operations = {
113 .d_delete = v9fs_dentry_delete, 113 .d_delete = v9fs_dentry_delete,
114 .d_release = v9fs_dentry_release, 114 .d_release = v9fs_dentry_release,
115}; 115};
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 93212e40221a..5f8ab8adb5f5 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -168,8 +168,9 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
168 p9stat_free(st); 168 p9stat_free(st);
169 kfree(st); 169 kfree(st);
170 170
171P9_DPRINTK(P9_DEBUG_VFS, " return simple set mount\n"); 171P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n");
172 return simple_set_mnt(mnt, sb); 172 simple_set_mnt(mnt, sb);
173 return 0;
173 174
174release_sb: 175release_sb:
175 if (sb) { 176 if (sb) {
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
index 831157502d5a..e0a85dbeeb88 100644
--- a/fs/adfs/adfs.h
+++ b/fs/adfs/adfs.h
@@ -86,7 +86,7 @@ void __adfs_error(struct super_block *sb, const char *function,
86/* dir_*.c */ 86/* dir_*.c */
87extern const struct inode_operations adfs_dir_inode_operations; 87extern const struct inode_operations adfs_dir_inode_operations;
88extern const struct file_operations adfs_dir_operations; 88extern const struct file_operations adfs_dir_operations;
89extern struct dentry_operations adfs_dentry_operations; 89extern const struct dentry_operations adfs_dentry_operations;
90extern struct adfs_dir_ops adfs_f_dir_ops; 90extern struct adfs_dir_ops adfs_f_dir_ops;
91extern struct adfs_dir_ops adfs_fplus_dir_ops; 91extern struct adfs_dir_ops adfs_fplus_dir_ops;
92 92
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 85a30e929800..e867ccf37246 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -263,7 +263,7 @@ adfs_compare(struct dentry *parent, struct qstr *entry, struct qstr *name)
263 return 0; 263 return 0;
264} 264}
265 265
266struct dentry_operations adfs_dentry_operations = { 266const struct dentry_operations adfs_dentry_operations = {
267 .d_hash = adfs_hash, 267 .d_hash = adfs_hash,
268 .d_compare = adfs_compare, 268 .d_compare = adfs_compare,
269}; 269};
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index e9ec915f7553..1a2d5e3c7f4e 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -199,8 +199,7 @@ extern const struct address_space_operations affs_symlink_aops;
199extern const struct address_space_operations affs_aops; 199extern const struct address_space_operations affs_aops;
200extern const struct address_space_operations affs_aops_ofs; 200extern const struct address_space_operations affs_aops_ofs;
201 201
202extern struct dentry_operations affs_dentry_operations; 202extern const struct dentry_operations affs_dentry_operations;
203extern struct dentry_operations affs_dentry_operations_intl;
204 203
205static inline void 204static inline void
206affs_set_blocksize(struct super_block *sb, int size) 205affs_set_blocksize(struct super_block *sb, int size)
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 805573005de6..7d0f0a30f7a3 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -179,14 +179,18 @@ affs_remove_link(struct dentry *dentry)
179 affs_lock_dir(dir); 179 affs_lock_dir(dir);
180 affs_fix_dcache(dentry, link_ino); 180 affs_fix_dcache(dentry, link_ino);
181 retval = affs_remove_hash(dir, link_bh); 181 retval = affs_remove_hash(dir, link_bh);
182 if (retval) 182 if (retval) {
183 affs_unlock_dir(dir);
183 goto done; 184 goto done;
185 }
184 mark_buffer_dirty_inode(link_bh, inode); 186 mark_buffer_dirty_inode(link_bh, inode);
185 187
186 memcpy(AFFS_TAIL(sb, bh)->name, AFFS_TAIL(sb, link_bh)->name, 32); 188 memcpy(AFFS_TAIL(sb, bh)->name, AFFS_TAIL(sb, link_bh)->name, 32);
187 retval = affs_insert_hash(dir, bh); 189 retval = affs_insert_hash(dir, bh);
188 if (retval) 190 if (retval) {
191 affs_unlock_dir(dir);
189 goto done; 192 goto done;
193 }
190 mark_buffer_dirty_inode(bh, inode); 194 mark_buffer_dirty_inode(bh, inode);
191 195
192 affs_unlock_dir(dir); 196 affs_unlock_dir(dir);
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index cfcf1b6cf82b..960d336ec694 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -19,12 +19,12 @@ static int affs_intl_toupper(int ch);
19static int affs_intl_hash_dentry(struct dentry *, struct qstr *); 19static int affs_intl_hash_dentry(struct dentry *, struct qstr *);
20static int affs_intl_compare_dentry(struct dentry *, struct qstr *, struct qstr *); 20static int affs_intl_compare_dentry(struct dentry *, struct qstr *, struct qstr *);
21 21
22struct dentry_operations affs_dentry_operations = { 22const struct dentry_operations affs_dentry_operations = {
23 .d_hash = affs_hash_dentry, 23 .d_hash = affs_hash_dentry,
24 .d_compare = affs_compare_dentry, 24 .d_compare = affs_compare_dentry,
25}; 25};
26 26
27static struct dentry_operations affs_intl_dentry_operations = { 27static const struct dentry_operations affs_intl_dentry_operations = {
28 .d_hash = affs_intl_hash_dentry, 28 .d_hash = affs_intl_hash_dentry,
29 .d_compare = affs_intl_compare_dentry, 29 .d_compare = affs_intl_compare_dentry,
30}; 30};
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 99cf390641f7..9bd757774c9e 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -62,7 +62,7 @@ const struct inode_operations afs_dir_inode_operations = {
62 .setattr = afs_setattr, 62 .setattr = afs_setattr,
63}; 63};
64 64
65static struct dentry_operations afs_fs_dentry_operations = { 65static const struct dentry_operations afs_fs_dentry_operations = {
66 .d_revalidate = afs_d_revalidate, 66 .d_revalidate = afs_d_revalidate,
67 .d_delete = afs_d_delete, 67 .d_delete = afs_d_delete,
68 .d_release = afs_d_release, 68 .d_release = afs_d_release,
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 3bbdb9d02376..1dd96d4406c0 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -48,7 +48,7 @@ static struct file_system_type anon_inode_fs_type = {
48 .get_sb = anon_inodefs_get_sb, 48 .get_sb = anon_inodefs_get_sb,
49 .kill_sb = kill_anon_super, 49 .kill_sb = kill_anon_super,
50}; 50};
51static struct dentry_operations anon_inodefs_dentry_operations = { 51static const struct dentry_operations anon_inodefs_dentry_operations = {
52 .d_delete = anon_inodefs_delete_dentry, 52 .d_delete = anon_inodefs_delete_dentry,
53}; 53};
54 54
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 8aacade56956..4a1401cea0a1 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -192,7 +192,7 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
192 return 1; 192 return 1;
193} 193}
194 194
195static struct dentry_operations autofs_dentry_operations = { 195static const struct dentry_operations autofs_dentry_operations = {
196 .d_revalidate = autofs_revalidate, 196 .d_revalidate = autofs_revalidate,
197}; 197};
198 198
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 716e12b627b2..69c8142da838 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -310,7 +310,7 @@ static struct autofs_info *autofs4_mkroot(struct autofs_sb_info *sbi)
310 return ino; 310 return ino;
311} 311}
312 312
313static struct dentry_operations autofs4_sb_dentry_operations = { 313static const struct dentry_operations autofs4_sb_dentry_operations = {
314 .d_release = autofs4_dentry_release, 314 .d_release = autofs4_dentry_release,
315}; 315};
316 316
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 2a41c2a7fc52..74b1469a9504 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -349,13 +349,13 @@ void autofs4_dentry_release(struct dentry *de)
349} 349}
350 350
351/* For dentries of directories in the root dir */ 351/* For dentries of directories in the root dir */
352static struct dentry_operations autofs4_root_dentry_operations = { 352static const struct dentry_operations autofs4_root_dentry_operations = {
353 .d_revalidate = autofs4_revalidate, 353 .d_revalidate = autofs4_revalidate,
354 .d_release = autofs4_dentry_release, 354 .d_release = autofs4_dentry_release,
355}; 355};
356 356
357/* For other dentries */ 357/* For other dentries */
358static struct dentry_operations autofs4_dentry_operations = { 358static const struct dentry_operations autofs4_dentry_operations = {
359 .d_revalidate = autofs4_revalidate, 359 .d_revalidate = autofs4_revalidate,
360 .d_release = autofs4_dentry_release, 360 .d_release = autofs4_dentry_release,
361}; 361};
diff --git a/fs/block_dev.c b/fs/block_dev.c
index b3c1efff5e1d..8c3c6899ccf3 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/blkpg.h> 19#include <linux/blkpg.h>
20#include <linux/buffer_head.h> 20#include <linux/buffer_head.h>
21#include <linux/pagevec.h>
21#include <linux/writeback.h> 22#include <linux/writeback.h>
22#include <linux/mpage.h> 23#include <linux/mpage.h>
23#include <linux/mount.h> 24#include <linux/mount.h>
@@ -174,6 +175,151 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
174 iov, offset, nr_segs, blkdev_get_blocks, NULL); 175 iov, offset, nr_segs, blkdev_get_blocks, NULL);
175} 176}
176 177
178/*
179 * Write out and wait upon all the dirty data associated with a block
180 * device via its mapping. Does not take the superblock lock.
181 */
182int sync_blockdev(struct block_device *bdev)
183{
184 int ret = 0;
185
186 if (bdev)
187 ret = filemap_write_and_wait(bdev->bd_inode->i_mapping);
188 return ret;
189}
190EXPORT_SYMBOL(sync_blockdev);
191
192/*
193 * Write out and wait upon all dirty data associated with this
194 * device. Filesystem data as well as the underlying block
195 * device. Takes the superblock lock.
196 */
197int fsync_bdev(struct block_device *bdev)
198{
199 struct super_block *sb = get_super(bdev);
200 if (sb) {
201 int res = fsync_super(sb);
202 drop_super(sb);
203 return res;
204 }
205 return sync_blockdev(bdev);
206}
207
208/**
209 * freeze_bdev -- lock a filesystem and force it into a consistent state
210 * @bdev: blockdevice to lock
211 *
212 * This takes the block device bd_mount_sem to make sure no new mounts
213 * happen on bdev until thaw_bdev() is called.
214 * If a superblock is found on this device, we take the s_umount semaphore
215 * on it to make sure nobody unmounts until the snapshot creation is done.
216 * The reference counter (bd_fsfreeze_count) guarantees that only the last
217 * unfreeze process can unfreeze the frozen filesystem actually when multiple
218 * freeze requests arrive simultaneously. It counts up in freeze_bdev() and
219 * count down in thaw_bdev(). When it becomes 0, thaw_bdev() will unfreeze
220 * actually.
221 */
222struct super_block *freeze_bdev(struct block_device *bdev)
223{
224 struct super_block *sb;
225 int error = 0;
226
227 mutex_lock(&bdev->bd_fsfreeze_mutex);
228 if (bdev->bd_fsfreeze_count > 0) {
229 bdev->bd_fsfreeze_count++;
230 sb = get_super(bdev);
231 mutex_unlock(&bdev->bd_fsfreeze_mutex);
232 return sb;
233 }
234 bdev->bd_fsfreeze_count++;
235
236 down(&bdev->bd_mount_sem);
237 sb = get_super(bdev);
238 if (sb && !(sb->s_flags & MS_RDONLY)) {
239 sb->s_frozen = SB_FREEZE_WRITE;
240 smp_wmb();
241
242 __fsync_super(sb);
243
244 sb->s_frozen = SB_FREEZE_TRANS;
245 smp_wmb();
246
247 sync_blockdev(sb->s_bdev);
248
249 if (sb->s_op->freeze_fs) {
250 error = sb->s_op->freeze_fs(sb);
251 if (error) {
252 printk(KERN_ERR
253 "VFS:Filesystem freeze failed\n");
254 sb->s_frozen = SB_UNFROZEN;
255 drop_super(sb);
256 up(&bdev->bd_mount_sem);
257 bdev->bd_fsfreeze_count--;
258 mutex_unlock(&bdev->bd_fsfreeze_mutex);
259 return ERR_PTR(error);
260 }
261 }
262 }
263
264 sync_blockdev(bdev);
265 mutex_unlock(&bdev->bd_fsfreeze_mutex);
266
267 return sb; /* thaw_bdev releases s->s_umount and bd_mount_sem */
268}
269EXPORT_SYMBOL(freeze_bdev);
270
271/**
272 * thaw_bdev -- unlock filesystem
273 * @bdev: blockdevice to unlock
274 * @sb: associated superblock
275 *
276 * Unlocks the filesystem and marks it writeable again after freeze_bdev().
277 */
278int thaw_bdev(struct block_device *bdev, struct super_block *sb)
279{
280 int error = 0;
281
282 mutex_lock(&bdev->bd_fsfreeze_mutex);
283 if (!bdev->bd_fsfreeze_count) {
284 mutex_unlock(&bdev->bd_fsfreeze_mutex);
285 return -EINVAL;
286 }
287
288 bdev->bd_fsfreeze_count--;
289 if (bdev->bd_fsfreeze_count > 0) {
290 if (sb)
291 drop_super(sb);
292 mutex_unlock(&bdev->bd_fsfreeze_mutex);
293 return 0;
294 }
295
296 if (sb) {
297 BUG_ON(sb->s_bdev != bdev);
298 if (!(sb->s_flags & MS_RDONLY)) {
299 if (sb->s_op->unfreeze_fs) {
300 error = sb->s_op->unfreeze_fs(sb);
301 if (error) {
302 printk(KERN_ERR
303 "VFS:Filesystem thaw failed\n");
304 sb->s_frozen = SB_FREEZE_TRANS;
305 bdev->bd_fsfreeze_count++;
306 mutex_unlock(&bdev->bd_fsfreeze_mutex);
307 return error;
308 }
309 }
310 sb->s_frozen = SB_UNFROZEN;
311 smp_wmb();
312 wake_up(&sb->s_wait_unfrozen);
313 }
314 drop_super(sb);
315 }
316
317 up(&bdev->bd_mount_sem);
318 mutex_unlock(&bdev->bd_fsfreeze_mutex);
319 return 0;
320}
321EXPORT_SYMBOL(thaw_bdev);
322
177static int blkdev_writepage(struct page *page, struct writeback_control *wbc) 323static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
178{ 324{
179 return block_write_full_page(page, blkdev_get_block, wbc); 325 return block_write_full_page(page, blkdev_get_block, wbc);
diff --git a/fs/buffer.c b/fs/buffer.c
index 891e1c78e4f1..a2fd743d97cb 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -166,151 +166,6 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate)
166} 166}
167 167
168/* 168/*
169 * Write out and wait upon all the dirty data associated with a block
170 * device via its mapping. Does not take the superblock lock.
171 */
172int sync_blockdev(struct block_device *bdev)
173{
174 int ret = 0;
175
176 if (bdev)
177 ret = filemap_write_and_wait(bdev->bd_inode->i_mapping);
178 return ret;
179}
180EXPORT_SYMBOL(sync_blockdev);
181
182/*
183 * Write out and wait upon all dirty data associated with this
184 * device. Filesystem data as well as the underlying block
185 * device. Takes the superblock lock.
186 */
187int fsync_bdev(struct block_device *bdev)
188{
189 struct super_block *sb = get_super(bdev);
190 if (sb) {
191 int res = fsync_super(sb);
192 drop_super(sb);
193 return res;
194 }
195 return sync_blockdev(bdev);
196}
197
198/**
199 * freeze_bdev -- lock a filesystem and force it into a consistent state
200 * @bdev: blockdevice to lock
201 *
202 * This takes the block device bd_mount_sem to make sure no new mounts
203 * happen on bdev until thaw_bdev() is called.
204 * If a superblock is found on this device, we take the s_umount semaphore
205 * on it to make sure nobody unmounts until the snapshot creation is done.
206 * The reference counter (bd_fsfreeze_count) guarantees that only the last
207 * unfreeze process can unfreeze the frozen filesystem actually when multiple
208 * freeze requests arrive simultaneously. It counts up in freeze_bdev() and
209 * count down in thaw_bdev(). When it becomes 0, thaw_bdev() will unfreeze
210 * actually.
211 */
212struct super_block *freeze_bdev(struct block_device *bdev)
213{
214 struct super_block *sb;
215 int error = 0;
216
217 mutex_lock(&bdev->bd_fsfreeze_mutex);
218 if (bdev->bd_fsfreeze_count > 0) {
219 bdev->bd_fsfreeze_count++;
220 sb = get_super(bdev);
221 mutex_unlock(&bdev->bd_fsfreeze_mutex);
222 return sb;
223 }
224 bdev->bd_fsfreeze_count++;
225
226 down(&bdev->bd_mount_sem);
227 sb = get_super(bdev);
228 if (sb && !(sb->s_flags & MS_RDONLY)) {
229 sb->s_frozen = SB_FREEZE_WRITE;
230 smp_wmb();
231
232 __fsync_super(sb);
233
234 sb->s_frozen = SB_FREEZE_TRANS;
235 smp_wmb();
236
237 sync_blockdev(sb->s_bdev);
238
239 if (sb->s_op->freeze_fs) {
240 error = sb->s_op->freeze_fs(sb);
241 if (error) {
242 printk(KERN_ERR
243 "VFS:Filesystem freeze failed\n");
244 sb->s_frozen = SB_UNFROZEN;
245 drop_super(sb);
246 up(&bdev->bd_mount_sem);
247 bdev->bd_fsfreeze_count--;
248 mutex_unlock(&bdev->bd_fsfreeze_mutex);
249 return ERR_PTR(error);
250 }
251 }
252 }
253
254 sync_blockdev(bdev);
255 mutex_unlock(&bdev->bd_fsfreeze_mutex);
256
257 return sb; /* thaw_bdev releases s->s_umount and bd_mount_sem */
258}
259EXPORT_SYMBOL(freeze_bdev);
260
261/**
262 * thaw_bdev -- unlock filesystem
263 * @bdev: blockdevice to unlock
264 * @sb: associated superblock
265 *
266 * Unlocks the filesystem and marks it writeable again after freeze_bdev().
267 */
268int thaw_bdev(struct block_device *bdev, struct super_block *sb)
269{
270 int error = 0;
271
272 mutex_lock(&bdev->bd_fsfreeze_mutex);
273 if (!bdev->bd_fsfreeze_count) {
274 mutex_unlock(&bdev->bd_fsfreeze_mutex);
275 return -EINVAL;
276 }
277
278 bdev->bd_fsfreeze_count--;
279 if (bdev->bd_fsfreeze_count > 0) {
280 if (sb)
281 drop_super(sb);
282 mutex_unlock(&bdev->bd_fsfreeze_mutex);
283 return 0;
284 }
285
286 if (sb) {
287 BUG_ON(sb->s_bdev != bdev);
288 if (!(sb->s_flags & MS_RDONLY)) {
289 if (sb->s_op->unfreeze_fs) {
290 error = sb->s_op->unfreeze_fs(sb);
291 if (error) {
292 printk(KERN_ERR
293 "VFS:Filesystem thaw failed\n");
294 sb->s_frozen = SB_FREEZE_TRANS;
295 bdev->bd_fsfreeze_count++;
296 mutex_unlock(&bdev->bd_fsfreeze_mutex);
297 return error;
298 }
299 }
300 sb->s_frozen = SB_UNFROZEN;
301 smp_wmb();
302 wake_up(&sb->s_wait_unfrozen);
303 }
304 drop_super(sb);
305 }
306
307 up(&bdev->bd_mount_sem);
308 mutex_unlock(&bdev->bd_fsfreeze_mutex);
309 return 0;
310}
311EXPORT_SYMBOL(thaw_bdev);
312
313/*
314 * Various filesystems appear to want __find_get_block to be non-blocking. 169 * Various filesystems appear to want __find_get_block to be non-blocking.
315 * But it's the page lock which protects the buffers. To get around this, 170 * But it's the page lock which protects the buffers. To get around this,
316 * we get exclusion from try_to_free_buffers with the blockdev mapping's 171 * we get exclusion from try_to_free_buffers with the blockdev mapping's
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 13ea53251dcf..38491fd3871d 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -606,7 +606,8 @@ cifs_get_sb(struct file_system_type *fs_type,
606 return rc; 606 return rc;
607 } 607 }
608 sb->s_flags |= MS_ACTIVE; 608 sb->s_flags |= MS_ACTIVE;
609 return simple_set_mnt(mnt, sb); 609 simple_set_mnt(mnt, sb);
610 return 0;
610} 611}
611 612
612static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, 613static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 2b1d28a9ee28..77e190dc2883 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -78,8 +78,8 @@ extern int cifs_dir_open(struct inode *inode, struct file *file);
78extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir); 78extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir);
79 79
80/* Functions related to dir entries */ 80/* Functions related to dir entries */
81extern struct dentry_operations cifs_dentry_ops; 81extern const struct dentry_operations cifs_dentry_ops;
82extern struct dentry_operations cifs_ci_dentry_ops; 82extern const struct dentry_operations cifs_ci_dentry_ops;
83 83
84/* Functions related to symlinks */ 84/* Functions related to symlinks */
85extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd); 85extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd);
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index f9b6f68be976..2f35cccfcd8d 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -701,7 +701,7 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
701 return rc; 701 return rc;
702} */ 702} */
703 703
704struct dentry_operations cifs_dentry_ops = { 704const struct dentry_operations cifs_dentry_ops = {
705 .d_revalidate = cifs_d_revalidate, 705 .d_revalidate = cifs_d_revalidate,
706/* d_delete: cifs_d_delete, */ /* not needed except for debugging */ 706/* d_delete: cifs_d_delete, */ /* not needed except for debugging */
707}; 707};
@@ -739,7 +739,7 @@ static int cifs_ci_compare(struct dentry *dentry, struct qstr *a,
739 return 1; 739 return 1;
740} 740}
741 741
742struct dentry_operations cifs_ci_dentry_ops = { 742const struct dentry_operations cifs_ci_dentry_ops = {
743 .d_revalidate = cifs_d_revalidate, 743 .d_revalidate = cifs_d_revalidate,
744 .d_hash = cifs_ci_hash, 744 .d_hash = cifs_ci_hash,
745 .d_compare = cifs_ci_compare, 745 .d_compare = cifs_ci_compare,
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 75b1fa90b2cb..4bb9d0a5decc 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -59,7 +59,7 @@ static int coda_return_EIO(void)
59} 59}
60#define CODA_EIO_ERROR ((void *) (coda_return_EIO)) 60#define CODA_EIO_ERROR ((void *) (coda_return_EIO))
61 61
62static struct dentry_operations coda_dentry_operations = 62static const struct dentry_operations coda_dentry_operations =
63{ 63{
64 .d_revalidate = coda_dentry_revalidate, 64 .d_revalidate = coda_dentry_revalidate,
65 .d_delete = coda_dentry_delete, 65 .d_delete = coda_dentry_delete,
diff --git a/fs/compat.c b/fs/compat.c
index 0949b43794a4..5e374aad33f7 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -378,6 +378,34 @@ out:
378 return error; 378 return error;
379} 379}
380 380
381/*
382 * This is a copy of sys_ustat, just dealing with a structure layout.
383 * Given how simple this syscall is that apporach is more maintainable
384 * than the various conversion hacks.
385 */
386asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u)
387{
388 struct super_block *sb;
389 struct compat_ustat tmp;
390 struct kstatfs sbuf;
391 int err;
392
393 sb = user_get_super(new_decode_dev(dev));
394 if (!sb)
395 return -EINVAL;
396 err = vfs_statfs(sb->s_root, &sbuf);
397 drop_super(sb);
398 if (err)
399 return err;
400
401 memset(&tmp, 0, sizeof(struct compat_ustat));
402 tmp.f_tfree = sbuf.f_bfree;
403 tmp.f_tinode = sbuf.f_ffree;
404 if (copy_to_user(u, &tmp, sizeof(struct compat_ustat)))
405 return -EFAULT;
406 return 0;
407}
408
381static int get_compat_flock(struct flock *kfl, struct compat_flock __user *ufl) 409static int get_compat_flock(struct flock *kfl, struct compat_flock __user *ufl)
382{ 410{
383 if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) || 411 if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 8e93341f3e82..05373db21a4e 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -72,7 +72,7 @@ static int configfs_d_delete(struct dentry *dentry)
72 return 1; 72 return 1;
73} 73}
74 74
75static struct dentry_operations configfs_dentry_ops = { 75static const struct dentry_operations configfs_dentry_ops = {
76 .d_iput = configfs_d_iput, 76 .d_iput = configfs_d_iput,
77 /* simple_delete_dentry() isn't exported */ 77 /* simple_delete_dentry() isn't exported */
78 .d_delete = configfs_d_delete, 78 .d_delete = configfs_d_delete,
diff --git a/fs/dcache.c b/fs/dcache.c
index 07e2d4a44bda..90bbd7e1b116 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1247,15 +1247,18 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
1247 struct dentry *found; 1247 struct dentry *found;
1248 struct dentry *new; 1248 struct dentry *new;
1249 1249
1250 /* Does a dentry matching the name exist already? */ 1250 /*
1251 * First check if a dentry matching the name already exists,
1252 * if not go ahead and create it now.
1253 */
1251 found = d_hash_and_lookup(dentry->d_parent, name); 1254 found = d_hash_and_lookup(dentry->d_parent, name);
1252 /* If not, create it now and return */
1253 if (!found) { 1255 if (!found) {
1254 new = d_alloc(dentry->d_parent, name); 1256 new = d_alloc(dentry->d_parent, name);
1255 if (!new) { 1257 if (!new) {
1256 error = -ENOMEM; 1258 error = -ENOMEM;
1257 goto err_out; 1259 goto err_out;
1258 } 1260 }
1261
1259 found = d_splice_alias(inode, new); 1262 found = d_splice_alias(inode, new);
1260 if (found) { 1263 if (found) {
1261 dput(new); 1264 dput(new);
@@ -1263,61 +1266,46 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
1263 } 1266 }
1264 return new; 1267 return new;
1265 } 1268 }
1266 /* Matching dentry exists, check if it is negative. */ 1269
1270 /*
1271 * If a matching dentry exists, and it's not negative use it.
1272 *
1273 * Decrement the reference count to balance the iget() done
1274 * earlier on.
1275 */
1267 if (found->d_inode) { 1276 if (found->d_inode) {
1268 if (unlikely(found->d_inode != inode)) { 1277 if (unlikely(found->d_inode != inode)) {
1269 /* This can't happen because bad inodes are unhashed. */ 1278 /* This can't happen because bad inodes are unhashed. */
1270 BUG_ON(!is_bad_inode(inode)); 1279 BUG_ON(!is_bad_inode(inode));
1271 BUG_ON(!is_bad_inode(found->d_inode)); 1280 BUG_ON(!is_bad_inode(found->d_inode));
1272 } 1281 }
1273 /*
1274 * Already have the inode and the dentry attached, decrement
1275 * the reference count to balance the iget() done
1276 * earlier on. We found the dentry using d_lookup() so it
1277 * cannot be disconnected and thus we do not need to worry
1278 * about any NFS/disconnectedness issues here.
1279 */
1280 iput(inode); 1282 iput(inode);
1281 return found; 1283 return found;
1282 } 1284 }
1285
1283 /* 1286 /*
1284 * Negative dentry: instantiate it unless the inode is a directory and 1287 * Negative dentry: instantiate it unless the inode is a directory and
1285 * has a 'disconnected' dentry (i.e. IS_ROOT and DCACHE_DISCONNECTED), 1288 * already has a dentry.
1286 * in which case d_move() that in place of the found dentry.
1287 */ 1289 */
1288 if (!S_ISDIR(inode->i_mode)) {
1289 /* Not a directory; everything is easy. */
1290 d_instantiate(found, inode);
1291 return found;
1292 }
1293 spin_lock(&dcache_lock); 1290 spin_lock(&dcache_lock);
1294 if (list_empty(&inode->i_dentry)) { 1291 if (!S_ISDIR(inode->i_mode) || list_empty(&inode->i_dentry)) {
1295 /*
1296 * Directory without a 'disconnected' dentry; we need to do
1297 * d_instantiate() by hand because it takes dcache_lock which
1298 * we already hold.
1299 */
1300 __d_instantiate(found, inode); 1292 __d_instantiate(found, inode);
1301 spin_unlock(&dcache_lock); 1293 spin_unlock(&dcache_lock);
1302 security_d_instantiate(found, inode); 1294 security_d_instantiate(found, inode);
1303 return found; 1295 return found;
1304 } 1296 }
1297
1305 /* 1298 /*
1306 * Directory with a 'disconnected' dentry; get a reference to the 1299 * In case a directory already has a (disconnected) entry grab a
1307 * 'disconnected' dentry. 1300 * reference to it, move it in place and use it.
1308 */ 1301 */
1309 new = list_entry(inode->i_dentry.next, struct dentry, d_alias); 1302 new = list_entry(inode->i_dentry.next, struct dentry, d_alias);
1310 dget_locked(new); 1303 dget_locked(new);
1311 spin_unlock(&dcache_lock); 1304 spin_unlock(&dcache_lock);
1312 /* Do security vodoo. */
1313 security_d_instantiate(found, inode); 1305 security_d_instantiate(found, inode);
1314 /* Move new in place of found. */
1315 d_move(new, found); 1306 d_move(new, found);
1316 /* Balance the iget() we did above. */
1317 iput(inode); 1307 iput(inode);
1318 /* Throw away found. */
1319 dput(found); 1308 dput(found);
1320 /* Use new as the actual dentry. */
1321 return new; 1309 return new;
1322 1310
1323err_out: 1311err_out:
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index bff4052b05e7..63a4a59e4148 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -322,177 +322,81 @@ static int compare_init_pts_sb(struct super_block *s, void *p)
322} 322}
323 323
324/* 324/*
325 * Safely parse the mount options in @data and update @opts. 325 * devpts_get_sb()
326 * 326 *
327 * devpts ends up parsing options two times during mount, due to the 327 * If the '-o newinstance' mount option was specified, mount a new
328 * two modes of operation it supports. The first parse occurs in 328 * (private) instance of devpts. PTYs created in this instance are
329 * devpts_get_sb() when determining the mode (single-instance or 329 * independent of the PTYs in other devpts instances.
330 * multi-instance mode). The second parse happens in devpts_remount()
331 * or new_pts_mount() depending on the mode.
332 * 330 *
333 * Parsing of options modifies the @data making subsequent parsing 331 * If the '-o newinstance' option was not specified, mount/remount the
334 * incorrect. So make a local copy of @data and parse it. 332 * initial kernel mount of devpts. This type of mount gives the
333 * legacy, single-instance semantics.
335 * 334 *
336 * Return: 0 On success, -errno on error 335 * The 'newinstance' option is needed to support multiple namespace
337 */ 336 * semantics in devpts while preserving backward compatibility of the
338static int safe_parse_mount_options(void *data, struct pts_mount_opts *opts) 337 * current 'single-namespace' semantics. i.e all mounts of devpts
339{ 338 * without the 'newinstance' mount option should bind to the initial
340 int rc; 339 * kernel mount, like get_sb_single().
341 void *datacp;
342
343 if (!data)
344 return 0;
345
346 /* Use kstrdup() ? */
347 datacp = kmalloc(PAGE_SIZE, GFP_KERNEL);
348 if (!datacp)
349 return -ENOMEM;
350
351 memcpy(datacp, data, PAGE_SIZE);
352 rc = parse_mount_options((char *)datacp, PARSE_MOUNT, opts);
353 kfree(datacp);
354
355 return rc;
356}
357
358/*
359 * Mount a new (private) instance of devpts. PTYs created in this
360 * instance are independent of the PTYs in other devpts instances.
361 */
362static int new_pts_mount(struct file_system_type *fs_type, int flags,
363 void *data, struct vfsmount *mnt)
364{
365 int err;
366 struct pts_fs_info *fsi;
367 struct pts_mount_opts *opts;
368
369 err = get_sb_nodev(fs_type, flags, data, devpts_fill_super, mnt);
370 if (err)
371 return err;
372
373 fsi = DEVPTS_SB(mnt->mnt_sb);
374 opts = &fsi->mount_opts;
375
376 err = parse_mount_options(data, PARSE_MOUNT, opts);
377 if (err)
378 goto fail;
379
380 err = mknod_ptmx(mnt->mnt_sb);
381 if (err)
382 goto fail;
383
384 return 0;
385
386fail:
387 dput(mnt->mnt_sb->s_root);
388 deactivate_super(mnt->mnt_sb);
389 return err;
390}
391
392/*
393 * Check if 'newinstance' mount option was specified in @data.
394 * 340 *
395 * Return: -errno on error (eg: invalid mount options specified) 341 * Mounts with 'newinstance' option create a new, private namespace.
396 * : 1 if 'newinstance' mount option was specified
397 * : 0 if 'newinstance' mount option was NOT specified
398 */
399static int is_new_instance_mount(void *data)
400{
401 int rc;
402 struct pts_mount_opts opts;
403
404 if (!data)
405 return 0;
406
407 rc = safe_parse_mount_options(data, &opts);
408 if (!rc)
409 rc = opts.newinstance;
410
411 return rc;
412}
413
414/*
415 * get_init_pts_sb()
416 *
417 * This interface is needed to support multiple namespace semantics in
418 * devpts while preserving backward compatibility of the current 'single-
419 * namespace' semantics. i.e all mounts of devpts without the 'newinstance'
420 * mount option should bind to the initial kernel mount, like
421 * get_sb_single().
422 * 342 *
423 * Mounts with 'newinstance' option create a new private namespace. 343 * NOTE:
424 * 344 *
425 * But for single-mount semantics, devpts cannot use get_sb_single(), 345 * For single-mount semantics, devpts cannot use get_sb_single(),
426 * because get_sb_single()/sget() find and use the super-block from 346 * because get_sb_single()/sget() find and use the super-block from
427 * the most recent mount of devpts. But that recent mount may be a 347 * the most recent mount of devpts. But that recent mount may be a
428 * 'newinstance' mount and get_sb_single() would pick the newinstance 348 * 'newinstance' mount and get_sb_single() would pick the newinstance
429 * super-block instead of the initial super-block. 349 * super-block instead of the initial super-block.
430 *
431 * This interface is identical to get_sb_single() except that it
432 * consistently selects the 'single-namespace' superblock even in the
433 * presence of the private namespace (i.e 'newinstance') super-blocks.
434 */ 350 */
435static int get_init_pts_sb(struct file_system_type *fs_type, int flags, 351static int devpts_get_sb(struct file_system_type *fs_type,
436 void *data, struct vfsmount *mnt) 352 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
437{ 353{
438 struct super_block *s;
439 int error; 354 int error;
355 struct pts_mount_opts opts;
356 struct super_block *s;
357
358 memset(&opts, 0, sizeof(opts));
359 if (data) {
360 error = parse_mount_options(data, PARSE_MOUNT, &opts);
361 if (error)
362 return error;
363 }
364
365 if (opts.newinstance)
366 s = sget(fs_type, NULL, set_anon_super, NULL);
367 else
368 s = sget(fs_type, compare_init_pts_sb, set_anon_super, NULL);
440 369
441 s = sget(fs_type, compare_init_pts_sb, set_anon_super, NULL);
442 if (IS_ERR(s)) 370 if (IS_ERR(s))
443 return PTR_ERR(s); 371 return PTR_ERR(s);
444 372
445 if (!s->s_root) { 373 if (!s->s_root) {
446 s->s_flags = flags; 374 s->s_flags = flags;
447 error = devpts_fill_super(s, data, flags & MS_SILENT ? 1 : 0); 375 error = devpts_fill_super(s, data, flags & MS_SILENT ? 1 : 0);
448 if (error) { 376 if (error)
449 up_write(&s->s_umount); 377 goto out_undo_sget;
450 deactivate_super(s);
451 return error;
452 }
453 s->s_flags |= MS_ACTIVE; 378 s->s_flags |= MS_ACTIVE;
454 } 379 }
455 do_remount_sb(s, flags, data, 0);
456 return simple_set_mnt(mnt, s);
457}
458 380
459/* 381 simple_set_mnt(mnt, s);
460 * Mount or remount the initial kernel mount of devpts. This type of
461 * mount maintains the legacy, single-instance semantics, while the
462 * kernel still allows multiple-instances.
463 */
464static int init_pts_mount(struct file_system_type *fs_type, int flags,
465 void *data, struct vfsmount *mnt)
466{
467 int err;
468 382
469 err = get_init_pts_sb(fs_type, flags, data, mnt); 383 memcpy(&(DEVPTS_SB(s))->mount_opts, &opts, sizeof(opts));
470 if (err)
471 return err;
472 384
473 err = mknod_ptmx(mnt->mnt_sb); 385 error = mknod_ptmx(s);
474 if (err) { 386 if (error)
475 dput(mnt->mnt_sb->s_root); 387 goto out_dput;
476 deactivate_super(mnt->mnt_sb);
477 }
478 388
479 return err; 389 return 0;
480}
481
482static int devpts_get_sb(struct file_system_type *fs_type,
483 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
484{
485 int new;
486
487 new = is_new_instance_mount(data);
488 if (new < 0)
489 return new;
490 390
491 if (new) 391out_dput:
492 return new_pts_mount(fs_type, flags, data, mnt); 392 dput(s->s_root);
493 393
494 return init_pts_mount(fs_type, flags, data, mnt); 394out_undo_sget:
395 up_write(&s->s_umount);
396 deactivate_super(s);
397 return error;
495} 398}
399
496#else 400#else
497/* 401/*
498 * This supports only the legacy single-instance semantics (no 402 * This supports only the legacy single-instance semantics (no
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index 3e5637fc3779..44d725f612cf 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -18,7 +18,7 @@ static void drop_pagecache_sb(struct super_block *sb)
18 18
19 spin_lock(&inode_lock); 19 spin_lock(&inode_lock);
20 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { 20 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
21 if (inode->i_state & (I_FREEING|I_WILL_FREE)) 21 if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW))
22 continue; 22 continue;
23 if (inode->i_mapping->nrpages == 0) 23 if (inode->i_mapping->nrpages == 0)
24 continue; 24 continue;
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c
index 5e596583946c..2dda5ade75bc 100644
--- a/fs/ecryptfs/dentry.c
+++ b/fs/ecryptfs/dentry.c
@@ -89,7 +89,7 @@ static void ecryptfs_d_release(struct dentry *dentry)
89 return; 89 return;
90} 90}
91 91
92struct dentry_operations ecryptfs_dops = { 92const struct dentry_operations ecryptfs_dops = {
93 .d_revalidate = ecryptfs_d_revalidate, 93 .d_revalidate = ecryptfs_d_revalidate,
94 .d_release = ecryptfs_d_release, 94 .d_release = ecryptfs_d_release,
95}; 95};
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index ac749d4d644f..064c5820e4e5 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -580,7 +580,7 @@ extern const struct inode_operations ecryptfs_main_iops;
580extern const struct inode_operations ecryptfs_dir_iops; 580extern const struct inode_operations ecryptfs_dir_iops;
581extern const struct inode_operations ecryptfs_symlink_iops; 581extern const struct inode_operations ecryptfs_symlink_iops;
582extern const struct super_operations ecryptfs_sops; 582extern const struct super_operations ecryptfs_sops;
583extern struct dentry_operations ecryptfs_dops; 583extern const struct dentry_operations ecryptfs_dops;
584extern struct address_space_operations ecryptfs_aops; 584extern struct address_space_operations ecryptfs_aops;
585extern int ecryptfs_verbosity; 585extern int ecryptfs_verbosity;
586extern unsigned int ecryptfs_message_buf_len; 586extern unsigned int ecryptfs_message_buf_len;
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 7ba03a4acbe0..da3f361a37dd 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -188,7 +188,7 @@ old_compare:
188 goto out; 188 goto out;
189} 189}
190 190
191static struct dentry_operations msdos_dentry_operations = { 191static const struct dentry_operations msdos_dentry_operations = {
192 .d_hash = msdos_hash, 192 .d_hash = msdos_hash,
193 .d_compare = msdos_cmp, 193 .d_compare = msdos_cmp,
194}; 194};
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 8ae32e37673c..a0e00e3a46e9 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -166,13 +166,13 @@ static int vfat_cmp(struct dentry *dentry, struct qstr *a, struct qstr *b)
166 return 1; 166 return 1;
167} 167}
168 168
169static struct dentry_operations vfat_ci_dentry_ops = { 169static const struct dentry_operations vfat_ci_dentry_ops = {
170 .d_revalidate = vfat_revalidate_ci, 170 .d_revalidate = vfat_revalidate_ci,
171 .d_hash = vfat_hashi, 171 .d_hash = vfat_hashi,
172 .d_compare = vfat_cmpi, 172 .d_compare = vfat_cmpi,
173}; 173};
174 174
175static struct dentry_operations vfat_dentry_ops = { 175static const struct dentry_operations vfat_dentry_ops = {
176 .d_revalidate = vfat_revalidate, 176 .d_revalidate = vfat_revalidate,
177 .d_hash = vfat_hash, 177 .d_hash = vfat_hash,
178 .d_compare = vfat_cmp, 178 .d_compare = vfat_cmp,
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index fdff346e96fd..06da05261e04 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -224,7 +224,7 @@ static int invalid_nodeid(u64 nodeid)
224 return !nodeid || nodeid == FUSE_ROOT_ID; 224 return !nodeid || nodeid == FUSE_ROOT_ID;
225} 225}
226 226
227struct dentry_operations fuse_dentry_operations = { 227const struct dentry_operations fuse_dentry_operations = {
228 .d_revalidate = fuse_dentry_revalidate, 228 .d_revalidate = fuse_dentry_revalidate,
229}; 229};
230 230
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 5e64b815a5a1..6fc5aedaa0d5 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -493,7 +493,7 @@ static inline u64 get_node_id(struct inode *inode)
493/** Device operations */ 493/** Device operations */
494extern const struct file_operations fuse_dev_operations; 494extern const struct file_operations fuse_dev_operations;
495 495
496extern struct dentry_operations fuse_dentry_operations; 496extern const struct dentry_operations fuse_dentry_operations;
497 497
498/** 498/**
499 * Get a filled in inode 499 * Get a filled in inode
diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c
index 5eb57b044382..022c66cd5606 100644
--- a/fs/gfs2/ops_dentry.c
+++ b/fs/gfs2/ops_dentry.c
@@ -107,7 +107,7 @@ static int gfs2_dhash(struct dentry *dentry, struct qstr *str)
107 return 0; 107 return 0;
108} 108}
109 109
110struct dentry_operations gfs2_dops = { 110const struct dentry_operations gfs2_dops = {
111 .d_revalidate = gfs2_drevalidate, 111 .d_revalidate = gfs2_drevalidate,
112 .d_hash = gfs2_dhash, 112 .d_hash = gfs2_dhash,
113}; 113};
diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h
index 91abdbedcc86..b56413e3e40d 100644
--- a/fs/gfs2/super.h
+++ b/fs/gfs2/super.h
@@ -49,7 +49,7 @@ extern struct file_system_type gfs2_fs_type;
49extern struct file_system_type gfs2meta_fs_type; 49extern struct file_system_type gfs2meta_fs_type;
50extern const struct export_operations gfs2_export_ops; 50extern const struct export_operations gfs2_export_ops;
51extern const struct super_operations gfs2_super_ops; 51extern const struct super_operations gfs2_super_ops;
52extern struct dentry_operations gfs2_dops; 52extern const struct dentry_operations gfs2_dops;
53 53
54#endif /* __SUPER_DOT_H__ */ 54#endif /* __SUPER_DOT_H__ */
55 55
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 9955232fdf8c..052387e11671 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -213,7 +213,7 @@ extern void hfs_mdb_put(struct super_block *);
213extern int hfs_part_find(struct super_block *, sector_t *, sector_t *); 213extern int hfs_part_find(struct super_block *, sector_t *, sector_t *);
214 214
215/* string.c */ 215/* string.c */
216extern struct dentry_operations hfs_dentry_operations; 216extern const struct dentry_operations hfs_dentry_operations;
217 217
218extern int hfs_hash_dentry(struct dentry *, struct qstr *); 218extern int hfs_hash_dentry(struct dentry *, struct qstr *);
219extern int hfs_strcmp(const unsigned char *, unsigned int, 219extern int hfs_strcmp(const unsigned char *, unsigned int,
diff --git a/fs/hfs/sysdep.c b/fs/hfs/sysdep.c
index 5bf89ec01cd4..7478f5c219aa 100644
--- a/fs/hfs/sysdep.c
+++ b/fs/hfs/sysdep.c
@@ -31,7 +31,7 @@ static int hfs_revalidate_dentry(struct dentry *dentry, struct nameidata *nd)
31 return 1; 31 return 1;
32} 32}
33 33
34struct dentry_operations hfs_dentry_operations = 34const struct dentry_operations hfs_dentry_operations =
35{ 35{
36 .d_revalidate = hfs_revalidate_dentry, 36 .d_revalidate = hfs_revalidate_dentry,
37 .d_hash = hfs_hash_dentry, 37 .d_hash = hfs_hash_dentry,
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index f027a905225f..5c10d803d9df 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -327,7 +327,7 @@ void hfsplus_file_truncate(struct inode *);
327/* inode.c */ 327/* inode.c */
328extern const struct address_space_operations hfsplus_aops; 328extern const struct address_space_operations hfsplus_aops;
329extern const struct address_space_operations hfsplus_btree_aops; 329extern const struct address_space_operations hfsplus_btree_aops;
330extern struct dentry_operations hfsplus_dentry_operations; 330extern const struct dentry_operations hfsplus_dentry_operations;
331 331
332void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *); 332void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *);
333void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *); 333void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index f105ee9e1cc4..1bcf597c0562 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -137,7 +137,7 @@ const struct address_space_operations hfsplus_aops = {
137 .writepages = hfsplus_writepages, 137 .writepages = hfsplus_writepages,
138}; 138};
139 139
140struct dentry_operations hfsplus_dentry_operations = { 140const struct dentry_operations hfsplus_dentry_operations = {
141 .d_hash = hfsplus_hash_dentry, 141 .d_hash = hfsplus_hash_dentry,
142 .d_compare = hfsplus_compare_dentry, 142 .d_compare = hfsplus_compare_dentry,
143}; 143};
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 5c538e0ec14b..fe02ad4740e7 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -31,12 +31,12 @@ static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
31 31
32#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode) 32#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode)
33 33
34int hostfs_d_delete(struct dentry *dentry) 34static int hostfs_d_delete(struct dentry *dentry)
35{ 35{
36 return 1; 36 return 1;
37} 37}
38 38
39struct dentry_operations hostfs_dentry_ops = { 39static const struct dentry_operations hostfs_dentry_ops = {
40 .d_delete = hostfs_d_delete, 40 .d_delete = hostfs_d_delete,
41}; 41};
42 42
diff --git a/fs/hpfs/dentry.c b/fs/hpfs/dentry.c
index 08319126b2af..940d6d150bee 100644
--- a/fs/hpfs/dentry.c
+++ b/fs/hpfs/dentry.c
@@ -49,7 +49,7 @@ static int hpfs_compare_dentry(struct dentry *dentry, struct qstr *a, struct qst
49 return 0; 49 return 0;
50} 50}
51 51
52static struct dentry_operations hpfs_dentry_operations = { 52static const struct dentry_operations hpfs_dentry_operations = {
53 .d_hash = hpfs_hash_dentry, 53 .d_hash = hpfs_hash_dentry,
54 .d_compare = hpfs_compare_dentry, 54 .d_compare = hpfs_compare_dentry,
55}; 55};
diff --git a/fs/inode.c b/fs/inode.c
index 29df4a297449..d06d6d268de9 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -366,6 +366,8 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose)
366 if (tmp == head) 366 if (tmp == head)
367 break; 367 break;
368 inode = list_entry(tmp, struct inode, i_sb_list); 368 inode = list_entry(tmp, struct inode, i_sb_list);
369 if (inode->i_state & I_NEW)
370 continue;
369 invalidate_inode_buffers(inode); 371 invalidate_inode_buffers(inode);
370 if (!atomic_read(&inode->i_count)) { 372 if (!atomic_read(&inode->i_count)) {
371 list_move(&inode->i_list, dispose); 373 list_move(&inode->i_list, dispose);
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 6147ec3643a0..13d2eddd0692 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -114,7 +114,7 @@ static const struct super_operations isofs_sops = {
114}; 114};
115 115
116 116
117static struct dentry_operations isofs_dentry_ops[] = { 117static const struct dentry_operations isofs_dentry_ops[] = {
118 { 118 {
119 .d_hash = isofs_hash, 119 .d_hash = isofs_hash,
120 .d_compare = isofs_dentry_cmp, 120 .d_compare = isofs_dentry_cmp,
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
index adb2fafcc544..1eff7db34d63 100644
--- a/fs/jfs/jfs_inode.h
+++ b/fs/jfs/jfs_inode.h
@@ -47,5 +47,5 @@ extern const struct file_operations jfs_dir_operations;
47extern const struct inode_operations jfs_file_inode_operations; 47extern const struct inode_operations jfs_file_inode_operations;
48extern const struct file_operations jfs_file_operations; 48extern const struct file_operations jfs_file_operations;
49extern const struct inode_operations jfs_symlink_inode_operations; 49extern const struct inode_operations jfs_symlink_inode_operations;
50extern struct dentry_operations jfs_ci_dentry_operations; 50extern const struct dentry_operations jfs_ci_dentry_operations;
51#endif /* _H_JFS_INODE */ 51#endif /* _H_JFS_INODE */
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 9feaa04555d2..514ee2edb92a 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -35,7 +35,7 @@
35/* 35/*
36 * forward references 36 * forward references
37 */ 37 */
38struct dentry_operations jfs_ci_dentry_operations; 38const struct dentry_operations jfs_ci_dentry_operations;
39 39
40static s64 commitZeroLink(tid_t, struct inode *); 40static s64 commitZeroLink(tid_t, struct inode *);
41 41
@@ -1595,7 +1595,7 @@ out:
1595 return result; 1595 return result;
1596} 1596}
1597 1597
1598struct dentry_operations jfs_ci_dentry_operations = 1598const struct dentry_operations jfs_ci_dentry_operations =
1599{ 1599{
1600 .d_hash = jfs_ci_hash, 1600 .d_hash = jfs_ci_hash,
1601 .d_compare = jfs_ci_compare, 1601 .d_compare = jfs_ci_compare,
diff --git a/fs/libfs.c b/fs/libfs.c
index 49b44099dabb..4910a36f516e 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -44,7 +44,7 @@ static int simple_delete_dentry(struct dentry *dentry)
44 */ 44 */
45struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) 45struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
46{ 46{
47 static struct dentry_operations simple_dentry_operations = { 47 static const struct dentry_operations simple_dentry_operations = {
48 .d_delete = simple_delete_dentry, 48 .d_delete = simple_delete_dentry,
49 }; 49 };
50 50
@@ -242,7 +242,8 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name,
242 d_instantiate(dentry, root); 242 d_instantiate(dentry, root);
243 s->s_root = dentry; 243 s->s_root = dentry;
244 s->s_flags |= MS_ACTIVE; 244 s->s_flags |= MS_ACTIVE;
245 return simple_set_mnt(mnt, s); 245 simple_set_mnt(mnt, s);
246 return 0;
246 247
247Enomem: 248Enomem:
248 up_write(&s->s_umount); 249 up_write(&s->s_umount);
diff --git a/fs/namei.c b/fs/namei.c
index 1928197b3874..d040ce11785d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1489,24 +1489,22 @@ int may_open(struct path *path, int acc_mode, int flag)
1489 if (!inode) 1489 if (!inode)
1490 return -ENOENT; 1490 return -ENOENT;
1491 1491
1492 if (S_ISLNK(inode->i_mode)) 1492 switch (inode->i_mode & S_IFMT) {
1493 case S_IFLNK:
1493 return -ELOOP; 1494 return -ELOOP;
1494 1495 case S_IFDIR:
1495 if (S_ISDIR(inode->i_mode) && (acc_mode & MAY_WRITE)) 1496 if (acc_mode & MAY_WRITE)
1496 return -EISDIR; 1497 return -EISDIR;
1497 1498 break;
1498 /* 1499 case S_IFBLK:
1499 * FIFO's, sockets and device files are special: they don't 1500 case S_IFCHR:
1500 * actually live on the filesystem itself, and as such you
1501 * can write to them even if the filesystem is read-only.
1502 */
1503 if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
1504 flag &= ~O_TRUNC;
1505 } else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
1506 if (path->mnt->mnt_flags & MNT_NODEV) 1501 if (path->mnt->mnt_flags & MNT_NODEV)
1507 return -EACCES; 1502 return -EACCES;
1508 1503 /*FALLTHRU*/
1504 case S_IFIFO:
1505 case S_IFSOCK:
1509 flag &= ~O_TRUNC; 1506 flag &= ~O_TRUNC;
1507 break;
1510 } 1508 }
1511 1509
1512 error = inode_permission(inode, acc_mode); 1510 error = inode_permission(inode, acc_mode);
diff --git a/fs/namespace.c b/fs/namespace.c
index f0e753097353..0a42e0e96027 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -397,11 +397,10 @@ static void __mnt_unmake_readonly(struct vfsmount *mnt)
397 spin_unlock(&vfsmount_lock); 397 spin_unlock(&vfsmount_lock);
398} 398}
399 399
400int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb) 400void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb)
401{ 401{
402 mnt->mnt_sb = sb; 402 mnt->mnt_sb = sb;
403 mnt->mnt_root = dget(sb->s_root); 403 mnt->mnt_root = dget(sb->s_root);
404 return 0;
405} 404}
406 405
407EXPORT_SYMBOL(simple_set_mnt); 406EXPORT_SYMBOL(simple_set_mnt);
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 07e9715b8658..9c590722d87e 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -79,7 +79,7 @@ static int ncp_hash_dentry(struct dentry *, struct qstr *);
79static int ncp_compare_dentry (struct dentry *, struct qstr *, struct qstr *); 79static int ncp_compare_dentry (struct dentry *, struct qstr *, struct qstr *);
80static int ncp_delete_dentry(struct dentry *); 80static int ncp_delete_dentry(struct dentry *);
81 81
82static struct dentry_operations ncp_dentry_operations = 82static const struct dentry_operations ncp_dentry_operations =
83{ 83{
84 .d_revalidate = ncp_lookup_validate, 84 .d_revalidate = ncp_lookup_validate,
85 .d_hash = ncp_hash_dentry, 85 .d_hash = ncp_hash_dentry,
@@ -87,7 +87,7 @@ static struct dentry_operations ncp_dentry_operations =
87 .d_delete = ncp_delete_dentry, 87 .d_delete = ncp_delete_dentry,
88}; 88};
89 89
90struct dentry_operations ncp_root_dentry_operations = 90const struct dentry_operations ncp_root_dentry_operations =
91{ 91{
92 .d_hash = ncp_hash_dentry, 92 .d_hash = ncp_hash_dentry,
93 .d_compare = ncp_compare_dentry, 93 .d_compare = ncp_compare_dentry,
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 672368f865ca..78bf72fc1db3 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -899,7 +899,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
899 iput(inode); 899 iput(inode);
900} 900}
901 901
902struct dentry_operations nfs_dentry_operations = { 902const struct dentry_operations nfs_dentry_operations = {
903 .d_revalidate = nfs_lookup_revalidate, 903 .d_revalidate = nfs_lookup_revalidate,
904 .d_delete = nfs_dentry_delete, 904 .d_delete = nfs_dentry_delete,
905 .d_iput = nfs_dentry_iput, 905 .d_iput = nfs_dentry_iput,
@@ -967,7 +967,7 @@ out:
967#ifdef CONFIG_NFS_V4 967#ifdef CONFIG_NFS_V4
968static int nfs_open_revalidate(struct dentry *, struct nameidata *); 968static int nfs_open_revalidate(struct dentry *, struct nameidata *);
969 969
970struct dentry_operations nfs4_dentry_operations = { 970const struct dentry_operations nfs4_dentry_operations = {
971 .d_revalidate = nfs_open_revalidate, 971 .d_revalidate = nfs_open_revalidate,
972 .d_delete = nfs_dentry_delete, 972 .d_delete = nfs_dentry_delete,
973 .d_iput = nfs_dentry_iput, 973 .d_iput = nfs_dentry_iput,
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 4e4d33204376..84345deab26f 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -179,7 +179,7 @@ struct nfs4_state_recovery_ops {
179 int (*recover_lock)(struct nfs4_state *, struct file_lock *); 179 int (*recover_lock)(struct nfs4_state *, struct file_lock *);
180}; 180};
181 181
182extern struct dentry_operations nfs4_dentry_operations; 182extern const struct dentry_operations nfs4_dentry_operations;
183extern const struct inode_operations nfs4_dir_inode_operations; 183extern const struct inode_operations nfs4_dir_inode_operations;
184 184
185/* inode.c */ 185/* inode.c */
diff --git a/fs/notify/inotify/inotify.c b/fs/notify/inotify/inotify.c
index 331f2e88e284..220c13f0d73d 100644
--- a/fs/notify/inotify/inotify.c
+++ b/fs/notify/inotify/inotify.c
@@ -380,6 +380,14 @@ void inotify_unmount_inodes(struct list_head *list)
380 struct list_head *watches; 380 struct list_head *watches;
381 381
382 /* 382 /*
383 * We cannot __iget() an inode in state I_CLEAR, I_FREEING,
384 * I_WILL_FREE, or I_NEW which is fine because by that point
385 * the inode cannot have any associated watches.
386 */
387 if (inode->i_state & (I_CLEAR|I_FREEING|I_WILL_FREE|I_NEW))
388 continue;
389
390 /*
383 * If i_count is zero, the inode cannot have any watches and 391 * If i_count is zero, the inode cannot have any watches and
384 * doing an __iget/iput with MS_ACTIVE clear would actually 392 * doing an __iget/iput with MS_ACTIVE clear would actually
385 * evict all inodes with zero i_count from icache which is 393 * evict all inodes with zero i_count from icache which is
@@ -388,14 +396,6 @@ void inotify_unmount_inodes(struct list_head *list)
388 if (!atomic_read(&inode->i_count)) 396 if (!atomic_read(&inode->i_count))
389 continue; 397 continue;
390 398
391 /*
392 * We cannot __iget() an inode in state I_CLEAR, I_FREEING, or
393 * I_WILL_FREE which is fine because by that point the inode
394 * cannot have any associated watches.
395 */
396 if (inode->i_state & (I_CLEAR | I_FREEING | I_WILL_FREE))
397 continue;
398
399 need_iput_tmp = need_iput; 399 need_iput_tmp = need_iput;
400 need_iput = NULL; 400 need_iput = NULL;
401 /* In case inotify_remove_watch_locked() drops a reference. */ 401 /* In case inotify_remove_watch_locked() drops a reference. */
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index e9d7c2038c0f..7d604480557a 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -455,7 +455,7 @@ out_move:
455 d_move(dentry, target); 455 d_move(dentry, target);
456} 456}
457 457
458struct dentry_operations ocfs2_dentry_ops = { 458const struct dentry_operations ocfs2_dentry_ops = {
459 .d_revalidate = ocfs2_dentry_revalidate, 459 .d_revalidate = ocfs2_dentry_revalidate,
460 .d_iput = ocfs2_dentry_iput, 460 .d_iput = ocfs2_dentry_iput,
461}; 461};
diff --git a/fs/ocfs2/dcache.h b/fs/ocfs2/dcache.h
index d06e16c06640..faa12e75f98d 100644
--- a/fs/ocfs2/dcache.h
+++ b/fs/ocfs2/dcache.h
@@ -26,7 +26,7 @@
26#ifndef OCFS2_DCACHE_H 26#ifndef OCFS2_DCACHE_H
27#define OCFS2_DCACHE_H 27#define OCFS2_DCACHE_H
28 28
29extern struct dentry_operations ocfs2_dentry_ops; 29extern const struct dentry_operations ocfs2_dentry_ops;
30 30
31struct ocfs2_dentry_lock { 31struct ocfs2_dentry_lock {
32 /* Use count of dentry lock */ 32 /* Use count of dentry lock */
diff --git a/fs/pipe.c b/fs/pipe.c
index 94ad15967cf9..4af7aa521813 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -860,7 +860,7 @@ static char *pipefs_dname(struct dentry *dentry, char *buffer, int buflen)
860 dentry->d_inode->i_ino); 860 dentry->d_inode->i_ino);
861} 861}
862 862
863static struct dentry_operations pipefs_dentry_operations = { 863static const struct dentry_operations pipefs_dentry_operations = {
864 .d_delete = pipefs_delete_dentry, 864 .d_delete = pipefs_delete_dentry,
865 .d_dname = pipefs_dname, 865 .d_dname = pipefs_dname,
866}; 866};
@@ -1024,11 +1024,6 @@ int do_pipe_flags(int *fd, int flags)
1024 return error; 1024 return error;
1025} 1025}
1026 1026
1027int do_pipe(int *fd)
1028{
1029 return do_pipe_flags(fd, 0);
1030}
1031
1032/* 1027/*
1033 * sys_pipe() is the normal C calling standard for creating 1028 * sys_pipe() is the normal C calling standard for creating
1034 * a pipe. It's not the way Unix traditionally does this, though. 1029 * a pipe. It's not the way Unix traditionally does this, though.
diff --git a/fs/proc/base.c b/fs/proc/base.c
index beaa0ce3b82e..aef6d55b7de6 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1545,7 +1545,7 @@ static int pid_delete_dentry(struct dentry * dentry)
1545 return !proc_pid(dentry->d_inode)->tasks[PIDTYPE_PID].first; 1545 return !proc_pid(dentry->d_inode)->tasks[PIDTYPE_PID].first;
1546} 1546}
1547 1547
1548static struct dentry_operations pid_dentry_operations = 1548static const struct dentry_operations pid_dentry_operations =
1549{ 1549{
1550 .d_revalidate = pid_revalidate, 1550 .d_revalidate = pid_revalidate,
1551 .d_delete = pid_delete_dentry, 1551 .d_delete = pid_delete_dentry,
@@ -1717,7 +1717,7 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
1717 return 0; 1717 return 0;
1718} 1718}
1719 1719
1720static struct dentry_operations tid_fd_dentry_operations = 1720static const struct dentry_operations tid_fd_dentry_operations =
1721{ 1721{
1722 .d_revalidate = tid_fd_revalidate, 1722 .d_revalidate = tid_fd_revalidate,
1723 .d_delete = pid_delete_dentry, 1723 .d_delete = pid_delete_dentry,
@@ -2339,7 +2339,7 @@ static int proc_base_revalidate(struct dentry *dentry, struct nameidata *nd)
2339 return 0; 2339 return 0;
2340} 2340}
2341 2341
2342static struct dentry_operations proc_base_dentry_operations = 2342static const struct dentry_operations proc_base_dentry_operations =
2343{ 2343{
2344 .d_revalidate = proc_base_revalidate, 2344 .d_revalidate = proc_base_revalidate,
2345 .d_delete = pid_delete_dentry, 2345 .d_delete = pid_delete_dentry,
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index db7fa5cab988..5d2989e9dcc1 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -363,7 +363,7 @@ static int proc_delete_dentry(struct dentry * dentry)
363 return 1; 363 return 1;
364} 364}
365 365
366static struct dentry_operations proc_dentry_operations = 366static const struct dentry_operations proc_dentry_operations =
367{ 367{
368 .d_delete = proc_delete_dentry, 368 .d_delete = proc_delete_dentry,
369}; 369};
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 94fcfff6863a..9b1e4e9a16bf 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -7,7 +7,7 @@
7#include <linux/security.h> 7#include <linux/security.h>
8#include "internal.h" 8#include "internal.h"
9 9
10static struct dentry_operations proc_sys_dentry_operations; 10static const struct dentry_operations proc_sys_dentry_operations;
11static const struct file_operations proc_sys_file_operations; 11static const struct file_operations proc_sys_file_operations;
12static const struct inode_operations proc_sys_inode_operations; 12static const struct inode_operations proc_sys_inode_operations;
13static const struct file_operations proc_sys_dir_file_operations; 13static const struct file_operations proc_sys_dir_file_operations;
@@ -396,7 +396,7 @@ static int proc_sys_compare(struct dentry *dir, struct qstr *qstr,
396 return !sysctl_is_seen(PROC_I(dentry->d_inode)->sysctl); 396 return !sysctl_is_seen(PROC_I(dentry->d_inode)->sysctl);
397} 397}
398 398
399static struct dentry_operations proc_sys_dentry_operations = { 399static const struct dentry_operations proc_sys_dentry_operations = {
400 .d_revalidate = proc_sys_revalidate, 400 .d_revalidate = proc_sys_revalidate,
401 .d_delete = proc_sys_delete, 401 .d_delete = proc_sys_delete,
402 .d_compare = proc_sys_compare, 402 .d_compare = proc_sys_compare,
diff --git a/fs/proc/root.c b/fs/proc/root.c
index f6299a25594e..1e15a2b176e8 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -83,7 +83,8 @@ static int proc_get_sb(struct file_system_type *fs_type,
83 ns->proc_mnt = mnt; 83 ns->proc_mnt = mnt;
84 } 84 }
85 85
86 return simple_set_mnt(mnt, sb); 86 simple_set_mnt(mnt, sb);
87 return 0;
87} 88}
88 89
89static void proc_kill_sb(struct super_block *sb) 90static void proc_kill_sb(struct super_block *sb)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index eb938015bd91..2ca967a5ef77 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -823,12 +823,12 @@ static void add_dquot_ref(struct super_block *sb, int type)
823 823
824 spin_lock(&inode_lock); 824 spin_lock(&inode_lock);
825 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { 825 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
826 if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW))
827 continue;
826 if (!atomic_read(&inode->i_writecount)) 828 if (!atomic_read(&inode->i_writecount))
827 continue; 829 continue;
828 if (!dqinit_needed(inode, type)) 830 if (!dqinit_needed(inode, type))
829 continue; 831 continue;
830 if (inode->i_state & (I_FREEING|I_WILL_FREE))
831 continue;
832 832
833 __iget(inode); 833 __iget(inode);
834 spin_unlock(&inode_lock); 834 spin_unlock(&inode_lock);
@@ -915,6 +915,12 @@ static void remove_dquot_ref(struct super_block *sb, int type,
915 915
916 spin_lock(&inode_lock); 916 spin_lock(&inode_lock);
917 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { 917 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
918 /*
919 * We have to scan also I_NEW inodes because they can already
920 * have quota pointer initialized. Luckily, we need to touch
921 * only quota pointers and these have separate locking
922 * (dqptr_sem).
923 */
918 if (!IS_NOQUOTA(inode)) 924 if (!IS_NOQUOTA(inode))
919 remove_inode_dquot_ref(inode, type, tofree_head); 925 remove_inode_dquot_ref(inode, type, tofree_head);
920 } 926 }
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index ad92461cbfc3..ae881ccd2f03 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -1136,7 +1136,7 @@ xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name)
1136 return 1; 1136 return 1;
1137} 1137}
1138 1138
1139static struct dentry_operations xattr_lookup_poison_ops = { 1139static const struct dentry_operations xattr_lookup_poison_ops = {
1140 .d_compare = xattr_lookup_poison, 1140 .d_compare = xattr_lookup_poison,
1141}; 1141};
1142 1142
diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index e7ddd0328ddc..3e4803b4427e 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -277,7 +277,7 @@ static int smb_hash_dentry(struct dentry *, struct qstr *);
277static int smb_compare_dentry(struct dentry *, struct qstr *, struct qstr *); 277static int smb_compare_dentry(struct dentry *, struct qstr *, struct qstr *);
278static int smb_delete_dentry(struct dentry *); 278static int smb_delete_dentry(struct dentry *);
279 279
280static struct dentry_operations smbfs_dentry_operations = 280static const struct dentry_operations smbfs_dentry_operations =
281{ 281{
282 .d_revalidate = smb_lookup_validate, 282 .d_revalidate = smb_lookup_validate,
283 .d_hash = smb_hash_dentry, 283 .d_hash = smb_hash_dentry,
@@ -285,7 +285,7 @@ static struct dentry_operations smbfs_dentry_operations =
285 .d_delete = smb_delete_dentry, 285 .d_delete = smb_delete_dentry,
286}; 286};
287 287
288static struct dentry_operations smbfs_dentry_operations_case = 288static const struct dentry_operations smbfs_dentry_operations_case =
289{ 289{
290 .d_revalidate = smb_lookup_validate, 290 .d_revalidate = smb_lookup_validate,
291 .d_delete = smb_delete_dentry, 291 .d_delete = smb_delete_dentry,
diff --git a/fs/super.c b/fs/super.c
index 49d0bd32a5a7..2ba481518ba7 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -838,7 +838,8 @@ int get_sb_bdev(struct file_system_type *fs_type,
838 bdev->bd_super = s; 838 bdev->bd_super = s;
839 } 839 }
840 840
841 return simple_set_mnt(mnt, s); 841 simple_set_mnt(mnt, s);
842 return 0;
842 843
843error_s: 844error_s:
844 error = PTR_ERR(s); 845 error = PTR_ERR(s);
@@ -884,7 +885,8 @@ int get_sb_nodev(struct file_system_type *fs_type,
884 return error; 885 return error;
885 } 886 }
886 s->s_flags |= MS_ACTIVE; 887 s->s_flags |= MS_ACTIVE;
887 return simple_set_mnt(mnt, s); 888 simple_set_mnt(mnt, s);
889 return 0;
888} 890}
889 891
890EXPORT_SYMBOL(get_sb_nodev); 892EXPORT_SYMBOL(get_sb_nodev);
@@ -916,7 +918,8 @@ int get_sb_single(struct file_system_type *fs_type,
916 s->s_flags |= MS_ACTIVE; 918 s->s_flags |= MS_ACTIVE;
917 } 919 }
918 do_remount_sb(s, flags, data, 0); 920 do_remount_sb(s, flags, data, 0);
919 return simple_set_mnt(mnt, s); 921 simple_set_mnt(mnt, s);
922 return 0;
920} 923}
921 924
922EXPORT_SYMBOL(get_sb_single); 925EXPORT_SYMBOL(get_sb_single);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 66aeb4fff0c3..d88d0fac9fa5 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -302,7 +302,7 @@ static void sysfs_d_iput(struct dentry * dentry, struct inode * inode)
302 iput(inode); 302 iput(inode);
303} 303}
304 304
305static struct dentry_operations sysfs_dentry_ops = { 305static const struct dentry_operations sysfs_dentry_ops = {
306 .d_iput = sysfs_d_iput, 306 .d_iput = sysfs_d_iput,
307}; 307};
308 308
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index a1f1ef33e81c..33e047b59b8d 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -38,7 +38,7 @@ static int sysv_hash(struct dentry *dentry, struct qstr *qstr)
38 return 0; 38 return 0;
39} 39}
40 40
41struct dentry_operations sysv_dentry_operations = { 41const struct dentry_operations sysv_dentry_operations = {
42 .d_hash = sysv_hash, 42 .d_hash = sysv_hash,
43}; 43};
44 44
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index 38ebe3f85b3d..5784a318c883 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -170,7 +170,7 @@ extern const struct file_operations sysv_file_operations;
170extern const struct file_operations sysv_dir_operations; 170extern const struct file_operations sysv_dir_operations;
171extern const struct address_space_operations sysv_aops; 171extern const struct address_space_operations sysv_aops;
172extern const struct super_operations sysv_sops; 172extern const struct super_operations sysv_sops;
173extern struct dentry_operations sysv_dentry_operations; 173extern const struct dentry_operations sysv_dentry_operations;
174 174
175 175
176enum { 176enum {
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 1182b66a5491..c5c98355459a 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -2034,7 +2034,8 @@ static int ubifs_get_sb(struct file_system_type *fs_type, int flags,
2034 /* 'fill_super()' opens ubi again so we must close it here */ 2034 /* 'fill_super()' opens ubi again so we must close it here */
2035 ubi_close_volume(ubi); 2035 ubi_close_volume(ubi);
2036 2036
2037 return simple_set_mnt(mnt, sb); 2037 simple_set_mnt(mnt, sb);
2038 return 0;
2038 2039
2039out_deact: 2040out_deact:
2040 up_write(&sb->s_umount); 2041 up_write(&sb->s_umount);
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 39f877898565..3d2512c21f05 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -622,7 +622,6 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
622 struct ufs_inode_info *ufsi = UFS_I(inode); 622 struct ufs_inode_info *ufsi = UFS_I(inode);
623 struct super_block *sb = inode->i_sb; 623 struct super_block *sb = inode->i_sb;
624 mode_t mode; 624 mode_t mode;
625 unsigned i;
626 625
627 /* 626 /*
628 * Copy data to the in-core inode. 627 * Copy data to the in-core inode.
@@ -655,11 +654,12 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
655 654
656 655
657 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { 656 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {
658 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) 657 memcpy(ufsi->i_u1.i_data, &ufs_inode->ui_u2.ui_addr,
659 ufsi->i_u1.i_data[i] = ufs_inode->ui_u2.ui_addr.ui_db[i]; 658 sizeof(ufs_inode->ui_u2.ui_addr));
660 } else { 659 } else {
661 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 660 memcpy(ufsi->i_u1.i_symlink, ufs_inode->ui_u2.ui_symlink,
662 ufsi->i_u1.i_symlink[i] = ufs_inode->ui_u2.ui_symlink[i]; 661 sizeof(ufs_inode->ui_u2.ui_symlink) - 1);
662 ufsi->i_u1.i_symlink[sizeof(ufs_inode->ui_u2.ui_symlink) - 1] = 0;
663 } 663 }
664 return 0; 664 return 0;
665} 665}
@@ -669,7 +669,6 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
669 struct ufs_inode_info *ufsi = UFS_I(inode); 669 struct ufs_inode_info *ufsi = UFS_I(inode);
670 struct super_block *sb = inode->i_sb; 670 struct super_block *sb = inode->i_sb;
671 mode_t mode; 671 mode_t mode;
672 unsigned i;
673 672
674 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); 673 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino);
675 /* 674 /*
@@ -704,12 +703,12 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
704 */ 703 */
705 704
706 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) { 705 if (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {
707 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) 706 memcpy(ufsi->i_u1.u2_i_data, &ufs2_inode->ui_u2.ui_addr,
708 ufsi->i_u1.u2_i_data[i] = 707 sizeof(ufs2_inode->ui_u2.ui_addr));
709 ufs2_inode->ui_u2.ui_addr.ui_db[i];
710 } else { 708 } else {
711 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 709 memcpy(ufsi->i_u1.i_symlink, ufs2_inode->ui_u2.ui_symlink,
712 ufsi->i_u1.i_symlink[i] = ufs2_inode->ui_u2.ui_symlink[i]; 710 sizeof(ufs2_inode->ui_u2.ui_symlink) - 1);
711 ufsi->i_u1.i_symlink[sizeof(ufs2_inode->ui_u2.ui_symlink) - 1] = 0;
713 } 712 }
714 return 0; 713 return 0;
715} 714}
@@ -781,7 +780,6 @@ static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
781{ 780{
782 struct super_block *sb = inode->i_sb; 781 struct super_block *sb = inode->i_sb;
783 struct ufs_inode_info *ufsi = UFS_I(inode); 782 struct ufs_inode_info *ufsi = UFS_I(inode);
784 unsigned i;
785 783
786 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); 784 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode);
787 ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink); 785 ufs_inode->ui_nlink = cpu_to_fs16(sb, inode->i_nlink);
@@ -809,12 +807,12 @@ static void ufs1_update_inode(struct inode *inode, struct ufs_inode *ufs_inode)
809 /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */ 807 /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */
810 ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.i_data[0]; 808 ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.i_data[0];
811 } else if (inode->i_blocks) { 809 } else if (inode->i_blocks) {
812 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) 810 memcpy(&ufs_inode->ui_u2.ui_addr, ufsi->i_u1.i_data,
813 ufs_inode->ui_u2.ui_addr.ui_db[i] = ufsi->i_u1.i_data[i]; 811 sizeof(ufs_inode->ui_u2.ui_addr));
814 } 812 }
815 else { 813 else {
816 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 814 memcpy(&ufs_inode->ui_u2.ui_symlink, ufsi->i_u1.i_symlink,
817 ufs_inode->ui_u2.ui_symlink[i] = ufsi->i_u1.i_symlink[i]; 815 sizeof(ufs_inode->ui_u2.ui_symlink));
818 } 816 }
819 817
820 if (!inode->i_nlink) 818 if (!inode->i_nlink)
@@ -825,7 +823,6 @@ static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode)
825{ 823{
826 struct super_block *sb = inode->i_sb; 824 struct super_block *sb = inode->i_sb;
827 struct ufs_inode_info *ufsi = UFS_I(inode); 825 struct ufs_inode_info *ufsi = UFS_I(inode);
828 unsigned i;
829 826
830 UFSD("ENTER\n"); 827 UFSD("ENTER\n");
831 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode); 828 ufs_inode->ui_mode = cpu_to_fs16(sb, inode->i_mode);
@@ -850,11 +847,11 @@ static void ufs2_update_inode(struct inode *inode, struct ufs2_inode *ufs_inode)
850 /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */ 847 /* ufs_inode->ui_u2.ui_addr.ui_db[0] = cpu_to_fs32(sb, inode->i_rdev); */
851 ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.u2_i_data[0]; 848 ufs_inode->ui_u2.ui_addr.ui_db[0] = ufsi->i_u1.u2_i_data[0];
852 } else if (inode->i_blocks) { 849 } else if (inode->i_blocks) {
853 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR); i++) 850 memcpy(&ufs_inode->ui_u2.ui_addr, ufsi->i_u1.u2_i_data,
854 ufs_inode->ui_u2.ui_addr.ui_db[i] = ufsi->i_u1.u2_i_data[i]; 851 sizeof(ufs_inode->ui_u2.ui_addr));
855 } else { 852 } else {
856 for (i = 0; i < (UFS_NDADDR + UFS_NINDIR) * 4; i++) 853 memcpy(&ufs_inode->ui_u2.ui_symlink, ufsi->i_u1.i_symlink,
857 ufs_inode->ui_u2.ui_symlink[i] = ufsi->i_u1.i_symlink[i]; 854 sizeof(ufs_inode->ui_u2.ui_symlink));
858 } 855 }
859 856
860 if (!inode->i_nlink) 857 if (!inode->i_nlink)
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index e3a9b1fac75a..23119fe7ad62 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -147,7 +147,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
147 } else { 147 } else {
148 /* fast symlink */ 148 /* fast symlink */
149 inode->i_op = &ufs_fast_symlink_inode_operations; 149 inode->i_op = &ufs_fast_symlink_inode_operations;
150 memcpy((char*)&UFS_I(inode)->i_u1.i_data,symname,l); 150 memcpy(UFS_I(inode)->i_u1.i_symlink, symname, l);
151 inode->i_size = l-1; 151 inode->i_size = l-1;
152 } 152 }
153 mark_inode_dirty(inode); 153 mark_inode_dirty(inode);
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 261a1c2f22dd..e1c1fc5ee239 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -636,6 +636,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
636 unsigned block_size, super_block_size; 636 unsigned block_size, super_block_size;
637 unsigned flags; 637 unsigned flags;
638 unsigned super_block_offset; 638 unsigned super_block_offset;
639 unsigned maxsymlen;
639 int ret = -EINVAL; 640 int ret = -EINVAL;
640 641
641 uspi = NULL; 642 uspi = NULL;
@@ -1069,6 +1070,16 @@ magic_found:
1069 uspi->s_maxsymlinklen = 1070 uspi->s_maxsymlinklen =
1070 fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); 1071 fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen);
1071 1072
1073 if (uspi->fs_magic == UFS2_MAGIC)
1074 maxsymlen = 2 * 4 * (UFS_NDADDR + UFS_NINDIR);
1075 else
1076 maxsymlen = 4 * (UFS_NDADDR + UFS_NINDIR);
1077 if (uspi->s_maxsymlinklen > maxsymlen) {
1078 ufs_warning(sb, __func__, "ufs_read_super: excessive maximum "
1079 "fast symlink size (%u)\n", uspi->s_maxsymlinklen);
1080 uspi->s_maxsymlinklen = maxsymlen;
1081 }
1082
1072 inode = ufs_iget(sb, UFS_ROOTINO); 1083 inode = ufs_iget(sb, UFS_ROOTINO);
1073 if (IS_ERR(inode)) { 1084 if (IS_ERR(inode)) {
1074 ret = PTR_ERR(inode); 1085 ret = PTR_ERR(inode);
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 11c035168ea6..69b3427d7885 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -23,7 +23,7 @@ struct ufs_sb_info {
23struct ufs_inode_info { 23struct ufs_inode_info {
24 union { 24 union {
25 __fs32 i_data[15]; 25 __fs32 i_data[15];
26 __u8 i_symlink[4*15]; 26 __u8 i_symlink[2 * 4 * 15];
27 __fs64 u2_i_data[15]; 27 __fs64 u2_i_data[15];
28 } i_u1; 28 } i_u1;
29 __u32 i_flags; 29 __u32 i_flags;