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_inode.c46
-rw-r--r--fs/9p/vfs_inode_dotl.c14
-rw-r--r--fs/9p/vfs_super.c2
-rw-r--r--fs/Kconfig8
-rw-r--r--fs/Makefile3
-rw-r--r--fs/adfs/super.c4
-rw-r--r--fs/affs/affs.h6
-rw-r--r--fs/affs/amigaffs.c6
-rw-r--r--fs/affs/namei.c8
-rw-r--r--fs/affs/super.c1
-rw-r--r--fs/afs/dir.c12
-rw-r--r--fs/afs/mntpt.c4
-rw-r--r--fs/afs/super.c1
-rw-r--r--fs/attr.c4
-rw-r--r--fs/autofs4/autofs_i.h2
-rw-r--r--fs/autofs4/dev-ioctl.c10
-rw-r--r--fs/autofs4/inode.c8
-rw-r--r--fs/autofs4/root.c4
-rw-r--r--fs/bad_inode.c6
-rw-r--r--fs/befs/linuxvfs.c1
-rw-r--r--fs/bfs/dir.c2
-rw-r--r--fs/bfs/inode.c1
-rw-r--r--fs/binfmt_misc.c6
-rw-r--r--fs/block_dev.c38
-rw-r--r--fs/btrfs/inode.c11
-rw-r--r--fs/btrfs/ioctl.c22
-rw-r--r--fs/btrfs/super.c5
-rw-r--r--fs/buffer.c50
-rw-r--r--fs/cachefiles/interface.c1
-rw-r--r--fs/ceph/caps.c4
-rw-r--r--fs/ceph/dir.c12
-rw-r--r--fs/ceph/inode.c1
-rw-r--r--fs/ceph/super.c6
-rw-r--r--fs/ceph/super.h2
-rw-r--r--fs/cifs/cifs_fs_sb.h4
-rw-r--r--fs/cifs/cifsfs.c10
-rw-r--r--fs/cifs/cifsfs.h6
-rw-r--r--fs/cifs/cifsglob.h4
-rw-r--r--fs/cifs/connect.c2
-rw-r--r--fs/cifs/dir.c4
-rw-r--r--fs/cifs/inode.c4
-rw-r--r--fs/coda/dir.c8
-rw-r--r--fs/coda/inode.c1
-rw-r--r--fs/compat.c13
-rw-r--r--fs/configfs/configfs_internal.h4
-rw-r--r--fs/configfs/dir.c6
-rw-r--r--fs/configfs/inode.c6
-rw-r--r--fs/cramfs/inode.c3
-rw-r--r--fs/dcache.c37
-rw-r--r--fs/debugfs/file.c22
-rw-r--r--fs/debugfs/inode.c16
-rw-r--r--fs/devpts/inode.c4
-rw-r--r--fs/ecryptfs/inode.c29
-rw-r--r--fs/ecryptfs/super.c5
-rw-r--r--fs/efs/super.c1
-rw-r--r--fs/exec.c2
-rw-r--r--fs/exofs/dir.c2
-rw-r--r--fs/exofs/exofs.h2
-rw-r--r--fs/exofs/inode.c2
-rw-r--r--fs/exofs/namei.c6
-rw-r--r--fs/exofs/super.c1
-rw-r--r--fs/ext2/dir.c2
-rw-r--r--fs/ext2/ext2.h2
-rw-r--r--fs/ext2/ialloc.c2
-rw-r--r--fs/ext2/ioctl.c12
-rw-r--r--fs/ext2/namei.c6
-rw-r--r--fs/ext2/super.c5
-rw-r--r--fs/ext3/ialloc.c2
-rw-r--r--fs/ext3/ioctl.c20
-rw-r--r--fs/ext3/namei.c6
-rw-r--r--fs/ext3/super.c7
-rw-r--r--fs/ext4/ext4.h2
-rw-r--r--fs/ext4/ialloc.c8
-rw-r--r--fs/ext4/ioctl.c28
-rw-r--r--fs/ext4/namei.c6
-rw-r--r--fs/ext4/super.c7
-rw-r--r--fs/fat/fat.h6
-rw-r--r--fs/fat/file.c8
-rw-r--r--fs/fat/inode.c7
-rw-r--r--fs/fat/namei_msdos.c4
-rw-r--r--fs/fat/namei_vfat.c4
-rw-r--r--fs/fhandle.c8
-rw-r--r--fs/file_table.c23
-rw-r--r--fs/filesystems.c1
-rw-r--r--fs/freevxfs/vxfs_inode.c5
-rw-r--r--fs/fs-writeback.c1
-rw-r--r--fs/fuse/dir.c12
-rw-r--r--fs/fuse/fuse_i.h2
-rw-r--r--fs/fuse/inode.c11
-rw-r--r--fs/gfs2/file.c4
-rw-r--r--fs/gfs2/inode.c16
-rw-r--r--fs/gfs2/super.c9
-rw-r--r--fs/hfs/dir.c4
-rw-r--r--fs/hfs/hfs_fs.h2
-rw-r--r--fs/hfs/inode.c2
-rw-r--r--fs/hfs/super.c5
-rw-r--r--fs/hfsplus/dir.c6
-rw-r--r--fs/hfsplus/hfsplus_fs.h4
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hfsplus/ioctl.c4
-rw-r--r--fs/hfsplus/options.c4
-rw-r--r--fs/hfsplus/super.c1
-rw-r--r--fs/hostfs/hostfs.h2
-rw-r--r--fs/hostfs/hostfs_kern.c11
-rw-r--r--fs/hpfs/namei.c6
-rw-r--r--fs/hpfs/super.c1
-rw-r--r--fs/hppfs/hppfs.c3
-rw-r--r--fs/hugetlbfs/inode.c66
-rw-r--r--fs/inode.c92
-rw-r--r--fs/internal.h30
-rw-r--r--fs/isofs/inode.c5
-rw-r--r--fs/isofs/isofs.h6
-rw-r--r--fs/jffs2/dir.c14
-rw-r--r--fs/jffs2/super.c5
-rw-r--r--fs/jfs/ioctl.c4
-rw-r--r--fs/jfs/namei.c6
-rw-r--r--fs/jfs/super.c5
-rw-r--r--fs/libfs.c2
-rw-r--r--fs/lockd/svcsubs.c2
-rw-r--r--fs/logfs/dir.c6
-rw-r--r--fs/logfs/inode.c3
-rw-r--r--fs/logfs/logfs.h2
-rw-r--r--fs/minix/bitmap.c2
-rw-r--r--fs/minix/inode.c1
-rw-r--r--fs/minix/minix.h2
-rw-r--r--fs/minix/namei.c6
-rw-r--r--fs/mount.h76
-rw-r--r--fs/namei.c55
-rw-r--r--fs/namespace.c829
-rw-r--r--fs/ncpfs/dir.c18
-rw-r--r--fs/ncpfs/inode.c7
-rw-r--r--fs/ncpfs/ioctl.c2
-rw-r--r--fs/ncpfs/ncplib_kernel.h2
-rw-r--r--fs/ncpfs/symlink.c2
-rw-r--r--fs/nfs/dir.c33
-rw-r--r--fs/nfs/inode.c41
-rw-r--r--fs/nfs/super.c49
-rw-r--r--fs/nfsd/nfs4proc.c4
-rw-r--r--fs/nfsd/nfs4recover.c12
-rw-r--r--fs/nfsd/nfsctl.c2
-rw-r--r--fs/nfsd/nfsfh.c4
-rw-r--r--fs/nfsd/nfsfh.h2
-rw-r--r--fs/nfsd/vfs.c38
-rw-r--r--fs/nfsd/vfs.h12
-rw-r--r--fs/nilfs2/dir.c2
-rw-r--r--fs/nilfs2/inode.c2
-rw-r--r--fs/nilfs2/ioctl.c22
-rw-r--r--fs/nilfs2/namei.c6
-rw-r--r--fs/nilfs2/nilfs.h2
-rw-r--r--fs/nilfs2/super.c8
-rw-r--r--fs/notify/fanotify/fanotify_user.c6
-rw-r--r--fs/notify/fsnotify.c9
-rw-r--r--fs/notify/vfsmount_mark.c19
-rw-r--r--fs/ntfs/inode.c9
-rw-r--r--fs/ntfs/inode.h2
-rw-r--r--fs/ntfs/super.c6
-rw-r--r--fs/ntfs/volume.h4
-rw-r--r--fs/ocfs2/cluster/netdebug.c2
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c24
-rw-r--r--fs/ocfs2/ioctl.c4
-rw-r--r--fs/ocfs2/move_extents.c4
-rw-r--r--fs/ocfs2/namei.c8
-rw-r--r--fs/ocfs2/super.c10
-rw-r--r--fs/ocfs2/xattr.c2
-rw-r--r--fs/ocfs2/xattr.h2
-rw-r--r--fs/omfs/dir.c6
-rw-r--r--fs/omfs/inode.c2
-rw-r--r--fs/omfs/omfs.h2
-rw-r--r--fs/open.c22
-rw-r--r--fs/openpromfs/inode.c1
-rw-r--r--fs/partitions/Kconfig251
-rw-r--r--fs/partitions/Makefile20
-rw-r--r--fs/partitions/acorn.c556
-rw-r--r--fs/partitions/acorn.h14
-rw-r--r--fs/partitions/amiga.c139
-rw-r--r--fs/partitions/amiga.h6
-rw-r--r--fs/partitions/atari.c149
-rw-r--r--fs/partitions/atari.h34
-rw-r--r--fs/partitions/check.c687
-rw-r--r--fs/partitions/check.h49
-rw-r--r--fs/partitions/efi.c675
-rw-r--r--fs/partitions/efi.h134
-rw-r--r--fs/partitions/ibm.c275
-rw-r--r--fs/partitions/ibm.h1
-rw-r--r--fs/partitions/karma.c57
-rw-r--r--fs/partitions/karma.h8
-rw-r--r--fs/partitions/ldm.c1570
-rw-r--r--fs/partitions/ldm.h215
-rw-r--r--fs/partitions/mac.c134
-rw-r--r--fs/partitions/mac.h44
-rw-r--r--fs/partitions/msdos.c552
-rw-r--r--fs/partitions/msdos.h8
-rw-r--r--fs/partitions/osf.c86
-rw-r--r--fs/partitions/osf.h7
-rw-r--r--fs/partitions/sgi.c82
-rw-r--r--fs/partitions/sgi.h8
-rw-r--r--fs/partitions/sun.c122
-rw-r--r--fs/partitions/sun.h8
-rw-r--r--fs/partitions/sysv68.c95
-rw-r--r--fs/partitions/sysv68.h1
-rw-r--r--fs/partitions/ultrix.c48
-rw-r--r--fs/partitions/ultrix.h5
-rw-r--r--fs/pipe.c7
-rw-r--r--fs/pnode.c120
-rw-r--r--fs/pnode.h36
-rw-r--r--fs/proc/base.c116
-rw-r--r--fs/proc/generic.c8
-rw-r--r--fs/proc/inode.c1
-rw-r--r--fs/proc/namespaces.c1
-rw-r--r--fs/proc/proc_net.c2
-rw-r--r--fs/proc_namespace.c333
-rw-r--r--fs/qnx4/inode.c1
-rw-r--r--fs/quota/dquot.c3
-rw-r--r--fs/quota/quota.c1
-rw-r--r--fs/ramfs/inode.c8
-rw-r--r--fs/reiserfs/bitmap.c91
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/reiserfs/ioctl.c8
-rw-r--r--fs/reiserfs/namei.c8
-rw-r--r--fs/reiserfs/super.c119
-rw-r--r--fs/reiserfs/xattr.c2
-rw-r--r--fs/romfs/super.c1
-rw-r--r--fs/seq_file.c10
-rw-r--r--fs/splice.c1
-rw-r--r--fs/squashfs/super.c1
-rw-r--r--fs/statfs.c21
-rw-r--r--fs/super.c70
-rw-r--r--fs/sync.c1
-rw-r--r--fs/sysfs/file.c4
-rw-r--r--fs/sysfs/group.c2
-rw-r--r--fs/sysfs/inode.c2
-rw-r--r--fs/sysfs/sysfs.h4
-rw-r--r--fs/sysv/ialloc.c2
-rw-r--r--fs/sysv/inode.c1
-rw-r--r--fs/sysv/itree.c2
-rw-r--r--fs/sysv/namei.c6
-rw-r--r--fs/sysv/sysv.h2
-rw-r--r--fs/ubifs/dir.c14
-rw-r--r--fs/ubifs/ioctl.c4
-rw-r--r--fs/ubifs/super.c5
-rw-r--r--fs/ubifs/ubifs.h2
-rw-r--r--fs/udf/ialloc.c2
-rw-r--r--fs/udf/inode.c6
-rw-r--r--fs/udf/namei.c6
-rw-r--r--fs/udf/super.c19
-rw-r--r--fs/udf/udf_sb.h8
-rw-r--r--fs/udf/udfdecl.h2
-rw-r--r--fs/ufs/ialloc.c2
-rw-r--r--fs/ufs/inode.c4
-rw-r--r--fs/ufs/namei.c6
-rw-r--r--fs/ufs/super.c5
-rw-r--r--fs/ufs/ufs.h2
-rw-r--r--fs/xattr.c4
-rw-r--r--fs/xfs/xfs_ialloc.c4
-rw-r--r--fs/xfs/xfs_ialloc.h2
-rw-r--r--fs/xfs/xfs_iget.c1
-rw-r--r--fs/xfs/xfs_inode.c4
-rw-r--r--fs/xfs/xfs_inode.h2
-rw-r--r--fs/xfs/xfs_ioctl.c8
-rw-r--r--fs/xfs/xfs_ioctl32.c8
-rw-r--r--fs/xfs/xfs_iops.c8
-rw-r--r--fs/xfs/xfs_super.c4
-rw-r--r--fs/xfs/xfs_utils.c2
-rw-r--r--fs/xfs/xfs_utils.h2
-rw-r--r--fs/xfs/xfs_vnodeops.c4
-rw-r--r--fs/xfs/xfs_vnodeops.h4
267 files changed, 1920 insertions, 7706 deletions
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index 410ffd6ceb5f..dc95a252523d 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -54,9 +54,9 @@ extern struct kmem_cache *v9fs_inode_cache;
54 54
55struct inode *v9fs_alloc_inode(struct super_block *sb); 55struct inode *v9fs_alloc_inode(struct super_block *sb);
56void v9fs_destroy_inode(struct inode *inode); 56void v9fs_destroy_inode(struct inode *inode);
57struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t); 57struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t);
58int v9fs_init_inode(struct v9fs_session_info *v9ses, 58int v9fs_init_inode(struct v9fs_session_info *v9ses,
59 struct inode *inode, int mode, dev_t); 59 struct inode *inode, umode_t mode, dev_t);
60void v9fs_evict_inode(struct inode *inode); 60void v9fs_evict_inode(struct inode *inode);
61ino_t v9fs_qid2ino(struct p9_qid *qid); 61ino_t v9fs_qid2ino(struct p9_qid *qid);
62void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *); 62void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 879ed8851737..e0f20de6aa2b 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -59,15 +59,13 @@ static const struct inode_operations v9fs_symlink_inode_operations;
59 * 59 *
60 */ 60 */
61 61
62static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) 62static u32 unixmode2p9mode(struct v9fs_session_info *v9ses, umode_t mode)
63{ 63{
64 int res; 64 int res;
65 res = mode & 0777; 65 res = mode & 0777;
66 if (S_ISDIR(mode)) 66 if (S_ISDIR(mode))
67 res |= P9_DMDIR; 67 res |= P9_DMDIR;
68 if (v9fs_proto_dotu(v9ses)) { 68 if (v9fs_proto_dotu(v9ses)) {
69 if (S_ISLNK(mode))
70 res |= P9_DMSYMLINK;
71 if (v9ses->nodev == 0) { 69 if (v9ses->nodev == 0) {
72 if (S_ISSOCK(mode)) 70 if (S_ISSOCK(mode))
73 res |= P9_DMSOCKET; 71 res |= P9_DMSOCKET;
@@ -85,10 +83,7 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
85 res |= P9_DMSETGID; 83 res |= P9_DMSETGID;
86 if ((mode & S_ISVTX) == S_ISVTX) 84 if ((mode & S_ISVTX) == S_ISVTX)
87 res |= P9_DMSETVTX; 85 res |= P9_DMSETVTX;
88 if ((mode & P9_DMLINK))
89 res |= P9_DMLINK;
90 } 86 }
91
92 return res; 87 return res;
93} 88}
94 89
@@ -99,11 +94,11 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
99 * @rdev: major number, minor number in case of device files. 94 * @rdev: major number, minor number in case of device files.
100 * 95 *
101 */ 96 */
102static int p9mode2unixmode(struct v9fs_session_info *v9ses, 97static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses,
103 struct p9_wstat *stat, dev_t *rdev) 98 struct p9_wstat *stat, dev_t *rdev)
104{ 99{
105 int res; 100 int res;
106 int mode = stat->mode; 101 u32 mode = stat->mode;
107 102
108 res = mode & S_IALLUGO; 103 res = mode & S_IALLUGO;
109 *rdev = 0; 104 *rdev = 0;
@@ -251,7 +246,6 @@ struct inode *v9fs_alloc_inode(struct super_block *sb)
251static void v9fs_i_callback(struct rcu_head *head) 246static void v9fs_i_callback(struct rcu_head *head)
252{ 247{
253 struct inode *inode = container_of(head, struct inode, i_rcu); 248 struct inode *inode = container_of(head, struct inode, i_rcu);
254 INIT_LIST_HEAD(&inode->i_dentry);
255 kmem_cache_free(v9fs_inode_cache, V9FS_I(inode)); 249 kmem_cache_free(v9fs_inode_cache, V9FS_I(inode));
256} 250}
257 251
@@ -261,7 +255,7 @@ void v9fs_destroy_inode(struct inode *inode)
261} 255}
262 256
263int v9fs_init_inode(struct v9fs_session_info *v9ses, 257int v9fs_init_inode(struct v9fs_session_info *v9ses,
264 struct inode *inode, int mode, dev_t rdev) 258 struct inode *inode, umode_t mode, dev_t rdev)
265{ 259{
266 int err = 0; 260 int err = 0;
267 261
@@ -335,7 +329,7 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
335 329
336 break; 330 break;
337 default: 331 default:
338 P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n", 332 P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%hx S_IFMT 0x%x\n",
339 mode, mode & S_IFMT); 333 mode, mode & S_IFMT);
340 err = -EINVAL; 334 err = -EINVAL;
341 goto error; 335 goto error;
@@ -352,13 +346,13 @@ error:
352 * 346 *
353 */ 347 */
354 348
355struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t rdev) 349struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev)
356{ 350{
357 int err; 351 int err;
358 struct inode *inode; 352 struct inode *inode;
359 struct v9fs_session_info *v9ses = sb->s_fs_info; 353 struct v9fs_session_info *v9ses = sb->s_fs_info;
360 354
361 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); 355 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %ho\n", sb, mode);
362 356
363 inode = new_inode(sb); 357 inode = new_inode(sb);
364 if (!inode) { 358 if (!inode) {
@@ -492,7 +486,8 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
492 int new) 486 int new)
493{ 487{
494 dev_t rdev; 488 dev_t rdev;
495 int retval, umode; 489 int retval;
490 umode_t umode;
496 unsigned long i_ino; 491 unsigned long i_ino;
497 struct inode *inode; 492 struct inode *inode;
498 struct v9fs_session_info *v9ses = sb->s_fs_info; 493 struct v9fs_session_info *v9ses = sb->s_fs_info;
@@ -703,7 +698,7 @@ error:
703 */ 698 */
704 699
705static int 700static int
706v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, 701v9fs_vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
707 struct nameidata *nd) 702 struct nameidata *nd)
708{ 703{
709 int err; 704 int err;
@@ -786,7 +781,7 @@ error:
786 * 781 *
787 */ 782 */
788 783
789static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 784static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
790{ 785{
791 int err; 786 int err;
792 u32 perm; 787 u32 perm;
@@ -1131,7 +1126,7 @@ void
1131v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, 1126v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
1132 struct super_block *sb) 1127 struct super_block *sb)
1133{ 1128{
1134 mode_t mode; 1129 umode_t mode;
1135 char ext[32]; 1130 char ext[32];
1136 char tag_name[14]; 1131 char tag_name[14];
1137 unsigned int i_nlink; 1132 unsigned int i_nlink;
@@ -1304,9 +1299,8 @@ v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
1304 */ 1299 */
1305 1300
1306static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, 1301static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1307 int mode, const char *extension) 1302 u32 perm, const char *extension)
1308{ 1303{
1309 u32 perm;
1310 struct p9_fid *fid; 1304 struct p9_fid *fid;
1311 struct v9fs_session_info *v9ses; 1305 struct v9fs_session_info *v9ses;
1312 1306
@@ -1316,7 +1310,6 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1316 return -EPERM; 1310 return -EPERM;
1317 } 1311 }
1318 1312
1319 perm = unixmode2p9mode(v9ses, mode);
1320 fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm, 1313 fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm,
1321 P9_OREAD); 1314 P9_OREAD);
1322 if (IS_ERR(fid)) 1315 if (IS_ERR(fid))
@@ -1343,7 +1336,7 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1343 P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, 1336 P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino,
1344 dentry->d_name.name, symname); 1337 dentry->d_name.name, symname);
1345 1338
1346 return v9fs_vfs_mkspecial(dir, dentry, S_IFLNK, symname); 1339 return v9fs_vfs_mkspecial(dir, dentry, P9_DMSYMLINK, symname);
1347} 1340}
1348 1341
1349/** 1342/**
@@ -1398,13 +1391,15 @@ clunk_fid:
1398 */ 1391 */
1399 1392
1400static int 1393static int
1401v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) 1394v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev)
1402{ 1395{
1396 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
1403 int retval; 1397 int retval;
1404 char *name; 1398 char *name;
1399 u32 perm;
1405 1400
1406 P9_DPRINTK(P9_DEBUG_VFS, 1401 P9_DPRINTK(P9_DEBUG_VFS,
1407 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, 1402 " %lu,%s mode: %hx MAJOR: %u MINOR: %u\n", dir->i_ino,
1408 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); 1403 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
1409 1404
1410 if (!new_valid_dev(rdev)) 1405 if (!new_valid_dev(rdev))
@@ -1427,7 +1422,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1427 return -EINVAL; 1422 return -EINVAL;
1428 } 1423 }
1429 1424
1430 retval = v9fs_vfs_mkspecial(dir, dentry, mode, name); 1425 perm = unixmode2p9mode(v9ses, mode);
1426 retval = v9fs_vfs_mkspecial(dir, dentry, perm, name);
1431 __putname(name); 1427 __putname(name);
1432 1428
1433 return retval; 1429 return retval;
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 0b5745e21946..8ef152ac6a16 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -48,7 +48,7 @@
48#include "acl.h" 48#include "acl.h"
49 49
50static int 50static int
51v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, 51v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
52 dev_t rdev); 52 dev_t rdev);
53 53
54/** 54/**
@@ -253,7 +253,7 @@ int v9fs_open_to_dotl_flags(int flags)
253 */ 253 */
254 254
255static int 255static int
256v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, 256v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
257 struct nameidata *nd) 257 struct nameidata *nd)
258{ 258{
259 int err = 0; 259 int err = 0;
@@ -284,7 +284,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
284 284
285 name = (char *) dentry->d_name.name; 285 name = (char *) dentry->d_name.name;
286 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x " 286 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x "
287 "mode:0x%x\n", name, flags, omode); 287 "mode:0x%hx\n", name, flags, omode);
288 288
289 dfid = v9fs_fid_lookup(dentry->d_parent); 289 dfid = v9fs_fid_lookup(dentry->d_parent);
290 if (IS_ERR(dfid)) { 290 if (IS_ERR(dfid)) {
@@ -395,7 +395,7 @@ err_clunk_old_fid:
395 */ 395 */
396 396
397static int v9fs_vfs_mkdir_dotl(struct inode *dir, 397static int v9fs_vfs_mkdir_dotl(struct inode *dir,
398 struct dentry *dentry, int omode) 398 struct dentry *dentry, umode_t omode)
399{ 399{
400 int err; 400 int err;
401 struct v9fs_session_info *v9ses; 401 struct v9fs_session_info *v9ses;
@@ -594,7 +594,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
594void 594void
595v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) 595v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
596{ 596{
597 mode_t mode; 597 umode_t mode;
598 struct v9fs_inode *v9inode = V9FS_I(inode); 598 struct v9fs_inode *v9inode = V9FS_I(inode);
599 599
600 if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) { 600 if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {
@@ -799,7 +799,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
799 * 799 *
800 */ 800 */
801static int 801static int
802v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, 802v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
803 dev_t rdev) 803 dev_t rdev)
804{ 804{
805 int err; 805 int err;
@@ -814,7 +814,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
814 struct posix_acl *dacl = NULL, *pacl = NULL; 814 struct posix_acl *dacl = NULL, *pacl = NULL;
815 815
816 P9_DPRINTK(P9_DEBUG_VFS, 816 P9_DPRINTK(P9_DEBUG_VFS,
817 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, 817 " %lu,%s mode: %hx MAJOR: %u MINOR: %u\n", dir->i_ino,
818 dentry->d_name.name, omode, MAJOR(rdev), MINOR(rdev)); 818 dentry->d_name.name, omode, MAJOR(rdev), MINOR(rdev));
819 819
820 if (!new_valid_dev(rdev)) 820 if (!new_valid_dev(rdev))
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index c70251d47ed1..f68ff65a32a5 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -117,7 +117,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags,
117 struct inode *inode = NULL; 117 struct inode *inode = NULL;
118 struct dentry *root = NULL; 118 struct dentry *root = NULL;
119 struct v9fs_session_info *v9ses = NULL; 119 struct v9fs_session_info *v9ses = NULL;
120 int mode = S_IRWXUGO | S_ISVTX; 120 umode_t mode = S_IRWXUGO | S_ISVTX;
121 struct p9_fid *fid; 121 struct p9_fid *fid;
122 int retval = 0; 122 int retval = 0;
123 123
diff --git a/fs/Kconfig b/fs/Kconfig
index 5f4c45d4aa10..30145d886bc2 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -266,14 +266,6 @@ source "fs/9p/Kconfig"
266 266
267endif # NETWORK_FILESYSTEMS 267endif # NETWORK_FILESYSTEMS
268 268
269if BLOCK
270menu "Partition Types"
271
272source "fs/partitions/Kconfig"
273
274endmenu
275endif
276
277source "fs/nls/Kconfig" 269source "fs/nls/Kconfig"
278source "fs/dlm/Kconfig" 270source "fs/dlm/Kconfig"
279 271
diff --git a/fs/Makefile b/fs/Makefile
index d2c3353d5477..93804d4d66e1 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -19,6 +19,8 @@ else
19obj-y += no-block.o 19obj-y += no-block.o
20endif 20endif
21 21
22obj-$(CONFIG_PROC_FS) += proc_namespace.o
23
22obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o 24obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o
23obj-y += notify/ 25obj-y += notify/
24obj-$(CONFIG_EPOLL) += eventpoll.o 26obj-$(CONFIG_EPOLL) += eventpoll.o
@@ -52,7 +54,6 @@ obj-$(CONFIG_FHANDLE) += fhandle.o
52obj-y += quota/ 54obj-y += quota/
53 55
54obj-$(CONFIG_PROC_FS) += proc/ 56obj-$(CONFIG_PROC_FS) += proc/
55obj-y += partitions/
56obj-$(CONFIG_SYSFS) += sysfs/ 57obj-$(CONFIG_SYSFS) += sysfs/
57obj-$(CONFIG_CONFIGFS_FS) += configfs/ 58obj-$(CONFIG_CONFIGFS_FS) += configfs/
58obj-y += devpts/ 59obj-y += devpts/
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index c8bf36a1996a..8e3b36ace305 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -126,9 +126,9 @@ static void adfs_put_super(struct super_block *sb)
126 sb->s_fs_info = NULL; 126 sb->s_fs_info = NULL;
127} 127}
128 128
129static int adfs_show_options(struct seq_file *seq, struct vfsmount *mnt) 129static int adfs_show_options(struct seq_file *seq, struct dentry *root)
130{ 130{
131 struct adfs_sb_info *asb = ADFS_SB(mnt->mnt_sb); 131 struct adfs_sb_info *asb = ADFS_SB(root->d_sb);
132 132
133 if (asb->s_uid != 0) 133 if (asb->s_uid != 0)
134 seq_printf(seq, ",uid=%u", asb->s_uid); 134 seq_printf(seq, ",uid=%u", asb->s_uid);
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index c2b9c79eb64e..45a0ce45d7b4 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -136,7 +136,7 @@ extern int affs_remove_header(struct dentry *dentry);
136extern u32 affs_checksum_block(struct super_block *sb, struct buffer_head *bh); 136extern u32 affs_checksum_block(struct super_block *sb, struct buffer_head *bh);
137extern void affs_fix_checksum(struct super_block *sb, struct buffer_head *bh); 137extern void affs_fix_checksum(struct super_block *sb, struct buffer_head *bh);
138extern void secs_to_datestamp(time_t secs, struct affs_date *ds); 138extern void secs_to_datestamp(time_t secs, struct affs_date *ds);
139extern mode_t prot_to_mode(u32 prot); 139extern umode_t prot_to_mode(u32 prot);
140extern void mode_to_prot(struct inode *inode); 140extern void mode_to_prot(struct inode *inode);
141extern void affs_error(struct super_block *sb, const char *function, const char *fmt, ...); 141extern void affs_error(struct super_block *sb, const char *function, const char *fmt, ...);
142extern void affs_warning(struct super_block *sb, const char *function, const char *fmt, ...); 142extern void affs_warning(struct super_block *sb, const char *function, const char *fmt, ...);
@@ -156,8 +156,8 @@ extern void affs_free_bitmap(struct super_block *sb);
156extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len); 156extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len);
157extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *); 157extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *);
158extern int affs_unlink(struct inode *dir, struct dentry *dentry); 158extern int affs_unlink(struct inode *dir, struct dentry *dentry);
159extern int affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *); 159extern int affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *);
160extern int affs_mkdir(struct inode *dir, struct dentry *dentry, int mode); 160extern int affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
161extern int affs_rmdir(struct inode *dir, struct dentry *dentry); 161extern int affs_rmdir(struct inode *dir, struct dentry *dentry);
162extern int affs_link(struct dentry *olddentry, struct inode *dir, 162extern int affs_link(struct dentry *olddentry, struct inode *dir,
163 struct dentry *dentry); 163 struct dentry *dentry);
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index de37ec842340..52a6407682e6 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -390,10 +390,10 @@ secs_to_datestamp(time_t secs, struct affs_date *ds)
390 ds->ticks = cpu_to_be32(secs * 50); 390 ds->ticks = cpu_to_be32(secs * 50);
391} 391}
392 392
393mode_t 393umode_t
394prot_to_mode(u32 prot) 394prot_to_mode(u32 prot)
395{ 395{
396 int mode = 0; 396 umode_t mode = 0;
397 397
398 if (!(prot & FIBF_NOWRITE)) 398 if (!(prot & FIBF_NOWRITE))
399 mode |= S_IWUSR; 399 mode |= S_IWUSR;
@@ -421,7 +421,7 @@ void
421mode_to_prot(struct inode *inode) 421mode_to_prot(struct inode *inode)
422{ 422{
423 u32 prot = AFFS_I(inode)->i_protect; 423 u32 prot = AFFS_I(inode)->i_protect;
424 mode_t mode = inode->i_mode; 424 umode_t mode = inode->i_mode;
425 425
426 if (!(mode & S_IXUSR)) 426 if (!(mode & S_IXUSR))
427 prot |= FIBF_NOEXECUTE; 427 prot |= FIBF_NOEXECUTE;
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 780a11dc6318..47806940aac0 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -255,13 +255,13 @@ affs_unlink(struct inode *dir, struct dentry *dentry)
255} 255}
256 256
257int 257int
258affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) 258affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd)
259{ 259{
260 struct super_block *sb = dir->i_sb; 260 struct super_block *sb = dir->i_sb;
261 struct inode *inode; 261 struct inode *inode;
262 int error; 262 int error;
263 263
264 pr_debug("AFFS: create(%lu,\"%.*s\",0%o)\n",dir->i_ino,(int)dentry->d_name.len, 264 pr_debug("AFFS: create(%lu,\"%.*s\",0%ho)\n",dir->i_ino,(int)dentry->d_name.len,
265 dentry->d_name.name,mode); 265 dentry->d_name.name,mode);
266 266
267 inode = affs_new_inode(dir); 267 inode = affs_new_inode(dir);
@@ -285,12 +285,12 @@ affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata
285} 285}
286 286
287int 287int
288affs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 288affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
289{ 289{
290 struct inode *inode; 290 struct inode *inode;
291 int error; 291 int error;
292 292
293 pr_debug("AFFS: mkdir(%lu,\"%.*s\",0%o)\n",dir->i_ino, 293 pr_debug("AFFS: mkdir(%lu,\"%.*s\",0%ho)\n",dir->i_ino,
294 (int)dentry->d_name.len,dentry->d_name.name,mode); 294 (int)dentry->d_name.len,dentry->d_name.name,mode);
295 295
296 inode = affs_new_inode(dir); 296 inode = affs_new_inode(dir);
diff --git a/fs/affs/super.c b/fs/affs/super.c
index b31507d0f9b9..8ba73fed7964 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -98,7 +98,6 @@ static struct inode *affs_alloc_inode(struct super_block *sb)
98static void affs_i_callback(struct rcu_head *head) 98static void affs_i_callback(struct rcu_head *head)
99{ 99{
100 struct inode *inode = container_of(head, struct inode, i_rcu); 100 struct inode *inode = container_of(head, struct inode, i_rcu);
101 INIT_LIST_HEAD(&inode->i_dentry);
102 kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); 101 kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
103} 102}
104 103
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 1b0b19550015..e22dc4b4a503 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -28,9 +28,9 @@ static int afs_d_delete(const struct dentry *dentry);
28static void afs_d_release(struct dentry *dentry); 28static void afs_d_release(struct dentry *dentry);
29static int afs_lookup_filldir(void *_cookie, const char *name, int nlen, 29static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
30 loff_t fpos, u64 ino, unsigned dtype); 30 loff_t fpos, u64 ino, unsigned dtype);
31static int afs_create(struct inode *dir, struct dentry *dentry, int mode, 31static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
32 struct nameidata *nd); 32 struct nameidata *nd);
33static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode); 33static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
34static int afs_rmdir(struct inode *dir, struct dentry *dentry); 34static int afs_rmdir(struct inode *dir, struct dentry *dentry);
35static int afs_unlink(struct inode *dir, struct dentry *dentry); 35static int afs_unlink(struct inode *dir, struct dentry *dentry);
36static int afs_link(struct dentry *from, struct inode *dir, 36static int afs_link(struct dentry *from, struct inode *dir,
@@ -764,7 +764,7 @@ static void afs_d_release(struct dentry *dentry)
764/* 764/*
765 * create a directory on an AFS filesystem 765 * create a directory on an AFS filesystem
766 */ 766 */
767static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 767static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
768{ 768{
769 struct afs_file_status status; 769 struct afs_file_status status;
770 struct afs_callback cb; 770 struct afs_callback cb;
@@ -777,7 +777,7 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
777 777
778 dvnode = AFS_FS_I(dir); 778 dvnode = AFS_FS_I(dir);
779 779
780 _enter("{%x:%u},{%s},%o", 780 _enter("{%x:%u},{%s},%ho",
781 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); 781 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
782 782
783 ret = -ENAMETOOLONG; 783 ret = -ENAMETOOLONG;
@@ -948,7 +948,7 @@ error:
948/* 948/*
949 * create a regular file on an AFS filesystem 949 * create a regular file on an AFS filesystem
950 */ 950 */
951static int afs_create(struct inode *dir, struct dentry *dentry, int mode, 951static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
952 struct nameidata *nd) 952 struct nameidata *nd)
953{ 953{
954 struct afs_file_status status; 954 struct afs_file_status status;
@@ -962,7 +962,7 @@ static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
962 962
963 dvnode = AFS_FS_I(dir); 963 dvnode = AFS_FS_I(dir);
964 964
965 _enter("{%x:%u},{%s},%o,", 965 _enter("{%x:%u},{%s},%ho,",
966 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); 966 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
967 967
968 ret = -ENAMETOOLONG; 968 ret = -ENAMETOOLONG;
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index aa59184151d0..8f4ce2658b7d 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -242,7 +242,7 @@ struct vfsmount *afs_d_automount(struct path *path)
242{ 242{
243 struct vfsmount *newmnt; 243 struct vfsmount *newmnt;
244 244
245 _enter("{%s,%s}", path->mnt->mnt_devname, path->dentry->d_name.name); 245 _enter("{%s}", path->dentry->d_name.name);
246 246
247 newmnt = afs_mntpt_do_automount(path->dentry); 247 newmnt = afs_mntpt_do_automount(path->dentry);
248 if (IS_ERR(newmnt)) 248 if (IS_ERR(newmnt))
@@ -252,7 +252,7 @@ struct vfsmount *afs_d_automount(struct path *path)
252 mnt_set_expiry(newmnt, &afs_vfsmounts); 252 mnt_set_expiry(newmnt, &afs_vfsmounts);
253 queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer, 253 queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer,
254 afs_mntpt_expiry_timeout * HZ); 254 afs_mntpt_expiry_timeout * HZ);
255 _leave(" = %p {%s}", newmnt, newmnt->mnt_devname); 255 _leave(" = %p", newmnt);
256 return newmnt; 256 return newmnt;
257} 257}
258 258
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 356dcf0929e8..983ec59fc80d 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -495,7 +495,6 @@ static void afs_i_callback(struct rcu_head *head)
495{ 495{
496 struct inode *inode = container_of(head, struct inode, i_rcu); 496 struct inode *inode = container_of(head, struct inode, i_rcu);
497 struct afs_vnode *vnode = AFS_FS_I(inode); 497 struct afs_vnode *vnode = AFS_FS_I(inode);
498 INIT_LIST_HEAD(&inode->i_dentry);
499 kmem_cache_free(afs_inode_cachep, vnode); 498 kmem_cache_free(afs_inode_cachep, vnode);
500} 499}
501 500
diff --git a/fs/attr.c b/fs/attr.c
index 7ee7ba488313..95053ad8abcc 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -166,7 +166,7 @@ EXPORT_SYMBOL(setattr_copy);
166int notify_change(struct dentry * dentry, struct iattr * attr) 166int notify_change(struct dentry * dentry, struct iattr * attr)
167{ 167{
168 struct inode *inode = dentry->d_inode; 168 struct inode *inode = dentry->d_inode;
169 mode_t mode = inode->i_mode; 169 umode_t mode = inode->i_mode;
170 int error; 170 int error;
171 struct timespec now; 171 struct timespec now;
172 unsigned int ia_valid = attr->ia_valid; 172 unsigned int ia_valid = attr->ia_valid;
@@ -177,7 +177,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
177 } 177 }
178 178
179 if ((ia_valid & ATTR_MODE)) { 179 if ((ia_valid & ATTR_MODE)) {
180 mode_t amode = attr->ia_mode; 180 umode_t amode = attr->ia_mode;
181 /* Flag setting protected by i_mutex */ 181 /* Flag setting protected by i_mutex */
182 if (is_sxid(amode)) 182 if (is_sxid(amode))
183 inode->i_flags &= ~S_NOSEC; 183 inode->i_flags &= ~S_NOSEC;
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 326dc08d3e3f..5869d4e974a9 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -155,7 +155,7 @@ static inline int autofs4_ispending(struct dentry *dentry)
155 return 0; 155 return 0;
156} 156}
157 157
158struct inode *autofs4_get_inode(struct super_block *, mode_t); 158struct inode *autofs4_get_inode(struct super_block *, umode_t);
159void autofs4_free_ino(struct autofs_info *); 159void autofs4_free_ino(struct autofs_info *);
160 160
161/* Expiration */ 161/* Expiration */
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 509fe1eb66ae..76741d8d7786 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -194,7 +194,7 @@ static int find_autofs_mount(const char *pathname,
194 return err; 194 return err;
195 err = -ENOENT; 195 err = -ENOENT;
196 while (path.dentry == path.mnt->mnt_root) { 196 while (path.dentry == path.mnt->mnt_root) {
197 if (path.mnt->mnt_sb->s_magic == AUTOFS_SUPER_MAGIC) { 197 if (path.dentry->d_sb->s_magic == AUTOFS_SUPER_MAGIC) {
198 if (test(&path, data)) { 198 if (test(&path, data)) {
199 path_get(&path); 199 path_get(&path);
200 if (!err) /* already found some */ 200 if (!err) /* already found some */
@@ -212,7 +212,7 @@ static int find_autofs_mount(const char *pathname,
212 212
213static int test_by_dev(struct path *path, void *p) 213static int test_by_dev(struct path *path, void *p)
214{ 214{
215 return path->mnt->mnt_sb->s_dev == *(dev_t *)p; 215 return path->dentry->d_sb->s_dev == *(dev_t *)p;
216} 216}
217 217
218static int test_by_type(struct path *path, void *p) 218static int test_by_type(struct path *path, void *p)
@@ -538,11 +538,11 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
538 err = find_autofs_mount(name, &path, test_by_type, &type); 538 err = find_autofs_mount(name, &path, test_by_type, &type);
539 if (err) 539 if (err)
540 goto out; 540 goto out;
541 devid = new_encode_dev(path.mnt->mnt_sb->s_dev); 541 devid = new_encode_dev(path.dentry->d_sb->s_dev);
542 err = 0; 542 err = 0;
543 if (path.mnt->mnt_root == path.dentry) { 543 if (path.mnt->mnt_root == path.dentry) {
544 err = 1; 544 err = 1;
545 magic = path.mnt->mnt_sb->s_magic; 545 magic = path.dentry->d_sb->s_magic;
546 } 546 }
547 } else { 547 } else {
548 dev_t dev = sbi->sb->s_dev; 548 dev_t dev = sbi->sb->s_dev;
@@ -556,7 +556,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
556 err = have_submounts(path.dentry); 556 err = have_submounts(path.dentry);
557 557
558 if (follow_down_one(&path)) 558 if (follow_down_one(&path))
559 magic = path.mnt->mnt_sb->s_magic; 559 magic = path.dentry->d_sb->s_magic;
560 } 560 }
561 561
562 param->ismountpoint.out.devid = devid; 562 param->ismountpoint.out.devid = devid;
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 8179f1ab8175..2ba44c79d548 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -70,10 +70,10 @@ out_kill_sb:
70 kill_litter_super(sb); 70 kill_litter_super(sb);
71} 71}
72 72
73static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt) 73static int autofs4_show_options(struct seq_file *m, struct dentry *root)
74{ 74{
75 struct autofs_sb_info *sbi = autofs4_sbi(mnt->mnt_sb); 75 struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb);
76 struct inode *root_inode = mnt->mnt_sb->s_root->d_inode; 76 struct inode *root_inode = root->d_sb->s_root->d_inode;
77 77
78 if (!sbi) 78 if (!sbi)
79 return 0; 79 return 0;
@@ -326,7 +326,7 @@ fail_unlock:
326 return -EINVAL; 326 return -EINVAL;
327} 327}
328 328
329struct inode *autofs4_get_inode(struct super_block *sb, mode_t mode) 329struct inode *autofs4_get_inode(struct super_block *sb, umode_t mode)
330{ 330{
331 struct inode *inode = new_inode(sb); 331 struct inode *inode = new_inode(sb);
332 332
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index f55ae23b137e..75e5f1c8e028 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -26,7 +26,7 @@
26static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); 26static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
27static int autofs4_dir_unlink(struct inode *,struct dentry *); 27static int autofs4_dir_unlink(struct inode *,struct dentry *);
28static int autofs4_dir_rmdir(struct inode *,struct dentry *); 28static int autofs4_dir_rmdir(struct inode *,struct dentry *);
29static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); 29static int autofs4_dir_mkdir(struct inode *,struct dentry *,umode_t);
30static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); 30static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long);
31#ifdef CONFIG_COMPAT 31#ifdef CONFIG_COMPAT
32static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long); 32static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long);
@@ -699,7 +699,7 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
699 return 0; 699 return 0;
700} 700}
701 701
702static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode) 702static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
703{ 703{
704 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); 704 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
705 struct autofs_info *ino = autofs4_dentry_ino(dentry); 705 struct autofs_info *ino = autofs4_dentry_ino(dentry);
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 9205cf25f1c6..22e9a78872ff 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -173,7 +173,7 @@ static const struct file_operations bad_file_ops =
173}; 173};
174 174
175static int bad_inode_create (struct inode *dir, struct dentry *dentry, 175static int bad_inode_create (struct inode *dir, struct dentry *dentry,
176 int mode, struct nameidata *nd) 176 umode_t mode, struct nameidata *nd)
177{ 177{
178 return -EIO; 178 return -EIO;
179} 179}
@@ -202,7 +202,7 @@ static int bad_inode_symlink (struct inode *dir, struct dentry *dentry,
202} 202}
203 203
204static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry, 204static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry,
205 int mode) 205 umode_t mode)
206{ 206{
207 return -EIO; 207 return -EIO;
208} 208}
@@ -213,7 +213,7 @@ static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
213} 213}
214 214
215static int bad_inode_mknod (struct inode *dir, struct dentry *dentry, 215static int bad_inode_mknod (struct inode *dir, struct dentry *dentry,
216 int mode, dev_t rdev) 216 umode_t mode, dev_t rdev)
217{ 217{
218 return -EIO; 218 return -EIO;
219} 219}
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 8342ca67abcd..6e6d536767fe 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -286,7 +286,6 @@ befs_alloc_inode(struct super_block *sb)
286static void befs_i_callback(struct rcu_head *head) 286static void befs_i_callback(struct rcu_head *head)
287{ 287{
288 struct inode *inode = container_of(head, struct inode, i_rcu); 288 struct inode *inode = container_of(head, struct inode, i_rcu);
289 INIT_LIST_HEAD(&inode->i_dentry);
290 kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); 289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode));
291} 290}
292 291
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 9cc074019479..d12c7966db27 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -84,7 +84,7 @@ const struct file_operations bfs_dir_operations = {
84 84
85extern void dump_imap(const char *, struct super_block *); 85extern void dump_imap(const char *, struct super_block *);
86 86
87static int bfs_create(struct inode *dir, struct dentry *dentry, int mode, 87static int bfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
88 struct nameidata *nd) 88 struct nameidata *nd)
89{ 89{
90 int err; 90 int err;
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 697af5bf70b3..b0391bc402b1 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -251,7 +251,6 @@ static struct inode *bfs_alloc_inode(struct super_block *sb)
251static void bfs_i_callback(struct rcu_head *head) 251static void bfs_i_callback(struct rcu_head *head)
252{ 252{
253 struct inode *inode = container_of(head, struct inode, i_rcu); 253 struct inode *inode = container_of(head, struct inode, i_rcu);
254 INIT_LIST_HEAD(&inode->i_dentry);
255 kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); 254 kmem_cache_free(bfs_inode_cachep, BFS_I(inode));
256} 255}
257 256
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 1e9edbdeda7e..a9198dfd5f85 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -560,7 +560,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
560 break; 560 break;
561 case 2: set_bit(Enabled, &e->flags); 561 case 2: set_bit(Enabled, &e->flags);
562 break; 562 break;
563 case 3: root = dget(file->f_path.mnt->mnt_sb->s_root); 563 case 3: root = dget(file->f_path.dentry->d_sb->s_root);
564 mutex_lock(&root->d_inode->i_mutex); 564 mutex_lock(&root->d_inode->i_mutex);
565 565
566 kill_node(e); 566 kill_node(e);
@@ -587,7 +587,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
587 Node *e; 587 Node *e;
588 struct inode *inode; 588 struct inode *inode;
589 struct dentry *root, *dentry; 589 struct dentry *root, *dentry;
590 struct super_block *sb = file->f_path.mnt->mnt_sb; 590 struct super_block *sb = file->f_path.dentry->d_sb;
591 int err = 0; 591 int err = 0;
592 592
593 e = create_entry(buffer, count); 593 e = create_entry(buffer, count);
@@ -666,7 +666,7 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
666 switch (res) { 666 switch (res) {
667 case 1: enabled = 0; break; 667 case 1: enabled = 0; break;
668 case 2: enabled = 1; break; 668 case 2: enabled = 1; break;
669 case 3: root = dget(file->f_path.mnt->mnt_sb->s_root); 669 case 3: root = dget(file->f_path.dentry->d_sb->s_root);
670 mutex_lock(&root->d_inode->i_mutex); 670 mutex_lock(&root->d_inode->i_mutex);
671 671
672 while (!list_empty(&entries)) 672 while (!list_empty(&entries))
diff --git a/fs/block_dev.c b/fs/block_dev.c
index b07f1da1de4e..69a5b6fbee2b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/blkpg.h> 18#include <linux/blkpg.h>
19#include <linux/buffer_head.h> 19#include <linux/buffer_head.h>
20#include <linux/swap.h>
20#include <linux/pagevec.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>
@@ -25,6 +26,7 @@
25#include <linux/namei.h> 26#include <linux/namei.h>
26#include <linux/log2.h> 27#include <linux/log2.h>
27#include <linux/kmemleak.h> 28#include <linux/kmemleak.h>
29#include <linux/cleancache.h>
28#include <asm/uaccess.h> 30#include <asm/uaccess.h>
29#include "internal.h" 31#include "internal.h"
30 32
@@ -82,13 +84,35 @@ static sector_t max_block(struct block_device *bdev)
82} 84}
83 85
84/* Kill _all_ buffers and pagecache , dirty or not.. */ 86/* Kill _all_ buffers and pagecache , dirty or not.. */
85static void kill_bdev(struct block_device *bdev) 87void kill_bdev(struct block_device *bdev)
86{ 88{
87 if (bdev->bd_inode->i_mapping->nrpages == 0) 89 struct address_space *mapping = bdev->bd_inode->i_mapping;
90
91 if (mapping->nrpages == 0)
88 return; 92 return;
93
89 invalidate_bh_lrus(); 94 invalidate_bh_lrus();
90 truncate_inode_pages(bdev->bd_inode->i_mapping, 0); 95 truncate_inode_pages(mapping, 0);
91} 96}
97EXPORT_SYMBOL(kill_bdev);
98
99/* Invalidate clean unused buffers and pagecache. */
100void invalidate_bdev(struct block_device *bdev)
101{
102 struct address_space *mapping = bdev->bd_inode->i_mapping;
103
104 if (mapping->nrpages == 0)
105 return;
106
107 invalidate_bh_lrus();
108 lru_add_drain_all(); /* make sure all lru add caches are flushed */
109 invalidate_mapping_pages(mapping, 0, -1);
110 /* 99% of the time, we don't need to flush the cleancache on the bdev.
111 * But, for the strange corners, lets be cautious
112 */
113 cleancache_flush_inode(mapping);
114}
115EXPORT_SYMBOL(invalidate_bdev);
92 116
93int set_blocksize(struct block_device *bdev, int size) 117int set_blocksize(struct block_device *bdev, int size)
94{ 118{
@@ -425,7 +449,6 @@ static void bdev_i_callback(struct rcu_head *head)
425 struct inode *inode = container_of(head, struct inode, i_rcu); 449 struct inode *inode = container_of(head, struct inode, i_rcu);
426 struct bdev_inode *bdi = BDEV_I(inode); 450 struct bdev_inode *bdi = BDEV_I(inode);
427 451
428 INIT_LIST_HEAD(&inode->i_dentry);
429 kmem_cache_free(bdev_cachep, bdi); 452 kmem_cache_free(bdev_cachep, bdi);
430} 453}
431 454
@@ -493,7 +516,7 @@ static struct file_system_type bd_type = {
493 .kill_sb = kill_anon_super, 516 .kill_sb = kill_anon_super,
494}; 517};
495 518
496struct super_block *blockdev_superblock __read_mostly; 519static struct super_block *blockdev_superblock __read_mostly;
497 520
498void __init bdev_cache_init(void) 521void __init bdev_cache_init(void)
499{ 522{
@@ -639,6 +662,11 @@ static struct block_device *bd_acquire(struct inode *inode)
639 return bdev; 662 return bdev;
640} 663}
641 664
665static inline int sb_is_blkdev_sb(struct super_block *sb)
666{
667 return sb == blockdev_superblock;
668}
669
642/* Call when you free inode */ 670/* Call when you free inode */
643 671
644void bd_forget(struct inode *inode) 672void bd_forget(struct inode *inode)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fd1a06df5bc6..2f426a51e60d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4412,8 +4412,8 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
4412 struct btrfs_root *root, 4412 struct btrfs_root *root,
4413 struct inode *dir, 4413 struct inode *dir,
4414 const char *name, int name_len, 4414 const char *name, int name_len,
4415 u64 ref_objectid, u64 objectid, int mode, 4415 u64 ref_objectid, u64 objectid,
4416 u64 *index) 4416 umode_t mode, u64 *index)
4417{ 4417{
4418 struct inode *inode; 4418 struct inode *inode;
4419 struct btrfs_inode_item *inode_item; 4419 struct btrfs_inode_item *inode_item;
@@ -4596,7 +4596,7 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
4596} 4596}
4597 4597
4598static int btrfs_mknod(struct inode *dir, struct dentry *dentry, 4598static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
4599 int mode, dev_t rdev) 4599 umode_t mode, dev_t rdev)
4600{ 4600{
4601 struct btrfs_trans_handle *trans; 4601 struct btrfs_trans_handle *trans;
4602 struct btrfs_root *root = BTRFS_I(dir)->root; 4602 struct btrfs_root *root = BTRFS_I(dir)->root;
@@ -4665,7 +4665,7 @@ out_unlock:
4665} 4665}
4666 4666
4667static int btrfs_create(struct inode *dir, struct dentry *dentry, 4667static int btrfs_create(struct inode *dir, struct dentry *dentry,
4668 int mode, struct nameidata *nd) 4668 umode_t mode, struct nameidata *nd)
4669{ 4669{
4670 struct btrfs_trans_handle *trans; 4670 struct btrfs_trans_handle *trans;
4671 struct btrfs_root *root = BTRFS_I(dir)->root; 4671 struct btrfs_root *root = BTRFS_I(dir)->root;
@@ -4792,7 +4792,7 @@ fail:
4792 return err; 4792 return err;
4793} 4793}
4794 4794
4795static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 4795static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
4796{ 4796{
4797 struct inode *inode = NULL; 4797 struct inode *inode = NULL;
4798 struct btrfs_trans_handle *trans; 4798 struct btrfs_trans_handle *trans;
@@ -6761,7 +6761,6 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
6761static void btrfs_i_callback(struct rcu_head *head) 6761static void btrfs_i_callback(struct rcu_head *head)
6762{ 6762{
6763 struct inode *inode = container_of(head, struct inode, i_rcu); 6763 struct inode *inode = container_of(head, struct inode, i_rcu);
6764 INIT_LIST_HEAD(&inode->i_dentry);
6765 kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); 6764 kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));
6766} 6765}
6767 6766
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index c04f02c7d5bb..5441ff1480fd 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -201,7 +201,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
201 } 201 }
202 } 202 }
203 203
204 ret = mnt_want_write(file->f_path.mnt); 204 ret = mnt_want_write_file(file);
205 if (ret) 205 if (ret)
206 goto out_unlock; 206 goto out_unlock;
207 207
@@ -259,7 +259,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
259 259
260 btrfs_end_transaction(trans, root); 260 btrfs_end_transaction(trans, root);
261 261
262 mnt_drop_write(file->f_path.mnt); 262 mnt_drop_write_file(file);
263 263
264 ret = 0; 264 ret = 0;
265 out_unlock: 265 out_unlock:
@@ -1855,7 +1855,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
1855 goto out; 1855 goto out;
1856 } 1856 }
1857 1857
1858 err = mnt_want_write(file->f_path.mnt); 1858 err = mnt_want_write_file(file);
1859 if (err) 1859 if (err)
1860 goto out; 1860 goto out;
1861 1861
@@ -1971,7 +1971,7 @@ out_dput:
1971 dput(dentry); 1971 dput(dentry);
1972out_unlock_dir: 1972out_unlock_dir:
1973 mutex_unlock(&dir->i_mutex); 1973 mutex_unlock(&dir->i_mutex);
1974 mnt_drop_write(file->f_path.mnt); 1974 mnt_drop_write_file(file);
1975out: 1975out:
1976 kfree(vol_args); 1976 kfree(vol_args);
1977 return err; 1977 return err;
@@ -1987,7 +1987,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
1987 if (btrfs_root_readonly(root)) 1987 if (btrfs_root_readonly(root))
1988 return -EROFS; 1988 return -EROFS;
1989 1989
1990 ret = mnt_want_write(file->f_path.mnt); 1990 ret = mnt_want_write_file(file);
1991 if (ret) 1991 if (ret)
1992 return ret; 1992 return ret;
1993 1993
@@ -2040,7 +2040,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
2040 ret = -EINVAL; 2040 ret = -EINVAL;
2041 } 2041 }
2042out: 2042out:
2043 mnt_drop_write(file->f_path.mnt); 2043 mnt_drop_write_file(file);
2044 return ret; 2044 return ret;
2045} 2045}
2046 2046
@@ -2195,7 +2195,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
2195 if (btrfs_root_readonly(root)) 2195 if (btrfs_root_readonly(root))
2196 return -EROFS; 2196 return -EROFS;
2197 2197
2198 ret = mnt_want_write(file->f_path.mnt); 2198 ret = mnt_want_write_file(file);
2199 if (ret) 2199 if (ret)
2200 return ret; 2200 return ret;
2201 2201
@@ -2510,7 +2510,7 @@ out_unlock:
2510out_fput: 2510out_fput:
2511 fput(src_file); 2511 fput(src_file);
2512out_drop_write: 2512out_drop_write:
2513 mnt_drop_write(file->f_path.mnt); 2513 mnt_drop_write_file(file);
2514 return ret; 2514 return ret;
2515} 2515}
2516 2516
@@ -2549,7 +2549,7 @@ static long btrfs_ioctl_trans_start(struct file *file)
2549 if (btrfs_root_readonly(root)) 2549 if (btrfs_root_readonly(root))
2550 goto out; 2550 goto out;
2551 2551
2552 ret = mnt_want_write(file->f_path.mnt); 2552 ret = mnt_want_write_file(file);
2553 if (ret) 2553 if (ret)
2554 goto out; 2554 goto out;
2555 2555
@@ -2565,7 +2565,7 @@ static long btrfs_ioctl_trans_start(struct file *file)
2565 2565
2566out_drop: 2566out_drop:
2567 atomic_dec(&root->fs_info->open_ioctl_trans); 2567 atomic_dec(&root->fs_info->open_ioctl_trans);
2568 mnt_drop_write(file->f_path.mnt); 2568 mnt_drop_write_file(file);
2569out: 2569out:
2570 return ret; 2570 return ret;
2571} 2571}
@@ -2800,7 +2800,7 @@ long btrfs_ioctl_trans_end(struct file *file)
2800 2800
2801 atomic_dec(&root->fs_info->open_ioctl_trans); 2801 atomic_dec(&root->fs_info->open_ioctl_trans);
2802 2802
2803 mnt_drop_write(file->f_path.mnt); 2803 mnt_drop_write_file(file);
2804 return 0; 2804 return 0;
2805} 2805}
2806 2806
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 200f63bc6675..ae488aa1966a 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -40,7 +40,6 @@
40#include <linux/magic.h> 40#include <linux/magic.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/cleancache.h> 42#include <linux/cleancache.h>
43#include <linux/mnt_namespace.h>
44#include <linux/ratelimit.h> 43#include <linux/ratelimit.h>
45#include "compat.h" 44#include "compat.h"
46#include "delayed-inode.h" 45#include "delayed-inode.h"
@@ -662,9 +661,9 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
662 return ret; 661 return ret;
663} 662}
664 663
665static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 664static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
666{ 665{
667 struct btrfs_root *root = btrfs_sb(vfs->mnt_sb); 666 struct btrfs_root *root = btrfs_sb(dentry->d_sb);
668 struct btrfs_fs_info *info = root->fs_info; 667 struct btrfs_fs_info *info = root->fs_info;
669 char *compress_type; 668 char *compress_type;
670 669
diff --git a/fs/buffer.c b/fs/buffer.c
index 19d8eb7fdc81..1a30db77af32 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -41,7 +41,6 @@
41#include <linux/bitops.h> 41#include <linux/bitops.h>
42#include <linux/mpage.h> 42#include <linux/mpage.h>
43#include <linux/bit_spinlock.h> 43#include <linux/bit_spinlock.h>
44#include <linux/cleancache.h>
45 44
46static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); 45static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
47 46
@@ -231,55 +230,6 @@ out:
231 return ret; 230 return ret;
232} 231}
233 232
234/* If invalidate_buffers() will trash dirty buffers, it means some kind
235 of fs corruption is going on. Trashing dirty data always imply losing
236 information that was supposed to be just stored on the physical layer
237 by the user.
238
239 Thus invalidate_buffers in general usage is not allwowed to trash
240 dirty buffers. For example ioctl(FLSBLKBUF) expects dirty data to
241 be preserved. These buffers are simply skipped.
242
243 We also skip buffers which are still in use. For example this can
244 happen if a userspace program is reading the block device.
245
246 NOTE: In the case where the user removed a removable-media-disk even if
247 there's still dirty data not synced on disk (due a bug in the device driver
248 or due an error of the user), by not destroying the dirty buffers we could
249 generate corruption also on the next media inserted, thus a parameter is
250 necessary to handle this case in the most safe way possible (trying
251 to not corrupt also the new disk inserted with the data belonging to
252 the old now corrupted disk). Also for the ramdisk the natural thing
253 to do in order to release the ramdisk memory is to destroy dirty buffers.
254
255 These are two special cases. Normal usage imply the device driver
256 to issue a sync on the device (without waiting I/O completion) and
257 then an invalidate_buffers call that doesn't trash dirty buffers.
258
259 For handling cache coherency with the blkdev pagecache the 'update' case
260 is been introduced. It is needed to re-read from disk any pinned
261 buffer. NOTE: re-reading from disk is destructive so we can do it only
262 when we assume nobody is changing the buffercache under our I/O and when
263 we think the disk contains more recent information than the buffercache.
264 The update == 1 pass marks the buffers we need to update, the update == 2
265 pass does the actual I/O. */
266void invalidate_bdev(struct block_device *bdev)
267{
268 struct address_space *mapping = bdev->bd_inode->i_mapping;
269
270 if (mapping->nrpages == 0)
271 return;
272
273 invalidate_bh_lrus();
274 lru_add_drain_all(); /* make sure all lru add caches are flushed */
275 invalidate_mapping_pages(mapping, 0, -1);
276 /* 99% of the time, we don't need to flush the cleancache on the bdev.
277 * But, for the strange corners, lets be cautious
278 */
279 cleancache_flush_inode(mapping);
280}
281EXPORT_SYMBOL(invalidate_bdev);
282
283/* 233/*
284 * Kick the writeback threads then try to free up some ZONE_NORMAL memory. 234 * Kick the writeback threads then try to free up some ZONE_NORMAL memory.
285 */ 235 */
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index 1064805e653b..67bef6d01484 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/mount.h> 13#include <linux/mount.h>
14#include <linux/buffer_head.h>
15#include "internal.h" 14#include "internal.h"
16 15
17#define list_to_page(head) (list_entry((head)->prev, struct page, lru)) 16#define list_to_page(head) (list_entry((head)->prev, struct page, lru))
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 8b53193e4f7c..b60fc8bfb3e9 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -928,7 +928,7 @@ static int send_cap_msg(struct ceph_mds_session *session,
928 u64 size, u64 max_size, 928 u64 size, u64 max_size,
929 struct timespec *mtime, struct timespec *atime, 929 struct timespec *mtime, struct timespec *atime,
930 u64 time_warp_seq, 930 u64 time_warp_seq,
931 uid_t uid, gid_t gid, mode_t mode, 931 uid_t uid, gid_t gid, umode_t mode,
932 u64 xattr_version, 932 u64 xattr_version,
933 struct ceph_buffer *xattrs_buf, 933 struct ceph_buffer *xattrs_buf,
934 u64 follows) 934 u64 follows)
@@ -1078,7 +1078,7 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
1078 u64 size, max_size; 1078 u64 size, max_size;
1079 struct timespec mtime, atime; 1079 struct timespec mtime, atime;
1080 int wake = 0; 1080 int wake = 0;
1081 mode_t mode; 1081 umode_t mode;
1082 uid_t uid; 1082 uid_t uid;
1083 gid_t gid; 1083 gid_t gid;
1084 struct ceph_mds_session *session; 1084 struct ceph_mds_session *session;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 98954003a8d3..74fd74719dc2 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -666,7 +666,7 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
666} 666}
667 667
668static int ceph_mknod(struct inode *dir, struct dentry *dentry, 668static int ceph_mknod(struct inode *dir, struct dentry *dentry,
669 int mode, dev_t rdev) 669 umode_t mode, dev_t rdev)
670{ 670{
671 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb); 671 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
672 struct ceph_mds_client *mdsc = fsc->mdsc; 672 struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -676,7 +676,7 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
676 if (ceph_snap(dir) != CEPH_NOSNAP) 676 if (ceph_snap(dir) != CEPH_NOSNAP)
677 return -EROFS; 677 return -EROFS;
678 678
679 dout("mknod in dir %p dentry %p mode 0%o rdev %d\n", 679 dout("mknod in dir %p dentry %p mode 0%ho rdev %d\n",
680 dir, dentry, mode, rdev); 680 dir, dentry, mode, rdev);
681 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_MKNOD, USE_AUTH_MDS); 681 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_MKNOD, USE_AUTH_MDS);
682 if (IS_ERR(req)) { 682 if (IS_ERR(req)) {
@@ -699,7 +699,7 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
699 return err; 699 return err;
700} 700}
701 701
702static int ceph_create(struct inode *dir, struct dentry *dentry, int mode, 702static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode,
703 struct nameidata *nd) 703 struct nameidata *nd)
704{ 704{
705 dout("create in dir %p dentry %p name '%.*s'\n", 705 dout("create in dir %p dentry %p name '%.*s'\n",
@@ -753,7 +753,7 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry,
753 return err; 753 return err;
754} 754}
755 755
756static int ceph_mkdir(struct inode *dir, struct dentry *dentry, int mode) 756static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
757{ 757{
758 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb); 758 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
759 struct ceph_mds_client *mdsc = fsc->mdsc; 759 struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -767,7 +767,7 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, int mode)
767 dout("mksnap dir %p snap '%.*s' dn %p\n", dir, 767 dout("mksnap dir %p snap '%.*s' dn %p\n", dir,
768 dentry->d_name.len, dentry->d_name.name, dentry); 768 dentry->d_name.len, dentry->d_name.name, dentry);
769 } else if (ceph_snap(dir) == CEPH_NOSNAP) { 769 } else if (ceph_snap(dir) == CEPH_NOSNAP) {
770 dout("mkdir dir %p dn %p mode 0%o\n", dir, dentry, mode); 770 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode);
771 op = CEPH_MDS_OP_MKDIR; 771 op = CEPH_MDS_OP_MKDIR;
772 } else { 772 } else {
773 goto out; 773 goto out;
@@ -870,7 +870,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry)
870 } else if (ceph_snap(dir) == CEPH_NOSNAP) { 870 } else if (ceph_snap(dir) == CEPH_NOSNAP) {
871 dout("unlink/rmdir dir %p dn %p inode %p\n", 871 dout("unlink/rmdir dir %p dn %p inode %p\n",
872 dir, dentry, inode); 872 dir, dentry, inode);
873 op = ((dentry->d_inode->i_mode & S_IFMT) == S_IFDIR) ? 873 op = S_ISDIR(dentry->d_inode->i_mode) ?
874 CEPH_MDS_OP_RMDIR : CEPH_MDS_OP_UNLINK; 874 CEPH_MDS_OP_RMDIR : CEPH_MDS_OP_UNLINK;
875 } else 875 } else
876 goto out; 876 goto out;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 87fb132fb330..25283e7a37f8 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -384,7 +384,6 @@ static void ceph_i_callback(struct rcu_head *head)
384 struct inode *inode = container_of(head, struct inode, i_rcu); 384 struct inode *inode = container_of(head, struct inode, i_rcu);
385 struct ceph_inode_info *ci = ceph_inode(inode); 385 struct ceph_inode_info *ci = ceph_inode(inode);
386 386
387 INIT_LIST_HEAD(&inode->i_dentry);
388 kmem_cache_free(ceph_inode_cachep, ci); 387 kmem_cache_free(ceph_inode_cachep, ci);
389} 388}
390 389
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index b48f15f101a0..11bd0fc4853f 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -341,11 +341,11 @@ out:
341/** 341/**
342 * ceph_show_options - Show mount options in /proc/mounts 342 * ceph_show_options - Show mount options in /proc/mounts
343 * @m: seq_file to write to 343 * @m: seq_file to write to
344 * @mnt: mount descriptor 344 * @root: root of that (sub)tree
345 */ 345 */
346static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt) 346static int ceph_show_options(struct seq_file *m, struct dentry *root)
347{ 347{
348 struct ceph_fs_client *fsc = ceph_sb_to_client(mnt->mnt_sb); 348 struct ceph_fs_client *fsc = ceph_sb_to_client(root->d_sb);
349 struct ceph_mount_options *fsopt = fsc->mount_options; 349 struct ceph_mount_options *fsopt = fsc->mount_options;
350 struct ceph_options *opt = fsc->client->options; 350 struct ceph_options *opt = fsc->client->options;
351 351
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index edcbf3774a56..cb3652b37271 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -136,7 +136,7 @@ struct ceph_cap_snap {
136 int issued, dirty; 136 int issued, dirty;
137 struct ceph_snap_context *context; 137 struct ceph_snap_context *context;
138 138
139 mode_t mode; 139 umode_t mode;
140 uid_t uid; 140 uid_t uid;
141 gid_t gid; 141 gid_t gid;
142 142
diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h
index 500d65859279..c865bfdfe819 100644
--- a/fs/cifs/cifs_fs_sb.h
+++ b/fs/cifs/cifs_fs_sb.h
@@ -59,8 +59,8 @@ struct cifs_sb_info {
59 gid_t mnt_gid; 59 gid_t mnt_gid;
60 uid_t mnt_backupuid; 60 uid_t mnt_backupuid;
61 gid_t mnt_backupgid; 61 gid_t mnt_backupgid;
62 mode_t mnt_file_mode; 62 umode_t mnt_file_mode;
63 mode_t mnt_dir_mode; 63 umode_t mnt_dir_mode;
64 unsigned int mnt_cifs_flags; 64 unsigned int mnt_cifs_flags;
65 char *mountdata; /* options received at mount time or via DFS refs */ 65 char *mountdata; /* options received at mount time or via DFS refs */
66 struct backing_dev_info bdi; 66 struct backing_dev_info bdi;
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 8f1fe324162b..b1fd382d1952 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -343,9 +343,9 @@ cifs_show_security(struct seq_file *s, struct TCP_Server_Info *server)
343 * ones are. 343 * ones are.
344 */ 344 */
345static int 345static int
346cifs_show_options(struct seq_file *s, struct vfsmount *m) 346cifs_show_options(struct seq_file *s, struct dentry *root)
347{ 347{
348 struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb); 348 struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
349 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 349 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
350 struct sockaddr *srcaddr; 350 struct sockaddr *srcaddr;
351 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; 351 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
@@ -393,7 +393,7 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
393 cifs_show_address(s, tcon->ses->server); 393 cifs_show_address(s, tcon->ses->server);
394 394
395 if (!tcon->unix_ext) 395 if (!tcon->unix_ext)
396 seq_printf(s, ",file_mode=0%o,dir_mode=0%o", 396 seq_printf(s, ",file_mode=0%ho,dir_mode=0%ho",
397 cifs_sb->mnt_file_mode, 397 cifs_sb->mnt_file_mode,
398 cifs_sb->mnt_dir_mode); 398 cifs_sb->mnt_dir_mode);
399 if (tcon->seal) 399 if (tcon->seal)
@@ -430,7 +430,7 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
430 seq_printf(s, ",cifsacl"); 430 seq_printf(s, ",cifsacl");
431 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) 431 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
432 seq_printf(s, ",dynperm"); 432 seq_printf(s, ",dynperm");
433 if (m->mnt_sb->s_flags & MS_POSIXACL) 433 if (root->d_sb->s_flags & MS_POSIXACL)
434 seq_printf(s, ",acl"); 434 seq_printf(s, ",acl");
435 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) 435 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
436 seq_printf(s, ",mfsymlinks"); 436 seq_printf(s, ",mfsymlinks");
@@ -488,7 +488,7 @@ static void cifs_umount_begin(struct super_block *sb)
488} 488}
489 489
490#ifdef CONFIG_CIFS_STATS2 490#ifdef CONFIG_CIFS_STATS2
491static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt) 491static int cifs_show_stats(struct seq_file *s, struct dentry *root)
492{ 492{
493 /* BB FIXME */ 493 /* BB FIXME */
494 return 0; 494 return 0;
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 30ff56005d8f..fe5ecf1b422a 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -44,14 +44,14 @@ extern const struct address_space_operations cifs_addr_ops_smallbuf;
44/* Functions related to inodes */ 44/* Functions related to inodes */
45extern const struct inode_operations cifs_dir_inode_ops; 45extern const struct inode_operations cifs_dir_inode_ops;
46extern struct inode *cifs_root_iget(struct super_block *); 46extern struct inode *cifs_root_iget(struct super_block *);
47extern int cifs_create(struct inode *, struct dentry *, int, 47extern int cifs_create(struct inode *, struct dentry *, umode_t,
48 struct nameidata *); 48 struct nameidata *);
49extern struct dentry *cifs_lookup(struct inode *, struct dentry *, 49extern struct dentry *cifs_lookup(struct inode *, struct dentry *,
50 struct nameidata *); 50 struct nameidata *);
51extern int cifs_unlink(struct inode *dir, struct dentry *dentry); 51extern int cifs_unlink(struct inode *dir, struct dentry *dentry);
52extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *); 52extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *);
53extern int cifs_mknod(struct inode *, struct dentry *, int, dev_t); 53extern int cifs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
54extern int cifs_mkdir(struct inode *, struct dentry *, int); 54extern int cifs_mkdir(struct inode *, struct dentry *, umode_t);
55extern int cifs_rmdir(struct inode *, struct dentry *); 55extern int cifs_rmdir(struct inode *, struct dentry *);
56extern int cifs_rename(struct inode *, struct dentry *, struct inode *, 56extern int cifs_rename(struct inode *, struct dentry *, struct inode *,
57 struct dentry *); 57 struct dentry *);
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 8238aa13e01c..ba53c1c6c6cc 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -169,8 +169,8 @@ struct smb_vol {
169 gid_t linux_gid; 169 gid_t linux_gid;
170 uid_t backupuid; 170 uid_t backupuid;
171 gid_t backupgid; 171 gid_t backupgid;
172 mode_t file_mode; 172 umode_t file_mode;
173 mode_t dir_mode; 173 umode_t dir_mode;
174 unsigned secFlg; 174 unsigned secFlg;
175 bool retry:1; 175 bool retry:1;
176 bool intr:1; 176 bool intr:1;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index f3670cf72587..4666780f315d 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2819,7 +2819,7 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
2819 cifs_sb->mnt_backupgid = pvolume_info->backupgid; 2819 cifs_sb->mnt_backupgid = pvolume_info->backupgid;
2820 cifs_sb->mnt_file_mode = pvolume_info->file_mode; 2820 cifs_sb->mnt_file_mode = pvolume_info->file_mode;
2821 cifs_sb->mnt_dir_mode = pvolume_info->dir_mode; 2821 cifs_sb->mnt_dir_mode = pvolume_info->dir_mode;
2822 cFYI(1, "file mode: 0x%x dir mode: 0x%x", 2822 cFYI(1, "file mode: 0x%hx dir mode: 0x%hx",
2823 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode); 2823 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode);
2824 2824
2825 cifs_sb->actimeo = pvolume_info->actimeo; 2825 cifs_sb->actimeo = pvolume_info->actimeo;
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index d7eeb9d3ed6f..df8fecb5b993 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -136,7 +136,7 @@ cifs_bp_rename_retry:
136/* Inode operations in similar order to how they appear in Linux file fs.h */ 136/* Inode operations in similar order to how they appear in Linux file fs.h */
137 137
138int 138int
139cifs_create(struct inode *inode, struct dentry *direntry, int mode, 139cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode,
140 struct nameidata *nd) 140 struct nameidata *nd)
141{ 141{
142 int rc = -ENOENT; 142 int rc = -ENOENT;
@@ -355,7 +355,7 @@ cifs_create_out:
355 return rc; 355 return rc;
356} 356}
357 357
358int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, 358int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
359 dev_t device_number) 359 dev_t device_number)
360{ 360{
361 int rc = -EPERM; 361 int rc = -EPERM;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index e851d5b8931e..a5f54b7d9822 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1264,7 +1264,7 @@ unlink_out:
1264 return rc; 1264 return rc;
1265} 1265}
1266 1266
1267int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) 1267int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode)
1268{ 1268{
1269 int rc = 0, tmprc; 1269 int rc = 0, tmprc;
1270 int xid; 1270 int xid;
@@ -1275,7 +1275,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1275 struct inode *newinode = NULL; 1275 struct inode *newinode = NULL;
1276 struct cifs_fattr fattr; 1276 struct cifs_fattr fattr;
1277 1277
1278 cFYI(1, "In cifs_mkdir, mode = 0x%x inode = 0x%p", mode, inode); 1278 cFYI(1, "In cifs_mkdir, mode = 0x%hx inode = 0x%p", mode, inode);
1279 1279
1280 cifs_sb = CIFS_SB(inode->i_sb); 1280 cifs_sb = CIFS_SB(inode->i_sb);
1281 tlink = cifs_sb_tlink(cifs_sb); 1281 tlink = cifs_sb_tlink(cifs_sb);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 28e7e135cfab..83d2fd8ec24b 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -30,14 +30,14 @@
30#include "coda_int.h" 30#include "coda_int.h"
31 31
32/* dir inode-ops */ 32/* dir inode-ops */
33static int coda_create(struct inode *dir, struct dentry *new, int mode, struct nameidata *nd); 33static int coda_create(struct inode *dir, struct dentry *new, umode_t mode, struct nameidata *nd);
34static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd); 34static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd);
35static int coda_link(struct dentry *old_dentry, struct inode *dir_inode, 35static int coda_link(struct dentry *old_dentry, struct inode *dir_inode,
36 struct dentry *entry); 36 struct dentry *entry);
37static int coda_unlink(struct inode *dir_inode, struct dentry *entry); 37static int coda_unlink(struct inode *dir_inode, struct dentry *entry);
38static int coda_symlink(struct inode *dir_inode, struct dentry *entry, 38static int coda_symlink(struct inode *dir_inode, struct dentry *entry,
39 const char *symname); 39 const char *symname);
40static int coda_mkdir(struct inode *dir_inode, struct dentry *entry, int mode); 40static int coda_mkdir(struct inode *dir_inode, struct dentry *entry, umode_t mode);
41static int coda_rmdir(struct inode *dir_inode, struct dentry *entry); 41static int coda_rmdir(struct inode *dir_inode, struct dentry *entry);
42static int coda_rename(struct inode *old_inode, struct dentry *old_dentry, 42static int coda_rename(struct inode *old_inode, struct dentry *old_dentry,
43 struct inode *new_inode, struct dentry *new_dentry); 43 struct inode *new_inode, struct dentry *new_dentry);
@@ -191,7 +191,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir)
191} 191}
192 192
193/* creation routines: create, mknod, mkdir, link, symlink */ 193/* creation routines: create, mknod, mkdir, link, symlink */
194static int coda_create(struct inode *dir, struct dentry *de, int mode, struct nameidata *nd) 194static int coda_create(struct inode *dir, struct dentry *de, umode_t mode, struct nameidata *nd)
195{ 195{
196 int error; 196 int error;
197 const char *name=de->d_name.name; 197 const char *name=de->d_name.name;
@@ -223,7 +223,7 @@ err_out:
223 return error; 223 return error;
224} 224}
225 225
226static int coda_mkdir(struct inode *dir, struct dentry *de, int mode) 226static int coda_mkdir(struct inode *dir, struct dentry *de, umode_t mode)
227{ 227{
228 struct inode *inode; 228 struct inode *inode;
229 struct coda_vattr attrs; 229 struct coda_vattr attrs;
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 871b27715465..1c08a8cd673a 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -58,7 +58,6 @@ static struct inode *coda_alloc_inode(struct super_block *sb)
58static void coda_i_callback(struct rcu_head *head) 58static void coda_i_callback(struct rcu_head *head)
59{ 59{
60 struct inode *inode = container_of(head, struct inode, i_rcu); 60 struct inode *inode = container_of(head, struct inode, i_rcu);
61 INIT_LIST_HEAD(&inode->i_dentry);
62 kmem_cache_free(coda_inode_cachep, ITOC(inode)); 61 kmem_cache_free(coda_inode_cachep, ITOC(inode));
63} 62}
64 63
diff --git a/fs/compat.c b/fs/compat.c
index c98787536bb8..fa9d721ecfee 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -342,16 +342,9 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c
342 */ 342 */
343asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u) 343asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u)
344{ 344{
345 struct super_block *sb;
346 struct compat_ustat tmp; 345 struct compat_ustat tmp;
347 struct kstatfs sbuf; 346 struct kstatfs sbuf;
348 int err; 347 int err = vfs_ustat(new_decode_dev(dev), &sbuf);
349
350 sb = user_get_super(new_decode_dev(dev));
351 if (!sb)
352 return -EINVAL;
353 err = statfs_by_dentry(sb->s_root, &sbuf);
354 drop_super(sb);
355 if (err) 348 if (err)
356 return err; 349 return err;
357 350
@@ -1288,7 +1281,7 @@ compat_sys_vmsplice(int fd, const struct compat_iovec __user *iov32,
1288 * O_LARGEFILE flag. 1281 * O_LARGEFILE flag.
1289 */ 1282 */
1290asmlinkage long 1283asmlinkage long
1291compat_sys_open(const char __user *filename, int flags, int mode) 1284compat_sys_open(const char __user *filename, int flags, umode_t mode)
1292{ 1285{
1293 return do_sys_open(AT_FDCWD, filename, flags, mode); 1286 return do_sys_open(AT_FDCWD, filename, flags, mode);
1294} 1287}
@@ -1298,7 +1291,7 @@ compat_sys_open(const char __user *filename, int flags, int mode)
1298 * O_LARGEFILE flag. 1291 * O_LARGEFILE flag.
1299 */ 1292 */
1300asmlinkage long 1293asmlinkage long
1301compat_sys_openat(unsigned int dfd, const char __user *filename, int flags, int mode) 1294compat_sys_openat(unsigned int dfd, const char __user *filename, int flags, umode_t mode)
1302{ 1295{
1303 return do_sys_open(dfd, filename, flags, mode); 1296 return do_sys_open(dfd, filename, flags, mode);
1304} 1297}
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index 82bda8fdfc1c..ede857d20a04 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -63,8 +63,8 @@ extern struct kmem_cache *configfs_dir_cachep;
63 63
64extern int configfs_is_root(struct config_item *item); 64extern int configfs_is_root(struct config_item *item);
65 65
66extern struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent *); 66extern struct inode * configfs_new_inode(umode_t mode, struct configfs_dirent *);
67extern int configfs_create(struct dentry *, int mode, int (*init)(struct inode *)); 67extern int configfs_create(struct dentry *, umode_t mode, int (*init)(struct inode *));
68extern int configfs_inode_init(void); 68extern int configfs_inode_init(void);
69extern void configfs_inode_exit(void); 69extern void configfs_inode_exit(void);
70 70
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 9a37a9b6de3a..5ddd7ebd9dcd 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -311,8 +311,8 @@ static int configfs_create_dir(struct config_item * item, struct dentry *dentry)
311 311
312 if (item->ci_parent) 312 if (item->ci_parent)
313 parent = item->ci_parent->ci_dentry; 313 parent = item->ci_parent->ci_dentry;
314 else if (configfs_mount && configfs_mount->mnt_sb) 314 else if (configfs_mount)
315 parent = configfs_mount->mnt_sb->s_root; 315 parent = configfs_mount->mnt_root;
316 else 316 else
317 return -EFAULT; 317 return -EFAULT;
318 318
@@ -1170,7 +1170,7 @@ void configfs_undepend_item(struct configfs_subsystem *subsys,
1170} 1170}
1171EXPORT_SYMBOL(configfs_undepend_item); 1171EXPORT_SYMBOL(configfs_undepend_item);
1172 1172
1173static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 1173static int configfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1174{ 1174{
1175 int ret = 0; 1175 int ret = 0;
1176 int module_got = 0; 1176 int module_got = 0;
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 9d8715c45f25..3ee36d418863 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -116,7 +116,7 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
116 return error; 116 return error;
117} 117}
118 118
119static inline void set_default_inode_attr(struct inode * inode, mode_t mode) 119static inline void set_default_inode_attr(struct inode * inode, umode_t mode)
120{ 120{
121 inode->i_mode = mode; 121 inode->i_mode = mode;
122 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 122 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
@@ -132,7 +132,7 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
132 inode->i_ctime = iattr->ia_ctime; 132 inode->i_ctime = iattr->ia_ctime;
133} 133}
134 134
135struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd) 135struct inode *configfs_new_inode(umode_t mode, struct configfs_dirent * sd)
136{ 136{
137 struct inode * inode = new_inode(configfs_sb); 137 struct inode * inode = new_inode(configfs_sb);
138 if (inode) { 138 if (inode) {
@@ -185,7 +185,7 @@ static void configfs_set_inode_lock_class(struct configfs_dirent *sd,
185 185
186#endif /* CONFIG_LOCKDEP */ 186#endif /* CONFIG_LOCKDEP */
187 187
188int configfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *)) 188int configfs_create(struct dentry * dentry, umode_t mode, int (*init)(struct inode *))
189{ 189{
190 int error = 0; 190 int error = 0;
191 struct inode * inode = NULL; 191 struct inode * inode = NULL;
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 739fb59bcdc2..a2ee8f9f5a38 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -20,7 +20,6 @@
20#include <linux/cramfs_fs.h> 20#include <linux/cramfs_fs.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/cramfs_fs_sb.h> 22#include <linux/cramfs_fs_sb.h>
23#include <linux/buffer_head.h>
24#include <linux/vfs.h> 23#include <linux/vfs.h>
25#include <linux/mutex.h> 24#include <linux/mutex.h>
26 25
@@ -378,7 +377,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
378 unsigned long nextoffset; 377 unsigned long nextoffset;
379 char *name; 378 char *name;
380 ino_t ino; 379 ino_t ino;
381 mode_t mode; 380 umode_t mode;
382 int namelen, error; 381 int namelen, error;
383 382
384 mutex_lock(&read_mutex); 383 mutex_lock(&read_mutex);
diff --git a/fs/dcache.c b/fs/dcache.c
index 89509b5a090e..9791b1e7eee4 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -38,6 +38,7 @@
38#include <linux/prefetch.h> 38#include <linux/prefetch.h>
39#include <linux/ratelimit.h> 39#include <linux/ratelimit.h>
40#include "internal.h" 40#include "internal.h"
41#include "mount.h"
41 42
42/* 43/*
43 * Usage: 44 * Usage:
@@ -2451,6 +2452,7 @@ static int prepend_path(const struct path *path,
2451{ 2452{
2452 struct dentry *dentry = path->dentry; 2453 struct dentry *dentry = path->dentry;
2453 struct vfsmount *vfsmnt = path->mnt; 2454 struct vfsmount *vfsmnt = path->mnt;
2455 struct mount *mnt = real_mount(vfsmnt);
2454 bool slash = false; 2456 bool slash = false;
2455 int error = 0; 2457 int error = 0;
2456 2458
@@ -2460,11 +2462,11 @@ static int prepend_path(const struct path *path,
2460 2462
2461 if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { 2463 if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
2462 /* Global root? */ 2464 /* Global root? */
2463 if (vfsmnt->mnt_parent == vfsmnt) { 2465 if (!mnt_has_parent(mnt))
2464 goto global_root; 2466 goto global_root;
2465 } 2467 dentry = mnt->mnt_mountpoint;
2466 dentry = vfsmnt->mnt_mountpoint; 2468 mnt = mnt->mnt_parent;
2467 vfsmnt = vfsmnt->mnt_parent; 2469 vfsmnt = &mnt->mnt;
2468 continue; 2470 continue;
2469 } 2471 }
2470 parent = dentry->d_parent; 2472 parent = dentry->d_parent;
@@ -2501,7 +2503,7 @@ global_root:
2501 if (!slash) 2503 if (!slash)
2502 error = prepend(buffer, buflen, "/", 1); 2504 error = prepend(buffer, buflen, "/", 1);
2503 if (!error) 2505 if (!error)
2504 error = vfsmnt->mnt_ns ? 1 : 2; 2506 error = real_mount(vfsmnt)->mnt_ns ? 1 : 2;
2505 goto out; 2507 goto out;
2506} 2508}
2507 2509
@@ -2853,31 +2855,6 @@ int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry)
2853 return result; 2855 return result;
2854} 2856}
2855 2857
2856int path_is_under(struct path *path1, struct path *path2)
2857{
2858 struct vfsmount *mnt = path1->mnt;
2859 struct dentry *dentry = path1->dentry;
2860 int res;
2861
2862 br_read_lock(vfsmount_lock);
2863 if (mnt != path2->mnt) {
2864 for (;;) {
2865 if (mnt->mnt_parent == mnt) {
2866 br_read_unlock(vfsmount_lock);
2867 return 0;
2868 }
2869 if (mnt->mnt_parent == path2->mnt)
2870 break;
2871 mnt = mnt->mnt_parent;
2872 }
2873 dentry = mnt->mnt_mountpoint;
2874 }
2875 res = is_subdir(dentry, path2->dentry);
2876 br_read_unlock(vfsmount_lock);
2877 return res;
2878}
2879EXPORT_SYMBOL(path_is_under);
2880
2881void d_genocide(struct dentry *root) 2858void d_genocide(struct dentry *root)
2882{ 2859{
2883 struct dentry *this_parent; 2860 struct dentry *this_parent;
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index ea62afa4fd57..f65d4455c5e5 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -97,7 +97,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u8_wo, NULL, debugfs_u8_set, "%llu\n");
97 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 97 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
98 * code. 98 * code.
99 */ 99 */
100struct dentry *debugfs_create_u8(const char *name, mode_t mode, 100struct dentry *debugfs_create_u8(const char *name, umode_t mode,
101 struct dentry *parent, u8 *value) 101 struct dentry *parent, u8 *value)
102{ 102{
103 /* if there are no write bits set, make read only */ 103 /* if there are no write bits set, make read only */
@@ -149,7 +149,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u16_wo, NULL, debugfs_u16_set, "%llu\n");
149 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 149 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
150 * code. 150 * code.
151 */ 151 */
152struct dentry *debugfs_create_u16(const char *name, mode_t mode, 152struct dentry *debugfs_create_u16(const char *name, umode_t mode,
153 struct dentry *parent, u16 *value) 153 struct dentry *parent, u16 *value)
154{ 154{
155 /* if there are no write bits set, make read only */ 155 /* if there are no write bits set, make read only */
@@ -201,7 +201,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u32_wo, NULL, debugfs_u32_set, "%llu\n");
201 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 201 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
202 * code. 202 * code.
203 */ 203 */
204struct dentry *debugfs_create_u32(const char *name, mode_t mode, 204struct dentry *debugfs_create_u32(const char *name, umode_t mode,
205 struct dentry *parent, u32 *value) 205 struct dentry *parent, u32 *value)
206{ 206{
207 /* if there are no write bits set, make read only */ 207 /* if there are no write bits set, make read only */
@@ -254,7 +254,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u64_wo, NULL, debugfs_u64_set, "%llu\n");
254 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 254 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
255 * code. 255 * code.
256 */ 256 */
257struct dentry *debugfs_create_u64(const char *name, mode_t mode, 257struct dentry *debugfs_create_u64(const char *name, umode_t mode,
258 struct dentry *parent, u64 *value) 258 struct dentry *parent, u64 *value)
259{ 259{
260 /* if there are no write bits set, make read only */ 260 /* if there are no write bits set, make read only */
@@ -300,7 +300,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_x64, debugfs_u64_get, debugfs_u64_set, "0x%016llx\n
300 * @value: a pointer to the variable that the file should read to and write 300 * @value: a pointer to the variable that the file should read to and write
301 * from. 301 * from.
302 */ 302 */
303struct dentry *debugfs_create_x8(const char *name, mode_t mode, 303struct dentry *debugfs_create_x8(const char *name, umode_t mode,
304 struct dentry *parent, u8 *value) 304 struct dentry *parent, u8 *value)
305{ 305{
306 /* if there are no write bits set, make read only */ 306 /* if there are no write bits set, make read only */
@@ -324,7 +324,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_x8);
324 * @value: a pointer to the variable that the file should read to and write 324 * @value: a pointer to the variable that the file should read to and write
325 * from. 325 * from.
326 */ 326 */
327struct dentry *debugfs_create_x16(const char *name, mode_t mode, 327struct dentry *debugfs_create_x16(const char *name, umode_t mode,
328 struct dentry *parent, u16 *value) 328 struct dentry *parent, u16 *value)
329{ 329{
330 /* if there are no write bits set, make read only */ 330 /* if there are no write bits set, make read only */
@@ -348,7 +348,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_x16);
348 * @value: a pointer to the variable that the file should read to and write 348 * @value: a pointer to the variable that the file should read to and write
349 * from. 349 * from.
350 */ 350 */
351struct dentry *debugfs_create_x32(const char *name, mode_t mode, 351struct dentry *debugfs_create_x32(const char *name, umode_t mode,
352 struct dentry *parent, u32 *value) 352 struct dentry *parent, u32 *value)
353{ 353{
354 /* if there are no write bits set, make read only */ 354 /* if there are no write bits set, make read only */
@@ -372,7 +372,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_x32);
372 * @value: a pointer to the variable that the file should read to and write 372 * @value: a pointer to the variable that the file should read to and write
373 * from. 373 * from.
374 */ 374 */
375struct dentry *debugfs_create_x64(const char *name, mode_t mode, 375struct dentry *debugfs_create_x64(const char *name, umode_t mode,
376 struct dentry *parent, u64 *value) 376 struct dentry *parent, u64 *value)
377{ 377{
378 return debugfs_create_file(name, mode, parent, value, &fops_x64); 378 return debugfs_create_file(name, mode, parent, value, &fops_x64);
@@ -403,7 +403,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_size_t, debugfs_size_t_get, debugfs_size_t_set,
403 * @value: a pointer to the variable that the file should read to and write 403 * @value: a pointer to the variable that the file should read to and write
404 * from. 404 * from.
405 */ 405 */
406struct dentry *debugfs_create_size_t(const char *name, mode_t mode, 406struct dentry *debugfs_create_size_t(const char *name, umode_t mode,
407 struct dentry *parent, size_t *value) 407 struct dentry *parent, size_t *value)
408{ 408{
409 return debugfs_create_file(name, mode, parent, value, &fops_size_t); 409 return debugfs_create_file(name, mode, parent, value, &fops_size_t);
@@ -475,7 +475,7 @@ static const struct file_operations fops_bool = {
475 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 475 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
476 * code. 476 * code.
477 */ 477 */
478struct dentry *debugfs_create_bool(const char *name, mode_t mode, 478struct dentry *debugfs_create_bool(const char *name, umode_t mode,
479 struct dentry *parent, u32 *value) 479 struct dentry *parent, u32 *value)
480{ 480{
481 return debugfs_create_file(name, mode, parent, value, &fops_bool); 481 return debugfs_create_file(name, mode, parent, value, &fops_bool);
@@ -520,7 +520,7 @@ static const struct file_operations fops_blob = {
520 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling 520 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
521 * code. 521 * code.
522 */ 522 */
523struct dentry *debugfs_create_blob(const char *name, mode_t mode, 523struct dentry *debugfs_create_blob(const char *name, umode_t mode,
524 struct dentry *parent, 524 struct dentry *parent,
525 struct debugfs_blob_wrapper *blob) 525 struct debugfs_blob_wrapper *blob)
526{ 526{
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index f3a257d7a985..956d5ddddf6e 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -30,7 +30,7 @@ static struct vfsmount *debugfs_mount;
30static int debugfs_mount_count; 30static int debugfs_mount_count;
31static bool debugfs_registered; 31static bool debugfs_registered;
32 32
33static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t dev, 33static struct inode *debugfs_get_inode(struct super_block *sb, umode_t mode, dev_t dev,
34 void *data, const struct file_operations *fops) 34 void *data, const struct file_operations *fops)
35 35
36{ 36{
@@ -69,7 +69,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
69 69
70/* SMP-safe */ 70/* SMP-safe */
71static int debugfs_mknod(struct inode *dir, struct dentry *dentry, 71static int debugfs_mknod(struct inode *dir, struct dentry *dentry,
72 int mode, dev_t dev, void *data, 72 umode_t mode, dev_t dev, void *data,
73 const struct file_operations *fops) 73 const struct file_operations *fops)
74{ 74{
75 struct inode *inode; 75 struct inode *inode;
@@ -87,7 +87,7 @@ static int debugfs_mknod(struct inode *dir, struct dentry *dentry,
87 return error; 87 return error;
88} 88}
89 89
90static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode, 90static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode,
91 void *data, const struct file_operations *fops) 91 void *data, const struct file_operations *fops)
92{ 92{
93 int res; 93 int res;
@@ -101,14 +101,14 @@ static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode,
101 return res; 101 return res;
102} 102}
103 103
104static int debugfs_link(struct inode *dir, struct dentry *dentry, int mode, 104static int debugfs_link(struct inode *dir, struct dentry *dentry, umode_t mode,
105 void *data, const struct file_operations *fops) 105 void *data, const struct file_operations *fops)
106{ 106{
107 mode = (mode & S_IALLUGO) | S_IFLNK; 107 mode = (mode & S_IALLUGO) | S_IFLNK;
108 return debugfs_mknod(dir, dentry, mode, 0, data, fops); 108 return debugfs_mknod(dir, dentry, mode, 0, data, fops);
109} 109}
110 110
111static int debugfs_create(struct inode *dir, struct dentry *dentry, int mode, 111static int debugfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
112 void *data, const struct file_operations *fops) 112 void *data, const struct file_operations *fops)
113{ 113{
114 int res; 114 int res;
@@ -146,7 +146,7 @@ static struct file_system_type debug_fs_type = {
146 .kill_sb = kill_litter_super, 146 .kill_sb = kill_litter_super,
147}; 147};
148 148
149static int debugfs_create_by_name(const char *name, mode_t mode, 149static int debugfs_create_by_name(const char *name, umode_t mode,
150 struct dentry *parent, 150 struct dentry *parent,
151 struct dentry **dentry, 151 struct dentry **dentry,
152 void *data, 152 void *data,
@@ -160,7 +160,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
160 * have around. 160 * have around.
161 */ 161 */
162 if (!parent) 162 if (!parent)
163 parent = debugfs_mount->mnt_sb->s_root; 163 parent = debugfs_mount->mnt_root;
164 164
165 *dentry = NULL; 165 *dentry = NULL;
166 mutex_lock(&parent->d_inode->i_mutex); 166 mutex_lock(&parent->d_inode->i_mutex);
@@ -214,7 +214,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
214 * If debugfs is not enabled in the kernel, the value -%ENODEV will be 214 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
215 * returned. 215 * returned.
216 */ 216 */
217struct dentry *debugfs_create_file(const char *name, mode_t mode, 217struct dentry *debugfs_create_file(const char *name, umode_t mode,
218 struct dentry *parent, void *data, 218 struct dentry *parent, void *data,
219 const struct file_operations *fops) 219 const struct file_operations *fops)
220{ 220{
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index d5d5297efe97..79673eb71151 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -246,9 +246,9 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data)
246 return err; 246 return err;
247} 247}
248 248
249static int devpts_show_options(struct seq_file *seq, struct vfsmount *vfs) 249static int devpts_show_options(struct seq_file *seq, struct dentry *root)
250{ 250{
251 struct pts_fs_info *fsi = DEVPTS_SB(vfs->mnt_sb); 251 struct pts_fs_info *fsi = DEVPTS_SB(root->d_sb);
252 struct pts_mount_opts *opts = &fsi->mount_opts; 252 struct pts_mount_opts *opts = &fsi->mount_opts;
253 253
254 if (opts->setuid) 254 if (opts->setuid)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 32f90a3ae63e..19a8ca4ab1dd 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -144,24 +144,6 @@ static int ecryptfs_interpose(struct dentry *lower_dentry,
144} 144}
145 145
146/** 146/**
147 * ecryptfs_create_underlying_file
148 * @lower_dir_inode: inode of the parent in the lower fs of the new file
149 * @dentry: New file's dentry
150 * @mode: The mode of the new file
151 *
152 * Creates the file in the lower file system.
153 *
154 * Returns zero on success; non-zero on error condition
155 */
156static int
157ecryptfs_create_underlying_file(struct inode *lower_dir_inode,
158 struct dentry *dentry, int mode)
159{
160 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
161 return vfs_create(lower_dir_inode, lower_dentry, mode, NULL);
162}
163
164/**
165 * ecryptfs_do_create 147 * ecryptfs_do_create
166 * @directory_inode: inode of the new file's dentry's parent in ecryptfs 148 * @directory_inode: inode of the new file's dentry's parent in ecryptfs
167 * @ecryptfs_dentry: New file's dentry in ecryptfs 149 * @ecryptfs_dentry: New file's dentry in ecryptfs
@@ -176,7 +158,7 @@ ecryptfs_create_underlying_file(struct inode *lower_dir_inode,
176 */ 158 */
177static struct inode * 159static struct inode *
178ecryptfs_do_create(struct inode *directory_inode, 160ecryptfs_do_create(struct inode *directory_inode,
179 struct dentry *ecryptfs_dentry, int mode) 161 struct dentry *ecryptfs_dentry, umode_t mode)
180{ 162{
181 int rc; 163 int rc;
182 struct dentry *lower_dentry; 164 struct dentry *lower_dentry;
@@ -191,8 +173,7 @@ ecryptfs_do_create(struct inode *directory_inode,
191 inode = ERR_CAST(lower_dir_dentry); 173 inode = ERR_CAST(lower_dir_dentry);
192 goto out; 174 goto out;
193 } 175 }
194 rc = ecryptfs_create_underlying_file(lower_dir_dentry->d_inode, 176 rc = vfs_create(lower_dir_dentry->d_inode, lower_dentry, mode, NULL);
195 ecryptfs_dentry, mode);
196 if (rc) { 177 if (rc) {
197 printk(KERN_ERR "%s: Failure to create dentry in lower fs; " 178 printk(KERN_ERR "%s: Failure to create dentry in lower fs; "
198 "rc = [%d]\n", __func__, rc); 179 "rc = [%d]\n", __func__, rc);
@@ -267,7 +248,7 @@ out:
267 */ 248 */
268static int 249static int
269ecryptfs_create(struct inode *directory_inode, struct dentry *ecryptfs_dentry, 250ecryptfs_create(struct inode *directory_inode, struct dentry *ecryptfs_dentry,
270 int mode, struct nameidata *nd) 251 umode_t mode, struct nameidata *nd)
271{ 252{
272 struct inode *ecryptfs_inode; 253 struct inode *ecryptfs_inode;
273 int rc; 254 int rc;
@@ -559,7 +540,7 @@ out_lock:
559 return rc; 540 return rc;
560} 541}
561 542
562static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 543static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
563{ 544{
564 int rc; 545 int rc;
565 struct dentry *lower_dentry; 546 struct dentry *lower_dentry;
@@ -607,7 +588,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
607} 588}
608 589
609static int 590static int
610ecryptfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) 591ecryptfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
611{ 592{
612 int rc; 593 int rc;
613 struct dentry *lower_dentry; 594 struct dentry *lower_dentry;
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c
index dbd52d40df4c..9df7fd6e0c39 100644
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -69,7 +69,6 @@ static void ecryptfs_i_callback(struct rcu_head *head)
69 struct ecryptfs_inode_info *inode_info; 69 struct ecryptfs_inode_info *inode_info;
70 inode_info = ecryptfs_inode_to_private(inode); 70 inode_info = ecryptfs_inode_to_private(inode);
71 71
72 INIT_LIST_HEAD(&inode->i_dentry);
73 kmem_cache_free(ecryptfs_inode_info_cache, inode_info); 72 kmem_cache_free(ecryptfs_inode_info_cache, inode_info);
74} 73}
75 74
@@ -132,9 +131,9 @@ static void ecryptfs_evict_inode(struct inode *inode)
132 * Prints the mount options for a given superblock. 131 * Prints the mount options for a given superblock.
133 * Returns zero; does not fail. 132 * Returns zero; does not fail.
134 */ 133 */
135static int ecryptfs_show_options(struct seq_file *m, struct vfsmount *mnt) 134static int ecryptfs_show_options(struct seq_file *m, struct dentry *root)
136{ 135{
137 struct super_block *sb = mnt->mnt_sb; 136 struct super_block *sb = root->d_sb;
138 struct ecryptfs_mount_crypt_stat *mount_crypt_stat = 137 struct ecryptfs_mount_crypt_stat *mount_crypt_stat =
139 &ecryptfs_superblock_to_private(sb)->mount_crypt_stat; 138 &ecryptfs_superblock_to_private(sb)->mount_crypt_stat;
140 struct ecryptfs_global_auth_tok *walker; 139 struct ecryptfs_global_auth_tok *walker;
diff --git a/fs/efs/super.c b/fs/efs/super.c
index 0f31acb0131c..981106429a9f 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -68,7 +68,6 @@ static struct inode *efs_alloc_inode(struct super_block *sb)
68static void efs_i_callback(struct rcu_head *head) 68static void efs_i_callback(struct rcu_head *head)
69{ 69{
70 struct inode *inode = container_of(head, struct inode, i_rcu); 70 struct inode *inode = container_of(head, struct inode, i_rcu);
71 INIT_LIST_HEAD(&inode->i_dentry);
72 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); 71 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
73} 72}
74 73
diff --git a/fs/exec.c b/fs/exec.c
index 36254645b7cc..3f64b9f26e7d 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1225,7 +1225,7 @@ EXPORT_SYMBOL(install_exec_creds);
1225 * - the caller must hold ->cred_guard_mutex to protect against 1225 * - the caller must hold ->cred_guard_mutex to protect against
1226 * PTRACE_ATTACH 1226 * PTRACE_ATTACH
1227 */ 1227 */
1228int check_unsafe_exec(struct linux_binprm *bprm) 1228static int check_unsafe_exec(struct linux_binprm *bprm)
1229{ 1229{
1230 struct task_struct *p = current, *t; 1230 struct task_struct *p = current, *t;
1231 unsigned n_fs; 1231 unsigned n_fs;
diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c
index d0941c6a1f72..80405836ba6e 100644
--- a/fs/exofs/dir.c
+++ b/fs/exofs/dir.c
@@ -234,7 +234,7 @@ static unsigned char exofs_type_by_mode[S_IFMT >> S_SHIFT] = {
234static inline 234static inline
235void exofs_set_de_type(struct exofs_dir_entry *de, struct inode *inode) 235void exofs_set_de_type(struct exofs_dir_entry *de, struct inode *inode)
236{ 236{
237 mode_t mode = inode->i_mode; 237 umode_t mode = inode->i_mode;
238 de->file_type = exofs_type_by_mode[(mode & S_IFMT) >> S_SHIFT]; 238 de->file_type = exofs_type_by_mode[(mode & S_IFMT) >> S_SHIFT];
239} 239}
240 240
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h
index 51f4b4c40f09..ca9d49665ef6 100644
--- a/fs/exofs/exofs.h
+++ b/fs/exofs/exofs.h
@@ -154,7 +154,7 @@ int exofs_write_begin(struct file *file, struct address_space *mapping,
154 loff_t pos, unsigned len, unsigned flags, 154 loff_t pos, unsigned len, unsigned flags,
155 struct page **pagep, void **fsdata); 155 struct page **pagep, void **fsdata);
156extern struct inode *exofs_iget(struct super_block *, unsigned long); 156extern struct inode *exofs_iget(struct super_block *, unsigned long);
157struct inode *exofs_new_inode(struct inode *, int); 157struct inode *exofs_new_inode(struct inode *, umode_t);
158extern int exofs_write_inode(struct inode *, struct writeback_control *wbc); 158extern int exofs_write_inode(struct inode *, struct writeback_control *wbc);
159extern void exofs_evict_inode(struct inode *); 159extern void exofs_evict_inode(struct inode *);
160 160
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index f6dbf7768ce6..ea5e1f97806a 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -1276,7 +1276,7 @@ static void create_done(struct ore_io_state *ios, void *p)
1276/* 1276/*
1277 * Set up a new inode and create an object for it on the OSD 1277 * Set up a new inode and create an object for it on the OSD
1278 */ 1278 */
1279struct inode *exofs_new_inode(struct inode *dir, int mode) 1279struct inode *exofs_new_inode(struct inode *dir, umode_t mode)
1280{ 1280{
1281 struct super_block *sb = dir->i_sb; 1281 struct super_block *sb = dir->i_sb;
1282 struct exofs_sb_info *sbi = sb->s_fs_info; 1282 struct exofs_sb_info *sbi = sb->s_fs_info;
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index b54c43775f17..9dbf0c301030 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -59,7 +59,7 @@ static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry,
59 return d_splice_alias(inode, dentry); 59 return d_splice_alias(inode, dentry);
60} 60}
61 61
62static int exofs_create(struct inode *dir, struct dentry *dentry, int mode, 62static int exofs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
63 struct nameidata *nd) 63 struct nameidata *nd)
64{ 64{
65 struct inode *inode = exofs_new_inode(dir, mode); 65 struct inode *inode = exofs_new_inode(dir, mode);
@@ -74,7 +74,7 @@ static int exofs_create(struct inode *dir, struct dentry *dentry, int mode,
74 return err; 74 return err;
75} 75}
76 76
77static int exofs_mknod(struct inode *dir, struct dentry *dentry, int mode, 77static int exofs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
78 dev_t rdev) 78 dev_t rdev)
79{ 79{
80 struct inode *inode; 80 struct inode *inode;
@@ -153,7 +153,7 @@ static int exofs_link(struct dentry *old_dentry, struct inode *dir,
153 return exofs_add_nondir(dentry, inode); 153 return exofs_add_nondir(dentry, inode);
154} 154}
155 155
156static int exofs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 156static int exofs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
157{ 157{
158 struct inode *inode; 158 struct inode *inode;
159 int err = -EMLINK; 159 int err = -EMLINK;
diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index e6085ec192d6..8addfe314dc7 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -166,7 +166,6 @@ static struct inode *exofs_alloc_inode(struct super_block *sb)
166static void exofs_i_callback(struct rcu_head *head) 166static void exofs_i_callback(struct rcu_head *head)
167{ 167{
168 struct inode *inode = container_of(head, struct inode, i_rcu); 168 struct inode *inode = container_of(head, struct inode, i_rcu);
169 INIT_LIST_HEAD(&inode->i_dentry);
170 kmem_cache_free(exofs_inode_cachep, exofs_i(inode)); 169 kmem_cache_free(exofs_inode_cachep, exofs_i(inode));
171} 170}
172 171
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 47cda410b548..d37df352d324 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -279,7 +279,7 @@ static unsigned char ext2_type_by_mode[S_IFMT >> S_SHIFT] = {
279 279
280static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode) 280static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode)
281{ 281{
282 mode_t mode = inode->i_mode; 282 umode_t mode = inode->i_mode;
283 if (EXT2_HAS_INCOMPAT_FEATURE(inode->i_sb, EXT2_FEATURE_INCOMPAT_FILETYPE)) 283 if (EXT2_HAS_INCOMPAT_FEATURE(inode->i_sb, EXT2_FEATURE_INCOMPAT_FILETYPE))
284 de->file_type = ext2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; 284 de->file_type = ext2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
285 else 285 else
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 9a4e5e206d08..75ad433c6691 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -110,7 +110,7 @@ extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
110extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int); 110extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int);
111 111
112/* ialloc.c */ 112/* ialloc.c */
113extern struct inode * ext2_new_inode (struct inode *, int, const struct qstr *); 113extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *);
114extern void ext2_free_inode (struct inode *); 114extern void ext2_free_inode (struct inode *);
115extern unsigned long ext2_count_free_inodes (struct super_block *); 115extern unsigned long ext2_count_free_inodes (struct super_block *);
116extern void ext2_check_inodes_bitmap (struct super_block *); 116extern void ext2_check_inodes_bitmap (struct super_block *);
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index c4e81dfb74ba..cd7f5f424a75 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -429,7 +429,7 @@ found:
429 return group; 429 return group;
430} 430}
431 431
432struct inode *ext2_new_inode(struct inode *dir, int mode, 432struct inode *ext2_new_inode(struct inode *dir, umode_t mode,
433 const struct qstr *qstr) 433 const struct qstr *qstr)
434{ 434{
435 struct super_block *sb; 435 struct super_block *sb;
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index f81e250ac5c4..1089f760c847 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -35,7 +35,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35 case EXT2_IOC_SETFLAGS: { 35 case EXT2_IOC_SETFLAGS: {
36 unsigned int oldflags; 36 unsigned int oldflags;
37 37
38 ret = mnt_want_write(filp->f_path.mnt); 38 ret = mnt_want_write_file(filp);
39 if (ret) 39 if (ret)
40 return ret; 40 return ret;
41 41
@@ -83,7 +83,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
83 inode->i_ctime = CURRENT_TIME_SEC; 83 inode->i_ctime = CURRENT_TIME_SEC;
84 mark_inode_dirty(inode); 84 mark_inode_dirty(inode);
85setflags_out: 85setflags_out:
86 mnt_drop_write(filp->f_path.mnt); 86 mnt_drop_write_file(filp);
87 return ret; 87 return ret;
88 } 88 }
89 case EXT2_IOC_GETVERSION: 89 case EXT2_IOC_GETVERSION:
@@ -91,7 +91,7 @@ setflags_out:
91 case EXT2_IOC_SETVERSION: 91 case EXT2_IOC_SETVERSION:
92 if (!inode_owner_or_capable(inode)) 92 if (!inode_owner_or_capable(inode))
93 return -EPERM; 93 return -EPERM;
94 ret = mnt_want_write(filp->f_path.mnt); 94 ret = mnt_want_write_file(filp);
95 if (ret) 95 if (ret)
96 return ret; 96 return ret;
97 if (get_user(inode->i_generation, (int __user *) arg)) { 97 if (get_user(inode->i_generation, (int __user *) arg)) {
@@ -100,7 +100,7 @@ setflags_out:
100 inode->i_ctime = CURRENT_TIME_SEC; 100 inode->i_ctime = CURRENT_TIME_SEC;
101 mark_inode_dirty(inode); 101 mark_inode_dirty(inode);
102 } 102 }
103 mnt_drop_write(filp->f_path.mnt); 103 mnt_drop_write_file(filp);
104 return ret; 104 return ret;
105 case EXT2_IOC_GETRSVSZ: 105 case EXT2_IOC_GETRSVSZ:
106 if (test_opt(inode->i_sb, RESERVATION) 106 if (test_opt(inode->i_sb, RESERVATION)
@@ -121,7 +121,7 @@ setflags_out:
121 if (get_user(rsv_window_size, (int __user *)arg)) 121 if (get_user(rsv_window_size, (int __user *)arg))
122 return -EFAULT; 122 return -EFAULT;
123 123
124 ret = mnt_want_write(filp->f_path.mnt); 124 ret = mnt_want_write_file(filp);
125 if (ret) 125 if (ret)
126 return ret; 126 return ret;
127 127
@@ -145,7 +145,7 @@ setflags_out:
145 rsv->rsv_goal_size = rsv_window_size; 145 rsv->rsv_goal_size = rsv_window_size;
146 } 146 }
147 mutex_unlock(&ei->truncate_mutex); 147 mutex_unlock(&ei->truncate_mutex);
148 mnt_drop_write(filp->f_path.mnt); 148 mnt_drop_write_file(filp);
149 return 0; 149 return 0;
150 } 150 }
151 default: 151 default:
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 761fde807fc9..080419814bae 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -94,7 +94,7 @@ struct dentry *ext2_get_parent(struct dentry *child)
94 * If the create succeeds, we fill in the inode information 94 * If the create succeeds, we fill in the inode information
95 * with d_instantiate(). 95 * with d_instantiate().
96 */ 96 */
97static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd) 97static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode, struct nameidata *nd)
98{ 98{
99 struct inode *inode; 99 struct inode *inode;
100 100
@@ -119,7 +119,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, st
119 return ext2_add_nondir(dentry, inode); 119 return ext2_add_nondir(dentry, inode);
120} 120}
121 121
122static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev) 122static int ext2_mknod (struct inode * dir, struct dentry *dentry, umode_t mode, dev_t rdev)
123{ 123{
124 struct inode * inode; 124 struct inode * inode;
125 int err; 125 int err;
@@ -214,7 +214,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
214 return err; 214 return err;
215} 215}
216 216
217static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) 217static int ext2_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
218{ 218{
219 struct inode * inode; 219 struct inode * inode;
220 int err = -EMLINK; 220 int err = -EMLINK;
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index bd8ac164a3bf..9b403f064ce0 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -173,7 +173,6 @@ static struct inode *ext2_alloc_inode(struct super_block *sb)
173static void ext2_i_callback(struct rcu_head *head) 173static void ext2_i_callback(struct rcu_head *head)
174{ 174{
175 struct inode *inode = container_of(head, struct inode, i_rcu); 175 struct inode *inode = container_of(head, struct inode, i_rcu);
176 INIT_LIST_HEAD(&inode->i_dentry);
177 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); 176 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
178} 177}
179 178
@@ -211,9 +210,9 @@ static void destroy_inodecache(void)
211 kmem_cache_destroy(ext2_inode_cachep); 210 kmem_cache_destroy(ext2_inode_cachep);
212} 211}
213 212
214static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs) 213static int ext2_show_options(struct seq_file *seq, struct dentry *root)
215{ 214{
216 struct super_block *sb = vfs->mnt_sb; 215 struct super_block *sb = root->d_sb;
217 struct ext2_sb_info *sbi = EXT2_SB(sb); 216 struct ext2_sb_info *sbi = EXT2_SB(sb);
218 struct ext2_super_block *es = sbi->s_es; 217 struct ext2_super_block *es = sbi->s_es;
219 unsigned long def_mount_opts; 218 unsigned long def_mount_opts;
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index 5c866e06e7ab..92cc86dfa23d 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -371,7 +371,7 @@ static int find_group_other(struct super_block *sb, struct inode *parent)
371 * group to find a free inode. 371 * group to find a free inode.
372 */ 372 */
373struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, 373struct inode *ext3_new_inode(handle_t *handle, struct inode * dir,
374 const struct qstr *qstr, int mode) 374 const struct qstr *qstr, umode_t mode)
375{ 375{
376 struct super_block *sb; 376 struct super_block *sb;
377 struct buffer_head *bitmap_bh = NULL; 377 struct buffer_head *bitmap_bh = NULL;
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index ba1b54e23cae..8e37c41a071b 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -44,7 +44,7 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
44 if (get_user(flags, (int __user *) arg)) 44 if (get_user(flags, (int __user *) arg))
45 return -EFAULT; 45 return -EFAULT;
46 46
47 err = mnt_want_write(filp->f_path.mnt); 47 err = mnt_want_write_file(filp);
48 if (err) 48 if (err)
49 return err; 49 return err;
50 50
@@ -110,7 +110,7 @@ flags_err:
110 err = ext3_change_inode_journal_flag(inode, jflag); 110 err = ext3_change_inode_journal_flag(inode, jflag);
111flags_out: 111flags_out:
112 mutex_unlock(&inode->i_mutex); 112 mutex_unlock(&inode->i_mutex);
113 mnt_drop_write(filp->f_path.mnt); 113 mnt_drop_write_file(filp);
114 return err; 114 return err;
115 } 115 }
116 case EXT3_IOC_GETVERSION: 116 case EXT3_IOC_GETVERSION:
@@ -126,7 +126,7 @@ flags_out:
126 if (!inode_owner_or_capable(inode)) 126 if (!inode_owner_or_capable(inode))
127 return -EPERM; 127 return -EPERM;
128 128
129 err = mnt_want_write(filp->f_path.mnt); 129 err = mnt_want_write_file(filp);
130 if (err) 130 if (err)
131 return err; 131 return err;
132 if (get_user(generation, (int __user *) arg)) { 132 if (get_user(generation, (int __user *) arg)) {
@@ -147,7 +147,7 @@ flags_out:
147 } 147 }
148 ext3_journal_stop(handle); 148 ext3_journal_stop(handle);
149setversion_out: 149setversion_out:
150 mnt_drop_write(filp->f_path.mnt); 150 mnt_drop_write_file(filp);
151 return err; 151 return err;
152 } 152 }
153 case EXT3_IOC_GETRSVSZ: 153 case EXT3_IOC_GETRSVSZ:
@@ -164,7 +164,7 @@ setversion_out:
164 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode)) 164 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
165 return -ENOTTY; 165 return -ENOTTY;
166 166
167 err = mnt_want_write(filp->f_path.mnt); 167 err = mnt_want_write_file(filp);
168 if (err) 168 if (err)
169 return err; 169 return err;
170 170
@@ -195,7 +195,7 @@ setversion_out:
195 } 195 }
196 mutex_unlock(&ei->truncate_mutex); 196 mutex_unlock(&ei->truncate_mutex);
197setrsvsz_out: 197setrsvsz_out:
198 mnt_drop_write(filp->f_path.mnt); 198 mnt_drop_write_file(filp);
199 return err; 199 return err;
200 } 200 }
201 case EXT3_IOC_GROUP_EXTEND: { 201 case EXT3_IOC_GROUP_EXTEND: {
@@ -206,7 +206,7 @@ setrsvsz_out:
206 if (!capable(CAP_SYS_RESOURCE)) 206 if (!capable(CAP_SYS_RESOURCE))
207 return -EPERM; 207 return -EPERM;
208 208
209 err = mnt_want_write(filp->f_path.mnt); 209 err = mnt_want_write_file(filp);
210 if (err) 210 if (err)
211 return err; 211 return err;
212 212
@@ -221,7 +221,7 @@ setrsvsz_out:
221 if (err == 0) 221 if (err == 0)
222 err = err2; 222 err = err2;
223group_extend_out: 223group_extend_out:
224 mnt_drop_write(filp->f_path.mnt); 224 mnt_drop_write_file(filp);
225 return err; 225 return err;
226 } 226 }
227 case EXT3_IOC_GROUP_ADD: { 227 case EXT3_IOC_GROUP_ADD: {
@@ -232,7 +232,7 @@ group_extend_out:
232 if (!capable(CAP_SYS_RESOURCE)) 232 if (!capable(CAP_SYS_RESOURCE))
233 return -EPERM; 233 return -EPERM;
234 234
235 err = mnt_want_write(filp->f_path.mnt); 235 err = mnt_want_write_file(filp);
236 if (err) 236 if (err)
237 return err; 237 return err;
238 238
@@ -249,7 +249,7 @@ group_extend_out:
249 if (err == 0) 249 if (err == 0)
250 err = err2; 250 err = err2;
251group_add_out: 251group_add_out:
252 mnt_drop_write(filp->f_path.mnt); 252 mnt_drop_write_file(filp);
253 return err; 253 return err;
254 } 254 }
255 case FITRIM: { 255 case FITRIM: {
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 642dc6d66dfd..4f35b2f315d4 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1698,7 +1698,7 @@ static int ext3_add_nondir(handle_t *handle,
1698 * If the create succeeds, we fill in the inode information 1698 * If the create succeeds, we fill in the inode information
1699 * with d_instantiate(). 1699 * with d_instantiate().
1700 */ 1700 */
1701static int ext3_create (struct inode * dir, struct dentry * dentry, int mode, 1701static int ext3_create (struct inode * dir, struct dentry * dentry, umode_t mode,
1702 struct nameidata *nd) 1702 struct nameidata *nd)
1703{ 1703{
1704 handle_t *handle; 1704 handle_t *handle;
@@ -1732,7 +1732,7 @@ retry:
1732} 1732}
1733 1733
1734static int ext3_mknod (struct inode * dir, struct dentry *dentry, 1734static int ext3_mknod (struct inode * dir, struct dentry *dentry,
1735 int mode, dev_t rdev) 1735 umode_t mode, dev_t rdev)
1736{ 1736{
1737 handle_t *handle; 1737 handle_t *handle;
1738 struct inode *inode; 1738 struct inode *inode;
@@ -1768,7 +1768,7 @@ retry:
1768 return err; 1768 return err;
1769} 1769}
1770 1770
1771static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode) 1771static int ext3_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
1772{ 1772{
1773 handle_t *handle; 1773 handle_t *handle;
1774 struct inode * inode; 1774 struct inode * inode;
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 922d289aeeb3..3a10b884e1be 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -511,7 +511,6 @@ static int ext3_drop_inode(struct inode *inode)
511static void ext3_i_callback(struct rcu_head *head) 511static void ext3_i_callback(struct rcu_head *head)
512{ 512{
513 struct inode *inode = container_of(head, struct inode, i_rcu); 513 struct inode *inode = container_of(head, struct inode, i_rcu);
514 INIT_LIST_HEAD(&inode->i_dentry);
515 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 514 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode));
516} 515}
517 516
@@ -611,9 +610,9 @@ static char *data_mode_string(unsigned long mode)
611 * - it's set to a non-default value OR 610 * - it's set to a non-default value OR
612 * - if the per-sb default is different from the global default 611 * - if the per-sb default is different from the global default
613 */ 612 */
614static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) 613static int ext3_show_options(struct seq_file *seq, struct dentry *root)
615{ 614{
616 struct super_block *sb = vfs->mnt_sb; 615 struct super_block *sb = root->d_sb;
617 struct ext3_sb_info *sbi = EXT3_SB(sb); 616 struct ext3_sb_info *sbi = EXT3_SB(sb);
618 struct ext3_super_block *es = sbi->s_es; 617 struct ext3_super_block *es = sbi->s_es;
619 unsigned long def_mount_opts; 618 unsigned long def_mount_opts;
@@ -2910,7 +2909,7 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2910 return -EINVAL; 2909 return -EINVAL;
2911 2910
2912 /* Quotafile not on the same filesystem? */ 2911 /* Quotafile not on the same filesystem? */
2913 if (path->mnt->mnt_sb != sb) 2912 if (path->dentry->d_sb != sb)
2914 return -EXDEV; 2913 return -EXDEV;
2915 /* Journaling quota? */ 2914 /* Journaling quota? */
2916 if (EXT3_SB(sb)->s_qf_names[type]) { 2915 if (EXT3_SB(sb)->s_qf_names[type]) {
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 5b0e26a1272d..1554b15f91bc 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1819,7 +1819,7 @@ extern int ext4fs_dirhash(const char *name, int len, struct
1819 dx_hash_info *hinfo); 1819 dx_hash_info *hinfo);
1820 1820
1821/* ialloc.c */ 1821/* ialloc.c */
1822extern struct inode *ext4_new_inode(handle_t *, struct inode *, int, 1822extern struct inode *ext4_new_inode(handle_t *, struct inode *, umode_t,
1823 const struct qstr *qstr, __u32 goal, 1823 const struct qstr *qstr, __u32 goal,
1824 uid_t *owner); 1824 uid_t *owner);
1825extern void ext4_free_inode(handle_t *, struct inode *); 1825extern void ext4_free_inode(handle_t *, struct inode *);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 00beb4f9cc4f..4637af036d9c 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -351,7 +351,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
351 */ 351 */
352 352
353static int find_group_orlov(struct super_block *sb, struct inode *parent, 353static int find_group_orlov(struct super_block *sb, struct inode *parent,
354 ext4_group_t *group, int mode, 354 ext4_group_t *group, umode_t mode,
355 const struct qstr *qstr) 355 const struct qstr *qstr)
356{ 356{
357 ext4_group_t parent_group = EXT4_I(parent)->i_block_group; 357 ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
@@ -497,7 +497,7 @@ fallback_retry:
497} 497}
498 498
499static int find_group_other(struct super_block *sb, struct inode *parent, 499static int find_group_other(struct super_block *sb, struct inode *parent,
500 ext4_group_t *group, int mode) 500 ext4_group_t *group, umode_t mode)
501{ 501{
502 ext4_group_t parent_group = EXT4_I(parent)->i_block_group; 502 ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
503 ext4_group_t i, last, ngroups = ext4_get_groups_count(sb); 503 ext4_group_t i, last, ngroups = ext4_get_groups_count(sb);
@@ -602,7 +602,7 @@ static int find_group_other(struct super_block *sb, struct inode *parent,
602 */ 602 */
603static int ext4_claim_inode(struct super_block *sb, 603static int ext4_claim_inode(struct super_block *sb,
604 struct buffer_head *inode_bitmap_bh, 604 struct buffer_head *inode_bitmap_bh,
605 unsigned long ino, ext4_group_t group, int mode) 605 unsigned long ino, ext4_group_t group, umode_t mode)
606{ 606{
607 int free = 0, retval = 0, count; 607 int free = 0, retval = 0, count;
608 struct ext4_sb_info *sbi = EXT4_SB(sb); 608 struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -690,7 +690,7 @@ err_ret:
690 * For other inodes, search forward from the parent directory's block 690 * For other inodes, search forward from the parent directory's block
691 * group to find a free inode. 691 * group to find a free inode.
692 */ 692 */
693struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode, 693struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, umode_t mode,
694 const struct qstr *qstr, __u32 goal, uid_t *owner) 694 const struct qstr *qstr, __u32 goal, uid_t *owner)
695{ 695{
696 struct super_block *sb; 696 struct super_block *sb;
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index a56796814d6a..d37b3bb2a3b8 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -45,7 +45,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
45 if (get_user(flags, (int __user *) arg)) 45 if (get_user(flags, (int __user *) arg))
46 return -EFAULT; 46 return -EFAULT;
47 47
48 err = mnt_want_write(filp->f_path.mnt); 48 err = mnt_want_write_file(filp);
49 if (err) 49 if (err)
50 return err; 50 return err;
51 51
@@ -134,7 +134,7 @@ flags_err:
134 err = ext4_ext_migrate(inode); 134 err = ext4_ext_migrate(inode);
135flags_out: 135flags_out:
136 mutex_unlock(&inode->i_mutex); 136 mutex_unlock(&inode->i_mutex);
137 mnt_drop_write(filp->f_path.mnt); 137 mnt_drop_write_file(filp);
138 return err; 138 return err;
139 } 139 }
140 case EXT4_IOC_GETVERSION: 140 case EXT4_IOC_GETVERSION:
@@ -150,7 +150,7 @@ flags_out:
150 if (!inode_owner_or_capable(inode)) 150 if (!inode_owner_or_capable(inode))
151 return -EPERM; 151 return -EPERM;
152 152
153 err = mnt_want_write(filp->f_path.mnt); 153 err = mnt_want_write_file(filp);
154 if (err) 154 if (err)
155 return err; 155 return err;
156 if (get_user(generation, (int __user *) arg)) { 156 if (get_user(generation, (int __user *) arg)) {
@@ -171,7 +171,7 @@ flags_out:
171 } 171 }
172 ext4_journal_stop(handle); 172 ext4_journal_stop(handle);
173setversion_out: 173setversion_out:
174 mnt_drop_write(filp->f_path.mnt); 174 mnt_drop_write_file(filp);
175 return err; 175 return err;
176 } 176 }
177 case EXT4_IOC_GROUP_EXTEND: { 177 case EXT4_IOC_GROUP_EXTEND: {
@@ -192,7 +192,7 @@ setversion_out:
192 return -EOPNOTSUPP; 192 return -EOPNOTSUPP;
193 } 193 }
194 194
195 err = mnt_want_write(filp->f_path.mnt); 195 err = mnt_want_write_file(filp);
196 if (err) 196 if (err)
197 return err; 197 return err;
198 198
@@ -204,7 +204,7 @@ setversion_out:
204 } 204 }
205 if (err == 0) 205 if (err == 0)
206 err = err2; 206 err = err2;
207 mnt_drop_write(filp->f_path.mnt); 207 mnt_drop_write_file(filp);
208 ext4_resize_end(sb); 208 ext4_resize_end(sb);
209 209
210 return err; 210 return err;
@@ -240,13 +240,13 @@ setversion_out:
240 return -EOPNOTSUPP; 240 return -EOPNOTSUPP;
241 } 241 }
242 242
243 err = mnt_want_write(filp->f_path.mnt); 243 err = mnt_want_write_file(filp);
244 if (err) 244 if (err)
245 goto mext_out; 245 goto mext_out;
246 246
247 err = ext4_move_extents(filp, donor_filp, me.orig_start, 247 err = ext4_move_extents(filp, donor_filp, me.orig_start,
248 me.donor_start, me.len, &me.moved_len); 248 me.donor_start, me.len, &me.moved_len);
249 mnt_drop_write(filp->f_path.mnt); 249 mnt_drop_write_file(filp);
250 if (me.moved_len > 0) 250 if (me.moved_len > 0)
251 file_remove_suid(donor_filp); 251 file_remove_suid(donor_filp);
252 252
@@ -277,7 +277,7 @@ mext_out:
277 return -EOPNOTSUPP; 277 return -EOPNOTSUPP;
278 } 278 }
279 279
280 err = mnt_want_write(filp->f_path.mnt); 280 err = mnt_want_write_file(filp);
281 if (err) 281 if (err)
282 return err; 282 return err;
283 283
@@ -289,7 +289,7 @@ mext_out:
289 } 289 }
290 if (err == 0) 290 if (err == 0)
291 err = err2; 291 err = err2;
292 mnt_drop_write(filp->f_path.mnt); 292 mnt_drop_write_file(filp);
293 ext4_resize_end(sb); 293 ext4_resize_end(sb);
294 294
295 return err; 295 return err;
@@ -301,7 +301,7 @@ mext_out:
301 if (!inode_owner_or_capable(inode)) 301 if (!inode_owner_or_capable(inode))
302 return -EACCES; 302 return -EACCES;
303 303
304 err = mnt_want_write(filp->f_path.mnt); 304 err = mnt_want_write_file(filp);
305 if (err) 305 if (err)
306 return err; 306 return err;
307 /* 307 /*
@@ -313,7 +313,7 @@ mext_out:
313 mutex_lock(&(inode->i_mutex)); 313 mutex_lock(&(inode->i_mutex));
314 err = ext4_ext_migrate(inode); 314 err = ext4_ext_migrate(inode);
315 mutex_unlock(&(inode->i_mutex)); 315 mutex_unlock(&(inode->i_mutex));
316 mnt_drop_write(filp->f_path.mnt); 316 mnt_drop_write_file(filp);
317 return err; 317 return err;
318 } 318 }
319 319
@@ -323,11 +323,11 @@ mext_out:
323 if (!inode_owner_or_capable(inode)) 323 if (!inode_owner_or_capable(inode))
324 return -EACCES; 324 return -EACCES;
325 325
326 err = mnt_want_write(filp->f_path.mnt); 326 err = mnt_want_write_file(filp);
327 if (err) 327 if (err)
328 return err; 328 return err;
329 err = ext4_alloc_da_blocks(inode); 329 err = ext4_alloc_da_blocks(inode);
330 mnt_drop_write(filp->f_path.mnt); 330 mnt_drop_write_file(filp);
331 return err; 331 return err;
332 } 332 }
333 333
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index aa4c782c9dd7..86edc45b52a4 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1736,7 +1736,7 @@ static int ext4_add_nondir(handle_t *handle,
1736 * If the create succeeds, we fill in the inode information 1736 * If the create succeeds, we fill in the inode information
1737 * with d_instantiate(). 1737 * with d_instantiate().
1738 */ 1738 */
1739static int ext4_create(struct inode *dir, struct dentry *dentry, int mode, 1739static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
1740 struct nameidata *nd) 1740 struct nameidata *nd)
1741{ 1741{
1742 handle_t *handle; 1742 handle_t *handle;
@@ -1770,7 +1770,7 @@ retry:
1770} 1770}
1771 1771
1772static int ext4_mknod(struct inode *dir, struct dentry *dentry, 1772static int ext4_mknod(struct inode *dir, struct dentry *dentry,
1773 int mode, dev_t rdev) 1773 umode_t mode, dev_t rdev)
1774{ 1774{
1775 handle_t *handle; 1775 handle_t *handle;
1776 struct inode *inode; 1776 struct inode *inode;
@@ -1806,7 +1806,7 @@ retry:
1806 return err; 1806 return err;
1807} 1807}
1808 1808
1809static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) 1809static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1810{ 1810{
1811 handle_t *handle; 1811 handle_t *handle;
1812 struct inode *inode; 1812 struct inode *inode;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 3e1329e2f826..6733b3736b3b 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -930,7 +930,6 @@ static int ext4_drop_inode(struct inode *inode)
930static void ext4_i_callback(struct rcu_head *head) 930static void ext4_i_callback(struct rcu_head *head)
931{ 931{
932 struct inode *inode = container_of(head, struct inode, i_rcu); 932 struct inode *inode = container_of(head, struct inode, i_rcu);
933 INIT_LIST_HEAD(&inode->i_dentry);
934 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); 933 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
935} 934}
936 935
@@ -1033,11 +1032,11 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
1033 * - it's set to a non-default value OR 1032 * - it's set to a non-default value OR
1034 * - if the per-sb default is different from the global default 1033 * - if the per-sb default is different from the global default
1035 */ 1034 */
1036static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) 1035static int ext4_show_options(struct seq_file *seq, struct dentry *root)
1037{ 1036{
1038 int def_errors; 1037 int def_errors;
1039 unsigned long def_mount_opts; 1038 unsigned long def_mount_opts;
1040 struct super_block *sb = vfs->mnt_sb; 1039 struct super_block *sb = root->d_sb;
1041 struct ext4_sb_info *sbi = EXT4_SB(sb); 1040 struct ext4_sb_info *sbi = EXT4_SB(sb);
1042 struct ext4_super_block *es = sbi->s_es; 1041 struct ext4_super_block *es = sbi->s_es;
1043 1042
@@ -4782,7 +4781,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
4782 return -EINVAL; 4781 return -EINVAL;
4783 4782
4784 /* Quotafile not on the same filesystem? */ 4783 /* Quotafile not on the same filesystem? */
4785 if (path->mnt->mnt_sb != sb) 4784 if (path->dentry->d_sb != sb)
4786 return -EXDEV; 4785 return -EXDEV;
4787 /* Journaling quota? */ 4786 /* Journaling quota? */
4788 if (EXT4_SB(sb)->s_qf_names[type]) { 4787 if (EXT4_SB(sb)->s_qf_names[type]) {
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 1510a4d51990..66994f316e18 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -141,7 +141,7 @@ static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
141static inline int fat_mode_can_hold_ro(struct inode *inode) 141static inline int fat_mode_can_hold_ro(struct inode *inode)
142{ 142{
143 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); 143 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
144 mode_t mask; 144 umode_t mask;
145 145
146 if (S_ISDIR(inode->i_mode)) { 146 if (S_ISDIR(inode->i_mode)) {
147 if (!sbi->options.rodir) 147 if (!sbi->options.rodir)
@@ -156,8 +156,8 @@ static inline int fat_mode_can_hold_ro(struct inode *inode)
156} 156}
157 157
158/* Convert attribute bits and a mask to the UNIX mode. */ 158/* Convert attribute bits and a mask to the UNIX mode. */
159static inline mode_t fat_make_mode(struct msdos_sb_info *sbi, 159static inline umode_t fat_make_mode(struct msdos_sb_info *sbi,
160 u8 attrs, mode_t mode) 160 u8 attrs, umode_t mode)
161{ 161{
162 if (attrs & ATTR_RO && !((attrs & ATTR_DIR) && !sbi->options.rodir)) 162 if (attrs & ATTR_RO && !((attrs & ATTR_DIR) && !sbi->options.rodir))
163 mode &= ~S_IWUGO; 163 mode &= ~S_IWUGO;
diff --git a/fs/fat/file.c b/fs/fat/file.c
index c118acf16e43..a71fe3715ee8 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -44,7 +44,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
44 goto out; 44 goto out;
45 45
46 mutex_lock(&inode->i_mutex); 46 mutex_lock(&inode->i_mutex);
47 err = mnt_want_write(file->f_path.mnt); 47 err = mnt_want_write_file(file);
48 if (err) 48 if (err)
49 goto out_unlock_inode; 49 goto out_unlock_inode;
50 50
@@ -108,7 +108,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
108 fat_save_attrs(inode, attr); 108 fat_save_attrs(inode, attr);
109 mark_inode_dirty(inode); 109 mark_inode_dirty(inode);
110out_drop_write: 110out_drop_write:
111 mnt_drop_write(file->f_path.mnt); 111 mnt_drop_write_file(file);
112out_unlock_inode: 112out_unlock_inode:
113 mutex_unlock(&inode->i_mutex); 113 mutex_unlock(&inode->i_mutex);
114out: 114out:
@@ -314,7 +314,7 @@ EXPORT_SYMBOL_GPL(fat_getattr);
314static int fat_sanitize_mode(const struct msdos_sb_info *sbi, 314static int fat_sanitize_mode(const struct msdos_sb_info *sbi,
315 struct inode *inode, umode_t *mode_ptr) 315 struct inode *inode, umode_t *mode_ptr)
316{ 316{
317 mode_t mask, perm; 317 umode_t mask, perm;
318 318
319 /* 319 /*
320 * Note, the basic check is already done by a caller of 320 * Note, the basic check is already done by a caller of
@@ -351,7 +351,7 @@ static int fat_sanitize_mode(const struct msdos_sb_info *sbi,
351 351
352static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode) 352static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode)
353{ 353{
354 mode_t allow_utime = sbi->options.allow_utime; 354 umode_t allow_utime = sbi->options.allow_utime;
355 355
356 if (current_fsuid() != inode->i_uid) { 356 if (current_fsuid() != inode->i_uid) {
357 if (in_group_p(inode->i_gid)) 357 if (in_group_p(inode->i_gid))
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 808cac7edcfb..7873797cc76a 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -518,7 +518,6 @@ static struct inode *fat_alloc_inode(struct super_block *sb)
518static void fat_i_callback(struct rcu_head *head) 518static void fat_i_callback(struct rcu_head *head)
519{ 519{
520 struct inode *inode = container_of(head, struct inode, i_rcu); 520 struct inode *inode = container_of(head, struct inode, i_rcu);
521 INIT_LIST_HEAD(&inode->i_dentry);
522 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); 521 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode));
523} 522}
524 523
@@ -672,7 +671,7 @@ int fat_sync_inode(struct inode *inode)
672 671
673EXPORT_SYMBOL_GPL(fat_sync_inode); 672EXPORT_SYMBOL_GPL(fat_sync_inode);
674 673
675static int fat_show_options(struct seq_file *m, struct vfsmount *mnt); 674static int fat_show_options(struct seq_file *m, struct dentry *root);
676static const struct super_operations fat_sops = { 675static const struct super_operations fat_sops = {
677 .alloc_inode = fat_alloc_inode, 676 .alloc_inode = fat_alloc_inode,
678 .destroy_inode = fat_destroy_inode, 677 .destroy_inode = fat_destroy_inode,
@@ -811,9 +810,9 @@ static const struct export_operations fat_export_ops = {
811 .get_parent = fat_get_parent, 810 .get_parent = fat_get_parent,
812}; 811};
813 812
814static int fat_show_options(struct seq_file *m, struct vfsmount *mnt) 813static int fat_show_options(struct seq_file *m, struct dentry *root)
815{ 814{
816 struct msdos_sb_info *sbi = MSDOS_SB(mnt->mnt_sb); 815 struct msdos_sb_info *sbi = MSDOS_SB(root->d_sb);
817 struct fat_mount_options *opts = &sbi->options; 816 struct fat_mount_options *opts = &sbi->options;
818 int isvfat = opts->isvfat; 817 int isvfat = opts->isvfat;
819 818
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 216b419f30e2..c5938c9084b9 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -264,7 +264,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
264} 264}
265 265
266/***** Create a file */ 266/***** Create a file */
267static int msdos_create(struct inode *dir, struct dentry *dentry, int mode, 267static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
268 struct nameidata *nd) 268 struct nameidata *nd)
269{ 269{
270 struct super_block *sb = dir->i_sb; 270 struct super_block *sb = dir->i_sb;
@@ -346,7 +346,7 @@ out:
346} 346}
347 347
348/***** Make a directory */ 348/***** Make a directory */
349static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode) 349static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
350{ 350{
351 struct super_block *sb = dir->i_sb; 351 struct super_block *sb = dir->i_sb;
352 struct fat_slot_info sinfo; 352 struct fat_slot_info sinfo;
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index a87a65663c25..3a444b4e2368 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -781,7 +781,7 @@ error:
781 return ERR_PTR(err); 781 return ERR_PTR(err);
782} 782}
783 783
784static int vfat_create(struct inode *dir, struct dentry *dentry, int mode, 784static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
785 struct nameidata *nd) 785 struct nameidata *nd)
786{ 786{
787 struct super_block *sb = dir->i_sb; 787 struct super_block *sb = dir->i_sb;
@@ -870,7 +870,7 @@ out:
870 return err; 870 return err;
871} 871}
872 872
873static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode) 873static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
874{ 874{
875 struct super_block *sb = dir->i_sb; 875 struct super_block *sb = dir->i_sb;
876 struct inode *inode; 876 struct inode *inode;
diff --git a/fs/fhandle.c b/fs/fhandle.c
index 6b088641f5bf..a48e4a139be1 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -10,6 +10,7 @@
10#include <linux/personality.h> 10#include <linux/personality.h>
11#include <asm/uaccess.h> 11#include <asm/uaccess.h>
12#include "internal.h" 12#include "internal.h"
13#include "mount.h"
13 14
14static long do_sys_name_to_handle(struct path *path, 15static long do_sys_name_to_handle(struct path *path,
15 struct file_handle __user *ufh, 16 struct file_handle __user *ufh,
@@ -24,8 +25,8 @@ static long do_sys_name_to_handle(struct path *path,
24 * We need t make sure wether the file system 25 * We need t make sure wether the file system
25 * support decoding of the file handle 26 * support decoding of the file handle
26 */ 27 */
27 if (!path->mnt->mnt_sb->s_export_op || 28 if (!path->dentry->d_sb->s_export_op ||
28 !path->mnt->mnt_sb->s_export_op->fh_to_dentry) 29 !path->dentry->d_sb->s_export_op->fh_to_dentry)
29 return -EOPNOTSUPP; 30 return -EOPNOTSUPP;
30 31
31 if (copy_from_user(&f_handle, ufh, sizeof(struct file_handle))) 32 if (copy_from_user(&f_handle, ufh, sizeof(struct file_handle)))
@@ -66,7 +67,8 @@ static long do_sys_name_to_handle(struct path *path,
66 } else 67 } else
67 retval = 0; 68 retval = 0;
68 /* copy the mount id */ 69 /* copy the mount id */
69 if (copy_to_user(mnt_id, &path->mnt->mnt_id, sizeof(*mnt_id)) || 70 if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
71 sizeof(*mnt_id)) ||
70 copy_to_user(ufh, handle, 72 copy_to_user(ufh, handle,
71 sizeof(struct file_handle) + handle_bytes)) 73 sizeof(struct file_handle) + handle_bytes))
72 retval = -EFAULT; 74 retval = -EFAULT;
diff --git a/fs/file_table.c b/fs/file_table.c
index c322794f7360..20002e39754d 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -474,29 +474,6 @@ void file_sb_list_del(struct file *file)
474 474
475#endif 475#endif
476 476
477int fs_may_remount_ro(struct super_block *sb)
478{
479 struct file *file;
480 /* Check that no files are currently opened for writing. */
481 lg_global_lock(files_lglock);
482 do_file_list_for_each_entry(sb, file) {
483 struct inode *inode = file->f_path.dentry->d_inode;
484
485 /* File with pending delete? */
486 if (inode->i_nlink == 0)
487 goto too_bad;
488
489 /* Writeable file? */
490 if (S_ISREG(inode->i_mode) && (file->f_mode & FMODE_WRITE))
491 goto too_bad;
492 } while_file_list_for_each_entry;
493 lg_global_unlock(files_lglock);
494 return 1; /* Tis' cool bro. */
495too_bad:
496 lg_global_unlock(files_lglock);
497 return 0;
498}
499
500/** 477/**
501 * mark_files_ro - mark all files read-only 478 * mark_files_ro - mark all files read-only
502 * @sb: superblock in question 479 * @sb: superblock in question
diff --git a/fs/filesystems.c b/fs/filesystems.c
index 0845f84f2a5f..96f24286667a 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -74,7 +74,6 @@ int register_filesystem(struct file_system_type * fs)
74 BUG_ON(strchr(fs->name, '.')); 74 BUG_ON(strchr(fs->name, '.'));
75 if (fs->next) 75 if (fs->next)
76 return -EBUSY; 76 return -EBUSY;
77 INIT_LIST_HEAD(&fs->fs_supers);
78 write_lock(&file_systems_lock); 77 write_lock(&file_systems_lock);
79 p = find_filesystem(fs->name, strlen(fs->name)); 78 p = find_filesystem(fs->name, strlen(fs->name));
80 if (*p) 79 if (*p)
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index 7b2af5abe2fa..cf9ef918a2a9 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -187,10 +187,10 @@ vxfs_stiget(struct super_block *sbp, ino_t ino)
187 * vxfs_transmod returns a Linux mode_t for a given 187 * vxfs_transmod returns a Linux mode_t for a given
188 * VxFS inode structure. 188 * VxFS inode structure.
189 */ 189 */
190static __inline__ mode_t 190static __inline__ umode_t
191vxfs_transmod(struct vxfs_inode_info *vip) 191vxfs_transmod(struct vxfs_inode_info *vip)
192{ 192{
193 mode_t ret = vip->vii_mode & ~VXFS_TYPE_MASK; 193 umode_t ret = vip->vii_mode & ~VXFS_TYPE_MASK;
194 194
195 if (VXFS_ISFIFO(vip)) 195 if (VXFS_ISFIFO(vip))
196 ret |= S_IFIFO; 196 ret |= S_IFIFO;
@@ -340,7 +340,6 @@ vxfs_iget(struct super_block *sbp, ino_t ino)
340static void vxfs_i_callback(struct rcu_head *head) 340static void vxfs_i_callback(struct rcu_head *head)
341{ 341{
342 struct inode *inode = container_of(head, struct inode, i_rcu); 342 struct inode *inode = container_of(head, struct inode, i_rcu);
343 INIT_LIST_HEAD(&inode->i_dentry);
344 kmem_cache_free(vxfs_inode_cachep, inode->i_private); 343 kmem_cache_free(vxfs_inode_cachep, inode->i_private);
345} 344}
346 345
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 517f211a3bd4..80a4574028f1 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -25,7 +25,6 @@
25#include <linux/writeback.h> 25#include <linux/writeback.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/backing-dev.h> 27#include <linux/backing-dev.h>
28#include <linux/buffer_head.h>
29#include <linux/tracepoint.h> 28#include <linux/tracepoint.h>
30#include "internal.h" 29#include "internal.h"
31 30
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 9f63e493a9b6..5ddd6ea8f839 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -369,8 +369,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
369 * If the filesystem doesn't support this, then fall back to separate 369 * If the filesystem doesn't support this, then fall back to separate
370 * 'mknod' + 'open' requests. 370 * 'mknod' + 'open' requests.
371 */ 371 */
372static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, 372static int fuse_create_open(struct inode *dir, struct dentry *entry,
373 struct nameidata *nd) 373 umode_t mode, struct nameidata *nd)
374{ 374{
375 int err; 375 int err;
376 struct inode *inode; 376 struct inode *inode;
@@ -480,7 +480,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
480 */ 480 */
481static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, 481static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req,
482 struct inode *dir, struct dentry *entry, 482 struct inode *dir, struct dentry *entry,
483 int mode) 483 umode_t mode)
484{ 484{
485 struct fuse_entry_out outarg; 485 struct fuse_entry_out outarg;
486 struct inode *inode; 486 struct inode *inode;
@@ -547,7 +547,7 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req,
547 return err; 547 return err;
548} 548}
549 549
550static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, 550static int fuse_mknod(struct inode *dir, struct dentry *entry, umode_t mode,
551 dev_t rdev) 551 dev_t rdev)
552{ 552{
553 struct fuse_mknod_in inarg; 553 struct fuse_mknod_in inarg;
@@ -573,7 +573,7 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode,
573 return create_new_entry(fc, req, dir, entry, mode); 573 return create_new_entry(fc, req, dir, entry, mode);
574} 574}
575 575
576static int fuse_create(struct inode *dir, struct dentry *entry, int mode, 576static int fuse_create(struct inode *dir, struct dentry *entry, umode_t mode,
577 struct nameidata *nd) 577 struct nameidata *nd)
578{ 578{
579 if (nd) { 579 if (nd) {
@@ -585,7 +585,7 @@ static int fuse_create(struct inode *dir, struct dentry *entry, int mode,
585 return fuse_mknod(dir, entry, mode, 0); 585 return fuse_mknod(dir, entry, mode, 0);
586} 586}
587 587
588static int fuse_mkdir(struct inode *dir, struct dentry *entry, int mode) 588static int fuse_mkdir(struct inode *dir, struct dentry *entry, umode_t mode)
589{ 589{
590 struct fuse_mkdir_in inarg; 590 struct fuse_mkdir_in inarg;
591 struct fuse_conn *fc = get_fuse_conn(dir); 591 struct fuse_conn *fc = get_fuse_conn(dir);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index cf6db0a93219..1964da0257d9 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -80,7 +80,7 @@ struct fuse_inode {
80 80
81 /** The sticky bit in inode->i_mode may have been removed, so 81 /** The sticky bit in inode->i_mode may have been removed, so
82 preserve the original mode */ 82 preserve the original mode */
83 mode_t orig_i_mode; 83 umode_t orig_i_mode;
84 84
85 /** Version of last attribute change */ 85 /** Version of last attribute change */
86 u64 attr_version; 86 u64 attr_version;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index aa83109b9431..64cf8d07393e 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -107,7 +107,6 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
107static void fuse_i_callback(struct rcu_head *head) 107static void fuse_i_callback(struct rcu_head *head)
108{ 108{
109 struct inode *inode = container_of(head, struct inode, i_rcu); 109 struct inode *inode = container_of(head, struct inode, i_rcu);
110 INIT_LIST_HEAD(&inode->i_dentry);
111 kmem_cache_free(fuse_inode_cachep, inode); 110 kmem_cache_free(fuse_inode_cachep, inode);
112} 111}
113 112
@@ -498,9 +497,10 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
498 return 1; 497 return 1;
499} 498}
500 499
501static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt) 500static int fuse_show_options(struct seq_file *m, struct dentry *root)
502{ 501{
503 struct fuse_conn *fc = get_fuse_conn_super(mnt->mnt_sb); 502 struct super_block *sb = root->d_sb;
503 struct fuse_conn *fc = get_fuse_conn_super(sb);
504 504
505 seq_printf(m, ",user_id=%u", fc->user_id); 505 seq_printf(m, ",user_id=%u", fc->user_id);
506 seq_printf(m, ",group_id=%u", fc->group_id); 506 seq_printf(m, ",group_id=%u", fc->group_id);
@@ -510,9 +510,8 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
510 seq_puts(m, ",allow_other"); 510 seq_puts(m, ",allow_other");
511 if (fc->max_read != ~0) 511 if (fc->max_read != ~0)
512 seq_printf(m, ",max_read=%u", fc->max_read); 512 seq_printf(m, ",max_read=%u", fc->max_read);
513 if (mnt->mnt_sb->s_bdev && 513 if (sb->s_bdev && sb->s_blocksize != FUSE_DEFAULT_BLKSIZE)
514 mnt->mnt_sb->s_blocksize != FUSE_DEFAULT_BLKSIZE) 514 seq_printf(m, ",blksize=%lu", sb->s_blocksize);
515 seq_printf(m, ",blksize=%lu", mnt->mnt_sb->s_blocksize);
516 return 0; 515 return 0;
517} 516}
518 517
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index ce36a56dfeac..b8927d4f3bf2 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -223,7 +223,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
223 int error; 223 int error;
224 u32 new_flags, flags; 224 u32 new_flags, flags;
225 225
226 error = mnt_want_write(filp->f_path.mnt); 226 error = mnt_want_write_file(filp);
227 if (error) 227 if (error)
228 return error; 228 return error;
229 229
@@ -285,7 +285,7 @@ out_trans_end:
285out: 285out:
286 gfs2_glock_dq_uninit(&gh); 286 gfs2_glock_dq_uninit(&gh);
287out_drop_write: 287out_drop_write:
288 mnt_drop_write(filp->f_path.mnt); 288 mnt_drop_write_file(filp);
289 return error; 289 return error;
290} 290}
291 291
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index cfd4959b218c..4b0e59e0a249 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -333,7 +333,7 @@ out:
333 */ 333 */
334 334
335static int create_ok(struct gfs2_inode *dip, const struct qstr *name, 335static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
336 unsigned int mode) 336 umode_t mode)
337{ 337{
338 int error; 338 int error;
339 339
@@ -364,7 +364,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
364 return 0; 364 return 0;
365} 365}
366 366
367static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode, 367static void munge_mode_uid_gid(struct gfs2_inode *dip, umode_t *mode,
368 unsigned int *uid, unsigned int *gid) 368 unsigned int *uid, unsigned int *gid)
369{ 369{
370 if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir && 370 if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
@@ -447,7 +447,7 @@ static void gfs2_init_dir(struct buffer_head *dibh,
447 */ 447 */
448 448
449static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, 449static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
450 const struct gfs2_inum_host *inum, unsigned int mode, 450 const struct gfs2_inum_host *inum, umode_t mode,
451 unsigned int uid, unsigned int gid, 451 unsigned int uid, unsigned int gid,
452 const u64 *generation, dev_t dev, const char *symname, 452 const u64 *generation, dev_t dev, const char *symname,
453 unsigned size, struct buffer_head **bhp) 453 unsigned size, struct buffer_head **bhp)
@@ -516,7 +516,7 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
516} 516}
517 517
518static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, 518static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
519 unsigned int mode, const struct gfs2_inum_host *inum, 519 umode_t mode, const struct gfs2_inum_host *inum,
520 const u64 *generation, dev_t dev, const char *symname, 520 const u64 *generation, dev_t dev, const char *symname,
521 unsigned int size, struct buffer_head **bhp) 521 unsigned int size, struct buffer_head **bhp)
522{ 522{
@@ -659,7 +659,7 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip,
659 */ 659 */
660 660
661static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, 661static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
662 unsigned int mode, dev_t dev, const char *symname, 662 umode_t mode, dev_t dev, const char *symname,
663 unsigned int size, int excl) 663 unsigned int size, int excl)
664{ 664{
665 const struct qstr *name = &dentry->d_name; 665 const struct qstr *name = &dentry->d_name;
@@ -760,7 +760,7 @@ fail:
760 */ 760 */
761 761
762static int gfs2_create(struct inode *dir, struct dentry *dentry, 762static int gfs2_create(struct inode *dir, struct dentry *dentry,
763 int mode, struct nameidata *nd) 763 umode_t mode, struct nameidata *nd)
764{ 764{
765 int excl = 0; 765 int excl = 0;
766 if (nd && (nd->flags & LOOKUP_EXCL)) 766 if (nd && (nd->flags & LOOKUP_EXCL))
@@ -1129,7 +1129,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
1129 * Returns: errno 1129 * Returns: errno
1130 */ 1130 */
1131 1131
1132static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) 1132static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1133{ 1133{
1134 return gfs2_create_inode(dir, dentry, S_IFDIR | mode, 0, NULL, 0, 0); 1134 return gfs2_create_inode(dir, dentry, S_IFDIR | mode, 0, NULL, 0, 0);
1135} 1135}
@@ -1143,7 +1143,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
1143 * 1143 *
1144 */ 1144 */
1145 1145
1146static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, 1146static int gfs2_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
1147 dev_t dev) 1147 dev_t dev)
1148{ 1148{
1149 return gfs2_create_inode(dir, dentry, mode, dev, NULL, 0, 0); 1149 return gfs2_create_inode(dir, dentry, mode, dev, NULL, 0, 0);
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 71e420989f77..10c7733a899b 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1284,18 +1284,18 @@ static int is_ancestor(const struct dentry *d1, const struct dentry *d2)
1284/** 1284/**
1285 * gfs2_show_options - Show mount options for /proc/mounts 1285 * gfs2_show_options - Show mount options for /proc/mounts
1286 * @s: seq_file structure 1286 * @s: seq_file structure
1287 * @mnt: vfsmount 1287 * @root: root of this (sub)tree
1288 * 1288 *
1289 * Returns: 0 on success or error code 1289 * Returns: 0 on success or error code
1290 */ 1290 */
1291 1291
1292static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) 1292static int gfs2_show_options(struct seq_file *s, struct dentry *root)
1293{ 1293{
1294 struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info; 1294 struct gfs2_sbd *sdp = root->d_sb->s_fs_info;
1295 struct gfs2_args *args = &sdp->sd_args; 1295 struct gfs2_args *args = &sdp->sd_args;
1296 int val; 1296 int val;
1297 1297
1298 if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir)) 1298 if (is_ancestor(root, sdp->sd_master_dir))
1299 seq_printf(s, ",meta"); 1299 seq_printf(s, ",meta");
1300 if (args->ar_lockproto[0]) 1300 if (args->ar_lockproto[0])
1301 seq_printf(s, ",lockproto=%s", args->ar_lockproto); 1301 seq_printf(s, ",lockproto=%s", args->ar_lockproto);
@@ -1582,7 +1582,6 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb)
1582static void gfs2_i_callback(struct rcu_head *head) 1582static void gfs2_i_callback(struct rcu_head *head)
1583{ 1583{
1584 struct inode *inode = container_of(head, struct inode, i_rcu); 1584 struct inode *inode = container_of(head, struct inode, i_rcu);
1585 INIT_LIST_HEAD(&inode->i_dentry);
1586 kmem_cache_free(gfs2_inode_cachep, inode); 1585 kmem_cache_free(gfs2_inode_cachep, inode);
1587} 1586}
1588 1587
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index bce4eef91a06..62fc14ea4b73 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -186,7 +186,7 @@ static int hfs_dir_release(struct inode *inode, struct file *file)
186 * a directory and return a corresponding inode, given the inode for 186 * a directory and return a corresponding inode, given the inode for
187 * the directory and the name (and its length) of the new file. 187 * the directory and the name (and its length) of the new file.
188 */ 188 */
189static int hfs_create(struct inode *dir, struct dentry *dentry, int mode, 189static int hfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
190 struct nameidata *nd) 190 struct nameidata *nd)
191{ 191{
192 struct inode *inode; 192 struct inode *inode;
@@ -216,7 +216,7 @@ static int hfs_create(struct inode *dir, struct dentry *dentry, int mode,
216 * in a directory, given the inode for the parent directory and the 216 * in a directory, given the inode for the parent directory and the
217 * name (and its length) of the new directory. 217 * name (and its length) of the new directory.
218 */ 218 */
219static int hfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 219static int hfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
220{ 220{
221 struct inode *inode; 221 struct inode *inode;
222 int res; 222 int res;
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index ad97c2d58287..1bf967c6bfdc 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -184,7 +184,7 @@ extern int hfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
184extern const struct address_space_operations hfs_aops; 184extern const struct address_space_operations hfs_aops;
185extern const struct address_space_operations hfs_btree_aops; 185extern const struct address_space_operations hfs_btree_aops;
186 186
187extern struct inode *hfs_new_inode(struct inode *, struct qstr *, int); 187extern struct inode *hfs_new_inode(struct inode *, struct qstr *, umode_t);
188extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *); 188extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *);
189extern int hfs_write_inode(struct inode *, struct writeback_control *); 189extern int hfs_write_inode(struct inode *, struct writeback_control *);
190extern int hfs_inode_setattr(struct dentry *, struct iattr *); 190extern int hfs_inode_setattr(struct dentry *, struct iattr *);
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index a1a9fdcd2a00..737dbeb64320 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -169,7 +169,7 @@ const struct address_space_operations hfs_aops = {
169/* 169/*
170 * hfs_new_inode 170 * hfs_new_inode
171 */ 171 */
172struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode) 172struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, umode_t mode)
173{ 173{
174 struct super_block *sb = dir->i_sb; 174 struct super_block *sb = dir->i_sb;
175 struct inode *inode = new_inode(sb); 175 struct inode *inode = new_inode(sb);
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 1b55f704fb22..8137fb3e6780 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -133,9 +133,9 @@ static int hfs_remount(struct super_block *sb, int *flags, char *data)
133 return 0; 133 return 0;
134} 134}
135 135
136static int hfs_show_options(struct seq_file *seq, struct vfsmount *mnt) 136static int hfs_show_options(struct seq_file *seq, struct dentry *root)
137{ 137{
138 struct hfs_sb_info *sbi = HFS_SB(mnt->mnt_sb); 138 struct hfs_sb_info *sbi = HFS_SB(root->d_sb);
139 139
140 if (sbi->s_creator != cpu_to_be32(0x3f3f3f3f)) 140 if (sbi->s_creator != cpu_to_be32(0x3f3f3f3f))
141 seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator); 141 seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator);
@@ -170,7 +170,6 @@ static struct inode *hfs_alloc_inode(struct super_block *sb)
170static void hfs_i_callback(struct rcu_head *head) 170static void hfs_i_callback(struct rcu_head *head)
171{ 171{
172 struct inode *inode = container_of(head, struct inode, i_rcu); 172 struct inode *inode = container_of(head, struct inode, i_rcu);
173 INIT_LIST_HEAD(&inode->i_dentry);
174 kmem_cache_free(hfs_inode_cachep, HFS_I(inode)); 173 kmem_cache_free(hfs_inode_cachep, HFS_I(inode));
175} 174}
176 175
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 4536cd3f15ae..88e155f895c6 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -424,7 +424,7 @@ out:
424} 424}
425 425
426static int hfsplus_mknod(struct inode *dir, struct dentry *dentry, 426static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,
427 int mode, dev_t rdev) 427 umode_t mode, dev_t rdev)
428{ 428{
429 struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); 429 struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
430 struct inode *inode; 430 struct inode *inode;
@@ -453,13 +453,13 @@ out:
453 return res; 453 return res;
454} 454}
455 455
456static int hfsplus_create(struct inode *dir, struct dentry *dentry, int mode, 456static int hfsplus_create(struct inode *dir, struct dentry *dentry, umode_t mode,
457 struct nameidata *nd) 457 struct nameidata *nd)
458{ 458{
459 return hfsplus_mknod(dir, dentry, mode, 0); 459 return hfsplus_mknod(dir, dentry, mode, 0);
460} 460}
461 461
462static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, int mode) 462static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
463{ 463{
464 return hfsplus_mknod(dir, dentry, mode | S_IFDIR, 0); 464 return hfsplus_mknod(dir, dentry, mode | S_IFDIR, 0);
465} 465}
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index d7674d051f52..21a5b7fc6db4 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -402,7 +402,7 @@ void hfsplus_inode_read_fork(struct inode *, struct hfsplus_fork_raw *);
402void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *); 402void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *);
403int hfsplus_cat_read_inode(struct inode *, struct hfs_find_data *); 403int hfsplus_cat_read_inode(struct inode *, struct hfs_find_data *);
404int hfsplus_cat_write_inode(struct inode *); 404int hfsplus_cat_write_inode(struct inode *);
405struct inode *hfsplus_new_inode(struct super_block *, int); 405struct inode *hfsplus_new_inode(struct super_block *, umode_t);
406void hfsplus_delete_inode(struct inode *); 406void hfsplus_delete_inode(struct inode *);
407int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, 407int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
408 int datasync); 408 int datasync);
@@ -419,7 +419,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size);
419int hfsplus_parse_options(char *, struct hfsplus_sb_info *); 419int hfsplus_parse_options(char *, struct hfsplus_sb_info *);
420int hfsplus_parse_options_remount(char *input, int *force); 420int hfsplus_parse_options_remount(char *input, int *force);
421void hfsplus_fill_defaults(struct hfsplus_sb_info *); 421void hfsplus_fill_defaults(struct hfsplus_sb_info *);
422int hfsplus_show_options(struct seq_file *, struct vfsmount *); 422int hfsplus_show_options(struct seq_file *, struct dentry *);
423 423
424/* super.c */ 424/* super.c */
425struct inode *hfsplus_iget(struct super_block *, unsigned long); 425struct inode *hfsplus_iget(struct super_block *, unsigned long);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 40e1413be4cf..6643b242bdd7 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -378,7 +378,7 @@ static const struct file_operations hfsplus_file_operations = {
378 .unlocked_ioctl = hfsplus_ioctl, 378 .unlocked_ioctl = hfsplus_ioctl,
379}; 379};
380 380
381struct inode *hfsplus_new_inode(struct super_block *sb, int mode) 381struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode)
382{ 382{
383 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 383 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
384 struct inode *inode = new_inode(sb); 384 struct inode *inode = new_inode(sb);
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index fbaa6690c8e0..f66c7655b3f7 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -43,7 +43,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
43 unsigned int flags; 43 unsigned int flags;
44 int err = 0; 44 int err = 0;
45 45
46 err = mnt_want_write(file->f_path.mnt); 46 err = mnt_want_write_file(file);
47 if (err) 47 if (err)
48 goto out; 48 goto out;
49 49
@@ -94,7 +94,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
94out_unlock_inode: 94out_unlock_inode:
95 mutex_unlock(&inode->i_mutex); 95 mutex_unlock(&inode->i_mutex);
96out_drop_write: 96out_drop_write:
97 mnt_drop_write(file->f_path.mnt); 97 mnt_drop_write_file(file);
98out: 98out:
99 return err; 99 return err;
100} 100}
diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
index bb62a5882147..06fa5618600c 100644
--- a/fs/hfsplus/options.c
+++ b/fs/hfsplus/options.c
@@ -206,9 +206,9 @@ done:
206 return 1; 206 return 1;
207} 207}
208 208
209int hfsplus_show_options(struct seq_file *seq, struct vfsmount *mnt) 209int hfsplus_show_options(struct seq_file *seq, struct dentry *root)
210{ 210{
211 struct hfsplus_sb_info *sbi = HFSPLUS_SB(mnt->mnt_sb); 211 struct hfsplus_sb_info *sbi = HFSPLUS_SB(root->d_sb);
212 212
213 if (sbi->creator != HFSPLUS_DEF_CR_TYPE) 213 if (sbi->creator != HFSPLUS_DEF_CR_TYPE)
214 seq_printf(seq, ",creator=%.4s", (char *)&sbi->creator); 214 seq_printf(seq, ",creator=%.4s", (char *)&sbi->creator);
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index d24a9b666a23..edf0a801446b 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -558,7 +558,6 @@ static void hfsplus_i_callback(struct rcu_head *head)
558{ 558{
559 struct inode *inode = container_of(head, struct inode, i_rcu); 559 struct inode *inode = container_of(head, struct inode, i_rcu);
560 560
561 INIT_LIST_HEAD(&inode->i_dentry);
562 kmem_cache_free(hfsplus_inode_cachep, HFSPLUS_I(inode)); 561 kmem_cache_free(hfsplus_inode_cachep, HFSPLUS_I(inode));
563} 562}
564 563
diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h
index bf15a43016b9..3cbfa93cd782 100644
--- a/fs/hostfs/hostfs.h
+++ b/fs/hostfs/hostfs.h
@@ -39,7 +39,7 @@
39 39
40struct hostfs_iattr { 40struct hostfs_iattr {
41 unsigned int ia_valid; 41 unsigned int ia_valid;
42 mode_t ia_mode; 42 unsigned short ia_mode;
43 uid_t ia_uid; 43 uid_t ia_uid;
44 gid_t ia_gid; 44 gid_t ia_gid;
45 loff_t ia_size; 45 loff_t ia_size;
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 2f72da5ae686..e130bd46d671 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -250,7 +250,6 @@ static void hostfs_evict_inode(struct inode *inode)
250static void hostfs_i_callback(struct rcu_head *head) 250static void hostfs_i_callback(struct rcu_head *head)
251{ 251{
252 struct inode *inode = container_of(head, struct inode, i_rcu); 252 struct inode *inode = container_of(head, struct inode, i_rcu);
253 INIT_LIST_HEAD(&inode->i_dentry);
254 kfree(HOSTFS_I(inode)); 253 kfree(HOSTFS_I(inode));
255} 254}
256 255
@@ -259,9 +258,9 @@ static void hostfs_destroy_inode(struct inode *inode)
259 call_rcu(&inode->i_rcu, hostfs_i_callback); 258 call_rcu(&inode->i_rcu, hostfs_i_callback);
260} 259}
261 260
262static int hostfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 261static int hostfs_show_options(struct seq_file *seq, struct dentry *root)
263{ 262{
264 const char *root_path = vfs->mnt_sb->s_fs_info; 263 const char *root_path = root->d_sb->s_fs_info;
265 size_t offset = strlen(root_ino) + 1; 264 size_t offset = strlen(root_ino) + 1;
266 265
267 if (strlen(root_path) > offset) 266 if (strlen(root_path) > offset)
@@ -552,7 +551,7 @@ static int read_name(struct inode *ino, char *name)
552 return 0; 551 return 0;
553} 552}
554 553
555int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, 554int hostfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
556 struct nameidata *nd) 555 struct nameidata *nd)
557{ 556{
558 struct inode *inode; 557 struct inode *inode;
@@ -677,7 +676,7 @@ int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
677 return err; 676 return err;
678} 677}
679 678
680int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode) 679int hostfs_mkdir(struct inode *ino, struct dentry *dentry, umode_t mode)
681{ 680{
682 char *file; 681 char *file;
683 int err; 682 int err;
@@ -701,7 +700,7 @@ int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
701 return err; 700 return err;
702} 701}
703 702
704int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) 703static int hostfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
705{ 704{
706 struct inode *inode; 705 struct inode *inode;
707 char *name; 706 char *name;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index ea91fcb0ef9b..30dd7b10b507 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -8,7 +8,7 @@
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include "hpfs_fn.h" 9#include "hpfs_fn.h"
10 10
11static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 11static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
12{ 12{
13 const unsigned char *name = dentry->d_name.name; 13 const unsigned char *name = dentry->d_name.name;
14 unsigned len = dentry->d_name.len; 14 unsigned len = dentry->d_name.len;
@@ -115,7 +115,7 @@ bail:
115 return err; 115 return err;
116} 116}
117 117
118static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) 118static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd)
119{ 119{
120 const unsigned char *name = dentry->d_name.name; 120 const unsigned char *name = dentry->d_name.name;
121 unsigned len = dentry->d_name.len; 121 unsigned len = dentry->d_name.len;
@@ -201,7 +201,7 @@ bail:
201 return err; 201 return err;
202} 202}
203 203
204static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) 204static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev)
205{ 205{
206 const unsigned char *name = dentry->d_name.name; 206 const unsigned char *name = dentry->d_name.name;
207 unsigned len = dentry->d_name.len; 207 unsigned len = dentry->d_name.len;
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 98580a3b5005..3690467c944e 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -181,7 +181,6 @@ static struct inode *hpfs_alloc_inode(struct super_block *sb)
181static void hpfs_i_callback(struct rcu_head *head) 181static void hpfs_i_callback(struct rcu_head *head)
182{ 182{
183 struct inode *inode = container_of(head, struct inode, i_rcu); 183 struct inode *inode = container_of(head, struct inode, i_rcu);
184 INIT_LIST_HEAD(&inode->i_dentry);
185 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); 184 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode));
186} 185}
187 186
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index f590b1160c6c..d92f4ce80925 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -622,7 +622,6 @@ void hppfs_evict_inode(struct inode *ino)
622static void hppfs_i_callback(struct rcu_head *head) 622static void hppfs_i_callback(struct rcu_head *head)
623{ 623{
624 struct inode *inode = container_of(head, struct inode, i_rcu); 624 struct inode *inode = container_of(head, struct inode, i_rcu);
625 INIT_LIST_HEAD(&inode->i_dentry);
626 kfree(HPPFS_I(inode)); 625 kfree(HPPFS_I(inode));
627} 626}
628 627
@@ -726,7 +725,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
726 sb->s_fs_info = proc_mnt; 725 sb->s_fs_info = proc_mnt;
727 726
728 err = -ENOMEM; 727 err = -ENOMEM;
729 root_inode = get_inode(sb, dget(proc_mnt->mnt_sb->s_root)); 728 root_inode = get_inode(sb, dget(proc_mnt->mnt_root));
730 if (!root_inode) 729 if (!root_inode)
731 goto out_mntput; 730 goto out_mntput;
732 731
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 0be5a78598d0..e425ad9d0490 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -447,8 +447,8 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
447 return 0; 447 return 0;
448} 448}
449 449
450static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, 450static struct inode *hugetlbfs_get_root(struct super_block *sb,
451 gid_t gid, int mode, dev_t dev) 451 struct hugetlbfs_config *config)
452{ 452{
453 struct inode *inode; 453 struct inode *inode;
454 454
@@ -456,9 +456,31 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
456 if (inode) { 456 if (inode) {
457 struct hugetlbfs_inode_info *info; 457 struct hugetlbfs_inode_info *info;
458 inode->i_ino = get_next_ino(); 458 inode->i_ino = get_next_ino();
459 inode->i_mode = mode; 459 inode->i_mode = S_IFDIR | config->mode;
460 inode->i_uid = uid; 460 inode->i_uid = config->uid;
461 inode->i_gid = gid; 461 inode->i_gid = config->gid;
462 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
463 info = HUGETLBFS_I(inode);
464 mpol_shared_policy_init(&info->policy, NULL);
465 inode->i_op = &hugetlbfs_dir_inode_operations;
466 inode->i_fop = &simple_dir_operations;
467 /* directory inodes start off with i_nlink == 2 (for "." entry) */
468 inc_nlink(inode);
469 }
470 return inode;
471}
472
473static struct inode *hugetlbfs_get_inode(struct super_block *sb,
474 struct inode *dir,
475 umode_t mode, dev_t dev)
476{
477 struct inode *inode;
478
479 inode = new_inode(sb);
480 if (inode) {
481 struct hugetlbfs_inode_info *info;
482 inode->i_ino = get_next_ino();
483 inode_init_owner(inode, dir, mode);
462 inode->i_mapping->a_ops = &hugetlbfs_aops; 484 inode->i_mapping->a_ops = &hugetlbfs_aops;
463 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; 485 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
464 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 486 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
@@ -500,20 +522,12 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
500 * File creation. Allocate an inode, and we're done.. 522 * File creation. Allocate an inode, and we're done..
501 */ 523 */
502static int hugetlbfs_mknod(struct inode *dir, 524static int hugetlbfs_mknod(struct inode *dir,
503 struct dentry *dentry, int mode, dev_t dev) 525 struct dentry *dentry, umode_t mode, dev_t dev)
504{ 526{
505 struct inode *inode; 527 struct inode *inode;
506 int error = -ENOSPC; 528 int error = -ENOSPC;
507 gid_t gid; 529
508 530 inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev);
509 if (dir->i_mode & S_ISGID) {
510 gid = dir->i_gid;
511 if (S_ISDIR(mode))
512 mode |= S_ISGID;
513 } else {
514 gid = current_fsgid();
515 }
516 inode = hugetlbfs_get_inode(dir->i_sb, current_fsuid(), gid, mode, dev);
517 if (inode) { 531 if (inode) {
518 dir->i_ctime = dir->i_mtime = CURRENT_TIME; 532 dir->i_ctime = dir->i_mtime = CURRENT_TIME;
519 d_instantiate(dentry, inode); 533 d_instantiate(dentry, inode);
@@ -523,7 +537,7 @@ static int hugetlbfs_mknod(struct inode *dir,
523 return error; 537 return error;
524} 538}
525 539
526static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 540static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
527{ 541{
528 int retval = hugetlbfs_mknod(dir, dentry, mode | S_IFDIR, 0); 542 int retval = hugetlbfs_mknod(dir, dentry, mode | S_IFDIR, 0);
529 if (!retval) 543 if (!retval)
@@ -531,7 +545,7 @@ static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
531 return retval; 545 return retval;
532} 546}
533 547
534static int hugetlbfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) 548static int hugetlbfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd)
535{ 549{
536 return hugetlbfs_mknod(dir, dentry, mode | S_IFREG, 0); 550 return hugetlbfs_mknod(dir, dentry, mode | S_IFREG, 0);
537} 551}
@@ -541,15 +555,8 @@ static int hugetlbfs_symlink(struct inode *dir,
541{ 555{
542 struct inode *inode; 556 struct inode *inode;
543 int error = -ENOSPC; 557 int error = -ENOSPC;
544 gid_t gid;
545
546 if (dir->i_mode & S_ISGID)
547 gid = dir->i_gid;
548 else
549 gid = current_fsgid();
550 558
551 inode = hugetlbfs_get_inode(dir->i_sb, current_fsuid(), 559 inode = hugetlbfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0);
552 gid, S_IFLNK|S_IRWXUGO, 0);
553 if (inode) { 560 if (inode) {
554 int l = strlen(symname)+1; 561 int l = strlen(symname)+1;
555 error = page_symlink(inode, symname, l); 562 error = page_symlink(inode, symname, l);
@@ -666,7 +673,6 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
666static void hugetlbfs_i_callback(struct rcu_head *head) 673static void hugetlbfs_i_callback(struct rcu_head *head)
667{ 674{
668 struct inode *inode = container_of(head, struct inode, i_rcu); 675 struct inode *inode = container_of(head, struct inode, i_rcu);
669 INIT_LIST_HEAD(&inode->i_dentry);
670 kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); 676 kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode));
671} 677}
672 678
@@ -858,8 +864,7 @@ hugetlbfs_fill_super(struct super_block *sb, void *data, int silent)
858 sb->s_magic = HUGETLBFS_MAGIC; 864 sb->s_magic = HUGETLBFS_MAGIC;
859 sb->s_op = &hugetlbfs_ops; 865 sb->s_op = &hugetlbfs_ops;
860 sb->s_time_gran = 1; 866 sb->s_time_gran = 1;
861 inode = hugetlbfs_get_inode(sb, config.uid, config.gid, 867 inode = hugetlbfs_get_root(sb, &config);
862 S_IFDIR | config.mode, 0);
863 if (!inode) 868 if (!inode)
864 goto out_free; 869 goto out_free;
865 870
@@ -957,8 +962,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size,
957 962
958 path.mnt = mntget(hugetlbfs_vfsmount); 963 path.mnt = mntget(hugetlbfs_vfsmount);
959 error = -ENOSPC; 964 error = -ENOSPC;
960 inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), 965 inode = hugetlbfs_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0);
961 current_fsgid(), S_IFREG | S_IRWXUGO, 0);
962 if (!inode) 966 if (!inode)
963 goto out_dentry; 967 goto out_dentry;
964 968
diff --git a/fs/inode.c b/fs/inode.c
index ee4e66b998f4..87535753ab04 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -26,6 +26,7 @@
26#include <linux/ima.h> 26#include <linux/ima.h>
27#include <linux/cred.h> 27#include <linux/cred.h>
28#include <linux/buffer_head.h> /* for inode_has_buffers */ 28#include <linux/buffer_head.h> /* for inode_has_buffers */
29#include <linux/ratelimit.h>
29#include "internal.h" 30#include "internal.h"
30 31
31/* 32/*
@@ -191,6 +192,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
191 } 192 }
192 inode->i_private = NULL; 193 inode->i_private = NULL;
193 inode->i_mapping = mapping; 194 inode->i_mapping = mapping;
195 INIT_LIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */
194#ifdef CONFIG_FS_POSIX_ACL 196#ifdef CONFIG_FS_POSIX_ACL
195 inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED; 197 inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
196#endif 198#endif
@@ -241,6 +243,11 @@ void __destroy_inode(struct inode *inode)
241 BUG_ON(inode_has_buffers(inode)); 243 BUG_ON(inode_has_buffers(inode));
242 security_inode_free(inode); 244 security_inode_free(inode);
243 fsnotify_inode_delete(inode); 245 fsnotify_inode_delete(inode);
246 if (!inode->i_nlink) {
247 WARN_ON(atomic_long_read(&inode->i_sb->s_remove_count) == 0);
248 atomic_long_dec(&inode->i_sb->s_remove_count);
249 }
250
244#ifdef CONFIG_FS_POSIX_ACL 251#ifdef CONFIG_FS_POSIX_ACL
245 if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED) 252 if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED)
246 posix_acl_release(inode->i_acl); 253 posix_acl_release(inode->i_acl);
@@ -254,7 +261,6 @@ EXPORT_SYMBOL(__destroy_inode);
254static void i_callback(struct rcu_head *head) 261static void i_callback(struct rcu_head *head)
255{ 262{
256 struct inode *inode = container_of(head, struct inode, i_rcu); 263 struct inode *inode = container_of(head, struct inode, i_rcu);
257 INIT_LIST_HEAD(&inode->i_dentry);
258 kmem_cache_free(inode_cachep, inode); 264 kmem_cache_free(inode_cachep, inode);
259} 265}
260 266
@@ -268,6 +274,85 @@ static void destroy_inode(struct inode *inode)
268 call_rcu(&inode->i_rcu, i_callback); 274 call_rcu(&inode->i_rcu, i_callback);
269} 275}
270 276
277/**
278 * drop_nlink - directly drop an inode's link count
279 * @inode: inode
280 *
281 * This is a low-level filesystem helper to replace any
282 * direct filesystem manipulation of i_nlink. In cases
283 * where we are attempting to track writes to the
284 * filesystem, a decrement to zero means an imminent
285 * write when the file is truncated and actually unlinked
286 * on the filesystem.
287 */
288void drop_nlink(struct inode *inode)
289{
290 WARN_ON(inode->i_nlink == 0);
291 inode->__i_nlink--;
292 if (!inode->i_nlink)
293 atomic_long_inc(&inode->i_sb->s_remove_count);
294}
295EXPORT_SYMBOL(drop_nlink);
296
297/**
298 * clear_nlink - directly zero an inode's link count
299 * @inode: inode
300 *
301 * This is a low-level filesystem helper to replace any
302 * direct filesystem manipulation of i_nlink. See
303 * drop_nlink() for why we care about i_nlink hitting zero.
304 */
305void clear_nlink(struct inode *inode)
306{
307 if (inode->i_nlink) {
308 inode->__i_nlink = 0;
309 atomic_long_inc(&inode->i_sb->s_remove_count);
310 }
311}
312EXPORT_SYMBOL(clear_nlink);
313
314/**
315 * set_nlink - directly set an inode's link count
316 * @inode: inode
317 * @nlink: new nlink (should be non-zero)
318 *
319 * This is a low-level filesystem helper to replace any
320 * direct filesystem manipulation of i_nlink.
321 */
322void set_nlink(struct inode *inode, unsigned int nlink)
323{
324 if (!nlink) {
325 printk_ratelimited(KERN_INFO
326 "set_nlink() clearing i_nlink on %s inode %li\n",
327 inode->i_sb->s_type->name, inode->i_ino);
328 clear_nlink(inode);
329 } else {
330 /* Yes, some filesystems do change nlink from zero to one */
331 if (inode->i_nlink == 0)
332 atomic_long_dec(&inode->i_sb->s_remove_count);
333
334 inode->__i_nlink = nlink;
335 }
336}
337EXPORT_SYMBOL(set_nlink);
338
339/**
340 * inc_nlink - directly increment an inode's link count
341 * @inode: inode
342 *
343 * This is a low-level filesystem helper to replace any
344 * direct filesystem manipulation of i_nlink. Currently,
345 * it is only here for parity with dec_nlink().
346 */
347void inc_nlink(struct inode *inode)
348{
349 if (WARN_ON(inode->i_nlink == 0))
350 atomic_long_dec(&inode->i_sb->s_remove_count);
351
352 inode->__i_nlink++;
353}
354EXPORT_SYMBOL(inc_nlink);
355
271void address_space_init_once(struct address_space *mapping) 356void address_space_init_once(struct address_space *mapping)
272{ 357{
273 memset(mapping, 0, sizeof(*mapping)); 358 memset(mapping, 0, sizeof(*mapping));
@@ -290,7 +375,6 @@ void inode_init_once(struct inode *inode)
290{ 375{
291 memset(inode, 0, sizeof(*inode)); 376 memset(inode, 0, sizeof(*inode));
292 INIT_HLIST_NODE(&inode->i_hash); 377 INIT_HLIST_NODE(&inode->i_hash);
293 INIT_LIST_HEAD(&inode->i_dentry);
294 INIT_LIST_HEAD(&inode->i_devices); 378 INIT_LIST_HEAD(&inode->i_devices);
295 INIT_LIST_HEAD(&inode->i_wb_list); 379 INIT_LIST_HEAD(&inode->i_wb_list);
296 INIT_LIST_HEAD(&inode->i_lru); 380 INIT_LIST_HEAD(&inode->i_lru);
@@ -1508,7 +1592,7 @@ void file_update_time(struct file *file)
1508 if (sync_it & S_MTIME) 1592 if (sync_it & S_MTIME)
1509 inode->i_mtime = now; 1593 inode->i_mtime = now;
1510 mark_inode_dirty_sync(inode); 1594 mark_inode_dirty_sync(inode);
1511 mnt_drop_write(file->f_path.mnt); 1595 mnt_drop_write_file(file);
1512} 1596}
1513EXPORT_SYMBOL(file_update_time); 1597EXPORT_SYMBOL(file_update_time);
1514 1598
@@ -1647,7 +1731,7 @@ EXPORT_SYMBOL(init_special_inode);
1647 * @mode: mode of the new inode 1731 * @mode: mode of the new inode
1648 */ 1732 */
1649void inode_init_owner(struct inode *inode, const struct inode *dir, 1733void inode_init_owner(struct inode *inode, const struct inode *dir,
1650 mode_t mode) 1734 umode_t mode)
1651{ 1735{
1652 inode->i_uid = current_fsuid(); 1736 inode->i_uid = current_fsuid();
1653 if (dir && dir->i_mode & S_ISGID) { 1737 if (dir && dir->i_mode & S_ISGID) {
diff --git a/fs/internal.h b/fs/internal.h
index fe327c20af83..9962c59ba280 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -15,19 +15,14 @@ struct super_block;
15struct file_system_type; 15struct file_system_type;
16struct linux_binprm; 16struct linux_binprm;
17struct path; 17struct path;
18struct mount;
18 19
19/* 20/*
20 * block_dev.c 21 * block_dev.c
21 */ 22 */
22#ifdef CONFIG_BLOCK 23#ifdef CONFIG_BLOCK
23extern struct super_block *blockdev_superblock;
24extern void __init bdev_cache_init(void); 24extern void __init bdev_cache_init(void);
25 25
26static inline int sb_is_blkdev_sb(struct super_block *sb)
27{
28 return sb == blockdev_superblock;
29}
30
31extern int __sync_blockdev(struct block_device *bdev, int wait); 26extern int __sync_blockdev(struct block_device *bdev, int wait);
32 27
33#else 28#else
@@ -35,11 +30,6 @@ static inline void bdev_cache_init(void)
35{ 30{
36} 31}
37 32
38static inline int sb_is_blkdev_sb(struct super_block *sb)
39{
40 return 0;
41}
42
43static inline int __sync_blockdev(struct block_device *bdev, int wait) 33static inline int __sync_blockdev(struct block_device *bdev, int wait)
44{ 34{
45 return 0; 35 return 0;
@@ -52,28 +42,17 @@ static inline int __sync_blockdev(struct block_device *bdev, int wait)
52extern void __init chrdev_init(void); 42extern void __init chrdev_init(void);
53 43
54/* 44/*
55 * exec.c
56 */
57extern int check_unsafe_exec(struct linux_binprm *);
58
59/*
60 * namespace.c 45 * namespace.c
61 */ 46 */
62extern int copy_mount_options(const void __user *, unsigned long *); 47extern int copy_mount_options(const void __user *, unsigned long *);
63extern int copy_mount_string(const void __user *, char **); 48extern int copy_mount_string(const void __user *, char **);
64 49
65extern unsigned int mnt_get_count(struct vfsmount *mnt);
66extern struct vfsmount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
67extern struct vfsmount *lookup_mnt(struct path *); 50extern struct vfsmount *lookup_mnt(struct path *);
68extern void mnt_set_mountpoint(struct vfsmount *, struct dentry *,
69 struct vfsmount *);
70extern void release_mounts(struct list_head *);
71extern void umount_tree(struct vfsmount *, int, struct list_head *);
72extern struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int);
73extern int finish_automount(struct vfsmount *, struct path *); 51extern int finish_automount(struct vfsmount *, struct path *);
74 52
75extern void mnt_make_longterm(struct vfsmount *); 53extern void mnt_make_longterm(struct vfsmount *);
76extern void mnt_make_shortterm(struct vfsmount *); 54extern void mnt_make_shortterm(struct vfsmount *);
55extern int sb_prepare_remount_readonly(struct super_block *);
77 56
78extern void __init mnt_init(void); 57extern void __init mnt_init(void);
79 58
@@ -98,10 +77,9 @@ extern struct file *get_empty_filp(void);
98 */ 77 */
99extern int do_remount_sb(struct super_block *, int, void *, int); 78extern int do_remount_sb(struct super_block *, int, void *, int);
100extern bool grab_super_passive(struct super_block *sb); 79extern bool grab_super_passive(struct super_block *sb);
101extern void __put_super(struct super_block *sb);
102extern void put_super(struct super_block *sb);
103extern struct dentry *mount_fs(struct file_system_type *, 80extern struct dentry *mount_fs(struct file_system_type *,
104 int, const char *, void *); 81 int, const char *, void *);
82extern struct super_block *user_get_super(dev_t);
105 83
106/* 84/*
107 * open.c 85 * open.c
@@ -111,7 +89,7 @@ extern struct file *nameidata_to_filp(struct nameidata *);
111extern void release_open_intent(struct nameidata *); 89extern void release_open_intent(struct nameidata *);
112struct open_flags { 90struct open_flags {
113 int open_flag; 91 int open_flag;
114 int mode; 92 umode_t mode;
115 int acc_mode; 93 int acc_mode;
116 int intent; 94 int intent;
117}; 95};
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index f950059525fc..7b99f5f460be 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -85,7 +85,6 @@ static struct inode *isofs_alloc_inode(struct super_block *sb)
85static void isofs_i_callback(struct rcu_head *head) 85static void isofs_i_callback(struct rcu_head *head)
86{ 86{
87 struct inode *inode = container_of(head, struct inode, i_rcu); 87 struct inode *inode = container_of(head, struct inode, i_rcu);
88 INIT_LIST_HEAD(&inode->i_dentry);
89 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 88 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
90} 89}
91 90
@@ -170,8 +169,8 @@ struct iso9660_options{
170 unsigned char map; 169 unsigned char map;
171 unsigned char check; 170 unsigned char check;
172 unsigned int blocksize; 171 unsigned int blocksize;
173 mode_t fmode; 172 umode_t fmode;
174 mode_t dmode; 173 umode_t dmode;
175 gid_t gid; 174 gid_t gid;
176 uid_t uid; 175 uid_t uid;
177 char *iocharset; 176 char *iocharset;
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index 7d33de84f52a..0e73f63d9274 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -50,14 +50,14 @@ struct isofs_sb_info {
50 unsigned int s_uid_set:1; 50 unsigned int s_uid_set:1;
51 unsigned int s_gid_set:1; 51 unsigned int s_gid_set:1;
52 52
53 mode_t s_fmode; 53 umode_t s_fmode;
54 mode_t s_dmode; 54 umode_t s_dmode;
55 gid_t s_gid; 55 gid_t s_gid;
56 uid_t s_uid; 56 uid_t s_uid;
57 struct nls_table *s_nls_iocharset; /* Native language support table */ 57 struct nls_table *s_nls_iocharset; /* Native language support table */
58}; 58};
59 59
60#define ISOFS_INVALID_MODE ((mode_t) -1) 60#define ISOFS_INVALID_MODE ((umode_t) -1)
61 61
62static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb) 62static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb)
63{ 63{
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index be6169bd8acd..973ac5822bd7 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -22,16 +22,16 @@
22 22
23static int jffs2_readdir (struct file *, void *, filldir_t); 23static int jffs2_readdir (struct file *, void *, filldir_t);
24 24
25static int jffs2_create (struct inode *,struct dentry *,int, 25static int jffs2_create (struct inode *,struct dentry *,umode_t,
26 struct nameidata *); 26 struct nameidata *);
27static struct dentry *jffs2_lookup (struct inode *,struct dentry *, 27static struct dentry *jffs2_lookup (struct inode *,struct dentry *,
28 struct nameidata *); 28 struct nameidata *);
29static int jffs2_link (struct dentry *,struct inode *,struct dentry *); 29static int jffs2_link (struct dentry *,struct inode *,struct dentry *);
30static int jffs2_unlink (struct inode *,struct dentry *); 30static int jffs2_unlink (struct inode *,struct dentry *);
31static int jffs2_symlink (struct inode *,struct dentry *,const char *); 31static int jffs2_symlink (struct inode *,struct dentry *,const char *);
32static int jffs2_mkdir (struct inode *,struct dentry *,int); 32static int jffs2_mkdir (struct inode *,struct dentry *,umode_t);
33static int jffs2_rmdir (struct inode *,struct dentry *); 33static int jffs2_rmdir (struct inode *,struct dentry *);
34static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t); 34static int jffs2_mknod (struct inode *,struct dentry *,umode_t,dev_t);
35static int jffs2_rename (struct inode *, struct dentry *, 35static int jffs2_rename (struct inode *, struct dentry *,
36 struct inode *, struct dentry *); 36 struct inode *, struct dentry *);
37 37
@@ -169,8 +169,8 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir)
169/***********************************************************************/ 169/***********************************************************************/
170 170
171 171
172static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode, 172static int jffs2_create(struct inode *dir_i, struct dentry *dentry,
173 struct nameidata *nd) 173 umode_t mode, struct nameidata *nd)
174{ 174{
175 struct jffs2_raw_inode *ri; 175 struct jffs2_raw_inode *ri;
176 struct jffs2_inode_info *f, *dir_f; 176 struct jffs2_inode_info *f, *dir_f;
@@ -450,7 +450,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
450} 450}
451 451
452 452
453static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) 453static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode)
454{ 454{
455 struct jffs2_inode_info *f, *dir_f; 455 struct jffs2_inode_info *f, *dir_f;
456 struct jffs2_sb_info *c; 456 struct jffs2_sb_info *c;
@@ -618,7 +618,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
618 return ret; 618 return ret;
619} 619}
620 620
621static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, dev_t rdev) 621static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode, dev_t rdev)
622{ 622{
623 struct jffs2_inode_info *f, *dir_f; 623 struct jffs2_inode_info *f, *dir_f;
624 struct jffs2_sb_info *c; 624 struct jffs2_sb_info *c;
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index e7e974454115..8be4925296cf 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -45,7 +45,6 @@ static struct inode *jffs2_alloc_inode(struct super_block *sb)
45static void jffs2_i_callback(struct rcu_head *head) 45static void jffs2_i_callback(struct rcu_head *head)
46{ 46{
47 struct inode *inode = container_of(head, struct inode, i_rcu); 47 struct inode *inode = container_of(head, struct inode, i_rcu);
48 INIT_LIST_HEAD(&inode->i_dentry);
49 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); 48 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
50} 49}
51 50
@@ -97,9 +96,9 @@ static const char *jffs2_compr_name(unsigned int compr)
97 } 96 }
98} 97}
99 98
100static int jffs2_show_options(struct seq_file *s, struct vfsmount *mnt) 99static int jffs2_show_options(struct seq_file *s, struct dentry *root)
101{ 100{
102 struct jffs2_sb_info *c = JFFS2_SB_INFO(mnt->mnt_sb); 101 struct jffs2_sb_info *c = JFFS2_SB_INFO(root->d_sb);
103 struct jffs2_mount_opts *opts = &c->mount_opts; 102 struct jffs2_mount_opts *opts = &c->mount_opts;
104 103
105 if (opts->override_compr) 104 if (opts->override_compr)
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index 6f98a1866776..f19d1e04a374 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -68,7 +68,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
68 unsigned int oldflags; 68 unsigned int oldflags;
69 int err; 69 int err;
70 70
71 err = mnt_want_write(filp->f_path.mnt); 71 err = mnt_want_write_file(filp);
72 if (err) 72 if (err)
73 return err; 73 return err;
74 74
@@ -120,7 +120,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
120 inode->i_ctime = CURRENT_TIME_SEC; 120 inode->i_ctime = CURRENT_TIME_SEC;
121 mark_inode_dirty(inode); 121 mark_inode_dirty(inode);
122setflags_out: 122setflags_out:
123 mnt_drop_write(filp->f_path.mnt); 123 mnt_drop_write_file(filp);
124 return err; 124 return err;
125 } 125 }
126 default: 126 default:
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index a112ad96e474..5f7c160ea64f 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -72,7 +72,7 @@ static inline void free_ea_wmap(struct inode *inode)
72 * RETURN: Errors from subroutines 72 * RETURN: Errors from subroutines
73 * 73 *
74 */ 74 */
75static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, 75static int jfs_create(struct inode *dip, struct dentry *dentry, umode_t mode,
76 struct nameidata *nd) 76 struct nameidata *nd)
77{ 77{
78 int rc = 0; 78 int rc = 0;
@@ -205,7 +205,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
205 * note: 205 * note:
206 * EACCESS: user needs search+write permission on the parent directory 206 * EACCESS: user needs search+write permission on the parent directory
207 */ 207 */
208static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) 208static int jfs_mkdir(struct inode *dip, struct dentry *dentry, umode_t mode)
209{ 209{
210 int rc = 0; 210 int rc = 0;
211 tid_t tid; /* transaction id */ 211 tid_t tid; /* transaction id */
@@ -1353,7 +1353,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1353 * FUNCTION: Create a special file (device) 1353 * FUNCTION: Create a special file (device)
1354 */ 1354 */
1355static int jfs_mknod(struct inode *dir, struct dentry *dentry, 1355static int jfs_mknod(struct inode *dir, struct dentry *dentry,
1356 int mode, dev_t rdev) 1356 umode_t mode, dev_t rdev)
1357{ 1357{
1358 struct jfs_inode_info *jfs_ip; 1358 struct jfs_inode_info *jfs_ip;
1359 struct btstack btstack; 1359 struct btstack btstack;
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index a44eff076c17..682bca642f38 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -119,7 +119,6 @@ static void jfs_i_callback(struct rcu_head *head)
119{ 119{
120 struct inode *inode = container_of(head, struct inode, i_rcu); 120 struct inode *inode = container_of(head, struct inode, i_rcu);
121 struct jfs_inode_info *ji = JFS_IP(inode); 121 struct jfs_inode_info *ji = JFS_IP(inode);
122 INIT_LIST_HEAD(&inode->i_dentry);
123 kmem_cache_free(jfs_inode_cachep, ji); 122 kmem_cache_free(jfs_inode_cachep, ji);
124} 123}
125 124
@@ -609,9 +608,9 @@ static int jfs_sync_fs(struct super_block *sb, int wait)
609 return 0; 608 return 0;
610} 609}
611 610
612static int jfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 611static int jfs_show_options(struct seq_file *seq, struct dentry *root)
613{ 612{
614 struct jfs_sb_info *sbi = JFS_SBI(vfs->mnt_sb); 613 struct jfs_sb_info *sbi = JFS_SBI(root->d_sb);
615 614
616 if (sbi->uid != -1) 615 if (sbi->uid != -1)
617 seq_printf(seq, ",uid=%d", sbi->uid); 616 seq_printf(seq, ",uid=%d", sbi->uid);
diff --git a/fs/libfs.c b/fs/libfs.c
index f6d411eef1e7..5b2dbb3ba4fc 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -12,7 +12,7 @@
12#include <linux/mutex.h> 12#include <linux/mutex.h>
13#include <linux/exportfs.h> 13#include <linux/exportfs.h>
14#include <linux/writeback.h> 14#include <linux/writeback.h>
15#include <linux/buffer_head.h> 15#include <linux/buffer_head.h> /* sync_mapping_buffers */
16 16
17#include <asm/uaccess.h> 17#include <asm/uaccess.h>
18 18
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 1ca0679c80bf..2240d384d787 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -403,7 +403,7 @@ nlmsvc_match_sb(void *datap, struct nlm_file *file)
403{ 403{
404 struct super_block *sb = datap; 404 struct super_block *sb = datap;
405 405
406 return sb == file->f_file->f_path.mnt->mnt_sb; 406 return sb == file->f_file->f_path.dentry->d_sb;
407} 407}
408 408
409/** 409/**
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index b7d7f67cee5a..501043e8966c 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -482,7 +482,7 @@ out:
482 return ret; 482 return ret;
483} 483}
484 484
485static int logfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 485static int logfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
486{ 486{
487 struct inode *inode; 487 struct inode *inode;
488 488
@@ -501,7 +501,7 @@ static int logfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
501 return __logfs_create(dir, dentry, inode, NULL, 0); 501 return __logfs_create(dir, dentry, inode, NULL, 0);
502} 502}
503 503
504static int logfs_create(struct inode *dir, struct dentry *dentry, int mode, 504static int logfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
505 struct nameidata *nd) 505 struct nameidata *nd)
506{ 506{
507 struct inode *inode; 507 struct inode *inode;
@@ -517,7 +517,7 @@ static int logfs_create(struct inode *dir, struct dentry *dentry, int mode,
517 return __logfs_create(dir, dentry, inode, NULL, 0); 517 return __logfs_create(dir, dentry, inode, NULL, 0);
518} 518}
519 519
520static int logfs_mknod(struct inode *dir, struct dentry *dentry, int mode, 520static int logfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
521 dev_t rdev) 521 dev_t rdev)
522{ 522{
523 struct inode *inode; 523 struct inode *inode;
diff --git a/fs/logfs/inode.c b/fs/logfs/inode.c
index 7e441ad5f792..388df1aa35e5 100644
--- a/fs/logfs/inode.c
+++ b/fs/logfs/inode.c
@@ -144,7 +144,6 @@ struct inode *logfs_safe_iget(struct super_block *sb, ino_t ino, int *is_cached)
144static void logfs_i_callback(struct rcu_head *head) 144static void logfs_i_callback(struct rcu_head *head)
145{ 145{
146 struct inode *inode = container_of(head, struct inode, i_rcu); 146 struct inode *inode = container_of(head, struct inode, i_rcu);
147 INIT_LIST_HEAD(&inode->i_dentry);
148 kmem_cache_free(logfs_inode_cache, logfs_inode(inode)); 147 kmem_cache_free(logfs_inode_cache, logfs_inode(inode));
149} 148}
150 149
@@ -324,7 +323,7 @@ static void logfs_set_ino_generation(struct super_block *sb,
324 mutex_unlock(&super->s_journal_mutex); 323 mutex_unlock(&super->s_journal_mutex);
325} 324}
326 325
327struct inode *logfs_new_inode(struct inode *dir, int mode) 326struct inode *logfs_new_inode(struct inode *dir, umode_t mode)
328{ 327{
329 struct super_block *sb = dir->i_sb; 328 struct super_block *sb = dir->i_sb;
330 struct inode *inode; 329 struct inode *inode;
diff --git a/fs/logfs/logfs.h b/fs/logfs/logfs.h
index 398ecff6e548..926373866a55 100644
--- a/fs/logfs/logfs.h
+++ b/fs/logfs/logfs.h
@@ -520,7 +520,7 @@ extern const struct super_operations logfs_super_operations;
520struct inode *logfs_iget(struct super_block *sb, ino_t ino); 520struct inode *logfs_iget(struct super_block *sb, ino_t ino);
521struct inode *logfs_safe_iget(struct super_block *sb, ino_t ino, int *cookie); 521struct inode *logfs_safe_iget(struct super_block *sb, ino_t ino, int *cookie);
522void logfs_safe_iput(struct inode *inode, int cookie); 522void logfs_safe_iput(struct inode *inode, int cookie);
523struct inode *logfs_new_inode(struct inode *dir, int mode); 523struct inode *logfs_new_inode(struct inode *dir, umode_t mode);
524struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino); 524struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino);
525struct inode *logfs_read_meta_inode(struct super_block *sb, u64 ino); 525struct inode *logfs_read_meta_inode(struct super_block *sb, u64 ino);
526int logfs_init_inode_cache(void); 526int logfs_init_inode_cache(void);
diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index ef175cb8cfd8..4bc50dac8e97 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -209,7 +209,7 @@ void minix_free_inode(struct inode * inode)
209 mark_buffer_dirty(bh); 209 mark_buffer_dirty(bh);
210} 210}
211 211
212struct inode *minix_new_inode(const struct inode *dir, int mode, int *error) 212struct inode *minix_new_inode(const struct inode *dir, umode_t mode, int *error)
213{ 213{
214 struct super_block *sb = dir->i_sb; 214 struct super_block *sb = dir->i_sb;
215 struct minix_sb_info *sbi = minix_sb(sb); 215 struct minix_sb_info *sbi = minix_sb(sb);
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 4d46a6a59070..fa8b612b8ce2 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -71,7 +71,6 @@ static struct inode *minix_alloc_inode(struct super_block *sb)
71static void minix_i_callback(struct rcu_head *head) 71static void minix_i_callback(struct rcu_head *head)
72{ 72{
73 struct inode *inode = container_of(head, struct inode, i_rcu); 73 struct inode *inode = container_of(head, struct inode, i_rcu);
74 INIT_LIST_HEAD(&inode->i_dentry);
75 kmem_cache_free(minix_inode_cachep, minix_i(inode)); 74 kmem_cache_free(minix_inode_cachep, minix_i(inode));
76} 75}
77 76
diff --git a/fs/minix/minix.h b/fs/minix/minix.h
index 26bbd55e82ea..c889ef0aa571 100644
--- a/fs/minix/minix.h
+++ b/fs/minix/minix.h
@@ -46,7 +46,7 @@ struct minix_sb_info {
46extern struct inode *minix_iget(struct super_block *, unsigned long); 46extern struct inode *minix_iget(struct super_block *, unsigned long);
47extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); 47extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **);
48extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); 48extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **);
49extern struct inode * minix_new_inode(const struct inode *, int, int *); 49extern struct inode * minix_new_inode(const struct inode *, umode_t, int *);
50extern void minix_free_inode(struct inode * inode); 50extern void minix_free_inode(struct inode * inode);
51extern unsigned long minix_count_free_inodes(struct super_block *sb); 51extern unsigned long minix_count_free_inodes(struct super_block *sb);
52extern int minix_new_block(struct inode * inode); 52extern int minix_new_block(struct inode * inode);
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 6e6777f1b4b2..2f76e38c2065 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -36,7 +36,7 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, st
36 return NULL; 36 return NULL;
37} 37}
38 38
39static int minix_mknod(struct inode * dir, struct dentry *dentry, int mode, dev_t rdev) 39static int minix_mknod(struct inode * dir, struct dentry *dentry, umode_t mode, dev_t rdev)
40{ 40{
41 int error; 41 int error;
42 struct inode *inode; 42 struct inode *inode;
@@ -54,7 +54,7 @@ static int minix_mknod(struct inode * dir, struct dentry *dentry, int mode, dev_
54 return error; 54 return error;
55} 55}
56 56
57static int minix_create(struct inode * dir, struct dentry *dentry, int mode, 57static int minix_create(struct inode *dir, struct dentry *dentry, umode_t mode,
58 struct nameidata *nd) 58 struct nameidata *nd)
59{ 59{
60 return minix_mknod(dir, dentry, mode, 0); 60 return minix_mknod(dir, dentry, mode, 0);
@@ -103,7 +103,7 @@ static int minix_link(struct dentry * old_dentry, struct inode * dir,
103 return add_nondir(dentry, inode); 103 return add_nondir(dentry, inode);
104} 104}
105 105
106static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode) 106static int minix_mkdir(struct inode * dir, struct dentry *dentry, umode_t mode)
107{ 107{
108 struct inode * inode; 108 struct inode * inode;
109 int err = -EMLINK; 109 int err = -EMLINK;
diff --git a/fs/mount.h b/fs/mount.h
new file mode 100644
index 000000000000..4ef36d93e5a2
--- /dev/null
+++ b/fs/mount.h
@@ -0,0 +1,76 @@
1#include <linux/mount.h>
2#include <linux/seq_file.h>
3#include <linux/poll.h>
4
5struct mnt_namespace {
6 atomic_t count;
7 struct mount * root;
8 struct list_head list;
9 wait_queue_head_t poll;
10 int event;
11};
12
13struct mnt_pcp {
14 int mnt_count;
15 int mnt_writers;
16};
17
18struct mount {
19 struct list_head mnt_hash;
20 struct mount *mnt_parent;
21 struct dentry *mnt_mountpoint;
22 struct vfsmount mnt;
23#ifdef CONFIG_SMP
24 struct mnt_pcp __percpu *mnt_pcp;
25 atomic_t mnt_longterm; /* how many of the refs are longterm */
26#else
27 int mnt_count;
28 int mnt_writers;
29#endif
30 struct list_head mnt_mounts; /* list of children, anchored here */
31 struct list_head mnt_child; /* and going through their mnt_child */
32 struct list_head mnt_instance; /* mount instance on sb->s_mounts */
33 const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
34 struct list_head mnt_list;
35 struct list_head mnt_expire; /* link in fs-specific expiry list */
36 struct list_head mnt_share; /* circular list of shared mounts */
37 struct list_head mnt_slave_list;/* list of slave mounts */
38 struct list_head mnt_slave; /* slave list entry */
39 struct mount *mnt_master; /* slave is on master->mnt_slave_list */
40 struct mnt_namespace *mnt_ns; /* containing namespace */
41#ifdef CONFIG_FSNOTIFY
42 struct hlist_head mnt_fsnotify_marks;
43 __u32 mnt_fsnotify_mask;
44#endif
45 int mnt_id; /* mount identifier */
46 int mnt_group_id; /* peer group identifier */
47 int mnt_expiry_mark; /* true if marked for expiry */
48 int mnt_pinned;
49 int mnt_ghosts;
50};
51
52static inline struct mount *real_mount(struct vfsmount *mnt)
53{
54 return container_of(mnt, struct mount, mnt);
55}
56
57static inline int mnt_has_parent(struct mount *mnt)
58{
59 return mnt != mnt->mnt_parent;
60}
61
62extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
63
64static inline void get_mnt_ns(struct mnt_namespace *ns)
65{
66 atomic_inc(&ns->count);
67}
68
69struct proc_mounts {
70 struct seq_file m; /* must be the first element */
71 struct mnt_namespace *ns;
72 struct path root;
73 int (*show)(struct seq_file *, struct vfsmount *);
74};
75
76extern const struct seq_operations mounts_op;
diff --git a/fs/namei.c b/fs/namei.c
index 5008f01787f5..c283a1ec008e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -36,6 +36,7 @@
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37 37
38#include "internal.h" 38#include "internal.h"
39#include "mount.h"
39 40
40/* [Feb-1997 T. Schoebel-Theuer] 41/* [Feb-1997 T. Schoebel-Theuer]
41 * Fundamental changes in the pathname lookup mechanisms (namei) 42 * Fundamental changes in the pathname lookup mechanisms (namei)
@@ -676,36 +677,38 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
676 677
677static int follow_up_rcu(struct path *path) 678static int follow_up_rcu(struct path *path)
678{ 679{
679 struct vfsmount *parent; 680 struct mount *mnt = real_mount(path->mnt);
681 struct mount *parent;
680 struct dentry *mountpoint; 682 struct dentry *mountpoint;
681 683
682 parent = path->mnt->mnt_parent; 684 parent = mnt->mnt_parent;
683 if (parent == path->mnt) 685 if (&parent->mnt == path->mnt)
684 return 0; 686 return 0;
685 mountpoint = path->mnt->mnt_mountpoint; 687 mountpoint = mnt->mnt_mountpoint;
686 path->dentry = mountpoint; 688 path->dentry = mountpoint;
687 path->mnt = parent; 689 path->mnt = &parent->mnt;
688 return 1; 690 return 1;
689} 691}
690 692
691int follow_up(struct path *path) 693int follow_up(struct path *path)
692{ 694{
693 struct vfsmount *parent; 695 struct mount *mnt = real_mount(path->mnt);
696 struct mount *parent;
694 struct dentry *mountpoint; 697 struct dentry *mountpoint;
695 698
696 br_read_lock(vfsmount_lock); 699 br_read_lock(vfsmount_lock);
697 parent = path->mnt->mnt_parent; 700 parent = mnt->mnt_parent;
698 if (parent == path->mnt) { 701 if (&parent->mnt == path->mnt) {
699 br_read_unlock(vfsmount_lock); 702 br_read_unlock(vfsmount_lock);
700 return 0; 703 return 0;
701 } 704 }
702 mntget(parent); 705 mntget(&parent->mnt);
703 mountpoint = dget(path->mnt->mnt_mountpoint); 706 mountpoint = dget(mnt->mnt_mountpoint);
704 br_read_unlock(vfsmount_lock); 707 br_read_unlock(vfsmount_lock);
705 dput(path->dentry); 708 dput(path->dentry);
706 path->dentry = mountpoint; 709 path->dentry = mountpoint;
707 mntput(path->mnt); 710 mntput(path->mnt);
708 path->mnt = parent; 711 path->mnt = &parent->mnt;
709 return 1; 712 return 1;
710} 713}
711 714
@@ -884,7 +887,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
884 struct inode **inode) 887 struct inode **inode)
885{ 888{
886 for (;;) { 889 for (;;) {
887 struct vfsmount *mounted; 890 struct mount *mounted;
888 /* 891 /*
889 * Don't forget we might have a non-mountpoint managed dentry 892 * Don't forget we might have a non-mountpoint managed dentry
890 * that wants to block transit. 893 * that wants to block transit.
@@ -898,8 +901,8 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
898 mounted = __lookup_mnt(path->mnt, path->dentry, 1); 901 mounted = __lookup_mnt(path->mnt, path->dentry, 1);
899 if (!mounted) 902 if (!mounted)
900 break; 903 break;
901 path->mnt = mounted; 904 path->mnt = &mounted->mnt;
902 path->dentry = mounted->mnt_root; 905 path->dentry = mounted->mnt.mnt_root;
903 nd->flags |= LOOKUP_JUMPED; 906 nd->flags |= LOOKUP_JUMPED;
904 nd->seq = read_seqcount_begin(&path->dentry->d_seq); 907 nd->seq = read_seqcount_begin(&path->dentry->d_seq);
905 /* 908 /*
@@ -915,12 +918,12 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path,
915static void follow_mount_rcu(struct nameidata *nd) 918static void follow_mount_rcu(struct nameidata *nd)
916{ 919{
917 while (d_mountpoint(nd->path.dentry)) { 920 while (d_mountpoint(nd->path.dentry)) {
918 struct vfsmount *mounted; 921 struct mount *mounted;
919 mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry, 1); 922 mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry, 1);
920 if (!mounted) 923 if (!mounted)
921 break; 924 break;
922 nd->path.mnt = mounted; 925 nd->path.mnt = &mounted->mnt;
923 nd->path.dentry = mounted->mnt_root; 926 nd->path.dentry = mounted->mnt.mnt_root;
924 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); 927 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
925 } 928 }
926} 929}
@@ -1976,7 +1979,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)
1976 } 1979 }
1977} 1980}
1978 1981
1979int vfs_create(struct inode *dir, struct dentry *dentry, int mode, 1982int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
1980 struct nameidata *nd) 1983 struct nameidata *nd)
1981{ 1984{
1982 int error = may_create(dir, dentry); 1985 int error = may_create(dir, dentry);
@@ -2177,7 +2180,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
2177 2180
2178 /* Negative dentry, just create the file */ 2181 /* Negative dentry, just create the file */
2179 if (!dentry->d_inode) { 2182 if (!dentry->d_inode) {
2180 int mode = op->mode; 2183 umode_t mode = op->mode;
2181 if (!IS_POSIXACL(dir->d_inode)) 2184 if (!IS_POSIXACL(dir->d_inode))
2182 mode &= ~current_umask(); 2185 mode &= ~current_umask();
2183 /* 2186 /*
@@ -2444,7 +2447,7 @@ struct dentry *user_path_create(int dfd, const char __user *pathname, struct pat
2444} 2447}
2445EXPORT_SYMBOL(user_path_create); 2448EXPORT_SYMBOL(user_path_create);
2446 2449
2447int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) 2450int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
2448{ 2451{
2449 int error = may_create(dir, dentry); 2452 int error = may_create(dir, dentry);
2450 2453
@@ -2472,7 +2475,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
2472 return error; 2475 return error;
2473} 2476}
2474 2477
2475static int may_mknod(mode_t mode) 2478static int may_mknod(umode_t mode)
2476{ 2479{
2477 switch (mode & S_IFMT) { 2480 switch (mode & S_IFMT) {
2478 case S_IFREG: 2481 case S_IFREG:
@@ -2489,7 +2492,7 @@ static int may_mknod(mode_t mode)
2489 } 2492 }
2490} 2493}
2491 2494
2492SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, int, mode, 2495SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
2493 unsigned, dev) 2496 unsigned, dev)
2494{ 2497{
2495 struct dentry *dentry; 2498 struct dentry *dentry;
@@ -2536,12 +2539,12 @@ out_dput:
2536 return error; 2539 return error;
2537} 2540}
2538 2541
2539SYSCALL_DEFINE3(mknod, const char __user *, filename, int, mode, unsigned, dev) 2542SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, dev)
2540{ 2543{
2541 return sys_mknodat(AT_FDCWD, filename, mode, dev); 2544 return sys_mknodat(AT_FDCWD, filename, mode, dev);
2542} 2545}
2543 2546
2544int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 2547int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
2545{ 2548{
2546 int error = may_create(dir, dentry); 2549 int error = may_create(dir, dentry);
2547 2550
@@ -2562,7 +2565,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
2562 return error; 2565 return error;
2563} 2566}
2564 2567
2565SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, int, mode) 2568SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
2566{ 2569{
2567 struct dentry *dentry; 2570 struct dentry *dentry;
2568 struct path path; 2571 struct path path;
@@ -2590,7 +2593,7 @@ out_dput:
2590 return error; 2593 return error;
2591} 2594}
2592 2595
2593SYSCALL_DEFINE2(mkdir, const char __user *, pathname, int, mode) 2596SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
2594{ 2597{
2595 return sys_mkdirat(AT_FDCWD, pathname, mode); 2598 return sys_mkdirat(AT_FDCWD, pathname, mode);
2596} 2599}
diff --git a/fs/namespace.c b/fs/namespace.c
index cfc6d4448aa5..7e6f2c9dc7c4 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -9,30 +9,17 @@
9 */ 9 */
10 10
11#include <linux/syscalls.h> 11#include <linux/syscalls.h>
12#include <linux/slab.h> 12#include <linux/export.h>
13#include <linux/sched.h>
14#include <linux/spinlock.h>
15#include <linux/percpu.h>
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/acct.h>
19#include <linux/capability.h> 13#include <linux/capability.h>
20#include <linux/cpumask.h>
21#include <linux/module.h>
22#include <linux/sysfs.h>
23#include <linux/seq_file.h>
24#include <linux/mnt_namespace.h> 14#include <linux/mnt_namespace.h>
25#include <linux/namei.h> 15#include <linux/namei.h>
26#include <linux/nsproxy.h>
27#include <linux/security.h> 16#include <linux/security.h>
28#include <linux/mount.h>
29#include <linux/ramfs.h>
30#include <linux/log2.h>
31#include <linux/idr.h> 17#include <linux/idr.h>
32#include <linux/fs_struct.h> 18#include <linux/acct.h> /* acct_auto_close_mnt */
33#include <linux/fsnotify.h> 19#include <linux/ramfs.h> /* init_rootfs */
34#include <asm/uaccess.h> 20#include <linux/fs_struct.h> /* get_fs_root et.al. */
35#include <asm/unistd.h> 21#include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
22#include <linux/uaccess.h>
36#include "pnode.h" 23#include "pnode.h"
37#include "internal.h" 24#include "internal.h"
38 25
@@ -78,7 +65,7 @@ static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
78 * allocation is serialized by namespace_sem, but we need the spinlock to 65 * allocation is serialized by namespace_sem, but we need the spinlock to
79 * serialize with freeing. 66 * serialize with freeing.
80 */ 67 */
81static int mnt_alloc_id(struct vfsmount *mnt) 68static int mnt_alloc_id(struct mount *mnt)
82{ 69{
83 int res; 70 int res;
84 71
@@ -95,7 +82,7 @@ retry:
95 return res; 82 return res;
96} 83}
97 84
98static void mnt_free_id(struct vfsmount *mnt) 85static void mnt_free_id(struct mount *mnt)
99{ 86{
100 int id = mnt->mnt_id; 87 int id = mnt->mnt_id;
101 spin_lock(&mnt_id_lock); 88 spin_lock(&mnt_id_lock);
@@ -110,7 +97,7 @@ static void mnt_free_id(struct vfsmount *mnt)
110 * 97 *
111 * mnt_group_ida is protected by namespace_sem 98 * mnt_group_ida is protected by namespace_sem
112 */ 99 */
113static int mnt_alloc_group_id(struct vfsmount *mnt) 100static int mnt_alloc_group_id(struct mount *mnt)
114{ 101{
115 int res; 102 int res;
116 103
@@ -129,7 +116,7 @@ static int mnt_alloc_group_id(struct vfsmount *mnt)
129/* 116/*
130 * Release a peer group ID 117 * Release a peer group ID
131 */ 118 */
132void mnt_release_group_id(struct vfsmount *mnt) 119void mnt_release_group_id(struct mount *mnt)
133{ 120{
134 int id = mnt->mnt_group_id; 121 int id = mnt->mnt_group_id;
135 ida_remove(&mnt_group_ida, id); 122 ida_remove(&mnt_group_ida, id);
@@ -141,7 +128,7 @@ void mnt_release_group_id(struct vfsmount *mnt)
141/* 128/*
142 * vfsmount lock must be held for read 129 * vfsmount lock must be held for read
143 */ 130 */
144static inline void mnt_add_count(struct vfsmount *mnt, int n) 131static inline void mnt_add_count(struct mount *mnt, int n)
145{ 132{
146#ifdef CONFIG_SMP 133#ifdef CONFIG_SMP
147 this_cpu_add(mnt->mnt_pcp->mnt_count, n); 134 this_cpu_add(mnt->mnt_pcp->mnt_count, n);
@@ -152,35 +139,10 @@ static inline void mnt_add_count(struct vfsmount *mnt, int n)
152#endif 139#endif
153} 140}
154 141
155static inline void mnt_set_count(struct vfsmount *mnt, int n)
156{
157#ifdef CONFIG_SMP
158 this_cpu_write(mnt->mnt_pcp->mnt_count, n);
159#else
160 mnt->mnt_count = n;
161#endif
162}
163
164/*
165 * vfsmount lock must be held for read
166 */
167static inline void mnt_inc_count(struct vfsmount *mnt)
168{
169 mnt_add_count(mnt, 1);
170}
171
172/*
173 * vfsmount lock must be held for read
174 */
175static inline void mnt_dec_count(struct vfsmount *mnt)
176{
177 mnt_add_count(mnt, -1);
178}
179
180/* 142/*
181 * vfsmount lock must be held for write 143 * vfsmount lock must be held for write
182 */ 144 */
183unsigned int mnt_get_count(struct vfsmount *mnt) 145unsigned int mnt_get_count(struct mount *mnt)
184{ 146{
185#ifdef CONFIG_SMP 147#ifdef CONFIG_SMP
186 unsigned int count = 0; 148 unsigned int count = 0;
@@ -196,9 +158,9 @@ unsigned int mnt_get_count(struct vfsmount *mnt)
196#endif 158#endif
197} 159}
198 160
199static struct vfsmount *alloc_vfsmnt(const char *name) 161static struct mount *alloc_vfsmnt(const char *name)
200{ 162{
201 struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); 163 struct mount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
202 if (mnt) { 164 if (mnt) {
203 int err; 165 int err;
204 166
@@ -277,7 +239,7 @@ int __mnt_is_readonly(struct vfsmount *mnt)
277} 239}
278EXPORT_SYMBOL_GPL(__mnt_is_readonly); 240EXPORT_SYMBOL_GPL(__mnt_is_readonly);
279 241
280static inline void mnt_inc_writers(struct vfsmount *mnt) 242static inline void mnt_inc_writers(struct mount *mnt)
281{ 243{
282#ifdef CONFIG_SMP 244#ifdef CONFIG_SMP
283 this_cpu_inc(mnt->mnt_pcp->mnt_writers); 245 this_cpu_inc(mnt->mnt_pcp->mnt_writers);
@@ -286,7 +248,7 @@ static inline void mnt_inc_writers(struct vfsmount *mnt)
286#endif 248#endif
287} 249}
288 250
289static inline void mnt_dec_writers(struct vfsmount *mnt) 251static inline void mnt_dec_writers(struct mount *mnt)
290{ 252{
291#ifdef CONFIG_SMP 253#ifdef CONFIG_SMP
292 this_cpu_dec(mnt->mnt_pcp->mnt_writers); 254 this_cpu_dec(mnt->mnt_pcp->mnt_writers);
@@ -295,7 +257,7 @@ static inline void mnt_dec_writers(struct vfsmount *mnt)
295#endif 257#endif
296} 258}
297 259
298static unsigned int mnt_get_writers(struct vfsmount *mnt) 260static unsigned int mnt_get_writers(struct mount *mnt)
299{ 261{
300#ifdef CONFIG_SMP 262#ifdef CONFIG_SMP
301 unsigned int count = 0; 263 unsigned int count = 0;
@@ -311,6 +273,15 @@ static unsigned int mnt_get_writers(struct vfsmount *mnt)
311#endif 273#endif
312} 274}
313 275
276static int mnt_is_readonly(struct vfsmount *mnt)
277{
278 if (mnt->mnt_sb->s_readonly_remount)
279 return 1;
280 /* Order wrt setting s_flags/s_readonly_remount in do_remount() */
281 smp_rmb();
282 return __mnt_is_readonly(mnt);
283}
284
314/* 285/*
315 * Most r/o checks on a fs are for operations that take 286 * Most r/o checks on a fs are for operations that take
316 * discrete amounts of time, like a write() or unlink(). 287 * discrete amounts of time, like a write() or unlink().
@@ -321,7 +292,7 @@ static unsigned int mnt_get_writers(struct vfsmount *mnt)
321 */ 292 */
322/** 293/**
323 * mnt_want_write - get write access to a mount 294 * mnt_want_write - get write access to a mount
324 * @mnt: the mount on which to take a write 295 * @m: the mount on which to take a write
325 * 296 *
326 * This tells the low-level filesystem that a write is 297 * This tells the low-level filesystem that a write is
327 * about to be performed to it, and makes sure that 298 * about to be performed to it, and makes sure that
@@ -329,8 +300,9 @@ static unsigned int mnt_get_writers(struct vfsmount *mnt)
329 * the write operation is finished, mnt_drop_write() 300 * the write operation is finished, mnt_drop_write()
330 * must be called. This is effectively a refcount. 301 * must be called. This is effectively a refcount.
331 */ 302 */
332int mnt_want_write(struct vfsmount *mnt) 303int mnt_want_write(struct vfsmount *m)
333{ 304{
305 struct mount *mnt = real_mount(m);
334 int ret = 0; 306 int ret = 0;
335 307
336 preempt_disable(); 308 preempt_disable();
@@ -341,7 +313,7 @@ int mnt_want_write(struct vfsmount *mnt)
341 * incremented count after it has set MNT_WRITE_HOLD. 313 * incremented count after it has set MNT_WRITE_HOLD.
342 */ 314 */
343 smp_mb(); 315 smp_mb();
344 while (mnt->mnt_flags & MNT_WRITE_HOLD) 316 while (mnt->mnt.mnt_flags & MNT_WRITE_HOLD)
345 cpu_relax(); 317 cpu_relax();
346 /* 318 /*
347 * After the slowpath clears MNT_WRITE_HOLD, mnt_is_readonly will 319 * After the slowpath clears MNT_WRITE_HOLD, mnt_is_readonly will
@@ -349,7 +321,7 @@ int mnt_want_write(struct vfsmount *mnt)
349 * MNT_WRITE_HOLD is cleared. 321 * MNT_WRITE_HOLD is cleared.
350 */ 322 */
351 smp_rmb(); 323 smp_rmb();
352 if (__mnt_is_readonly(mnt)) { 324 if (mnt_is_readonly(m)) {
353 mnt_dec_writers(mnt); 325 mnt_dec_writers(mnt);
354 ret = -EROFS; 326 ret = -EROFS;
355 goto out; 327 goto out;
@@ -378,7 +350,7 @@ int mnt_clone_write(struct vfsmount *mnt)
378 if (__mnt_is_readonly(mnt)) 350 if (__mnt_is_readonly(mnt))
379 return -EROFS; 351 return -EROFS;
380 preempt_disable(); 352 preempt_disable();
381 mnt_inc_writers(mnt); 353 mnt_inc_writers(real_mount(mnt));
382 preempt_enable(); 354 preempt_enable();
383 return 0; 355 return 0;
384} 356}
@@ -412,17 +384,23 @@ EXPORT_SYMBOL_GPL(mnt_want_write_file);
412void mnt_drop_write(struct vfsmount *mnt) 384void mnt_drop_write(struct vfsmount *mnt)
413{ 385{
414 preempt_disable(); 386 preempt_disable();
415 mnt_dec_writers(mnt); 387 mnt_dec_writers(real_mount(mnt));
416 preempt_enable(); 388 preempt_enable();
417} 389}
418EXPORT_SYMBOL_GPL(mnt_drop_write); 390EXPORT_SYMBOL_GPL(mnt_drop_write);
419 391
420static int mnt_make_readonly(struct vfsmount *mnt) 392void mnt_drop_write_file(struct file *file)
393{
394 mnt_drop_write(file->f_path.mnt);
395}
396EXPORT_SYMBOL(mnt_drop_write_file);
397
398static int mnt_make_readonly(struct mount *mnt)
421{ 399{
422 int ret = 0; 400 int ret = 0;
423 401
424 br_write_lock(vfsmount_lock); 402 br_write_lock(vfsmount_lock);
425 mnt->mnt_flags |= MNT_WRITE_HOLD; 403 mnt->mnt.mnt_flags |= MNT_WRITE_HOLD;
426 /* 404 /*
427 * After storing MNT_WRITE_HOLD, we'll read the counters. This store 405 * After storing MNT_WRITE_HOLD, we'll read the counters. This store
428 * should be visible before we do. 406 * should be visible before we do.
@@ -448,25 +426,61 @@ static int mnt_make_readonly(struct vfsmount *mnt)
448 if (mnt_get_writers(mnt) > 0) 426 if (mnt_get_writers(mnt) > 0)
449 ret = -EBUSY; 427 ret = -EBUSY;
450 else 428 else
451 mnt->mnt_flags |= MNT_READONLY; 429 mnt->mnt.mnt_flags |= MNT_READONLY;
452 /* 430 /*
453 * MNT_READONLY must become visible before ~MNT_WRITE_HOLD, so writers 431 * MNT_READONLY must become visible before ~MNT_WRITE_HOLD, so writers
454 * that become unheld will see MNT_READONLY. 432 * that become unheld will see MNT_READONLY.
455 */ 433 */
456 smp_wmb(); 434 smp_wmb();
457 mnt->mnt_flags &= ~MNT_WRITE_HOLD; 435 mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;
458 br_write_unlock(vfsmount_lock); 436 br_write_unlock(vfsmount_lock);
459 return ret; 437 return ret;
460} 438}
461 439
462static void __mnt_unmake_readonly(struct vfsmount *mnt) 440static void __mnt_unmake_readonly(struct mount *mnt)
463{ 441{
464 br_write_lock(vfsmount_lock); 442 br_write_lock(vfsmount_lock);
465 mnt->mnt_flags &= ~MNT_READONLY; 443 mnt->mnt.mnt_flags &= ~MNT_READONLY;
466 br_write_unlock(vfsmount_lock); 444 br_write_unlock(vfsmount_lock);
467} 445}
468 446
469static void free_vfsmnt(struct vfsmount *mnt) 447int sb_prepare_remount_readonly(struct super_block *sb)
448{
449 struct mount *mnt;
450 int err = 0;
451
452 /* Racy optimization. Recheck the counter under MNT_WRITE_HOLD */
453 if (atomic_long_read(&sb->s_remove_count))
454 return -EBUSY;
455
456 br_write_lock(vfsmount_lock);
457 list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
458 if (!(mnt->mnt.mnt_flags & MNT_READONLY)) {
459 mnt->mnt.mnt_flags |= MNT_WRITE_HOLD;
460 smp_mb();
461 if (mnt_get_writers(mnt) > 0) {
462 err = -EBUSY;
463 break;
464 }
465 }
466 }
467 if (!err && atomic_long_read(&sb->s_remove_count))
468 err = -EBUSY;
469
470 if (!err) {
471 sb->s_readonly_remount = 1;
472 smp_wmb();
473 }
474 list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
475 if (mnt->mnt.mnt_flags & MNT_WRITE_HOLD)
476 mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;
477 }
478 br_write_unlock(vfsmount_lock);
479
480 return err;
481}
482
483static void free_vfsmnt(struct mount *mnt)
470{ 484{
471 kfree(mnt->mnt_devname); 485 kfree(mnt->mnt_devname);
472 mnt_free_id(mnt); 486 mnt_free_id(mnt);
@@ -481,20 +495,20 @@ static void free_vfsmnt(struct vfsmount *mnt)
481 * @dir. If @dir is set return the first mount else return the last mount. 495 * @dir. If @dir is set return the first mount else return the last mount.
482 * vfsmount_lock must be held for read or write. 496 * vfsmount_lock must be held for read or write.
483 */ 497 */
484struct vfsmount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, 498struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry,
485 int dir) 499 int dir)
486{ 500{
487 struct list_head *head = mount_hashtable + hash(mnt, dentry); 501 struct list_head *head = mount_hashtable + hash(mnt, dentry);
488 struct list_head *tmp = head; 502 struct list_head *tmp = head;
489 struct vfsmount *p, *found = NULL; 503 struct mount *p, *found = NULL;
490 504
491 for (;;) { 505 for (;;) {
492 tmp = dir ? tmp->next : tmp->prev; 506 tmp = dir ? tmp->next : tmp->prev;
493 p = NULL; 507 p = NULL;
494 if (tmp == head) 508 if (tmp == head)
495 break; 509 break;
496 p = list_entry(tmp, struct vfsmount, mnt_hash); 510 p = list_entry(tmp, struct mount, mnt_hash);
497 if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry) { 511 if (&p->mnt_parent->mnt == mnt && p->mnt_mountpoint == dentry) {
498 found = p; 512 found = p;
499 break; 513 break;
500 } 514 }
@@ -508,16 +522,21 @@ struct vfsmount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry,
508 */ 522 */
509struct vfsmount *lookup_mnt(struct path *path) 523struct vfsmount *lookup_mnt(struct path *path)
510{ 524{
511 struct vfsmount *child_mnt; 525 struct mount *child_mnt;
512 526
513 br_read_lock(vfsmount_lock); 527 br_read_lock(vfsmount_lock);
514 if ((child_mnt = __lookup_mnt(path->mnt, path->dentry, 1))) 528 child_mnt = __lookup_mnt(path->mnt, path->dentry, 1);
515 mntget(child_mnt); 529 if (child_mnt) {
516 br_read_unlock(vfsmount_lock); 530 mnt_add_count(child_mnt, 1);
517 return child_mnt; 531 br_read_unlock(vfsmount_lock);
532 return &child_mnt->mnt;
533 } else {
534 br_read_unlock(vfsmount_lock);
535 return NULL;
536 }
518} 537}
519 538
520static inline int check_mnt(struct vfsmount *mnt) 539static inline int check_mnt(struct mount *mnt)
521{ 540{
522 return mnt->mnt_ns == current->nsproxy->mnt_ns; 541 return mnt->mnt_ns == current->nsproxy->mnt_ns;
523} 542}
@@ -548,12 +567,12 @@ static void __touch_mnt_namespace(struct mnt_namespace *ns)
548 * Clear dentry's mounted state if it has no remaining mounts. 567 * Clear dentry's mounted state if it has no remaining mounts.
549 * vfsmount_lock must be held for write. 568 * vfsmount_lock must be held for write.
550 */ 569 */
551static void dentry_reset_mounted(struct vfsmount *mnt, struct dentry *dentry) 570static void dentry_reset_mounted(struct dentry *dentry)
552{ 571{
553 unsigned u; 572 unsigned u;
554 573
555 for (u = 0; u < HASH_SIZE; u++) { 574 for (u = 0; u < HASH_SIZE; u++) {
556 struct vfsmount *p; 575 struct mount *p;
557 576
558 list_for_each_entry(p, &mount_hashtable[u], mnt_hash) { 577 list_for_each_entry(p, &mount_hashtable[u], mnt_hash) {
559 if (p->mnt_mountpoint == dentry) 578 if (p->mnt_mountpoint == dentry)
@@ -568,25 +587,26 @@ static void dentry_reset_mounted(struct vfsmount *mnt, struct dentry *dentry)
568/* 587/*
569 * vfsmount lock must be held for write 588 * vfsmount lock must be held for write
570 */ 589 */
571static void detach_mnt(struct vfsmount *mnt, struct path *old_path) 590static void detach_mnt(struct mount *mnt, struct path *old_path)
572{ 591{
573 old_path->dentry = mnt->mnt_mountpoint; 592 old_path->dentry = mnt->mnt_mountpoint;
574 old_path->mnt = mnt->mnt_parent; 593 old_path->mnt = &mnt->mnt_parent->mnt;
575 mnt->mnt_parent = mnt; 594 mnt->mnt_parent = mnt;
576 mnt->mnt_mountpoint = mnt->mnt_root; 595 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
577 list_del_init(&mnt->mnt_child); 596 list_del_init(&mnt->mnt_child);
578 list_del_init(&mnt->mnt_hash); 597 list_del_init(&mnt->mnt_hash);
579 dentry_reset_mounted(old_path->mnt, old_path->dentry); 598 dentry_reset_mounted(old_path->dentry);
580} 599}
581 600
582/* 601/*
583 * vfsmount lock must be held for write 602 * vfsmount lock must be held for write
584 */ 603 */
585void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, 604void mnt_set_mountpoint(struct mount *mnt, struct dentry *dentry,
586 struct vfsmount *child_mnt) 605 struct mount *child_mnt)
587{ 606{
588 child_mnt->mnt_parent = mntget(mnt); 607 mnt_add_count(mnt, 1); /* essentially, that's mntget */
589 child_mnt->mnt_mountpoint = dget(dentry); 608 child_mnt->mnt_mountpoint = dget(dentry);
609 child_mnt->mnt_parent = mnt;
590 spin_lock(&dentry->d_lock); 610 spin_lock(&dentry->d_lock);
591 dentry->d_flags |= DCACHE_MOUNTED; 611 dentry->d_flags |= DCACHE_MOUNTED;
592 spin_unlock(&dentry->d_lock); 612 spin_unlock(&dentry->d_lock);
@@ -595,15 +615,15 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry,
595/* 615/*
596 * vfsmount lock must be held for write 616 * vfsmount lock must be held for write
597 */ 617 */
598static void attach_mnt(struct vfsmount *mnt, struct path *path) 618static void attach_mnt(struct mount *mnt, struct path *path)
599{ 619{
600 mnt_set_mountpoint(path->mnt, path->dentry, mnt); 620 mnt_set_mountpoint(real_mount(path->mnt), path->dentry, mnt);
601 list_add_tail(&mnt->mnt_hash, mount_hashtable + 621 list_add_tail(&mnt->mnt_hash, mount_hashtable +
602 hash(path->mnt, path->dentry)); 622 hash(path->mnt, path->dentry));
603 list_add_tail(&mnt->mnt_child, &path->mnt->mnt_mounts); 623 list_add_tail(&mnt->mnt_child, &real_mount(path->mnt)->mnt_mounts);
604} 624}
605 625
606static inline void __mnt_make_longterm(struct vfsmount *mnt) 626static inline void __mnt_make_longterm(struct mount *mnt)
607{ 627{
608#ifdef CONFIG_SMP 628#ifdef CONFIG_SMP
609 atomic_inc(&mnt->mnt_longterm); 629 atomic_inc(&mnt->mnt_longterm);
@@ -611,7 +631,7 @@ static inline void __mnt_make_longterm(struct vfsmount *mnt)
611} 631}
612 632
613/* needs vfsmount lock for write */ 633/* needs vfsmount lock for write */
614static inline void __mnt_make_shortterm(struct vfsmount *mnt) 634static inline void __mnt_make_shortterm(struct mount *mnt)
615{ 635{
616#ifdef CONFIG_SMP 636#ifdef CONFIG_SMP
617 atomic_dec(&mnt->mnt_longterm); 637 atomic_dec(&mnt->mnt_longterm);
@@ -621,10 +641,10 @@ static inline void __mnt_make_shortterm(struct vfsmount *mnt)
621/* 641/*
622 * vfsmount lock must be held for write 642 * vfsmount lock must be held for write
623 */ 643 */
624static void commit_tree(struct vfsmount *mnt) 644static void commit_tree(struct mount *mnt)
625{ 645{
626 struct vfsmount *parent = mnt->mnt_parent; 646 struct mount *parent = mnt->mnt_parent;
627 struct vfsmount *m; 647 struct mount *m;
628 LIST_HEAD(head); 648 LIST_HEAD(head);
629 struct mnt_namespace *n = parent->mnt_ns; 649 struct mnt_namespace *n = parent->mnt_ns;
630 650
@@ -639,12 +659,12 @@ static void commit_tree(struct vfsmount *mnt)
639 list_splice(&head, n->list.prev); 659 list_splice(&head, n->list.prev);
640 660
641 list_add_tail(&mnt->mnt_hash, mount_hashtable + 661 list_add_tail(&mnt->mnt_hash, mount_hashtable +
642 hash(parent, mnt->mnt_mountpoint)); 662 hash(&parent->mnt, mnt->mnt_mountpoint));
643 list_add_tail(&mnt->mnt_child, &parent->mnt_mounts); 663 list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
644 touch_mnt_namespace(n); 664 touch_mnt_namespace(n);
645} 665}
646 666
647static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root) 667static struct mount *next_mnt(struct mount *p, struct mount *root)
648{ 668{
649 struct list_head *next = p->mnt_mounts.next; 669 struct list_head *next = p->mnt_mounts.next;
650 if (next == &p->mnt_mounts) { 670 if (next == &p->mnt_mounts) {
@@ -657,14 +677,14 @@ static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root)
657 p = p->mnt_parent; 677 p = p->mnt_parent;
658 } 678 }
659 } 679 }
660 return list_entry(next, struct vfsmount, mnt_child); 680 return list_entry(next, struct mount, mnt_child);
661} 681}
662 682
663static struct vfsmount *skip_mnt_tree(struct vfsmount *p) 683static struct mount *skip_mnt_tree(struct mount *p)
664{ 684{
665 struct list_head *prev = p->mnt_mounts.prev; 685 struct list_head *prev = p->mnt_mounts.prev;
666 while (prev != &p->mnt_mounts) { 686 while (prev != &p->mnt_mounts) {
667 p = list_entry(prev, struct vfsmount, mnt_child); 687 p = list_entry(prev, struct mount, mnt_child);
668 prev = p->mnt_mounts.prev; 688 prev = p->mnt_mounts.prev;
669 } 689 }
670 return p; 690 return p;
@@ -673,7 +693,7 @@ static struct vfsmount *skip_mnt_tree(struct vfsmount *p)
673struct vfsmount * 693struct vfsmount *
674vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) 694vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
675{ 695{
676 struct vfsmount *mnt; 696 struct mount *mnt;
677 struct dentry *root; 697 struct dentry *root;
678 698
679 if (!type) 699 if (!type)
@@ -684,7 +704,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
684 return ERR_PTR(-ENOMEM); 704 return ERR_PTR(-ENOMEM);
685 705
686 if (flags & MS_KERNMOUNT) 706 if (flags & MS_KERNMOUNT)
687 mnt->mnt_flags = MNT_INTERNAL; 707 mnt->mnt.mnt_flags = MNT_INTERNAL;
688 708
689 root = mount_fs(type, flags, name, data); 709 root = mount_fs(type, flags, name, data);
690 if (IS_ERR(root)) { 710 if (IS_ERR(root)) {
@@ -692,19 +712,22 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
692 return ERR_CAST(root); 712 return ERR_CAST(root);
693 } 713 }
694 714
695 mnt->mnt_root = root; 715 mnt->mnt.mnt_root = root;
696 mnt->mnt_sb = root->d_sb; 716 mnt->mnt.mnt_sb = root->d_sb;
697 mnt->mnt_mountpoint = mnt->mnt_root; 717 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
698 mnt->mnt_parent = mnt; 718 mnt->mnt_parent = mnt;
699 return mnt; 719 br_write_lock(vfsmount_lock);
720 list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts);
721 br_write_unlock(vfsmount_lock);
722 return &mnt->mnt;
700} 723}
701EXPORT_SYMBOL_GPL(vfs_kern_mount); 724EXPORT_SYMBOL_GPL(vfs_kern_mount);
702 725
703static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, 726static struct mount *clone_mnt(struct mount *old, struct dentry *root,
704 int flag) 727 int flag)
705{ 728{
706 struct super_block *sb = old->mnt_sb; 729 struct super_block *sb = old->mnt.mnt_sb;
707 struct vfsmount *mnt = alloc_vfsmnt(old->mnt_devname); 730 struct mount *mnt = alloc_vfsmnt(old->mnt_devname);
708 731
709 if (mnt) { 732 if (mnt) {
710 if (flag & (CL_SLAVE | CL_PRIVATE)) 733 if (flag & (CL_SLAVE | CL_PRIVATE))
@@ -718,12 +741,15 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root,
718 goto out_free; 741 goto out_free;
719 } 742 }
720 743
721 mnt->mnt_flags = old->mnt_flags & ~MNT_WRITE_HOLD; 744 mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~MNT_WRITE_HOLD;
722 atomic_inc(&sb->s_active); 745 atomic_inc(&sb->s_active);
723 mnt->mnt_sb = sb; 746 mnt->mnt.mnt_sb = sb;
724 mnt->mnt_root = dget(root); 747 mnt->mnt.mnt_root = dget(root);
725 mnt->mnt_mountpoint = mnt->mnt_root; 748 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
726 mnt->mnt_parent = mnt; 749 mnt->mnt_parent = mnt;
750 br_write_lock(vfsmount_lock);
751 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
752 br_write_unlock(vfsmount_lock);
727 753
728 if (flag & CL_SLAVE) { 754 if (flag & CL_SLAVE) {
729 list_add(&mnt->mnt_slave, &old->mnt_slave_list); 755 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
@@ -753,9 +779,10 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root,
753 return NULL; 779 return NULL;
754} 780}
755 781
756static inline void mntfree(struct vfsmount *mnt) 782static inline void mntfree(struct mount *mnt)
757{ 783{
758 struct super_block *sb = mnt->mnt_sb; 784 struct vfsmount *m = &mnt->mnt;
785 struct super_block *sb = m->mnt_sb;
759 786
760 /* 787 /*
761 * This probably indicates that somebody messed 788 * This probably indicates that somebody messed
@@ -768,32 +795,32 @@ static inline void mntfree(struct vfsmount *mnt)
768 * so mnt_get_writers() below is safe. 795 * so mnt_get_writers() below is safe.
769 */ 796 */
770 WARN_ON(mnt_get_writers(mnt)); 797 WARN_ON(mnt_get_writers(mnt));
771 fsnotify_vfsmount_delete(mnt); 798 fsnotify_vfsmount_delete(m);
772 dput(mnt->mnt_root); 799 dput(m->mnt_root);
773 free_vfsmnt(mnt); 800 free_vfsmnt(mnt);
774 deactivate_super(sb); 801 deactivate_super(sb);
775} 802}
776 803
777static void mntput_no_expire(struct vfsmount *mnt) 804static void mntput_no_expire(struct mount *mnt)
778{ 805{
779put_again: 806put_again:
780#ifdef CONFIG_SMP 807#ifdef CONFIG_SMP
781 br_read_lock(vfsmount_lock); 808 br_read_lock(vfsmount_lock);
782 if (likely(atomic_read(&mnt->mnt_longterm))) { 809 if (likely(atomic_read(&mnt->mnt_longterm))) {
783 mnt_dec_count(mnt); 810 mnt_add_count(mnt, -1);
784 br_read_unlock(vfsmount_lock); 811 br_read_unlock(vfsmount_lock);
785 return; 812 return;
786 } 813 }
787 br_read_unlock(vfsmount_lock); 814 br_read_unlock(vfsmount_lock);
788 815
789 br_write_lock(vfsmount_lock); 816 br_write_lock(vfsmount_lock);
790 mnt_dec_count(mnt); 817 mnt_add_count(mnt, -1);
791 if (mnt_get_count(mnt)) { 818 if (mnt_get_count(mnt)) {
792 br_write_unlock(vfsmount_lock); 819 br_write_unlock(vfsmount_lock);
793 return; 820 return;
794 } 821 }
795#else 822#else
796 mnt_dec_count(mnt); 823 mnt_add_count(mnt, -1);
797 if (likely(mnt_get_count(mnt))) 824 if (likely(mnt_get_count(mnt)))
798 return; 825 return;
799 br_write_lock(vfsmount_lock); 826 br_write_lock(vfsmount_lock);
@@ -802,9 +829,10 @@ put_again:
802 mnt_add_count(mnt, mnt->mnt_pinned + 1); 829 mnt_add_count(mnt, mnt->mnt_pinned + 1);
803 mnt->mnt_pinned = 0; 830 mnt->mnt_pinned = 0;
804 br_write_unlock(vfsmount_lock); 831 br_write_unlock(vfsmount_lock);
805 acct_auto_close_mnt(mnt); 832 acct_auto_close_mnt(&mnt->mnt);
806 goto put_again; 833 goto put_again;
807 } 834 }
835 list_del(&mnt->mnt_instance);
808 br_write_unlock(vfsmount_lock); 836 br_write_unlock(vfsmount_lock);
809 mntfree(mnt); 837 mntfree(mnt);
810} 838}
@@ -812,10 +840,11 @@ put_again:
812void mntput(struct vfsmount *mnt) 840void mntput(struct vfsmount *mnt)
813{ 841{
814 if (mnt) { 842 if (mnt) {
843 struct mount *m = real_mount(mnt);
815 /* avoid cacheline pingpong, hope gcc doesn't get "smart" */ 844 /* avoid cacheline pingpong, hope gcc doesn't get "smart" */
816 if (unlikely(mnt->mnt_expiry_mark)) 845 if (unlikely(m->mnt_expiry_mark))
817 mnt->mnt_expiry_mark = 0; 846 m->mnt_expiry_mark = 0;
818 mntput_no_expire(mnt); 847 mntput_no_expire(m);
819 } 848 }
820} 849}
821EXPORT_SYMBOL(mntput); 850EXPORT_SYMBOL(mntput);
@@ -823,7 +852,7 @@ EXPORT_SYMBOL(mntput);
823struct vfsmount *mntget(struct vfsmount *mnt) 852struct vfsmount *mntget(struct vfsmount *mnt)
824{ 853{
825 if (mnt) 854 if (mnt)
826 mnt_inc_count(mnt); 855 mnt_add_count(real_mount(mnt), 1);
827 return mnt; 856 return mnt;
828} 857}
829EXPORT_SYMBOL(mntget); 858EXPORT_SYMBOL(mntget);
@@ -831,16 +860,17 @@ EXPORT_SYMBOL(mntget);
831void mnt_pin(struct vfsmount *mnt) 860void mnt_pin(struct vfsmount *mnt)
832{ 861{
833 br_write_lock(vfsmount_lock); 862 br_write_lock(vfsmount_lock);
834 mnt->mnt_pinned++; 863 real_mount(mnt)->mnt_pinned++;
835 br_write_unlock(vfsmount_lock); 864 br_write_unlock(vfsmount_lock);
836} 865}
837EXPORT_SYMBOL(mnt_pin); 866EXPORT_SYMBOL(mnt_pin);
838 867
839void mnt_unpin(struct vfsmount *mnt) 868void mnt_unpin(struct vfsmount *m)
840{ 869{
870 struct mount *mnt = real_mount(m);
841 br_write_lock(vfsmount_lock); 871 br_write_lock(vfsmount_lock);
842 if (mnt->mnt_pinned) { 872 if (mnt->mnt_pinned) {
843 mnt_inc_count(mnt); 873 mnt_add_count(mnt, 1);
844 mnt->mnt_pinned--; 874 mnt->mnt_pinned--;
845 } 875 }
846 br_write_unlock(vfsmount_lock); 876 br_write_unlock(vfsmount_lock);
@@ -858,12 +888,12 @@ static inline void mangle(struct seq_file *m, const char *s)
858 * 888 *
859 * See also save_mount_options(). 889 * See also save_mount_options().
860 */ 890 */
861int generic_show_options(struct seq_file *m, struct vfsmount *mnt) 891int generic_show_options(struct seq_file *m, struct dentry *root)
862{ 892{
863 const char *options; 893 const char *options;
864 894
865 rcu_read_lock(); 895 rcu_read_lock();
866 options = rcu_dereference(mnt->mnt_sb->s_options); 896 options = rcu_dereference(root->d_sb->s_options);
867 897
868 if (options != NULL && options[0]) { 898 if (options != NULL && options[0]) {
869 seq_putc(m, ','); 899 seq_putc(m, ',');
@@ -907,10 +937,10 @@ void replace_mount_options(struct super_block *sb, char *options)
907EXPORT_SYMBOL(replace_mount_options); 937EXPORT_SYMBOL(replace_mount_options);
908 938
909#ifdef CONFIG_PROC_FS 939#ifdef CONFIG_PROC_FS
910/* iterator */ 940/* iterator; we want it to have access to namespace_sem, thus here... */
911static void *m_start(struct seq_file *m, loff_t *pos) 941static void *m_start(struct seq_file *m, loff_t *pos)
912{ 942{
913 struct proc_mounts *p = m->private; 943 struct proc_mounts *p = container_of(m, struct proc_mounts, m);
914 944
915 down_read(&namespace_sem); 945 down_read(&namespace_sem);
916 return seq_list_start(&p->ns->list, *pos); 946 return seq_list_start(&p->ns->list, *pos);
@@ -918,7 +948,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
918 948
919static void *m_next(struct seq_file *m, void *v, loff_t *pos) 949static void *m_next(struct seq_file *m, void *v, loff_t *pos)
920{ 950{
921 struct proc_mounts *p = m->private; 951 struct proc_mounts *p = container_of(m, struct proc_mounts, m);
922 952
923 return seq_list_next(v, &p->ns->list, pos); 953 return seq_list_next(v, &p->ns->list, pos);
924} 954}
@@ -928,219 +958,18 @@ static void m_stop(struct seq_file *m, void *v)
928 up_read(&namespace_sem); 958 up_read(&namespace_sem);
929} 959}
930 960
931int mnt_had_events(struct proc_mounts *p) 961static int m_show(struct seq_file *m, void *v)
932{ 962{
933 struct mnt_namespace *ns = p->ns; 963 struct proc_mounts *p = container_of(m, struct proc_mounts, m);
934 int res = 0; 964 struct mount *r = list_entry(v, struct mount, mnt_list);
935 965 return p->show(m, &r->mnt);
936 br_read_lock(vfsmount_lock);
937 if (p->m.poll_event != ns->event) {
938 p->m.poll_event = ns->event;
939 res = 1;
940 }
941 br_read_unlock(vfsmount_lock);
942
943 return res;
944}
945
946struct proc_fs_info {
947 int flag;
948 const char *str;
949};
950
951static int show_sb_opts(struct seq_file *m, struct super_block *sb)
952{
953 static const struct proc_fs_info fs_info[] = {
954 { MS_SYNCHRONOUS, ",sync" },
955 { MS_DIRSYNC, ",dirsync" },
956 { MS_MANDLOCK, ",mand" },
957 { 0, NULL }
958 };
959 const struct proc_fs_info *fs_infop;
960
961 for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
962 if (sb->s_flags & fs_infop->flag)
963 seq_puts(m, fs_infop->str);
964 }
965
966 return security_sb_show_options(m, sb);
967}
968
969static void show_mnt_opts(struct seq_file *m, struct vfsmount *mnt)
970{
971 static const struct proc_fs_info mnt_info[] = {
972 { MNT_NOSUID, ",nosuid" },
973 { MNT_NODEV, ",nodev" },
974 { MNT_NOEXEC, ",noexec" },
975 { MNT_NOATIME, ",noatime" },
976 { MNT_NODIRATIME, ",nodiratime" },
977 { MNT_RELATIME, ",relatime" },
978 { 0, NULL }
979 };
980 const struct proc_fs_info *fs_infop;
981
982 for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
983 if (mnt->mnt_flags & fs_infop->flag)
984 seq_puts(m, fs_infop->str);
985 }
986}
987
988static void show_type(struct seq_file *m, struct super_block *sb)
989{
990 mangle(m, sb->s_type->name);
991 if (sb->s_subtype && sb->s_subtype[0]) {
992 seq_putc(m, '.');
993 mangle(m, sb->s_subtype);
994 }
995}
996
997static int show_vfsmnt(struct seq_file *m, void *v)
998{
999 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
1000 int err = 0;
1001 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
1002
1003 if (mnt->mnt_sb->s_op->show_devname) {
1004 err = mnt->mnt_sb->s_op->show_devname(m, mnt);
1005 if (err)
1006 goto out;
1007 } else {
1008 mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
1009 }
1010 seq_putc(m, ' ');
1011 seq_path(m, &mnt_path, " \t\n\\");
1012 seq_putc(m, ' ');
1013 show_type(m, mnt->mnt_sb);
1014 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
1015 err = show_sb_opts(m, mnt->mnt_sb);
1016 if (err)
1017 goto out;
1018 show_mnt_opts(m, mnt);
1019 if (mnt->mnt_sb->s_op->show_options)
1020 err = mnt->mnt_sb->s_op->show_options(m, mnt);
1021 seq_puts(m, " 0 0\n");
1022out:
1023 return err;
1024} 966}
1025 967
1026const struct seq_operations mounts_op = { 968const struct seq_operations mounts_op = {
1027 .start = m_start, 969 .start = m_start,
1028 .next = m_next, 970 .next = m_next,
1029 .stop = m_stop, 971 .stop = m_stop,
1030 .show = show_vfsmnt 972 .show = m_show,
1031};
1032
1033static int show_mountinfo(struct seq_file *m, void *v)
1034{
1035 struct proc_mounts *p = m->private;
1036 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
1037 struct super_block *sb = mnt->mnt_sb;
1038 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
1039 struct path root = p->root;
1040 int err = 0;
1041
1042 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
1043 MAJOR(sb->s_dev), MINOR(sb->s_dev));
1044 if (sb->s_op->show_path)
1045 err = sb->s_op->show_path(m, mnt);
1046 else
1047 seq_dentry(m, mnt->mnt_root, " \t\n\\");
1048 if (err)
1049 goto out;
1050 seq_putc(m, ' ');
1051
1052 /* mountpoints outside of chroot jail will give SEQ_SKIP on this */
1053 err = seq_path_root(m, &mnt_path, &root, " \t\n\\");
1054 if (err)
1055 goto out;
1056
1057 seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw");
1058 show_mnt_opts(m, mnt);
1059
1060 /* Tagged fields ("foo:X" or "bar") */
1061 if (IS_MNT_SHARED(mnt))
1062 seq_printf(m, " shared:%i", mnt->mnt_group_id);
1063 if (IS_MNT_SLAVE(mnt)) {
1064 int master = mnt->mnt_master->mnt_group_id;
1065 int dom = get_dominating_id(mnt, &p->root);
1066 seq_printf(m, " master:%i", master);
1067 if (dom && dom != master)
1068 seq_printf(m, " propagate_from:%i", dom);
1069 }
1070 if (IS_MNT_UNBINDABLE(mnt))
1071 seq_puts(m, " unbindable");
1072
1073 /* Filesystem specific data */
1074 seq_puts(m, " - ");
1075 show_type(m, sb);
1076 seq_putc(m, ' ');
1077 if (sb->s_op->show_devname)
1078 err = sb->s_op->show_devname(m, mnt);
1079 else
1080 mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
1081 if (err)
1082 goto out;
1083 seq_puts(m, sb->s_flags & MS_RDONLY ? " ro" : " rw");
1084 err = show_sb_opts(m, sb);
1085 if (err)
1086 goto out;
1087 if (sb->s_op->show_options)
1088 err = sb->s_op->show_options(m, mnt);
1089 seq_putc(m, '\n');
1090out:
1091 return err;
1092}
1093
1094const struct seq_operations mountinfo_op = {
1095 .start = m_start,
1096 .next = m_next,
1097 .stop = m_stop,
1098 .show = show_mountinfo,
1099};
1100
1101static int show_vfsstat(struct seq_file *m, void *v)
1102{
1103 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
1104 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
1105 int err = 0;
1106
1107 /* device */
1108 if (mnt->mnt_sb->s_op->show_devname) {
1109 seq_puts(m, "device ");
1110 err = mnt->mnt_sb->s_op->show_devname(m, mnt);
1111 } else {
1112 if (mnt->mnt_devname) {
1113 seq_puts(m, "device ");
1114 mangle(m, mnt->mnt_devname);
1115 } else
1116 seq_puts(m, "no device");
1117 }
1118
1119 /* mount point */
1120 seq_puts(m, " mounted on ");
1121 seq_path(m, &mnt_path, " \t\n\\");
1122 seq_putc(m, ' ');
1123
1124 /* file system type */
1125 seq_puts(m, "with fstype ");
1126 show_type(m, mnt->mnt_sb);
1127
1128 /* optional statistics */
1129 if (mnt->mnt_sb->s_op->show_stats) {
1130 seq_putc(m, ' ');
1131 if (!err)
1132 err = mnt->mnt_sb->s_op->show_stats(m, mnt);
1133 }
1134
1135 seq_putc(m, '\n');
1136 return err;
1137}
1138
1139const struct seq_operations mountstats_op = {
1140 .start = m_start,
1141 .next = m_next,
1142 .stop = m_stop,
1143 .show = show_vfsstat,
1144}; 973};
1145#endif /* CONFIG_PROC_FS */ 974#endif /* CONFIG_PROC_FS */
1146 975
@@ -1152,11 +981,13 @@ const struct seq_operations mountstats_op = {
1152 * open files, pwds, chroots or sub mounts that are 981 * open files, pwds, chroots or sub mounts that are
1153 * busy. 982 * busy.
1154 */ 983 */
1155int may_umount_tree(struct vfsmount *mnt) 984int may_umount_tree(struct vfsmount *m)
1156{ 985{
986 struct mount *mnt = real_mount(m);
1157 int actual_refs = 0; 987 int actual_refs = 0;
1158 int minimum_refs = 0; 988 int minimum_refs = 0;
1159 struct vfsmount *p; 989 struct mount *p;
990 BUG_ON(!m);
1160 991
1161 /* write lock needed for mnt_get_count */ 992 /* write lock needed for mnt_get_count */
1162 br_write_lock(vfsmount_lock); 993 br_write_lock(vfsmount_lock);
@@ -1192,7 +1023,7 @@ int may_umount(struct vfsmount *mnt)
1192 int ret = 1; 1023 int ret = 1;
1193 down_read(&namespace_sem); 1024 down_read(&namespace_sem);
1194 br_write_lock(vfsmount_lock); 1025 br_write_lock(vfsmount_lock);
1195 if (propagate_mount_busy(mnt, 2)) 1026 if (propagate_mount_busy(real_mount(mnt), 2))
1196 ret = 0; 1027 ret = 0;
1197 br_write_unlock(vfsmount_lock); 1028 br_write_unlock(vfsmount_lock);
1198 up_read(&namespace_sem); 1029 up_read(&namespace_sem);
@@ -1203,25 +1034,25 @@ EXPORT_SYMBOL(may_umount);
1203 1034
1204void release_mounts(struct list_head *head) 1035void release_mounts(struct list_head *head)
1205{ 1036{
1206 struct vfsmount *mnt; 1037 struct mount *mnt;
1207 while (!list_empty(head)) { 1038 while (!list_empty(head)) {
1208 mnt = list_first_entry(head, struct vfsmount, mnt_hash); 1039 mnt = list_first_entry(head, struct mount, mnt_hash);
1209 list_del_init(&mnt->mnt_hash); 1040 list_del_init(&mnt->mnt_hash);
1210 if (mnt->mnt_parent != mnt) { 1041 if (mnt_has_parent(mnt)) {
1211 struct dentry *dentry; 1042 struct dentry *dentry;
1212 struct vfsmount *m; 1043 struct mount *m;
1213 1044
1214 br_write_lock(vfsmount_lock); 1045 br_write_lock(vfsmount_lock);
1215 dentry = mnt->mnt_mountpoint; 1046 dentry = mnt->mnt_mountpoint;
1216 m = mnt->mnt_parent; 1047 m = mnt->mnt_parent;
1217 mnt->mnt_mountpoint = mnt->mnt_root; 1048 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
1218 mnt->mnt_parent = mnt; 1049 mnt->mnt_parent = mnt;
1219 m->mnt_ghosts--; 1050 m->mnt_ghosts--;
1220 br_write_unlock(vfsmount_lock); 1051 br_write_unlock(vfsmount_lock);
1221 dput(dentry); 1052 dput(dentry);
1222 mntput(m); 1053 mntput(&m->mnt);
1223 } 1054 }
1224 mntput(mnt); 1055 mntput(&mnt->mnt);
1225 } 1056 }
1226} 1057}
1227 1058
@@ -1229,10 +1060,10 @@ void release_mounts(struct list_head *head)
1229 * vfsmount lock must be held for write 1060 * vfsmount lock must be held for write
1230 * namespace_sem must be held for write 1061 * namespace_sem must be held for write
1231 */ 1062 */
1232void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) 1063void umount_tree(struct mount *mnt, int propagate, struct list_head *kill)
1233{ 1064{
1234 LIST_HEAD(tmp_list); 1065 LIST_HEAD(tmp_list);
1235 struct vfsmount *p; 1066 struct mount *p;
1236 1067
1237 for (p = mnt; p; p = next_mnt(p, mnt)) 1068 for (p = mnt; p; p = next_mnt(p, mnt))
1238 list_move(&p->mnt_hash, &tmp_list); 1069 list_move(&p->mnt_hash, &tmp_list);
@@ -1247,24 +1078,24 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
1247 p->mnt_ns = NULL; 1078 p->mnt_ns = NULL;
1248 __mnt_make_shortterm(p); 1079 __mnt_make_shortterm(p);
1249 list_del_init(&p->mnt_child); 1080 list_del_init(&p->mnt_child);
1250 if (p->mnt_parent != p) { 1081 if (mnt_has_parent(p)) {
1251 p->mnt_parent->mnt_ghosts++; 1082 p->mnt_parent->mnt_ghosts++;
1252 dentry_reset_mounted(p->mnt_parent, p->mnt_mountpoint); 1083 dentry_reset_mounted(p->mnt_mountpoint);
1253 } 1084 }
1254 change_mnt_propagation(p, MS_PRIVATE); 1085 change_mnt_propagation(p, MS_PRIVATE);
1255 } 1086 }
1256 list_splice(&tmp_list, kill); 1087 list_splice(&tmp_list, kill);
1257} 1088}
1258 1089
1259static void shrink_submounts(struct vfsmount *mnt, struct list_head *umounts); 1090static void shrink_submounts(struct mount *mnt, struct list_head *umounts);
1260 1091
1261static int do_umount(struct vfsmount *mnt, int flags) 1092static int do_umount(struct mount *mnt, int flags)
1262{ 1093{
1263 struct super_block *sb = mnt->mnt_sb; 1094 struct super_block *sb = mnt->mnt.mnt_sb;
1264 int retval; 1095 int retval;
1265 LIST_HEAD(umount_list); 1096 LIST_HEAD(umount_list);
1266 1097
1267 retval = security_sb_umount(mnt, flags); 1098 retval = security_sb_umount(&mnt->mnt, flags);
1268 if (retval) 1099 if (retval)
1269 return retval; 1100 return retval;
1270 1101
@@ -1275,7 +1106,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
1275 * (2) the usage count == 1 [parent vfsmount] + 1 [sys_umount] 1106 * (2) the usage count == 1 [parent vfsmount] + 1 [sys_umount]
1276 */ 1107 */
1277 if (flags & MNT_EXPIRE) { 1108 if (flags & MNT_EXPIRE) {
1278 if (mnt == current->fs->root.mnt || 1109 if (&mnt->mnt == current->fs->root.mnt ||
1279 flags & (MNT_FORCE | MNT_DETACH)) 1110 flags & (MNT_FORCE | MNT_DETACH))
1280 return -EINVAL; 1111 return -EINVAL;
1281 1112
@@ -1317,7 +1148,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
1317 * /reboot - static binary that would close all descriptors and 1148 * /reboot - static binary that would close all descriptors and
1318 * call reboot(9). Then init(8) could umount root and exec /reboot. 1149 * call reboot(9). Then init(8) could umount root and exec /reboot.
1319 */ 1150 */
1320 if (mnt == current->fs->root.mnt && !(flags & MNT_DETACH)) { 1151 if (&mnt->mnt == current->fs->root.mnt && !(flags & MNT_DETACH)) {
1321 /* 1152 /*
1322 * Special case for "unmounting" root ... 1153 * Special case for "unmounting" root ...
1323 * we just try to remount it readonly. 1154 * we just try to remount it readonly.
@@ -1359,6 +1190,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
1359SYSCALL_DEFINE2(umount, char __user *, name, int, flags) 1190SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
1360{ 1191{
1361 struct path path; 1192 struct path path;
1193 struct mount *mnt;
1362 int retval; 1194 int retval;
1363 int lookup_flags = 0; 1195 int lookup_flags = 0;
1364 1196
@@ -1371,21 +1203,22 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
1371 retval = user_path_at(AT_FDCWD, name, lookup_flags, &path); 1203 retval = user_path_at(AT_FDCWD, name, lookup_flags, &path);
1372 if (retval) 1204 if (retval)
1373 goto out; 1205 goto out;
1206 mnt = real_mount(path.mnt);
1374 retval = -EINVAL; 1207 retval = -EINVAL;
1375 if (path.dentry != path.mnt->mnt_root) 1208 if (path.dentry != path.mnt->mnt_root)
1376 goto dput_and_out; 1209 goto dput_and_out;
1377 if (!check_mnt(path.mnt)) 1210 if (!check_mnt(mnt))
1378 goto dput_and_out; 1211 goto dput_and_out;
1379 1212
1380 retval = -EPERM; 1213 retval = -EPERM;
1381 if (!capable(CAP_SYS_ADMIN)) 1214 if (!capable(CAP_SYS_ADMIN))
1382 goto dput_and_out; 1215 goto dput_and_out;
1383 1216
1384 retval = do_umount(path.mnt, flags); 1217 retval = do_umount(mnt, flags);
1385dput_and_out: 1218dput_and_out:
1386 /* we mustn't call path_put() as that would clear mnt_expiry_mark */ 1219 /* we mustn't call path_put() as that would clear mnt_expiry_mark */
1387 dput(path.dentry); 1220 dput(path.dentry);
1388 mntput_no_expire(path.mnt); 1221 mntput_no_expire(mnt);
1389out: 1222out:
1390 return retval; 1223 return retval;
1391} 1224}
@@ -1420,10 +1253,10 @@ static int mount_is_safe(struct path *path)
1420#endif 1253#endif
1421} 1254}
1422 1255
1423struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, 1256struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,
1424 int flag) 1257 int flag)
1425{ 1258{
1426 struct vfsmount *res, *p, *q, *r, *s; 1259 struct mount *res, *p, *q, *r;
1427 struct path path; 1260 struct path path;
1428 1261
1429 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt)) 1262 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt))
@@ -1436,6 +1269,7 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry,
1436 1269
1437 p = mnt; 1270 p = mnt;
1438 list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) { 1271 list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) {
1272 struct mount *s;
1439 if (!is_subdir(r->mnt_mountpoint, dentry)) 1273 if (!is_subdir(r->mnt_mountpoint, dentry))
1440 continue; 1274 continue;
1441 1275
@@ -1449,9 +1283,9 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry,
1449 q = q->mnt_parent; 1283 q = q->mnt_parent;
1450 } 1284 }
1451 p = s; 1285 p = s;
1452 path.mnt = q; 1286 path.mnt = &q->mnt;
1453 path.dentry = p->mnt_mountpoint; 1287 path.dentry = p->mnt_mountpoint;
1454 q = clone_mnt(p, p->mnt_root, flag); 1288 q = clone_mnt(p, p->mnt.mnt_root, flag);
1455 if (!q) 1289 if (!q)
1456 goto Enomem; 1290 goto Enomem;
1457 br_write_lock(vfsmount_lock); 1291 br_write_lock(vfsmount_lock);
@@ -1474,11 +1308,12 @@ Enomem:
1474 1308
1475struct vfsmount *collect_mounts(struct path *path) 1309struct vfsmount *collect_mounts(struct path *path)
1476{ 1310{
1477 struct vfsmount *tree; 1311 struct mount *tree;
1478 down_write(&namespace_sem); 1312 down_write(&namespace_sem);
1479 tree = copy_tree(path->mnt, path->dentry, CL_COPY_ALL | CL_PRIVATE); 1313 tree = copy_tree(real_mount(path->mnt), path->dentry,
1314 CL_COPY_ALL | CL_PRIVATE);
1480 up_write(&namespace_sem); 1315 up_write(&namespace_sem);
1481 return tree; 1316 return tree ? &tree->mnt : NULL;
1482} 1317}
1483 1318
1484void drop_collected_mounts(struct vfsmount *mnt) 1319void drop_collected_mounts(struct vfsmount *mnt)
@@ -1486,7 +1321,7 @@ void drop_collected_mounts(struct vfsmount *mnt)
1486 LIST_HEAD(umount_list); 1321 LIST_HEAD(umount_list);
1487 down_write(&namespace_sem); 1322 down_write(&namespace_sem);
1488 br_write_lock(vfsmount_lock); 1323 br_write_lock(vfsmount_lock);
1489 umount_tree(mnt, 0, &umount_list); 1324 umount_tree(real_mount(mnt), 0, &umount_list);
1490 br_write_unlock(vfsmount_lock); 1325 br_write_unlock(vfsmount_lock);
1491 up_write(&namespace_sem); 1326 up_write(&namespace_sem);
1492 release_mounts(&umount_list); 1327 release_mounts(&umount_list);
@@ -1495,21 +1330,21 @@ void drop_collected_mounts(struct vfsmount *mnt)
1495int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, 1330int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
1496 struct vfsmount *root) 1331 struct vfsmount *root)
1497{ 1332{
1498 struct vfsmount *mnt; 1333 struct mount *mnt;
1499 int res = f(root, arg); 1334 int res = f(root, arg);
1500 if (res) 1335 if (res)
1501 return res; 1336 return res;
1502 list_for_each_entry(mnt, &root->mnt_list, mnt_list) { 1337 list_for_each_entry(mnt, &real_mount(root)->mnt_list, mnt_list) {
1503 res = f(mnt, arg); 1338 res = f(&mnt->mnt, arg);
1504 if (res) 1339 if (res)
1505 return res; 1340 return res;
1506 } 1341 }
1507 return 0; 1342 return 0;
1508} 1343}
1509 1344
1510static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end) 1345static void cleanup_group_ids(struct mount *mnt, struct mount *end)
1511{ 1346{
1512 struct vfsmount *p; 1347 struct mount *p;
1513 1348
1514 for (p = mnt; p != end; p = next_mnt(p, mnt)) { 1349 for (p = mnt; p != end; p = next_mnt(p, mnt)) {
1515 if (p->mnt_group_id && !IS_MNT_SHARED(p)) 1350 if (p->mnt_group_id && !IS_MNT_SHARED(p))
@@ -1517,9 +1352,9 @@ static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end)
1517 } 1352 }
1518} 1353}
1519 1354
1520static int invent_group_ids(struct vfsmount *mnt, bool recurse) 1355static int invent_group_ids(struct mount *mnt, bool recurse)
1521{ 1356{
1522 struct vfsmount *p; 1357 struct mount *p;
1523 1358
1524 for (p = mnt; p; p = recurse ? next_mnt(p, mnt) : NULL) { 1359 for (p = mnt; p; p = recurse ? next_mnt(p, mnt) : NULL) {
1525 if (!p->mnt_group_id && !IS_MNT_SHARED(p)) { 1360 if (!p->mnt_group_id && !IS_MNT_SHARED(p)) {
@@ -1597,13 +1432,13 @@ static int invent_group_ids(struct vfsmount *mnt, bool recurse)
1597 * Must be called without spinlocks held, since this function can sleep 1432 * Must be called without spinlocks held, since this function can sleep
1598 * in allocations. 1433 * in allocations.
1599 */ 1434 */
1600static int attach_recursive_mnt(struct vfsmount *source_mnt, 1435static int attach_recursive_mnt(struct mount *source_mnt,
1601 struct path *path, struct path *parent_path) 1436 struct path *path, struct path *parent_path)
1602{ 1437{
1603 LIST_HEAD(tree_list); 1438 LIST_HEAD(tree_list);
1604 struct vfsmount *dest_mnt = path->mnt; 1439 struct mount *dest_mnt = real_mount(path->mnt);
1605 struct dentry *dest_dentry = path->dentry; 1440 struct dentry *dest_dentry = path->dentry;
1606 struct vfsmount *child, *p; 1441 struct mount *child, *p;
1607 int err; 1442 int err;
1608 1443
1609 if (IS_MNT_SHARED(dest_mnt)) { 1444 if (IS_MNT_SHARED(dest_mnt)) {
@@ -1624,7 +1459,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
1624 if (parent_path) { 1459 if (parent_path) {
1625 detach_mnt(source_mnt, parent_path); 1460 detach_mnt(source_mnt, parent_path);
1626 attach_mnt(source_mnt, path); 1461 attach_mnt(source_mnt, path);
1627 touch_mnt_namespace(parent_path->mnt->mnt_ns); 1462 touch_mnt_namespace(source_mnt->mnt_ns);
1628 } else { 1463 } else {
1629 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); 1464 mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
1630 commit_tree(source_mnt); 1465 commit_tree(source_mnt);
@@ -1672,13 +1507,13 @@ static void unlock_mount(struct path *path)
1672 mutex_unlock(&path->dentry->d_inode->i_mutex); 1507 mutex_unlock(&path->dentry->d_inode->i_mutex);
1673} 1508}
1674 1509
1675static int graft_tree(struct vfsmount *mnt, struct path *path) 1510static int graft_tree(struct mount *mnt, struct path *path)
1676{ 1511{
1677 if (mnt->mnt_sb->s_flags & MS_NOUSER) 1512 if (mnt->mnt.mnt_sb->s_flags & MS_NOUSER)
1678 return -EINVAL; 1513 return -EINVAL;
1679 1514
1680 if (S_ISDIR(path->dentry->d_inode->i_mode) != 1515 if (S_ISDIR(path->dentry->d_inode->i_mode) !=
1681 S_ISDIR(mnt->mnt_root->d_inode->i_mode)) 1516 S_ISDIR(mnt->mnt.mnt_root->d_inode->i_mode))
1682 return -ENOTDIR; 1517 return -ENOTDIR;
1683 1518
1684 if (d_unlinked(path->dentry)) 1519 if (d_unlinked(path->dentry))
@@ -1709,7 +1544,8 @@ static int flags_to_propagation_type(int flags)
1709 */ 1544 */
1710static int do_change_type(struct path *path, int flag) 1545static int do_change_type(struct path *path, int flag)
1711{ 1546{
1712 struct vfsmount *m, *mnt = path->mnt; 1547 struct mount *m;
1548 struct mount *mnt = real_mount(path->mnt);
1713 int recurse = flag & MS_REC; 1549 int recurse = flag & MS_REC;
1714 int type; 1550 int type;
1715 int err = 0; 1551 int err = 0;
@@ -1749,7 +1585,7 @@ static int do_loopback(struct path *path, char *old_name,
1749{ 1585{
1750 LIST_HEAD(umount_list); 1586 LIST_HEAD(umount_list);
1751 struct path old_path; 1587 struct path old_path;
1752 struct vfsmount *mnt = NULL; 1588 struct mount *mnt = NULL, *old;
1753 int err = mount_is_safe(path); 1589 int err = mount_is_safe(path);
1754 if (err) 1590 if (err)
1755 return err; 1591 return err;
@@ -1763,18 +1599,20 @@ static int do_loopback(struct path *path, char *old_name,
1763 if (err) 1599 if (err)
1764 goto out; 1600 goto out;
1765 1601
1602 old = real_mount(old_path.mnt);
1603
1766 err = -EINVAL; 1604 err = -EINVAL;
1767 if (IS_MNT_UNBINDABLE(old_path.mnt)) 1605 if (IS_MNT_UNBINDABLE(old))
1768 goto out2; 1606 goto out2;
1769 1607
1770 if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) 1608 if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old))
1771 goto out2; 1609 goto out2;
1772 1610
1773 err = -ENOMEM; 1611 err = -ENOMEM;
1774 if (recurse) 1612 if (recurse)
1775 mnt = copy_tree(old_path.mnt, old_path.dentry, 0); 1613 mnt = copy_tree(old, old_path.dentry, 0);
1776 else 1614 else
1777 mnt = clone_mnt(old_path.mnt, old_path.dentry, 0); 1615 mnt = clone_mnt(old, old_path.dentry, 0);
1778 1616
1779 if (!mnt) 1617 if (!mnt)
1780 goto out2; 1618 goto out2;
@@ -1804,9 +1642,9 @@ static int change_mount_flags(struct vfsmount *mnt, int ms_flags)
1804 return 0; 1642 return 0;
1805 1643
1806 if (readonly_request) 1644 if (readonly_request)
1807 error = mnt_make_readonly(mnt); 1645 error = mnt_make_readonly(real_mount(mnt));
1808 else 1646 else
1809 __mnt_unmake_readonly(mnt); 1647 __mnt_unmake_readonly(real_mount(mnt));
1810 return error; 1648 return error;
1811} 1649}
1812 1650
@@ -1820,11 +1658,12 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
1820{ 1658{
1821 int err; 1659 int err;
1822 struct super_block *sb = path->mnt->mnt_sb; 1660 struct super_block *sb = path->mnt->mnt_sb;
1661 struct mount *mnt = real_mount(path->mnt);
1823 1662
1824 if (!capable(CAP_SYS_ADMIN)) 1663 if (!capable(CAP_SYS_ADMIN))
1825 return -EPERM; 1664 return -EPERM;
1826 1665
1827 if (!check_mnt(path->mnt)) 1666 if (!check_mnt(mnt))
1828 return -EINVAL; 1667 return -EINVAL;
1829 1668
1830 if (path->dentry != path->mnt->mnt_root) 1669 if (path->dentry != path->mnt->mnt_root)
@@ -1841,22 +1680,22 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
1841 err = do_remount_sb(sb, flags, data, 0); 1680 err = do_remount_sb(sb, flags, data, 0);
1842 if (!err) { 1681 if (!err) {
1843 br_write_lock(vfsmount_lock); 1682 br_write_lock(vfsmount_lock);
1844 mnt_flags |= path->mnt->mnt_flags & MNT_PROPAGATION_MASK; 1683 mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK;
1845 path->mnt->mnt_flags = mnt_flags; 1684 mnt->mnt.mnt_flags = mnt_flags;
1846 br_write_unlock(vfsmount_lock); 1685 br_write_unlock(vfsmount_lock);
1847 } 1686 }
1848 up_write(&sb->s_umount); 1687 up_write(&sb->s_umount);
1849 if (!err) { 1688 if (!err) {
1850 br_write_lock(vfsmount_lock); 1689 br_write_lock(vfsmount_lock);
1851 touch_mnt_namespace(path->mnt->mnt_ns); 1690 touch_mnt_namespace(mnt->mnt_ns);
1852 br_write_unlock(vfsmount_lock); 1691 br_write_unlock(vfsmount_lock);
1853 } 1692 }
1854 return err; 1693 return err;
1855} 1694}
1856 1695
1857static inline int tree_contains_unbindable(struct vfsmount *mnt) 1696static inline int tree_contains_unbindable(struct mount *mnt)
1858{ 1697{
1859 struct vfsmount *p; 1698 struct mount *p;
1860 for (p = mnt; p; p = next_mnt(p, mnt)) { 1699 for (p = mnt; p; p = next_mnt(p, mnt)) {
1861 if (IS_MNT_UNBINDABLE(p)) 1700 if (IS_MNT_UNBINDABLE(p))
1862 return 1; 1701 return 1;
@@ -1867,7 +1706,8 @@ static inline int tree_contains_unbindable(struct vfsmount *mnt)
1867static int do_move_mount(struct path *path, char *old_name) 1706static int do_move_mount(struct path *path, char *old_name)
1868{ 1707{
1869 struct path old_path, parent_path; 1708 struct path old_path, parent_path;
1870 struct vfsmount *p; 1709 struct mount *p;
1710 struct mount *old;
1871 int err = 0; 1711 int err = 0;
1872 if (!capable(CAP_SYS_ADMIN)) 1712 if (!capable(CAP_SYS_ADMIN))
1873 return -EPERM; 1713 return -EPERM;
@@ -1881,8 +1721,11 @@ static int do_move_mount(struct path *path, char *old_name)
1881 if (err < 0) 1721 if (err < 0)
1882 goto out; 1722 goto out;
1883 1723
1724 old = real_mount(old_path.mnt);
1725 p = real_mount(path->mnt);
1726
1884 err = -EINVAL; 1727 err = -EINVAL;
1885 if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) 1728 if (!check_mnt(p) || !check_mnt(old))
1886 goto out1; 1729 goto out1;
1887 1730
1888 if (d_unlinked(path->dentry)) 1731 if (d_unlinked(path->dentry))
@@ -1892,7 +1735,7 @@ static int do_move_mount(struct path *path, char *old_name)
1892 if (old_path.dentry != old_path.mnt->mnt_root) 1735 if (old_path.dentry != old_path.mnt->mnt_root)
1893 goto out1; 1736 goto out1;
1894 1737
1895 if (old_path.mnt == old_path.mnt->mnt_parent) 1738 if (!mnt_has_parent(old))
1896 goto out1; 1739 goto out1;
1897 1740
1898 if (S_ISDIR(path->dentry->d_inode->i_mode) != 1741 if (S_ISDIR(path->dentry->d_inode->i_mode) !=
@@ -1901,28 +1744,26 @@ static int do_move_mount(struct path *path, char *old_name)
1901 /* 1744 /*
1902 * Don't move a mount residing in a shared parent. 1745 * Don't move a mount residing in a shared parent.
1903 */ 1746 */
1904 if (old_path.mnt->mnt_parent && 1747 if (IS_MNT_SHARED(old->mnt_parent))
1905 IS_MNT_SHARED(old_path.mnt->mnt_parent))
1906 goto out1; 1748 goto out1;
1907 /* 1749 /*
1908 * Don't move a mount tree containing unbindable mounts to a destination 1750 * Don't move a mount tree containing unbindable mounts to a destination
1909 * mount which is shared. 1751 * mount which is shared.
1910 */ 1752 */
1911 if (IS_MNT_SHARED(path->mnt) && 1753 if (IS_MNT_SHARED(p) && tree_contains_unbindable(old))
1912 tree_contains_unbindable(old_path.mnt))
1913 goto out1; 1754 goto out1;
1914 err = -ELOOP; 1755 err = -ELOOP;
1915 for (p = path->mnt; p->mnt_parent != p; p = p->mnt_parent) 1756 for (; mnt_has_parent(p); p = p->mnt_parent)
1916 if (p == old_path.mnt) 1757 if (p == old)
1917 goto out1; 1758 goto out1;
1918 1759
1919 err = attach_recursive_mnt(old_path.mnt, path, &parent_path); 1760 err = attach_recursive_mnt(old, path, &parent_path);
1920 if (err) 1761 if (err)
1921 goto out1; 1762 goto out1;
1922 1763
1923 /* if the mount is moved, it should no longer be expire 1764 /* if the mount is moved, it should no longer be expire
1924 * automatically */ 1765 * automatically */
1925 list_del_init(&old_path.mnt->mnt_expire); 1766 list_del_init(&old->mnt_expire);
1926out1: 1767out1:
1927 unlock_mount(path); 1768 unlock_mount(path);
1928out: 1769out:
@@ -1955,7 +1796,7 @@ static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype)
1955 return ERR_PTR(err); 1796 return ERR_PTR(err);
1956} 1797}
1957 1798
1958struct vfsmount * 1799static struct vfsmount *
1959do_kern_mount(const char *fstype, int flags, const char *name, void *data) 1800do_kern_mount(const char *fstype, int flags, const char *name, void *data)
1960{ 1801{
1961 struct file_system_type *type = get_fs_type(fstype); 1802 struct file_system_type *type = get_fs_type(fstype);
@@ -1969,12 +1810,11 @@ do_kern_mount(const char *fstype, int flags, const char *name, void *data)
1969 put_filesystem(type); 1810 put_filesystem(type);
1970 return mnt; 1811 return mnt;
1971} 1812}
1972EXPORT_SYMBOL_GPL(do_kern_mount);
1973 1813
1974/* 1814/*
1975 * add a mount into a namespace's mount tree 1815 * add a mount into a namespace's mount tree
1976 */ 1816 */
1977static int do_add_mount(struct vfsmount *newmnt, struct path *path, int mnt_flags) 1817static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags)
1978{ 1818{
1979 int err; 1819 int err;
1980 1820
@@ -1985,20 +1825,20 @@ static int do_add_mount(struct vfsmount *newmnt, struct path *path, int mnt_flag
1985 return err; 1825 return err;
1986 1826
1987 err = -EINVAL; 1827 err = -EINVAL;
1988 if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(path->mnt)) 1828 if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(real_mount(path->mnt)))
1989 goto unlock; 1829 goto unlock;
1990 1830
1991 /* Refuse the same filesystem on the same mount point */ 1831 /* Refuse the same filesystem on the same mount point */
1992 err = -EBUSY; 1832 err = -EBUSY;
1993 if (path->mnt->mnt_sb == newmnt->mnt_sb && 1833 if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb &&
1994 path->mnt->mnt_root == path->dentry) 1834 path->mnt->mnt_root == path->dentry)
1995 goto unlock; 1835 goto unlock;
1996 1836
1997 err = -EINVAL; 1837 err = -EINVAL;
1998 if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) 1838 if (S_ISLNK(newmnt->mnt.mnt_root->d_inode->i_mode))
1999 goto unlock; 1839 goto unlock;
2000 1840
2001 newmnt->mnt_flags = mnt_flags; 1841 newmnt->mnt.mnt_flags = mnt_flags;
2002 err = graft_tree(newmnt, path); 1842 err = graft_tree(newmnt, path);
2003 1843
2004unlock: 1844unlock:
@@ -2027,7 +1867,7 @@ static int do_new_mount(struct path *path, char *type, int flags,
2027 if (IS_ERR(mnt)) 1867 if (IS_ERR(mnt))
2028 return PTR_ERR(mnt); 1868 return PTR_ERR(mnt);
2029 1869
2030 err = do_add_mount(mnt, path, mnt_flags); 1870 err = do_add_mount(real_mount(mnt), path, mnt_flags);
2031 if (err) 1871 if (err)
2032 mntput(mnt); 1872 mntput(mnt);
2033 return err; 1873 return err;
@@ -2035,11 +1875,12 @@ static int do_new_mount(struct path *path, char *type, int flags,
2035 1875
2036int finish_automount(struct vfsmount *m, struct path *path) 1876int finish_automount(struct vfsmount *m, struct path *path)
2037{ 1877{
1878 struct mount *mnt = real_mount(m);
2038 int err; 1879 int err;
2039 /* The new mount record should have at least 2 refs to prevent it being 1880 /* The new mount record should have at least 2 refs to prevent it being
2040 * expired before we get a chance to add it 1881 * expired before we get a chance to add it
2041 */ 1882 */
2042 BUG_ON(mnt_get_count(m) < 2); 1883 BUG_ON(mnt_get_count(mnt) < 2);
2043 1884
2044 if (m->mnt_sb == path->mnt->mnt_sb && 1885 if (m->mnt_sb == path->mnt->mnt_sb &&
2045 m->mnt_root == path->dentry) { 1886 m->mnt_root == path->dentry) {
@@ -2047,15 +1888,15 @@ int finish_automount(struct vfsmount *m, struct path *path)
2047 goto fail; 1888 goto fail;
2048 } 1889 }
2049 1890
2050 err = do_add_mount(m, path, path->mnt->mnt_flags | MNT_SHRINKABLE); 1891 err = do_add_mount(mnt, path, path->mnt->mnt_flags | MNT_SHRINKABLE);
2051 if (!err) 1892 if (!err)
2052 return 0; 1893 return 0;
2053fail: 1894fail:
2054 /* remove m from any expiration list it may be on */ 1895 /* remove m from any expiration list it may be on */
2055 if (!list_empty(&m->mnt_expire)) { 1896 if (!list_empty(&mnt->mnt_expire)) {
2056 down_write(&namespace_sem); 1897 down_write(&namespace_sem);
2057 br_write_lock(vfsmount_lock); 1898 br_write_lock(vfsmount_lock);
2058 list_del_init(&m->mnt_expire); 1899 list_del_init(&mnt->mnt_expire);
2059 br_write_unlock(vfsmount_lock); 1900 br_write_unlock(vfsmount_lock);
2060 up_write(&namespace_sem); 1901 up_write(&namespace_sem);
2061 } 1902 }
@@ -2074,7 +1915,7 @@ void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list)
2074 down_write(&namespace_sem); 1915 down_write(&namespace_sem);
2075 br_write_lock(vfsmount_lock); 1916 br_write_lock(vfsmount_lock);
2076 1917
2077 list_add_tail(&mnt->mnt_expire, expiry_list); 1918 list_add_tail(&real_mount(mnt)->mnt_expire, expiry_list);
2078 1919
2079 br_write_unlock(vfsmount_lock); 1920 br_write_unlock(vfsmount_lock);
2080 up_write(&namespace_sem); 1921 up_write(&namespace_sem);
@@ -2088,7 +1929,7 @@ EXPORT_SYMBOL(mnt_set_expiry);
2088 */ 1929 */
2089void mark_mounts_for_expiry(struct list_head *mounts) 1930void mark_mounts_for_expiry(struct list_head *mounts)
2090{ 1931{
2091 struct vfsmount *mnt, *next; 1932 struct mount *mnt, *next;
2092 LIST_HEAD(graveyard); 1933 LIST_HEAD(graveyard);
2093 LIST_HEAD(umounts); 1934 LIST_HEAD(umounts);
2094 1935
@@ -2111,7 +1952,7 @@ void mark_mounts_for_expiry(struct list_head *mounts)
2111 list_move(&mnt->mnt_expire, &graveyard); 1952 list_move(&mnt->mnt_expire, &graveyard);
2112 } 1953 }
2113 while (!list_empty(&graveyard)) { 1954 while (!list_empty(&graveyard)) {
2114 mnt = list_first_entry(&graveyard, struct vfsmount, mnt_expire); 1955 mnt = list_first_entry(&graveyard, struct mount, mnt_expire);
2115 touch_mnt_namespace(mnt->mnt_ns); 1956 touch_mnt_namespace(mnt->mnt_ns);
2116 umount_tree(mnt, 1, &umounts); 1957 umount_tree(mnt, 1, &umounts);
2117 } 1958 }
@@ -2129,9 +1970,9 @@ EXPORT_SYMBOL_GPL(mark_mounts_for_expiry);
2129 * search the list of submounts for a given mountpoint, and move any 1970 * search the list of submounts for a given mountpoint, and move any
2130 * shrinkable submounts to the 'graveyard' list. 1971 * shrinkable submounts to the 'graveyard' list.
2131 */ 1972 */
2132static int select_submounts(struct vfsmount *parent, struct list_head *graveyard) 1973static int select_submounts(struct mount *parent, struct list_head *graveyard)
2133{ 1974{
2134 struct vfsmount *this_parent = parent; 1975 struct mount *this_parent = parent;
2135 struct list_head *next; 1976 struct list_head *next;
2136 int found = 0; 1977 int found = 0;
2137 1978
@@ -2140,10 +1981,10 @@ repeat:
2140resume: 1981resume:
2141 while (next != &this_parent->mnt_mounts) { 1982 while (next != &this_parent->mnt_mounts) {
2142 struct list_head *tmp = next; 1983 struct list_head *tmp = next;
2143 struct vfsmount *mnt = list_entry(tmp, struct vfsmount, mnt_child); 1984 struct mount *mnt = list_entry(tmp, struct mount, mnt_child);
2144 1985
2145 next = tmp->next; 1986 next = tmp->next;
2146 if (!(mnt->mnt_flags & MNT_SHRINKABLE)) 1987 if (!(mnt->mnt.mnt_flags & MNT_SHRINKABLE))
2147 continue; 1988 continue;
2148 /* 1989 /*
2149 * Descend a level if the d_mounts list is non-empty. 1990 * Descend a level if the d_mounts list is non-empty.
@@ -2175,15 +2016,15 @@ resume:
2175 * 2016 *
2176 * vfsmount_lock must be held for write 2017 * vfsmount_lock must be held for write
2177 */ 2018 */
2178static void shrink_submounts(struct vfsmount *mnt, struct list_head *umounts) 2019static void shrink_submounts(struct mount *mnt, struct list_head *umounts)
2179{ 2020{
2180 LIST_HEAD(graveyard); 2021 LIST_HEAD(graveyard);
2181 struct vfsmount *m; 2022 struct mount *m;
2182 2023
2183 /* extract submounts of 'mountpoint' from the expiration list */ 2024 /* extract submounts of 'mountpoint' from the expiration list */
2184 while (select_submounts(mnt, &graveyard)) { 2025 while (select_submounts(mnt, &graveyard)) {
2185 while (!list_empty(&graveyard)) { 2026 while (!list_empty(&graveyard)) {
2186 m = list_first_entry(&graveyard, struct vfsmount, 2027 m = list_first_entry(&graveyard, struct mount,
2187 mnt_expire); 2028 mnt_expire);
2188 touch_mnt_namespace(m->mnt_ns); 2029 touch_mnt_namespace(m->mnt_ns);
2189 umount_tree(m, 1, umounts); 2030 umount_tree(m, 1, umounts);
@@ -2370,12 +2211,13 @@ static struct mnt_namespace *alloc_mnt_ns(void)
2370 2211
2371void mnt_make_longterm(struct vfsmount *mnt) 2212void mnt_make_longterm(struct vfsmount *mnt)
2372{ 2213{
2373 __mnt_make_longterm(mnt); 2214 __mnt_make_longterm(real_mount(mnt));
2374} 2215}
2375 2216
2376void mnt_make_shortterm(struct vfsmount *mnt) 2217void mnt_make_shortterm(struct vfsmount *m)
2377{ 2218{
2378#ifdef CONFIG_SMP 2219#ifdef CONFIG_SMP
2220 struct mount *mnt = real_mount(m);
2379 if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) 2221 if (atomic_add_unless(&mnt->mnt_longterm, -1, 1))
2380 return; 2222 return;
2381 br_write_lock(vfsmount_lock); 2223 br_write_lock(vfsmount_lock);
@@ -2393,7 +2235,9 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2393{ 2235{
2394 struct mnt_namespace *new_ns; 2236 struct mnt_namespace *new_ns;
2395 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; 2237 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL;
2396 struct vfsmount *p, *q; 2238 struct mount *p, *q;
2239 struct mount *old = mnt_ns->root;
2240 struct mount *new;
2397 2241
2398 new_ns = alloc_mnt_ns(); 2242 new_ns = alloc_mnt_ns();
2399 if (IS_ERR(new_ns)) 2243 if (IS_ERR(new_ns))
@@ -2401,15 +2245,15 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2401 2245
2402 down_write(&namespace_sem); 2246 down_write(&namespace_sem);
2403 /* First pass: copy the tree topology */ 2247 /* First pass: copy the tree topology */
2404 new_ns->root = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root, 2248 new = copy_tree(old, old->mnt.mnt_root, CL_COPY_ALL | CL_EXPIRE);
2405 CL_COPY_ALL | CL_EXPIRE); 2249 if (!new) {
2406 if (!new_ns->root) {
2407 up_write(&namespace_sem); 2250 up_write(&namespace_sem);
2408 kfree(new_ns); 2251 kfree(new_ns);
2409 return ERR_PTR(-ENOMEM); 2252 return ERR_PTR(-ENOMEM);
2410 } 2253 }
2254 new_ns->root = new;
2411 br_write_lock(vfsmount_lock); 2255 br_write_lock(vfsmount_lock);
2412 list_add_tail(&new_ns->list, &new_ns->root->mnt_list); 2256 list_add_tail(&new_ns->list, &new->mnt_list);
2413 br_write_unlock(vfsmount_lock); 2257 br_write_unlock(vfsmount_lock);
2414 2258
2415 /* 2259 /*
@@ -2417,27 +2261,27 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2417 * as belonging to new namespace. We have already acquired a private 2261 * as belonging to new namespace. We have already acquired a private
2418 * fs_struct, so tsk->fs->lock is not needed. 2262 * fs_struct, so tsk->fs->lock is not needed.
2419 */ 2263 */
2420 p = mnt_ns->root; 2264 p = old;
2421 q = new_ns->root; 2265 q = new;
2422 while (p) { 2266 while (p) {
2423 q->mnt_ns = new_ns; 2267 q->mnt_ns = new_ns;
2424 __mnt_make_longterm(q); 2268 __mnt_make_longterm(q);
2425 if (fs) { 2269 if (fs) {
2426 if (p == fs->root.mnt) { 2270 if (&p->mnt == fs->root.mnt) {
2427 fs->root.mnt = mntget(q); 2271 fs->root.mnt = mntget(&q->mnt);
2428 __mnt_make_longterm(q); 2272 __mnt_make_longterm(q);
2429 mnt_make_shortterm(p); 2273 mnt_make_shortterm(&p->mnt);
2430 rootmnt = p; 2274 rootmnt = &p->mnt;
2431 } 2275 }
2432 if (p == fs->pwd.mnt) { 2276 if (&p->mnt == fs->pwd.mnt) {
2433 fs->pwd.mnt = mntget(q); 2277 fs->pwd.mnt = mntget(&q->mnt);
2434 __mnt_make_longterm(q); 2278 __mnt_make_longterm(q);
2435 mnt_make_shortterm(p); 2279 mnt_make_shortterm(&p->mnt);
2436 pwdmnt = p; 2280 pwdmnt = &p->mnt;
2437 } 2281 }
2438 } 2282 }
2439 p = next_mnt(p, mnt_ns->root); 2283 p = next_mnt(p, old);
2440 q = next_mnt(q, new_ns->root); 2284 q = next_mnt(q, new);
2441 } 2285 }
2442 up_write(&namespace_sem); 2286 up_write(&namespace_sem);
2443 2287
@@ -2470,22 +2314,20 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
2470 * create_mnt_ns - creates a private namespace and adds a root filesystem 2314 * create_mnt_ns - creates a private namespace and adds a root filesystem
2471 * @mnt: pointer to the new root filesystem mountpoint 2315 * @mnt: pointer to the new root filesystem mountpoint
2472 */ 2316 */
2473struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) 2317static struct mnt_namespace *create_mnt_ns(struct vfsmount *m)
2474{ 2318{
2475 struct mnt_namespace *new_ns; 2319 struct mnt_namespace *new_ns = alloc_mnt_ns();
2476
2477 new_ns = alloc_mnt_ns();
2478 if (!IS_ERR(new_ns)) { 2320 if (!IS_ERR(new_ns)) {
2321 struct mount *mnt = real_mount(m);
2479 mnt->mnt_ns = new_ns; 2322 mnt->mnt_ns = new_ns;
2480 __mnt_make_longterm(mnt); 2323 __mnt_make_longterm(mnt);
2481 new_ns->root = mnt; 2324 new_ns->root = mnt;
2482 list_add(&new_ns->list, &new_ns->root->mnt_list); 2325 list_add(&new_ns->list, &mnt->mnt_list);
2483 } else { 2326 } else {
2484 mntput(mnt); 2327 mntput(m);
2485 } 2328 }
2486 return new_ns; 2329 return new_ns;
2487} 2330}
2488EXPORT_SYMBOL(create_mnt_ns);
2489 2331
2490struct dentry *mount_subtree(struct vfsmount *mnt, const char *name) 2332struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
2491{ 2333{
@@ -2559,6 +2401,31 @@ out_type:
2559} 2401}
2560 2402
2561/* 2403/*
2404 * Return true if path is reachable from root
2405 *
2406 * namespace_sem or vfsmount_lock is held
2407 */
2408bool is_path_reachable(struct mount *mnt, struct dentry *dentry,
2409 const struct path *root)
2410{
2411 while (&mnt->mnt != root->mnt && mnt_has_parent(mnt)) {
2412 dentry = mnt->mnt_mountpoint;
2413 mnt = mnt->mnt_parent;
2414 }
2415 return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry);
2416}
2417
2418int path_is_under(struct path *path1, struct path *path2)
2419{
2420 int res;
2421 br_read_lock(vfsmount_lock);
2422 res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2);
2423 br_read_unlock(vfsmount_lock);
2424 return res;
2425}
2426EXPORT_SYMBOL(path_is_under);
2427
2428/*
2562 * pivot_root Semantics: 2429 * pivot_root Semantics:
2563 * Moves the root file system of the current process to the directory put_old, 2430 * Moves the root file system of the current process to the directory put_old,
2564 * makes new_root as the new root file system of the current process, and sets 2431 * makes new_root as the new root file system of the current process, and sets
@@ -2586,8 +2453,8 @@ out_type:
2586SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, 2453SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2587 const char __user *, put_old) 2454 const char __user *, put_old)
2588{ 2455{
2589 struct vfsmount *tmp;
2590 struct path new, old, parent_path, root_parent, root; 2456 struct path new, old, parent_path, root_parent, root;
2457 struct mount *new_mnt, *root_mnt;
2591 int error; 2458 int error;
2592 2459
2593 if (!capable(CAP_SYS_ADMIN)) 2460 if (!capable(CAP_SYS_ADMIN))
@@ -2611,11 +2478,13 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2611 goto out3; 2478 goto out3;
2612 2479
2613 error = -EINVAL; 2480 error = -EINVAL;
2614 if (IS_MNT_SHARED(old.mnt) || 2481 new_mnt = real_mount(new.mnt);
2615 IS_MNT_SHARED(new.mnt->mnt_parent) || 2482 root_mnt = real_mount(root.mnt);
2616 IS_MNT_SHARED(root.mnt->mnt_parent)) 2483 if (IS_MNT_SHARED(real_mount(old.mnt)) ||
2484 IS_MNT_SHARED(new_mnt->mnt_parent) ||
2485 IS_MNT_SHARED(root_mnt->mnt_parent))
2617 goto out4; 2486 goto out4;
2618 if (!check_mnt(root.mnt) || !check_mnt(new.mnt)) 2487 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
2619 goto out4; 2488 goto out4;
2620 error = -ENOENT; 2489 error = -ENOENT;
2621 if (d_unlinked(new.dentry)) 2490 if (d_unlinked(new.dentry))
@@ -2629,33 +2498,22 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2629 error = -EINVAL; 2498 error = -EINVAL;
2630 if (root.mnt->mnt_root != root.dentry) 2499 if (root.mnt->mnt_root != root.dentry)
2631 goto out4; /* not a mountpoint */ 2500 goto out4; /* not a mountpoint */
2632 if (root.mnt->mnt_parent == root.mnt) 2501 if (!mnt_has_parent(root_mnt))
2633 goto out4; /* not attached */ 2502 goto out4; /* not attached */
2634 if (new.mnt->mnt_root != new.dentry) 2503 if (new.mnt->mnt_root != new.dentry)
2635 goto out4; /* not a mountpoint */ 2504 goto out4; /* not a mountpoint */
2636 if (new.mnt->mnt_parent == new.mnt) 2505 if (!mnt_has_parent(new_mnt))
2637 goto out4; /* not attached */ 2506 goto out4; /* not attached */
2638 /* make sure we can reach put_old from new_root */ 2507 /* make sure we can reach put_old from new_root */
2639 tmp = old.mnt; 2508 if (!is_path_reachable(real_mount(old.mnt), old.dentry, &new))
2640 if (tmp != new.mnt) {
2641 for (;;) {
2642 if (tmp->mnt_parent == tmp)
2643 goto out4; /* already mounted on put_old */
2644 if (tmp->mnt_parent == new.mnt)
2645 break;
2646 tmp = tmp->mnt_parent;
2647 }
2648 if (!is_subdir(tmp->mnt_mountpoint, new.dentry))
2649 goto out4;
2650 } else if (!is_subdir(old.dentry, new.dentry))
2651 goto out4; 2509 goto out4;
2652 br_write_lock(vfsmount_lock); 2510 br_write_lock(vfsmount_lock);
2653 detach_mnt(new.mnt, &parent_path); 2511 detach_mnt(new_mnt, &parent_path);
2654 detach_mnt(root.mnt, &root_parent); 2512 detach_mnt(root_mnt, &root_parent);
2655 /* mount old root on put_old */ 2513 /* mount old root on put_old */
2656 attach_mnt(root.mnt, &old); 2514 attach_mnt(root_mnt, &old);
2657 /* mount new_root on / */ 2515 /* mount new_root on / */
2658 attach_mnt(new.mnt, &root_parent); 2516 attach_mnt(new_mnt, &root_parent);
2659 touch_mnt_namespace(current->nsproxy->mnt_ns); 2517 touch_mnt_namespace(current->nsproxy->mnt_ns);
2660 br_write_unlock(vfsmount_lock); 2518 br_write_unlock(vfsmount_lock);
2661 chroot_fs_refs(&root, &new); 2519 chroot_fs_refs(&root, &new);
@@ -2693,8 +2551,8 @@ static void __init init_mount_tree(void)
2693 init_task.nsproxy->mnt_ns = ns; 2551 init_task.nsproxy->mnt_ns = ns;
2694 get_mnt_ns(ns); 2552 get_mnt_ns(ns);
2695 2553
2696 root.mnt = ns->root; 2554 root.mnt = mnt;
2697 root.dentry = ns->root->mnt_root; 2555 root.dentry = mnt->mnt_root;
2698 2556
2699 set_fs_pwd(current->fs, &root); 2557 set_fs_pwd(current->fs, &root);
2700 set_fs_root(current->fs, &root); 2558 set_fs_root(current->fs, &root);
@@ -2707,7 +2565,7 @@ void __init mnt_init(void)
2707 2565
2708 init_rwsem(&namespace_sem); 2566 init_rwsem(&namespace_sem);
2709 2567
2710 mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct vfsmount), 2568 mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),
2711 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL); 2569 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
2712 2570
2713 mount_hashtable = (struct list_head *)__get_free_page(GFP_ATOMIC); 2571 mount_hashtable = (struct list_head *)__get_free_page(GFP_ATOMIC);
@@ -2747,7 +2605,6 @@ void put_mnt_ns(struct mnt_namespace *ns)
2747 release_mounts(&umount_list); 2605 release_mounts(&umount_list);
2748 kfree(ns); 2606 kfree(ns);
2749} 2607}
2750EXPORT_SYMBOL(put_mnt_ns);
2751 2608
2752struct vfsmount *kern_mount_data(struct file_system_type *type, void *data) 2609struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
2753{ 2610{
@@ -2776,5 +2633,5 @@ EXPORT_SYMBOL(kern_unmount);
2776 2633
2777bool our_mnt(struct vfsmount *mnt) 2634bool our_mnt(struct vfsmount *mnt)
2778{ 2635{
2779 return check_mnt(mnt); 2636 return check_mnt(real_mount(mnt));
2780} 2637}
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 9c51f621e901..aeed93a6bde0 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -30,15 +30,15 @@ static void ncp_do_readdir(struct file *, void *, filldir_t,
30 30
31static int ncp_readdir(struct file *, void *, filldir_t); 31static int ncp_readdir(struct file *, void *, filldir_t);
32 32
33static int ncp_create(struct inode *, struct dentry *, int, struct nameidata *); 33static int ncp_create(struct inode *, struct dentry *, umode_t, struct nameidata *);
34static struct dentry *ncp_lookup(struct inode *, struct dentry *, struct nameidata *); 34static struct dentry *ncp_lookup(struct inode *, struct dentry *, struct nameidata *);
35static int ncp_unlink(struct inode *, struct dentry *); 35static int ncp_unlink(struct inode *, struct dentry *);
36static int ncp_mkdir(struct inode *, struct dentry *, int); 36static int ncp_mkdir(struct inode *, struct dentry *, umode_t);
37static int ncp_rmdir(struct inode *, struct dentry *); 37static int ncp_rmdir(struct inode *, struct dentry *);
38static int ncp_rename(struct inode *, struct dentry *, 38static int ncp_rename(struct inode *, struct dentry *,
39 struct inode *, struct dentry *); 39 struct inode *, struct dentry *);
40static int ncp_mknod(struct inode * dir, struct dentry *dentry, 40static int ncp_mknod(struct inode * dir, struct dentry *dentry,
41 int mode, dev_t rdev); 41 umode_t mode, dev_t rdev);
42#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS) 42#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
43extern int ncp_symlink(struct inode *, struct dentry *, const char *); 43extern int ncp_symlink(struct inode *, struct dentry *, const char *);
44#else 44#else
@@ -919,7 +919,7 @@ out_close:
919 goto out; 919 goto out;
920} 920}
921 921
922int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode, 922int ncp_create_new(struct inode *dir, struct dentry *dentry, umode_t mode,
923 dev_t rdev, __le32 attributes) 923 dev_t rdev, __le32 attributes)
924{ 924{
925 struct ncp_server *server = NCP_SERVER(dir); 925 struct ncp_server *server = NCP_SERVER(dir);
@@ -928,7 +928,7 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode,
928 int opmode; 928 int opmode;
929 __u8 __name[NCP_MAXPATHLEN + 1]; 929 __u8 __name[NCP_MAXPATHLEN + 1];
930 930
931 PPRINTK("ncp_create_new: creating %s/%s, mode=%x\n", 931 PPRINTK("ncp_create_new: creating %s/%s, mode=%hx\n",
932 dentry->d_parent->d_name.name, dentry->d_name.name, mode); 932 dentry->d_parent->d_name.name, dentry->d_name.name, mode);
933 933
934 ncp_age_dentry(server, dentry); 934 ncp_age_dentry(server, dentry);
@@ -979,13 +979,13 @@ out:
979 return error; 979 return error;
980} 980}
981 981
982static int ncp_create(struct inode *dir, struct dentry *dentry, int mode, 982static int ncp_create(struct inode *dir, struct dentry *dentry, umode_t mode,
983 struct nameidata *nd) 983 struct nameidata *nd)
984{ 984{
985 return ncp_create_new(dir, dentry, mode, 0, 0); 985 return ncp_create_new(dir, dentry, mode, 0, 0);
986} 986}
987 987
988static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode) 988static int ncp_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
989{ 989{
990 struct ncp_entry_info finfo; 990 struct ncp_entry_info finfo;
991 struct ncp_server *server = NCP_SERVER(dir); 991 struct ncp_server *server = NCP_SERVER(dir);
@@ -1201,12 +1201,12 @@ out:
1201} 1201}
1202 1202
1203static int ncp_mknod(struct inode * dir, struct dentry *dentry, 1203static int ncp_mknod(struct inode * dir, struct dentry *dentry,
1204 int mode, dev_t rdev) 1204 umode_t mode, dev_t rdev)
1205{ 1205{
1206 if (!new_valid_dev(rdev)) 1206 if (!new_valid_dev(rdev))
1207 return -EINVAL; 1207 return -EINVAL;
1208 if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber)) { 1208 if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber)) {
1209 DPRINTK(KERN_DEBUG "ncp_mknod: mode = 0%o\n", mode); 1209 DPRINTK(KERN_DEBUG "ncp_mknod: mode = 0%ho\n", mode);
1210 return ncp_create_new(dir, dentry, mode, rdev, 0); 1210 return ncp_create_new(dir, dentry, mode, rdev, 0);
1211 } 1211 }
1212 return -EPERM; /* Strange, but true */ 1212 return -EPERM; /* Strange, but true */
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index cbd1a61c110a..3d1e34f8a68e 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -44,7 +44,7 @@
44static void ncp_evict_inode(struct inode *); 44static void ncp_evict_inode(struct inode *);
45static void ncp_put_super(struct super_block *); 45static void ncp_put_super(struct super_block *);
46static int ncp_statfs(struct dentry *, struct kstatfs *); 46static int ncp_statfs(struct dentry *, struct kstatfs *);
47static int ncp_show_options(struct seq_file *, struct vfsmount *); 47static int ncp_show_options(struct seq_file *, struct dentry *);
48 48
49static struct kmem_cache * ncp_inode_cachep; 49static struct kmem_cache * ncp_inode_cachep;
50 50
@@ -60,7 +60,6 @@ static struct inode *ncp_alloc_inode(struct super_block *sb)
60static void ncp_i_callback(struct rcu_head *head) 60static void ncp_i_callback(struct rcu_head *head)
61{ 61{
62 struct inode *inode = container_of(head, struct inode, i_rcu); 62 struct inode *inode = container_of(head, struct inode, i_rcu);
63 INIT_LIST_HEAD(&inode->i_dentry);
64 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); 63 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode));
65} 64}
66 65
@@ -323,9 +322,9 @@ static void ncp_stop_tasks(struct ncp_server *server) {
323 flush_work_sync(&server->timeout_tq); 322 flush_work_sync(&server->timeout_tq);
324} 323}
325 324
326static int ncp_show_options(struct seq_file *seq, struct vfsmount *mnt) 325static int ncp_show_options(struct seq_file *seq, struct dentry *root)
327{ 326{
328 struct ncp_server *server = NCP_SBP(mnt->mnt_sb); 327 struct ncp_server *server = NCP_SBP(root->d_sb);
329 unsigned int tmp; 328 unsigned int tmp;
330 329
331 if (server->m.uid != 0) 330 if (server->m.uid != 0)
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index 790e92a9ec63..6958adfaff08 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -901,7 +901,7 @@ long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
901 ret = __ncp_ioctl(inode, cmd, arg); 901 ret = __ncp_ioctl(inode, cmd, arg);
902outDropWrite: 902outDropWrite:
903 if (need_drop_write) 903 if (need_drop_write)
904 mnt_drop_write(filp->f_path.mnt); 904 mnt_drop_write_file(filp);
905out: 905out:
906 return ret; 906 return ret;
907} 907}
diff --git a/fs/ncpfs/ncplib_kernel.h b/fs/ncpfs/ncplib_kernel.h
index 09881e6aa5ad..32c06587351a 100644
--- a/fs/ncpfs/ncplib_kernel.h
+++ b/fs/ncpfs/ncplib_kernel.h
@@ -114,7 +114,7 @@ int ncp_dirhandle_alloc(struct ncp_server *, __u8 vol, __le32 dirent, __u8 *dirh
114int ncp_dirhandle_free(struct ncp_server *, __u8 dirhandle); 114int ncp_dirhandle_free(struct ncp_server *, __u8 dirhandle);
115 115
116int ncp_create_new(struct inode *dir, struct dentry *dentry, 116int ncp_create_new(struct inode *dir, struct dentry *dentry,
117 int mode, dev_t rdev, __le32 attributes); 117 umode_t mode, dev_t rdev, __le32 attributes);
118 118
119static inline int ncp_is_nfs_extras(struct ncp_server* server, unsigned int volnum) { 119static inline int ncp_is_nfs_extras(struct ncp_server* server, unsigned int volnum) {
120#ifdef CONFIG_NCPFS_NFS_NS 120#ifdef CONFIG_NCPFS_NFS_NS
diff --git a/fs/ncpfs/symlink.c b/fs/ncpfs/symlink.c
index 661f861d80c6..52439ddc8de0 100644
--- a/fs/ncpfs/symlink.c
+++ b/fs/ncpfs/symlink.c
@@ -108,7 +108,7 @@ int ncp_symlink(struct inode *dir, struct dentry *dentry, const char *symname) {
108 char *rawlink; 108 char *rawlink;
109 int length, err, i, outlen; 109 int length, err, i, outlen;
110 int kludge; 110 int kludge;
111 int mode; 111 umode_t mode;
112 __le32 attr; 112 __le32 attr;
113 unsigned int hdr; 113 unsigned int hdr;
114 114
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ac2899098147..fd9a872fada0 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -47,13 +47,13 @@ static int nfs_opendir(struct inode *, struct file *);
47static int nfs_closedir(struct inode *, struct file *); 47static int nfs_closedir(struct inode *, struct file *);
48static int nfs_readdir(struct file *, void *, filldir_t); 48static int nfs_readdir(struct file *, void *, filldir_t);
49static struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *); 49static struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *);
50static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *); 50static int nfs_create(struct inode *, struct dentry *, umode_t, struct nameidata *);
51static int nfs_mkdir(struct inode *, struct dentry *, int); 51static int nfs_mkdir(struct inode *, struct dentry *, umode_t);
52static int nfs_rmdir(struct inode *, struct dentry *); 52static int nfs_rmdir(struct inode *, struct dentry *);
53static int nfs_unlink(struct inode *, struct dentry *); 53static int nfs_unlink(struct inode *, struct dentry *);
54static int nfs_symlink(struct inode *, struct dentry *, const char *); 54static int nfs_symlink(struct inode *, struct dentry *, const char *);
55static int nfs_link(struct dentry *, struct inode *, struct dentry *); 55static int nfs_link(struct dentry *, struct inode *, struct dentry *);
56static int nfs_mknod(struct inode *, struct dentry *, int, dev_t); 56static int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
57static int nfs_rename(struct inode *, struct dentry *, 57static int nfs_rename(struct inode *, struct dentry *,
58 struct inode *, struct dentry *); 58 struct inode *, struct dentry *);
59static int nfs_fsync_dir(struct file *, loff_t, loff_t, int); 59static int nfs_fsync_dir(struct file *, loff_t, loff_t, int);
@@ -112,7 +112,7 @@ const struct inode_operations nfs3_dir_inode_operations = {
112#ifdef CONFIG_NFS_V4 112#ifdef CONFIG_NFS_V4
113 113
114static struct dentry *nfs_atomic_lookup(struct inode *, struct dentry *, struct nameidata *); 114static struct dentry *nfs_atomic_lookup(struct inode *, struct dentry *, struct nameidata *);
115static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd); 115static int nfs_open_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd);
116const struct inode_operations nfs4_dir_inode_operations = { 116const struct inode_operations nfs4_dir_inode_operations = {
117 .create = nfs_open_create, 117 .create = nfs_open_create,
118 .lookup = nfs_atomic_lookup, 118 .lookup = nfs_atomic_lookup,
@@ -1368,18 +1368,7 @@ static fmode_t flags_to_mode(int flags)
1368 1368
1369static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags) 1369static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags)
1370{ 1370{
1371 struct nfs_open_context *ctx; 1371 return alloc_nfs_open_context(dentry, flags_to_mode(open_flags));
1372 struct rpc_cred *cred;
1373 fmode_t fmode = flags_to_mode(open_flags);
1374
1375 cred = rpc_lookup_cred();
1376 if (IS_ERR(cred))
1377 return ERR_CAST(cred);
1378 ctx = alloc_nfs_open_context(dentry, cred, fmode);
1379 put_rpccred(cred);
1380 if (ctx == NULL)
1381 return ERR_PTR(-ENOMEM);
1382 return ctx;
1383} 1372}
1384 1373
1385static int do_open(struct inode *inode, struct file *filp) 1374static int do_open(struct inode *inode, struct file *filp)
@@ -1584,8 +1573,8 @@ no_open:
1584 return nfs_lookup_revalidate(dentry, nd); 1573 return nfs_lookup_revalidate(dentry, nd);
1585} 1574}
1586 1575
1587static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode, 1576static int nfs_open_create(struct inode *dir, struct dentry *dentry,
1588 struct nameidata *nd) 1577 umode_t mode, struct nameidata *nd)
1589{ 1578{
1590 struct nfs_open_context *ctx = NULL; 1579 struct nfs_open_context *ctx = NULL;
1591 struct iattr attr; 1580 struct iattr attr;
@@ -1675,8 +1664,8 @@ out_error:
1675 * that the operation succeeded on the server, but an error in the 1664 * that the operation succeeded on the server, but an error in the
1676 * reply path made it appear to have failed. 1665 * reply path made it appear to have failed.
1677 */ 1666 */
1678static int nfs_create(struct inode *dir, struct dentry *dentry, int mode, 1667static int nfs_create(struct inode *dir, struct dentry *dentry,
1679 struct nameidata *nd) 1668 umode_t mode, struct nameidata *nd)
1680{ 1669{
1681 struct iattr attr; 1670 struct iattr attr;
1682 int error; 1671 int error;
@@ -1704,7 +1693,7 @@ out_err:
1704 * See comments for nfs_proc_create regarding failed operations. 1693 * See comments for nfs_proc_create regarding failed operations.
1705 */ 1694 */
1706static int 1695static int
1707nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) 1696nfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev)
1708{ 1697{
1709 struct iattr attr; 1698 struct iattr attr;
1710 int status; 1699 int status;
@@ -1730,7 +1719,7 @@ out_err:
1730/* 1719/*
1731 * See comments for nfs_proc_create regarding failed operations. 1720 * See comments for nfs_proc_create regarding failed operations.
1732 */ 1721 */
1733static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 1722static int nfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1734{ 1723{
1735 struct iattr attr; 1724 struct iattr attr;
1736 int error; 1725 int error;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 50a15fa8cf98..6f00086e340f 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -629,23 +629,28 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
629 nfs_revalidate_inode(server, inode); 629 nfs_revalidate_inode(server, inode);
630} 630}
631 631
632struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode) 632struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode)
633{ 633{
634 struct nfs_open_context *ctx; 634 struct nfs_open_context *ctx;
635 struct rpc_cred *cred = rpc_lookup_cred();
636 if (IS_ERR(cred))
637 return ERR_CAST(cred);
635 638
636 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 639 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
637 if (ctx != NULL) { 640 if (!ctx) {
638 nfs_sb_active(dentry->d_sb); 641 put_rpccred(cred);
639 ctx->dentry = dget(dentry); 642 return ERR_PTR(-ENOMEM);
640 ctx->cred = get_rpccred(cred);
641 ctx->state = NULL;
642 ctx->mode = f_mode;
643 ctx->flags = 0;
644 ctx->error = 0;
645 nfs_init_lock_context(&ctx->lock_context);
646 ctx->lock_context.open_context = ctx;
647 INIT_LIST_HEAD(&ctx->list);
648 } 643 }
644 nfs_sb_active(dentry->d_sb);
645 ctx->dentry = dget(dentry);
646 ctx->cred = cred;
647 ctx->state = NULL;
648 ctx->mode = f_mode;
649 ctx->flags = 0;
650 ctx->error = 0;
651 nfs_init_lock_context(&ctx->lock_context);
652 ctx->lock_context.open_context = ctx;
653 INIT_LIST_HEAD(&ctx->list);
649 return ctx; 654 return ctx;
650} 655}
651 656
@@ -738,15 +743,10 @@ static void nfs_file_clear_open_context(struct file *filp)
738int nfs_open(struct inode *inode, struct file *filp) 743int nfs_open(struct inode *inode, struct file *filp)
739{ 744{
740 struct nfs_open_context *ctx; 745 struct nfs_open_context *ctx;
741 struct rpc_cred *cred;
742 746
743 cred = rpc_lookup_cred(); 747 ctx = alloc_nfs_open_context(filp->f_path.dentry, filp->f_mode);
744 if (IS_ERR(cred)) 748 if (IS_ERR(ctx))
745 return PTR_ERR(cred); 749 return PTR_ERR(ctx);
746 ctx = alloc_nfs_open_context(filp->f_path.dentry, cred, filp->f_mode);
747 put_rpccred(cred);
748 if (ctx == NULL)
749 return -ENOMEM;
750 nfs_file_set_open_context(filp, ctx); 750 nfs_file_set_open_context(filp, ctx);
751 put_nfs_open_context(ctx); 751 put_nfs_open_context(ctx);
752 nfs_fscache_set_inode_cookie(inode, filp); 752 nfs_fscache_set_inode_cookie(inode, filp);
@@ -1464,7 +1464,6 @@ struct inode *nfs_alloc_inode(struct super_block *sb)
1464static void nfs_i_callback(struct rcu_head *head) 1464static void nfs_i_callback(struct rcu_head *head)
1465{ 1465{
1466 struct inode *inode = container_of(head, struct inode, i_rcu); 1466 struct inode *inode = container_of(head, struct inode, i_rcu);
1467 INIT_LIST_HEAD(&inode->i_dentry);
1468 kmem_cache_free(nfs_inode_cachep, NFS_I(inode)); 1467 kmem_cache_free(nfs_inode_cachep, NFS_I(inode));
1469} 1468}
1470 1469
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 134777406ee3..e463967aafb8 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -41,7 +41,6 @@
41#include <linux/lockd/bind.h> 41#include <linux/lockd/bind.h>
42#include <linux/seq_file.h> 42#include <linux/seq_file.h>
43#include <linux/mount.h> 43#include <linux/mount.h>
44#include <linux/mnt_namespace.h>
45#include <linux/namei.h> 44#include <linux/namei.h>
46#include <linux/nfs_idmap.h> 45#include <linux/nfs_idmap.h>
47#include <linux/vfs.h> 46#include <linux/vfs.h>
@@ -263,10 +262,10 @@ static match_table_t nfs_local_lock_tokens = {
263 262
264static void nfs_umount_begin(struct super_block *); 263static void nfs_umount_begin(struct super_block *);
265static int nfs_statfs(struct dentry *, struct kstatfs *); 264static int nfs_statfs(struct dentry *, struct kstatfs *);
266static int nfs_show_options(struct seq_file *, struct vfsmount *); 265static int nfs_show_options(struct seq_file *, struct dentry *);
267static int nfs_show_devname(struct seq_file *, struct vfsmount *); 266static int nfs_show_devname(struct seq_file *, struct dentry *);
268static int nfs_show_path(struct seq_file *, struct vfsmount *); 267static int nfs_show_path(struct seq_file *, struct dentry *);
269static int nfs_show_stats(struct seq_file *, struct vfsmount *); 268static int nfs_show_stats(struct seq_file *, struct dentry *);
270static struct dentry *nfs_fs_mount(struct file_system_type *, 269static struct dentry *nfs_fs_mount(struct file_system_type *,
271 int, const char *, void *); 270 int, const char *, void *);
272static struct dentry *nfs_xdev_mount(struct file_system_type *fs_type, 271static struct dentry *nfs_xdev_mount(struct file_system_type *fs_type,
@@ -721,9 +720,9 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
721/* 720/*
722 * Describe the mount options on this VFS mountpoint 721 * Describe the mount options on this VFS mountpoint
723 */ 722 */
724static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt) 723static int nfs_show_options(struct seq_file *m, struct dentry *root)
725{ 724{
726 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); 725 struct nfs_server *nfss = NFS_SB(root->d_sb);
727 726
728 nfs_show_mount_options(m, nfss, 0); 727 nfs_show_mount_options(m, nfss, 0);
729 728
@@ -761,14 +760,14 @@ static void show_pnfs(struct seq_file *m, struct nfs_server *server) {}
761#endif 760#endif
762#endif 761#endif
763 762
764static int nfs_show_devname(struct seq_file *m, struct vfsmount *mnt) 763static int nfs_show_devname(struct seq_file *m, struct dentry *root)
765{ 764{
766 char *page = (char *) __get_free_page(GFP_KERNEL); 765 char *page = (char *) __get_free_page(GFP_KERNEL);
767 char *devname, *dummy; 766 char *devname, *dummy;
768 int err = 0; 767 int err = 0;
769 if (!page) 768 if (!page)
770 return -ENOMEM; 769 return -ENOMEM;
771 devname = nfs_path(&dummy, mnt->mnt_root, page, PAGE_SIZE); 770 devname = nfs_path(&dummy, root, page, PAGE_SIZE);
772 if (IS_ERR(devname)) 771 if (IS_ERR(devname))
773 err = PTR_ERR(devname); 772 err = PTR_ERR(devname);
774 else 773 else
@@ -777,7 +776,7 @@ static int nfs_show_devname(struct seq_file *m, struct vfsmount *mnt)
777 return err; 776 return err;
778} 777}
779 778
780static int nfs_show_path(struct seq_file *m, struct vfsmount *mnt) 779static int nfs_show_path(struct seq_file *m, struct dentry *dentry)
781{ 780{
782 seq_puts(m, "/"); 781 seq_puts(m, "/");
783 return 0; 782 return 0;
@@ -786,10 +785,10 @@ static int nfs_show_path(struct seq_file *m, struct vfsmount *mnt)
786/* 785/*
787 * Present statistical information for this VFS mountpoint 786 * Present statistical information for this VFS mountpoint
788 */ 787 */
789static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) 788static int nfs_show_stats(struct seq_file *m, struct dentry *root)
790{ 789{
791 int i, cpu; 790 int i, cpu;
792 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); 791 struct nfs_server *nfss = NFS_SB(root->d_sb);
793 struct rpc_auth *auth = nfss->client->cl_auth; 792 struct rpc_auth *auth = nfss->client->cl_auth;
794 struct nfs_iostats totals = { }; 793 struct nfs_iostats totals = { };
795 794
@@ -799,10 +798,10 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
799 * Display all mount option settings 798 * Display all mount option settings
800 */ 799 */
801 seq_printf(m, "\n\topts:\t"); 800 seq_printf(m, "\n\topts:\t");
802 seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw"); 801 seq_puts(m, root->d_sb->s_flags & MS_RDONLY ? "ro" : "rw");
803 seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : ""); 802 seq_puts(m, root->d_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : "");
804 seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : ""); 803 seq_puts(m, root->d_sb->s_flags & MS_NOATIME ? ",noatime" : "");
805 seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : ""); 804 seq_puts(m, root->d_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : "");
806 nfs_show_mount_options(m, nfss, 1); 805 nfs_show_mount_options(m, nfss, 1);
807 806
808 seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ); 807 seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ);
@@ -2788,11 +2787,15 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
2788 const char *export_path) 2787 const char *export_path)
2789{ 2788{
2790 struct dentry *dentry; 2789 struct dentry *dentry;
2791 int ret = nfs_referral_loop_protect(); 2790 int err;
2792 2791
2793 if (ret) { 2792 if (IS_ERR(root_mnt))
2793 return ERR_CAST(root_mnt);
2794
2795 err = nfs_referral_loop_protect();
2796 if (err) {
2794 mntput(root_mnt); 2797 mntput(root_mnt);
2795 return ERR_PTR(ret); 2798 return ERR_PTR(err);
2796 } 2799 }
2797 2800
2798 dentry = mount_subtree(root_mnt, export_path); 2801 dentry = mount_subtree(root_mnt, export_path);
@@ -2816,9 +2819,7 @@ static struct dentry *nfs4_try_mount(int flags, const char *dev_name,
2816 data->nfs_server.hostname); 2819 data->nfs_server.hostname);
2817 data->nfs_server.export_path = export_path; 2820 data->nfs_server.export_path = export_path;
2818 2821
2819 res = ERR_CAST(root_mnt); 2822 res = nfs_follow_remote_path(root_mnt, export_path);
2820 if (!IS_ERR(root_mnt))
2821 res = nfs_follow_remote_path(root_mnt, export_path);
2822 2823
2823 dfprintk(MOUNT, "<-- nfs4_try_mount() = %ld%s\n", 2824 dfprintk(MOUNT, "<-- nfs4_try_mount() = %ld%s\n",
2824 IS_ERR(res) ? PTR_ERR(res) : 0, 2825 IS_ERR(res) ? PTR_ERR(res) : 0,
@@ -3079,9 +3080,7 @@ static struct dentry *nfs4_referral_mount(struct file_system_type *fs_type,
3079 flags, data, data->hostname); 3080 flags, data, data->hostname);
3080 data->mnt_path = export_path; 3081 data->mnt_path = export_path;
3081 3082
3082 res = ERR_CAST(root_mnt); 3083 res = nfs_follow_remote_path(root_mnt, export_path);
3083 if (!IS_ERR(root_mnt))
3084 res = nfs_follow_remote_path(root_mnt, export_path);
3085 dprintk("<-- nfs4_referral_mount() = %ld%s\n", 3084 dprintk("<-- nfs4_referral_mount() = %ld%s\n",
3086 IS_ERR(res) ? PTR_ERR(res) : 0, 3085 IS_ERR(res) ? PTR_ERR(res) : 0,
3087 IS_ERR(res) ? " [error]" : ""); 3086 IS_ERR(res) ? " [error]" : "");
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index fa383361bc61..c5e28ed8bca0 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -838,7 +838,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
838 return status; 838 return status;
839 } 839 }
840 } 840 }
841 status = mnt_want_write(cstate->current_fh.fh_export->ex_path.mnt); 841 status = fh_want_write(&cstate->current_fh);
842 if (status) 842 if (status)
843 return status; 843 return status;
844 status = nfs_ok; 844 status = nfs_ok;
@@ -856,7 +856,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
856 status = nfsd_setattr(rqstp, &cstate->current_fh, &setattr->sa_iattr, 856 status = nfsd_setattr(rqstp, &cstate->current_fh, &setattr->sa_iattr,
857 0, (time_t)0); 857 0, (time_t)0);
858out: 858out:
859 mnt_drop_write(cstate->current_fh.fh_export->ex_path.mnt); 859 fh_drop_write(&cstate->current_fh);
860 return status; 860 return status;
861} 861}
862 862
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index ed083b9a731b..80a0be9ed008 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -147,11 +147,11 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
147 status = -EEXIST; 147 status = -EEXIST;
148 if (dentry->d_inode) 148 if (dentry->d_inode)
149 goto out_put; 149 goto out_put;
150 status = mnt_want_write(rec_file->f_path.mnt); 150 status = mnt_want_write_file(rec_file);
151 if (status) 151 if (status)
152 goto out_put; 152 goto out_put;
153 status = vfs_mkdir(dir->d_inode, dentry, S_IRWXU); 153 status = vfs_mkdir(dir->d_inode, dentry, S_IRWXU);
154 mnt_drop_write(rec_file->f_path.mnt); 154 mnt_drop_write_file(rec_file);
155out_put: 155out_put:
156 dput(dentry); 156 dput(dentry);
157out_unlock: 157out_unlock:
@@ -268,7 +268,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
268 if (!rec_file || !clp->cl_firststate) 268 if (!rec_file || !clp->cl_firststate)
269 return; 269 return;
270 270
271 status = mnt_want_write(rec_file->f_path.mnt); 271 status = mnt_want_write_file(rec_file);
272 if (status) 272 if (status)
273 goto out; 273 goto out;
274 clp->cl_firststate = 0; 274 clp->cl_firststate = 0;
@@ -281,7 +281,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
281 nfs4_reset_creds(original_cred); 281 nfs4_reset_creds(original_cred);
282 if (status == 0) 282 if (status == 0)
283 vfs_fsync(rec_file, 0); 283 vfs_fsync(rec_file, 0);
284 mnt_drop_write(rec_file->f_path.mnt); 284 mnt_drop_write_file(rec_file);
285out: 285out:
286 if (status) 286 if (status)
287 printk("NFSD: Failed to remove expired client state directory" 287 printk("NFSD: Failed to remove expired client state directory"
@@ -311,13 +311,13 @@ nfsd4_recdir_purge_old(void) {
311 311
312 if (!rec_file) 312 if (!rec_file)
313 return; 313 return;
314 status = mnt_want_write(rec_file->f_path.mnt); 314 status = mnt_want_write_file(rec_file);
315 if (status) 315 if (status)
316 goto out; 316 goto out;
317 status = nfsd4_list_rec_dir(purge_old); 317 status = nfsd4_list_rec_dir(purge_old);
318 if (status == 0) 318 if (status == 0)
319 vfs_fsync(rec_file, 0); 319 vfs_fsync(rec_file, 0);
320 mnt_drop_write(rec_file->f_path.mnt); 320 mnt_drop_write_file(rec_file);
321out: 321out:
322 if (status) 322 if (status)
323 printk("nfsd4: failed to purge old clients from recovery" 323 printk("nfsd4: failed to purge old clients from recovery"
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index c45a2ea4a090..bb4a11d58a5a 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -272,7 +272,7 @@ static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size)
272 * 2. Is that directory a mount point, or 272 * 2. Is that directory a mount point, or
273 * 3. Is that directory the root of an exported file system? 273 * 3. Is that directory the root of an exported file system?
274 */ 274 */
275 error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb); 275 error = nlmsvc_unlock_all_by_sb(path.dentry->d_sb);
276 276
277 path_put(&path); 277 path_put(&path);
278 return error; 278 return error;
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index c763de5c1157..68454e75fce9 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -59,7 +59,7 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry)
59 * the write call). 59 * the write call).
60 */ 60 */
61static inline __be32 61static inline __be32
62nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int requested) 62nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, umode_t requested)
63{ 63{
64 mode &= S_IFMT; 64 mode &= S_IFMT;
65 65
@@ -293,7 +293,7 @@ out:
293 * include/linux/nfsd/nfsd.h. 293 * include/linux/nfsd/nfsd.h.
294 */ 294 */
295__be32 295__be32
296fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) 296fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
297{ 297{
298 struct svc_export *exp; 298 struct svc_export *exp;
299 struct dentry *dentry; 299 struct dentry *dentry;
diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h
index c16f8d8331b5..e5e6707ba687 100644
--- a/fs/nfsd/nfsfh.h
+++ b/fs/nfsd/nfsfh.h
@@ -102,7 +102,7 @@ extern char * SVCFH_fmt(struct svc_fh *fhp);
102/* 102/*
103 * Function prototypes 103 * Function prototypes
104 */ 104 */
105__be32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int); 105__be32 fh_verify(struct svc_rqst *, struct svc_fh *, umode_t, int);
106__be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *); 106__be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
107__be32 fh_update(struct svc_fh *); 107__be32 fh_update(struct svc_fh *);
108void fh_put(struct svc_fh *); 108void fh_put(struct svc_fh *);
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 7a2e442623c8..d25a723b68ad 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -307,7 +307,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
307 struct dentry *dentry; 307 struct dentry *dentry;
308 struct inode *inode; 308 struct inode *inode;
309 int accmode = NFSD_MAY_SATTR; 309 int accmode = NFSD_MAY_SATTR;
310 int ftype = 0; 310 umode_t ftype = 0;
311 __be32 err; 311 __be32 err;
312 int host_err; 312 int host_err;
313 int size_change = 0; 313 int size_change = 0;
@@ -730,7 +730,7 @@ static int nfsd_open_break_lease(struct inode *inode, int access)
730 * N.B. After this call fhp needs an fh_put 730 * N.B. After this call fhp needs an fh_put
731 */ 731 */
732__be32 732__be32
733nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, 733nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
734 int access, struct file **filp) 734 int access, struct file **filp)
735{ 735{
736 struct dentry *dentry; 736 struct dentry *dentry;
@@ -1300,7 +1300,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1300 goto out; 1300 goto out;
1301 } 1301 }
1302 1302
1303 host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); 1303 host_err = fh_want_write(fhp);
1304 if (host_err) 1304 if (host_err)
1305 goto out_nfserr; 1305 goto out_nfserr;
1306 1306
@@ -1325,7 +1325,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1325 break; 1325 break;
1326 } 1326 }
1327 if (host_err < 0) { 1327 if (host_err < 0) {
1328 mnt_drop_write(fhp->fh_export->ex_path.mnt); 1328 fh_drop_write(fhp);
1329 goto out_nfserr; 1329 goto out_nfserr;
1330 } 1330 }
1331 1331
@@ -1339,7 +1339,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1339 err2 = nfserrno(commit_metadata(fhp)); 1339 err2 = nfserrno(commit_metadata(fhp));
1340 if (err2) 1340 if (err2)
1341 err = err2; 1341 err = err2;
1342 mnt_drop_write(fhp->fh_export->ex_path.mnt); 1342 fh_drop_write(fhp);
1343 /* 1343 /*
1344 * Update the file handle to get the new inode info. 1344 * Update the file handle to get the new inode info.
1345 */ 1345 */
@@ -1430,7 +1430,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1430 v_atime = verifier[1]&0x7fffffff; 1430 v_atime = verifier[1]&0x7fffffff;
1431 } 1431 }
1432 1432
1433 host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); 1433 host_err = fh_want_write(fhp);
1434 if (host_err) 1434 if (host_err)
1435 goto out_nfserr; 1435 goto out_nfserr;
1436 if (dchild->d_inode) { 1436 if (dchild->d_inode) {
@@ -1469,13 +1469,13 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1469 case NFS3_CREATE_GUARDED: 1469 case NFS3_CREATE_GUARDED:
1470 err = nfserr_exist; 1470 err = nfserr_exist;
1471 } 1471 }
1472 mnt_drop_write(fhp->fh_export->ex_path.mnt); 1472 fh_drop_write(fhp);
1473 goto out; 1473 goto out;
1474 } 1474 }
1475 1475
1476 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL); 1476 host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
1477 if (host_err < 0) { 1477 if (host_err < 0) {
1478 mnt_drop_write(fhp->fh_export->ex_path.mnt); 1478 fh_drop_write(fhp);
1479 goto out_nfserr; 1479 goto out_nfserr;
1480 } 1480 }
1481 if (created) 1481 if (created)
@@ -1503,7 +1503,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1503 if (!err) 1503 if (!err)
1504 err = nfserrno(commit_metadata(fhp)); 1504 err = nfserrno(commit_metadata(fhp));
1505 1505
1506 mnt_drop_write(fhp->fh_export->ex_path.mnt); 1506 fh_drop_write(fhp);
1507 /* 1507 /*
1508 * Update the filehandle to get the new inode info. 1508 * Update the filehandle to get the new inode info.
1509 */ 1509 */
@@ -1600,7 +1600,7 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1600 if (IS_ERR(dnew)) 1600 if (IS_ERR(dnew))
1601 goto out_nfserr; 1601 goto out_nfserr;
1602 1602
1603 host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); 1603 host_err = fh_want_write(fhp);
1604 if (host_err) 1604 if (host_err)
1605 goto out_nfserr; 1605 goto out_nfserr;
1606 1606
@@ -1621,7 +1621,7 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp,
1621 err = nfserrno(commit_metadata(fhp)); 1621 err = nfserrno(commit_metadata(fhp));
1622 fh_unlock(fhp); 1622 fh_unlock(fhp);
1623 1623
1624 mnt_drop_write(fhp->fh_export->ex_path.mnt); 1624 fh_drop_write(fhp);
1625 1625
1626 cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp); 1626 cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp);
1627 dput(dnew); 1627 dput(dnew);
@@ -1674,7 +1674,7 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
1674 1674
1675 dold = tfhp->fh_dentry; 1675 dold = tfhp->fh_dentry;
1676 1676
1677 host_err = mnt_want_write(tfhp->fh_export->ex_path.mnt); 1677 host_err = fh_want_write(tfhp);
1678 if (host_err) { 1678 if (host_err) {
1679 err = nfserrno(host_err); 1679 err = nfserrno(host_err);
1680 goto out_dput; 1680 goto out_dput;
@@ -1699,7 +1699,7 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
1699 err = nfserrno(host_err); 1699 err = nfserrno(host_err);
1700 } 1700 }
1701out_drop_write: 1701out_drop_write:
1702 mnt_drop_write(tfhp->fh_export->ex_path.mnt); 1702 fh_drop_write(tfhp);
1703out_dput: 1703out_dput:
1704 dput(dnew); 1704 dput(dnew);
1705out_unlock: 1705out_unlock:
@@ -1776,7 +1776,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
1776 host_err = -EXDEV; 1776 host_err = -EXDEV;
1777 if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt) 1777 if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt)
1778 goto out_dput_new; 1778 goto out_dput_new;
1779 host_err = mnt_want_write(ffhp->fh_export->ex_path.mnt); 1779 host_err = fh_want_write(ffhp);
1780 if (host_err) 1780 if (host_err)
1781 goto out_dput_new; 1781 goto out_dput_new;
1782 1782
@@ -1795,7 +1795,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
1795 host_err = commit_metadata(ffhp); 1795 host_err = commit_metadata(ffhp);
1796 } 1796 }
1797out_drop_write: 1797out_drop_write:
1798 mnt_drop_write(ffhp->fh_export->ex_path.mnt); 1798 fh_drop_write(ffhp);
1799 out_dput_new: 1799 out_dput_new:
1800 dput(ndentry); 1800 dput(ndentry);
1801 out_dput_old: 1801 out_dput_old:
@@ -1854,7 +1854,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
1854 if (!type) 1854 if (!type)
1855 type = rdentry->d_inode->i_mode & S_IFMT; 1855 type = rdentry->d_inode->i_mode & S_IFMT;
1856 1856
1857 host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); 1857 host_err = fh_want_write(fhp);
1858 if (host_err) 1858 if (host_err)
1859 goto out_put; 1859 goto out_put;
1860 1860
@@ -1868,7 +1868,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
1868 if (!host_err) 1868 if (!host_err)
1869 host_err = commit_metadata(fhp); 1869 host_err = commit_metadata(fhp);
1870out_drop_write: 1870out_drop_write:
1871 mnt_drop_write(fhp->fh_export->ex_path.mnt); 1871 fh_drop_write(fhp);
1872out_put: 1872out_put:
1873 dput(rdentry); 1873 dput(rdentry);
1874 1874
@@ -2270,7 +2270,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
2270 } else 2270 } else
2271 size = 0; 2271 size = 0;
2272 2272
2273 error = mnt_want_write(fhp->fh_export->ex_path.mnt); 2273 error = fh_want_write(fhp);
2274 if (error) 2274 if (error)
2275 goto getout; 2275 goto getout;
2276 if (size) 2276 if (size)
@@ -2284,7 +2284,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
2284 error = 0; 2284 error = 0;
2285 } 2285 }
2286 } 2286 }
2287 mnt_drop_write(fhp->fh_export->ex_path.mnt); 2287 fh_drop_write(fhp);
2288 2288
2289getout: 2289getout:
2290 kfree(value); 2290 kfree(value);
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 3f54ad03bb2b..1dcd238e11a0 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -66,7 +66,7 @@ __be32 do_nfsd_create(struct svc_rqst *, struct svc_fh *,
66__be32 nfsd_commit(struct svc_rqst *, struct svc_fh *, 66__be32 nfsd_commit(struct svc_rqst *, struct svc_fh *,
67 loff_t, unsigned long); 67 loff_t, unsigned long);
68#endif /* CONFIG_NFSD_V3 */ 68#endif /* CONFIG_NFSD_V3 */
69__be32 nfsd_open(struct svc_rqst *, struct svc_fh *, int, 69__be32 nfsd_open(struct svc_rqst *, struct svc_fh *, umode_t,
70 int, struct file **); 70 int, struct file **);
71void nfsd_close(struct file *); 71void nfsd_close(struct file *);
72__be32 nfsd_read(struct svc_rqst *, struct svc_fh *, 72__be32 nfsd_read(struct svc_rqst *, struct svc_fh *,
@@ -106,4 +106,14 @@ struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int);
106int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *); 106int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *);
107#endif 107#endif
108 108
109static inline int fh_want_write(struct svc_fh *fh)
110{
111 return mnt_want_write(fh->fh_export->ex_path.mnt);
112}
113
114static inline void fh_drop_write(struct svc_fh *fh)
115{
116 mnt_drop_write(fh->fh_export->ex_path.mnt);
117}
118
109#endif /* LINUX_NFSD_VFS_H */ 119#endif /* LINUX_NFSD_VFS_H */
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index 3a1923943b14..ca35b3a46d17 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -251,7 +251,7 @@ nilfs_type_by_mode[S_IFMT >> S_SHIFT] = {
251 251
252static void nilfs_set_de_type(struct nilfs_dir_entry *de, struct inode *inode) 252static void nilfs_set_de_type(struct nilfs_dir_entry *de, struct inode *inode)
253{ 253{
254 mode_t mode = inode->i_mode; 254 umode_t mode = inode->i_mode;
255 255
256 de->file_type = nilfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; 256 de->file_type = nilfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
257} 257}
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index b50ffb72e5b3..8f7b95ac1f7e 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -291,7 +291,7 @@ const struct address_space_operations nilfs_aops = {
291 .is_partially_uptodate = block_is_partially_uptodate, 291 .is_partially_uptodate = block_is_partially_uptodate,
292}; 292};
293 293
294struct inode *nilfs_new_inode(struct inode *dir, int mode) 294struct inode *nilfs_new_inode(struct inode *dir, umode_t mode)
295{ 295{
296 struct super_block *sb = dir->i_sb; 296 struct super_block *sb = dir->i_sb;
297 struct the_nilfs *nilfs = sb->s_fs_info; 297 struct the_nilfs *nilfs = sb->s_fs_info;
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index ac258beeda3c..886649627c3d 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -27,7 +27,7 @@
27#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ 27#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
28#include <linux/vmalloc.h> 28#include <linux/vmalloc.h>
29#include <linux/compat.h> /* compat_ptr() */ 29#include <linux/compat.h> /* compat_ptr() */
30#include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */ 30#include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write_file() */
31#include <linux/buffer_head.h> 31#include <linux/buffer_head.h>
32#include <linux/nilfs2_fs.h> 32#include <linux/nilfs2_fs.h>
33#include "nilfs.h" 33#include "nilfs.h"
@@ -119,7 +119,7 @@ static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp,
119 if (get_user(flags, (int __user *)argp)) 119 if (get_user(flags, (int __user *)argp))
120 return -EFAULT; 120 return -EFAULT;
121 121
122 ret = mnt_want_write(filp->f_path.mnt); 122 ret = mnt_want_write_file(filp);
123 if (ret) 123 if (ret)
124 return ret; 124 return ret;
125 125
@@ -154,7 +154,7 @@ static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp,
154 ret = nilfs_transaction_commit(inode->i_sb); 154 ret = nilfs_transaction_commit(inode->i_sb);
155out: 155out:
156 mutex_unlock(&inode->i_mutex); 156 mutex_unlock(&inode->i_mutex);
157 mnt_drop_write(filp->f_path.mnt); 157 mnt_drop_write_file(filp);
158 return ret; 158 return ret;
159} 159}
160 160
@@ -174,7 +174,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
174 if (!capable(CAP_SYS_ADMIN)) 174 if (!capable(CAP_SYS_ADMIN))
175 return -EPERM; 175 return -EPERM;
176 176
177 ret = mnt_want_write(filp->f_path.mnt); 177 ret = mnt_want_write_file(filp);
178 if (ret) 178 if (ret)
179 return ret; 179 return ret;
180 180
@@ -194,7 +194,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
194 194
195 up_read(&inode->i_sb->s_umount); 195 up_read(&inode->i_sb->s_umount);
196out: 196out:
197 mnt_drop_write(filp->f_path.mnt); 197 mnt_drop_write_file(filp);
198 return ret; 198 return ret;
199} 199}
200 200
@@ -210,7 +210,7 @@ nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp,
210 if (!capable(CAP_SYS_ADMIN)) 210 if (!capable(CAP_SYS_ADMIN))
211 return -EPERM; 211 return -EPERM;
212 212
213 ret = mnt_want_write(filp->f_path.mnt); 213 ret = mnt_want_write_file(filp);
214 if (ret) 214 if (ret)
215 return ret; 215 return ret;
216 216
@@ -225,7 +225,7 @@ nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp,
225 else 225 else
226 nilfs_transaction_commit(inode->i_sb); /* never fails */ 226 nilfs_transaction_commit(inode->i_sb); /* never fails */
227out: 227out:
228 mnt_drop_write(filp->f_path.mnt); 228 mnt_drop_write_file(filp);
229 return ret; 229 return ret;
230} 230}
231 231
@@ -591,7 +591,7 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
591 if (!capable(CAP_SYS_ADMIN)) 591 if (!capable(CAP_SYS_ADMIN))
592 return -EPERM; 592 return -EPERM;
593 593
594 ret = mnt_want_write(filp->f_path.mnt); 594 ret = mnt_want_write_file(filp);
595 if (ret) 595 if (ret)
596 return ret; 596 return ret;
597 597
@@ -675,7 +675,7 @@ out_free:
675 vfree(kbufs[n]); 675 vfree(kbufs[n]);
676 kfree(kbufs[4]); 676 kfree(kbufs[4]);
677out: 677out:
678 mnt_drop_write(filp->f_path.mnt); 678 mnt_drop_write_file(filp);
679 return ret; 679 return ret;
680} 680}
681 681
@@ -710,7 +710,7 @@ static int nilfs_ioctl_resize(struct inode *inode, struct file *filp,
710 if (!capable(CAP_SYS_ADMIN)) 710 if (!capable(CAP_SYS_ADMIN))
711 goto out; 711 goto out;
712 712
713 ret = mnt_want_write(filp->f_path.mnt); 713 ret = mnt_want_write_file(filp);
714 if (ret) 714 if (ret)
715 goto out; 715 goto out;
716 716
@@ -721,7 +721,7 @@ static int nilfs_ioctl_resize(struct inode *inode, struct file *filp,
721 ret = nilfs_resize_fs(inode->i_sb, newsize); 721 ret = nilfs_resize_fs(inode->i_sb, newsize);
722 722
723out_drop_write: 723out_drop_write:
724 mnt_drop_write(filp->f_path.mnt); 724 mnt_drop_write_file(filp);
725out: 725out:
726 return ret; 726 return ret;
727} 727}
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index 768982de10e4..1cd3f624dffc 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -84,7 +84,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
84 * If the create succeeds, we fill in the inode information 84 * If the create succeeds, we fill in the inode information
85 * with d_instantiate(). 85 * with d_instantiate().
86 */ 86 */
87static int nilfs_create(struct inode *dir, struct dentry *dentry, int mode, 87static int nilfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
88 struct nameidata *nd) 88 struct nameidata *nd)
89{ 89{
90 struct inode *inode; 90 struct inode *inode;
@@ -112,7 +112,7 @@ static int nilfs_create(struct inode *dir, struct dentry *dentry, int mode,
112} 112}
113 113
114static int 114static int
115nilfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) 115nilfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev)
116{ 116{
117 struct inode *inode; 117 struct inode *inode;
118 struct nilfs_transaction_info ti; 118 struct nilfs_transaction_info ti;
@@ -213,7 +213,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
213 return err; 213 return err;
214} 214}
215 215
216static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 216static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
217{ 217{
218 struct inode *inode; 218 struct inode *inode;
219 struct nilfs_transaction_info ti; 219 struct nilfs_transaction_info ti;
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 3777d138f895..250add84da76 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -246,7 +246,7 @@ int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *,
246/* inode.c */ 246/* inode.c */
247void nilfs_inode_add_blocks(struct inode *inode, int n); 247void nilfs_inode_add_blocks(struct inode *inode, int n);
248void nilfs_inode_sub_blocks(struct inode *inode, int n); 248void nilfs_inode_sub_blocks(struct inode *inode, int n);
249extern struct inode *nilfs_new_inode(struct inode *, int); 249extern struct inode *nilfs_new_inode(struct inode *, umode_t);
250extern void nilfs_free_inode(struct inode *); 250extern void nilfs_free_inode(struct inode *);
251extern int nilfs_get_block(struct inode *, sector_t, struct buffer_head *, int); 251extern int nilfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
252extern void nilfs_set_inode_flags(struct inode *); 252extern void nilfs_set_inode_flags(struct inode *);
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 8351c44a7320..08e3d4f9df18 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -175,8 +175,6 @@ static void nilfs_i_callback(struct rcu_head *head)
175 struct inode *inode = container_of(head, struct inode, i_rcu); 175 struct inode *inode = container_of(head, struct inode, i_rcu);
176 struct nilfs_mdt_info *mdi = NILFS_MDT(inode); 176 struct nilfs_mdt_info *mdi = NILFS_MDT(inode);
177 177
178 INIT_LIST_HEAD(&inode->i_dentry);
179
180 if (mdi) { 178 if (mdi) {
181 kfree(mdi->mi_bgl); /* kfree(NULL) is safe */ 179 kfree(mdi->mi_bgl); /* kfree(NULL) is safe */
182 kfree(mdi); 180 kfree(mdi);
@@ -650,11 +648,11 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf)
650 return 0; 648 return 0;
651} 649}
652 650
653static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 651static int nilfs_show_options(struct seq_file *seq, struct dentry *dentry)
654{ 652{
655 struct super_block *sb = vfs->mnt_sb; 653 struct super_block *sb = dentry->d_sb;
656 struct the_nilfs *nilfs = sb->s_fs_info; 654 struct the_nilfs *nilfs = sb->s_fs_info;
657 struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; 655 struct nilfs_root *root = NILFS_I(dentry->d_inode)->i_root;
658 656
659 if (!nilfs_test_opt(nilfs, BARRIER)) 657 if (!nilfs_test_opt(nilfs, BARRIER))
660 seq_puts(seq, ",nobarrier"); 658 seq_puts(seq, ",nobarrier");
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 9fde1c00a296..3568c8a8b138 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -16,6 +16,8 @@
16 16
17#include <asm/ioctls.h> 17#include <asm/ioctls.h>
18 18
19#include "../../mount.h"
20
19#define FANOTIFY_DEFAULT_MAX_EVENTS 16384 21#define FANOTIFY_DEFAULT_MAX_EVENTS 16384
20#define FANOTIFY_DEFAULT_MAX_MARKS 8192 22#define FANOTIFY_DEFAULT_MAX_MARKS 8192
21#define FANOTIFY_DEFAULT_MAX_LISTENERS 128 23#define FANOTIFY_DEFAULT_MAX_LISTENERS 128
@@ -546,7 +548,7 @@ static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group,
546 548
547 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags); 549 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags);
548 fsnotify_put_mark(fsn_mark); 550 fsnotify_put_mark(fsn_mark);
549 if (removed & mnt->mnt_fsnotify_mask) 551 if (removed & real_mount(mnt)->mnt_fsnotify_mask)
550 fsnotify_recalc_vfsmount_mask(mnt); 552 fsnotify_recalc_vfsmount_mask(mnt);
551 553
552 return 0; 554 return 0;
@@ -623,7 +625,7 @@ static int fanotify_add_vfsmount_mark(struct fsnotify_group *group,
623 } 625 }
624 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags); 626 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);
625 627
626 if (added & ~mnt->mnt_fsnotify_mask) 628 if (added & ~real_mount(mnt)->mnt_fsnotify_mask)
627 fsnotify_recalc_vfsmount_mask(mnt); 629 fsnotify_recalc_vfsmount_mask(mnt);
628err: 630err:
629 fsnotify_put_mark(fsn_mark); 631 fsnotify_put_mark(fsn_mark);
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 79b47cbb5cd8..ccb14d3fc0de 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/fsnotify_backend.h> 27#include <linux/fsnotify_backend.h>
28#include "fsnotify.h" 28#include "fsnotify.h"
29#include "../mount.h"
29 30
30/* 31/*
31 * Clear all of the marks on an inode when it is being evicted from core 32 * Clear all of the marks on an inode when it is being evicted from core
@@ -205,13 +206,13 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
205 struct fsnotify_mark *inode_mark = NULL, *vfsmount_mark = NULL; 206 struct fsnotify_mark *inode_mark = NULL, *vfsmount_mark = NULL;
206 struct fsnotify_group *inode_group, *vfsmount_group; 207 struct fsnotify_group *inode_group, *vfsmount_group;
207 struct fsnotify_event *event = NULL; 208 struct fsnotify_event *event = NULL;
208 struct vfsmount *mnt; 209 struct mount *mnt;
209 int idx, ret = 0; 210 int idx, ret = 0;
210 /* global tests shouldn't care about events on child only the specific event */ 211 /* global tests shouldn't care about events on child only the specific event */
211 __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); 212 __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD);
212 213
213 if (data_is == FSNOTIFY_EVENT_PATH) 214 if (data_is == FSNOTIFY_EVENT_PATH)
214 mnt = ((struct path *)data)->mnt; 215 mnt = real_mount(((struct path *)data)->mnt);
215 else 216 else
216 mnt = NULL; 217 mnt = NULL;
217 218
@@ -262,11 +263,11 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
262 /* we didn't use the vfsmount_mark */ 263 /* we didn't use the vfsmount_mark */
263 vfsmount_group = NULL; 264 vfsmount_group = NULL;
264 } else if (vfsmount_group > inode_group) { 265 } else if (vfsmount_group > inode_group) {
265 ret = send_to_group(to_tell, mnt, NULL, vfsmount_mark, mask, data, 266 ret = send_to_group(to_tell, &mnt->mnt, NULL, vfsmount_mark, mask, data,
266 data_is, cookie, file_name, &event); 267 data_is, cookie, file_name, &event);
267 inode_group = NULL; 268 inode_group = NULL;
268 } else { 269 } else {
269 ret = send_to_group(to_tell, mnt, inode_mark, vfsmount_mark, 270 ret = send_to_group(to_tell, &mnt->mnt, inode_mark, vfsmount_mark,
270 mask, data, data_is, cookie, file_name, 271 mask, data, data_is, cookie, file_name,
271 &event); 272 &event);
272 } 273 }
diff --git a/fs/notify/vfsmount_mark.c b/fs/notify/vfsmount_mark.c
index 778fe6cae3b0..b7b4b0e8554f 100644
--- a/fs/notify/vfsmount_mark.c
+++ b/fs/notify/vfsmount_mark.c
@@ -28,15 +28,17 @@
28 28
29#include <linux/fsnotify_backend.h> 29#include <linux/fsnotify_backend.h>
30#include "fsnotify.h" 30#include "fsnotify.h"
31#include "../mount.h"
31 32
32void fsnotify_clear_marks_by_mount(struct vfsmount *mnt) 33void fsnotify_clear_marks_by_mount(struct vfsmount *mnt)
33{ 34{
34 struct fsnotify_mark *mark, *lmark; 35 struct fsnotify_mark *mark, *lmark;
35 struct hlist_node *pos, *n; 36 struct hlist_node *pos, *n;
37 struct mount *m = real_mount(mnt);
36 LIST_HEAD(free_list); 38 LIST_HEAD(free_list);
37 39
38 spin_lock(&mnt->mnt_root->d_lock); 40 spin_lock(&mnt->mnt_root->d_lock);
39 hlist_for_each_entry_safe(mark, pos, n, &mnt->mnt_fsnotify_marks, m.m_list) { 41 hlist_for_each_entry_safe(mark, pos, n, &m->mnt_fsnotify_marks, m.m_list) {
40 list_add(&mark->m.free_m_list, &free_list); 42 list_add(&mark->m.free_m_list, &free_list);
41 hlist_del_init_rcu(&mark->m.m_list); 43 hlist_del_init_rcu(&mark->m.m_list);
42 fsnotify_get_mark(mark); 44 fsnotify_get_mark(mark);
@@ -59,15 +61,16 @@ void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group)
59 */ 61 */
60static void fsnotify_recalc_vfsmount_mask_locked(struct vfsmount *mnt) 62static void fsnotify_recalc_vfsmount_mask_locked(struct vfsmount *mnt)
61{ 63{
64 struct mount *m = real_mount(mnt);
62 struct fsnotify_mark *mark; 65 struct fsnotify_mark *mark;
63 struct hlist_node *pos; 66 struct hlist_node *pos;
64 __u32 new_mask = 0; 67 __u32 new_mask = 0;
65 68
66 assert_spin_locked(&mnt->mnt_root->d_lock); 69 assert_spin_locked(&mnt->mnt_root->d_lock);
67 70
68 hlist_for_each_entry(mark, pos, &mnt->mnt_fsnotify_marks, m.m_list) 71 hlist_for_each_entry(mark, pos, &m->mnt_fsnotify_marks, m.m_list)
69 new_mask |= mark->mask; 72 new_mask |= mark->mask;
70 mnt->mnt_fsnotify_mask = new_mask; 73 m->mnt_fsnotify_mask = new_mask;
71} 74}
72 75
73/* 76/*
@@ -101,12 +104,13 @@ void fsnotify_destroy_vfsmount_mark(struct fsnotify_mark *mark)
101static struct fsnotify_mark *fsnotify_find_vfsmount_mark_locked(struct fsnotify_group *group, 104static struct fsnotify_mark *fsnotify_find_vfsmount_mark_locked(struct fsnotify_group *group,
102 struct vfsmount *mnt) 105 struct vfsmount *mnt)
103{ 106{
107 struct mount *m = real_mount(mnt);
104 struct fsnotify_mark *mark; 108 struct fsnotify_mark *mark;
105 struct hlist_node *pos; 109 struct hlist_node *pos;
106 110
107 assert_spin_locked(&mnt->mnt_root->d_lock); 111 assert_spin_locked(&mnt->mnt_root->d_lock);
108 112
109 hlist_for_each_entry(mark, pos, &mnt->mnt_fsnotify_marks, m.m_list) { 113 hlist_for_each_entry(mark, pos, &m->mnt_fsnotify_marks, m.m_list) {
110 if (mark->group == group) { 114 if (mark->group == group) {
111 fsnotify_get_mark(mark); 115 fsnotify_get_mark(mark);
112 return mark; 116 return mark;
@@ -140,6 +144,7 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
140 struct fsnotify_group *group, struct vfsmount *mnt, 144 struct fsnotify_group *group, struct vfsmount *mnt,
141 int allow_dups) 145 int allow_dups)
142{ 146{
147 struct mount *m = real_mount(mnt);
143 struct fsnotify_mark *lmark; 148 struct fsnotify_mark *lmark;
144 struct hlist_node *node, *last = NULL; 149 struct hlist_node *node, *last = NULL;
145 int ret = 0; 150 int ret = 0;
@@ -154,13 +159,13 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
154 mark->m.mnt = mnt; 159 mark->m.mnt = mnt;
155 160
156 /* is mark the first mark? */ 161 /* is mark the first mark? */
157 if (hlist_empty(&mnt->mnt_fsnotify_marks)) { 162 if (hlist_empty(&m->mnt_fsnotify_marks)) {
158 hlist_add_head_rcu(&mark->m.m_list, &mnt->mnt_fsnotify_marks); 163 hlist_add_head_rcu(&mark->m.m_list, &m->mnt_fsnotify_marks);
159 goto out; 164 goto out;
160 } 165 }
161 166
162 /* should mark be in the middle of the current list? */ 167 /* should mark be in the middle of the current list? */
163 hlist_for_each_entry(lmark, node, &mnt->mnt_fsnotify_marks, m.m_list) { 168 hlist_for_each_entry(lmark, node, &m->mnt_fsnotify_marks, m.m_list) {
164 last = node; 169 last = node;
165 170
166 if ((lmark->group == group) && !allow_dups) { 171 if ((lmark->group == group) && !allow_dups) {
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 97e2dacbc867..2eaa66652944 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -335,7 +335,6 @@ struct inode *ntfs_alloc_big_inode(struct super_block *sb)
335static void ntfs_i_callback(struct rcu_head *head) 335static void ntfs_i_callback(struct rcu_head *head)
336{ 336{
337 struct inode *inode = container_of(head, struct inode, i_rcu); 337 struct inode *inode = container_of(head, struct inode, i_rcu);
338 INIT_LIST_HEAD(&inode->i_dentry);
339 kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode)); 338 kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode));
340} 339}
341 340
@@ -2301,16 +2300,16 @@ void ntfs_evict_big_inode(struct inode *vi)
2301/** 2300/**
2302 * ntfs_show_options - show mount options in /proc/mounts 2301 * ntfs_show_options - show mount options in /proc/mounts
2303 * @sf: seq_file in which to write our mount options 2302 * @sf: seq_file in which to write our mount options
2304 * @mnt: vfs mount whose mount options to display 2303 * @root: root of the mounted tree whose mount options to display
2305 * 2304 *
2306 * Called by the VFS once for each mounted ntfs volume when someone reads 2305 * Called by the VFS once for each mounted ntfs volume when someone reads
2307 * /proc/mounts in order to display the NTFS specific mount options of each 2306 * /proc/mounts in order to display the NTFS specific mount options of each
2308 * mount. The mount options of the vfs mount @mnt are written to the seq file 2307 * mount. The mount options of fs specified by @root are written to the seq file
2309 * @sf and success is returned. 2308 * @sf and success is returned.
2310 */ 2309 */
2311int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt) 2310int ntfs_show_options(struct seq_file *sf, struct dentry *root)
2312{ 2311{
2313 ntfs_volume *vol = NTFS_SB(mnt->mnt_sb); 2312 ntfs_volume *vol = NTFS_SB(root->d_sb);
2314 int i; 2313 int i;
2315 2314
2316 seq_printf(sf, ",uid=%i", vol->uid); 2315 seq_printf(sf, ",uid=%i", vol->uid);
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
index fe8e7e928889..db29695f845c 100644
--- a/fs/ntfs/inode.h
+++ b/fs/ntfs/inode.h
@@ -298,7 +298,7 @@ extern void ntfs_clear_extent_inode(ntfs_inode *ni);
298 298
299extern int ntfs_read_inode_mount(struct inode *vi); 299extern int ntfs_read_inode_mount(struct inode *vi);
300 300
301extern int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt); 301extern int ntfs_show_options(struct seq_file *sf, struct dentry *root);
302 302
303#ifdef NTFS_RW 303#ifdef NTFS_RW
304 304
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index b52706da4645..608be4516091 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -104,7 +104,7 @@ static bool parse_options(ntfs_volume *vol, char *opt)
104 int errors = 0, sloppy = 0; 104 int errors = 0, sloppy = 0;
105 uid_t uid = (uid_t)-1; 105 uid_t uid = (uid_t)-1;
106 gid_t gid = (gid_t)-1; 106 gid_t gid = (gid_t)-1;
107 mode_t fmask = (mode_t)-1, dmask = (mode_t)-1; 107 umode_t fmask = (umode_t)-1, dmask = (umode_t)-1;
108 int mft_zone_multiplier = -1, on_errors = -1; 108 int mft_zone_multiplier = -1, on_errors = -1;
109 int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1; 109 int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1;
110 struct nls_table *nls_map = NULL, *old_nls; 110 struct nls_table *nls_map = NULL, *old_nls;
@@ -287,9 +287,9 @@ no_mount_options:
287 vol->uid = uid; 287 vol->uid = uid;
288 if (gid != (gid_t)-1) 288 if (gid != (gid_t)-1)
289 vol->gid = gid; 289 vol->gid = gid;
290 if (fmask != (mode_t)-1) 290 if (fmask != (umode_t)-1)
291 vol->fmask = fmask; 291 vol->fmask = fmask;
292 if (dmask != (mode_t)-1) 292 if (dmask != (umode_t)-1)
293 vol->dmask = dmask; 293 vol->dmask = dmask;
294 if (show_sys_files != -1) { 294 if (show_sys_files != -1) {
295 if (show_sys_files) 295 if (show_sys_files)
diff --git a/fs/ntfs/volume.h b/fs/ntfs/volume.h
index 406ab55dfb32..15e3ba8d521a 100644
--- a/fs/ntfs/volume.h
+++ b/fs/ntfs/volume.h
@@ -48,8 +48,8 @@ typedef struct {
48 unsigned long flags; /* Miscellaneous flags, see below. */ 48 unsigned long flags; /* Miscellaneous flags, see below. */
49 uid_t uid; /* uid that files will be mounted as. */ 49 uid_t uid; /* uid that files will be mounted as. */
50 gid_t gid; /* gid that files will be mounted as. */ 50 gid_t gid; /* gid that files will be mounted as. */
51 mode_t fmask; /* The mask for file permissions. */ 51 umode_t fmask; /* The mask for file permissions. */
52 mode_t dmask; /* The mask for directory 52 umode_t dmask; /* The mask for directory
53 permissions. */ 53 permissions. */
54 u8 mft_zone_multiplier; /* Initial mft zone multiplier. */ 54 u8 mft_zone_multiplier; /* Initial mft zone multiplier. */
55 u8 on_errors; /* What to do on filesystem errors. */ 55 u8 on_errors; /* What to do on filesystem errors. */
diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c
index dc45deb19e68..73ba81928bce 100644
--- a/fs/ocfs2/cluster/netdebug.c
+++ b/fs/ocfs2/cluster/netdebug.c
@@ -553,7 +553,7 @@ void o2net_debugfs_exit(void)
553 553
554int o2net_debugfs_init(void) 554int o2net_debugfs_init(void)
555{ 555{
556 mode_t mode = S_IFREG|S_IRUSR; 556 umode_t mode = S_IFREG|S_IRUSR;
557 557
558 o2net_dentry = debugfs_create_dir(O2NET_DEBUG_DIR, NULL); 558 o2net_dentry = debugfs_create_dir(O2NET_DEBUG_DIR, NULL);
559 if (o2net_dentry) 559 if (o2net_dentry)
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index b42076797049..abfac0d7ae9c 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -354,7 +354,6 @@ static struct inode *dlmfs_alloc_inode(struct super_block *sb)
354static void dlmfs_i_callback(struct rcu_head *head) 354static void dlmfs_i_callback(struct rcu_head *head)
355{ 355{
356 struct inode *inode = container_of(head, struct inode, i_rcu); 356 struct inode *inode = container_of(head, struct inode, i_rcu);
357 INIT_LIST_HEAD(&inode->i_dentry);
358 kmem_cache_free(dlmfs_inode_cache, DLMFS_I(inode)); 357 kmem_cache_free(dlmfs_inode_cache, DLMFS_I(inode));
359} 358}
360 359
@@ -401,16 +400,14 @@ static struct backing_dev_info dlmfs_backing_dev_info = {
401static struct inode *dlmfs_get_root_inode(struct super_block *sb) 400static struct inode *dlmfs_get_root_inode(struct super_block *sb)
402{ 401{
403 struct inode *inode = new_inode(sb); 402 struct inode *inode = new_inode(sb);
404 int mode = S_IFDIR | 0755; 403 umode_t mode = S_IFDIR | 0755;
405 struct dlmfs_inode_private *ip; 404 struct dlmfs_inode_private *ip;
406 405
407 if (inode) { 406 if (inode) {
408 ip = DLMFS_I(inode); 407 ip = DLMFS_I(inode);
409 408
410 inode->i_ino = get_next_ino(); 409 inode->i_ino = get_next_ino();
411 inode->i_mode = mode; 410 inode_init_owner(inode, NULL, mode);
412 inode->i_uid = current_fsuid();
413 inode->i_gid = current_fsgid();
414 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; 411 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
415 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 412 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
416 inc_nlink(inode); 413 inc_nlink(inode);
@@ -424,7 +421,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
424 421
425static struct inode *dlmfs_get_inode(struct inode *parent, 422static struct inode *dlmfs_get_inode(struct inode *parent,
426 struct dentry *dentry, 423 struct dentry *dentry,
427 int mode) 424 umode_t mode)
428{ 425{
429 struct super_block *sb = parent->i_sb; 426 struct super_block *sb = parent->i_sb;
430 struct inode * inode = new_inode(sb); 427 struct inode * inode = new_inode(sb);
@@ -434,9 +431,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
434 return NULL; 431 return NULL;
435 432
436 inode->i_ino = get_next_ino(); 433 inode->i_ino = get_next_ino();
437 inode->i_mode = mode; 434 inode_init_owner(inode, parent, mode);
438 inode->i_uid = current_fsuid();
439 inode->i_gid = current_fsgid();
440 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; 435 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
441 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 436 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
442 437
@@ -473,13 +468,6 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
473 inc_nlink(inode); 468 inc_nlink(inode);
474 break; 469 break;
475 } 470 }
476
477 if (parent->i_mode & S_ISGID) {
478 inode->i_gid = parent->i_gid;
479 if (S_ISDIR(mode))
480 inode->i_mode |= S_ISGID;
481 }
482
483 return inode; 471 return inode;
484} 472}
485 473
@@ -489,7 +477,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
489/* SMP-safe */ 477/* SMP-safe */
490static int dlmfs_mkdir(struct inode * dir, 478static int dlmfs_mkdir(struct inode * dir,
491 struct dentry * dentry, 479 struct dentry * dentry,
492 int mode) 480 umode_t mode)
493{ 481{
494 int status; 482 int status;
495 struct inode *inode = NULL; 483 struct inode *inode = NULL;
@@ -537,7 +525,7 @@ bail:
537 525
538static int dlmfs_create(struct inode *dir, 526static int dlmfs_create(struct inode *dir,
539 struct dentry *dentry, 527 struct dentry *dentry,
540 int mode, 528 umode_t mode,
541 struct nameidata *nd) 529 struct nameidata *nd)
542{ 530{
543 int status = 0; 531 int status = 0;
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 726ff265b296..a6fda3c188aa 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -906,12 +906,12 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
906 if (get_user(flags, (int __user *) arg)) 906 if (get_user(flags, (int __user *) arg))
907 return -EFAULT; 907 return -EFAULT;
908 908
909 status = mnt_want_write(filp->f_path.mnt); 909 status = mnt_want_write_file(filp);
910 if (status) 910 if (status)
911 return status; 911 return status;
912 status = ocfs2_set_inode_attr(inode, flags, 912 status = ocfs2_set_inode_attr(inode, flags,
913 OCFS2_FL_MODIFIABLE); 913 OCFS2_FL_MODIFIABLE);
914 mnt_drop_write(filp->f_path.mnt); 914 mnt_drop_write_file(filp);
915 return status; 915 return status;
916 case OCFS2_IOC_RESVSP: 916 case OCFS2_IOC_RESVSP:
917 case OCFS2_IOC_RESVSP64: 917 case OCFS2_IOC_RESVSP64:
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index 184c76b8c293..b1e3fce72ea4 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -1059,7 +1059,7 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
1059 struct ocfs2_move_extents range; 1059 struct ocfs2_move_extents range;
1060 struct ocfs2_move_extents_context *context = NULL; 1060 struct ocfs2_move_extents_context *context = NULL;
1061 1061
1062 status = mnt_want_write(filp->f_path.mnt); 1062 status = mnt_want_write_file(filp);
1063 if (status) 1063 if (status)
1064 return status; 1064 return status;
1065 1065
@@ -1145,7 +1145,7 @@ out:
1145 1145
1146 kfree(context); 1146 kfree(context);
1147 1147
1148 mnt_drop_write(filp->f_path.mnt); 1148 mnt_drop_write_file(filp);
1149 1149
1150 return status; 1150 return status;
1151} 1151}
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index a8b2bfea574e..be244692550d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -185,7 +185,7 @@ bail:
185 return ret; 185 return ret;
186} 186}
187 187
188static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode) 188static struct inode *ocfs2_get_init_inode(struct inode *dir, umode_t mode)
189{ 189{
190 struct inode *inode; 190 struct inode *inode;
191 191
@@ -207,7 +207,7 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode)
207 207
208static int ocfs2_mknod(struct inode *dir, 208static int ocfs2_mknod(struct inode *dir,
209 struct dentry *dentry, 209 struct dentry *dentry,
210 int mode, 210 umode_t mode,
211 dev_t dev) 211 dev_t dev)
212{ 212{
213 int status = 0; 213 int status = 0;
@@ -602,7 +602,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
602 602
603static int ocfs2_mkdir(struct inode *dir, 603static int ocfs2_mkdir(struct inode *dir,
604 struct dentry *dentry, 604 struct dentry *dentry,
605 int mode) 605 umode_t mode)
606{ 606{
607 int ret; 607 int ret;
608 608
@@ -617,7 +617,7 @@ static int ocfs2_mkdir(struct inode *dir,
617 617
618static int ocfs2_create(struct inode *dir, 618static int ocfs2_create(struct inode *dir,
619 struct dentry *dentry, 619 struct dentry *dentry,
620 int mode, 620 umode_t mode,
621 struct nameidata *nd) 621 struct nameidata *nd)
622{ 622{
623 int ret; 623 int ret;
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 4994f8b0e604..604e12c4e979 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -108,7 +108,7 @@ static int ocfs2_parse_options(struct super_block *sb, char *options,
108 int is_remount); 108 int is_remount);
109static int ocfs2_check_set_options(struct super_block *sb, 109static int ocfs2_check_set_options(struct super_block *sb,
110 struct mount_options *options); 110 struct mount_options *options);
111static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt); 111static int ocfs2_show_options(struct seq_file *s, struct dentry *root);
112static void ocfs2_put_super(struct super_block *sb); 112static void ocfs2_put_super(struct super_block *sb);
113static int ocfs2_mount_volume(struct super_block *sb); 113static int ocfs2_mount_volume(struct super_block *sb);
114static int ocfs2_remount(struct super_block *sb, int *flags, char *data); 114static int ocfs2_remount(struct super_block *sb, int *flags, char *data);
@@ -569,7 +569,6 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb)
569static void ocfs2_i_callback(struct rcu_head *head) 569static void ocfs2_i_callback(struct rcu_head *head)
570{ 570{
571 struct inode *inode = container_of(head, struct inode, i_rcu); 571 struct inode *inode = container_of(head, struct inode, i_rcu);
572 INIT_LIST_HEAD(&inode->i_dentry);
573 kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode)); 572 kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode));
574} 573}
575 574
@@ -1534,9 +1533,9 @@ bail:
1534 return status; 1533 return status;
1535} 1534}
1536 1535
1537static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) 1536static int ocfs2_show_options(struct seq_file *s, struct dentry *root)
1538{ 1537{
1539 struct ocfs2_super *osb = OCFS2_SB(mnt->mnt_sb); 1538 struct ocfs2_super *osb = OCFS2_SB(root->d_sb);
1540 unsigned long opts = osb->s_mount_opt; 1539 unsigned long opts = osb->s_mount_opt;
1541 unsigned int local_alloc_megs; 1540 unsigned int local_alloc_megs;
1542 1541
@@ -1568,8 +1567,7 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
1568 if (osb->preferred_slot != OCFS2_INVALID_SLOT) 1567 if (osb->preferred_slot != OCFS2_INVALID_SLOT)
1569 seq_printf(s, ",preferred_slot=%d", osb->preferred_slot); 1568 seq_printf(s, ",preferred_slot=%d", osb->preferred_slot);
1570 1569
1571 if (!(mnt->mnt_flags & MNT_NOATIME) && !(mnt->mnt_flags & MNT_RELATIME)) 1570 seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum);
1572 seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum);
1573 1571
1574 if (osb->osb_commit_interval) 1572 if (osb->osb_commit_interval)
1575 seq_printf(s, ",commit=%u", 1573 seq_printf(s, ",commit=%u",
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index aa9e8777b09a..0ba9ea1e7961 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -623,7 +623,7 @@ int ocfs2_calc_security_init(struct inode *dir,
623 623
624int ocfs2_calc_xattr_init(struct inode *dir, 624int ocfs2_calc_xattr_init(struct inode *dir,
625 struct buffer_head *dir_bh, 625 struct buffer_head *dir_bh,
626 int mode, 626 umode_t mode,
627 struct ocfs2_security_xattr_info *si, 627 struct ocfs2_security_xattr_info *si,
628 int *want_clusters, 628 int *want_clusters,
629 int *xattr_credits, 629 int *xattr_credits,
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
index d63cfb72316b..e5c7f15465b4 100644
--- a/fs/ocfs2/xattr.h
+++ b/fs/ocfs2/xattr.h
@@ -68,7 +68,7 @@ int ocfs2_calc_security_init(struct inode *,
68 struct ocfs2_security_xattr_info *, 68 struct ocfs2_security_xattr_info *,
69 int *, int *, struct ocfs2_alloc_context **); 69 int *, int *, struct ocfs2_alloc_context **);
70int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *, 70int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *,
71 int, struct ocfs2_security_xattr_info *, 71 umode_t, struct ocfs2_security_xattr_info *,
72 int *, int *, int *); 72 int *, int *, int *);
73 73
74/* 74/*
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index 98e544274390..f00576ec320f 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -255,7 +255,7 @@ static int omfs_remove(struct inode *dir, struct dentry *dentry)
255 return 0; 255 return 0;
256} 256}
257 257
258static int omfs_add_node(struct inode *dir, struct dentry *dentry, int mode) 258static int omfs_add_node(struct inode *dir, struct dentry *dentry, umode_t mode)
259{ 259{
260 int err; 260 int err;
261 struct inode *inode = omfs_new_inode(dir, mode); 261 struct inode *inode = omfs_new_inode(dir, mode);
@@ -279,12 +279,12 @@ out_free_inode:
279 return err; 279 return err;
280} 280}
281 281
282static int omfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 282static int omfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
283{ 283{
284 return omfs_add_node(dir, dentry, mode | S_IFDIR); 284 return omfs_add_node(dir, dentry, mode | S_IFDIR);
285} 285}
286 286
287static int omfs_create(struct inode *dir, struct dentry *dentry, int mode, 287static int omfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
288 struct nameidata *nd) 288 struct nameidata *nd)
289{ 289{
290 return omfs_add_node(dir, dentry, mode | S_IFREG); 290 return omfs_add_node(dir, dentry, mode | S_IFREG);
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index e043c4cb9a97..6065bb0ba207 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -28,7 +28,7 @@ struct buffer_head *omfs_bread(struct super_block *sb, sector_t block)
28 return sb_bread(sb, clus_to_blk(sbi, block)); 28 return sb_bread(sb, clus_to_blk(sbi, block));
29} 29}
30 30
31struct inode *omfs_new_inode(struct inode *dir, int mode) 31struct inode *omfs_new_inode(struct inode *dir, umode_t mode)
32{ 32{
33 struct inode *inode; 33 struct inode *inode;
34 u64 new_block; 34 u64 new_block;
diff --git a/fs/omfs/omfs.h b/fs/omfs/omfs.h
index 7d414fef501a..8941f12c6b01 100644
--- a/fs/omfs/omfs.h
+++ b/fs/omfs/omfs.h
@@ -60,7 +60,7 @@ extern int omfs_shrink_inode(struct inode *inode);
60/* inode.c */ 60/* inode.c */
61extern struct buffer_head *omfs_bread(struct super_block *sb, sector_t block); 61extern struct buffer_head *omfs_bread(struct super_block *sb, sector_t block);
62extern struct inode *omfs_iget(struct super_block *sb, ino_t inode); 62extern struct inode *omfs_iget(struct super_block *sb, ino_t inode);
63extern struct inode *omfs_new_inode(struct inode *dir, int mode); 63extern struct inode *omfs_new_inode(struct inode *dir, umode_t mode);
64extern int omfs_reserve_block(struct super_block *sb, sector_t block); 64extern int omfs_reserve_block(struct super_block *sb, sector_t block);
65extern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino); 65extern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino);
66extern int omfs_sync_inode(struct inode *inode); 66extern int omfs_sync_inode(struct inode *inode);
diff --git a/fs/open.c b/fs/open.c
index 22c41b543f2d..77becc041149 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -456,7 +456,7 @@ static int chmod_common(struct path *path, umode_t mode)
456 if (error) 456 if (error)
457 return error; 457 return error;
458 mutex_lock(&inode->i_mutex); 458 mutex_lock(&inode->i_mutex);
459 error = security_path_chmod(path->dentry, path->mnt, mode); 459 error = security_path_chmod(path, mode);
460 if (error) 460 if (error)
461 goto out_unlock; 461 goto out_unlock;
462 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); 462 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
@@ -468,7 +468,7 @@ out_unlock:
468 return error; 468 return error;
469} 469}
470 470
471SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode) 471SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
472{ 472{
473 struct file * file; 473 struct file * file;
474 int err = -EBADF; 474 int err = -EBADF;
@@ -482,7 +482,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode)
482 return err; 482 return err;
483} 483}
484 484
485SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode) 485SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, umode_t, mode)
486{ 486{
487 struct path path; 487 struct path path;
488 int error; 488 int error;
@@ -495,7 +495,7 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode)
495 return error; 495 return error;
496} 496}
497 497
498SYSCALL_DEFINE2(chmod, const char __user *, filename, mode_t, mode) 498SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode)
499{ 499{
500 return sys_fchmodat(AT_FDCWD, filename, mode); 500 return sys_fchmodat(AT_FDCWD, filename, mode);
501} 501}
@@ -608,7 +608,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group)
608 dentry = file->f_path.dentry; 608 dentry = file->f_path.dentry;
609 audit_inode(NULL, dentry); 609 audit_inode(NULL, dentry);
610 error = chown_common(&file->f_path, user, group); 610 error = chown_common(&file->f_path, user, group);
611 mnt_drop_write(file->f_path.mnt); 611 mnt_drop_write_file(file);
612out_fput: 612out_fput:
613 fput(file); 613 fput(file);
614out: 614out:
@@ -877,7 +877,7 @@ void fd_install(unsigned int fd, struct file *file)
877 877
878EXPORT_SYMBOL(fd_install); 878EXPORT_SYMBOL(fd_install);
879 879
880static inline int build_open_flags(int flags, int mode, struct open_flags *op) 880static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op)
881{ 881{
882 int lookup_flags = 0; 882 int lookup_flags = 0;
883 int acc_mode; 883 int acc_mode;
@@ -948,7 +948,7 @@ static inline int build_open_flags(int flags, int mode, struct open_flags *op)
948 * have to. But in generally you should not do this, so please move 948 * have to. But in generally you should not do this, so please move
949 * along, nothing to see here.. 949 * along, nothing to see here..
950 */ 950 */
951struct file *filp_open(const char *filename, int flags, int mode) 951struct file *filp_open(const char *filename, int flags, umode_t mode)
952{ 952{
953 struct open_flags op; 953 struct open_flags op;
954 int lookup = build_open_flags(flags, mode, &op); 954 int lookup = build_open_flags(flags, mode, &op);
@@ -970,7 +970,7 @@ struct file *file_open_root(struct dentry *dentry, struct vfsmount *mnt,
970} 970}
971EXPORT_SYMBOL(file_open_root); 971EXPORT_SYMBOL(file_open_root);
972 972
973long do_sys_open(int dfd, const char __user *filename, int flags, int mode) 973long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
974{ 974{
975 struct open_flags op; 975 struct open_flags op;
976 int lookup = build_open_flags(flags, mode, &op); 976 int lookup = build_open_flags(flags, mode, &op);
@@ -994,7 +994,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
994 return fd; 994 return fd;
995} 995}
996 996
997SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode) 997SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
998{ 998{
999 long ret; 999 long ret;
1000 1000
@@ -1008,7 +1008,7 @@ SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode)
1008} 1008}
1009 1009
1010SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, 1010SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
1011 int, mode) 1011 umode_t, mode)
1012{ 1012{
1013 long ret; 1013 long ret;
1014 1014
@@ -1027,7 +1027,7 @@ SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
1027 * For backward compatibility? Maybe this should be moved 1027 * For backward compatibility? Maybe this should be moved
1028 * into arch/i386 instead? 1028 * into arch/i386 instead?
1029 */ 1029 */
1030SYSCALL_DEFINE2(creat, const char __user *, pathname, int, mode) 1030SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, mode)
1031{ 1031{
1032 return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode); 1032 return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
1033} 1033}
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index e4e0ff7962e2..a88c03bc749d 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -346,7 +346,6 @@ static struct inode *openprom_alloc_inode(struct super_block *sb)
346static void openprom_i_callback(struct rcu_head *head) 346static void openprom_i_callback(struct rcu_head *head)
347{ 347{
348 struct inode *inode = container_of(head, struct inode, i_rcu); 348 struct inode *inode = container_of(head, struct inode, i_rcu);
349 INIT_LIST_HEAD(&inode->i_dentry);
350 kmem_cache_free(op_inode_cachep, OP_I(inode)); 349 kmem_cache_free(op_inode_cachep, OP_I(inode));
351} 350}
352 351
diff --git a/fs/partitions/Kconfig b/fs/partitions/Kconfig
deleted file mode 100644
index cb5f0a3f1b03..000000000000
--- a/fs/partitions/Kconfig
+++ /dev/null
@@ -1,251 +0,0 @@
1#
2# Partition configuration
3#
4config PARTITION_ADVANCED
5 bool "Advanced partition selection"
6 help
7 Say Y here if you would like to use hard disks under Linux which
8 were partitioned under an operating system running on a different
9 architecture than your Linux system.
10
11 Note that the answer to this question won't directly affect the
12 kernel: saying N will just cause the configurator to skip all
13 the questions about foreign partitioning schemes.
14
15 If unsure, say N.
16
17config ACORN_PARTITION
18 bool "Acorn partition support" if PARTITION_ADVANCED
19 default y if ARCH_ACORN
20 help
21 Support hard disks partitioned under Acorn operating systems.
22
23config ACORN_PARTITION_CUMANA
24 bool "Cumana partition support" if PARTITION_ADVANCED
25 default y if ARCH_ACORN
26 depends on ACORN_PARTITION
27 help
28 Say Y here if you would like to use hard disks under Linux which
29 were partitioned using the Cumana interface on Acorn machines.
30
31config ACORN_PARTITION_EESOX
32 bool "EESOX partition support" if PARTITION_ADVANCED
33 default y if ARCH_ACORN
34 depends on ACORN_PARTITION
35
36config ACORN_PARTITION_ICS
37 bool "ICS partition support" if PARTITION_ADVANCED
38 default y if ARCH_ACORN
39 depends on ACORN_PARTITION
40 help
41 Say Y here if you would like to use hard disks under Linux which
42 were partitioned using the ICS interface on Acorn machines.
43
44config ACORN_PARTITION_ADFS
45 bool "Native filecore partition support" if PARTITION_ADVANCED
46 default y if ARCH_ACORN
47 depends on ACORN_PARTITION
48 help
49 The Acorn Disc Filing System is the standard file system of the
50 RiscOS operating system which runs on Acorn's ARM-based Risc PC
51 systems and the Acorn Archimedes range of machines. If you say
52 `Y' here, Linux will support disk partitions created under ADFS.
53
54config ACORN_PARTITION_POWERTEC
55 bool "PowerTec partition support" if PARTITION_ADVANCED
56 default y if ARCH_ACORN
57 depends on ACORN_PARTITION
58 help
59 Support reading partition tables created on Acorn machines using
60 the PowerTec SCSI drive.
61
62config ACORN_PARTITION_RISCIX
63 bool "RISCiX partition support" if PARTITION_ADVANCED
64 default y if ARCH_ACORN
65 depends on ACORN_PARTITION
66 help
67 Once upon a time, there was a native Unix port for the Acorn series
68 of machines called RISCiX. If you say 'Y' here, Linux will be able
69 to read disks partitioned under RISCiX.
70
71config OSF_PARTITION
72 bool "Alpha OSF partition support" if PARTITION_ADVANCED
73 default y if ALPHA
74 help
75 Say Y here if you would like to use hard disks under Linux which
76 were partitioned on an Alpha machine.
77
78config AMIGA_PARTITION
79 bool "Amiga partition table support" if PARTITION_ADVANCED
80 default y if (AMIGA || AFFS_FS=y)
81 help
82 Say Y here if you would like to use hard disks under Linux which
83 were partitioned under AmigaOS.
84
85config ATARI_PARTITION
86 bool "Atari partition table support" if PARTITION_ADVANCED
87 default y if ATARI
88 help
89 Say Y here if you would like to use hard disks under Linux which
90 were partitioned under the Atari OS.
91
92config IBM_PARTITION
93 bool "IBM disk label and partition support"
94 depends on PARTITION_ADVANCED && S390
95 help
96 Say Y here if you would like to be able to read the hard disk
97 partition table format used by IBM DASD disks operating under CMS.
98 Otherwise, say N.
99
100config MAC_PARTITION
101 bool "Macintosh partition map support" if PARTITION_ADVANCED
102 default y if (MAC || PPC_PMAC)
103 help
104 Say Y here if you would like to use hard disks under Linux which
105 were partitioned on a Macintosh.
106
107config MSDOS_PARTITION
108 bool "PC BIOS (MSDOS partition tables) support" if PARTITION_ADVANCED
109 default y
110 help
111 Say Y here.
112
113config BSD_DISKLABEL
114 bool "BSD disklabel (FreeBSD partition tables) support"
115 depends on PARTITION_ADVANCED && MSDOS_PARTITION
116 help
117 FreeBSD uses its own hard disk partition scheme on your PC. It
118 requires only one entry in the primary partition table of your disk
119 and manages it similarly to DOS extended partitions, putting in its
120 first sector a new partition table in BSD disklabel format. Saying Y
121 here allows you to read these disklabels and further mount FreeBSD
122 partitions from within Linux if you have also said Y to "UFS
123 file system support", above. If you don't know what all this is
124 about, say N.
125
126config MINIX_SUBPARTITION
127 bool "Minix subpartition support"
128 depends on PARTITION_ADVANCED && MSDOS_PARTITION
129 help
130 Minix 2.0.0/2.0.2 subpartition table support for Linux.
131 Say Y here if you want to mount and use Minix 2.0.0/2.0.2
132 subpartitions.
133
134config SOLARIS_X86_PARTITION
135 bool "Solaris (x86) partition table support"
136 depends on PARTITION_ADVANCED && MSDOS_PARTITION
137 help
138 Like most systems, Solaris x86 uses its own hard disk partition
139 table format, incompatible with all others. Saying Y here allows you
140 to read these partition tables and further mount Solaris x86
141 partitions from within Linux if you have also said Y to "UFS
142 file system support", above.
143
144config UNIXWARE_DISKLABEL
145 bool "Unixware slices support"
146 depends on PARTITION_ADVANCED && MSDOS_PARTITION
147 ---help---
148 Like some systems, UnixWare uses its own slice table inside a
149 partition (VTOC - Virtual Table of Contents). Its format is
150 incompatible with all other OSes. Saying Y here allows you to read
151 VTOC and further mount UnixWare partitions read-only from within
152 Linux if you have also said Y to "UFS file system support" or
153 "System V and Coherent file system support", above.
154
155 This is mainly used to carry data from a UnixWare box to your
156 Linux box via a removable medium like magneto-optical, ZIP or
157 removable IDE drives. Note, however, that a good portable way to
158 transport files and directories between unixes (and even other
159 operating systems) is given by the tar program ("man tar" or
160 preferably "info tar").
161
162 If you don't know what all this is about, say N.
163
164config LDM_PARTITION
165 bool "Windows Logical Disk Manager (Dynamic Disk) support"
166 depends on PARTITION_ADVANCED
167 ---help---
168 Say Y here if you would like to use hard disks under Linux which
169 were partitioned using Windows 2000's/XP's or Vista's Logical Disk
170 Manager. They are also known as "Dynamic Disks".
171
172 Note this driver only supports Dynamic Disks with a protective MBR
173 label, i.e. DOS partition table. It does not support GPT labelled
174 Dynamic Disks yet as can be created with Vista.
175
176 Windows 2000 introduced the concept of Dynamic Disks to get around
177 the limitations of the PC's partitioning scheme. The Logical Disk
178 Manager allows the user to repartition a disk and create spanned,
179 mirrored, striped or RAID volumes, all without the need for
180 rebooting.
181
182 Normal partitions are now called Basic Disks under Windows 2000, XP,
183 and Vista.
184
185 For a fuller description read <file:Documentation/ldm.txt>.
186
187 If unsure, say N.
188
189config LDM_DEBUG
190 bool "Windows LDM extra logging"
191 depends on LDM_PARTITION
192 help
193 Say Y here if you would like LDM to log verbosely. This could be
194 helpful if the driver doesn't work as expected and you'd like to
195 report a bug.
196
197 If unsure, say N.
198
199config SGI_PARTITION
200 bool "SGI partition support" if PARTITION_ADVANCED
201 default y if DEFAULT_SGI_PARTITION
202 help
203 Say Y here if you would like to be able to read the hard disk
204 partition table format used by SGI machines.
205
206config ULTRIX_PARTITION
207 bool "Ultrix partition table support" if PARTITION_ADVANCED
208 default y if MACH_DECSTATION
209 help
210 Say Y here if you would like to be able to read the hard disk
211 partition table format used by DEC (now Compaq) Ultrix machines.
212 Otherwise, say N.
213
214config SUN_PARTITION
215 bool "Sun partition tables support" if PARTITION_ADVANCED
216 default y if (SPARC || SUN3 || SUN3X)
217 ---help---
218 Like most systems, SunOS uses its own hard disk partition table
219 format, incompatible with all others. Saying Y here allows you to
220 read these partition tables and further mount SunOS partitions from
221 within Linux if you have also said Y to "UFS file system support",
222 above. This is mainly used to carry data from a SPARC under SunOS to
223 your Linux box via a removable medium like magneto-optical or ZIP
224 drives; note however that a good portable way to transport files and
225 directories between unixes (and even other operating systems) is
226 given by the tar program ("man tar" or preferably "info tar"). If
227 you don't know what all this is about, say N.
228
229config KARMA_PARTITION
230 bool "Karma Partition support"
231 depends on PARTITION_ADVANCED
232 help
233 Say Y here if you would like to mount the Rio Karma MP3 player, as it
234 uses a proprietary partition table.
235
236config EFI_PARTITION
237 bool "EFI GUID Partition support"
238 depends on PARTITION_ADVANCED
239 select CRC32
240 help
241 Say Y here if you would like to use hard disks under Linux which
242 were partitioned using EFI GPT.
243
244config SYSV68_PARTITION
245 bool "SYSV68 partition table support" if PARTITION_ADVANCED
246 default y if VME
247 help
248 Say Y here if you would like to be able to read the hard disk
249 partition table format used by Motorola Delta machines (using
250 sysv68).
251 Otherwise, say N.
diff --git a/fs/partitions/Makefile b/fs/partitions/Makefile
deleted file mode 100644
index 03af8eac51da..000000000000
--- a/fs/partitions/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
1#
2# Makefile for the linux kernel.
3#
4
5obj-$(CONFIG_BLOCK) := check.o
6
7obj-$(CONFIG_ACORN_PARTITION) += acorn.o
8obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
9obj-$(CONFIG_ATARI_PARTITION) += atari.o
10obj-$(CONFIG_MAC_PARTITION) += mac.o
11obj-$(CONFIG_LDM_PARTITION) += ldm.o
12obj-$(CONFIG_MSDOS_PARTITION) += msdos.o
13obj-$(CONFIG_OSF_PARTITION) += osf.o
14obj-$(CONFIG_SGI_PARTITION) += sgi.o
15obj-$(CONFIG_SUN_PARTITION) += sun.o
16obj-$(CONFIG_ULTRIX_PARTITION) += ultrix.o
17obj-$(CONFIG_IBM_PARTITION) += ibm.o
18obj-$(CONFIG_EFI_PARTITION) += efi.o
19obj-$(CONFIG_KARMA_PARTITION) += karma.o
20obj-$(CONFIG_SYSV68_PARTITION) += sysv68.o
diff --git a/fs/partitions/acorn.c b/fs/partitions/acorn.c
deleted file mode 100644
index fbeb697374d5..000000000000
--- a/fs/partitions/acorn.c
+++ /dev/null
@@ -1,556 +0,0 @@
1/*
2 * linux/fs/partitions/acorn.c
3 *
4 * Copyright (c) 1996-2000 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Scan ADFS partitions on hard disk drives. Unfortunately, there
11 * isn't a standard for partitioning drives on Acorn machines, so
12 * every single manufacturer of SCSI and IDE cards created their own
13 * method.
14 */
15#include <linux/buffer_head.h>
16#include <linux/adfs_fs.h>
17
18#include "check.h"
19#include "acorn.h"
20
21/*
22 * Partition types. (Oh for reusability)
23 */
24#define PARTITION_RISCIX_MFM 1
25#define PARTITION_RISCIX_SCSI 2
26#define PARTITION_LINUX 9
27
28#if defined(CONFIG_ACORN_PARTITION_CUMANA) || \
29 defined(CONFIG_ACORN_PARTITION_ADFS)
30static struct adfs_discrecord *
31adfs_partition(struct parsed_partitions *state, char *name, char *data,
32 unsigned long first_sector, int slot)
33{
34 struct adfs_discrecord *dr;
35 unsigned int nr_sects;
36
37 if (adfs_checkbblk(data))
38 return NULL;
39
40 dr = (struct adfs_discrecord *)(data + 0x1c0);
41
42 if (dr->disc_size == 0 && dr->disc_size_high == 0)
43 return NULL;
44
45 nr_sects = (le32_to_cpu(dr->disc_size_high) << 23) |
46 (le32_to_cpu(dr->disc_size) >> 9);
47
48 if (name) {
49 strlcat(state->pp_buf, " [", PAGE_SIZE);
50 strlcat(state->pp_buf, name, PAGE_SIZE);
51 strlcat(state->pp_buf, "]", PAGE_SIZE);
52 }
53 put_partition(state, slot, first_sector, nr_sects);
54 return dr;
55}
56#endif
57
58#ifdef CONFIG_ACORN_PARTITION_RISCIX
59
60struct riscix_part {
61 __le32 start;
62 __le32 length;
63 __le32 one;
64 char name[16];
65};
66
67struct riscix_record {
68 __le32 magic;
69#define RISCIX_MAGIC cpu_to_le32(0x4a657320)
70 __le32 date;
71 struct riscix_part part[8];
72};
73
74#if defined(CONFIG_ACORN_PARTITION_CUMANA) || \
75 defined(CONFIG_ACORN_PARTITION_ADFS)
76static int riscix_partition(struct parsed_partitions *state,
77 unsigned long first_sect, int slot,
78 unsigned long nr_sects)
79{
80 Sector sect;
81 struct riscix_record *rr;
82
83 rr = read_part_sector(state, first_sect, &sect);
84 if (!rr)
85 return -1;
86
87 strlcat(state->pp_buf, " [RISCiX]", PAGE_SIZE);
88
89
90 if (rr->magic == RISCIX_MAGIC) {
91 unsigned long size = nr_sects > 2 ? 2 : nr_sects;
92 int part;
93
94 strlcat(state->pp_buf, " <", PAGE_SIZE);
95
96 put_partition(state, slot++, first_sect, size);
97 for (part = 0; part < 8; part++) {
98 if (rr->part[part].one &&
99 memcmp(rr->part[part].name, "All\0", 4)) {
100 put_partition(state, slot++,
101 le32_to_cpu(rr->part[part].start),
102 le32_to_cpu(rr->part[part].length));
103 strlcat(state->pp_buf, "(", PAGE_SIZE);
104 strlcat(state->pp_buf, rr->part[part].name, PAGE_SIZE);
105 strlcat(state->pp_buf, ")", PAGE_SIZE);
106 }
107 }
108
109 strlcat(state->pp_buf, " >\n", PAGE_SIZE);
110 } else {
111 put_partition(state, slot++, first_sect, nr_sects);
112 }
113
114 put_dev_sector(sect);
115 return slot;
116}
117#endif
118#endif
119
120#define LINUX_NATIVE_MAGIC 0xdeafa1de
121#define LINUX_SWAP_MAGIC 0xdeafab1e
122
123struct linux_part {
124 __le32 magic;
125 __le32 start_sect;
126 __le32 nr_sects;
127};
128
129#if defined(CONFIG_ACORN_PARTITION_CUMANA) || \
130 defined(CONFIG_ACORN_PARTITION_ADFS)
131static int linux_partition(struct parsed_partitions *state,
132 unsigned long first_sect, int slot,
133 unsigned long nr_sects)
134{
135 Sector sect;
136 struct linux_part *linuxp;
137 unsigned long size = nr_sects > 2 ? 2 : nr_sects;
138
139 strlcat(state->pp_buf, " [Linux]", PAGE_SIZE);
140
141 put_partition(state, slot++, first_sect, size);
142
143 linuxp = read_part_sector(state, first_sect, &sect);
144 if (!linuxp)
145 return -1;
146
147 strlcat(state->pp_buf, " <", PAGE_SIZE);
148 while (linuxp->magic == cpu_to_le32(LINUX_NATIVE_MAGIC) ||
149 linuxp->magic == cpu_to_le32(LINUX_SWAP_MAGIC)) {
150 if (slot == state->limit)
151 break;
152 put_partition(state, slot++, first_sect +
153 le32_to_cpu(linuxp->start_sect),
154 le32_to_cpu(linuxp->nr_sects));
155 linuxp ++;
156 }
157 strlcat(state->pp_buf, " >", PAGE_SIZE);
158
159 put_dev_sector(sect);
160 return slot;
161}
162#endif
163
164#ifdef CONFIG_ACORN_PARTITION_CUMANA
165int adfspart_check_CUMANA(struct parsed_partitions *state)
166{
167 unsigned long first_sector = 0;
168 unsigned int start_blk = 0;
169 Sector sect;
170 unsigned char *data;
171 char *name = "CUMANA/ADFS";
172 int first = 1;
173 int slot = 1;
174
175 /*
176 * Try Cumana style partitions - sector 6 contains ADFS boot block
177 * with pointer to next 'drive'.
178 *
179 * There are unknowns in this code - is the 'cylinder number' of the
180 * next partition relative to the start of this one - I'm assuming
181 * it is.
182 *
183 * Also, which ID did Cumana use?
184 *
185 * This is totally unfinished, and will require more work to get it
186 * going. Hence it is totally untested.
187 */
188 do {
189 struct adfs_discrecord *dr;
190 unsigned int nr_sects;
191
192 data = read_part_sector(state, start_blk * 2 + 6, &sect);
193 if (!data)
194 return -1;
195
196 if (slot == state->limit)
197 break;
198
199 dr = adfs_partition(state, name, data, first_sector, slot++);
200 if (!dr)
201 break;
202
203 name = NULL;
204
205 nr_sects = (data[0x1fd] + (data[0x1fe] << 8)) *
206 (dr->heads + (dr->lowsector & 0x40 ? 1 : 0)) *
207 dr->secspertrack;
208
209 if (!nr_sects)
210 break;
211
212 first = 0;
213 first_sector += nr_sects;
214 start_blk += nr_sects >> (BLOCK_SIZE_BITS - 9);
215 nr_sects = 0; /* hmm - should be partition size */
216
217 switch (data[0x1fc] & 15) {
218 case 0: /* No partition / ADFS? */
219 break;
220
221#ifdef CONFIG_ACORN_PARTITION_RISCIX
222 case PARTITION_RISCIX_SCSI:
223 /* RISCiX - we don't know how to find the next one. */
224 slot = riscix_partition(state, first_sector, slot,
225 nr_sects);
226 break;
227#endif
228
229 case PARTITION_LINUX:
230 slot = linux_partition(state, first_sector, slot,
231 nr_sects);
232 break;
233 }
234 put_dev_sector(sect);
235 if (slot == -1)
236 return -1;
237 } while (1);
238 put_dev_sector(sect);
239 return first ? 0 : 1;
240}
241#endif
242
243#ifdef CONFIG_ACORN_PARTITION_ADFS
244/*
245 * Purpose: allocate ADFS partitions.
246 *
247 * Params : hd - pointer to gendisk structure to store partition info.
248 * dev - device number to access.
249 *
250 * Returns: -1 on error, 0 for no ADFS boot sector, 1 for ok.
251 *
252 * Alloc : hda = whole drive
253 * hda1 = ADFS partition on first drive.
254 * hda2 = non-ADFS partition.
255 */
256int adfspart_check_ADFS(struct parsed_partitions *state)
257{
258 unsigned long start_sect, nr_sects, sectscyl, heads;
259 Sector sect;
260 unsigned char *data;
261 struct adfs_discrecord *dr;
262 unsigned char id;
263 int slot = 1;
264
265 data = read_part_sector(state, 6, &sect);
266 if (!data)
267 return -1;
268
269 dr = adfs_partition(state, "ADFS", data, 0, slot++);
270 if (!dr) {
271 put_dev_sector(sect);
272 return 0;
273 }
274
275 heads = dr->heads + ((dr->lowsector >> 6) & 1);
276 sectscyl = dr->secspertrack * heads;
277 start_sect = ((data[0x1fe] << 8) + data[0x1fd]) * sectscyl;
278 id = data[0x1fc] & 15;
279 put_dev_sector(sect);
280
281 /*
282 * Work out start of non-adfs partition.
283 */
284 nr_sects = (state->bdev->bd_inode->i_size >> 9) - start_sect;
285
286 if (start_sect) {
287 switch (id) {
288#ifdef CONFIG_ACORN_PARTITION_RISCIX
289 case PARTITION_RISCIX_SCSI:
290 case PARTITION_RISCIX_MFM:
291 slot = riscix_partition(state, start_sect, slot,
292 nr_sects);
293 break;
294#endif
295
296 case PARTITION_LINUX:
297 slot = linux_partition(state, start_sect, slot,
298 nr_sects);
299 break;
300 }
301 }
302 strlcat(state->pp_buf, "\n", PAGE_SIZE);
303 return 1;
304}
305#endif
306
307#ifdef CONFIG_ACORN_PARTITION_ICS
308
309struct ics_part {
310 __le32 start;
311 __le32 size;
312};
313
314static int adfspart_check_ICSLinux(struct parsed_partitions *state,
315 unsigned long block)
316{
317 Sector sect;
318 unsigned char *data = read_part_sector(state, block, &sect);
319 int result = 0;
320
321 if (data) {
322 if (memcmp(data, "LinuxPart", 9) == 0)
323 result = 1;
324 put_dev_sector(sect);
325 }
326
327 return result;
328}
329
330/*
331 * Check for a valid ICS partition using the checksum.
332 */
333static inline int valid_ics_sector(const unsigned char *data)
334{
335 unsigned long sum;
336 int i;
337
338 for (i = 0, sum = 0x50617274; i < 508; i++)
339 sum += data[i];
340
341 sum -= le32_to_cpu(*(__le32 *)(&data[508]));
342
343 return sum == 0;
344}
345
346/*
347 * Purpose: allocate ICS partitions.
348 * Params : hd - pointer to gendisk structure to store partition info.
349 * dev - device number to access.
350 * Returns: -1 on error, 0 for no ICS table, 1 for partitions ok.
351 * Alloc : hda = whole drive
352 * hda1 = ADFS partition 0 on first drive.
353 * hda2 = ADFS partition 1 on first drive.
354 * ..etc..
355 */
356int adfspart_check_ICS(struct parsed_partitions *state)
357{
358 const unsigned char *data;
359 const struct ics_part *p;
360 int slot;
361 Sector sect;
362
363 /*
364 * Try ICS style partitions - sector 0 contains partition info.
365 */
366 data = read_part_sector(state, 0, &sect);
367 if (!data)
368 return -1;
369
370 if (!valid_ics_sector(data)) {
371 put_dev_sector(sect);
372 return 0;
373 }
374
375 strlcat(state->pp_buf, " [ICS]", PAGE_SIZE);
376
377 for (slot = 1, p = (const struct ics_part *)data; p->size; p++) {
378 u32 start = le32_to_cpu(p->start);
379 s32 size = le32_to_cpu(p->size); /* yes, it's signed. */
380
381 if (slot == state->limit)
382 break;
383
384 /*
385 * Negative sizes tell the RISC OS ICS driver to ignore
386 * this partition - in effect it says that this does not
387 * contain an ADFS filesystem.
388 */
389 if (size < 0) {
390 size = -size;
391
392 /*
393 * Our own extension - We use the first sector
394 * of the partition to identify what type this
395 * partition is. We must not make this visible
396 * to the filesystem.
397 */
398 if (size > 1 && adfspart_check_ICSLinux(state, start)) {
399 start += 1;
400 size -= 1;
401 }
402 }
403
404 if (size)
405 put_partition(state, slot++, start, size);
406 }
407
408 put_dev_sector(sect);
409 strlcat(state->pp_buf, "\n", PAGE_SIZE);
410 return 1;
411}
412#endif
413
414#ifdef CONFIG_ACORN_PARTITION_POWERTEC
415struct ptec_part {
416 __le32 unused1;
417 __le32 unused2;
418 __le32 start;
419 __le32 size;
420 __le32 unused5;
421 char type[8];
422};
423
424static inline int valid_ptec_sector(const unsigned char *data)
425{
426 unsigned char checksum = 0x2a;
427 int i;
428
429 /*
430 * If it looks like a PC/BIOS partition, then it
431 * probably isn't PowerTec.
432 */
433 if (data[510] == 0x55 && data[511] == 0xaa)
434 return 0;
435
436 for (i = 0; i < 511; i++)
437 checksum += data[i];
438
439 return checksum == data[511];
440}
441
442/*
443 * Purpose: allocate ICS partitions.
444 * Params : hd - pointer to gendisk structure to store partition info.
445 * dev - device number to access.
446 * Returns: -1 on error, 0 for no ICS table, 1 for partitions ok.
447 * Alloc : hda = whole drive
448 * hda1 = ADFS partition 0 on first drive.
449 * hda2 = ADFS partition 1 on first drive.
450 * ..etc..
451 */
452int adfspart_check_POWERTEC(struct parsed_partitions *state)
453{
454 Sector sect;
455 const unsigned char *data;
456 const struct ptec_part *p;
457 int slot = 1;
458 int i;
459
460 data = read_part_sector(state, 0, &sect);
461 if (!data)
462 return -1;
463
464 if (!valid_ptec_sector(data)) {
465 put_dev_sector(sect);
466 return 0;
467 }
468
469 strlcat(state->pp_buf, " [POWERTEC]", PAGE_SIZE);
470
471 for (i = 0, p = (const struct ptec_part *)data; i < 12; i++, p++) {
472 u32 start = le32_to_cpu(p->start);
473 u32 size = le32_to_cpu(p->size);
474
475 if (size)
476 put_partition(state, slot++, start, size);
477 }
478
479 put_dev_sector(sect);
480 strlcat(state->pp_buf, "\n", PAGE_SIZE);
481 return 1;
482}
483#endif
484
485#ifdef CONFIG_ACORN_PARTITION_EESOX
486struct eesox_part {
487 char magic[6];
488 char name[10];
489 __le32 start;
490 __le32 unused6;
491 __le32 unused7;
492 __le32 unused8;
493};
494
495/*
496 * Guess who created this format?
497 */
498static const char eesox_name[] = {
499 'N', 'e', 'i', 'l', ' ',
500 'C', 'r', 'i', 't', 'c', 'h', 'e', 'l', 'l', ' ', ' '
501};
502
503/*
504 * EESOX SCSI partition format.
505 *
506 * This is a goddamned awful partition format. We don't seem to store
507 * the size of the partition in this table, only the start addresses.
508 *
509 * There are two possibilities where the size comes from:
510 * 1. The individual ADFS boot block entries that are placed on the disk.
511 * 2. The start address of the next entry.
512 */
513int adfspart_check_EESOX(struct parsed_partitions *state)
514{
515 Sector sect;
516 const unsigned char *data;
517 unsigned char buffer[256];
518 struct eesox_part *p;
519 sector_t start = 0;
520 int i, slot = 1;
521
522 data = read_part_sector(state, 7, &sect);
523 if (!data)
524 return -1;
525
526 /*
527 * "Decrypt" the partition table. God knows why...
528 */
529 for (i = 0; i < 256; i++)
530 buffer[i] = data[i] ^ eesox_name[i & 15];
531
532 put_dev_sector(sect);
533
534 for (i = 0, p = (struct eesox_part *)buffer; i < 8; i++, p++) {
535 sector_t next;
536
537 if (memcmp(p->magic, "Eesox", 6))
538 break;
539
540 next = le32_to_cpu(p->start);
541 if (i)
542 put_partition(state, slot++, start, next - start);
543 start = next;
544 }
545
546 if (i != 0) {
547 sector_t size;
548
549 size = get_capacity(state->bdev->bd_disk);
550 put_partition(state, slot++, start, size - start);
551 strlcat(state->pp_buf, "\n", PAGE_SIZE);
552 }
553
554 return i ? 1 : 0;
555}
556#endif
diff --git a/fs/partitions/acorn.h b/fs/partitions/acorn.h
deleted file mode 100644
index ede828529692..000000000000
--- a/fs/partitions/acorn.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/*
2 * linux/fs/partitions/acorn.h
3 *
4 * Copyright (C) 1996-2001 Russell King.
5 *
6 * I _hate_ this partitioning mess - why can't we have one defined
7 * format, and everyone stick to it?
8 */
9
10int adfspart_check_CUMANA(struct parsed_partitions *state);
11int adfspart_check_ADFS(struct parsed_partitions *state);
12int adfspart_check_ICS(struct parsed_partitions *state);
13int adfspart_check_POWERTEC(struct parsed_partitions *state);
14int adfspart_check_EESOX(struct parsed_partitions *state);
diff --git a/fs/partitions/amiga.c b/fs/partitions/amiga.c
deleted file mode 100644
index 70cbf44a1560..000000000000
--- a/fs/partitions/amiga.c
+++ /dev/null
@@ -1,139 +0,0 @@
1/*
2 * fs/partitions/amiga.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 *
6 * Copyright (C) 1991-1998 Linus Torvalds
7 * Re-organised Feb 1998 Russell King
8 */
9
10#include <linux/types.h>
11#include <linux/affs_hardblocks.h>
12
13#include "check.h"
14#include "amiga.h"
15
16static __inline__ u32
17checksum_block(__be32 *m, int size)
18{
19 u32 sum = 0;
20
21 while (size--)
22 sum += be32_to_cpu(*m++);
23 return sum;
24}
25
26int amiga_partition(struct parsed_partitions *state)
27{
28 Sector sect;
29 unsigned char *data;
30 struct RigidDiskBlock *rdb;
31 struct PartitionBlock *pb;
32 int start_sect, nr_sects, blk, part, res = 0;
33 int blksize = 1; /* Multiplier for disk block size */
34 int slot = 1;
35 char b[BDEVNAME_SIZE];
36
37 for (blk = 0; ; blk++, put_dev_sector(sect)) {
38 if (blk == RDB_ALLOCATION_LIMIT)
39 goto rdb_done;
40 data = read_part_sector(state, blk, &sect);
41 if (!data) {
42 if (warn_no_part)
43 printk("Dev %s: unable to read RDB block %d\n",
44 bdevname(state->bdev, b), blk);
45 res = -1;
46 goto rdb_done;
47 }
48 if (*(__be32 *)data != cpu_to_be32(IDNAME_RIGIDDISK))
49 continue;
50
51 rdb = (struct RigidDiskBlock *)data;
52 if (checksum_block((__be32 *)data, be32_to_cpu(rdb->rdb_SummedLongs) & 0x7F) == 0)
53 break;
54 /* Try again with 0xdc..0xdf zeroed, Windows might have
55 * trashed it.
56 */
57 *(__be32 *)(data+0xdc) = 0;
58 if (checksum_block((__be32 *)data,
59 be32_to_cpu(rdb->rdb_SummedLongs) & 0x7F)==0) {
60 printk("Warning: Trashed word at 0xd0 in block %d "
61 "ignored in checksum calculation\n",blk);
62 break;
63 }
64
65 printk("Dev %s: RDB in block %d has bad checksum\n",
66 bdevname(state->bdev, b), blk);
67 }
68
69 /* blksize is blocks per 512 byte standard block */
70 blksize = be32_to_cpu( rdb->rdb_BlockBytes ) / 512;
71
72 {
73 char tmp[7 + 10 + 1 + 1];
74
75 /* Be more informative */
76 snprintf(tmp, sizeof(tmp), " RDSK (%d)", blksize * 512);
77 strlcat(state->pp_buf, tmp, PAGE_SIZE);
78 }
79 blk = be32_to_cpu(rdb->rdb_PartitionList);
80 put_dev_sector(sect);
81 for (part = 1; blk>0 && part<=16; part++, put_dev_sector(sect)) {
82 blk *= blksize; /* Read in terms partition table understands */
83 data = read_part_sector(state, blk, &sect);
84 if (!data) {
85 if (warn_no_part)
86 printk("Dev %s: unable to read partition block %d\n",
87 bdevname(state->bdev, b), blk);
88 res = -1;
89 goto rdb_done;
90 }
91 pb = (struct PartitionBlock *)data;
92 blk = be32_to_cpu(pb->pb_Next);
93 if (pb->pb_ID != cpu_to_be32(IDNAME_PARTITION))
94 continue;
95 if (checksum_block((__be32 *)pb, be32_to_cpu(pb->pb_SummedLongs) & 0x7F) != 0 )
96 continue;
97
98 /* Tell Kernel about it */
99
100 nr_sects = (be32_to_cpu(pb->pb_Environment[10]) + 1 -
101 be32_to_cpu(pb->pb_Environment[9])) *
102 be32_to_cpu(pb->pb_Environment[3]) *
103 be32_to_cpu(pb->pb_Environment[5]) *
104 blksize;
105 if (!nr_sects)
106 continue;
107 start_sect = be32_to_cpu(pb->pb_Environment[9]) *
108 be32_to_cpu(pb->pb_Environment[3]) *
109 be32_to_cpu(pb->pb_Environment[5]) *
110 blksize;
111 put_partition(state,slot++,start_sect,nr_sects);
112 {
113 /* Be even more informative to aid mounting */
114 char dostype[4];
115 char tmp[42];
116
117 __be32 *dt = (__be32 *)dostype;
118 *dt = pb->pb_Environment[16];
119 if (dostype[3] < ' ')
120 snprintf(tmp, sizeof(tmp), " (%c%c%c^%c)",
121 dostype[0], dostype[1],
122 dostype[2], dostype[3] + '@' );
123 else
124 snprintf(tmp, sizeof(tmp), " (%c%c%c%c)",
125 dostype[0], dostype[1],
126 dostype[2], dostype[3]);
127 strlcat(state->pp_buf, tmp, PAGE_SIZE);
128 snprintf(tmp, sizeof(tmp), "(res %d spb %d)",
129 be32_to_cpu(pb->pb_Environment[6]),
130 be32_to_cpu(pb->pb_Environment[4]));
131 strlcat(state->pp_buf, tmp, PAGE_SIZE);
132 }
133 res = 1;
134 }
135 strlcat(state->pp_buf, "\n", PAGE_SIZE);
136
137rdb_done:
138 return res;
139}
diff --git a/fs/partitions/amiga.h b/fs/partitions/amiga.h
deleted file mode 100644
index d094585cadaa..000000000000
--- a/fs/partitions/amiga.h
+++ /dev/null
@@ -1,6 +0,0 @@
1/*
2 * fs/partitions/amiga.h
3 */
4
5int amiga_partition(struct parsed_partitions *state);
6
diff --git a/fs/partitions/atari.c b/fs/partitions/atari.c
deleted file mode 100644
index 9875b05e80a2..000000000000
--- a/fs/partitions/atari.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/*
2 * fs/partitions/atari.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 *
6 * Copyright (C) 1991-1998 Linus Torvalds
7 * Re-organised Feb 1998 Russell King
8 */
9
10#include <linux/ctype.h>
11#include "check.h"
12#include "atari.h"
13
14/* ++guenther: this should be settable by the user ("make config")?.
15 */
16#define ICD_PARTS
17
18/* check if a partition entry looks valid -- Atari format is assumed if at
19 least one of the primary entries is ok this way */
20#define VALID_PARTITION(pi,hdsiz) \
21 (((pi)->flg & 1) && \
22 isalnum((pi)->id[0]) && isalnum((pi)->id[1]) && isalnum((pi)->id[2]) && \
23 be32_to_cpu((pi)->st) <= (hdsiz) && \
24 be32_to_cpu((pi)->st) + be32_to_cpu((pi)->siz) <= (hdsiz))
25
26static inline int OK_id(char *s)
27{
28 return memcmp (s, "GEM", 3) == 0 || memcmp (s, "BGM", 3) == 0 ||
29 memcmp (s, "LNX", 3) == 0 || memcmp (s, "SWP", 3) == 0 ||
30 memcmp (s, "RAW", 3) == 0 ;
31}
32
33int atari_partition(struct parsed_partitions *state)
34{
35 Sector sect;
36 struct rootsector *rs;
37 struct partition_info *pi;
38 u32 extensect;
39 u32 hd_size;
40 int slot;
41#ifdef ICD_PARTS
42 int part_fmt = 0; /* 0:unknown, 1:AHDI, 2:ICD/Supra */
43#endif
44
45 rs = read_part_sector(state, 0, &sect);
46 if (!rs)
47 return -1;
48
49 /* Verify this is an Atari rootsector: */
50 hd_size = state->bdev->bd_inode->i_size >> 9;
51 if (!VALID_PARTITION(&rs->part[0], hd_size) &&
52 !VALID_PARTITION(&rs->part[1], hd_size) &&
53 !VALID_PARTITION(&rs->part[2], hd_size) &&
54 !VALID_PARTITION(&rs->part[3], hd_size)) {
55 /*
56 * if there's no valid primary partition, assume that no Atari
57 * format partition table (there's no reliable magic or the like
58 * :-()
59 */
60 put_dev_sector(sect);
61 return 0;
62 }
63
64 pi = &rs->part[0];
65 strlcat(state->pp_buf, " AHDI", PAGE_SIZE);
66 for (slot = 1; pi < &rs->part[4] && slot < state->limit; slot++, pi++) {
67 struct rootsector *xrs;
68 Sector sect2;
69 ulong partsect;
70
71 if ( !(pi->flg & 1) )
72 continue;
73 /* active partition */
74 if (memcmp (pi->id, "XGM", 3) != 0) {
75 /* we don't care about other id's */
76 put_partition (state, slot, be32_to_cpu(pi->st),
77 be32_to_cpu(pi->siz));
78 continue;
79 }
80 /* extension partition */
81#ifdef ICD_PARTS
82 part_fmt = 1;
83#endif
84 strlcat(state->pp_buf, " XGM<", PAGE_SIZE);
85 partsect = extensect = be32_to_cpu(pi->st);
86 while (1) {
87 xrs = read_part_sector(state, partsect, &sect2);
88 if (!xrs) {
89 printk (" block %ld read failed\n", partsect);
90 put_dev_sector(sect);
91 return -1;
92 }
93
94 /* ++roman: sanity check: bit 0 of flg field must be set */
95 if (!(xrs->part[0].flg & 1)) {
96 printk( "\nFirst sub-partition in extended partition is not valid!\n" );
97 put_dev_sector(sect2);
98 break;
99 }
100
101 put_partition(state, slot,
102 partsect + be32_to_cpu(xrs->part[0].st),
103 be32_to_cpu(xrs->part[0].siz));
104
105 if (!(xrs->part[1].flg & 1)) {
106 /* end of linked partition list */
107 put_dev_sector(sect2);
108 break;
109 }
110 if (memcmp( xrs->part[1].id, "XGM", 3 ) != 0) {
111 printk("\nID of extended partition is not XGM!\n");
112 put_dev_sector(sect2);
113 break;
114 }
115
116 partsect = be32_to_cpu(xrs->part[1].st) + extensect;
117 put_dev_sector(sect2);
118 if (++slot == state->limit) {
119 printk( "\nMaximum number of partitions reached!\n" );
120 break;
121 }
122 }
123 strlcat(state->pp_buf, " >", PAGE_SIZE);
124 }
125#ifdef ICD_PARTS
126 if ( part_fmt!=1 ) { /* no extended partitions -> test ICD-format */
127 pi = &rs->icdpart[0];
128 /* sanity check: no ICD format if first partition invalid */
129 if (OK_id(pi->id)) {
130 strlcat(state->pp_buf, " ICD<", PAGE_SIZE);
131 for (; pi < &rs->icdpart[8] && slot < state->limit; slot++, pi++) {
132 /* accept only GEM,BGM,RAW,LNX,SWP partitions */
133 if (!((pi->flg & 1) && OK_id(pi->id)))
134 continue;
135 part_fmt = 2;
136 put_partition (state, slot,
137 be32_to_cpu(pi->st),
138 be32_to_cpu(pi->siz));
139 }
140 strlcat(state->pp_buf, " >", PAGE_SIZE);
141 }
142 }
143#endif
144 put_dev_sector(sect);
145
146 strlcat(state->pp_buf, "\n", PAGE_SIZE);
147
148 return 1;
149}
diff --git a/fs/partitions/atari.h b/fs/partitions/atari.h
deleted file mode 100644
index fe2d32a89f36..000000000000
--- a/fs/partitions/atari.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * fs/partitions/atari.h
3 * Moved by Russell King from:
4 *
5 * linux/include/linux/atari_rootsec.h
6 * definitions for Atari Rootsector layout
7 * by Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de)
8 *
9 * modified for ICD/Supra partitioning scheme restricted to at most 12
10 * partitions
11 * by Guenther Kelleter (guenther@pool.informatik.rwth-aachen.de)
12 */
13
14struct partition_info
15{
16 u8 flg; /* bit 0: active; bit 7: bootable */
17 char id[3]; /* "GEM", "BGM", "XGM", or other */
18 __be32 st; /* start of partition */
19 __be32 siz; /* length of partition */
20};
21
22struct rootsector
23{
24 char unused[0x156]; /* room for boot code */
25 struct partition_info icdpart[8]; /* info for ICD-partitions 5..12 */
26 char unused2[0xc];
27 u32 hd_siz; /* size of disk in blocks */
28 struct partition_info part[4];
29 u32 bsl_st; /* start of bad sector list */
30 u32 bsl_cnt; /* length of bad sector list */
31 u16 checksum; /* checksum for bootable disks */
32} __attribute__((__packed__));
33
34int atari_partition(struct parsed_partitions *state);
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
deleted file mode 100644
index e3c63d1c5e13..000000000000
--- a/fs/partitions/check.c
+++ /dev/null
@@ -1,687 +0,0 @@
1/*
2 * fs/partitions/check.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 * Copyright (C) 1991-1998 Linus Torvalds
6 * Re-organised Feb 1998 Russell King
7 *
8 * We now have independent partition support from the
9 * block drivers, which allows all the partition code to
10 * be grouped in one location, and it to be mostly self
11 * contained.
12 *
13 * Added needed MAJORS for new pairs, {hdi,hdj}, {hdk,hdl}
14 */
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/fs.h>
19#include <linux/slab.h>
20#include <linux/kmod.h>
21#include <linux/ctype.h>
22#include <linux/genhd.h>
23#include <linux/blktrace_api.h>
24
25#include "check.h"
26
27#include "acorn.h"
28#include "amiga.h"
29#include "atari.h"
30#include "ldm.h"
31#include "mac.h"
32#include "msdos.h"
33#include "osf.h"
34#include "sgi.h"
35#include "sun.h"
36#include "ibm.h"
37#include "ultrix.h"
38#include "efi.h"
39#include "karma.h"
40#include "sysv68.h"
41
42#ifdef CONFIG_BLK_DEV_MD
43extern void md_autodetect_dev(dev_t dev);
44#endif
45
46int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
47
48static int (*check_part[])(struct parsed_partitions *) = {
49 /*
50 * Probe partition formats with tables at disk address 0
51 * that also have an ADFS boot block at 0xdc0.
52 */
53#ifdef CONFIG_ACORN_PARTITION_ICS
54 adfspart_check_ICS,
55#endif
56#ifdef CONFIG_ACORN_PARTITION_POWERTEC
57 adfspart_check_POWERTEC,
58#endif
59#ifdef CONFIG_ACORN_PARTITION_EESOX
60 adfspart_check_EESOX,
61#endif
62
63 /*
64 * Now move on to formats that only have partition info at
65 * disk address 0xdc0. Since these may also have stale
66 * PC/BIOS partition tables, they need to come before
67 * the msdos entry.
68 */
69#ifdef CONFIG_ACORN_PARTITION_CUMANA
70 adfspart_check_CUMANA,
71#endif
72#ifdef CONFIG_ACORN_PARTITION_ADFS
73 adfspart_check_ADFS,
74#endif
75
76#ifdef CONFIG_EFI_PARTITION
77 efi_partition, /* this must come before msdos */
78#endif
79#ifdef CONFIG_SGI_PARTITION
80 sgi_partition,
81#endif
82#ifdef CONFIG_LDM_PARTITION
83 ldm_partition, /* this must come before msdos */
84#endif
85#ifdef CONFIG_MSDOS_PARTITION
86 msdos_partition,
87#endif
88#ifdef CONFIG_OSF_PARTITION
89 osf_partition,
90#endif
91#ifdef CONFIG_SUN_PARTITION
92 sun_partition,
93#endif
94#ifdef CONFIG_AMIGA_PARTITION
95 amiga_partition,
96#endif
97#ifdef CONFIG_ATARI_PARTITION
98 atari_partition,
99#endif
100#ifdef CONFIG_MAC_PARTITION
101 mac_partition,
102#endif
103#ifdef CONFIG_ULTRIX_PARTITION
104 ultrix_partition,
105#endif
106#ifdef CONFIG_IBM_PARTITION
107 ibm_partition,
108#endif
109#ifdef CONFIG_KARMA_PARTITION
110 karma_partition,
111#endif
112#ifdef CONFIG_SYSV68_PARTITION
113 sysv68_partition,
114#endif
115 NULL
116};
117
118/*
119 * disk_name() is used by partition check code and the genhd driver.
120 * It formats the devicename of the indicated disk into
121 * the supplied buffer (of size at least 32), and returns
122 * a pointer to that same buffer (for convenience).
123 */
124
125char *disk_name(struct gendisk *hd, int partno, char *buf)
126{
127 if (!partno)
128 snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name);
129 else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1]))
130 snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, partno);
131 else
132 snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, partno);
133
134 return buf;
135}
136
137const char *bdevname(struct block_device *bdev, char *buf)
138{
139 return disk_name(bdev->bd_disk, bdev->bd_part->partno, buf);
140}
141
142EXPORT_SYMBOL(bdevname);
143
144/*
145 * There's very little reason to use this, you should really
146 * have a struct block_device just about everywhere and use
147 * bdevname() instead.
148 */
149const char *__bdevname(dev_t dev, char *buffer)
150{
151 scnprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)",
152 MAJOR(dev), MINOR(dev));
153 return buffer;
154}
155
156EXPORT_SYMBOL(__bdevname);
157
158static struct parsed_partitions *
159check_partition(struct gendisk *hd, struct block_device *bdev)
160{
161 struct parsed_partitions *state;
162 int i, res, err;
163
164 state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
165 if (!state)
166 return NULL;
167 state->pp_buf = (char *)__get_free_page(GFP_KERNEL);
168 if (!state->pp_buf) {
169 kfree(state);
170 return NULL;
171 }
172 state->pp_buf[0] = '\0';
173
174 state->bdev = bdev;
175 disk_name(hd, 0, state->name);
176 snprintf(state->pp_buf, PAGE_SIZE, " %s:", state->name);
177 if (isdigit(state->name[strlen(state->name)-1]))
178 sprintf(state->name, "p");
179
180 state->limit = disk_max_parts(hd);
181 i = res = err = 0;
182 while (!res && check_part[i]) {
183 memset(&state->parts, 0, sizeof(state->parts));
184 res = check_part[i++](state);
185 if (res < 0) {
186 /* We have hit an I/O error which we don't report now.
187 * But record it, and let the others do their job.
188 */
189 err = res;
190 res = 0;
191 }
192
193 }
194 if (res > 0) {
195 printk(KERN_INFO "%s", state->pp_buf);
196
197 free_page((unsigned long)state->pp_buf);
198 return state;
199 }
200 if (state->access_beyond_eod)
201 err = -ENOSPC;
202 if (err)
203 /* The partition is unrecognized. So report I/O errors if there were any */
204 res = err;
205 if (!res)
206 strlcat(state->pp_buf, " unknown partition table\n", PAGE_SIZE);
207 else if (warn_no_part)
208 strlcat(state->pp_buf, " unable to read partition table\n", PAGE_SIZE);
209
210 printk(KERN_INFO "%s", state->pp_buf);
211
212 free_page((unsigned long)state->pp_buf);
213 kfree(state);
214 return ERR_PTR(res);
215}
216
217static ssize_t part_partition_show(struct device *dev,
218 struct device_attribute *attr, char *buf)
219{
220 struct hd_struct *p = dev_to_part(dev);
221
222 return sprintf(buf, "%d\n", p->partno);
223}
224
225static ssize_t part_start_show(struct device *dev,
226 struct device_attribute *attr, char *buf)
227{
228 struct hd_struct *p = dev_to_part(dev);
229
230 return sprintf(buf, "%llu\n",(unsigned long long)p->start_sect);
231}
232
233ssize_t part_size_show(struct device *dev,
234 struct device_attribute *attr, char *buf)
235{
236 struct hd_struct *p = dev_to_part(dev);
237 return sprintf(buf, "%llu\n",(unsigned long long)p->nr_sects);
238}
239
240static ssize_t part_ro_show(struct device *dev,
241 struct device_attribute *attr, char *buf)
242{
243 struct hd_struct *p = dev_to_part(dev);
244 return sprintf(buf, "%d\n", p->policy ? 1 : 0);
245}
246
247static ssize_t part_alignment_offset_show(struct device *dev,
248 struct device_attribute *attr, char *buf)
249{
250 struct hd_struct *p = dev_to_part(dev);
251 return sprintf(buf, "%llu\n", (unsigned long long)p->alignment_offset);
252}
253
254static ssize_t part_discard_alignment_show(struct device *dev,
255 struct device_attribute *attr, char *buf)
256{
257 struct hd_struct *p = dev_to_part(dev);
258 return sprintf(buf, "%u\n", p->discard_alignment);
259}
260
261ssize_t part_stat_show(struct device *dev,
262 struct device_attribute *attr, char *buf)
263{
264 struct hd_struct *p = dev_to_part(dev);
265 int cpu;
266
267 cpu = part_stat_lock();
268 part_round_stats(cpu, p);
269 part_stat_unlock();
270 return sprintf(buf,
271 "%8lu %8lu %8llu %8u "
272 "%8lu %8lu %8llu %8u "
273 "%8u %8u %8u"
274 "\n",
275 part_stat_read(p, ios[READ]),
276 part_stat_read(p, merges[READ]),
277 (unsigned long long)part_stat_read(p, sectors[READ]),
278 jiffies_to_msecs(part_stat_read(p, ticks[READ])),
279 part_stat_read(p, ios[WRITE]),
280 part_stat_read(p, merges[WRITE]),
281 (unsigned long long)part_stat_read(p, sectors[WRITE]),
282 jiffies_to_msecs(part_stat_read(p, ticks[WRITE])),
283 part_in_flight(p),
284 jiffies_to_msecs(part_stat_read(p, io_ticks)),
285 jiffies_to_msecs(part_stat_read(p, time_in_queue)));
286}
287
288ssize_t part_inflight_show(struct device *dev,
289 struct device_attribute *attr, char *buf)
290{
291 struct hd_struct *p = dev_to_part(dev);
292
293 return sprintf(buf, "%8u %8u\n", atomic_read(&p->in_flight[0]),
294 atomic_read(&p->in_flight[1]));
295}
296
297#ifdef CONFIG_FAIL_MAKE_REQUEST
298ssize_t part_fail_show(struct device *dev,
299 struct device_attribute *attr, char *buf)
300{
301 struct hd_struct *p = dev_to_part(dev);
302
303 return sprintf(buf, "%d\n", p->make_it_fail);
304}
305
306ssize_t part_fail_store(struct device *dev,
307 struct device_attribute *attr,
308 const char *buf, size_t count)
309{
310 struct hd_struct *p = dev_to_part(dev);
311 int i;
312
313 if (count > 0 && sscanf(buf, "%d", &i) > 0)
314 p->make_it_fail = (i == 0) ? 0 : 1;
315
316 return count;
317}
318#endif
319
320static DEVICE_ATTR(partition, S_IRUGO, part_partition_show, NULL);
321static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL);
322static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL);
323static DEVICE_ATTR(ro, S_IRUGO, part_ro_show, NULL);
324static DEVICE_ATTR(alignment_offset, S_IRUGO, part_alignment_offset_show, NULL);
325static DEVICE_ATTR(discard_alignment, S_IRUGO, part_discard_alignment_show,
326 NULL);
327static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL);
328static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL);
329#ifdef CONFIG_FAIL_MAKE_REQUEST
330static struct device_attribute dev_attr_fail =
331 __ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store);
332#endif
333
334static struct attribute *part_attrs[] = {
335 &dev_attr_partition.attr,
336 &dev_attr_start.attr,
337 &dev_attr_size.attr,
338 &dev_attr_ro.attr,
339 &dev_attr_alignment_offset.attr,
340 &dev_attr_discard_alignment.attr,
341 &dev_attr_stat.attr,
342 &dev_attr_inflight.attr,
343#ifdef CONFIG_FAIL_MAKE_REQUEST
344 &dev_attr_fail.attr,
345#endif
346 NULL
347};
348
349static struct attribute_group part_attr_group = {
350 .attrs = part_attrs,
351};
352
353static const struct attribute_group *part_attr_groups[] = {
354 &part_attr_group,
355#ifdef CONFIG_BLK_DEV_IO_TRACE
356 &blk_trace_attr_group,
357#endif
358 NULL
359};
360
361static void part_release(struct device *dev)
362{
363 struct hd_struct *p = dev_to_part(dev);
364 free_part_stats(p);
365 free_part_info(p);
366 kfree(p);
367}
368
369struct device_type part_type = {
370 .name = "partition",
371 .groups = part_attr_groups,
372 .release = part_release,
373};
374
375static void delete_partition_rcu_cb(struct rcu_head *head)
376{
377 struct hd_struct *part = container_of(head, struct hd_struct, rcu_head);
378
379 part->start_sect = 0;
380 part->nr_sects = 0;
381 part_stat_set_all(part, 0);
382 put_device(part_to_dev(part));
383}
384
385void __delete_partition(struct hd_struct *part)
386{
387 call_rcu(&part->rcu_head, delete_partition_rcu_cb);
388}
389
390void delete_partition(struct gendisk *disk, int partno)
391{
392 struct disk_part_tbl *ptbl = disk->part_tbl;
393 struct hd_struct *part;
394
395 if (partno >= ptbl->len)
396 return;
397
398 part = ptbl->part[partno];
399 if (!part)
400 return;
401
402 blk_free_devt(part_devt(part));
403 rcu_assign_pointer(ptbl->part[partno], NULL);
404 rcu_assign_pointer(ptbl->last_lookup, NULL);
405 kobject_put(part->holder_dir);
406 device_del(part_to_dev(part));
407
408 hd_struct_put(part);
409}
410
411static ssize_t whole_disk_show(struct device *dev,
412 struct device_attribute *attr, char *buf)
413{
414 return 0;
415}
416static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
417 whole_disk_show, NULL);
418
419struct hd_struct *add_partition(struct gendisk *disk, int partno,
420 sector_t start, sector_t len, int flags,
421 struct partition_meta_info *info)
422{
423 struct hd_struct *p;
424 dev_t devt = MKDEV(0, 0);
425 struct device *ddev = disk_to_dev(disk);
426 struct device *pdev;
427 struct disk_part_tbl *ptbl;
428 const char *dname;
429 int err;
430
431 err = disk_expand_part_tbl(disk, partno);
432 if (err)
433 return ERR_PTR(err);
434 ptbl = disk->part_tbl;
435
436 if (ptbl->part[partno])
437 return ERR_PTR(-EBUSY);
438
439 p = kzalloc(sizeof(*p), GFP_KERNEL);
440 if (!p)
441 return ERR_PTR(-EBUSY);
442
443 if (!init_part_stats(p)) {
444 err = -ENOMEM;
445 goto out_free;
446 }
447 pdev = part_to_dev(p);
448
449 p->start_sect = start;
450 p->alignment_offset =
451 queue_limit_alignment_offset(&disk->queue->limits, start);
452 p->discard_alignment =
453 queue_limit_discard_alignment(&disk->queue->limits, start);
454 p->nr_sects = len;
455 p->partno = partno;
456 p->policy = get_disk_ro(disk);
457
458 if (info) {
459 struct partition_meta_info *pinfo = alloc_part_info(disk);
460 if (!pinfo)
461 goto out_free_stats;
462 memcpy(pinfo, info, sizeof(*info));
463 p->info = pinfo;
464 }
465
466 dname = dev_name(ddev);
467 if (isdigit(dname[strlen(dname) - 1]))
468 dev_set_name(pdev, "%sp%d", dname, partno);
469 else
470 dev_set_name(pdev, "%s%d", dname, partno);
471
472 device_initialize(pdev);
473 pdev->class = &block_class;
474 pdev->type = &part_type;
475 pdev->parent = ddev;
476
477 err = blk_alloc_devt(p, &devt);
478 if (err)
479 goto out_free_info;
480 pdev->devt = devt;
481
482 /* delay uevent until 'holders' subdir is created */
483 dev_set_uevent_suppress(pdev, 1);
484 err = device_add(pdev);
485 if (err)
486 goto out_put;
487
488 err = -ENOMEM;
489 p->holder_dir = kobject_create_and_add("holders", &pdev->kobj);
490 if (!p->holder_dir)
491 goto out_del;
492
493 dev_set_uevent_suppress(pdev, 0);
494 if (flags & ADDPART_FLAG_WHOLEDISK) {
495 err = device_create_file(pdev, &dev_attr_whole_disk);
496 if (err)
497 goto out_del;
498 }
499
500 /* everything is up and running, commence */
501 rcu_assign_pointer(ptbl->part[partno], p);
502
503 /* suppress uevent if the disk suppresses it */
504 if (!dev_get_uevent_suppress(ddev))
505 kobject_uevent(&pdev->kobj, KOBJ_ADD);
506
507 hd_ref_init(p);
508 return p;
509
510out_free_info:
511 free_part_info(p);
512out_free_stats:
513 free_part_stats(p);
514out_free:
515 kfree(p);
516 return ERR_PTR(err);
517out_del:
518 kobject_put(p->holder_dir);
519 device_del(pdev);
520out_put:
521 put_device(pdev);
522 blk_free_devt(devt);
523 return ERR_PTR(err);
524}
525
526static bool disk_unlock_native_capacity(struct gendisk *disk)
527{
528 const struct block_device_operations *bdops = disk->fops;
529
530 if (bdops->unlock_native_capacity &&
531 !(disk->flags & GENHD_FL_NATIVE_CAPACITY)) {
532 printk(KERN_CONT "enabling native capacity\n");
533 bdops->unlock_native_capacity(disk);
534 disk->flags |= GENHD_FL_NATIVE_CAPACITY;
535 return true;
536 } else {
537 printk(KERN_CONT "truncated\n");
538 return false;
539 }
540}
541
542int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
543{
544 struct parsed_partitions *state = NULL;
545 struct disk_part_iter piter;
546 struct hd_struct *part;
547 int p, highest, res;
548rescan:
549 if (state && !IS_ERR(state)) {
550 kfree(state);
551 state = NULL;
552 }
553
554 if (bdev->bd_part_count)
555 return -EBUSY;
556 res = invalidate_partition(disk, 0);
557 if (res)
558 return res;
559
560 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
561 while ((part = disk_part_iter_next(&piter)))
562 delete_partition(disk, part->partno);
563 disk_part_iter_exit(&piter);
564
565 if (disk->fops->revalidate_disk)
566 disk->fops->revalidate_disk(disk);
567 check_disk_size_change(disk, bdev);
568 bdev->bd_invalidated = 0;
569 if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
570 return 0;
571 if (IS_ERR(state)) {
572 /*
573 * I/O error reading the partition table. If any
574 * partition code tried to read beyond EOD, retry
575 * after unlocking native capacity.
576 */
577 if (PTR_ERR(state) == -ENOSPC) {
578 printk(KERN_WARNING "%s: partition table beyond EOD, ",
579 disk->disk_name);
580 if (disk_unlock_native_capacity(disk))
581 goto rescan;
582 }
583 return -EIO;
584 }
585 /*
586 * If any partition code tried to read beyond EOD, try
587 * unlocking native capacity even if partition table is
588 * successfully read as we could be missing some partitions.
589 */
590 if (state->access_beyond_eod) {
591 printk(KERN_WARNING
592 "%s: partition table partially beyond EOD, ",
593 disk->disk_name);
594 if (disk_unlock_native_capacity(disk))
595 goto rescan;
596 }
597
598 /* tell userspace that the media / partition table may have changed */
599 kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE);
600
601 /* Detect the highest partition number and preallocate
602 * disk->part_tbl. This is an optimization and not strictly
603 * necessary.
604 */
605 for (p = 1, highest = 0; p < state->limit; p++)
606 if (state->parts[p].size)
607 highest = p;
608
609 disk_expand_part_tbl(disk, highest);
610
611 /* add partitions */
612 for (p = 1; p < state->limit; p++) {
613 sector_t size, from;
614 struct partition_meta_info *info = NULL;
615
616 size = state->parts[p].size;
617 if (!size)
618 continue;
619
620 from = state->parts[p].from;
621 if (from >= get_capacity(disk)) {
622 printk(KERN_WARNING
623 "%s: p%d start %llu is beyond EOD, ",
624 disk->disk_name, p, (unsigned long long) from);
625 if (disk_unlock_native_capacity(disk))
626 goto rescan;
627 continue;
628 }
629
630 if (from + size > get_capacity(disk)) {
631 printk(KERN_WARNING
632 "%s: p%d size %llu extends beyond EOD, ",
633 disk->disk_name, p, (unsigned long long) size);
634
635 if (disk_unlock_native_capacity(disk)) {
636 /* free state and restart */
637 goto rescan;
638 } else {
639 /*
640 * we can not ignore partitions of broken tables
641 * created by for example camera firmware, but
642 * we limit them to the end of the disk to avoid
643 * creating invalid block devices
644 */
645 size = get_capacity(disk) - from;
646 }
647 }
648
649 if (state->parts[p].has_info)
650 info = &state->parts[p].info;
651 part = add_partition(disk, p, from, size,
652 state->parts[p].flags,
653 &state->parts[p].info);
654 if (IS_ERR(part)) {
655 printk(KERN_ERR " %s: p%d could not be added: %ld\n",
656 disk->disk_name, p, -PTR_ERR(part));
657 continue;
658 }
659#ifdef CONFIG_BLK_DEV_MD
660 if (state->parts[p].flags & ADDPART_FLAG_RAID)
661 md_autodetect_dev(part_to_dev(part)->devt);
662#endif
663 }
664 kfree(state);
665 return 0;
666}
667
668unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p)
669{
670 struct address_space *mapping = bdev->bd_inode->i_mapping;
671 struct page *page;
672
673 page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_CACHE_SHIFT-9)),
674 NULL);
675 if (!IS_ERR(page)) {
676 if (PageError(page))
677 goto fail;
678 p->v = page;
679 return (unsigned char *)page_address(page) + ((n & ((1 << (PAGE_CACHE_SHIFT - 9)) - 1)) << 9);
680fail:
681 page_cache_release(page);
682 }
683 p->v = NULL;
684 return NULL;
685}
686
687EXPORT_SYMBOL(read_dev_sector);
diff --git a/fs/partitions/check.h b/fs/partitions/check.h
deleted file mode 100644
index d68bf4dc3bc2..000000000000
--- a/fs/partitions/check.h
+++ /dev/null
@@ -1,49 +0,0 @@
1#include <linux/pagemap.h>
2#include <linux/blkdev.h>
3#include <linux/genhd.h>
4
5/*
6 * add_gd_partition adds a partitions details to the devices partition
7 * description.
8 */
9struct parsed_partitions {
10 struct block_device *bdev;
11 char name[BDEVNAME_SIZE];
12 struct {
13 sector_t from;
14 sector_t size;
15 int flags;
16 bool has_info;
17 struct partition_meta_info info;
18 } parts[DISK_MAX_PARTS];
19 int next;
20 int limit;
21 bool access_beyond_eod;
22 char *pp_buf;
23};
24
25static inline void *read_part_sector(struct parsed_partitions *state,
26 sector_t n, Sector *p)
27{
28 if (n >= get_capacity(state->bdev->bd_disk)) {
29 state->access_beyond_eod = true;
30 return NULL;
31 }
32 return read_dev_sector(state->bdev, n, p);
33}
34
35static inline void
36put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size)
37{
38 if (n < p->limit) {
39 char tmp[1 + BDEVNAME_SIZE + 10 + 1];
40
41 p->parts[n].from = from;
42 p->parts[n].size = size;
43 snprintf(tmp, sizeof(tmp), " %s%d", p->name, n);
44 strlcat(p->pp_buf, tmp, PAGE_SIZE);
45 }
46}
47
48extern int warn_no_part;
49
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
deleted file mode 100644
index 6296b403c67a..000000000000
--- a/fs/partitions/efi.c
+++ /dev/null
@@ -1,675 +0,0 @@
1/************************************************************
2 * EFI GUID Partition Table handling
3 *
4 * http://www.uefi.org/specs/
5 * http://www.intel.com/technology/efi/
6 *
7 * efi.[ch] by Matt Domsch <Matt_Domsch@dell.com>
8 * Copyright 2000,2001,2002,2004 Dell Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 *
25 * TODO:
26 *
27 * Changelog:
28 * Mon Nov 09 2004 Matt Domsch <Matt_Domsch@dell.com>
29 * - test for valid PMBR and valid PGPT before ever reading
30 * AGPT, allow override with 'gpt' kernel command line option.
31 * - check for first/last_usable_lba outside of size of disk
32 *
33 * Tue Mar 26 2002 Matt Domsch <Matt_Domsch@dell.com>
34 * - Ported to 2.5.7-pre1 and 2.5.7-dj2
35 * - Applied patch to avoid fault in alternate header handling
36 * - cleaned up find_valid_gpt
37 * - On-disk structure and copy in memory is *always* LE now -
38 * swab fields as needed
39 * - remove print_gpt_header()
40 * - only use first max_p partition entries, to keep the kernel minor number
41 * and partition numbers tied.
42 *
43 * Mon Feb 04 2002 Matt Domsch <Matt_Domsch@dell.com>
44 * - Removed __PRIPTR_PREFIX - not being used
45 *
46 * Mon Jan 14 2002 Matt Domsch <Matt_Domsch@dell.com>
47 * - Ported to 2.5.2-pre11 + library crc32 patch Linus applied
48 *
49 * Thu Dec 6 2001 Matt Domsch <Matt_Domsch@dell.com>
50 * - Added compare_gpts().
51 * - moved le_efi_guid_to_cpus() back into this file. GPT is the only
52 * thing that keeps EFI GUIDs on disk.
53 * - Changed gpt structure names and members to be simpler and more Linux-like.
54 *
55 * Wed Oct 17 2001 Matt Domsch <Matt_Domsch@dell.com>
56 * - Removed CONFIG_DEVFS_VOLUMES_UUID code entirely per Martin Wilck
57 *
58 * Wed Oct 10 2001 Matt Domsch <Matt_Domsch@dell.com>
59 * - Changed function comments to DocBook style per Andreas Dilger suggestion.
60 *
61 * Mon Oct 08 2001 Matt Domsch <Matt_Domsch@dell.com>
62 * - Change read_lba() to use the page cache per Al Viro's work.
63 * - print u64s properly on all architectures
64 * - fixed debug_printk(), now Dprintk()
65 *
66 * Mon Oct 01 2001 Matt Domsch <Matt_Domsch@dell.com>
67 * - Style cleanups
68 * - made most functions static
69 * - Endianness addition
70 * - remove test for second alternate header, as it's not per spec,
71 * and is unnecessary. There's now a method to read/write the last
72 * sector of an odd-sized disk from user space. No tools have ever
73 * been released which used this code, so it's effectively dead.
74 * - Per Asit Mallick of Intel, added a test for a valid PMBR.
75 * - Added kernel command line option 'gpt' to override valid PMBR test.
76 *
77 * Wed Jun 6 2001 Martin Wilck <Martin.Wilck@Fujitsu-Siemens.com>
78 * - added devfs volume UUID support (/dev/volumes/uuids) for
79 * mounting file systems by the partition GUID.
80 *
81 * Tue Dec 5 2000 Matt Domsch <Matt_Domsch@dell.com>
82 * - Moved crc32() to linux/lib, added efi_crc32().
83 *
84 * Thu Nov 30 2000 Matt Domsch <Matt_Domsch@dell.com>
85 * - Replaced Intel's CRC32 function with an equivalent
86 * non-license-restricted version.
87 *
88 * Wed Oct 25 2000 Matt Domsch <Matt_Domsch@dell.com>
89 * - Fixed the last_lba() call to return the proper last block
90 *
91 * Thu Oct 12 2000 Matt Domsch <Matt_Domsch@dell.com>
92 * - Thanks to Andries Brouwer for his debugging assistance.
93 * - Code works, detects all the partitions.
94 *
95 ************************************************************/
96#include <linux/crc32.h>
97#include <linux/ctype.h>
98#include <linux/math64.h>
99#include <linux/slab.h>
100#include "check.h"
101#include "efi.h"
102
103/* This allows a kernel command line option 'gpt' to override
104 * the test for invalid PMBR. Not __initdata because reloading
105 * the partition tables happens after init too.
106 */
107static int force_gpt;
108static int __init
109force_gpt_fn(char *str)
110{
111 force_gpt = 1;
112 return 1;
113}
114__setup("gpt", force_gpt_fn);
115
116
117/**
118 * efi_crc32() - EFI version of crc32 function
119 * @buf: buffer to calculate crc32 of
120 * @len - length of buf
121 *
122 * Description: Returns EFI-style CRC32 value for @buf
123 *
124 * This function uses the little endian Ethernet polynomial
125 * but seeds the function with ~0, and xor's with ~0 at the end.
126 * Note, the EFI Specification, v1.02, has a reference to
127 * Dr. Dobbs Journal, May 1994 (actually it's in May 1992).
128 */
129static inline u32
130efi_crc32(const void *buf, unsigned long len)
131{
132 return (crc32(~0L, buf, len) ^ ~0L);
133}
134
135/**
136 * last_lba(): return number of last logical block of device
137 * @bdev: block device
138 *
139 * Description: Returns last LBA value on success, 0 on error.
140 * This is stored (by sd and ide-geometry) in
141 * the part[0] entry for this disk, and is the number of
142 * physical sectors available on the disk.
143 */
144static u64 last_lba(struct block_device *bdev)
145{
146 if (!bdev || !bdev->bd_inode)
147 return 0;
148 return div_u64(bdev->bd_inode->i_size,
149 bdev_logical_block_size(bdev)) - 1ULL;
150}
151
152static inline int
153pmbr_part_valid(struct partition *part)
154{
155 if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT &&
156 le32_to_cpu(part->start_sect) == 1UL)
157 return 1;
158 return 0;
159}
160
161/**
162 * is_pmbr_valid(): test Protective MBR for validity
163 * @mbr: pointer to a legacy mbr structure
164 *
165 * Description: Returns 1 if PMBR is valid, 0 otherwise.
166 * Validity depends on two things:
167 * 1) MSDOS signature is in the last two bytes of the MBR
168 * 2) One partition of type 0xEE is found
169 */
170static int
171is_pmbr_valid(legacy_mbr *mbr)
172{
173 int i;
174 if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE)
175 return 0;
176 for (i = 0; i < 4; i++)
177 if (pmbr_part_valid(&mbr->partition_record[i]))
178 return 1;
179 return 0;
180}
181
182/**
183 * read_lba(): Read bytes from disk, starting at given LBA
184 * @state
185 * @lba
186 * @buffer
187 * @size_t
188 *
189 * Description: Reads @count bytes from @state->bdev into @buffer.
190 * Returns number of bytes read on success, 0 on error.
191 */
192static size_t read_lba(struct parsed_partitions *state,
193 u64 lba, u8 *buffer, size_t count)
194{
195 size_t totalreadcount = 0;
196 struct block_device *bdev = state->bdev;
197 sector_t n = lba * (bdev_logical_block_size(bdev) / 512);
198
199 if (!buffer || lba > last_lba(bdev))
200 return 0;
201
202 while (count) {
203 int copied = 512;
204 Sector sect;
205 unsigned char *data = read_part_sector(state, n++, &sect);
206 if (!data)
207 break;
208 if (copied > count)
209 copied = count;
210 memcpy(buffer, data, copied);
211 put_dev_sector(sect);
212 buffer += copied;
213 totalreadcount +=copied;
214 count -= copied;
215 }
216 return totalreadcount;
217}
218
219/**
220 * alloc_read_gpt_entries(): reads partition entries from disk
221 * @state
222 * @gpt - GPT header
223 *
224 * Description: Returns ptes on success, NULL on error.
225 * Allocates space for PTEs based on information found in @gpt.
226 * Notes: remember to free pte when you're done!
227 */
228static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
229 gpt_header *gpt)
230{
231 size_t count;
232 gpt_entry *pte;
233
234 if (!gpt)
235 return NULL;
236
237 count = le32_to_cpu(gpt->num_partition_entries) *
238 le32_to_cpu(gpt->sizeof_partition_entry);
239 if (!count)
240 return NULL;
241 pte = kzalloc(count, GFP_KERNEL);
242 if (!pte)
243 return NULL;
244
245 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
246 (u8 *) pte,
247 count) < count) {
248 kfree(pte);
249 pte=NULL;
250 return NULL;
251 }
252 return pte;
253}
254
255/**
256 * alloc_read_gpt_header(): Allocates GPT header, reads into it from disk
257 * @state
258 * @lba is the Logical Block Address of the partition table
259 *
260 * Description: returns GPT header on success, NULL on error. Allocates
261 * and fills a GPT header starting at @ from @state->bdev.
262 * Note: remember to free gpt when finished with it.
263 */
264static gpt_header *alloc_read_gpt_header(struct parsed_partitions *state,
265 u64 lba)
266{
267 gpt_header *gpt;
268 unsigned ssz = bdev_logical_block_size(state->bdev);
269
270 gpt = kzalloc(ssz, GFP_KERNEL);
271 if (!gpt)
272 return NULL;
273
274 if (read_lba(state, lba, (u8 *) gpt, ssz) < ssz) {
275 kfree(gpt);
276 gpt=NULL;
277 return NULL;
278 }
279
280 return gpt;
281}
282
283/**
284 * is_gpt_valid() - tests one GPT header and PTEs for validity
285 * @state
286 * @lba is the logical block address of the GPT header to test
287 * @gpt is a GPT header ptr, filled on return.
288 * @ptes is a PTEs ptr, filled on return.
289 *
290 * Description: returns 1 if valid, 0 on error.
291 * If valid, returns pointers to newly allocated GPT header and PTEs.
292 */
293static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
294 gpt_header **gpt, gpt_entry **ptes)
295{
296 u32 crc, origcrc;
297 u64 lastlba;
298
299 if (!ptes)
300 return 0;
301 if (!(*gpt = alloc_read_gpt_header(state, lba)))
302 return 0;
303
304 /* Check the GUID Partition Table signature */
305 if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) {
306 pr_debug("GUID Partition Table Header signature is wrong:"
307 "%lld != %lld\n",
308 (unsigned long long)le64_to_cpu((*gpt)->signature),
309 (unsigned long long)GPT_HEADER_SIGNATURE);
310 goto fail;
311 }
312
313 /* Check the GUID Partition Table header size */
314 if (le32_to_cpu((*gpt)->header_size) >
315 bdev_logical_block_size(state->bdev)) {
316 pr_debug("GUID Partition Table Header size is wrong: %u > %u\n",
317 le32_to_cpu((*gpt)->header_size),
318 bdev_logical_block_size(state->bdev));
319 goto fail;
320 }
321
322 /* Check the GUID Partition Table CRC */
323 origcrc = le32_to_cpu((*gpt)->header_crc32);
324 (*gpt)->header_crc32 = 0;
325 crc = efi_crc32((const unsigned char *) (*gpt), le32_to_cpu((*gpt)->header_size));
326
327 if (crc != origcrc) {
328 pr_debug("GUID Partition Table Header CRC is wrong: %x != %x\n",
329 crc, origcrc);
330 goto fail;
331 }
332 (*gpt)->header_crc32 = cpu_to_le32(origcrc);
333
334 /* Check that the my_lba entry points to the LBA that contains
335 * the GUID Partition Table */
336 if (le64_to_cpu((*gpt)->my_lba) != lba) {
337 pr_debug("GPT my_lba incorrect: %lld != %lld\n",
338 (unsigned long long)le64_to_cpu((*gpt)->my_lba),
339 (unsigned long long)lba);
340 goto fail;
341 }
342
343 /* Check the first_usable_lba and last_usable_lba are
344 * within the disk.
345 */
346 lastlba = last_lba(state->bdev);
347 if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) {
348 pr_debug("GPT: first_usable_lba incorrect: %lld > %lld\n",
349 (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba),
350 (unsigned long long)lastlba);
351 goto fail;
352 }
353 if (le64_to_cpu((*gpt)->last_usable_lba) > lastlba) {
354 pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n",
355 (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba),
356 (unsigned long long)lastlba);
357 goto fail;
358 }
359
360 /* Check that sizeof_partition_entry has the correct value */
361 if (le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) {
362 pr_debug("GUID Partitition Entry Size check failed.\n");
363 goto fail;
364 }
365
366 if (!(*ptes = alloc_read_gpt_entries(state, *gpt)))
367 goto fail;
368
369 /* Check the GUID Partition Entry Array CRC */
370 crc = efi_crc32((const unsigned char *) (*ptes),
371 le32_to_cpu((*gpt)->num_partition_entries) *
372 le32_to_cpu((*gpt)->sizeof_partition_entry));
373
374 if (crc != le32_to_cpu((*gpt)->partition_entry_array_crc32)) {
375 pr_debug("GUID Partitition Entry Array CRC check failed.\n");
376 goto fail_ptes;
377 }
378
379 /* We're done, all's well */
380 return 1;
381
382 fail_ptes:
383 kfree(*ptes);
384 *ptes = NULL;
385 fail:
386 kfree(*gpt);
387 *gpt = NULL;
388 return 0;
389}
390
391/**
392 * is_pte_valid() - tests one PTE for validity
393 * @pte is the pte to check
394 * @lastlba is last lba of the disk
395 *
396 * Description: returns 1 if valid, 0 on error.
397 */
398static inline int
399is_pte_valid(const gpt_entry *pte, const u64 lastlba)
400{
401 if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) ||
402 le64_to_cpu(pte->starting_lba) > lastlba ||
403 le64_to_cpu(pte->ending_lba) > lastlba)
404 return 0;
405 return 1;
406}
407
408/**
409 * compare_gpts() - Search disk for valid GPT headers and PTEs
410 * @pgpt is the primary GPT header
411 * @agpt is the alternate GPT header
412 * @lastlba is the last LBA number
413 * Description: Returns nothing. Sanity checks pgpt and agpt fields
414 * and prints warnings on discrepancies.
415 *
416 */
417static void
418compare_gpts(gpt_header *pgpt, gpt_header *agpt, u64 lastlba)
419{
420 int error_found = 0;
421 if (!pgpt || !agpt)
422 return;
423 if (le64_to_cpu(pgpt->my_lba) != le64_to_cpu(agpt->alternate_lba)) {
424 printk(KERN_WARNING
425 "GPT:Primary header LBA != Alt. header alternate_lba\n");
426 printk(KERN_WARNING "GPT:%lld != %lld\n",
427 (unsigned long long)le64_to_cpu(pgpt->my_lba),
428 (unsigned long long)le64_to_cpu(agpt->alternate_lba));
429 error_found++;
430 }
431 if (le64_to_cpu(pgpt->alternate_lba) != le64_to_cpu(agpt->my_lba)) {
432 printk(KERN_WARNING
433 "GPT:Primary header alternate_lba != Alt. header my_lba\n");
434 printk(KERN_WARNING "GPT:%lld != %lld\n",
435 (unsigned long long)le64_to_cpu(pgpt->alternate_lba),
436 (unsigned long long)le64_to_cpu(agpt->my_lba));
437 error_found++;
438 }
439 if (le64_to_cpu(pgpt->first_usable_lba) !=
440 le64_to_cpu(agpt->first_usable_lba)) {
441 printk(KERN_WARNING "GPT:first_usable_lbas don't match.\n");
442 printk(KERN_WARNING "GPT:%lld != %lld\n",
443 (unsigned long long)le64_to_cpu(pgpt->first_usable_lba),
444 (unsigned long long)le64_to_cpu(agpt->first_usable_lba));
445 error_found++;
446 }
447 if (le64_to_cpu(pgpt->last_usable_lba) !=
448 le64_to_cpu(agpt->last_usable_lba)) {
449 printk(KERN_WARNING "GPT:last_usable_lbas don't match.\n");
450 printk(KERN_WARNING "GPT:%lld != %lld\n",
451 (unsigned long long)le64_to_cpu(pgpt->last_usable_lba),
452 (unsigned long long)le64_to_cpu(agpt->last_usable_lba));
453 error_found++;
454 }
455 if (efi_guidcmp(pgpt->disk_guid, agpt->disk_guid)) {
456 printk(KERN_WARNING "GPT:disk_guids don't match.\n");
457 error_found++;
458 }
459 if (le32_to_cpu(pgpt->num_partition_entries) !=
460 le32_to_cpu(agpt->num_partition_entries)) {
461 printk(KERN_WARNING "GPT:num_partition_entries don't match: "
462 "0x%x != 0x%x\n",
463 le32_to_cpu(pgpt->num_partition_entries),
464 le32_to_cpu(agpt->num_partition_entries));
465 error_found++;
466 }
467 if (le32_to_cpu(pgpt->sizeof_partition_entry) !=
468 le32_to_cpu(agpt->sizeof_partition_entry)) {
469 printk(KERN_WARNING
470 "GPT:sizeof_partition_entry values don't match: "
471 "0x%x != 0x%x\n",
472 le32_to_cpu(pgpt->sizeof_partition_entry),
473 le32_to_cpu(agpt->sizeof_partition_entry));
474 error_found++;
475 }
476 if (le32_to_cpu(pgpt->partition_entry_array_crc32) !=
477 le32_to_cpu(agpt->partition_entry_array_crc32)) {
478 printk(KERN_WARNING
479 "GPT:partition_entry_array_crc32 values don't match: "
480 "0x%x != 0x%x\n",
481 le32_to_cpu(pgpt->partition_entry_array_crc32),
482 le32_to_cpu(agpt->partition_entry_array_crc32));
483 error_found++;
484 }
485 if (le64_to_cpu(pgpt->alternate_lba) != lastlba) {
486 printk(KERN_WARNING
487 "GPT:Primary header thinks Alt. header is not at the end of the disk.\n");
488 printk(KERN_WARNING "GPT:%lld != %lld\n",
489 (unsigned long long)le64_to_cpu(pgpt->alternate_lba),
490 (unsigned long long)lastlba);
491 error_found++;
492 }
493
494 if (le64_to_cpu(agpt->my_lba) != lastlba) {
495 printk(KERN_WARNING
496 "GPT:Alternate GPT header not at the end of the disk.\n");
497 printk(KERN_WARNING "GPT:%lld != %lld\n",
498 (unsigned long long)le64_to_cpu(agpt->my_lba),
499 (unsigned long long)lastlba);
500 error_found++;
501 }
502
503 if (error_found)
504 printk(KERN_WARNING
505 "GPT: Use GNU Parted to correct GPT errors.\n");
506 return;
507}
508
509/**
510 * find_valid_gpt() - Search disk for valid GPT headers and PTEs
511 * @state
512 * @gpt is a GPT header ptr, filled on return.
513 * @ptes is a PTEs ptr, filled on return.
514 * Description: Returns 1 if valid, 0 on error.
515 * If valid, returns pointers to newly allocated GPT header and PTEs.
516 * Validity depends on PMBR being valid (or being overridden by the
517 * 'gpt' kernel command line option) and finding either the Primary
518 * GPT header and PTEs valid, or the Alternate GPT header and PTEs
519 * valid. If the Primary GPT header is not valid, the Alternate GPT header
520 * is not checked unless the 'gpt' kernel command line option is passed.
521 * This protects against devices which misreport their size, and forces
522 * the user to decide to use the Alternate GPT.
523 */
524static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
525 gpt_entry **ptes)
526{
527 int good_pgpt = 0, good_agpt = 0, good_pmbr = 0;
528 gpt_header *pgpt = NULL, *agpt = NULL;
529 gpt_entry *pptes = NULL, *aptes = NULL;
530 legacy_mbr *legacymbr;
531 u64 lastlba;
532
533 if (!ptes)
534 return 0;
535
536 lastlba = last_lba(state->bdev);
537 if (!force_gpt) {
538 /* This will be added to the EFI Spec. per Intel after v1.02. */
539 legacymbr = kzalloc(sizeof (*legacymbr), GFP_KERNEL);
540 if (legacymbr) {
541 read_lba(state, 0, (u8 *) legacymbr,
542 sizeof (*legacymbr));
543 good_pmbr = is_pmbr_valid(legacymbr);
544 kfree(legacymbr);
545 }
546 if (!good_pmbr)
547 goto fail;
548 }
549
550 good_pgpt = is_gpt_valid(state, GPT_PRIMARY_PARTITION_TABLE_LBA,
551 &pgpt, &pptes);
552 if (good_pgpt)
553 good_agpt = is_gpt_valid(state,
554 le64_to_cpu(pgpt->alternate_lba),
555 &agpt, &aptes);
556 if (!good_agpt && force_gpt)
557 good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes);
558
559 /* The obviously unsuccessful case */
560 if (!good_pgpt && !good_agpt)
561 goto fail;
562
563 compare_gpts(pgpt, agpt, lastlba);
564
565 /* The good cases */
566 if (good_pgpt) {
567 *gpt = pgpt;
568 *ptes = pptes;
569 kfree(agpt);
570 kfree(aptes);
571 if (!good_agpt) {
572 printk(KERN_WARNING
573 "Alternate GPT is invalid, "
574 "using primary GPT.\n");
575 }
576 return 1;
577 }
578 else if (good_agpt) {
579 *gpt = agpt;
580 *ptes = aptes;
581 kfree(pgpt);
582 kfree(pptes);
583 printk(KERN_WARNING
584 "Primary GPT is invalid, using alternate GPT.\n");
585 return 1;
586 }
587
588 fail:
589 kfree(pgpt);
590 kfree(agpt);
591 kfree(pptes);
592 kfree(aptes);
593 *gpt = NULL;
594 *ptes = NULL;
595 return 0;
596}
597
598/**
599 * efi_partition(struct parsed_partitions *state)
600 * @state
601 *
602 * Description: called from check.c, if the disk contains GPT
603 * partitions, sets up partition entries in the kernel.
604 *
605 * If the first block on the disk is a legacy MBR,
606 * it will get handled by msdos_partition().
607 * If it's a Protective MBR, we'll handle it here.
608 *
609 * We do not create a Linux partition for GPT, but
610 * only for the actual data partitions.
611 * Returns:
612 * -1 if unable to read the partition table
613 * 0 if this isn't our partition table
614 * 1 if successful
615 *
616 */
617int efi_partition(struct parsed_partitions *state)
618{
619 gpt_header *gpt = NULL;
620 gpt_entry *ptes = NULL;
621 u32 i;
622 unsigned ssz = bdev_logical_block_size(state->bdev) / 512;
623 u8 unparsed_guid[37];
624
625 if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
626 kfree(gpt);
627 kfree(ptes);
628 return 0;
629 }
630
631 pr_debug("GUID Partition Table is valid! Yea!\n");
632
633 for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) {
634 struct partition_meta_info *info;
635 unsigned label_count = 0;
636 unsigned label_max;
637 u64 start = le64_to_cpu(ptes[i].starting_lba);
638 u64 size = le64_to_cpu(ptes[i].ending_lba) -
639 le64_to_cpu(ptes[i].starting_lba) + 1ULL;
640
641 if (!is_pte_valid(&ptes[i], last_lba(state->bdev)))
642 continue;
643
644 put_partition(state, i+1, start * ssz, size * ssz);
645
646 /* If this is a RAID volume, tell md */
647 if (!efi_guidcmp(ptes[i].partition_type_guid,
648 PARTITION_LINUX_RAID_GUID))
649 state->parts[i + 1].flags = ADDPART_FLAG_RAID;
650
651 info = &state->parts[i + 1].info;
652 /* Instead of doing a manual swap to big endian, reuse the
653 * common ASCII hex format as the interim.
654 */
655 efi_guid_unparse(&ptes[i].unique_partition_guid, unparsed_guid);
656 part_pack_uuid(unparsed_guid, info->uuid);
657
658 /* Naively convert UTF16-LE to 7 bits. */
659 label_max = min(sizeof(info->volname) - 1,
660 sizeof(ptes[i].partition_name));
661 info->volname[label_max] = 0;
662 while (label_count < label_max) {
663 u8 c = ptes[i].partition_name[label_count] & 0xff;
664 if (c && !isprint(c))
665 c = '!';
666 info->volname[label_count] = c;
667 label_count++;
668 }
669 state->parts[i + 1].has_info = true;
670 }
671 kfree(ptes);
672 kfree(gpt);
673 strlcat(state->pp_buf, "\n", PAGE_SIZE);
674 return 1;
675}
diff --git a/fs/partitions/efi.h b/fs/partitions/efi.h
deleted file mode 100644
index b69ab729558f..000000000000
--- a/fs/partitions/efi.h
+++ /dev/null
@@ -1,134 +0,0 @@
1/************************************************************
2 * EFI GUID Partition Table
3 * Per Intel EFI Specification v1.02
4 * http://developer.intel.com/technology/efi/efi.htm
5 *
6 * By Matt Domsch <Matt_Domsch@dell.com> Fri Sep 22 22:15:56 CDT 2000
7 * Copyright 2000,2001 Dell Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 ************************************************************/
24
25#ifndef FS_PART_EFI_H_INCLUDED
26#define FS_PART_EFI_H_INCLUDED
27
28#include <linux/types.h>
29#include <linux/fs.h>
30#include <linux/genhd.h>
31#include <linux/kernel.h>
32#include <linux/major.h>
33#include <linux/string.h>
34#include <linux/efi.h>
35
36#define MSDOS_MBR_SIGNATURE 0xaa55
37#define EFI_PMBR_OSTYPE_EFI 0xEF
38#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
39
40#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
41#define GPT_HEADER_REVISION_V1 0x00010000
42#define GPT_PRIMARY_PARTITION_TABLE_LBA 1
43
44#define PARTITION_SYSTEM_GUID \
45 EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
46 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B)
47#define LEGACY_MBR_PARTITION_GUID \
48 EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \
49 0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F)
50#define PARTITION_MSFT_RESERVED_GUID \
51 EFI_GUID( 0xE3C9E316, 0x0B5C, 0x4DB8, \
52 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE)
53#define PARTITION_BASIC_DATA_GUID \
54 EFI_GUID( 0xEBD0A0A2, 0xB9E5, 0x4433, \
55 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7)
56#define PARTITION_LINUX_RAID_GUID \
57 EFI_GUID( 0xa19d880f, 0x05fc, 0x4d3b, \
58 0xa0, 0x06, 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e)
59#define PARTITION_LINUX_SWAP_GUID \
60 EFI_GUID( 0x0657fd6d, 0xa4ab, 0x43c4, \
61 0x84, 0xe5, 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f)
62#define PARTITION_LINUX_LVM_GUID \
63 EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
64 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
65
66typedef struct _gpt_header {
67 __le64 signature;
68 __le32 revision;
69 __le32 header_size;
70 __le32 header_crc32;
71 __le32 reserved1;
72 __le64 my_lba;
73 __le64 alternate_lba;
74 __le64 first_usable_lba;
75 __le64 last_usable_lba;
76 efi_guid_t disk_guid;
77 __le64 partition_entry_lba;
78 __le32 num_partition_entries;
79 __le32 sizeof_partition_entry;
80 __le32 partition_entry_array_crc32;
81
82 /* The rest of the logical block is reserved by UEFI and must be zero.
83 * EFI standard handles this by:
84 *
85 * uint8_t reserved2[ BlockSize - 92 ];
86 */
87} __attribute__ ((packed)) gpt_header;
88
89typedef struct _gpt_entry_attributes {
90 u64 required_to_function:1;
91 u64 reserved:47;
92 u64 type_guid_specific:16;
93} __attribute__ ((packed)) gpt_entry_attributes;
94
95typedef struct _gpt_entry {
96 efi_guid_t partition_type_guid;
97 efi_guid_t unique_partition_guid;
98 __le64 starting_lba;
99 __le64 ending_lba;
100 gpt_entry_attributes attributes;
101 efi_char16_t partition_name[72 / sizeof (efi_char16_t)];
102} __attribute__ ((packed)) gpt_entry;
103
104typedef struct _legacy_mbr {
105 u8 boot_code[440];
106 __le32 unique_mbr_signature;
107 __le16 unknown;
108 struct partition partition_record[4];
109 __le16 signature;
110} __attribute__ ((packed)) legacy_mbr;
111
112/* Functions */
113extern int efi_partition(struct parsed_partitions *state);
114
115#endif
116
117/*
118 * Overrides for Emacs so that we follow Linus's tabbing style.
119 * Emacs will notice this stuff at the end of the file and automatically
120 * adjust the settings for this buffer only. This must remain at the end
121 * of the file.
122 * --------------------------------------------------------------------------
123 * Local variables:
124 * c-indent-level: 4
125 * c-brace-imaginary-offset: 0
126 * c-brace-offset: -4
127 * c-argdecl-indent: 4
128 * c-label-offset: -4
129 * c-continued-statement-offset: 4
130 * c-continued-brace-offset: 0
131 * indent-tabs-mode: nil
132 * tab-width: 8
133 * End:
134 */
diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c
deleted file mode 100644
index d513a07f44bb..000000000000
--- a/fs/partitions/ibm.c
+++ /dev/null
@@ -1,275 +0,0 @@
1/*
2 * File...........: linux/fs/partitions/ibm.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Volker Sameske <sameske@de.ibm.com>
5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
7 */
8
9#include <linux/buffer_head.h>
10#include <linux/hdreg.h>
11#include <linux/slab.h>
12#include <asm/dasd.h>
13#include <asm/ebcdic.h>
14#include <asm/uaccess.h>
15#include <asm/vtoc.h>
16
17#include "check.h"
18#include "ibm.h"
19
20/*
21 * compute the block number from a
22 * cyl-cyl-head-head structure
23 */
24static sector_t
25cchh2blk (struct vtoc_cchh *ptr, struct hd_geometry *geo) {
26
27 sector_t cyl;
28 __u16 head;
29
30 /*decode cylinder and heads for large volumes */
31 cyl = ptr->hh & 0xFFF0;
32 cyl <<= 12;
33 cyl |= ptr->cc;
34 head = ptr->hh & 0x000F;
35 return cyl * geo->heads * geo->sectors +
36 head * geo->sectors;
37}
38
39/*
40 * compute the block number from a
41 * cyl-cyl-head-head-block structure
42 */
43static sector_t
44cchhb2blk (struct vtoc_cchhb *ptr, struct hd_geometry *geo) {
45
46 sector_t cyl;
47 __u16 head;
48
49 /*decode cylinder and heads for large volumes */
50 cyl = ptr->hh & 0xFFF0;
51 cyl <<= 12;
52 cyl |= ptr->cc;
53 head = ptr->hh & 0x000F;
54 return cyl * geo->heads * geo->sectors +
55 head * geo->sectors +
56 ptr->b;
57}
58
59/*
60 */
61int ibm_partition(struct parsed_partitions *state)
62{
63 struct block_device *bdev = state->bdev;
64 int blocksize, res;
65 loff_t i_size, offset, size, fmt_size;
66 dasd_information2_t *info;
67 struct hd_geometry *geo;
68 char type[5] = {0,};
69 char name[7] = {0,};
70 union label_t {
71 struct vtoc_volume_label_cdl vol;
72 struct vtoc_volume_label_ldl lnx;
73 struct vtoc_cms_label cms;
74 } *label;
75 unsigned char *data;
76 Sector sect;
77 sector_t labelsect;
78 char tmp[64];
79
80 res = 0;
81 blocksize = bdev_logical_block_size(bdev);
82 if (blocksize <= 0)
83 goto out_exit;
84 i_size = i_size_read(bdev->bd_inode);
85 if (i_size == 0)
86 goto out_exit;
87
88 info = kmalloc(sizeof(dasd_information2_t), GFP_KERNEL);
89 if (info == NULL)
90 goto out_exit;
91 geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL);
92 if (geo == NULL)
93 goto out_nogeo;
94 label = kmalloc(sizeof(union label_t), GFP_KERNEL);
95 if (label == NULL)
96 goto out_nolab;
97
98 if (ioctl_by_bdev(bdev, BIODASDINFO2, (unsigned long)info) != 0 ||
99 ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0)
100 goto out_freeall;
101
102 /*
103 * Special case for FBA disks: label sector does not depend on
104 * blocksize.
105 */
106 if ((info->cu_type == 0x6310 && info->dev_type == 0x9336) ||
107 (info->cu_type == 0x3880 && info->dev_type == 0x3370))
108 labelsect = info->label_block;
109 else
110 labelsect = info->label_block * (blocksize >> 9);
111
112 /*
113 * Get volume label, extract name and type.
114 */
115 data = read_part_sector(state, labelsect, &sect);
116 if (data == NULL)
117 goto out_readerr;
118
119 memcpy(label, data, sizeof(union label_t));
120 put_dev_sector(sect);
121
122 if ((!info->FBA_layout) && (!strcmp(info->type, "ECKD"))) {
123 strncpy(type, label->vol.vollbl, 4);
124 strncpy(name, label->vol.volid, 6);
125 } else {
126 strncpy(type, label->lnx.vollbl, 4);
127 strncpy(name, label->lnx.volid, 6);
128 }
129 EBCASC(type, 4);
130 EBCASC(name, 6);
131
132 res = 1;
133
134 /*
135 * Three different formats: LDL, CDL and unformated disk
136 *
137 * identified by info->format
138 *
139 * unformated disks we do not have to care about
140 */
141 if (info->format == DASD_FORMAT_LDL) {
142 if (strncmp(type, "CMS1", 4) == 0) {
143 /*
144 * VM style CMS1 labeled disk
145 */
146 blocksize = label->cms.block_size;
147 if (label->cms.disk_offset != 0) {
148 snprintf(tmp, sizeof(tmp), "CMS1/%8s(MDSK):", name);
149 strlcat(state->pp_buf, tmp, PAGE_SIZE);
150 /* disk is reserved minidisk */
151 offset = label->cms.disk_offset;
152 size = (label->cms.block_count - 1)
153 * (blocksize >> 9);
154 } else {
155 snprintf(tmp, sizeof(tmp), "CMS1/%8s:", name);
156 strlcat(state->pp_buf, tmp, PAGE_SIZE);
157 offset = (info->label_block + 1);
158 size = label->cms.block_count
159 * (blocksize >> 9);
160 }
161 put_partition(state, 1, offset*(blocksize >> 9),
162 size-offset*(blocksize >> 9));
163 } else {
164 if (strncmp(type, "LNX1", 4) == 0) {
165 snprintf(tmp, sizeof(tmp), "LNX1/%8s:", name);
166 strlcat(state->pp_buf, tmp, PAGE_SIZE);
167 if (label->lnx.ldl_version == 0xf2) {
168 fmt_size = label->lnx.formatted_blocks
169 * (blocksize >> 9);
170 } else if (!strcmp(info->type, "ECKD")) {
171 /* formated w/o large volume support */
172 fmt_size = geo->cylinders * geo->heads
173 * geo->sectors * (blocksize >> 9);
174 } else {
175 /* old label and no usable disk geometry
176 * (e.g. DIAG) */
177 fmt_size = i_size >> 9;
178 }
179 size = i_size >> 9;
180 if (fmt_size < size)
181 size = fmt_size;
182 offset = (info->label_block + 1);
183 } else {
184 /* unlabeled disk */
185 strlcat(state->pp_buf, "(nonl)", PAGE_SIZE);
186 size = i_size >> 9;
187 offset = (info->label_block + 1);
188 }
189 put_partition(state, 1, offset*(blocksize >> 9),
190 size-offset*(blocksize >> 9));
191 }
192 } else if (info->format == DASD_FORMAT_CDL) {
193 /*
194 * New style CDL formatted disk
195 */
196 sector_t blk;
197 int counter;
198
199 /*
200 * check if VOL1 label is available
201 * if not, something is wrong, skipping partition detection
202 */
203 if (strncmp(type, "VOL1", 4) == 0) {
204 snprintf(tmp, sizeof(tmp), "VOL1/%8s:", name);
205 strlcat(state->pp_buf, tmp, PAGE_SIZE);
206 /*
207 * get block number and read then go through format1
208 * labels
209 */
210 blk = cchhb2blk(&label->vol.vtoc, geo) + 1;
211 counter = 0;
212 data = read_part_sector(state, blk * (blocksize/512),
213 &sect);
214 while (data != NULL) {
215 struct vtoc_format1_label f1;
216
217 memcpy(&f1, data,
218 sizeof(struct vtoc_format1_label));
219 put_dev_sector(sect);
220
221 /* skip FMT4 / FMT5 / FMT7 labels */
222 if (f1.DS1FMTID == _ascebc['4']
223 || f1.DS1FMTID == _ascebc['5']
224 || f1.DS1FMTID == _ascebc['7']
225 || f1.DS1FMTID == _ascebc['9']) {
226 blk++;
227 data = read_part_sector(state,
228 blk * (blocksize/512), &sect);
229 continue;
230 }
231
232 /* only FMT1 and 8 labels valid at this point */
233 if (f1.DS1FMTID != _ascebc['1'] &&
234 f1.DS1FMTID != _ascebc['8'])
235 break;
236
237 /* OK, we got valid partition data */
238 offset = cchh2blk(&f1.DS1EXT1.llimit, geo);
239 size = cchh2blk(&f1.DS1EXT1.ulimit, geo) -
240 offset + geo->sectors;
241 if (counter >= state->limit)
242 break;
243 put_partition(state, counter + 1,
244 offset * (blocksize >> 9),
245 size * (blocksize >> 9));
246 counter++;
247 blk++;
248 data = read_part_sector(state,
249 blk * (blocksize/512), &sect);
250 }
251
252 if (!data)
253 /* Are we not supposed to report this ? */
254 goto out_readerr;
255 } else
256 printk(KERN_WARNING "Warning, expected Label VOL1 not "
257 "found, treating as CDL formated Disk");
258
259 }
260
261 strlcat(state->pp_buf, "\n", PAGE_SIZE);
262 goto out_freeall;
263
264
265out_readerr:
266 res = -1;
267out_freeall:
268 kfree(label);
269out_nolab:
270 kfree(geo);
271out_nogeo:
272 kfree(info);
273out_exit:
274 return res;
275}
diff --git a/fs/partitions/ibm.h b/fs/partitions/ibm.h
deleted file mode 100644
index 08fb0804a812..000000000000
--- a/fs/partitions/ibm.h
+++ /dev/null
@@ -1 +0,0 @@
1int ibm_partition(struct parsed_partitions *);
diff --git a/fs/partitions/karma.c b/fs/partitions/karma.c
deleted file mode 100644
index 0ea19312706b..000000000000
--- a/fs/partitions/karma.c
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * fs/partitions/karma.c
3 * Rio Karma partition info.
4 *
5 * Copyright (C) 2006 Bob Copeland (me@bobcopeland.com)
6 * based on osf.c
7 */
8
9#include "check.h"
10#include "karma.h"
11
12int karma_partition(struct parsed_partitions *state)
13{
14 int i;
15 int slot = 1;
16 Sector sect;
17 unsigned char *data;
18 struct disklabel {
19 u8 d_reserved[270];
20 struct d_partition {
21 __le32 p_res;
22 u8 p_fstype;
23 u8 p_res2[3];
24 __le32 p_offset;
25 __le32 p_size;
26 } d_partitions[2];
27 u8 d_blank[208];
28 __le16 d_magic;
29 } __attribute__((packed)) *label;
30 struct d_partition *p;
31
32 data = read_part_sector(state, 0, &sect);
33 if (!data)
34 return -1;
35
36 label = (struct disklabel *)data;
37 if (le16_to_cpu(label->d_magic) != KARMA_LABEL_MAGIC) {
38 put_dev_sector(sect);
39 return 0;
40 }
41
42 p = label->d_partitions;
43 for (i = 0 ; i < 2; i++, p++) {
44 if (slot == state->limit)
45 break;
46
47 if (p->p_fstype == 0x4d && le32_to_cpu(p->p_size)) {
48 put_partition(state, slot, le32_to_cpu(p->p_offset),
49 le32_to_cpu(p->p_size));
50 }
51 slot++;
52 }
53 strlcat(state->pp_buf, "\n", PAGE_SIZE);
54 put_dev_sector(sect);
55 return 1;
56}
57
diff --git a/fs/partitions/karma.h b/fs/partitions/karma.h
deleted file mode 100644
index c764b2e9df21..000000000000
--- a/fs/partitions/karma.h
+++ /dev/null
@@ -1,8 +0,0 @@
1/*
2 * fs/partitions/karma.h
3 */
4
5#define KARMA_LABEL_MAGIC 0xAB56
6
7int karma_partition(struct parsed_partitions *state);
8
diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c
deleted file mode 100644
index bd8ae788f689..000000000000
--- a/fs/partitions/ldm.c
+++ /dev/null
@@ -1,1570 +0,0 @@
1/**
2 * ldm - Support for Windows Logical Disk Manager (Dynamic Disks)
3 *
4 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
5 * Copyright (c) 2001-2007 Anton Altaparmakov
6 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
7 *
8 * Documentation is available at http://www.linux-ntfs.org/doku.php?id=downloads
9 *
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the License, or (at your option) any later
13 * version.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program (in the main directory of the source in the file COPYING); if
22 * not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23 * Boston, MA 02111-1307 USA
24 */
25
26#include <linux/slab.h>
27#include <linux/pagemap.h>
28#include <linux/stringify.h>
29#include <linux/kernel.h>
30#include "ldm.h"
31#include "check.h"
32#include "msdos.h"
33
34/**
35 * ldm_debug/info/error/crit - Output an error message
36 * @f: A printf format string containing the message
37 * @...: Variables to substitute into @f
38 *
39 * ldm_debug() writes a DEBUG level message to the syslog but only if the
40 * driver was compiled with debug enabled. Otherwise, the call turns into a NOP.
41 */
42#ifndef CONFIG_LDM_DEBUG
43#define ldm_debug(...) do {} while (0)
44#else
45#define ldm_debug(f, a...) _ldm_printk (KERN_DEBUG, __func__, f, ##a)
46#endif
47
48#define ldm_crit(f, a...) _ldm_printk (KERN_CRIT, __func__, f, ##a)
49#define ldm_error(f, a...) _ldm_printk (KERN_ERR, __func__, f, ##a)
50#define ldm_info(f, a...) _ldm_printk (KERN_INFO, __func__, f, ##a)
51
52static __printf(3, 4)
53void _ldm_printk(const char *level, const char *function, const char *fmt, ...)
54{
55 struct va_format vaf;
56 va_list args;
57
58 va_start (args, fmt);
59
60 vaf.fmt = fmt;
61 vaf.va = &args;
62
63 printk("%s%s(): %pV\n", level, function, &vaf);
64
65 va_end(args);
66}
67
68/**
69 * ldm_parse_hexbyte - Convert a ASCII hex number to a byte
70 * @src: Pointer to at least 2 characters to convert.
71 *
72 * Convert a two character ASCII hex string to a number.
73 *
74 * Return: 0-255 Success, the byte was parsed correctly
75 * -1 Error, an invalid character was supplied
76 */
77static int ldm_parse_hexbyte (const u8 *src)
78{
79 unsigned int x; /* For correct wrapping */
80 int h;
81
82 /* high part */
83 x = h = hex_to_bin(src[0]);
84 if (h < 0)
85 return -1;
86
87 /* low part */
88 h = hex_to_bin(src[1]);
89 if (h < 0)
90 return -1;
91
92 return (x << 4) + h;
93}
94
95/**
96 * ldm_parse_guid - Convert GUID from ASCII to binary
97 * @src: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
98 * @dest: Memory block to hold binary GUID (16 bytes)
99 *
100 * N.B. The GUID need not be NULL terminated.
101 *
102 * Return: 'true' @dest contains binary GUID
103 * 'false' @dest contents are undefined
104 */
105static bool ldm_parse_guid (const u8 *src, u8 *dest)
106{
107 static const int size[] = { 4, 2, 2, 2, 6 };
108 int i, j, v;
109
110 if (src[8] != '-' || src[13] != '-' ||
111 src[18] != '-' || src[23] != '-')
112 return false;
113
114 for (j = 0; j < 5; j++, src++)
115 for (i = 0; i < size[j]; i++, src+=2, *dest++ = v)
116 if ((v = ldm_parse_hexbyte (src)) < 0)
117 return false;
118
119 return true;
120}
121
122/**
123 * ldm_parse_privhead - Read the LDM Database PRIVHEAD structure
124 * @data: Raw database PRIVHEAD structure loaded from the device
125 * @ph: In-memory privhead structure in which to return parsed information
126 *
127 * This parses the LDM database PRIVHEAD structure supplied in @data and
128 * sets up the in-memory privhead structure @ph with the obtained information.
129 *
130 * Return: 'true' @ph contains the PRIVHEAD data
131 * 'false' @ph contents are undefined
132 */
133static bool ldm_parse_privhead(const u8 *data, struct privhead *ph)
134{
135 bool is_vista = false;
136
137 BUG_ON(!data || !ph);
138 if (MAGIC_PRIVHEAD != get_unaligned_be64(data)) {
139 ldm_error("Cannot find PRIVHEAD structure. LDM database is"
140 " corrupt. Aborting.");
141 return false;
142 }
143 ph->ver_major = get_unaligned_be16(data + 0x000C);
144 ph->ver_minor = get_unaligned_be16(data + 0x000E);
145 ph->logical_disk_start = get_unaligned_be64(data + 0x011B);
146 ph->logical_disk_size = get_unaligned_be64(data + 0x0123);
147 ph->config_start = get_unaligned_be64(data + 0x012B);
148 ph->config_size = get_unaligned_be64(data + 0x0133);
149 /* Version 2.11 is Win2k/XP and version 2.12 is Vista. */
150 if (ph->ver_major == 2 && ph->ver_minor == 12)
151 is_vista = true;
152 if (!is_vista && (ph->ver_major != 2 || ph->ver_minor != 11)) {
153 ldm_error("Expected PRIVHEAD version 2.11 or 2.12, got %d.%d."
154 " Aborting.", ph->ver_major, ph->ver_minor);
155 return false;
156 }
157 ldm_debug("PRIVHEAD version %d.%d (Windows %s).", ph->ver_major,
158 ph->ver_minor, is_vista ? "Vista" : "2000/XP");
159 if (ph->config_size != LDM_DB_SIZE) { /* 1 MiB in sectors. */
160 /* Warn the user and continue, carefully. */
161 ldm_info("Database is normally %u bytes, it claims to "
162 "be %llu bytes.", LDM_DB_SIZE,
163 (unsigned long long)ph->config_size);
164 }
165 if ((ph->logical_disk_size == 0) || (ph->logical_disk_start +
166 ph->logical_disk_size > ph->config_start)) {
167 ldm_error("PRIVHEAD disk size doesn't match real disk size");
168 return false;
169 }
170 if (!ldm_parse_guid(data + 0x0030, ph->disk_id)) {
171 ldm_error("PRIVHEAD contains an invalid GUID.");
172 return false;
173 }
174 ldm_debug("Parsed PRIVHEAD successfully.");
175 return true;
176}
177
178/**
179 * ldm_parse_tocblock - Read the LDM Database TOCBLOCK structure
180 * @data: Raw database TOCBLOCK structure loaded from the device
181 * @toc: In-memory toc structure in which to return parsed information
182 *
183 * This parses the LDM Database TOCBLOCK (table of contents) structure supplied
184 * in @data and sets up the in-memory tocblock structure @toc with the obtained
185 * information.
186 *
187 * N.B. The *_start and *_size values returned in @toc are not range-checked.
188 *
189 * Return: 'true' @toc contains the TOCBLOCK data
190 * 'false' @toc contents are undefined
191 */
192static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
193{
194 BUG_ON (!data || !toc);
195
196 if (MAGIC_TOCBLOCK != get_unaligned_be64(data)) {
197 ldm_crit ("Cannot find TOCBLOCK, database may be corrupt.");
198 return false;
199 }
200 strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name));
201 toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0;
202 toc->bitmap1_start = get_unaligned_be64(data + 0x2E);
203 toc->bitmap1_size = get_unaligned_be64(data + 0x36);
204
205 if (strncmp (toc->bitmap1_name, TOC_BITMAP1,
206 sizeof (toc->bitmap1_name)) != 0) {
207 ldm_crit ("TOCBLOCK's first bitmap is '%s', should be '%s'.",
208 TOC_BITMAP1, toc->bitmap1_name);
209 return false;
210 }
211 strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name));
212 toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0;
213 toc->bitmap2_start = get_unaligned_be64(data + 0x50);
214 toc->bitmap2_size = get_unaligned_be64(data + 0x58);
215 if (strncmp (toc->bitmap2_name, TOC_BITMAP2,
216 sizeof (toc->bitmap2_name)) != 0) {
217 ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.",
218 TOC_BITMAP2, toc->bitmap2_name);
219 return false;
220 }
221 ldm_debug ("Parsed TOCBLOCK successfully.");
222 return true;
223}
224
225/**
226 * ldm_parse_vmdb - Read the LDM Database VMDB structure
227 * @data: Raw database VMDB structure loaded from the device
228 * @vm: In-memory vmdb structure in which to return parsed information
229 *
230 * This parses the LDM Database VMDB structure supplied in @data and sets up
231 * the in-memory vmdb structure @vm with the obtained information.
232 *
233 * N.B. The *_start, *_size and *_seq values will be range-checked later.
234 *
235 * Return: 'true' @vm contains VMDB info
236 * 'false' @vm contents are undefined
237 */
238static bool ldm_parse_vmdb (const u8 *data, struct vmdb *vm)
239{
240 BUG_ON (!data || !vm);
241
242 if (MAGIC_VMDB != get_unaligned_be32(data)) {
243 ldm_crit ("Cannot find the VMDB, database may be corrupt.");
244 return false;
245 }
246
247 vm->ver_major = get_unaligned_be16(data + 0x12);
248 vm->ver_minor = get_unaligned_be16(data + 0x14);
249 if ((vm->ver_major != 4) || (vm->ver_minor != 10)) {
250 ldm_error ("Expected VMDB version %d.%d, got %d.%d. "
251 "Aborting.", 4, 10, vm->ver_major, vm->ver_minor);
252 return false;
253 }
254
255 vm->vblk_size = get_unaligned_be32(data + 0x08);
256 if (vm->vblk_size == 0) {
257 ldm_error ("Illegal VBLK size");
258 return false;
259 }
260
261 vm->vblk_offset = get_unaligned_be32(data + 0x0C);
262 vm->last_vblk_seq = get_unaligned_be32(data + 0x04);
263
264 ldm_debug ("Parsed VMDB successfully.");
265 return true;
266}
267
268/**
269 * ldm_compare_privheads - Compare two privhead objects
270 * @ph1: First privhead
271 * @ph2: Second privhead
272 *
273 * This compares the two privhead structures @ph1 and @ph2.
274 *
275 * Return: 'true' Identical
276 * 'false' Different
277 */
278static bool ldm_compare_privheads (const struct privhead *ph1,
279 const struct privhead *ph2)
280{
281 BUG_ON (!ph1 || !ph2);
282
283 return ((ph1->ver_major == ph2->ver_major) &&
284 (ph1->ver_minor == ph2->ver_minor) &&
285 (ph1->logical_disk_start == ph2->logical_disk_start) &&
286 (ph1->logical_disk_size == ph2->logical_disk_size) &&
287 (ph1->config_start == ph2->config_start) &&
288 (ph1->config_size == ph2->config_size) &&
289 !memcmp (ph1->disk_id, ph2->disk_id, GUID_SIZE));
290}
291
292/**
293 * ldm_compare_tocblocks - Compare two tocblock objects
294 * @toc1: First toc
295 * @toc2: Second toc
296 *
297 * This compares the two tocblock structures @toc1 and @toc2.
298 *
299 * Return: 'true' Identical
300 * 'false' Different
301 */
302static bool ldm_compare_tocblocks (const struct tocblock *toc1,
303 const struct tocblock *toc2)
304{
305 BUG_ON (!toc1 || !toc2);
306
307 return ((toc1->bitmap1_start == toc2->bitmap1_start) &&
308 (toc1->bitmap1_size == toc2->bitmap1_size) &&
309 (toc1->bitmap2_start == toc2->bitmap2_start) &&
310 (toc1->bitmap2_size == toc2->bitmap2_size) &&
311 !strncmp (toc1->bitmap1_name, toc2->bitmap1_name,
312 sizeof (toc1->bitmap1_name)) &&
313 !strncmp (toc1->bitmap2_name, toc2->bitmap2_name,
314 sizeof (toc1->bitmap2_name)));
315}
316
317/**
318 * ldm_validate_privheads - Compare the primary privhead with its backups
319 * @state: Partition check state including device holding the LDM Database
320 * @ph1: Memory struct to fill with ph contents
321 *
322 * Read and compare all three privheads from disk.
323 *
324 * The privheads on disk show the size and location of the main disk area and
325 * the configuration area (the database). The values are range-checked against
326 * @hd, which contains the real size of the disk.
327 *
328 * Return: 'true' Success
329 * 'false' Error
330 */
331static bool ldm_validate_privheads(struct parsed_partitions *state,
332 struct privhead *ph1)
333{
334 static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 };
335 struct privhead *ph[3] = { ph1 };
336 Sector sect;
337 u8 *data;
338 bool result = false;
339 long num_sects;
340 int i;
341
342 BUG_ON (!state || !ph1);
343
344 ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL);
345 ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL);
346 if (!ph[1] || !ph[2]) {
347 ldm_crit ("Out of memory.");
348 goto out;
349 }
350
351 /* off[1 & 2] are relative to ph[0]->config_start */
352 ph[0]->config_start = 0;
353
354 /* Read and parse privheads */
355 for (i = 0; i < 3; i++) {
356 data = read_part_sector(state, ph[0]->config_start + off[i],
357 &sect);
358 if (!data) {
359 ldm_crit ("Disk read failed.");
360 goto out;
361 }
362 result = ldm_parse_privhead (data, ph[i]);
363 put_dev_sector (sect);
364 if (!result) {
365 ldm_error ("Cannot find PRIVHEAD %d.", i+1); /* Log again */
366 if (i < 2)
367 goto out; /* Already logged */
368 else
369 break; /* FIXME ignore for now, 3rd PH can fail on odd-sized disks */
370 }
371 }
372
373 num_sects = state->bdev->bd_inode->i_size >> 9;
374
375 if ((ph[0]->config_start > num_sects) ||
376 ((ph[0]->config_start + ph[0]->config_size) > num_sects)) {
377 ldm_crit ("Database extends beyond the end of the disk.");
378 goto out;
379 }
380
381 if ((ph[0]->logical_disk_start > ph[0]->config_start) ||
382 ((ph[0]->logical_disk_start + ph[0]->logical_disk_size)
383 > ph[0]->config_start)) {
384 ldm_crit ("Disk and database overlap.");
385 goto out;
386 }
387
388 if (!ldm_compare_privheads (ph[0], ph[1])) {
389 ldm_crit ("Primary and backup PRIVHEADs don't match.");
390 goto out;
391 }
392 /* FIXME ignore this for now
393 if (!ldm_compare_privheads (ph[0], ph[2])) {
394 ldm_crit ("Primary and backup PRIVHEADs don't match.");
395 goto out;
396 }*/
397 ldm_debug ("Validated PRIVHEADs successfully.");
398 result = true;
399out:
400 kfree (ph[1]);
401 kfree (ph[2]);
402 return result;
403}
404
405/**
406 * ldm_validate_tocblocks - Validate the table of contents and its backups
407 * @state: Partition check state including device holding the LDM Database
408 * @base: Offset, into @state->bdev, of the database
409 * @ldb: Cache of the database structures
410 *
411 * Find and compare the four tables of contents of the LDM Database stored on
412 * @state->bdev and return the parsed information into @toc1.
413 *
414 * The offsets and sizes of the configs are range-checked against a privhead.
415 *
416 * Return: 'true' @toc1 contains validated TOCBLOCK info
417 * 'false' @toc1 contents are undefined
418 */
419static bool ldm_validate_tocblocks(struct parsed_partitions *state,
420 unsigned long base, struct ldmdb *ldb)
421{
422 static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4};
423 struct tocblock *tb[4];
424 struct privhead *ph;
425 Sector sect;
426 u8 *data;
427 int i, nr_tbs;
428 bool result = false;
429
430 BUG_ON(!state || !ldb);
431 ph = &ldb->ph;
432 tb[0] = &ldb->toc;
433 tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
434 if (!tb[1]) {
435 ldm_crit("Out of memory.");
436 goto err;
437 }
438 tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1]));
439 tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2]));
440 /*
441 * Try to read and parse all four TOCBLOCKs.
442 *
443 * Windows Vista LDM v2.12 does not always have all four TOCBLOCKs so
444 * skip any that fail as long as we get at least one valid TOCBLOCK.
445 */
446 for (nr_tbs = i = 0; i < 4; i++) {
447 data = read_part_sector(state, base + off[i], &sect);
448 if (!data) {
449 ldm_error("Disk read failed for TOCBLOCK %d.", i);
450 continue;
451 }
452 if (ldm_parse_tocblock(data, tb[nr_tbs]))
453 nr_tbs++;
454 put_dev_sector(sect);
455 }
456 if (!nr_tbs) {
457 ldm_crit("Failed to find a valid TOCBLOCK.");
458 goto err;
459 }
460 /* Range check the TOCBLOCK against a privhead. */
461 if (((tb[0]->bitmap1_start + tb[0]->bitmap1_size) > ph->config_size) ||
462 ((tb[0]->bitmap2_start + tb[0]->bitmap2_size) >
463 ph->config_size)) {
464 ldm_crit("The bitmaps are out of range. Giving up.");
465 goto err;
466 }
467 /* Compare all loaded TOCBLOCKs. */
468 for (i = 1; i < nr_tbs; i++) {
469 if (!ldm_compare_tocblocks(tb[0], tb[i])) {
470 ldm_crit("TOCBLOCKs 0 and %d do not match.", i);
471 goto err;
472 }
473 }
474 ldm_debug("Validated %d TOCBLOCKs successfully.", nr_tbs);
475 result = true;
476err:
477 kfree(tb[1]);
478 return result;
479}
480
481/**
482 * ldm_validate_vmdb - Read the VMDB and validate it
483 * @state: Partition check state including device holding the LDM Database
484 * @base: Offset, into @bdev, of the database
485 * @ldb: Cache of the database structures
486 *
487 * Find the vmdb of the LDM Database stored on @bdev and return the parsed
488 * information in @ldb.
489 *
490 * Return: 'true' @ldb contains validated VBDB info
491 * 'false' @ldb contents are undefined
492 */
493static bool ldm_validate_vmdb(struct parsed_partitions *state,
494 unsigned long base, struct ldmdb *ldb)
495{
496 Sector sect;
497 u8 *data;
498 bool result = false;
499 struct vmdb *vm;
500 struct tocblock *toc;
501
502 BUG_ON (!state || !ldb);
503
504 vm = &ldb->vm;
505 toc = &ldb->toc;
506
507 data = read_part_sector(state, base + OFF_VMDB, &sect);
508 if (!data) {
509 ldm_crit ("Disk read failed.");
510 return false;
511 }
512
513 if (!ldm_parse_vmdb (data, vm))
514 goto out; /* Already logged */
515
516 /* Are there uncommitted transactions? */
517 if (get_unaligned_be16(data + 0x10) != 0x01) {
518 ldm_crit ("Database is not in a consistent state. Aborting.");
519 goto out;
520 }
521
522 if (vm->vblk_offset != 512)
523 ldm_info ("VBLKs start at offset 0x%04x.", vm->vblk_offset);
524
525 /*
526 * The last_vblkd_seq can be before the end of the vmdb, just make sure
527 * it is not out of bounds.
528 */
529 if ((vm->vblk_size * vm->last_vblk_seq) > (toc->bitmap1_size << 9)) {
530 ldm_crit ("VMDB exceeds allowed size specified by TOCBLOCK. "
531 "Database is corrupt. Aborting.");
532 goto out;
533 }
534
535 result = true;
536out:
537 put_dev_sector (sect);
538 return result;
539}
540
541
542/**
543 * ldm_validate_partition_table - Determine whether bdev might be a dynamic disk
544 * @state: Partition check state including device holding the LDM Database
545 *
546 * This function provides a weak test to decide whether the device is a dynamic
547 * disk or not. It looks for an MS-DOS-style partition table containing at
548 * least one partition of type 0x42 (formerly SFS, now used by Windows for
549 * dynamic disks).
550 *
551 * N.B. The only possible error can come from the read_part_sector and that is
552 * only likely to happen if the underlying device is strange. If that IS
553 * the case we should return zero to let someone else try.
554 *
555 * Return: 'true' @state->bdev is a dynamic disk
556 * 'false' @state->bdev is not a dynamic disk, or an error occurred
557 */
558static bool ldm_validate_partition_table(struct parsed_partitions *state)
559{
560 Sector sect;
561 u8 *data;
562 struct partition *p;
563 int i;
564 bool result = false;
565
566 BUG_ON(!state);
567
568 data = read_part_sector(state, 0, &sect);
569 if (!data) {
570 ldm_info ("Disk read failed.");
571 return false;
572 }
573
574 if (*(__le16*) (data + 0x01FE) != cpu_to_le16 (MSDOS_LABEL_MAGIC))
575 goto out;
576
577 p = (struct partition*)(data + 0x01BE);
578 for (i = 0; i < 4; i++, p++)
579 if (SYS_IND (p) == LDM_PARTITION) {
580 result = true;
581 break;
582 }
583
584 if (result)
585 ldm_debug ("Found W2K dynamic disk partition type.");
586
587out:
588 put_dev_sector (sect);
589 return result;
590}
591
592/**
593 * ldm_get_disk_objid - Search a linked list of vblk's for a given Disk Id
594 * @ldb: Cache of the database structures
595 *
596 * The LDM Database contains a list of all partitions on all dynamic disks.
597 * The primary PRIVHEAD, at the beginning of the physical disk, tells us
598 * the GUID of this disk. This function searches for the GUID in a linked
599 * list of vblk's.
600 *
601 * Return: Pointer, A matching vblk was found
602 * NULL, No match, or an error
603 */
604static struct vblk * ldm_get_disk_objid (const struct ldmdb *ldb)
605{
606 struct list_head *item;
607
608 BUG_ON (!ldb);
609
610 list_for_each (item, &ldb->v_disk) {
611 struct vblk *v = list_entry (item, struct vblk, list);
612 if (!memcmp (v->vblk.disk.disk_id, ldb->ph.disk_id, GUID_SIZE))
613 return v;
614 }
615
616 return NULL;
617}
618
619/**
620 * ldm_create_data_partitions - Create data partitions for this device
621 * @pp: List of the partitions parsed so far
622 * @ldb: Cache of the database structures
623 *
624 * The database contains ALL the partitions for ALL disk groups, so we need to
625 * filter out this specific disk. Using the disk's object id, we can find all
626 * the partitions in the database that belong to this disk.
627 *
628 * Add each partition in our database, to the parsed_partitions structure.
629 *
630 * N.B. This function creates the partitions in the order it finds partition
631 * objects in the linked list.
632 *
633 * Return: 'true' Partition created
634 * 'false' Error, probably a range checking problem
635 */
636static bool ldm_create_data_partitions (struct parsed_partitions *pp,
637 const struct ldmdb *ldb)
638{
639 struct list_head *item;
640 struct vblk *vb;
641 struct vblk *disk;
642 struct vblk_part *part;
643 int part_num = 1;
644
645 BUG_ON (!pp || !ldb);
646
647 disk = ldm_get_disk_objid (ldb);
648 if (!disk) {
649 ldm_crit ("Can't find the ID of this disk in the database.");
650 return false;
651 }
652
653 strlcat(pp->pp_buf, " [LDM]", PAGE_SIZE);
654
655 /* Create the data partitions */
656 list_for_each (item, &ldb->v_part) {
657 vb = list_entry (item, struct vblk, list);
658 part = &vb->vblk.part;
659
660 if (part->disk_id != disk->obj_id)
661 continue;
662
663 put_partition (pp, part_num, ldb->ph.logical_disk_start +
664 part->start, part->size);
665 part_num++;
666 }
667
668 strlcat(pp->pp_buf, "\n", PAGE_SIZE);
669 return true;
670}
671
672
673/**
674 * ldm_relative - Calculate the next relative offset
675 * @buffer: Block of data being worked on
676 * @buflen: Size of the block of data
677 * @base: Size of the previous fixed width fields
678 * @offset: Cumulative size of the previous variable-width fields
679 *
680 * Because many of the VBLK fields are variable-width, it's necessary
681 * to calculate each offset based on the previous one and the length
682 * of the field it pointed to.
683 *
684 * Return: -1 Error, the calculated offset exceeded the size of the buffer
685 * n OK, a range-checked offset into buffer
686 */
687static int ldm_relative(const u8 *buffer, int buflen, int base, int offset)
688{
689
690 base += offset;
691 if (!buffer || offset < 0 || base > buflen) {
692 if (!buffer)
693 ldm_error("!buffer");
694 if (offset < 0)
695 ldm_error("offset (%d) < 0", offset);
696 if (base > buflen)
697 ldm_error("base (%d) > buflen (%d)", base, buflen);
698 return -1;
699 }
700 if (base + buffer[base] >= buflen) {
701 ldm_error("base (%d) + buffer[base] (%d) >= buflen (%d)", base,
702 buffer[base], buflen);
703 return -1;
704 }
705 return buffer[base] + offset + 1;
706}
707
708/**
709 * ldm_get_vnum - Convert a variable-width, big endian number, into cpu order
710 * @block: Pointer to the variable-width number to convert
711 *
712 * Large numbers in the LDM Database are often stored in a packed format. Each
713 * number is prefixed by a one byte width marker. All numbers in the database
714 * are stored in big-endian byte order. This function reads one of these
715 * numbers and returns the result
716 *
717 * N.B. This function DOES NOT perform any range checking, though the most
718 * it will read is eight bytes.
719 *
720 * Return: n A number
721 * 0 Zero, or an error occurred
722 */
723static u64 ldm_get_vnum (const u8 *block)
724{
725 u64 tmp = 0;
726 u8 length;
727
728 BUG_ON (!block);
729
730 length = *block++;
731
732 if (length && length <= 8)
733 while (length--)
734 tmp = (tmp << 8) | *block++;
735 else
736 ldm_error ("Illegal length %d.", length);
737
738 return tmp;
739}
740
741/**
742 * ldm_get_vstr - Read a length-prefixed string into a buffer
743 * @block: Pointer to the length marker
744 * @buffer: Location to copy string to
745 * @buflen: Size of the output buffer
746 *
747 * Many of the strings in the LDM Database are not NULL terminated. Instead
748 * they are prefixed by a one byte length marker. This function copies one of
749 * these strings into a buffer.
750 *
751 * N.B. This function DOES NOT perform any range checking on the input.
752 * If the buffer is too small, the output will be truncated.
753 *
754 * Return: 0, Error and @buffer contents are undefined
755 * n, String length in characters (excluding NULL)
756 * buflen-1, String was truncated.
757 */
758static int ldm_get_vstr (const u8 *block, u8 *buffer, int buflen)
759{
760 int length;
761
762 BUG_ON (!block || !buffer);
763
764 length = block[0];
765 if (length >= buflen) {
766 ldm_error ("Truncating string %d -> %d.", length, buflen);
767 length = buflen - 1;
768 }
769 memcpy (buffer, block + 1, length);
770 buffer[length] = 0;
771 return length;
772}
773
774
775/**
776 * ldm_parse_cmp3 - Read a raw VBLK Component object into a vblk structure
777 * @buffer: Block of data being worked on
778 * @buflen: Size of the block of data
779 * @vb: In-memory vblk in which to return information
780 *
781 * Read a raw VBLK Component object (version 3) into a vblk structure.
782 *
783 * Return: 'true' @vb contains a Component VBLK
784 * 'false' @vb contents are not defined
785 */
786static bool ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
787{
788 int r_objid, r_name, r_vstate, r_child, r_parent, r_stripe, r_cols, len;
789 struct vblk_comp *comp;
790
791 BUG_ON (!buffer || !vb);
792
793 r_objid = ldm_relative (buffer, buflen, 0x18, 0);
794 r_name = ldm_relative (buffer, buflen, 0x18, r_objid);
795 r_vstate = ldm_relative (buffer, buflen, 0x18, r_name);
796 r_child = ldm_relative (buffer, buflen, 0x1D, r_vstate);
797 r_parent = ldm_relative (buffer, buflen, 0x2D, r_child);
798
799 if (buffer[0x12] & VBLK_FLAG_COMP_STRIPE) {
800 r_stripe = ldm_relative (buffer, buflen, 0x2E, r_parent);
801 r_cols = ldm_relative (buffer, buflen, 0x2E, r_stripe);
802 len = r_cols;
803 } else {
804 r_stripe = 0;
805 r_cols = 0;
806 len = r_parent;
807 }
808 if (len < 0)
809 return false;
810
811 len += VBLK_SIZE_CMP3;
812 if (len != get_unaligned_be32(buffer + 0x14))
813 return false;
814
815 comp = &vb->vblk.comp;
816 ldm_get_vstr (buffer + 0x18 + r_name, comp->state,
817 sizeof (comp->state));
818 comp->type = buffer[0x18 + r_vstate];
819 comp->children = ldm_get_vnum (buffer + 0x1D + r_vstate);
820 comp->parent_id = ldm_get_vnum (buffer + 0x2D + r_child);
821 comp->chunksize = r_stripe ? ldm_get_vnum (buffer+r_parent+0x2E) : 0;
822
823 return true;
824}
825
826/**
827 * ldm_parse_dgr3 - Read a raw VBLK Disk Group object into a vblk structure
828 * @buffer: Block of data being worked on
829 * @buflen: Size of the block of data
830 * @vb: In-memory vblk in which to return information
831 *
832 * Read a raw VBLK Disk Group object (version 3) into a vblk structure.
833 *
834 * Return: 'true' @vb contains a Disk Group VBLK
835 * 'false' @vb contents are not defined
836 */
837static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb)
838{
839 int r_objid, r_name, r_diskid, r_id1, r_id2, len;
840 struct vblk_dgrp *dgrp;
841
842 BUG_ON (!buffer || !vb);
843
844 r_objid = ldm_relative (buffer, buflen, 0x18, 0);
845 r_name = ldm_relative (buffer, buflen, 0x18, r_objid);
846 r_diskid = ldm_relative (buffer, buflen, 0x18, r_name);
847
848 if (buffer[0x12] & VBLK_FLAG_DGR3_IDS) {
849 r_id1 = ldm_relative (buffer, buflen, 0x24, r_diskid);
850 r_id2 = ldm_relative (buffer, buflen, 0x24, r_id1);
851 len = r_id2;
852 } else {
853 r_id1 = 0;
854 r_id2 = 0;
855 len = r_diskid;
856 }
857 if (len < 0)
858 return false;
859
860 len += VBLK_SIZE_DGR3;
861 if (len != get_unaligned_be32(buffer + 0x14))
862 return false;
863
864 dgrp = &vb->vblk.dgrp;
865 ldm_get_vstr (buffer + 0x18 + r_name, dgrp->disk_id,
866 sizeof (dgrp->disk_id));
867 return true;
868}
869
870/**
871 * ldm_parse_dgr4 - Read a raw VBLK Disk Group object into a vblk structure
872 * @buffer: Block of data being worked on
873 * @buflen: Size of the block of data
874 * @vb: In-memory vblk in which to return information
875 *
876 * Read a raw VBLK Disk Group object (version 4) into a vblk structure.
877 *
878 * Return: 'true' @vb contains a Disk Group VBLK
879 * 'false' @vb contents are not defined
880 */
881static bool ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb)
882{
883 char buf[64];
884 int r_objid, r_name, r_id1, r_id2, len;
885 struct vblk_dgrp *dgrp;
886
887 BUG_ON (!buffer || !vb);
888
889 r_objid = ldm_relative (buffer, buflen, 0x18, 0);
890 r_name = ldm_relative (buffer, buflen, 0x18, r_objid);
891
892 if (buffer[0x12] & VBLK_FLAG_DGR4_IDS) {
893 r_id1 = ldm_relative (buffer, buflen, 0x44, r_name);
894 r_id2 = ldm_relative (buffer, buflen, 0x44, r_id1);
895 len = r_id2;
896 } else {
897 r_id1 = 0;
898 r_id2 = 0;
899 len = r_name;
900 }
901 if (len < 0)
902 return false;
903
904 len += VBLK_SIZE_DGR4;
905 if (len != get_unaligned_be32(buffer + 0x14))
906 return false;
907
908 dgrp = &vb->vblk.dgrp;
909
910 ldm_get_vstr (buffer + 0x18 + r_objid, buf, sizeof (buf));
911 return true;
912}
913
914/**
915 * ldm_parse_dsk3 - Read a raw VBLK Disk object into a vblk structure
916 * @buffer: Block of data being worked on
917 * @buflen: Size of the block of data
918 * @vb: In-memory vblk in which to return information
919 *
920 * Read a raw VBLK Disk object (version 3) into a vblk structure.
921 *
922 * Return: 'true' @vb contains a Disk VBLK
923 * 'false' @vb contents are not defined
924 */
925static bool ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
926{
927 int r_objid, r_name, r_diskid, r_altname, len;
928 struct vblk_disk *disk;
929
930 BUG_ON (!buffer || !vb);
931
932 r_objid = ldm_relative (buffer, buflen, 0x18, 0);
933 r_name = ldm_relative (buffer, buflen, 0x18, r_objid);
934 r_diskid = ldm_relative (buffer, buflen, 0x18, r_name);
935 r_altname = ldm_relative (buffer, buflen, 0x18, r_diskid);
936 len = r_altname;
937 if (len < 0)
938 return false;
939
940 len += VBLK_SIZE_DSK3;
941 if (len != get_unaligned_be32(buffer + 0x14))
942 return false;
943
944 disk = &vb->vblk.disk;
945 ldm_get_vstr (buffer + 0x18 + r_diskid, disk->alt_name,
946 sizeof (disk->alt_name));
947 if (!ldm_parse_guid (buffer + 0x19 + r_name, disk->disk_id))
948 return false;
949
950 return true;
951}
952
953/**
954 * ldm_parse_dsk4 - Read a raw VBLK Disk object into a vblk structure
955 * @buffer: Block of data being worked on
956 * @buflen: Size of the block of data
957 * @vb: In-memory vblk in which to return information
958 *
959 * Read a raw VBLK Disk object (version 4) into a vblk structure.
960 *
961 * Return: 'true' @vb contains a Disk VBLK
962 * 'false' @vb contents are not defined
963 */
964static bool ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
965{
966 int r_objid, r_name, len;
967 struct vblk_disk *disk;
968
969 BUG_ON (!buffer || !vb);
970
971 r_objid = ldm_relative (buffer, buflen, 0x18, 0);
972 r_name = ldm_relative (buffer, buflen, 0x18, r_objid);
973 len = r_name;
974 if (len < 0)
975 return false;
976
977 len += VBLK_SIZE_DSK4;
978 if (len != get_unaligned_be32(buffer + 0x14))
979 return false;
980
981 disk = &vb->vblk.disk;
982 memcpy (disk->disk_id, buffer + 0x18 + r_name, GUID_SIZE);
983 return true;
984}
985
986/**
987 * ldm_parse_prt3 - Read a raw VBLK Partition object into a vblk structure
988 * @buffer: Block of data being worked on
989 * @buflen: Size of the block of data
990 * @vb: In-memory vblk in which to return information
991 *
992 * Read a raw VBLK Partition object (version 3) into a vblk structure.
993 *
994 * Return: 'true' @vb contains a Partition VBLK
995 * 'false' @vb contents are not defined
996 */
997static bool ldm_parse_prt3(const u8 *buffer, int buflen, struct vblk *vb)
998{
999 int r_objid, r_name, r_size, r_parent, r_diskid, r_index, len;
1000 struct vblk_part *part;
1001
1002 BUG_ON(!buffer || !vb);
1003 r_objid = ldm_relative(buffer, buflen, 0x18, 0);
1004 if (r_objid < 0) {
1005 ldm_error("r_objid %d < 0", r_objid);
1006 return false;
1007 }
1008 r_name = ldm_relative(buffer, buflen, 0x18, r_objid);
1009 if (r_name < 0) {
1010 ldm_error("r_name %d < 0", r_name);
1011 return false;
1012 }
1013 r_size = ldm_relative(buffer, buflen, 0x34, r_name);
1014 if (r_size < 0) {
1015 ldm_error("r_size %d < 0", r_size);
1016 return false;
1017 }
1018 r_parent = ldm_relative(buffer, buflen, 0x34, r_size);
1019 if (r_parent < 0) {
1020 ldm_error("r_parent %d < 0", r_parent);
1021 return false;
1022 }
1023 r_diskid = ldm_relative(buffer, buflen, 0x34, r_parent);
1024 if (r_diskid < 0) {
1025 ldm_error("r_diskid %d < 0", r_diskid);
1026 return false;
1027 }
1028 if (buffer[0x12] & VBLK_FLAG_PART_INDEX) {
1029 r_index = ldm_relative(buffer, buflen, 0x34, r_diskid);
1030 if (r_index < 0) {
1031 ldm_error("r_index %d < 0", r_index);
1032 return false;
1033 }
1034 len = r_index;
1035 } else {
1036 r_index = 0;
1037 len = r_diskid;
1038 }
1039 if (len < 0) {
1040 ldm_error("len %d < 0", len);
1041 return false;
1042 }
1043 len += VBLK_SIZE_PRT3;
1044 if (len > get_unaligned_be32(buffer + 0x14)) {
1045 ldm_error("len %d > BE32(buffer + 0x14) %d", len,
1046 get_unaligned_be32(buffer + 0x14));
1047 return false;
1048 }
1049 part = &vb->vblk.part;
1050 part->start = get_unaligned_be64(buffer + 0x24 + r_name);
1051 part->volume_offset = get_unaligned_be64(buffer + 0x2C + r_name);
1052 part->size = ldm_get_vnum(buffer + 0x34 + r_name);
1053 part->parent_id = ldm_get_vnum(buffer + 0x34 + r_size);
1054 part->disk_id = ldm_get_vnum(buffer + 0x34 + r_parent);
1055 if (vb->flags & VBLK_FLAG_PART_INDEX)
1056 part->partnum = buffer[0x35 + r_diskid];
1057 else
1058 part->partnum = 0;
1059 return true;
1060}
1061
1062/**
1063 * ldm_parse_vol5 - Read a raw VBLK Volume object into a vblk structure
1064 * @buffer: Block of data being worked on
1065 * @buflen: Size of the block of data
1066 * @vb: In-memory vblk in which to return information
1067 *
1068 * Read a raw VBLK Volume object (version 5) into a vblk structure.
1069 *
1070 * Return: 'true' @vb contains a Volume VBLK
1071 * 'false' @vb contents are not defined
1072 */
1073static bool ldm_parse_vol5(const u8 *buffer, int buflen, struct vblk *vb)
1074{
1075 int r_objid, r_name, r_vtype, r_disable_drive_letter, r_child, r_size;
1076 int r_id1, r_id2, r_size2, r_drive, len;
1077 struct vblk_volu *volu;
1078
1079 BUG_ON(!buffer || !vb);
1080 r_objid = ldm_relative(buffer, buflen, 0x18, 0);
1081 if (r_objid < 0) {
1082 ldm_error("r_objid %d < 0", r_objid);
1083 return false;
1084 }
1085 r_name = ldm_relative(buffer, buflen, 0x18, r_objid);
1086 if (r_name < 0) {
1087 ldm_error("r_name %d < 0", r_name);
1088 return false;
1089 }
1090 r_vtype = ldm_relative(buffer, buflen, 0x18, r_name);
1091 if (r_vtype < 0) {
1092 ldm_error("r_vtype %d < 0", r_vtype);
1093 return false;
1094 }
1095 r_disable_drive_letter = ldm_relative(buffer, buflen, 0x18, r_vtype);
1096 if (r_disable_drive_letter < 0) {
1097 ldm_error("r_disable_drive_letter %d < 0",
1098 r_disable_drive_letter);
1099 return false;
1100 }
1101 r_child = ldm_relative(buffer, buflen, 0x2D, r_disable_drive_letter);
1102 if (r_child < 0) {
1103 ldm_error("r_child %d < 0", r_child);
1104 return false;
1105 }
1106 r_size = ldm_relative(buffer, buflen, 0x3D, r_child);
1107 if (r_size < 0) {
1108 ldm_error("r_size %d < 0", r_size);
1109 return false;
1110 }
1111 if (buffer[0x12] & VBLK_FLAG_VOLU_ID1) {
1112 r_id1 = ldm_relative(buffer, buflen, 0x52, r_size);
1113 if (r_id1 < 0) {
1114 ldm_error("r_id1 %d < 0", r_id1);
1115 return false;
1116 }
1117 } else
1118 r_id1 = r_size;
1119 if (buffer[0x12] & VBLK_FLAG_VOLU_ID2) {
1120 r_id2 = ldm_relative(buffer, buflen, 0x52, r_id1);
1121 if (r_id2 < 0) {
1122 ldm_error("r_id2 %d < 0", r_id2);
1123 return false;
1124 }
1125 } else
1126 r_id2 = r_id1;
1127 if (buffer[0x12] & VBLK_FLAG_VOLU_SIZE) {
1128 r_size2 = ldm_relative(buffer, buflen, 0x52, r_id2);
1129 if (r_size2 < 0) {
1130 ldm_error("r_size2 %d < 0", r_size2);
1131 return false;
1132 }
1133 } else
1134 r_size2 = r_id2;
1135 if (buffer[0x12] & VBLK_FLAG_VOLU_DRIVE) {
1136 r_drive = ldm_relative(buffer, buflen, 0x52, r_size2);
1137 if (r_drive < 0) {
1138 ldm_error("r_drive %d < 0", r_drive);
1139 return false;
1140 }
1141 } else
1142 r_drive = r_size2;
1143 len = r_drive;
1144 if (len < 0) {
1145 ldm_error("len %d < 0", len);
1146 return false;
1147 }
1148 len += VBLK_SIZE_VOL5;
1149 if (len > get_unaligned_be32(buffer + 0x14)) {
1150 ldm_error("len %d > BE32(buffer + 0x14) %d", len,
1151 get_unaligned_be32(buffer + 0x14));
1152 return false;
1153 }
1154 volu = &vb->vblk.volu;
1155 ldm_get_vstr(buffer + 0x18 + r_name, volu->volume_type,
1156 sizeof(volu->volume_type));
1157 memcpy(volu->volume_state, buffer + 0x18 + r_disable_drive_letter,
1158 sizeof(volu->volume_state));
1159 volu->size = ldm_get_vnum(buffer + 0x3D + r_child);
1160 volu->partition_type = buffer[0x41 + r_size];
1161 memcpy(volu->guid, buffer + 0x42 + r_size, sizeof(volu->guid));
1162 if (buffer[0x12] & VBLK_FLAG_VOLU_DRIVE) {
1163 ldm_get_vstr(buffer + 0x52 + r_size, volu->drive_hint,
1164 sizeof(volu->drive_hint));
1165 }
1166 return true;
1167}
1168
1169/**
1170 * ldm_parse_vblk - Read a raw VBLK object into a vblk structure
1171 * @buf: Block of data being worked on
1172 * @len: Size of the block of data
1173 * @vb: In-memory vblk in which to return information
1174 *
1175 * Read a raw VBLK object into a vblk structure. This function just reads the
1176 * information common to all VBLK types, then delegates the rest of the work to
1177 * helper functions: ldm_parse_*.
1178 *
1179 * Return: 'true' @vb contains a VBLK
1180 * 'false' @vb contents are not defined
1181 */
1182static bool ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb)
1183{
1184 bool result = false;
1185 int r_objid;
1186
1187 BUG_ON (!buf || !vb);
1188
1189 r_objid = ldm_relative (buf, len, 0x18, 0);
1190 if (r_objid < 0) {
1191 ldm_error ("VBLK header is corrupt.");
1192 return false;
1193 }
1194
1195 vb->flags = buf[0x12];
1196 vb->type = buf[0x13];
1197 vb->obj_id = ldm_get_vnum (buf + 0x18);
1198 ldm_get_vstr (buf+0x18+r_objid, vb->name, sizeof (vb->name));
1199
1200 switch (vb->type) {
1201 case VBLK_CMP3: result = ldm_parse_cmp3 (buf, len, vb); break;
1202 case VBLK_DSK3: result = ldm_parse_dsk3 (buf, len, vb); break;
1203 case VBLK_DSK4: result = ldm_parse_dsk4 (buf, len, vb); break;
1204 case VBLK_DGR3: result = ldm_parse_dgr3 (buf, len, vb); break;
1205 case VBLK_DGR4: result = ldm_parse_dgr4 (buf, len, vb); break;
1206 case VBLK_PRT3: result = ldm_parse_prt3 (buf, len, vb); break;
1207 case VBLK_VOL5: result = ldm_parse_vol5 (buf, len, vb); break;
1208 }
1209
1210 if (result)
1211 ldm_debug ("Parsed VBLK 0x%llx (type: 0x%02x) ok.",
1212 (unsigned long long) vb->obj_id, vb->type);
1213 else
1214 ldm_error ("Failed to parse VBLK 0x%llx (type: 0x%02x).",
1215 (unsigned long long) vb->obj_id, vb->type);
1216
1217 return result;
1218}
1219
1220
1221/**
1222 * ldm_ldmdb_add - Adds a raw VBLK entry to the ldmdb database
1223 * @data: Raw VBLK to add to the database
1224 * @len: Size of the raw VBLK
1225 * @ldb: Cache of the database structures
1226 *
1227 * The VBLKs are sorted into categories. Partitions are also sorted by offset.
1228 *
1229 * N.B. This function does not check the validity of the VBLKs.
1230 *
1231 * Return: 'true' The VBLK was added
1232 * 'false' An error occurred
1233 */
1234static bool ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
1235{
1236 struct vblk *vb;
1237 struct list_head *item;
1238
1239 BUG_ON (!data || !ldb);
1240
1241 vb = kmalloc (sizeof (*vb), GFP_KERNEL);
1242 if (!vb) {
1243 ldm_crit ("Out of memory.");
1244 return false;
1245 }
1246
1247 if (!ldm_parse_vblk (data, len, vb)) {
1248 kfree(vb);
1249 return false; /* Already logged */
1250 }
1251
1252 /* Put vblk into the correct list. */
1253 switch (vb->type) {
1254 case VBLK_DGR3:
1255 case VBLK_DGR4:
1256 list_add (&vb->list, &ldb->v_dgrp);
1257 break;
1258 case VBLK_DSK3:
1259 case VBLK_DSK4:
1260 list_add (&vb->list, &ldb->v_disk);
1261 break;
1262 case VBLK_VOL5:
1263 list_add (&vb->list, &ldb->v_volu);
1264 break;
1265 case VBLK_CMP3:
1266 list_add (&vb->list, &ldb->v_comp);
1267 break;
1268 case VBLK_PRT3:
1269 /* Sort by the partition's start sector. */
1270 list_for_each (item, &ldb->v_part) {
1271 struct vblk *v = list_entry (item, struct vblk, list);
1272 if ((v->vblk.part.disk_id == vb->vblk.part.disk_id) &&
1273 (v->vblk.part.start > vb->vblk.part.start)) {
1274 list_add_tail (&vb->list, &v->list);
1275 return true;
1276 }
1277 }
1278 list_add_tail (&vb->list, &ldb->v_part);
1279 break;
1280 }
1281 return true;
1282}
1283
1284/**
1285 * ldm_frag_add - Add a VBLK fragment to a list
1286 * @data: Raw fragment to be added to the list
1287 * @size: Size of the raw fragment
1288 * @frags: Linked list of VBLK fragments
1289 *
1290 * Fragmented VBLKs may not be consecutive in the database, so they are placed
1291 * in a list so they can be pieced together later.
1292 *
1293 * Return: 'true' Success, the VBLK was added to the list
1294 * 'false' Error, a problem occurred
1295 */
1296static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags)
1297{
1298 struct frag *f;
1299 struct list_head *item;
1300 int rec, num, group;
1301
1302 BUG_ON (!data || !frags);
1303
1304 if (size < 2 * VBLK_SIZE_HEAD) {
1305 ldm_error("Value of size is to small.");
1306 return false;
1307 }
1308
1309 group = get_unaligned_be32(data + 0x08);
1310 rec = get_unaligned_be16(data + 0x0C);
1311 num = get_unaligned_be16(data + 0x0E);
1312 if ((num < 1) || (num > 4)) {
1313 ldm_error ("A VBLK claims to have %d parts.", num);
1314 return false;
1315 }
1316 if (rec >= num) {
1317 ldm_error("REC value (%d) exceeds NUM value (%d)", rec, num);
1318 return false;
1319 }
1320
1321 list_for_each (item, frags) {
1322 f = list_entry (item, struct frag, list);
1323 if (f->group == group)
1324 goto found;
1325 }
1326
1327 f = kmalloc (sizeof (*f) + size*num, GFP_KERNEL);
1328 if (!f) {
1329 ldm_crit ("Out of memory.");
1330 return false;
1331 }
1332
1333 f->group = group;
1334 f->num = num;
1335 f->rec = rec;
1336 f->map = 0xFF << num;
1337
1338 list_add_tail (&f->list, frags);
1339found:
1340 if (rec >= f->num) {
1341 ldm_error("REC value (%d) exceeds NUM value (%d)", rec, f->num);
1342 return false;
1343 }
1344
1345 if (f->map & (1 << rec)) {
1346 ldm_error ("Duplicate VBLK, part %d.", rec);
1347 f->map &= 0x7F; /* Mark the group as broken */
1348 return false;
1349 }
1350
1351 f->map |= (1 << rec);
1352
1353 data += VBLK_SIZE_HEAD;
1354 size -= VBLK_SIZE_HEAD;
1355
1356 memcpy (f->data+rec*(size-VBLK_SIZE_HEAD)+VBLK_SIZE_HEAD, data, size);
1357
1358 return true;
1359}
1360
1361/**
1362 * ldm_frag_free - Free a linked list of VBLK fragments
1363 * @list: Linked list of fragments
1364 *
1365 * Free a linked list of VBLK fragments
1366 *
1367 * Return: none
1368 */
1369static void ldm_frag_free (struct list_head *list)
1370{
1371 struct list_head *item, *tmp;
1372
1373 BUG_ON (!list);
1374
1375 list_for_each_safe (item, tmp, list)
1376 kfree (list_entry (item, struct frag, list));
1377}
1378
1379/**
1380 * ldm_frag_commit - Validate fragmented VBLKs and add them to the database
1381 * @frags: Linked list of VBLK fragments
1382 * @ldb: Cache of the database structures
1383 *
1384 * Now that all the fragmented VBLKs have been collected, they must be added to
1385 * the database for later use.
1386 *
1387 * Return: 'true' All the fragments we added successfully
1388 * 'false' One or more of the fragments we invalid
1389 */
1390static bool ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb)
1391{
1392 struct frag *f;
1393 struct list_head *item;
1394
1395 BUG_ON (!frags || !ldb);
1396
1397 list_for_each (item, frags) {
1398 f = list_entry (item, struct frag, list);
1399
1400 if (f->map != 0xFF) {
1401 ldm_error ("VBLK group %d is incomplete (0x%02x).",
1402 f->group, f->map);
1403 return false;
1404 }
1405
1406 if (!ldm_ldmdb_add (f->data, f->num*ldb->vm.vblk_size, ldb))
1407 return false; /* Already logged */
1408 }
1409 return true;
1410}
1411
1412/**
1413 * ldm_get_vblks - Read the on-disk database of VBLKs into memory
1414 * @state: Partition check state including device holding the LDM Database
1415 * @base: Offset, into @state->bdev, of the database
1416 * @ldb: Cache of the database structures
1417 *
1418 * To use the information from the VBLKs, they need to be read from the disk,
1419 * unpacked and validated. We cache them in @ldb according to their type.
1420 *
1421 * Return: 'true' All the VBLKs were read successfully
1422 * 'false' An error occurred
1423 */
1424static bool ldm_get_vblks(struct parsed_partitions *state, unsigned long base,
1425 struct ldmdb *ldb)
1426{
1427 int size, perbuf, skip, finish, s, v, recs;
1428 u8 *data = NULL;
1429 Sector sect;
1430 bool result = false;
1431 LIST_HEAD (frags);
1432
1433 BUG_ON(!state || !ldb);
1434
1435 size = ldb->vm.vblk_size;
1436 perbuf = 512 / size;
1437 skip = ldb->vm.vblk_offset >> 9; /* Bytes to sectors */
1438 finish = (size * ldb->vm.last_vblk_seq) >> 9;
1439
1440 for (s = skip; s < finish; s++) { /* For each sector */
1441 data = read_part_sector(state, base + OFF_VMDB + s, &sect);
1442 if (!data) {
1443 ldm_crit ("Disk read failed.");
1444 goto out;
1445 }
1446
1447 for (v = 0; v < perbuf; v++, data+=size) { /* For each vblk */
1448 if (MAGIC_VBLK != get_unaligned_be32(data)) {
1449 ldm_error ("Expected to find a VBLK.");
1450 goto out;
1451 }
1452
1453 recs = get_unaligned_be16(data + 0x0E); /* Number of records */
1454 if (recs == 1) {
1455 if (!ldm_ldmdb_add (data, size, ldb))
1456 goto out; /* Already logged */
1457 } else if (recs > 1) {
1458 if (!ldm_frag_add (data, size, &frags))
1459 goto out; /* Already logged */
1460 }
1461 /* else Record is not in use, ignore it. */
1462 }
1463 put_dev_sector (sect);
1464 data = NULL;
1465 }
1466
1467 result = ldm_frag_commit (&frags, ldb); /* Failures, already logged */
1468out:
1469 if (data)
1470 put_dev_sector (sect);
1471 ldm_frag_free (&frags);
1472
1473 return result;
1474}
1475
1476/**
1477 * ldm_free_vblks - Free a linked list of vblk's
1478 * @lh: Head of a linked list of struct vblk
1479 *
1480 * Free a list of vblk's and free the memory used to maintain the list.
1481 *
1482 * Return: none
1483 */
1484static void ldm_free_vblks (struct list_head *lh)
1485{
1486 struct list_head *item, *tmp;
1487
1488 BUG_ON (!lh);
1489
1490 list_for_each_safe (item, tmp, lh)
1491 kfree (list_entry (item, struct vblk, list));
1492}
1493
1494
1495/**
1496 * ldm_partition - Find out whether a device is a dynamic disk and handle it
1497 * @state: Partition check state including device holding the LDM Database
1498 *
1499 * This determines whether the device @bdev is a dynamic disk and if so creates
1500 * the partitions necessary in the gendisk structure pointed to by @hd.
1501 *
1502 * We create a dummy device 1, which contains the LDM database, and then create
1503 * each partition described by the LDM database in sequence as devices 2+. For
1504 * example, if the device is hda, we would have: hda1: LDM database, hda2, hda3,
1505 * and so on: the actual data containing partitions.
1506 *
1507 * Return: 1 Success, @state->bdev is a dynamic disk and we handled it
1508 * 0 Success, @state->bdev is not a dynamic disk
1509 * -1 An error occurred before enough information had been read
1510 * Or @state->bdev is a dynamic disk, but it may be corrupted
1511 */
1512int ldm_partition(struct parsed_partitions *state)
1513{
1514 struct ldmdb *ldb;
1515 unsigned long base;
1516 int result = -1;
1517
1518 BUG_ON(!state);
1519
1520 /* Look for signs of a Dynamic Disk */
1521 if (!ldm_validate_partition_table(state))
1522 return 0;
1523
1524 ldb = kmalloc (sizeof (*ldb), GFP_KERNEL);
1525 if (!ldb) {
1526 ldm_crit ("Out of memory.");
1527 goto out;
1528 }
1529
1530 /* Parse and check privheads. */
1531 if (!ldm_validate_privheads(state, &ldb->ph))
1532 goto out; /* Already logged */
1533
1534 /* All further references are relative to base (database start). */
1535 base = ldb->ph.config_start;
1536
1537 /* Parse and check tocs and vmdb. */
1538 if (!ldm_validate_tocblocks(state, base, ldb) ||
1539 !ldm_validate_vmdb(state, base, ldb))
1540 goto out; /* Already logged */
1541
1542 /* Initialize vblk lists in ldmdb struct */
1543 INIT_LIST_HEAD (&ldb->v_dgrp);
1544 INIT_LIST_HEAD (&ldb->v_disk);
1545 INIT_LIST_HEAD (&ldb->v_volu);
1546 INIT_LIST_HEAD (&ldb->v_comp);
1547 INIT_LIST_HEAD (&ldb->v_part);
1548
1549 if (!ldm_get_vblks(state, base, ldb)) {
1550 ldm_crit ("Failed to read the VBLKs from the database.");
1551 goto cleanup;
1552 }
1553
1554 /* Finally, create the data partition devices. */
1555 if (ldm_create_data_partitions(state, ldb)) {
1556 ldm_debug ("Parsed LDM database successfully.");
1557 result = 1;
1558 }
1559 /* else Already logged */
1560
1561cleanup:
1562 ldm_free_vblks (&ldb->v_dgrp);
1563 ldm_free_vblks (&ldb->v_disk);
1564 ldm_free_vblks (&ldb->v_volu);
1565 ldm_free_vblks (&ldb->v_comp);
1566 ldm_free_vblks (&ldb->v_part);
1567out:
1568 kfree (ldb);
1569 return result;
1570}
diff --git a/fs/partitions/ldm.h b/fs/partitions/ldm.h
deleted file mode 100644
index 374242c0971a..000000000000
--- a/fs/partitions/ldm.h
+++ /dev/null
@@ -1,215 +0,0 @@
1/**
2 * ldm - Part of the Linux-NTFS project.
3 *
4 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
5 * Copyright (c) 2001-2007 Anton Altaparmakov
6 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
7 *
8 * Documentation is available at http://www.linux-ntfs.org/doku.php?id=downloads
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program (in the main directory of the Linux-NTFS source
22 * in the file COPYING); if not, write to the Free Software Foundation,
23 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#ifndef _FS_PT_LDM_H_
27#define _FS_PT_LDM_H_
28
29#include <linux/types.h>
30#include <linux/list.h>
31#include <linux/genhd.h>
32#include <linux/fs.h>
33#include <asm/unaligned.h>
34#include <asm/byteorder.h>
35
36struct parsed_partitions;
37
38/* Magic numbers in CPU format. */
39#define MAGIC_VMDB 0x564D4442 /* VMDB */
40#define MAGIC_VBLK 0x56424C4B /* VBLK */
41#define MAGIC_PRIVHEAD 0x5052495648454144ULL /* PRIVHEAD */
42#define MAGIC_TOCBLOCK 0x544F43424C4F434BULL /* TOCBLOCK */
43
44/* The defined vblk types. */
45#define VBLK_VOL5 0x51 /* Volume, version 5 */
46#define VBLK_CMP3 0x32 /* Component, version 3 */
47#define VBLK_PRT3 0x33 /* Partition, version 3 */
48#define VBLK_DSK3 0x34 /* Disk, version 3 */
49#define VBLK_DSK4 0x44 /* Disk, version 4 */
50#define VBLK_DGR3 0x35 /* Disk Group, version 3 */
51#define VBLK_DGR4 0x45 /* Disk Group, version 4 */
52
53/* vblk flags indicating extra information will be present */
54#define VBLK_FLAG_COMP_STRIPE 0x10
55#define VBLK_FLAG_PART_INDEX 0x08
56#define VBLK_FLAG_DGR3_IDS 0x08
57#define VBLK_FLAG_DGR4_IDS 0x08
58#define VBLK_FLAG_VOLU_ID1 0x08
59#define VBLK_FLAG_VOLU_ID2 0x20
60#define VBLK_FLAG_VOLU_SIZE 0x80
61#define VBLK_FLAG_VOLU_DRIVE 0x02
62
63/* size of a vblk's static parts */
64#define VBLK_SIZE_HEAD 16
65#define VBLK_SIZE_CMP3 22 /* Name and version */
66#define VBLK_SIZE_DGR3 12
67#define VBLK_SIZE_DGR4 44
68#define VBLK_SIZE_DSK3 12
69#define VBLK_SIZE_DSK4 45
70#define VBLK_SIZE_PRT3 28
71#define VBLK_SIZE_VOL5 58
72
73/* component types */
74#define COMP_STRIPE 0x01 /* Stripe-set */
75#define COMP_BASIC 0x02 /* Basic disk */
76#define COMP_RAID 0x03 /* Raid-set */
77
78/* Other constants. */
79#define LDM_DB_SIZE 2048 /* Size in sectors (= 1MiB). */
80
81#define OFF_PRIV1 6 /* Offset of the first privhead
82 relative to the start of the
83 device in sectors */
84
85/* Offsets to structures within the LDM Database in sectors. */
86#define OFF_PRIV2 1856 /* Backup private headers. */
87#define OFF_PRIV3 2047
88
89#define OFF_TOCB1 1 /* Tables of contents. */
90#define OFF_TOCB2 2
91#define OFF_TOCB3 2045
92#define OFF_TOCB4 2046
93
94#define OFF_VMDB 17 /* List of partitions. */
95
96#define LDM_PARTITION 0x42 /* Formerly SFS (Landis). */
97
98#define TOC_BITMAP1 "config" /* Names of the two defined */
99#define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */
100
101/* Borrowed from msdos.c */
102#define SYS_IND(p) (get_unaligned(&(p)->sys_ind))
103
104struct frag { /* VBLK Fragment handling */
105 struct list_head list;
106 u32 group;
107 u8 num; /* Total number of records */
108 u8 rec; /* This is record number n */
109 u8 map; /* Which portions are in use */
110 u8 data[0];
111};
112
113/* In memory LDM database structures. */
114
115#define GUID_SIZE 16
116
117struct privhead { /* Offsets and sizes are in sectors. */
118 u16 ver_major;
119 u16 ver_minor;
120 u64 logical_disk_start;
121 u64 logical_disk_size;
122 u64 config_start;
123 u64 config_size;
124 u8 disk_id[GUID_SIZE];
125};
126
127struct tocblock { /* We have exactly two bitmaps. */
128 u8 bitmap1_name[16];
129 u64 bitmap1_start;
130 u64 bitmap1_size;
131 u8 bitmap2_name[16];
132 u64 bitmap2_start;
133 u64 bitmap2_size;
134};
135
136struct vmdb { /* VMDB: The database header */
137 u16 ver_major;
138 u16 ver_minor;
139 u32 vblk_size;
140 u32 vblk_offset;
141 u32 last_vblk_seq;
142};
143
144struct vblk_comp { /* VBLK Component */
145 u8 state[16];
146 u64 parent_id;
147 u8 type;
148 u8 children;
149 u16 chunksize;
150};
151
152struct vblk_dgrp { /* VBLK Disk Group */
153 u8 disk_id[64];
154};
155
156struct vblk_disk { /* VBLK Disk */
157 u8 disk_id[GUID_SIZE];
158 u8 alt_name[128];
159};
160
161struct vblk_part { /* VBLK Partition */
162 u64 start;
163 u64 size; /* start, size and vol_off in sectors */
164 u64 volume_offset;
165 u64 parent_id;
166 u64 disk_id;
167 u8 partnum;
168};
169
170struct vblk_volu { /* VBLK Volume */
171 u8 volume_type[16];
172 u8 volume_state[16];
173 u8 guid[16];
174 u8 drive_hint[4];
175 u64 size;
176 u8 partition_type;
177};
178
179struct vblk_head { /* VBLK standard header */
180 u32 group;
181 u16 rec;
182 u16 nrec;
183};
184
185struct vblk { /* Generalised VBLK */
186 u8 name[64];
187 u64 obj_id;
188 u32 sequence;
189 u8 flags;
190 u8 type;
191 union {
192 struct vblk_comp comp;
193 struct vblk_dgrp dgrp;
194 struct vblk_disk disk;
195 struct vblk_part part;
196 struct vblk_volu volu;
197 } vblk;
198 struct list_head list;
199};
200
201struct ldmdb { /* Cache of the database */
202 struct privhead ph;
203 struct tocblock toc;
204 struct vmdb vm;
205 struct list_head v_dgrp;
206 struct list_head v_disk;
207 struct list_head v_volu;
208 struct list_head v_comp;
209 struct list_head v_part;
210};
211
212int ldm_partition(struct parsed_partitions *state);
213
214#endif /* _FS_PT_LDM_H_ */
215
diff --git a/fs/partitions/mac.c b/fs/partitions/mac.c
deleted file mode 100644
index 11f688bd76c5..000000000000
--- a/fs/partitions/mac.c
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * fs/partitions/mac.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 * Copyright (C) 1991-1998 Linus Torvalds
6 * Re-organised Feb 1998 Russell King
7 */
8
9#include <linux/ctype.h>
10#include "check.h"
11#include "mac.h"
12
13#ifdef CONFIG_PPC_PMAC
14#include <asm/machdep.h>
15extern void note_bootable_part(dev_t dev, int part, int goodness);
16#endif
17
18/*
19 * Code to understand MacOS partition tables.
20 */
21
22static inline void mac_fix_string(char *stg, int len)
23{
24 int i;
25
26 for (i = len - 1; i >= 0 && stg[i] == ' '; i--)
27 stg[i] = 0;
28}
29
30int mac_partition(struct parsed_partitions *state)
31{
32 Sector sect;
33 unsigned char *data;
34 int slot, blocks_in_map;
35 unsigned secsize;
36#ifdef CONFIG_PPC_PMAC
37 int found_root = 0;
38 int found_root_goodness = 0;
39#endif
40 struct mac_partition *part;
41 struct mac_driver_desc *md;
42
43 /* Get 0th block and look at the first partition map entry. */
44 md = read_part_sector(state, 0, &sect);
45 if (!md)
46 return -1;
47 if (be16_to_cpu(md->signature) != MAC_DRIVER_MAGIC) {
48 put_dev_sector(sect);
49 return 0;
50 }
51 secsize = be16_to_cpu(md->block_size);
52 put_dev_sector(sect);
53 data = read_part_sector(state, secsize/512, &sect);
54 if (!data)
55 return -1;
56 part = (struct mac_partition *) (data + secsize%512);
57 if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) {
58 put_dev_sector(sect);
59 return 0; /* not a MacOS disk */
60 }
61 blocks_in_map = be32_to_cpu(part->map_count);
62 if (blocks_in_map < 0 || blocks_in_map >= DISK_MAX_PARTS) {
63 put_dev_sector(sect);
64 return 0;
65 }
66 strlcat(state->pp_buf, " [mac]", PAGE_SIZE);
67 for (slot = 1; slot <= blocks_in_map; ++slot) {
68 int pos = slot * secsize;
69 put_dev_sector(sect);
70 data = read_part_sector(state, pos/512, &sect);
71 if (!data)
72 return -1;
73 part = (struct mac_partition *) (data + pos%512);
74 if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC)
75 break;
76 put_partition(state, slot,
77 be32_to_cpu(part->start_block) * (secsize/512),
78 be32_to_cpu(part->block_count) * (secsize/512));
79
80 if (!strnicmp(part->type, "Linux_RAID", 10))
81 state->parts[slot].flags = ADDPART_FLAG_RAID;
82#ifdef CONFIG_PPC_PMAC
83 /*
84 * If this is the first bootable partition, tell the
85 * setup code, in case it wants to make this the root.
86 */
87 if (machine_is(powermac)) {
88 int goodness = 0;
89
90 mac_fix_string(part->processor, 16);
91 mac_fix_string(part->name, 32);
92 mac_fix_string(part->type, 32);
93
94 if ((be32_to_cpu(part->status) & MAC_STATUS_BOOTABLE)
95 && strcasecmp(part->processor, "powerpc") == 0)
96 goodness++;
97
98 if (strcasecmp(part->type, "Apple_UNIX_SVR2") == 0
99 || (strnicmp(part->type, "Linux", 5) == 0
100 && strcasecmp(part->type, "Linux_swap") != 0)) {
101 int i, l;
102
103 goodness++;
104 l = strlen(part->name);
105 if (strcmp(part->name, "/") == 0)
106 goodness++;
107 for (i = 0; i <= l - 4; ++i) {
108 if (strnicmp(part->name + i, "root",
109 4) == 0) {
110 goodness += 2;
111 break;
112 }
113 }
114 if (strnicmp(part->name, "swap", 4) == 0)
115 goodness--;
116 }
117
118 if (goodness > found_root_goodness) {
119 found_root = slot;
120 found_root_goodness = goodness;
121 }
122 }
123#endif /* CONFIG_PPC_PMAC */
124 }
125#ifdef CONFIG_PPC_PMAC
126 if (found_root_goodness)
127 note_bootable_part(state->bdev->bd_dev, found_root,
128 found_root_goodness);
129#endif
130
131 put_dev_sector(sect);
132 strlcat(state->pp_buf, "\n", PAGE_SIZE);
133 return 1;
134}
diff --git a/fs/partitions/mac.h b/fs/partitions/mac.h
deleted file mode 100644
index 3c7d98436380..000000000000
--- a/fs/partitions/mac.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * fs/partitions/mac.h
3 */
4
5#define MAC_PARTITION_MAGIC 0x504d
6
7/* type field value for A/UX or other Unix partitions */
8#define APPLE_AUX_TYPE "Apple_UNIX_SVR2"
9
10struct mac_partition {
11 __be16 signature; /* expected to be MAC_PARTITION_MAGIC */
12 __be16 res1;
13 __be32 map_count; /* # blocks in partition map */
14 __be32 start_block; /* absolute starting block # of partition */
15 __be32 block_count; /* number of blocks in partition */
16 char name[32]; /* partition name */
17 char type[32]; /* string type description */
18 __be32 data_start; /* rel block # of first data block */
19 __be32 data_count; /* number of data blocks */
20 __be32 status; /* partition status bits */
21 __be32 boot_start;
22 __be32 boot_size;
23 __be32 boot_load;
24 __be32 boot_load2;
25 __be32 boot_entry;
26 __be32 boot_entry2;
27 __be32 boot_cksum;
28 char processor[16]; /* identifies ISA of boot */
29 /* there is more stuff after this that we don't need */
30};
31
32#define MAC_STATUS_BOOTABLE 8 /* partition is bootable */
33
34#define MAC_DRIVER_MAGIC 0x4552
35
36/* Driver descriptor structure, in block 0 */
37struct mac_driver_desc {
38 __be16 signature; /* expected to be MAC_DRIVER_MAGIC */
39 __be16 block_size;
40 __be32 block_count;
41 /* ... more stuff */
42};
43
44int mac_partition(struct parsed_partitions *state);
diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c
deleted file mode 100644
index 5f79a6677c69..000000000000
--- a/fs/partitions/msdos.c
+++ /dev/null
@@ -1,552 +0,0 @@
1/*
2 * fs/partitions/msdos.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 * Copyright (C) 1991-1998 Linus Torvalds
6 *
7 * Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug
8 * in the early extended-partition checks and added DM partitions
9 *
10 * Support for DiskManager v6.0x added by Mark Lord,
11 * with information provided by OnTrack. This now works for linux fdisk
12 * and LILO, as well as loadlin and bootln. Note that disks other than
13 * /dev/hda *must* have a "DOS" type 0x51 partition in the first slot (hda1).
14 *
15 * More flexible handling of extended partitions - aeb, 950831
16 *
17 * Check partition table on IDE disks for common CHS translations
18 *
19 * Re-organised Feb 1998 Russell King
20 */
21#include <linux/msdos_fs.h>
22
23#include "check.h"
24#include "msdos.h"
25#include "efi.h"
26
27/*
28 * Many architectures don't like unaligned accesses, while
29 * the nr_sects and start_sect partition table entries are
30 * at a 2 (mod 4) address.
31 */
32#include <asm/unaligned.h>
33
34#define SYS_IND(p) get_unaligned(&p->sys_ind)
35
36static inline sector_t nr_sects(struct partition *p)
37{
38 return (sector_t)get_unaligned_le32(&p->nr_sects);
39}
40
41static inline sector_t start_sect(struct partition *p)
42{
43 return (sector_t)get_unaligned_le32(&p->start_sect);
44}
45
46static inline int is_extended_partition(struct partition *p)
47{
48 return (SYS_IND(p) == DOS_EXTENDED_PARTITION ||
49 SYS_IND(p) == WIN98_EXTENDED_PARTITION ||
50 SYS_IND(p) == LINUX_EXTENDED_PARTITION);
51}
52
53#define MSDOS_LABEL_MAGIC1 0x55
54#define MSDOS_LABEL_MAGIC2 0xAA
55
56static inline int
57msdos_magic_present(unsigned char *p)
58{
59 return (p[0] == MSDOS_LABEL_MAGIC1 && p[1] == MSDOS_LABEL_MAGIC2);
60}
61
62/* Value is EBCDIC 'IBMA' */
63#define AIX_LABEL_MAGIC1 0xC9
64#define AIX_LABEL_MAGIC2 0xC2
65#define AIX_LABEL_MAGIC3 0xD4
66#define AIX_LABEL_MAGIC4 0xC1
67static int aix_magic_present(struct parsed_partitions *state, unsigned char *p)
68{
69 struct partition *pt = (struct partition *) (p + 0x1be);
70 Sector sect;
71 unsigned char *d;
72 int slot, ret = 0;
73
74 if (!(p[0] == AIX_LABEL_MAGIC1 &&
75 p[1] == AIX_LABEL_MAGIC2 &&
76 p[2] == AIX_LABEL_MAGIC3 &&
77 p[3] == AIX_LABEL_MAGIC4))
78 return 0;
79 /* Assume the partition table is valid if Linux partitions exists */
80 for (slot = 1; slot <= 4; slot++, pt++) {
81 if (pt->sys_ind == LINUX_SWAP_PARTITION ||
82 pt->sys_ind == LINUX_RAID_PARTITION ||
83 pt->sys_ind == LINUX_DATA_PARTITION ||
84 pt->sys_ind == LINUX_LVM_PARTITION ||
85 is_extended_partition(pt))
86 return 0;
87 }
88 d = read_part_sector(state, 7, &sect);
89 if (d) {
90 if (d[0] == '_' && d[1] == 'L' && d[2] == 'V' && d[3] == 'M')
91 ret = 1;
92 put_dev_sector(sect);
93 };
94 return ret;
95}
96
97/*
98 * Create devices for each logical partition in an extended partition.
99 * The logical partitions form a linked list, with each entry being
100 * a partition table with two entries. The first entry
101 * is the real data partition (with a start relative to the partition
102 * table start). The second is a pointer to the next logical partition
103 * (with a start relative to the entire extended partition).
104 * We do not create a Linux partition for the partition tables, but
105 * only for the actual data partitions.
106 */
107
108static void parse_extended(struct parsed_partitions *state,
109 sector_t first_sector, sector_t first_size)
110{
111 struct partition *p;
112 Sector sect;
113 unsigned char *data;
114 sector_t this_sector, this_size;
115 sector_t sector_size = bdev_logical_block_size(state->bdev) / 512;
116 int loopct = 0; /* number of links followed
117 without finding a data partition */
118 int i;
119
120 this_sector = first_sector;
121 this_size = first_size;
122
123 while (1) {
124 if (++loopct > 100)
125 return;
126 if (state->next == state->limit)
127 return;
128 data = read_part_sector(state, this_sector, &sect);
129 if (!data)
130 return;
131
132 if (!msdos_magic_present(data + 510))
133 goto done;
134
135 p = (struct partition *) (data + 0x1be);
136
137 /*
138 * Usually, the first entry is the real data partition,
139 * the 2nd entry is the next extended partition, or empty,
140 * and the 3rd and 4th entries are unused.
141 * However, DRDOS sometimes has the extended partition as
142 * the first entry (when the data partition is empty),
143 * and OS/2 seems to use all four entries.
144 */
145
146 /*
147 * First process the data partition(s)
148 */
149 for (i=0; i<4; i++, p++) {
150 sector_t offs, size, next;
151 if (!nr_sects(p) || is_extended_partition(p))
152 continue;
153
154 /* Check the 3rd and 4th entries -
155 these sometimes contain random garbage */
156 offs = start_sect(p)*sector_size;
157 size = nr_sects(p)*sector_size;
158 next = this_sector + offs;
159 if (i >= 2) {
160 if (offs + size > this_size)
161 continue;
162 if (next < first_sector)
163 continue;
164 if (next + size > first_sector + first_size)
165 continue;
166 }
167
168 put_partition(state, state->next, next, size);
169 if (SYS_IND(p) == LINUX_RAID_PARTITION)
170 state->parts[state->next].flags = ADDPART_FLAG_RAID;
171 loopct = 0;
172 if (++state->next == state->limit)
173 goto done;
174 }
175 /*
176 * Next, process the (first) extended partition, if present.
177 * (So far, there seems to be no reason to make
178 * parse_extended() recursive and allow a tree
179 * of extended partitions.)
180 * It should be a link to the next logical partition.
181 */
182 p -= 4;
183 for (i=0; i<4; i++, p++)
184 if (nr_sects(p) && is_extended_partition(p))
185 break;
186 if (i == 4)
187 goto done; /* nothing left to do */
188
189 this_sector = first_sector + start_sect(p) * sector_size;
190 this_size = nr_sects(p) * sector_size;
191 put_dev_sector(sect);
192 }
193done:
194 put_dev_sector(sect);
195}
196
197/* james@bpgc.com: Solaris has a nasty indicator: 0x82 which also
198 indicates linux swap. Be careful before believing this is Solaris. */
199
200static void parse_solaris_x86(struct parsed_partitions *state,
201 sector_t offset, sector_t size, int origin)
202{
203#ifdef CONFIG_SOLARIS_X86_PARTITION
204 Sector sect;
205 struct solaris_x86_vtoc *v;
206 int i;
207 short max_nparts;
208
209 v = read_part_sector(state, offset + 1, &sect);
210 if (!v)
211 return;
212 if (le32_to_cpu(v->v_sanity) != SOLARIS_X86_VTOC_SANE) {
213 put_dev_sector(sect);
214 return;
215 }
216 {
217 char tmp[1 + BDEVNAME_SIZE + 10 + 11 + 1];
218
219 snprintf(tmp, sizeof(tmp), " %s%d: <solaris:", state->name, origin);
220 strlcat(state->pp_buf, tmp, PAGE_SIZE);
221 }
222 if (le32_to_cpu(v->v_version) != 1) {
223 char tmp[64];
224
225 snprintf(tmp, sizeof(tmp), " cannot handle version %d vtoc>\n",
226 le32_to_cpu(v->v_version));
227 strlcat(state->pp_buf, tmp, PAGE_SIZE);
228 put_dev_sector(sect);
229 return;
230 }
231 /* Ensure we can handle previous case of VTOC with 8 entries gracefully */
232 max_nparts = le16_to_cpu (v->v_nparts) > 8 ? SOLARIS_X86_NUMSLICE : 8;
233 for (i=0; i<max_nparts && state->next<state->limit; i++) {
234 struct solaris_x86_slice *s = &v->v_slice[i];
235 char tmp[3 + 10 + 1 + 1];
236
237 if (s->s_size == 0)
238 continue;
239 snprintf(tmp, sizeof(tmp), " [s%d]", i);
240 strlcat(state->pp_buf, tmp, PAGE_SIZE);
241 /* solaris partitions are relative to current MS-DOS
242 * one; must add the offset of the current partition */
243 put_partition(state, state->next++,
244 le32_to_cpu(s->s_start)+offset,
245 le32_to_cpu(s->s_size));
246 }
247 put_dev_sector(sect);
248 strlcat(state->pp_buf, " >\n", PAGE_SIZE);
249#endif
250}
251
252#if defined(CONFIG_BSD_DISKLABEL)
253/*
254 * Create devices for BSD partitions listed in a disklabel, under a
255 * dos-like partition. See parse_extended() for more information.
256 */
257static void parse_bsd(struct parsed_partitions *state,
258 sector_t offset, sector_t size, int origin, char *flavour,
259 int max_partitions)
260{
261 Sector sect;
262 struct bsd_disklabel *l;
263 struct bsd_partition *p;
264 char tmp[64];
265
266 l = read_part_sector(state, offset + 1, &sect);
267 if (!l)
268 return;
269 if (le32_to_cpu(l->d_magic) != BSD_DISKMAGIC) {
270 put_dev_sector(sect);
271 return;
272 }
273
274 snprintf(tmp, sizeof(tmp), " %s%d: <%s:", state->name, origin, flavour);
275 strlcat(state->pp_buf, tmp, PAGE_SIZE);
276
277 if (le16_to_cpu(l->d_npartitions) < max_partitions)
278 max_partitions = le16_to_cpu(l->d_npartitions);
279 for (p = l->d_partitions; p - l->d_partitions < max_partitions; p++) {
280 sector_t bsd_start, bsd_size;
281
282 if (state->next == state->limit)
283 break;
284 if (p->p_fstype == BSD_FS_UNUSED)
285 continue;
286 bsd_start = le32_to_cpu(p->p_offset);
287 bsd_size = le32_to_cpu(p->p_size);
288 if (offset == bsd_start && size == bsd_size)
289 /* full parent partition, we have it already */
290 continue;
291 if (offset > bsd_start || offset+size < bsd_start+bsd_size) {
292 strlcat(state->pp_buf, "bad subpartition - ignored\n", PAGE_SIZE);
293 continue;
294 }
295 put_partition(state, state->next++, bsd_start, bsd_size);
296 }
297 put_dev_sector(sect);
298 if (le16_to_cpu(l->d_npartitions) > max_partitions) {
299 snprintf(tmp, sizeof(tmp), " (ignored %d more)",
300 le16_to_cpu(l->d_npartitions) - max_partitions);
301 strlcat(state->pp_buf, tmp, PAGE_SIZE);
302 }
303 strlcat(state->pp_buf, " >\n", PAGE_SIZE);
304}
305#endif
306
307static void parse_freebsd(struct parsed_partitions *state,
308 sector_t offset, sector_t size, int origin)
309{
310#ifdef CONFIG_BSD_DISKLABEL
311 parse_bsd(state, offset, size, origin, "bsd", BSD_MAXPARTITIONS);
312#endif
313}
314
315static void parse_netbsd(struct parsed_partitions *state,
316 sector_t offset, sector_t size, int origin)
317{
318#ifdef CONFIG_BSD_DISKLABEL
319 parse_bsd(state, offset, size, origin, "netbsd", BSD_MAXPARTITIONS);
320#endif
321}
322
323static void parse_openbsd(struct parsed_partitions *state,
324 sector_t offset, sector_t size, int origin)
325{
326#ifdef CONFIG_BSD_DISKLABEL
327 parse_bsd(state, offset, size, origin, "openbsd",
328 OPENBSD_MAXPARTITIONS);
329#endif
330}
331
332/*
333 * Create devices for Unixware partitions listed in a disklabel, under a
334 * dos-like partition. See parse_extended() for more information.
335 */
336static void parse_unixware(struct parsed_partitions *state,
337 sector_t offset, sector_t size, int origin)
338{
339#ifdef CONFIG_UNIXWARE_DISKLABEL
340 Sector sect;
341 struct unixware_disklabel *l;
342 struct unixware_slice *p;
343
344 l = read_part_sector(state, offset + 29, &sect);
345 if (!l)
346 return;
347 if (le32_to_cpu(l->d_magic) != UNIXWARE_DISKMAGIC ||
348 le32_to_cpu(l->vtoc.v_magic) != UNIXWARE_DISKMAGIC2) {
349 put_dev_sector(sect);
350 return;
351 }
352 {
353 char tmp[1 + BDEVNAME_SIZE + 10 + 12 + 1];
354
355 snprintf(tmp, sizeof(tmp), " %s%d: <unixware:", state->name, origin);
356 strlcat(state->pp_buf, tmp, PAGE_SIZE);
357 }
358 p = &l->vtoc.v_slice[1];
359 /* I omit the 0th slice as it is the same as whole disk. */
360 while (p - &l->vtoc.v_slice[0] < UNIXWARE_NUMSLICE) {
361 if (state->next == state->limit)
362 break;
363
364 if (p->s_label != UNIXWARE_FS_UNUSED)
365 put_partition(state, state->next++,
366 le32_to_cpu(p->start_sect),
367 le32_to_cpu(p->nr_sects));
368 p++;
369 }
370 put_dev_sector(sect);
371 strlcat(state->pp_buf, " >\n", PAGE_SIZE);
372#endif
373}
374
375/*
376 * Minix 2.0.0/2.0.2 subpartition support.
377 * Anand Krishnamurthy <anandk@wiproge.med.ge.com>
378 * Rajeev V. Pillai <rajeevvp@yahoo.com>
379 */
380static void parse_minix(struct parsed_partitions *state,
381 sector_t offset, sector_t size, int origin)
382{
383#ifdef CONFIG_MINIX_SUBPARTITION
384 Sector sect;
385 unsigned char *data;
386 struct partition *p;
387 int i;
388
389 data = read_part_sector(state, offset, &sect);
390 if (!data)
391 return;
392
393 p = (struct partition *)(data + 0x1be);
394
395 /* The first sector of a Minix partition can have either
396 * a secondary MBR describing its subpartitions, or
397 * the normal boot sector. */
398 if (msdos_magic_present (data + 510) &&
399 SYS_IND(p) == MINIX_PARTITION) { /* subpartition table present */
400 char tmp[1 + BDEVNAME_SIZE + 10 + 9 + 1];
401
402 snprintf(tmp, sizeof(tmp), " %s%d: <minix:", state->name, origin);
403 strlcat(state->pp_buf, tmp, PAGE_SIZE);
404 for (i = 0; i < MINIX_NR_SUBPARTITIONS; i++, p++) {
405 if (state->next == state->limit)
406 break;
407 /* add each partition in use */
408 if (SYS_IND(p) == MINIX_PARTITION)
409 put_partition(state, state->next++,
410 start_sect(p), nr_sects(p));
411 }
412 strlcat(state->pp_buf, " >\n", PAGE_SIZE);
413 }
414 put_dev_sector(sect);
415#endif /* CONFIG_MINIX_SUBPARTITION */
416}
417
418static struct {
419 unsigned char id;
420 void (*parse)(struct parsed_partitions *, sector_t, sector_t, int);
421} subtypes[] = {
422 {FREEBSD_PARTITION, parse_freebsd},
423 {NETBSD_PARTITION, parse_netbsd},
424 {OPENBSD_PARTITION, parse_openbsd},
425 {MINIX_PARTITION, parse_minix},
426 {UNIXWARE_PARTITION, parse_unixware},
427 {SOLARIS_X86_PARTITION, parse_solaris_x86},
428 {NEW_SOLARIS_X86_PARTITION, parse_solaris_x86},
429 {0, NULL},
430};
431
432int msdos_partition(struct parsed_partitions *state)
433{
434 sector_t sector_size = bdev_logical_block_size(state->bdev) / 512;
435 Sector sect;
436 unsigned char *data;
437 struct partition *p;
438 struct fat_boot_sector *fb;
439 int slot;
440
441 data = read_part_sector(state, 0, &sect);
442 if (!data)
443 return -1;
444 if (!msdos_magic_present(data + 510)) {
445 put_dev_sector(sect);
446 return 0;
447 }
448
449 if (aix_magic_present(state, data)) {
450 put_dev_sector(sect);
451 strlcat(state->pp_buf, " [AIX]", PAGE_SIZE);
452 return 0;
453 }
454
455 /*
456 * Now that the 55aa signature is present, this is probably
457 * either the boot sector of a FAT filesystem or a DOS-type
458 * partition table. Reject this in case the boot indicator
459 * is not 0 or 0x80.
460 */
461 p = (struct partition *) (data + 0x1be);
462 for (slot = 1; slot <= 4; slot++, p++) {
463 if (p->boot_ind != 0 && p->boot_ind != 0x80) {
464 /*
465 * Even without a valid boot inidicator value
466 * its still possible this is valid FAT filesystem
467 * without a partition table.
468 */
469 fb = (struct fat_boot_sector *) data;
470 if (slot == 1 && fb->reserved && fb->fats
471 && fat_valid_media(fb->media)) {
472 strlcat(state->pp_buf, "\n", PAGE_SIZE);
473 put_dev_sector(sect);
474 return 1;
475 } else {
476 put_dev_sector(sect);
477 return 0;
478 }
479 }
480 }
481
482#ifdef CONFIG_EFI_PARTITION
483 p = (struct partition *) (data + 0x1be);
484 for (slot = 1 ; slot <= 4 ; slot++, p++) {
485 /* If this is an EFI GPT disk, msdos should ignore it. */
486 if (SYS_IND(p) == EFI_PMBR_OSTYPE_EFI_GPT) {
487 put_dev_sector(sect);
488 return 0;
489 }
490 }
491#endif
492 p = (struct partition *) (data + 0x1be);
493
494 /*
495 * Look for partitions in two passes:
496 * First find the primary and DOS-type extended partitions.
497 * On the second pass look inside *BSD, Unixware and Solaris partitions.
498 */
499
500 state->next = 5;
501 for (slot = 1 ; slot <= 4 ; slot++, p++) {
502 sector_t start = start_sect(p)*sector_size;
503 sector_t size = nr_sects(p)*sector_size;
504 if (!size)
505 continue;
506 if (is_extended_partition(p)) {
507 /*
508 * prevent someone doing mkfs or mkswap on an
509 * extended partition, but leave room for LILO
510 * FIXME: this uses one logical sector for > 512b
511 * sector, although it may not be enough/proper.
512 */
513 sector_t n = 2;
514 n = min(size, max(sector_size, n));
515 put_partition(state, slot, start, n);
516
517 strlcat(state->pp_buf, " <", PAGE_SIZE);
518 parse_extended(state, start, size);
519 strlcat(state->pp_buf, " >", PAGE_SIZE);
520 continue;
521 }
522 put_partition(state, slot, start, size);
523 if (SYS_IND(p) == LINUX_RAID_PARTITION)
524 state->parts[slot].flags = ADDPART_FLAG_RAID;
525 if (SYS_IND(p) == DM6_PARTITION)
526 strlcat(state->pp_buf, "[DM]", PAGE_SIZE);
527 if (SYS_IND(p) == EZD_PARTITION)
528 strlcat(state->pp_buf, "[EZD]", PAGE_SIZE);
529 }
530
531 strlcat(state->pp_buf, "\n", PAGE_SIZE);
532
533 /* second pass - output for each on a separate line */
534 p = (struct partition *) (0x1be + data);
535 for (slot = 1 ; slot <= 4 ; slot++, p++) {
536 unsigned char id = SYS_IND(p);
537 int n;
538
539 if (!nr_sects(p))
540 continue;
541
542 for (n = 0; subtypes[n].parse && id != subtypes[n].id; n++)
543 ;
544
545 if (!subtypes[n].parse)
546 continue;
547 subtypes[n].parse(state, start_sect(p) * sector_size,
548 nr_sects(p) * sector_size, slot);
549 }
550 put_dev_sector(sect);
551 return 1;
552}
diff --git a/fs/partitions/msdos.h b/fs/partitions/msdos.h
deleted file mode 100644
index 38c781c490b3..000000000000
--- a/fs/partitions/msdos.h
+++ /dev/null
@@ -1,8 +0,0 @@
1/*
2 * fs/partitions/msdos.h
3 */
4
5#define MSDOS_LABEL_MAGIC 0xAA55
6
7int msdos_partition(struct parsed_partitions *state);
8
diff --git a/fs/partitions/osf.c b/fs/partitions/osf.c
deleted file mode 100644
index 764b86a01965..000000000000
--- a/fs/partitions/osf.c
+++ /dev/null
@@ -1,86 +0,0 @@
1/*
2 * fs/partitions/osf.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 *
6 * Copyright (C) 1991-1998 Linus Torvalds
7 * Re-organised Feb 1998 Russell King
8 */
9
10#include "check.h"
11#include "osf.h"
12
13#define MAX_OSF_PARTITIONS 18
14
15int osf_partition(struct parsed_partitions *state)
16{
17 int i;
18 int slot = 1;
19 unsigned int npartitions;
20 Sector sect;
21 unsigned char *data;
22 struct disklabel {
23 __le32 d_magic;
24 __le16 d_type,d_subtype;
25 u8 d_typename[16];
26 u8 d_packname[16];
27 __le32 d_secsize;
28 __le32 d_nsectors;
29 __le32 d_ntracks;
30 __le32 d_ncylinders;
31 __le32 d_secpercyl;
32 __le32 d_secprtunit;
33 __le16 d_sparespertrack;
34 __le16 d_sparespercyl;
35 __le32 d_acylinders;
36 __le16 d_rpm, d_interleave, d_trackskew, d_cylskew;
37 __le32 d_headswitch, d_trkseek, d_flags;
38 __le32 d_drivedata[5];
39 __le32 d_spare[5];
40 __le32 d_magic2;
41 __le16 d_checksum;
42 __le16 d_npartitions;
43 __le32 d_bbsize, d_sbsize;
44 struct d_partition {
45 __le32 p_size;
46 __le32 p_offset;
47 __le32 p_fsize;
48 u8 p_fstype;
49 u8 p_frag;
50 __le16 p_cpg;
51 } d_partitions[MAX_OSF_PARTITIONS];
52 } * label;
53 struct d_partition * partition;
54
55 data = read_part_sector(state, 0, &sect);
56 if (!data)
57 return -1;
58
59 label = (struct disklabel *) (data+64);
60 partition = label->d_partitions;
61 if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
62 put_dev_sector(sect);
63 return 0;
64 }
65 if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
66 put_dev_sector(sect);
67 return 0;
68 }
69 npartitions = le16_to_cpu(label->d_npartitions);
70 if (npartitions > MAX_OSF_PARTITIONS) {
71 put_dev_sector(sect);
72 return 0;
73 }
74 for (i = 0 ; i < npartitions; i++, partition++) {
75 if (slot == state->limit)
76 break;
77 if (le32_to_cpu(partition->p_size))
78 put_partition(state, slot,
79 le32_to_cpu(partition->p_offset),
80 le32_to_cpu(partition->p_size));
81 slot++;
82 }
83 strlcat(state->pp_buf, "\n", PAGE_SIZE);
84 put_dev_sector(sect);
85 return 1;
86}
diff --git a/fs/partitions/osf.h b/fs/partitions/osf.h
deleted file mode 100644
index 20ed2315ec16..000000000000
--- a/fs/partitions/osf.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/*
2 * fs/partitions/osf.h
3 */
4
5#define DISKLABELMAGIC (0x82564557UL)
6
7int osf_partition(struct parsed_partitions *state);
diff --git a/fs/partitions/sgi.c b/fs/partitions/sgi.c
deleted file mode 100644
index ea8a86dceaf4..000000000000
--- a/fs/partitions/sgi.c
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * fs/partitions/sgi.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 */
6
7#include "check.h"
8#include "sgi.h"
9
10struct sgi_disklabel {
11 __be32 magic_mushroom; /* Big fat spliff... */
12 __be16 root_part_num; /* Root partition number */
13 __be16 swap_part_num; /* Swap partition number */
14 s8 boot_file[16]; /* Name of boot file for ARCS */
15 u8 _unused0[48]; /* Device parameter useless crapola.. */
16 struct sgi_volume {
17 s8 name[8]; /* Name of volume */
18 __be32 block_num; /* Logical block number */
19 __be32 num_bytes; /* How big, in bytes */
20 } volume[15];
21 struct sgi_partition {
22 __be32 num_blocks; /* Size in logical blocks */
23 __be32 first_block; /* First logical block */
24 __be32 type; /* Type of this partition */
25 } partitions[16];
26 __be32 csum; /* Disk label checksum */
27 __be32 _unused1; /* Padding */
28};
29
30int sgi_partition(struct parsed_partitions *state)
31{
32 int i, csum;
33 __be32 magic;
34 int slot = 1;
35 unsigned int start, blocks;
36 __be32 *ui, cs;
37 Sector sect;
38 struct sgi_disklabel *label;
39 struct sgi_partition *p;
40 char b[BDEVNAME_SIZE];
41
42 label = read_part_sector(state, 0, &sect);
43 if (!label)
44 return -1;
45 p = &label->partitions[0];
46 magic = label->magic_mushroom;
47 if(be32_to_cpu(magic) != SGI_LABEL_MAGIC) {
48 /*printk("Dev %s SGI disklabel: bad magic %08x\n",
49 bdevname(bdev, b), be32_to_cpu(magic));*/
50 put_dev_sector(sect);
51 return 0;
52 }
53 ui = ((__be32 *) (label + 1)) - 1;
54 for(csum = 0; ui >= ((__be32 *) label);) {
55 cs = *ui--;
56 csum += be32_to_cpu(cs);
57 }
58 if(csum) {
59 printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
60 bdevname(state->bdev, b));
61 put_dev_sector(sect);
62 return 0;
63 }
64 /* All SGI disk labels have 16 partitions, disks under Linux only
65 * have 15 minor's. Luckily there are always a few zero length
66 * partitions which we don't care about so we never overflow the
67 * current_minor.
68 */
69 for(i = 0; i < 16; i++, p++) {
70 blocks = be32_to_cpu(p->num_blocks);
71 start = be32_to_cpu(p->first_block);
72 if (blocks) {
73 put_partition(state, slot, start, blocks);
74 if (be32_to_cpu(p->type) == LINUX_RAID_PARTITION)
75 state->parts[slot].flags = ADDPART_FLAG_RAID;
76 }
77 slot++;
78 }
79 strlcat(state->pp_buf, "\n", PAGE_SIZE);
80 put_dev_sector(sect);
81 return 1;
82}
diff --git a/fs/partitions/sgi.h b/fs/partitions/sgi.h
deleted file mode 100644
index b9553ebdd5a9..000000000000
--- a/fs/partitions/sgi.h
+++ /dev/null
@@ -1,8 +0,0 @@
1/*
2 * fs/partitions/sgi.h
3 */
4
5extern int sgi_partition(struct parsed_partitions *state);
6
7#define SGI_LABEL_MAGIC 0x0be5a941
8
diff --git a/fs/partitions/sun.c b/fs/partitions/sun.c
deleted file mode 100644
index b5b6fcfb3d36..000000000000
--- a/fs/partitions/sun.c
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * fs/partitions/sun.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 *
6 * Copyright (C) 1991-1998 Linus Torvalds
7 * Re-organised Feb 1998 Russell King
8 */
9
10#include "check.h"
11#include "sun.h"
12
13int sun_partition(struct parsed_partitions *state)
14{
15 int i;
16 __be16 csum;
17 int slot = 1;
18 __be16 *ush;
19 Sector sect;
20 struct sun_disklabel {
21 unsigned char info[128]; /* Informative text string */
22 struct sun_vtoc {
23 __be32 version; /* Layout version */
24 char volume[8]; /* Volume name */
25 __be16 nparts; /* Number of partitions */
26 struct sun_info { /* Partition hdrs, sec 2 */
27 __be16 id;
28 __be16 flags;
29 } infos[8];
30 __be16 padding; /* Alignment padding */
31 __be32 bootinfo[3]; /* Info needed by mboot */
32 __be32 sanity; /* To verify vtoc sanity */
33 __be32 reserved[10]; /* Free space */
34 __be32 timestamp[8]; /* Partition timestamp */
35 } vtoc;
36 __be32 write_reinstruct; /* sectors to skip, writes */
37 __be32 read_reinstruct; /* sectors to skip, reads */
38 unsigned char spare[148]; /* Padding */
39 __be16 rspeed; /* Disk rotational speed */
40 __be16 pcylcount; /* Physical cylinder count */
41 __be16 sparecyl; /* extra sects per cylinder */
42 __be16 obs1; /* gap1 */
43 __be16 obs2; /* gap2 */
44 __be16 ilfact; /* Interleave factor */
45 __be16 ncyl; /* Data cylinder count */
46 __be16 nacyl; /* Alt. cylinder count */
47 __be16 ntrks; /* Tracks per cylinder */
48 __be16 nsect; /* Sectors per track */
49 __be16 obs3; /* bhead - Label head offset */
50 __be16 obs4; /* ppart - Physical Partition */
51 struct sun_partition {
52 __be32 start_cylinder;
53 __be32 num_sectors;
54 } partitions[8];
55 __be16 magic; /* Magic number */
56 __be16 csum; /* Label xor'd checksum */
57 } * label;
58 struct sun_partition *p;
59 unsigned long spc;
60 char b[BDEVNAME_SIZE];
61 int use_vtoc;
62 int nparts;
63
64 label = read_part_sector(state, 0, &sect);
65 if (!label)
66 return -1;
67
68 p = label->partitions;
69 if (be16_to_cpu(label->magic) != SUN_LABEL_MAGIC) {
70/* printk(KERN_INFO "Dev %s Sun disklabel: bad magic %04x\n",
71 bdevname(bdev, b), be16_to_cpu(label->magic)); */
72 put_dev_sector(sect);
73 return 0;
74 }
75 /* Look at the checksum */
76 ush = ((__be16 *) (label+1)) - 1;
77 for (csum = 0; ush >= ((__be16 *) label);)
78 csum ^= *ush--;
79 if (csum) {
80 printk("Dev %s Sun disklabel: Csum bad, label corrupted\n",
81 bdevname(state->bdev, b));
82 put_dev_sector(sect);
83 return 0;
84 }
85
86 /* Check to see if we can use the VTOC table */
87 use_vtoc = ((be32_to_cpu(label->vtoc.sanity) == SUN_VTOC_SANITY) &&
88 (be32_to_cpu(label->vtoc.version) == 1) &&
89 (be16_to_cpu(label->vtoc.nparts) <= 8));
90
91 /* Use 8 partition entries if not specified in validated VTOC */
92 nparts = (use_vtoc) ? be16_to_cpu(label->vtoc.nparts) : 8;
93
94 /*
95 * So that old Linux-Sun partitions continue to work,
96 * alow the VTOC to be used under the additional condition ...
97 */
98 use_vtoc = use_vtoc || !(label->vtoc.sanity ||
99 label->vtoc.version || label->vtoc.nparts);
100 spc = be16_to_cpu(label->ntrks) * be16_to_cpu(label->nsect);
101 for (i = 0; i < nparts; i++, p++) {
102 unsigned long st_sector;
103 unsigned int num_sectors;
104
105 st_sector = be32_to_cpu(p->start_cylinder) * spc;
106 num_sectors = be32_to_cpu(p->num_sectors);
107 if (num_sectors) {
108 put_partition(state, slot, st_sector, num_sectors);
109 state->parts[slot].flags = 0;
110 if (use_vtoc) {
111 if (be16_to_cpu(label->vtoc.infos[i].id) == LINUX_RAID_PARTITION)
112 state->parts[slot].flags |= ADDPART_FLAG_RAID;
113 else if (be16_to_cpu(label->vtoc.infos[i].id) == SUN_WHOLE_DISK)
114 state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK;
115 }
116 }
117 slot++;
118 }
119 strlcat(state->pp_buf, "\n", PAGE_SIZE);
120 put_dev_sector(sect);
121 return 1;
122}
diff --git a/fs/partitions/sun.h b/fs/partitions/sun.h
deleted file mode 100644
index 2424baa8319f..000000000000
--- a/fs/partitions/sun.h
+++ /dev/null
@@ -1,8 +0,0 @@
1/*
2 * fs/partitions/sun.h
3 */
4
5#define SUN_LABEL_MAGIC 0xDABE
6#define SUN_VTOC_SANITY 0x600DDEEE
7
8int sun_partition(struct parsed_partitions *state);
diff --git a/fs/partitions/sysv68.c b/fs/partitions/sysv68.c
deleted file mode 100644
index 9627ccffc1c4..000000000000
--- a/fs/partitions/sysv68.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * fs/partitions/sysv68.c
3 *
4 * Copyright (C) 2007 Philippe De Muyter <phdm@macqel.be>
5 */
6
7#include "check.h"
8#include "sysv68.h"
9
10/*
11 * Volume ID structure: on first 256-bytes sector of disk
12 */
13
14struct volumeid {
15 u8 vid_unused[248];
16 u8 vid_mac[8]; /* ASCII string "MOTOROLA" */
17};
18
19/*
20 * config block: second 256-bytes sector on disk
21 */
22
23struct dkconfig {
24 u8 ios_unused0[128];
25 __be32 ios_slcblk; /* Slice table block number */
26 __be16 ios_slccnt; /* Number of entries in slice table */
27 u8 ios_unused1[122];
28};
29
30/*
31 * combined volumeid and dkconfig block
32 */
33
34struct dkblk0 {
35 struct volumeid dk_vid;
36 struct dkconfig dk_ios;
37};
38
39/*
40 * Slice Table Structure
41 */
42
43struct slice {
44 __be32 nblocks; /* slice size (in blocks) */
45 __be32 blkoff; /* block offset of slice */
46};
47
48
49int sysv68_partition(struct parsed_partitions *state)
50{
51 int i, slices;
52 int slot = 1;
53 Sector sect;
54 unsigned char *data;
55 struct dkblk0 *b;
56 struct slice *slice;
57 char tmp[64];
58
59 data = read_part_sector(state, 0, &sect);
60 if (!data)
61 return -1;
62
63 b = (struct dkblk0 *)data;
64 if (memcmp(b->dk_vid.vid_mac, "MOTOROLA", sizeof(b->dk_vid.vid_mac))) {
65 put_dev_sector(sect);
66 return 0;
67 }
68 slices = be16_to_cpu(b->dk_ios.ios_slccnt);
69 i = be32_to_cpu(b->dk_ios.ios_slcblk);
70 put_dev_sector(sect);
71
72 data = read_part_sector(state, i, &sect);
73 if (!data)
74 return -1;
75
76 slices -= 1; /* last slice is the whole disk */
77 snprintf(tmp, sizeof(tmp), "sysV68: %s(s%u)", state->name, slices);
78 strlcat(state->pp_buf, tmp, PAGE_SIZE);
79 slice = (struct slice *)data;
80 for (i = 0; i < slices; i++, slice++) {
81 if (slot == state->limit)
82 break;
83 if (be32_to_cpu(slice->nblocks)) {
84 put_partition(state, slot,
85 be32_to_cpu(slice->blkoff),
86 be32_to_cpu(slice->nblocks));
87 snprintf(tmp, sizeof(tmp), "(s%u)", i);
88 strlcat(state->pp_buf, tmp, PAGE_SIZE);
89 }
90 slot++;
91 }
92 strlcat(state->pp_buf, "\n", PAGE_SIZE);
93 put_dev_sector(sect);
94 return 1;
95}
diff --git a/fs/partitions/sysv68.h b/fs/partitions/sysv68.h
deleted file mode 100644
index bf2f5ffa97ac..000000000000
--- a/fs/partitions/sysv68.h
+++ /dev/null
@@ -1 +0,0 @@
1extern int sysv68_partition(struct parsed_partitions *state);
diff --git a/fs/partitions/ultrix.c b/fs/partitions/ultrix.c
deleted file mode 100644
index 8dbaf9f77a99..000000000000
--- a/fs/partitions/ultrix.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 * fs/partitions/ultrix.c
3 *
4 * Code extracted from drivers/block/genhd.c
5 *
6 * Re-organised Jul 1999 Russell King
7 */
8
9#include "check.h"
10#include "ultrix.h"
11
12int ultrix_partition(struct parsed_partitions *state)
13{
14 int i;
15 Sector sect;
16 unsigned char *data;
17 struct ultrix_disklabel {
18 s32 pt_magic; /* magic no. indicating part. info exits */
19 s32 pt_valid; /* set by driver if pt is current */
20 struct pt_info {
21 s32 pi_nblocks; /* no. of sectors */
22 u32 pi_blkoff; /* block offset for start */
23 } pt_part[8];
24 } *label;
25
26#define PT_MAGIC 0x032957 /* Partition magic number */
27#define PT_VALID 1 /* Indicates if struct is valid */
28
29 data = read_part_sector(state, (16384 - sizeof(*label))/512, &sect);
30 if (!data)
31 return -1;
32
33 label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label));
34
35 if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) {
36 for (i=0; i<8; i++)
37 if (label->pt_part[i].pi_nblocks)
38 put_partition(state, i+1,
39 label->pt_part[i].pi_blkoff,
40 label->pt_part[i].pi_nblocks);
41 put_dev_sector(sect);
42 strlcat(state->pp_buf, "\n", PAGE_SIZE);
43 return 1;
44 } else {
45 put_dev_sector(sect);
46 return 0;
47 }
48}
diff --git a/fs/partitions/ultrix.h b/fs/partitions/ultrix.h
deleted file mode 100644
index a3cc00b2bded..000000000000
--- a/fs/partitions/ultrix.h
+++ /dev/null
@@ -1,5 +0,0 @@
1/*
2 * fs/partitions/ultrix.h
3 */
4
5int ultrix_partition(struct parsed_partitions *state);
diff --git a/fs/pipe.c b/fs/pipe.c
index 4065f07366b3..f0e485d54e64 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1290,11 +1290,4 @@ static int __init init_pipe_fs(void)
1290 return err; 1290 return err;
1291} 1291}
1292 1292
1293static void __exit exit_pipe_fs(void)
1294{
1295 kern_unmount(pipe_mnt);
1296 unregister_filesystem(&pipe_fs_type);
1297}
1298
1299fs_initcall(init_pipe_fs); 1293fs_initcall(init_pipe_fs);
1300module_exit(exit_pipe_fs);
diff --git a/fs/pnode.c b/fs/pnode.c
index d42514e32380..ab5fa9e1a79a 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -13,45 +13,30 @@
13#include "pnode.h" 13#include "pnode.h"
14 14
15/* return the next shared peer mount of @p */ 15/* return the next shared peer mount of @p */
16static inline struct vfsmount *next_peer(struct vfsmount *p) 16static inline struct mount *next_peer(struct mount *p)
17{ 17{
18 return list_entry(p->mnt_share.next, struct vfsmount, mnt_share); 18 return list_entry(p->mnt_share.next, struct mount, mnt_share);
19} 19}
20 20
21static inline struct vfsmount *first_slave(struct vfsmount *p) 21static inline struct mount *first_slave(struct mount *p)
22{ 22{
23 return list_entry(p->mnt_slave_list.next, struct vfsmount, mnt_slave); 23 return list_entry(p->mnt_slave_list.next, struct mount, mnt_slave);
24} 24}
25 25
26static inline struct vfsmount *next_slave(struct vfsmount *p) 26static inline struct mount *next_slave(struct mount *p)
27{ 27{
28 return list_entry(p->mnt_slave.next, struct vfsmount, mnt_slave); 28 return list_entry(p->mnt_slave.next, struct mount, mnt_slave);
29} 29}
30 30
31/* 31static struct mount *get_peer_under_root(struct mount *mnt,
32 * Return true if path is reachable from root 32 struct mnt_namespace *ns,
33 * 33 const struct path *root)
34 * namespace_sem is held, and mnt is attached
35 */
36static bool is_path_reachable(struct vfsmount *mnt, struct dentry *dentry,
37 const struct path *root)
38{
39 while (mnt != root->mnt && mnt->mnt_parent != mnt) {
40 dentry = mnt->mnt_mountpoint;
41 mnt = mnt->mnt_parent;
42 }
43 return mnt == root->mnt && is_subdir(dentry, root->dentry);
44}
45
46static struct vfsmount *get_peer_under_root(struct vfsmount *mnt,
47 struct mnt_namespace *ns,
48 const struct path *root)
49{ 34{
50 struct vfsmount *m = mnt; 35 struct mount *m = mnt;
51 36
52 do { 37 do {
53 /* Check the namespace first for optimization */ 38 /* Check the namespace first for optimization */
54 if (m->mnt_ns == ns && is_path_reachable(m, m->mnt_root, root)) 39 if (m->mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root))
55 return m; 40 return m;
56 41
57 m = next_peer(m); 42 m = next_peer(m);
@@ -66,12 +51,12 @@ static struct vfsmount *get_peer_under_root(struct vfsmount *mnt,
66 * 51 *
67 * Caller must hold namespace_sem 52 * Caller must hold namespace_sem
68 */ 53 */
69int get_dominating_id(struct vfsmount *mnt, const struct path *root) 54int get_dominating_id(struct mount *mnt, const struct path *root)
70{ 55{
71 struct vfsmount *m; 56 struct mount *m;
72 57
73 for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) { 58 for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) {
74 struct vfsmount *d = get_peer_under_root(m, mnt->mnt_ns, root); 59 struct mount *d = get_peer_under_root(m, mnt->mnt_ns, root);
75 if (d) 60 if (d)
76 return d->mnt_group_id; 61 return d->mnt_group_id;
77 } 62 }
@@ -79,10 +64,10 @@ int get_dominating_id(struct vfsmount *mnt, const struct path *root)
79 return 0; 64 return 0;
80} 65}
81 66
82static int do_make_slave(struct vfsmount *mnt) 67static int do_make_slave(struct mount *mnt)
83{ 68{
84 struct vfsmount *peer_mnt = mnt, *master = mnt->mnt_master; 69 struct mount *peer_mnt = mnt, *master = mnt->mnt_master;
85 struct vfsmount *slave_mnt; 70 struct mount *slave_mnt;
86 71
87 /* 72 /*
88 * slave 'mnt' to a peer mount that has the 73 * slave 'mnt' to a peer mount that has the
@@ -90,7 +75,7 @@ static int do_make_slave(struct vfsmount *mnt)
90 * slave it to anything that is available. 75 * slave it to anything that is available.
91 */ 76 */
92 while ((peer_mnt = next_peer(peer_mnt)) != mnt && 77 while ((peer_mnt = next_peer(peer_mnt)) != mnt &&
93 peer_mnt->mnt_root != mnt->mnt_root) ; 78 peer_mnt->mnt.mnt_root != mnt->mnt.mnt_root) ;
94 79
95 if (peer_mnt == mnt) { 80 if (peer_mnt == mnt) {
96 peer_mnt = next_peer(mnt); 81 peer_mnt = next_peer(mnt);
@@ -116,7 +101,7 @@ static int do_make_slave(struct vfsmount *mnt)
116 struct list_head *p = &mnt->mnt_slave_list; 101 struct list_head *p = &mnt->mnt_slave_list;
117 while (!list_empty(p)) { 102 while (!list_empty(p)) {
118 slave_mnt = list_first_entry(p, 103 slave_mnt = list_first_entry(p,
119 struct vfsmount, mnt_slave); 104 struct mount, mnt_slave);
120 list_del_init(&slave_mnt->mnt_slave); 105 list_del_init(&slave_mnt->mnt_slave);
121 slave_mnt->mnt_master = NULL; 106 slave_mnt->mnt_master = NULL;
122 } 107 }
@@ -129,7 +114,7 @@ static int do_make_slave(struct vfsmount *mnt)
129/* 114/*
130 * vfsmount lock must be held for write 115 * vfsmount lock must be held for write
131 */ 116 */
132void change_mnt_propagation(struct vfsmount *mnt, int type) 117void change_mnt_propagation(struct mount *mnt, int type)
133{ 118{
134 if (type == MS_SHARED) { 119 if (type == MS_SHARED) {
135 set_mnt_shared(mnt); 120 set_mnt_shared(mnt);
@@ -140,9 +125,9 @@ void change_mnt_propagation(struct vfsmount *mnt, int type)
140 list_del_init(&mnt->mnt_slave); 125 list_del_init(&mnt->mnt_slave);
141 mnt->mnt_master = NULL; 126 mnt->mnt_master = NULL;
142 if (type == MS_UNBINDABLE) 127 if (type == MS_UNBINDABLE)
143 mnt->mnt_flags |= MNT_UNBINDABLE; 128 mnt->mnt.mnt_flags |= MNT_UNBINDABLE;
144 else 129 else
145 mnt->mnt_flags &= ~MNT_UNBINDABLE; 130 mnt->mnt.mnt_flags &= ~MNT_UNBINDABLE;
146 } 131 }
147} 132}
148 133
@@ -156,20 +141,19 @@ void change_mnt_propagation(struct vfsmount *mnt, int type)
156 * vfsmount found while iterating with propagation_next() is 141 * vfsmount found while iterating with propagation_next() is
157 * a peer of one we'd found earlier. 142 * a peer of one we'd found earlier.
158 */ 143 */
159static struct vfsmount *propagation_next(struct vfsmount *m, 144static struct mount *propagation_next(struct mount *m,
160 struct vfsmount *origin) 145 struct mount *origin)
161{ 146{
162 /* are there any slaves of this mount? */ 147 /* are there any slaves of this mount? */
163 if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list)) 148 if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list))
164 return first_slave(m); 149 return first_slave(m);
165 150
166 while (1) { 151 while (1) {
167 struct vfsmount *next; 152 struct mount *master = m->mnt_master;
168 struct vfsmount *master = m->mnt_master;
169 153
170 if (master == origin->mnt_master) { 154 if (master == origin->mnt_master) {
171 next = next_peer(m); 155 struct mount *next = next_peer(m);
172 return ((next == origin) ? NULL : next); 156 return (next == origin) ? NULL : next;
173 } else if (m->mnt_slave.next != &master->mnt_slave_list) 157 } else if (m->mnt_slave.next != &master->mnt_slave_list)
174 return next_slave(m); 158 return next_slave(m);
175 159
@@ -187,13 +171,13 @@ static struct vfsmount *propagation_next(struct vfsmount *m,
187 * @type return CL_SLAVE if the new mount has to be 171 * @type return CL_SLAVE if the new mount has to be
188 * cloned as a slave. 172 * cloned as a slave.
189 */ 173 */
190static struct vfsmount *get_source(struct vfsmount *dest, 174static struct mount *get_source(struct mount *dest,
191 struct vfsmount *last_dest, 175 struct mount *last_dest,
192 struct vfsmount *last_src, 176 struct mount *last_src,
193 int *type) 177 int *type)
194{ 178{
195 struct vfsmount *p_last_src = NULL; 179 struct mount *p_last_src = NULL;
196 struct vfsmount *p_last_dest = NULL; 180 struct mount *p_last_dest = NULL;
197 181
198 while (last_dest != dest->mnt_master) { 182 while (last_dest != dest->mnt_master) {
199 p_last_dest = last_dest; 183 p_last_dest = last_dest;
@@ -233,33 +217,33 @@ static struct vfsmount *get_source(struct vfsmount *dest,
233 * @source_mnt: source mount. 217 * @source_mnt: source mount.
234 * @tree_list : list of heads of trees to be attached. 218 * @tree_list : list of heads of trees to be attached.
235 */ 219 */
236int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, 220int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry,
237 struct vfsmount *source_mnt, struct list_head *tree_list) 221 struct mount *source_mnt, struct list_head *tree_list)
238{ 222{
239 struct vfsmount *m, *child; 223 struct mount *m, *child;
240 int ret = 0; 224 int ret = 0;
241 struct vfsmount *prev_dest_mnt = dest_mnt; 225 struct mount *prev_dest_mnt = dest_mnt;
242 struct vfsmount *prev_src_mnt = source_mnt; 226 struct mount *prev_src_mnt = source_mnt;
243 LIST_HEAD(tmp_list); 227 LIST_HEAD(tmp_list);
244 LIST_HEAD(umount_list); 228 LIST_HEAD(umount_list);
245 229
246 for (m = propagation_next(dest_mnt, dest_mnt); m; 230 for (m = propagation_next(dest_mnt, dest_mnt); m;
247 m = propagation_next(m, dest_mnt)) { 231 m = propagation_next(m, dest_mnt)) {
248 int type; 232 int type;
249 struct vfsmount *source; 233 struct mount *source;
250 234
251 if (IS_MNT_NEW(m)) 235 if (IS_MNT_NEW(m))
252 continue; 236 continue;
253 237
254 source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); 238 source = get_source(m, prev_dest_mnt, prev_src_mnt, &type);
255 239
256 if (!(child = copy_tree(source, source->mnt_root, type))) { 240 if (!(child = copy_tree(source, source->mnt.mnt_root, type))) {
257 ret = -ENOMEM; 241 ret = -ENOMEM;
258 list_splice(tree_list, tmp_list.prev); 242 list_splice(tree_list, tmp_list.prev);
259 goto out; 243 goto out;
260 } 244 }
261 245
262 if (is_subdir(dest_dentry, m->mnt_root)) { 246 if (is_subdir(dest_dentry, m->mnt.mnt_root)) {
263 mnt_set_mountpoint(m, dest_dentry, child); 247 mnt_set_mountpoint(m, dest_dentry, child);
264 list_add_tail(&child->mnt_hash, tree_list); 248 list_add_tail(&child->mnt_hash, tree_list);
265 } else { 249 } else {
@@ -275,7 +259,7 @@ int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry,
275out: 259out:
276 br_write_lock(vfsmount_lock); 260 br_write_lock(vfsmount_lock);
277 while (!list_empty(&tmp_list)) { 261 while (!list_empty(&tmp_list)) {
278 child = list_first_entry(&tmp_list, struct vfsmount, mnt_hash); 262 child = list_first_entry(&tmp_list, struct mount, mnt_hash);
279 umount_tree(child, 0, &umount_list); 263 umount_tree(child, 0, &umount_list);
280 } 264 }
281 br_write_unlock(vfsmount_lock); 265 br_write_unlock(vfsmount_lock);
@@ -286,7 +270,7 @@ out:
286/* 270/*
287 * return true if the refcount is greater than count 271 * return true if the refcount is greater than count
288 */ 272 */
289static inline int do_refcount_check(struct vfsmount *mnt, int count) 273static inline int do_refcount_check(struct mount *mnt, int count)
290{ 274{
291 int mycount = mnt_get_count(mnt) - mnt->mnt_ghosts; 275 int mycount = mnt_get_count(mnt) - mnt->mnt_ghosts;
292 return (mycount > count); 276 return (mycount > count);
@@ -302,10 +286,10 @@ static inline int do_refcount_check(struct vfsmount *mnt, int count)
302 * 286 *
303 * vfsmount lock must be held for write 287 * vfsmount lock must be held for write
304 */ 288 */
305int propagate_mount_busy(struct vfsmount *mnt, int refcnt) 289int propagate_mount_busy(struct mount *mnt, int refcnt)
306{ 290{
307 struct vfsmount *m, *child; 291 struct mount *m, *child;
308 struct vfsmount *parent = mnt->mnt_parent; 292 struct mount *parent = mnt->mnt_parent;
309 int ret = 0; 293 int ret = 0;
310 294
311 if (mnt == parent) 295 if (mnt == parent)
@@ -321,7 +305,7 @@ int propagate_mount_busy(struct vfsmount *mnt, int refcnt)
321 305
322 for (m = propagation_next(parent, parent); m; 306 for (m = propagation_next(parent, parent); m;
323 m = propagation_next(m, parent)) { 307 m = propagation_next(m, parent)) {
324 child = __lookup_mnt(m, mnt->mnt_mountpoint, 0); 308 child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint, 0);
325 if (child && list_empty(&child->mnt_mounts) && 309 if (child && list_empty(&child->mnt_mounts) &&
326 (ret = do_refcount_check(child, 1))) 310 (ret = do_refcount_check(child, 1)))
327 break; 311 break;
@@ -333,17 +317,17 @@ int propagate_mount_busy(struct vfsmount *mnt, int refcnt)
333 * NOTE: unmounting 'mnt' naturally propagates to all other mounts its 317 * NOTE: unmounting 'mnt' naturally propagates to all other mounts its
334 * parent propagates to. 318 * parent propagates to.
335 */ 319 */
336static void __propagate_umount(struct vfsmount *mnt) 320static void __propagate_umount(struct mount *mnt)
337{ 321{
338 struct vfsmount *parent = mnt->mnt_parent; 322 struct mount *parent = mnt->mnt_parent;
339 struct vfsmount *m; 323 struct mount *m;
340 324
341 BUG_ON(parent == mnt); 325 BUG_ON(parent == mnt);
342 326
343 for (m = propagation_next(parent, parent); m; 327 for (m = propagation_next(parent, parent); m;
344 m = propagation_next(m, parent)) { 328 m = propagation_next(m, parent)) {
345 329
346 struct vfsmount *child = __lookup_mnt(m, 330 struct mount *child = __lookup_mnt(&m->mnt,
347 mnt->mnt_mountpoint, 0); 331 mnt->mnt_mountpoint, 0);
348 /* 332 /*
349 * umount the child only if the child has no 333 * umount the child only if the child has no
@@ -363,7 +347,7 @@ static void __propagate_umount(struct vfsmount *mnt)
363 */ 347 */
364int propagate_umount(struct list_head *list) 348int propagate_umount(struct list_head *list)
365{ 349{
366 struct vfsmount *mnt; 350 struct mount *mnt;
367 351
368 list_for_each_entry(mnt, list, mnt_hash) 352 list_for_each_entry(mnt, list, mnt_hash)
369 __propagate_umount(mnt); 353 __propagate_umount(mnt);
diff --git a/fs/pnode.h b/fs/pnode.h
index 1ea4ae1efcd3..65c60979d541 100644
--- a/fs/pnode.h
+++ b/fs/pnode.h
@@ -9,13 +9,13 @@
9#define _LINUX_PNODE_H 9#define _LINUX_PNODE_H
10 10
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/mount.h> 12#include "mount.h"
13 13
14#define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED) 14#define IS_MNT_SHARED(m) ((m)->mnt.mnt_flags & MNT_SHARED)
15#define IS_MNT_SLAVE(mnt) (mnt->mnt_master) 15#define IS_MNT_SLAVE(m) ((m)->mnt_master)
16#define IS_MNT_NEW(mnt) (!mnt->mnt_ns) 16#define IS_MNT_NEW(m) (!(m)->mnt_ns)
17#define CLEAR_MNT_SHARED(mnt) (mnt->mnt_flags &= ~MNT_SHARED) 17#define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED)
18#define IS_MNT_UNBINDABLE(mnt) (mnt->mnt_flags & MNT_UNBINDABLE) 18#define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE)
19 19
20#define CL_EXPIRE 0x01 20#define CL_EXPIRE 0x01
21#define CL_SLAVE 0x02 21#define CL_SLAVE 0x02
@@ -23,17 +23,25 @@
23#define CL_MAKE_SHARED 0x08 23#define CL_MAKE_SHARED 0x08
24#define CL_PRIVATE 0x10 24#define CL_PRIVATE 0x10
25 25
26static inline void set_mnt_shared(struct vfsmount *mnt) 26static inline void set_mnt_shared(struct mount *mnt)
27{ 27{
28 mnt->mnt_flags &= ~MNT_SHARED_MASK; 28 mnt->mnt.mnt_flags &= ~MNT_SHARED_MASK;
29 mnt->mnt_flags |= MNT_SHARED; 29 mnt->mnt.mnt_flags |= MNT_SHARED;
30} 30}
31 31
32void change_mnt_propagation(struct vfsmount *, int); 32void change_mnt_propagation(struct mount *, int);
33int propagate_mnt(struct vfsmount *, struct dentry *, struct vfsmount *, 33int propagate_mnt(struct mount *, struct dentry *, struct mount *,
34 struct list_head *); 34 struct list_head *);
35int propagate_umount(struct list_head *); 35int propagate_umount(struct list_head *);
36int propagate_mount_busy(struct vfsmount *, int); 36int propagate_mount_busy(struct mount *, int);
37void mnt_release_group_id(struct vfsmount *); 37void mnt_release_group_id(struct mount *);
38int get_dominating_id(struct vfsmount *mnt, const struct path *root); 38int get_dominating_id(struct mount *mnt, const struct path *root);
39unsigned int mnt_get_count(struct mount *mnt);
40void mnt_set_mountpoint(struct mount *, struct dentry *,
41 struct mount *);
42void release_mounts(struct list_head *);
43void umount_tree(struct mount *, int, struct list_head *);
44struct mount *copy_tree(struct mount *, struct dentry *, int);
45bool is_path_reachable(struct mount *, struct dentry *,
46 const struct path *root);
39#endif /* _LINUX_PNODE_H */ 47#endif /* _LINUX_PNODE_H */
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 851ba3dcdc29..a1dddda999f2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -101,7 +101,7 @@
101struct pid_entry { 101struct pid_entry {
102 char *name; 102 char *name;
103 int len; 103 int len;
104 mode_t mode; 104 umode_t mode;
105 const struct inode_operations *iop; 105 const struct inode_operations *iop;
106 const struct file_operations *fop; 106 const struct file_operations *fop;
107 union proc_op op; 107 union proc_op op;
@@ -631,120 +631,6 @@ static const struct inode_operations proc_def_inode_operations = {
631 .setattr = proc_setattr, 631 .setattr = proc_setattr,
632}; 632};
633 633
634static int mounts_open_common(struct inode *inode, struct file *file,
635 const struct seq_operations *op)
636{
637 struct task_struct *task = get_proc_task(inode);
638 struct nsproxy *nsp;
639 struct mnt_namespace *ns = NULL;
640 struct path root;
641 struct proc_mounts *p;
642 int ret = -EINVAL;
643
644 if (task) {
645 rcu_read_lock();
646 nsp = task_nsproxy(task);
647 if (nsp) {
648 ns = nsp->mnt_ns;
649 if (ns)
650 get_mnt_ns(ns);
651 }
652 rcu_read_unlock();
653 if (ns && get_task_root(task, &root) == 0)
654 ret = 0;
655 put_task_struct(task);
656 }
657
658 if (!ns)
659 goto err;
660 if (ret)
661 goto err_put_ns;
662
663 ret = -ENOMEM;
664 p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL);
665 if (!p)
666 goto err_put_path;
667
668 file->private_data = &p->m;
669 ret = seq_open(file, op);
670 if (ret)
671 goto err_free;
672
673 p->m.private = p;
674 p->ns = ns;
675 p->root = root;
676 p->m.poll_event = ns->event;
677
678 return 0;
679
680 err_free:
681 kfree(p);
682 err_put_path:
683 path_put(&root);
684 err_put_ns:
685 put_mnt_ns(ns);
686 err:
687 return ret;
688}
689
690static int mounts_release(struct inode *inode, struct file *file)
691{
692 struct proc_mounts *p = file->private_data;
693 path_put(&p->root);
694 put_mnt_ns(p->ns);
695 return seq_release(inode, file);
696}
697
698static unsigned mounts_poll(struct file *file, poll_table *wait)
699{
700 struct proc_mounts *p = file->private_data;
701 unsigned res = POLLIN | POLLRDNORM;
702
703 poll_wait(file, &p->ns->poll, wait);
704 if (mnt_had_events(p))
705 res |= POLLERR | POLLPRI;
706
707 return res;
708}
709
710static int mounts_open(struct inode *inode, struct file *file)
711{
712 return mounts_open_common(inode, file, &mounts_op);
713}
714
715static const struct file_operations proc_mounts_operations = {
716 .open = mounts_open,
717 .read = seq_read,
718 .llseek = seq_lseek,
719 .release = mounts_release,
720 .poll = mounts_poll,
721};
722
723static int mountinfo_open(struct inode *inode, struct file *file)
724{
725 return mounts_open_common(inode, file, &mountinfo_op);
726}
727
728static const struct file_operations proc_mountinfo_operations = {
729 .open = mountinfo_open,
730 .read = seq_read,
731 .llseek = seq_lseek,
732 .release = mounts_release,
733 .poll = mounts_poll,
734};
735
736static int mountstats_open(struct inode *inode, struct file *file)
737{
738 return mounts_open_common(inode, file, &mountstats_op);
739}
740
741static const struct file_operations proc_mountstats_operations = {
742 .open = mountstats_open,
743 .read = seq_read,
744 .llseek = seq_lseek,
745 .release = mounts_release,
746};
747
748#define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */ 634#define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */
749 635
750static ssize_t proc_info_read(struct file * file, char __user * buf, 636static ssize_t proc_info_read(struct file * file, char __user * buf,
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 10090d9c7ad5..2edf34f2eb61 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -597,7 +597,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
597 597
598static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, 598static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
599 const char *name, 599 const char *name,
600 mode_t mode, 600 umode_t mode,
601 nlink_t nlink) 601 nlink_t nlink)
602{ 602{
603 struct proc_dir_entry *ent = NULL; 603 struct proc_dir_entry *ent = NULL;
@@ -659,7 +659,7 @@ struct proc_dir_entry *proc_symlink(const char *name,
659} 659}
660EXPORT_SYMBOL(proc_symlink); 660EXPORT_SYMBOL(proc_symlink);
661 661
662struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, 662struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
663 struct proc_dir_entry *parent) 663 struct proc_dir_entry *parent)
664{ 664{
665 struct proc_dir_entry *ent; 665 struct proc_dir_entry *ent;
@@ -699,7 +699,7 @@ struct proc_dir_entry *proc_mkdir(const char *name,
699} 699}
700EXPORT_SYMBOL(proc_mkdir); 700EXPORT_SYMBOL(proc_mkdir);
701 701
702struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, 702struct proc_dir_entry *create_proc_entry(const char *name, umode_t mode,
703 struct proc_dir_entry *parent) 703 struct proc_dir_entry *parent)
704{ 704{
705 struct proc_dir_entry *ent; 705 struct proc_dir_entry *ent;
@@ -728,7 +728,7 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
728} 728}
729EXPORT_SYMBOL(create_proc_entry); 729EXPORT_SYMBOL(create_proc_entry);
730 730
731struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, 731struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
732 struct proc_dir_entry *parent, 732 struct proc_dir_entry *parent,
733 const struct file_operations *proc_fops, 733 const struct file_operations *proc_fops,
734 void *data) 734 void *data)
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 7737c5468a40..51a176622b8f 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -77,7 +77,6 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
77static void proc_i_callback(struct rcu_head *head) 77static void proc_i_callback(struct rcu_head *head)
78{ 78{
79 struct inode *inode = container_of(head, struct inode, i_rcu); 79 struct inode *inode = container_of(head, struct inode, i_rcu);
80 INIT_LIST_HEAD(&inode->i_dentry);
81 kmem_cache_free(proc_inode_cachep, PROC_I(inode)); 80 kmem_cache_free(proc_inode_cachep, PROC_I(inode));
82} 81}
83 82
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index be177f702acb..27da860115c6 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -9,7 +9,6 @@
9#include <linux/file.h> 9#include <linux/file.h>
10#include <linux/utsname.h> 10#include <linux/utsname.h>
11#include <net/net_namespace.h> 11#include <net/net_namespace.h>
12#include <linux/mnt_namespace.h>
13#include <linux/ipc_namespace.h> 12#include <linux/ipc_namespace.h>
14#include <linux/pid_namespace.h> 13#include <linux/pid_namespace.h>
15#include "internal.h" 14#include "internal.h"
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index f738024ccc8e..06e1cc17caf6 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -179,7 +179,7 @@ const struct file_operations proc_net_operations = {
179 179
180 180
181struct proc_dir_entry *proc_net_fops_create(struct net *net, 181struct proc_dir_entry *proc_net_fops_create(struct net *net,
182 const char *name, mode_t mode, const struct file_operations *fops) 182 const char *name, umode_t mode, const struct file_operations *fops)
183{ 183{
184 return proc_create(name, mode, net->proc_net, fops); 184 return proc_create(name, mode, net->proc_net, fops);
185} 185}
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
new file mode 100644
index 000000000000..12412852d88a
--- /dev/null
+++ b/fs/proc_namespace.c
@@ -0,0 +1,333 @@
1/*
2 * fs/proc_namespace.c - handling of /proc/<pid>/{mounts,mountinfo,mountstats}
3 *
4 * In fact, that's a piece of procfs; it's *almost* isolated from
5 * the rest of fs/proc, but has rather close relationships with
6 * fs/namespace.c, thus here instead of fs/proc
7 *
8 */
9#include <linux/mnt_namespace.h>
10#include <linux/nsproxy.h>
11#include <linux/security.h>
12#include <linux/fs_struct.h>
13#include "proc/internal.h" /* only for get_proc_task() in ->open() */
14
15#include "pnode.h"
16#include "internal.h"
17
18static unsigned mounts_poll(struct file *file, poll_table *wait)
19{
20 struct proc_mounts *p = file->private_data;
21 struct mnt_namespace *ns = p->ns;
22 unsigned res = POLLIN | POLLRDNORM;
23
24 poll_wait(file, &p->ns->poll, wait);
25
26 br_read_lock(vfsmount_lock);
27 if (p->m.poll_event != ns->event) {
28 p->m.poll_event = ns->event;
29 res |= POLLERR | POLLPRI;
30 }
31 br_read_unlock(vfsmount_lock);
32
33 return res;
34}
35
36struct proc_fs_info {
37 int flag;
38 const char *str;
39};
40
41static int show_sb_opts(struct seq_file *m, struct super_block *sb)
42{
43 static const struct proc_fs_info fs_info[] = {
44 { MS_SYNCHRONOUS, ",sync" },
45 { MS_DIRSYNC, ",dirsync" },
46 { MS_MANDLOCK, ",mand" },
47 { 0, NULL }
48 };
49 const struct proc_fs_info *fs_infop;
50
51 for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
52 if (sb->s_flags & fs_infop->flag)
53 seq_puts(m, fs_infop->str);
54 }
55
56 return security_sb_show_options(m, sb);
57}
58
59static void show_mnt_opts(struct seq_file *m, struct vfsmount *mnt)
60{
61 static const struct proc_fs_info mnt_info[] = {
62 { MNT_NOSUID, ",nosuid" },
63 { MNT_NODEV, ",nodev" },
64 { MNT_NOEXEC, ",noexec" },
65 { MNT_NOATIME, ",noatime" },
66 { MNT_NODIRATIME, ",nodiratime" },
67 { MNT_RELATIME, ",relatime" },
68 { 0, NULL }
69 };
70 const struct proc_fs_info *fs_infop;
71
72 for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
73 if (mnt->mnt_flags & fs_infop->flag)
74 seq_puts(m, fs_infop->str);
75 }
76}
77
78static inline void mangle(struct seq_file *m, const char *s)
79{
80 seq_escape(m, s, " \t\n\\");
81}
82
83static void show_type(struct seq_file *m, struct super_block *sb)
84{
85 mangle(m, sb->s_type->name);
86 if (sb->s_subtype && sb->s_subtype[0]) {
87 seq_putc(m, '.');
88 mangle(m, sb->s_subtype);
89 }
90}
91
92static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt)
93{
94 struct mount *r = real_mount(mnt);
95 int err = 0;
96 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
97 struct super_block *sb = mnt_path.dentry->d_sb;
98
99 if (sb->s_op->show_devname) {
100 err = sb->s_op->show_devname(m, mnt_path.dentry);
101 if (err)
102 goto out;
103 } else {
104 mangle(m, r->mnt_devname ? r->mnt_devname : "none");
105 }
106 seq_putc(m, ' ');
107 seq_path(m, &mnt_path, " \t\n\\");
108 seq_putc(m, ' ');
109 show_type(m, sb);
110 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
111 err = show_sb_opts(m, sb);
112 if (err)
113 goto out;
114 show_mnt_opts(m, mnt);
115 if (sb->s_op->show_options)
116 err = sb->s_op->show_options(m, mnt_path.dentry);
117 seq_puts(m, " 0 0\n");
118out:
119 return err;
120}
121
122static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
123{
124 struct proc_mounts *p = m->private;
125 struct mount *r = real_mount(mnt);
126 struct super_block *sb = mnt->mnt_sb;
127 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
128 struct path root = p->root;
129 int err = 0;
130
131 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
132 MAJOR(sb->s_dev), MINOR(sb->s_dev));
133 if (sb->s_op->show_path)
134 err = sb->s_op->show_path(m, mnt->mnt_root);
135 else
136 seq_dentry(m, mnt->mnt_root, " \t\n\\");
137 if (err)
138 goto out;
139 seq_putc(m, ' ');
140
141 /* mountpoints outside of chroot jail will give SEQ_SKIP on this */
142 err = seq_path_root(m, &mnt_path, &root, " \t\n\\");
143 if (err)
144 goto out;
145
146 seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw");
147 show_mnt_opts(m, mnt);
148
149 /* Tagged fields ("foo:X" or "bar") */
150 if (IS_MNT_SHARED(r))
151 seq_printf(m, " shared:%i", r->mnt_group_id);
152 if (IS_MNT_SLAVE(r)) {
153 int master = r->mnt_master->mnt_group_id;
154 int dom = get_dominating_id(r, &p->root);
155 seq_printf(m, " master:%i", master);
156 if (dom && dom != master)
157 seq_printf(m, " propagate_from:%i", dom);
158 }
159 if (IS_MNT_UNBINDABLE(r))
160 seq_puts(m, " unbindable");
161
162 /* Filesystem specific data */
163 seq_puts(m, " - ");
164 show_type(m, sb);
165 seq_putc(m, ' ');
166 if (sb->s_op->show_devname)
167 err = sb->s_op->show_devname(m, mnt->mnt_root);
168 else
169 mangle(m, r->mnt_devname ? r->mnt_devname : "none");
170 if (err)
171 goto out;
172 seq_puts(m, sb->s_flags & MS_RDONLY ? " ro" : " rw");
173 err = show_sb_opts(m, sb);
174 if (err)
175 goto out;
176 if (sb->s_op->show_options)
177 err = sb->s_op->show_options(m, mnt->mnt_root);
178 seq_putc(m, '\n');
179out:
180 return err;
181}
182
183static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)
184{
185 struct mount *r = real_mount(mnt);
186 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
187 struct super_block *sb = mnt_path.dentry->d_sb;
188 int err = 0;
189
190 /* device */
191 if (sb->s_op->show_devname) {
192 seq_puts(m, "device ");
193 err = sb->s_op->show_devname(m, mnt_path.dentry);
194 } else {
195 if (r->mnt_devname) {
196 seq_puts(m, "device ");
197 mangle(m, r->mnt_devname);
198 } else
199 seq_puts(m, "no device");
200 }
201
202 /* mount point */
203 seq_puts(m, " mounted on ");
204 seq_path(m, &mnt_path, " \t\n\\");
205 seq_putc(m, ' ');
206
207 /* file system type */
208 seq_puts(m, "with fstype ");
209 show_type(m, sb);
210
211 /* optional statistics */
212 if (sb->s_op->show_stats) {
213 seq_putc(m, ' ');
214 if (!err)
215 err = sb->s_op->show_stats(m, mnt_path.dentry);
216 }
217
218 seq_putc(m, '\n');
219 return err;
220}
221
222static int mounts_open_common(struct inode *inode, struct file *file,
223 int (*show)(struct seq_file *, struct vfsmount *))
224{
225 struct task_struct *task = get_proc_task(inode);
226 struct nsproxy *nsp;
227 struct mnt_namespace *ns = NULL;
228 struct path root;
229 struct proc_mounts *p;
230 int ret = -EINVAL;
231
232 if (!task)
233 goto err;
234
235 rcu_read_lock();
236 nsp = task_nsproxy(task);
237 if (!nsp) {
238 rcu_read_unlock();
239 put_task_struct(task);
240 goto err;
241 }
242 ns = nsp->mnt_ns;
243 if (!ns) {
244 rcu_read_unlock();
245 put_task_struct(task);
246 goto err;
247 }
248 get_mnt_ns(ns);
249 rcu_read_unlock();
250 task_lock(task);
251 if (!task->fs) {
252 task_unlock(task);
253 put_task_struct(task);
254 ret = -ENOENT;
255 goto err_put_ns;
256 }
257 get_fs_root(task->fs, &root);
258 task_unlock(task);
259 put_task_struct(task);
260
261 ret = -ENOMEM;
262 p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL);
263 if (!p)
264 goto err_put_path;
265
266 file->private_data = &p->m;
267 ret = seq_open(file, &mounts_op);
268 if (ret)
269 goto err_free;
270
271 p->m.private = p;
272 p->ns = ns;
273 p->root = root;
274 p->m.poll_event = ns->event;
275 p->show = show;
276
277 return 0;
278
279 err_free:
280 kfree(p);
281 err_put_path:
282 path_put(&root);
283 err_put_ns:
284 put_mnt_ns(ns);
285 err:
286 return ret;
287}
288
289static int mounts_release(struct inode *inode, struct file *file)
290{
291 struct proc_mounts *p = file->private_data;
292 path_put(&p->root);
293 put_mnt_ns(p->ns);
294 return seq_release(inode, file);
295}
296
297static int mounts_open(struct inode *inode, struct file *file)
298{
299 return mounts_open_common(inode, file, show_vfsmnt);
300}
301
302static int mountinfo_open(struct inode *inode, struct file *file)
303{
304 return mounts_open_common(inode, file, show_mountinfo);
305}
306
307static int mountstats_open(struct inode *inode, struct file *file)
308{
309 return mounts_open_common(inode, file, show_vfsstat);
310}
311
312const struct file_operations proc_mounts_operations = {
313 .open = mounts_open,
314 .read = seq_read,
315 .llseek = seq_lseek,
316 .release = mounts_release,
317 .poll = mounts_poll,
318};
319
320const struct file_operations proc_mountinfo_operations = {
321 .open = mountinfo_open,
322 .read = seq_read,
323 .llseek = seq_lseek,
324 .release = mounts_release,
325 .poll = mounts_poll,
326};
327
328const struct file_operations proc_mountstats_operations = {
329 .open = mountstats_open,
330 .read = seq_read,
331 .llseek = seq_lseek,
332 .release = mounts_release,
333};
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 3bdd21418432..b90c7967fcae 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -427,7 +427,6 @@ static struct inode *qnx4_alloc_inode(struct super_block *sb)
427static void qnx4_i_callback(struct rcu_head *head) 427static void qnx4_i_callback(struct rcu_head *head)
428{ 428{
429 struct inode *inode = container_of(head, struct inode, i_rcu); 429 struct inode *inode = container_of(head, struct inode, i_rcu);
430 INIT_LIST_HEAD(&inode->i_dentry);
431 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); 430 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode));
432} 431}
433 432
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 5b572c89e6c4..5ec59b20cf76 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -73,7 +73,6 @@
73#include <linux/security.h> 73#include <linux/security.h>
74#include <linux/kmod.h> 74#include <linux/kmod.h>
75#include <linux/namei.h> 75#include <linux/namei.h>
76#include <linux/buffer_head.h>
77#include <linux/capability.h> 76#include <linux/capability.h>
78#include <linux/quotaops.h> 77#include <linux/quotaops.h>
79#include "../internal.h" /* ugh */ 78#include "../internal.h" /* ugh */
@@ -2199,7 +2198,7 @@ int dquot_quota_on(struct super_block *sb, int type, int format_id,
2199 if (error) 2198 if (error)
2200 return error; 2199 return error;
2201 /* Quota file not on the same filesystem? */ 2200 /* Quota file not on the same filesystem? */
2202 if (path->mnt->mnt_sb != sb) 2201 if (path->dentry->d_sb != sb)
2203 error = -EXDEV; 2202 error = -EXDEV;
2204 else 2203 else
2205 error = vfs_load_quota_inode(path->dentry->d_inode, type, 2204 error = vfs_load_quota_inode(path->dentry->d_inode, type,
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 35f4b0ecdeb3..7898cd688a00 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -13,7 +13,6 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/security.h> 14#include <linux/security.h>
15#include <linux/syscalls.h> 15#include <linux/syscalls.h>
16#include <linux/buffer_head.h>
17#include <linux/capability.h> 16#include <linux/capability.h>
18#include <linux/quotaops.h> 17#include <linux/quotaops.h>
19#include <linux/types.h> 18#include <linux/types.h>
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 462ceb38fec6..aec766abe3af 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -52,7 +52,7 @@ static struct backing_dev_info ramfs_backing_dev_info = {
52}; 52};
53 53
54struct inode *ramfs_get_inode(struct super_block *sb, 54struct inode *ramfs_get_inode(struct super_block *sb,
55 const struct inode *dir, int mode, dev_t dev) 55 const struct inode *dir, umode_t mode, dev_t dev)
56{ 56{
57 struct inode * inode = new_inode(sb); 57 struct inode * inode = new_inode(sb);
58 58
@@ -92,7 +92,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
92 */ 92 */
93/* SMP-safe */ 93/* SMP-safe */
94static int 94static int
95ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) 95ramfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
96{ 96{
97 struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev); 97 struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev);
98 int error = -ENOSPC; 98 int error = -ENOSPC;
@@ -106,7 +106,7 @@ ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
106 return error; 106 return error;
107} 107}
108 108
109static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) 109static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
110{ 110{
111 int retval = ramfs_mknod(dir, dentry, mode | S_IFDIR, 0); 111 int retval = ramfs_mknod(dir, dentry, mode | S_IFDIR, 0);
112 if (!retval) 112 if (!retval)
@@ -114,7 +114,7 @@ static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
114 return retval; 114 return retval;
115} 115}
116 116
117static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) 117static int ramfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd)
118{ 118{
119 return ramfs_mknod(dir, dentry, mode | S_IFREG, 0); 119 return ramfs_mknod(dir, dentry, mode | S_IFREG, 0);
120} 120}
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index d1aca1df4f92..a945cd265228 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -13,6 +13,7 @@
13#include <linux/reiserfs_fs_sb.h> 13#include <linux/reiserfs_fs_sb.h>
14#include <linux/reiserfs_fs_i.h> 14#include <linux/reiserfs_fs_i.h>
15#include <linux/quotaops.h> 15#include <linux/quotaops.h>
16#include <linux/seq_file.h>
16 17
17#define PREALLOCATION_SIZE 9 18#define PREALLOCATION_SIZE 9
18 19
@@ -634,6 +635,96 @@ int reiserfs_parse_alloc_options(struct super_block *s, char *options)
634 return 0; 635 return 0;
635} 636}
636 637
638static void print_sep(struct seq_file *seq, int *first)
639{
640 if (!*first)
641 seq_puts(seq, ":");
642 else
643 *first = 0;
644}
645
646void show_alloc_options(struct seq_file *seq, struct super_block *s)
647{
648 int first = 1;
649
650 if (SB_ALLOC_OPTS(s) == ((1 << _ALLOC_skip_busy) |
651 (1 << _ALLOC_dirid_groups) | (1 << _ALLOC_packing_groups)))
652 return;
653
654 seq_puts(seq, ",alloc=");
655
656 if (TEST_OPTION(concentrating_formatted_nodes, s)) {
657 print_sep(seq, &first);
658 if (REISERFS_SB(s)->s_alloc_options.border != 10) {
659 seq_printf(seq, "concentrating_formatted_nodes=%d",
660 100 / REISERFS_SB(s)->s_alloc_options.border);
661 } else
662 seq_puts(seq, "concentrating_formatted_nodes");
663 }
664 if (TEST_OPTION(displacing_large_files, s)) {
665 print_sep(seq, &first);
666 if (REISERFS_SB(s)->s_alloc_options.large_file_size != 16) {
667 seq_printf(seq, "displacing_large_files=%lu",
668 REISERFS_SB(s)->s_alloc_options.large_file_size);
669 } else
670 seq_puts(seq, "displacing_large_files");
671 }
672 if (TEST_OPTION(displacing_new_packing_localities, s)) {
673 print_sep(seq, &first);
674 seq_puts(seq, "displacing_new_packing_localities");
675 }
676 if (TEST_OPTION(old_hashed_relocation, s)) {
677 print_sep(seq, &first);
678 seq_puts(seq, "old_hashed_relocation");
679 }
680 if (TEST_OPTION(new_hashed_relocation, s)) {
681 print_sep(seq, &first);
682 seq_puts(seq, "new_hashed_relocation");
683 }
684 if (TEST_OPTION(dirid_groups, s)) {
685 print_sep(seq, &first);
686 seq_puts(seq, "dirid_groups");
687 }
688 if (TEST_OPTION(oid_groups, s)) {
689 print_sep(seq, &first);
690 seq_puts(seq, "oid_groups");
691 }
692 if (TEST_OPTION(packing_groups, s)) {
693 print_sep(seq, &first);
694 seq_puts(seq, "packing_groups");
695 }
696 if (TEST_OPTION(hashed_formatted_nodes, s)) {
697 print_sep(seq, &first);
698 seq_puts(seq, "hashed_formatted_nodes");
699 }
700 if (TEST_OPTION(skip_busy, s)) {
701 print_sep(seq, &first);
702 seq_puts(seq, "skip_busy");
703 }
704 if (TEST_OPTION(hundredth_slices, s)) {
705 print_sep(seq, &first);
706 seq_puts(seq, "hundredth_slices");
707 }
708 if (TEST_OPTION(old_way, s)) {
709 print_sep(seq, &first);
710 seq_puts(seq, "old_way");
711 }
712 if (TEST_OPTION(displace_based_on_dirid, s)) {
713 print_sep(seq, &first);
714 seq_puts(seq, "displace_based_on_dirid");
715 }
716 if (REISERFS_SB(s)->s_alloc_options.preallocmin != 0) {
717 print_sep(seq, &first);
718 seq_printf(seq, "preallocmin=%d",
719 REISERFS_SB(s)->s_alloc_options.preallocmin);
720 }
721 if (REISERFS_SB(s)->s_alloc_options.preallocsize != 17) {
722 print_sep(seq, &first);
723 seq_printf(seq, "preallocsize=%d",
724 REISERFS_SB(s)->s_alloc_options.preallocsize);
725 }
726}
727
637static inline void new_hashed_relocation(reiserfs_blocknr_hint_t * hint) 728static inline void new_hashed_relocation(reiserfs_blocknr_hint_t * hint)
638{ 729{
639 char *hash_in; 730 char *hash_in;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 950f13af0951..9e8cd5acd79c 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1766,7 +1766,7 @@ static int reiserfs_new_symlink(struct reiserfs_transaction_handle *th, struct i
1766 for the fresh inode. This can only be done outside a transaction, so 1766 for the fresh inode. This can only be done outside a transaction, so
1767 if we return non-zero, we also end the transaction. */ 1767 if we return non-zero, we also end the transaction. */
1768int reiserfs_new_inode(struct reiserfs_transaction_handle *th, 1768int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1769 struct inode *dir, int mode, const char *symname, 1769 struct inode *dir, umode_t mode, const char *symname,
1770 /* 0 for regular, EMTRY_DIR_SIZE for dirs, 1770 /* 0 for regular, EMTRY_DIR_SIZE for dirs,
1771 strlen (symname) for symlinks) */ 1771 strlen (symname) for symlinks) */
1772 loff_t i_size, struct dentry *dentry, 1772 loff_t i_size, struct dentry *dentry,
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 4e153051bc75..950e3d1b5c9e 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -55,7 +55,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
55 break; 55 break;
56 } 56 }
57 57
58 err = mnt_want_write(filp->f_path.mnt); 58 err = mnt_want_write_file(filp);
59 if (err) 59 if (err)
60 break; 60 break;
61 61
@@ -96,7 +96,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
96 inode->i_ctime = CURRENT_TIME_SEC; 96 inode->i_ctime = CURRENT_TIME_SEC;
97 mark_inode_dirty(inode); 97 mark_inode_dirty(inode);
98setflags_out: 98setflags_out:
99 mnt_drop_write(filp->f_path.mnt); 99 mnt_drop_write_file(filp);
100 break; 100 break;
101 } 101 }
102 case REISERFS_IOC_GETVERSION: 102 case REISERFS_IOC_GETVERSION:
@@ -107,7 +107,7 @@ setflags_out:
107 err = -EPERM; 107 err = -EPERM;
108 break; 108 break;
109 } 109 }
110 err = mnt_want_write(filp->f_path.mnt); 110 err = mnt_want_write_file(filp);
111 if (err) 111 if (err)
112 break; 112 break;
113 if (get_user(inode->i_generation, (int __user *)arg)) { 113 if (get_user(inode->i_generation, (int __user *)arg)) {
@@ -117,7 +117,7 @@ setflags_out:
117 inode->i_ctime = CURRENT_TIME_SEC; 117 inode->i_ctime = CURRENT_TIME_SEC;
118 mark_inode_dirty(inode); 118 mark_inode_dirty(inode);
119setversion_out: 119setversion_out:
120 mnt_drop_write(filp->f_path.mnt); 120 mnt_drop_write_file(filp);
121 break; 121 break;
122 default: 122 default:
123 err = -ENOTTY; 123 err = -ENOTTY;
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 80058e8ce361..146378865239 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -559,7 +559,7 @@ static int drop_new_inode(struct inode *inode)
559** outside of a transaction, so we had to pull some bits of 559** outside of a transaction, so we had to pull some bits of
560** reiserfs_new_inode out into this func. 560** reiserfs_new_inode out into this func.
561*/ 561*/
562static int new_inode_init(struct inode *inode, struct inode *dir, int mode) 562static int new_inode_init(struct inode *inode, struct inode *dir, umode_t mode)
563{ 563{
564 /* Make inode invalid - just in case we are going to drop it before 564 /* Make inode invalid - just in case we are going to drop it before
565 * the initialization happens */ 565 * the initialization happens */
@@ -572,7 +572,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, int mode)
572 return 0; 572 return 0;
573} 573}
574 574
575static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode, 575static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
576 struct nameidata *nd) 576 struct nameidata *nd)
577{ 577{
578 int retval; 578 int retval;
@@ -643,7 +643,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
643 return retval; 643 return retval;
644} 644}
645 645
646static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode, 646static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
647 dev_t rdev) 647 dev_t rdev)
648{ 648{
649 int retval; 649 int retval;
@@ -721,7 +721,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
721 return retval; 721 return retval;
722} 722}
723 723
724static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 724static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
725{ 725{
726 int retval; 726 int retval;
727 struct inode *inode; 727 struct inode *inode;
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 14363b96b6af..19c454e61b79 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -28,6 +28,7 @@
28#include <linux/mount.h> 28#include <linux/mount.h>
29#include <linux/namei.h> 29#include <linux/namei.h>
30#include <linux/crc32.h> 30#include <linux/crc32.h>
31#include <linux/seq_file.h>
31 32
32struct file_system_type reiserfs_fs_type; 33struct file_system_type reiserfs_fs_type;
33 34
@@ -61,6 +62,7 @@ static int is_any_reiserfs_magic_string(struct reiserfs_super_block *rs)
61 62
62static int reiserfs_remount(struct super_block *s, int *flags, char *data); 63static int reiserfs_remount(struct super_block *s, int *flags, char *data);
63static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf); 64static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf);
65void show_alloc_options(struct seq_file *seq, struct super_block *s);
64 66
65static int reiserfs_sync_fs(struct super_block *s, int wait) 67static int reiserfs_sync_fs(struct super_block *s, int wait)
66{ 68{
@@ -532,7 +534,6 @@ static struct inode *reiserfs_alloc_inode(struct super_block *sb)
532static void reiserfs_i_callback(struct rcu_head *head) 534static void reiserfs_i_callback(struct rcu_head *head)
533{ 535{
534 struct inode *inode = container_of(head, struct inode, i_rcu); 536 struct inode *inode = container_of(head, struct inode, i_rcu);
535 INIT_LIST_HEAD(&inode->i_dentry);
536 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); 537 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
537} 538}
538 539
@@ -597,6 +598,82 @@ out:
597 reiserfs_write_unlock_once(inode->i_sb, lock_depth); 598 reiserfs_write_unlock_once(inode->i_sb, lock_depth);
598} 599}
599 600
601static int reiserfs_show_options(struct seq_file *seq, struct dentry *root)
602{
603 struct super_block *s = root->d_sb;
604 struct reiserfs_journal *journal = SB_JOURNAL(s);
605 long opts = REISERFS_SB(s)->s_mount_opt;
606
607 if (opts & (1 << REISERFS_LARGETAIL))
608 seq_puts(seq, ",tails=on");
609 else if (!(opts & (1 << REISERFS_SMALLTAIL)))
610 seq_puts(seq, ",notail");
611 /* tails=small is default so we don't show it */
612
613 if (!(opts & (1 << REISERFS_BARRIER_FLUSH)))
614 seq_puts(seq, ",barrier=none");
615 /* barrier=flush is default so we don't show it */
616
617 if (opts & (1 << REISERFS_ERROR_CONTINUE))
618 seq_puts(seq, ",errors=continue");
619 else if (opts & (1 << REISERFS_ERROR_PANIC))
620 seq_puts(seq, ",errors=panic");
621 /* errors=ro is default so we don't show it */
622
623 if (opts & (1 << REISERFS_DATA_LOG))
624 seq_puts(seq, ",data=journal");
625 else if (opts & (1 << REISERFS_DATA_WRITEBACK))
626 seq_puts(seq, ",data=writeback");
627 /* data=ordered is default so we don't show it */
628
629 if (opts & (1 << REISERFS_ATTRS))
630 seq_puts(seq, ",attrs");
631
632 if (opts & (1 << REISERFS_XATTRS_USER))
633 seq_puts(seq, ",user_xattr");
634
635 if (opts & (1 << REISERFS_EXPOSE_PRIVROOT))
636 seq_puts(seq, ",expose_privroot");
637
638 if (opts & (1 << REISERFS_POSIXACL))
639 seq_puts(seq, ",acl");
640
641 if (REISERFS_SB(s)->s_jdev)
642 seq_printf(seq, ",jdev=%s", REISERFS_SB(s)->s_jdev);
643
644 if (journal->j_max_commit_age != journal->j_default_max_commit_age)
645 seq_printf(seq, ",commit=%d", journal->j_max_commit_age);
646
647#ifdef CONFIG_QUOTA
648 if (REISERFS_SB(s)->s_qf_names[USRQUOTA])
649 seq_printf(seq, ",usrjquota=%s", REISERFS_SB(s)->s_qf_names[USRQUOTA]);
650 else if (opts & (1 << REISERFS_USRQUOTA))
651 seq_puts(seq, ",usrquota");
652 if (REISERFS_SB(s)->s_qf_names[GRPQUOTA])
653 seq_printf(seq, ",grpjquota=%s", REISERFS_SB(s)->s_qf_names[GRPQUOTA]);
654 else if (opts & (1 << REISERFS_GRPQUOTA))
655 seq_puts(seq, ",grpquota");
656 if (REISERFS_SB(s)->s_jquota_fmt) {
657 if (REISERFS_SB(s)->s_jquota_fmt == QFMT_VFS_OLD)
658 seq_puts(seq, ",jqfmt=vfsold");
659 else if (REISERFS_SB(s)->s_jquota_fmt == QFMT_VFS_V0)
660 seq_puts(seq, ",jqfmt=vfsv0");
661 }
662#endif
663
664 /* Block allocator options */
665 if (opts & (1 << REISERFS_NO_BORDER))
666 seq_puts(seq, ",block-allocator=noborder");
667 if (opts & (1 << REISERFS_NO_UNHASHED_RELOCATION))
668 seq_puts(seq, ",block-allocator=no_unhashed_relocation");
669 if (opts & (1 << REISERFS_HASHED_RELOCATION))
670 seq_puts(seq, ",block-allocator=hashed_relocation");
671 if (opts & (1 << REISERFS_TEST4))
672 seq_puts(seq, ",block-allocator=test4");
673 show_alloc_options(seq, s);
674 return 0;
675}
676
600#ifdef CONFIG_QUOTA 677#ifdef CONFIG_QUOTA
601static ssize_t reiserfs_quota_write(struct super_block *, int, const char *, 678static ssize_t reiserfs_quota_write(struct super_block *, int, const char *,
602 size_t, loff_t); 679 size_t, loff_t);
@@ -617,7 +694,7 @@ static const struct super_operations reiserfs_sops = {
617 .unfreeze_fs = reiserfs_unfreeze, 694 .unfreeze_fs = reiserfs_unfreeze,
618 .statfs = reiserfs_statfs, 695 .statfs = reiserfs_statfs,
619 .remount_fs = reiserfs_remount, 696 .remount_fs = reiserfs_remount,
620 .show_options = generic_show_options, 697 .show_options = reiserfs_show_options,
621#ifdef CONFIG_QUOTA 698#ifdef CONFIG_QUOTA
622 .quota_read = reiserfs_quota_read, 699 .quota_read = reiserfs_quota_read,
623 .quota_write = reiserfs_quota_write, 700 .quota_write = reiserfs_quota_write,
@@ -915,9 +992,9 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
915 {"jdev",.arg_required = 'j',.values = NULL}, 992 {"jdev",.arg_required = 'j',.values = NULL},
916 {"nolargeio",.arg_required = 'w',.values = NULL}, 993 {"nolargeio",.arg_required = 'w',.values = NULL},
917 {"commit",.arg_required = 'c',.values = NULL}, 994 {"commit",.arg_required = 'c',.values = NULL},
918 {"usrquota",.setmask = 1 << REISERFS_QUOTA}, 995 {"usrquota",.setmask = 1 << REISERFS_USRQUOTA},
919 {"grpquota",.setmask = 1 << REISERFS_QUOTA}, 996 {"grpquota",.setmask = 1 << REISERFS_GRPQUOTA},
920 {"noquota",.clrmask = 1 << REISERFS_QUOTA}, 997 {"noquota",.clrmask = 1 << REISERFS_USRQUOTA | 1 << REISERFS_GRPQUOTA},
921 {"errors",.arg_required = 'e',.values = error_actions}, 998 {"errors",.arg_required = 'e',.values = error_actions},
922 {"usrjquota",.arg_required = 999 {"usrjquota",.arg_required =
923 'u' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL}, 1000 'u' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
@@ -1031,12 +1108,19 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
1031 return 0; 1108 return 0;
1032 } 1109 }
1033 strcpy(qf_names[qtype], arg); 1110 strcpy(qf_names[qtype], arg);
1034 *mount_options |= 1 << REISERFS_QUOTA; 1111 if (qtype == USRQUOTA)
1112 *mount_options |= 1 << REISERFS_USRQUOTA;
1113 else
1114 *mount_options |= 1 << REISERFS_GRPQUOTA;
1035 } else { 1115 } else {
1036 if (qf_names[qtype] != 1116 if (qf_names[qtype] !=
1037 REISERFS_SB(s)->s_qf_names[qtype]) 1117 REISERFS_SB(s)->s_qf_names[qtype])
1038 kfree(qf_names[qtype]); 1118 kfree(qf_names[qtype]);
1039 qf_names[qtype] = NULL; 1119 qf_names[qtype] = NULL;
1120 if (qtype == USRQUOTA)
1121 *mount_options &= ~(1 << REISERFS_USRQUOTA);
1122 else
1123 *mount_options &= ~(1 << REISERFS_GRPQUOTA);
1040 } 1124 }
1041 } 1125 }
1042 if (c == 'f') { 1126 if (c == 'f') {
@@ -1075,9 +1159,10 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
1075 "journaled quota format not specified."); 1159 "journaled quota format not specified.");
1076 return 0; 1160 return 0;
1077 } 1161 }
1078 /* This checking is not precise wrt the quota type but for our purposes it is sufficient */ 1162 if ((!(*mount_options & (1 << REISERFS_USRQUOTA)) &&
1079 if (!(*mount_options & (1 << REISERFS_QUOTA)) 1163 sb_has_quota_loaded(s, USRQUOTA)) ||
1080 && sb_any_quota_loaded(s)) { 1164 (!(*mount_options & (1 << REISERFS_GRPQUOTA)) &&
1165 sb_has_quota_loaded(s, GRPQUOTA))) {
1081 reiserfs_warning(s, "super-6516", "quota options must " 1166 reiserfs_warning(s, "super-6516", "quota options must "
1082 "be present when quota is turned on."); 1167 "be present when quota is turned on.");
1083 return 0; 1168 return 0;
@@ -1225,7 +1310,8 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1225 safe_mask |= 1 << REISERFS_ERROR_RO; 1310 safe_mask |= 1 << REISERFS_ERROR_RO;
1226 safe_mask |= 1 << REISERFS_ERROR_CONTINUE; 1311 safe_mask |= 1 << REISERFS_ERROR_CONTINUE;
1227 safe_mask |= 1 << REISERFS_ERROR_PANIC; 1312 safe_mask |= 1 << REISERFS_ERROR_PANIC;
1228 safe_mask |= 1 << REISERFS_QUOTA; 1313 safe_mask |= 1 << REISERFS_USRQUOTA;
1314 safe_mask |= 1 << REISERFS_GRPQUOTA;
1229 1315
1230 /* Update the bitmask, taking care to keep 1316 /* Update the bitmask, taking care to keep
1231 * the bits we're not allowed to change here */ 1317 * the bits we're not allowed to change here */
@@ -1672,6 +1758,14 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1672 &commit_max_age, qf_names, &qfmt) == 0) { 1758 &commit_max_age, qf_names, &qfmt) == 0) {
1673 goto error; 1759 goto error;
1674 } 1760 }
1761 if (jdev_name && jdev_name[0]) {
1762 REISERFS_SB(s)->s_jdev = kstrdup(jdev_name, GFP_KERNEL);
1763 if (!REISERFS_SB(s)->s_jdev) {
1764 SWARN(silent, s, "", "Cannot allocate memory for "
1765 "journal device name");
1766 goto error;
1767 }
1768 }
1675#ifdef CONFIG_QUOTA 1769#ifdef CONFIG_QUOTA
1676 handle_quota_files(s, qf_names, &qfmt); 1770 handle_quota_files(s, qf_names, &qfmt);
1677#endif 1771#endif
@@ -2054,12 +2148,13 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2054 int err; 2148 int err;
2055 struct inode *inode; 2149 struct inode *inode;
2056 struct reiserfs_transaction_handle th; 2150 struct reiserfs_transaction_handle th;
2151 int opt = type == USRQUOTA ? REISERFS_USRQUOTA : REISERFS_GRPQUOTA;
2057 2152
2058 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA))) 2153 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << opt)))
2059 return -EINVAL; 2154 return -EINVAL;
2060 2155
2061 /* Quotafile not on the same filesystem? */ 2156 /* Quotafile not on the same filesystem? */
2062 if (path->mnt->mnt_sb != sb) { 2157 if (path->dentry->d_sb != sb) {
2063 err = -EXDEV; 2158 err = -EXDEV;
2064 goto out; 2159 goto out;
2065 } 2160 }
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 6bc346c160e7..c24deda8a8bc 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -66,7 +66,7 @@ static int xattr_create(struct inode *dir, struct dentry *dentry, int mode)
66} 66}
67#endif 67#endif
68 68
69static int xattr_mkdir(struct inode *dir, struct dentry *dentry, int mode) 69static int xattr_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
70{ 70{
71 BUG_ON(!mutex_is_locked(&dir->i_mutex)); 71 BUG_ON(!mutex_is_locked(&dir->i_mutex));
72 return dir->i_op->mkdir(dir, dentry, mode); 72 return dir->i_op->mkdir(dir, dentry, mode);
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index 8b4089f30408..bb36ab74eb45 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -403,7 +403,6 @@ static struct inode *romfs_alloc_inode(struct super_block *sb)
403static void romfs_i_callback(struct rcu_head *head) 403static void romfs_i_callback(struct rcu_head *head)
404{ 404{
405 struct inode *inode = container_of(head, struct inode, i_rcu); 405 struct inode *inode = container_of(head, struct inode, i_rcu);
406 INIT_LIST_HEAD(&inode->i_dentry);
407 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); 406 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
408} 407}
409 408
diff --git a/fs/seq_file.c b/fs/seq_file.c
index dba43c3ea3af..4023d6be939b 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -397,7 +397,7 @@ EXPORT_SYMBOL(seq_printf);
397 * Returns pointer past last written character in @s, or NULL in case of 397 * Returns pointer past last written character in @s, or NULL in case of
398 * failure. 398 * failure.
399 */ 399 */
400char *mangle_path(char *s, char *p, char *esc) 400char *mangle_path(char *s, const char *p, const char *esc)
401{ 401{
402 while (s <= p) { 402 while (s <= p) {
403 char c = *p++; 403 char c = *p++;
@@ -427,7 +427,7 @@ EXPORT_SYMBOL(mangle_path);
427 * return the absolute path of 'path', as represented by the 427 * return the absolute path of 'path', as represented by the
428 * dentry / mnt pair in the path parameter. 428 * dentry / mnt pair in the path parameter.
429 */ 429 */
430int seq_path(struct seq_file *m, struct path *path, char *esc) 430int seq_path(struct seq_file *m, const struct path *path, const char *esc)
431{ 431{
432 char *buf; 432 char *buf;
433 size_t size = seq_get_buf(m, &buf); 433 size_t size = seq_get_buf(m, &buf);
@@ -450,8 +450,8 @@ EXPORT_SYMBOL(seq_path);
450/* 450/*
451 * Same as seq_path, but relative to supplied root. 451 * Same as seq_path, but relative to supplied root.
452 */ 452 */
453int seq_path_root(struct seq_file *m, struct path *path, struct path *root, 453int seq_path_root(struct seq_file *m, const struct path *path,
454 char *esc) 454 const struct path *root, const char *esc)
455{ 455{
456 char *buf; 456 char *buf;
457 size_t size = seq_get_buf(m, &buf); 457 size_t size = seq_get_buf(m, &buf);
@@ -480,7 +480,7 @@ int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
480/* 480/*
481 * returns the path of the 'dentry' from the root of its filesystem. 481 * returns the path of the 'dentry' from the root of its filesystem.
482 */ 482 */
483int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc) 483int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc)
484{ 484{
485 char *buf; 485 char *buf;
486 size_t size = seq_get_buf(m, &buf); 486 size_t size = seq_get_buf(m, &buf);
diff --git a/fs/splice.c b/fs/splice.c
index fa2defa8afcf..1ec0493266b3 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -25,7 +25,6 @@
25#include <linux/mm_inline.h> 25#include <linux/mm_inline.h>
26#include <linux/swap.h> 26#include <linux/swap.h>
27#include <linux/writeback.h> 27#include <linux/writeback.h>
28#include <linux/buffer_head.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/syscalls.h> 29#include <linux/syscalls.h>
31#include <linux/uio.h> 30#include <linux/uio.h>
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 2da1715452ac..d0858c2d9a47 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -464,7 +464,6 @@ static struct inode *squashfs_alloc_inode(struct super_block *sb)
464static void squashfs_i_callback(struct rcu_head *head) 464static void squashfs_i_callback(struct rcu_head *head)
465{ 465{
466 struct inode *inode = container_of(head, struct inode, i_rcu); 466 struct inode *inode = container_of(head, struct inode, i_rcu);
467 INIT_LIST_HEAD(&inode->i_dentry);
468 kmem_cache_free(squashfs_inode_cachep, squashfs_i(inode)); 467 kmem_cache_free(squashfs_inode_cachep, squashfs_i(inode));
469} 468}
470 469
diff --git a/fs/statfs.c b/fs/statfs.c
index 9cf04a118965..2aa6a22e0be2 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -7,6 +7,7 @@
7#include <linux/statfs.h> 7#include <linux/statfs.h>
8#include <linux/security.h> 8#include <linux/security.h>
9#include <linux/uaccess.h> 9#include <linux/uaccess.h>
10#include "internal.h"
10 11
11static int flags_by_mnt(int mnt_flags) 12static int flags_by_mnt(int mnt_flags)
12{ 13{
@@ -45,7 +46,7 @@ static int calculate_f_flags(struct vfsmount *mnt)
45 flags_by_sb(mnt->mnt_sb->s_flags); 46 flags_by_sb(mnt->mnt_sb->s_flags);
46} 47}
47 48
48int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf) 49static int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
49{ 50{
50 int retval; 51 int retval;
51 52
@@ -205,19 +206,23 @@ SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user
205 return error; 206 return error;
206} 207}
207 208
208SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf) 209int vfs_ustat(dev_t dev, struct kstatfs *sbuf)
209{ 210{
210 struct super_block *s; 211 struct super_block *s = user_get_super(dev);
211 struct ustat tmp;
212 struct kstatfs sbuf;
213 int err; 212 int err;
214
215 s = user_get_super(new_decode_dev(dev));
216 if (!s) 213 if (!s)
217 return -EINVAL; 214 return -EINVAL;
218 215
219 err = statfs_by_dentry(s->s_root, &sbuf); 216 err = statfs_by_dentry(s->s_root, sbuf);
220 drop_super(s); 217 drop_super(s);
218 return err;
219}
220
221SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
222{
223 struct ustat tmp;
224 struct kstatfs sbuf;
225 int err = vfs_ustat(new_decode_dev(dev), &sbuf);
221 if (err) 226 if (err)
222 return err; 227 return err;
223 228
diff --git a/fs/super.c b/fs/super.c
index afd0f1ad45e0..de41e1e46f09 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -136,12 +136,13 @@ static struct super_block *alloc_super(struct file_system_type *type)
136 INIT_LIST_HEAD(&s->s_files); 136 INIT_LIST_HEAD(&s->s_files);
137#endif 137#endif
138 s->s_bdi = &default_backing_dev_info; 138 s->s_bdi = &default_backing_dev_info;
139 INIT_LIST_HEAD(&s->s_instances); 139 INIT_HLIST_NODE(&s->s_instances);
140 INIT_HLIST_BL_HEAD(&s->s_anon); 140 INIT_HLIST_BL_HEAD(&s->s_anon);
141 INIT_LIST_HEAD(&s->s_inodes); 141 INIT_LIST_HEAD(&s->s_inodes);
142 INIT_LIST_HEAD(&s->s_dentry_lru); 142 INIT_LIST_HEAD(&s->s_dentry_lru);
143 INIT_LIST_HEAD(&s->s_inode_lru); 143 INIT_LIST_HEAD(&s->s_inode_lru);
144 spin_lock_init(&s->s_inode_lru_lock); 144 spin_lock_init(&s->s_inode_lru_lock);
145 INIT_LIST_HEAD(&s->s_mounts);
145 init_rwsem(&s->s_umount); 146 init_rwsem(&s->s_umount);
146 mutex_init(&s->s_lock); 147 mutex_init(&s->s_lock);
147 lockdep_set_class(&s->s_umount, &type->s_umount_key); 148 lockdep_set_class(&s->s_umount, &type->s_umount_key);
@@ -200,6 +201,7 @@ static inline void destroy_super(struct super_block *s)
200 free_percpu(s->s_files); 201 free_percpu(s->s_files);
201#endif 202#endif
202 security_sb_free(s); 203 security_sb_free(s);
204 WARN_ON(!list_empty(&s->s_mounts));
203 kfree(s->s_subtype); 205 kfree(s->s_subtype);
204 kfree(s->s_options); 206 kfree(s->s_options);
205 kfree(s); 207 kfree(s);
@@ -210,7 +212,7 @@ static inline void destroy_super(struct super_block *s)
210/* 212/*
211 * Drop a superblock's refcount. The caller must hold sb_lock. 213 * Drop a superblock's refcount. The caller must hold sb_lock.
212 */ 214 */
213void __put_super(struct super_block *sb) 215static void __put_super(struct super_block *sb)
214{ 216{
215 if (!--sb->s_count) { 217 if (!--sb->s_count) {
216 list_del_init(&sb->s_list); 218 list_del_init(&sb->s_list);
@@ -225,7 +227,7 @@ void __put_super(struct super_block *sb)
225 * Drops a temporary reference, frees superblock if there's no 227 * Drops a temporary reference, frees superblock if there's no
226 * references left. 228 * references left.
227 */ 229 */
228void put_super(struct super_block *sb) 230static void put_super(struct super_block *sb)
229{ 231{
230 spin_lock(&sb_lock); 232 spin_lock(&sb_lock);
231 __put_super(sb); 233 __put_super(sb);
@@ -328,7 +330,7 @@ static int grab_super(struct super_block *s) __releases(sb_lock)
328bool grab_super_passive(struct super_block *sb) 330bool grab_super_passive(struct super_block *sb)
329{ 331{
330 spin_lock(&sb_lock); 332 spin_lock(&sb_lock);
331 if (list_empty(&sb->s_instances)) { 333 if (hlist_unhashed(&sb->s_instances)) {
332 spin_unlock(&sb_lock); 334 spin_unlock(&sb_lock);
333 return false; 335 return false;
334 } 336 }
@@ -337,7 +339,7 @@ bool grab_super_passive(struct super_block *sb)
337 spin_unlock(&sb_lock); 339 spin_unlock(&sb_lock);
338 340
339 if (down_read_trylock(&sb->s_umount)) { 341 if (down_read_trylock(&sb->s_umount)) {
340 if (sb->s_root) 342 if (sb->s_root && (sb->s_flags & MS_BORN))
341 return true; 343 return true;
342 up_read(&sb->s_umount); 344 up_read(&sb->s_umount);
343 } 345 }
@@ -400,7 +402,7 @@ void generic_shutdown_super(struct super_block *sb)
400 } 402 }
401 spin_lock(&sb_lock); 403 spin_lock(&sb_lock);
402 /* should be initialized for __put_super_and_need_restart() */ 404 /* should be initialized for __put_super_and_need_restart() */
403 list_del_init(&sb->s_instances); 405 hlist_del_init(&sb->s_instances);
404 spin_unlock(&sb_lock); 406 spin_unlock(&sb_lock);
405 up_write(&sb->s_umount); 407 up_write(&sb->s_umount);
406} 408}
@@ -420,13 +422,14 @@ struct super_block *sget(struct file_system_type *type,
420 void *data) 422 void *data)
421{ 423{
422 struct super_block *s = NULL; 424 struct super_block *s = NULL;
425 struct hlist_node *node;
423 struct super_block *old; 426 struct super_block *old;
424 int err; 427 int err;
425 428
426retry: 429retry:
427 spin_lock(&sb_lock); 430 spin_lock(&sb_lock);
428 if (test) { 431 if (test) {
429 list_for_each_entry(old, &type->fs_supers, s_instances) { 432 hlist_for_each_entry(old, node, &type->fs_supers, s_instances) {
430 if (!test(old, data)) 433 if (!test(old, data))
431 continue; 434 continue;
432 if (!grab_super(old)) 435 if (!grab_super(old))
@@ -462,7 +465,7 @@ retry:
462 s->s_type = type; 465 s->s_type = type;
463 strlcpy(s->s_id, type->name, sizeof(s->s_id)); 466 strlcpy(s->s_id, type->name, sizeof(s->s_id));
464 list_add_tail(&s->s_list, &super_blocks); 467 list_add_tail(&s->s_list, &super_blocks);
465 list_add(&s->s_instances, &type->fs_supers); 468 hlist_add_head(&s->s_instances, &type->fs_supers);
466 spin_unlock(&sb_lock); 469 spin_unlock(&sb_lock);
467 get_filesystem(type); 470 get_filesystem(type);
468 register_shrinker(&s->s_shrink); 471 register_shrinker(&s->s_shrink);
@@ -497,14 +500,14 @@ void sync_supers(void)
497 500
498 spin_lock(&sb_lock); 501 spin_lock(&sb_lock);
499 list_for_each_entry(sb, &super_blocks, s_list) { 502 list_for_each_entry(sb, &super_blocks, s_list) {
500 if (list_empty(&sb->s_instances)) 503 if (hlist_unhashed(&sb->s_instances))
501 continue; 504 continue;
502 if (sb->s_op->write_super && sb->s_dirt) { 505 if (sb->s_op->write_super && sb->s_dirt) {
503 sb->s_count++; 506 sb->s_count++;
504 spin_unlock(&sb_lock); 507 spin_unlock(&sb_lock);
505 508
506 down_read(&sb->s_umount); 509 down_read(&sb->s_umount);
507 if (sb->s_root && sb->s_dirt) 510 if (sb->s_root && sb->s_dirt && (sb->s_flags & MS_BORN))
508 sb->s_op->write_super(sb); 511 sb->s_op->write_super(sb);
509 up_read(&sb->s_umount); 512 up_read(&sb->s_umount);
510 513
@@ -533,13 +536,13 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg)
533 536
534 spin_lock(&sb_lock); 537 spin_lock(&sb_lock);
535 list_for_each_entry(sb, &super_blocks, s_list) { 538 list_for_each_entry(sb, &super_blocks, s_list) {
536 if (list_empty(&sb->s_instances)) 539 if (hlist_unhashed(&sb->s_instances))
537 continue; 540 continue;
538 sb->s_count++; 541 sb->s_count++;
539 spin_unlock(&sb_lock); 542 spin_unlock(&sb_lock);
540 543
541 down_read(&sb->s_umount); 544 down_read(&sb->s_umount);
542 if (sb->s_root) 545 if (sb->s_root && (sb->s_flags & MS_BORN))
543 f(sb, arg); 546 f(sb, arg);
544 up_read(&sb->s_umount); 547 up_read(&sb->s_umount);
545 548
@@ -566,14 +569,15 @@ void iterate_supers_type(struct file_system_type *type,
566 void (*f)(struct super_block *, void *), void *arg) 569 void (*f)(struct super_block *, void *), void *arg)
567{ 570{
568 struct super_block *sb, *p = NULL; 571 struct super_block *sb, *p = NULL;
572 struct hlist_node *node;
569 573
570 spin_lock(&sb_lock); 574 spin_lock(&sb_lock);
571 list_for_each_entry(sb, &type->fs_supers, s_instances) { 575 hlist_for_each_entry(sb, node, &type->fs_supers, s_instances) {
572 sb->s_count++; 576 sb->s_count++;
573 spin_unlock(&sb_lock); 577 spin_unlock(&sb_lock);
574 578
575 down_read(&sb->s_umount); 579 down_read(&sb->s_umount);
576 if (sb->s_root) 580 if (sb->s_root && (sb->s_flags & MS_BORN))
577 f(sb, arg); 581 f(sb, arg);
578 up_read(&sb->s_umount); 582 up_read(&sb->s_umount);
579 583
@@ -607,14 +611,14 @@ struct super_block *get_super(struct block_device *bdev)
607 spin_lock(&sb_lock); 611 spin_lock(&sb_lock);
608rescan: 612rescan:
609 list_for_each_entry(sb, &super_blocks, s_list) { 613 list_for_each_entry(sb, &super_blocks, s_list) {
610 if (list_empty(&sb->s_instances)) 614 if (hlist_unhashed(&sb->s_instances))
611 continue; 615 continue;
612 if (sb->s_bdev == bdev) { 616 if (sb->s_bdev == bdev) {
613 sb->s_count++; 617 sb->s_count++;
614 spin_unlock(&sb_lock); 618 spin_unlock(&sb_lock);
615 down_read(&sb->s_umount); 619 down_read(&sb->s_umount);
616 /* still alive? */ 620 /* still alive? */
617 if (sb->s_root) 621 if (sb->s_root && (sb->s_flags & MS_BORN))
618 return sb; 622 return sb;
619 up_read(&sb->s_umount); 623 up_read(&sb->s_umount);
620 /* nope, got unmounted */ 624 /* nope, got unmounted */
@@ -647,7 +651,7 @@ struct super_block *get_active_super(struct block_device *bdev)
647restart: 651restart:
648 spin_lock(&sb_lock); 652 spin_lock(&sb_lock);
649 list_for_each_entry(sb, &super_blocks, s_list) { 653 list_for_each_entry(sb, &super_blocks, s_list) {
650 if (list_empty(&sb->s_instances)) 654 if (hlist_unhashed(&sb->s_instances))
651 continue; 655 continue;
652 if (sb->s_bdev == bdev) { 656 if (sb->s_bdev == bdev) {
653 if (grab_super(sb)) /* drops sb_lock */ 657 if (grab_super(sb)) /* drops sb_lock */
@@ -667,14 +671,14 @@ struct super_block *user_get_super(dev_t dev)
667 spin_lock(&sb_lock); 671 spin_lock(&sb_lock);
668rescan: 672rescan:
669 list_for_each_entry(sb, &super_blocks, s_list) { 673 list_for_each_entry(sb, &super_blocks, s_list) {
670 if (list_empty(&sb->s_instances)) 674 if (hlist_unhashed(&sb->s_instances))
671 continue; 675 continue;
672 if (sb->s_dev == dev) { 676 if (sb->s_dev == dev) {
673 sb->s_count++; 677 sb->s_count++;
674 spin_unlock(&sb_lock); 678 spin_unlock(&sb_lock);
675 down_read(&sb->s_umount); 679 down_read(&sb->s_umount);
676 /* still alive? */ 680 /* still alive? */
677 if (sb->s_root) 681 if (sb->s_root && (sb->s_flags & MS_BORN))
678 return sb; 682 return sb;
679 up_read(&sb->s_umount); 683 up_read(&sb->s_umount);
680 /* nope, got unmounted */ 684 /* nope, got unmounted */
@@ -719,23 +723,29 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
719 /* If we are remounting RDONLY and current sb is read/write, 723 /* If we are remounting RDONLY and current sb is read/write,
720 make sure there are no rw files opened */ 724 make sure there are no rw files opened */
721 if (remount_ro) { 725 if (remount_ro) {
722 if (force) 726 if (force) {
723 mark_files_ro(sb); 727 mark_files_ro(sb);
724 else if (!fs_may_remount_ro(sb)) 728 } else {
725 return -EBUSY; 729 retval = sb_prepare_remount_readonly(sb);
730 if (retval)
731 return retval;
732 }
726 } 733 }
727 734
728 if (sb->s_op->remount_fs) { 735 if (sb->s_op->remount_fs) {
729 retval = sb->s_op->remount_fs(sb, &flags, data); 736 retval = sb->s_op->remount_fs(sb, &flags, data);
730 if (retval) { 737 if (retval) {
731 if (!force) 738 if (!force)
732 return retval; 739 goto cancel_readonly;
733 /* If forced remount, go ahead despite any errors */ 740 /* If forced remount, go ahead despite any errors */
734 WARN(1, "forced remount of a %s fs returned %i\n", 741 WARN(1, "forced remount of a %s fs returned %i\n",
735 sb->s_type->name, retval); 742 sb->s_type->name, retval);
736 } 743 }
737 } 744 }
738 sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); 745 sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK);
746 /* Needs to be ordered wrt mnt_is_readonly() */
747 smp_wmb();
748 sb->s_readonly_remount = 0;
739 749
740 /* 750 /*
741 * Some filesystems modify their metadata via some other path than the 751 * Some filesystems modify their metadata via some other path than the
@@ -748,6 +758,10 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
748 if (remount_ro && sb->s_bdev) 758 if (remount_ro && sb->s_bdev)
749 invalidate_bdev(sb->s_bdev); 759 invalidate_bdev(sb->s_bdev);
750 return 0; 760 return 0;
761
762cancel_readonly:
763 sb->s_readonly_remount = 0;
764 return retval;
751} 765}
752 766
753static void do_emergency_remount(struct work_struct *work) 767static void do_emergency_remount(struct work_struct *work)
@@ -756,12 +770,13 @@ static void do_emergency_remount(struct work_struct *work)
756 770
757 spin_lock(&sb_lock); 771 spin_lock(&sb_lock);
758 list_for_each_entry(sb, &super_blocks, s_list) { 772 list_for_each_entry(sb, &super_blocks, s_list) {
759 if (list_empty(&sb->s_instances)) 773 if (hlist_unhashed(&sb->s_instances))
760 continue; 774 continue;
761 sb->s_count++; 775 sb->s_count++;
762 spin_unlock(&sb_lock); 776 spin_unlock(&sb_lock);
763 down_write(&sb->s_umount); 777 down_write(&sb->s_umount);
764 if (sb->s_root && sb->s_bdev && !(sb->s_flags & MS_RDONLY)) { 778 if (sb->s_root && sb->s_bdev && (sb->s_flags & MS_BORN) &&
779 !(sb->s_flags & MS_RDONLY)) {
765 /* 780 /*
766 * What lock protects sb->s_flags?? 781 * What lock protects sb->s_flags??
767 */ 782 */
@@ -1144,6 +1159,11 @@ int freeze_super(struct super_block *sb)
1144 return -EBUSY; 1159 return -EBUSY;
1145 } 1160 }
1146 1161
1162 if (!(sb->s_flags & MS_BORN)) {
1163 up_write(&sb->s_umount);
1164 return 0; /* sic - it's "nothing to do" */
1165 }
1166
1147 if (sb->s_flags & MS_RDONLY) { 1167 if (sb->s_flags & MS_RDONLY) {
1148 sb->s_frozen = SB_FREEZE_TRANS; 1168 sb->s_frozen = SB_FREEZE_TRANS;
1149 smp_wmb(); 1169 smp_wmb();
diff --git a/fs/sync.c b/fs/sync.c
index 101b8ef901d7..f3501ef39235 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -14,7 +14,6 @@
14#include <linux/linkage.h> 14#include <linux/linkage.h>
15#include <linux/pagemap.h> 15#include <linux/pagemap.h>
16#include <linux/quotaops.h> 16#include <linux/quotaops.h>
17#include <linux/buffer_head.h>
18#include <linux/backing-dev.h> 17#include <linux/backing-dev.h>
19#include "internal.h" 18#include "internal.h"
20 19
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index d4e6080b4b20..62f4fb37789e 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -518,7 +518,7 @@ out:
518} 518}
519 519
520int sysfs_add_file_mode(struct sysfs_dirent *dir_sd, 520int sysfs_add_file_mode(struct sysfs_dirent *dir_sd,
521 const struct attribute *attr, int type, mode_t amode) 521 const struct attribute *attr, int type, umode_t amode)
522{ 522{
523 umode_t mode = (amode & S_IALLUGO) | S_IFREG; 523 umode_t mode = (amode & S_IALLUGO) | S_IFREG;
524 struct sysfs_addrm_cxt acxt; 524 struct sysfs_addrm_cxt acxt;
@@ -618,7 +618,7 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group);
618 * 618 *
619 */ 619 */
620int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr, 620int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr,
621 mode_t mode) 621 umode_t mode)
622{ 622{
623 struct sysfs_dirent *sd; 623 struct sysfs_dirent *sd;
624 struct iattr newattrs; 624 struct iattr newattrs;
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 194414f8298c..dd1701caecc9 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -33,7 +33,7 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
33 int error = 0, i; 33 int error = 0, i;
34 34
35 for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) { 35 for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) {
36 mode_t mode = 0; 36 umode_t mode = 0;
37 37
38 /* in update mode, we're changing the permissions or 38 /* in update mode, we're changing the permissions or
39 * visibility. Do this by first removing then 39 * visibility. Do this by first removing then
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index c81b22f3ace1..4a802b4a9056 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -187,7 +187,7 @@ out:
187 return error; 187 return error;
188} 188}
189 189
190static inline void set_default_inode_attr(struct inode * inode, mode_t mode) 190static inline void set_default_inode_attr(struct inode * inode, umode_t mode)
191{ 191{
192 inode->i_mode = mode; 192 inode->i_mode = mode;
193 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 193 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index ce29e28b766d..7484a36ee678 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -79,7 +79,7 @@ struct sysfs_dirent {
79 }; 79 };
80 80
81 unsigned int s_flags; 81 unsigned int s_flags;
82 unsigned short s_mode; 82 umode_t s_mode;
83 ino_t s_ino; 83 ino_t s_ino;
84 struct sysfs_inode_attrs *s_iattr; 84 struct sysfs_inode_attrs *s_iattr;
85}; 85};
@@ -229,7 +229,7 @@ int sysfs_add_file(struct sysfs_dirent *dir_sd,
229 const struct attribute *attr, int type); 229 const struct attribute *attr, int type);
230 230
231int sysfs_add_file_mode(struct sysfs_dirent *dir_sd, 231int sysfs_add_file_mode(struct sysfs_dirent *dir_sd,
232 const struct attribute *attr, int type, mode_t amode); 232 const struct attribute *attr, int type, umode_t amode);
233/* 233/*
234 * bin.c 234 * bin.c
235 */ 235 */
diff --git a/fs/sysv/ialloc.c b/fs/sysv/ialloc.c
index 0c96c98bd1db..8233b02eccae 100644
--- a/fs/sysv/ialloc.c
+++ b/fs/sysv/ialloc.c
@@ -132,7 +132,7 @@ void sysv_free_inode(struct inode * inode)
132 brelse(bh); 132 brelse(bh);
133} 133}
134 134
135struct inode * sysv_new_inode(const struct inode * dir, mode_t mode) 135struct inode * sysv_new_inode(const struct inode * dir, umode_t mode)
136{ 136{
137 struct super_block *sb = dir->i_sb; 137 struct super_block *sb = dir->i_sb;
138 struct sysv_sb_info *sbi = SYSV_SB(sb); 138 struct sysv_sb_info *sbi = SYSV_SB(sb);
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index 25ffb3e9a3f8..3da5ce25faf0 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -336,7 +336,6 @@ static struct inode *sysv_alloc_inode(struct super_block *sb)
336static void sysv_i_callback(struct rcu_head *head) 336static void sysv_i_callback(struct rcu_head *head)
337{ 337{
338 struct inode *inode = container_of(head, struct inode, i_rcu); 338 struct inode *inode = container_of(head, struct inode, i_rcu);
339 INIT_LIST_HEAD(&inode->i_dentry);
340 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); 339 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode));
341} 340}
342 341
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index fa8d43c92bb8..90b54b438789 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -442,7 +442,7 @@ static unsigned sysv_nblocks(struct super_block *s, loff_t size)
442 442
443int sysv_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) 443int sysv_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
444{ 444{
445 struct super_block *s = mnt->mnt_sb; 445 struct super_block *s = dentry->d_sb;
446 generic_fillattr(dentry->d_inode, stat); 446 generic_fillattr(dentry->d_inode, stat);
447 stat->blocks = (s->s_blocksize / 512) * sysv_nblocks(s, stat->size); 447 stat->blocks = (s->s_blocksize / 512) * sysv_nblocks(s, stat->size);
448 stat->blksize = s->s_blocksize; 448 stat->blksize = s->s_blocksize;
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index e474fbcf8bde..b217797e621b 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -61,7 +61,7 @@ static struct dentry *sysv_lookup(struct inode * dir, struct dentry * dentry, st
61 return NULL; 61 return NULL;
62} 62}
63 63
64static int sysv_mknod(struct inode * dir, struct dentry * dentry, int mode, dev_t rdev) 64static int sysv_mknod(struct inode * dir, struct dentry * dentry, umode_t mode, dev_t rdev)
65{ 65{
66 struct inode * inode; 66 struct inode * inode;
67 int err; 67 int err;
@@ -80,7 +80,7 @@ static int sysv_mknod(struct inode * dir, struct dentry * dentry, int mode, dev_
80 return err; 80 return err;
81} 81}
82 82
83static int sysv_create(struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd) 83static int sysv_create(struct inode * dir, struct dentry * dentry, umode_t mode, struct nameidata *nd)
84{ 84{
85 return sysv_mknod(dir, dentry, mode, 0); 85 return sysv_mknod(dir, dentry, mode, 0);
86} 86}
@@ -131,7 +131,7 @@ static int sysv_link(struct dentry * old_dentry, struct inode * dir,
131 return add_nondir(dentry, inode); 131 return add_nondir(dentry, inode);
132} 132}
133 133
134static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode) 134static int sysv_mkdir(struct inode * dir, struct dentry *dentry, umode_t mode)
135{ 135{
136 struct inode * inode; 136 struct inode * inode;
137 int err = -EMLINK; 137 int err = -EMLINK;
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index bb55cdb394bf..0e4b821c5691 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -125,7 +125,7 @@ static inline void dirty_sb(struct super_block *sb)
125/* ialloc.c */ 125/* ialloc.c */
126extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned, 126extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned,
127 struct buffer_head **); 127 struct buffer_head **);
128extern struct inode * sysv_new_inode(const struct inode *, mode_t); 128extern struct inode * sysv_new_inode(const struct inode *, umode_t);
129extern void sysv_free_inode(struct inode *); 129extern void sysv_free_inode(struct inode *);
130extern unsigned long sysv_count_free_inodes(struct super_block *); 130extern unsigned long sysv_count_free_inodes(struct super_block *);
131 131
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 683492043317..d6fe1c79f18b 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -56,7 +56,7 @@
56 * 56 *
57 * This function returns the inherited flags. 57 * This function returns the inherited flags.
58 */ 58 */
59static int inherit_flags(const struct inode *dir, int mode) 59static int inherit_flags(const struct inode *dir, umode_t mode)
60{ 60{
61 int flags; 61 int flags;
62 const struct ubifs_inode *ui = ubifs_inode(dir); 62 const struct ubifs_inode *ui = ubifs_inode(dir);
@@ -86,7 +86,7 @@ static int inherit_flags(const struct inode *dir, int mode)
86 * case of failure. 86 * case of failure.
87 */ 87 */
88struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, 88struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
89 int mode) 89 umode_t mode)
90{ 90{
91 struct inode *inode; 91 struct inode *inode;
92 struct ubifs_inode *ui; 92 struct ubifs_inode *ui;
@@ -253,7 +253,7 @@ out:
253 return ERR_PTR(err); 253 return ERR_PTR(err);
254} 254}
255 255
256static int ubifs_create(struct inode *dir, struct dentry *dentry, int mode, 256static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
257 struct nameidata *nd) 257 struct nameidata *nd)
258{ 258{
259 struct inode *inode; 259 struct inode *inode;
@@ -268,7 +268,7 @@ static int ubifs_create(struct inode *dir, struct dentry *dentry, int mode,
268 * parent directory inode. 268 * parent directory inode.
269 */ 269 */
270 270
271 dbg_gen("dent '%.*s', mode %#x in dir ino %lu", 271 dbg_gen("dent '%.*s', mode %#hx in dir ino %lu",
272 dentry->d_name.len, dentry->d_name.name, mode, dir->i_ino); 272 dentry->d_name.len, dentry->d_name.name, mode, dir->i_ino);
273 273
274 err = ubifs_budget_space(c, &req); 274 err = ubifs_budget_space(c, &req);
@@ -712,7 +712,7 @@ out_cancel:
712 return err; 712 return err;
713} 713}
714 714
715static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 715static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
716{ 716{
717 struct inode *inode; 717 struct inode *inode;
718 struct ubifs_inode *dir_ui = ubifs_inode(dir); 718 struct ubifs_inode *dir_ui = ubifs_inode(dir);
@@ -725,7 +725,7 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
725 * directory inode. 725 * directory inode.
726 */ 726 */
727 727
728 dbg_gen("dent '%.*s', mode %#x in dir ino %lu", 728 dbg_gen("dent '%.*s', mode %#hx in dir ino %lu",
729 dentry->d_name.len, dentry->d_name.name, mode, dir->i_ino); 729 dentry->d_name.len, dentry->d_name.name, mode, dir->i_ino);
730 730
731 err = ubifs_budget_space(c, &req); 731 err = ubifs_budget_space(c, &req);
@@ -769,7 +769,7 @@ out_budg:
769} 769}
770 770
771static int ubifs_mknod(struct inode *dir, struct dentry *dentry, 771static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
772 int mode, dev_t rdev) 772 umode_t mode, dev_t rdev)
773{ 773{
774 struct inode *inode; 774 struct inode *inode;
775 struct ubifs_inode *ui; 775 struct ubifs_inode *ui;
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 548acf494afd..1a7e2d8bdbe9 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -173,12 +173,12 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
173 * Make sure the file-system is read-write and make sure it 173 * Make sure the file-system is read-write and make sure it
174 * will not become read-only while we are changing the flags. 174 * will not become read-only while we are changing the flags.
175 */ 175 */
176 err = mnt_want_write(file->f_path.mnt); 176 err = mnt_want_write_file(file);
177 if (err) 177 if (err)
178 return err; 178 return err;
179 dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags); 179 dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags);
180 err = setflags(inode, flags); 180 err = setflags(inode, flags);
181 mnt_drop_write(file->f_path.mnt); 181 mnt_drop_write_file(file);
182 return err; 182 return err;
183 } 183 }
184 184
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index ae0e76bb6ebf..63765d58445b 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -276,7 +276,6 @@ static void ubifs_i_callback(struct rcu_head *head)
276{ 276{
277 struct inode *inode = container_of(head, struct inode, i_rcu); 277 struct inode *inode = container_of(head, struct inode, i_rcu);
278 struct ubifs_inode *ui = ubifs_inode(inode); 278 struct ubifs_inode *ui = ubifs_inode(inode);
279 INIT_LIST_HEAD(&inode->i_dentry);
280 kmem_cache_free(ubifs_inode_slab, ui); 279 kmem_cache_free(ubifs_inode_slab, ui);
281} 280}
282 281
@@ -420,9 +419,9 @@ static int ubifs_statfs(struct dentry *dentry, struct kstatfs *buf)
420 return 0; 419 return 0;
421} 420}
422 421
423static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt) 422static int ubifs_show_options(struct seq_file *s, struct dentry *root)
424{ 423{
425 struct ubifs_info *c = mnt->mnt_sb->s_fs_info; 424 struct ubifs_info *c = root->d_sb->s_fs_info;
426 425
427 if (c->mount_opts.unmount_mode == 2) 426 if (c->mount_opts.unmount_mode == 2)
428 seq_printf(s, ",fast_unmount"); 427 seq_printf(s, ",fast_unmount");
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 27f22551f805..12e94774aa88 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1734,7 +1734,7 @@ int ubifs_setattr(struct dentry *dentry, struct iattr *attr);
1734 1734
1735/* dir.c */ 1735/* dir.c */
1736struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, 1736struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
1737 int mode); 1737 umode_t mode);
1738int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry, 1738int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1739 struct kstat *stat); 1739 struct kstat *stat);
1740 1740
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 6fb7e0adcda0..05ab48195be9 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -46,7 +46,7 @@ void udf_free_inode(struct inode *inode)
46 udf_free_blocks(sb, NULL, &UDF_I(inode)->i_location, 0, 1); 46 udf_free_blocks(sb, NULL, &UDF_I(inode)->i_location, 0, 1);
47} 47}
48 48
49struct inode *udf_new_inode(struct inode *dir, int mode, int *err) 49struct inode *udf_new_inode(struct inode *dir, umode_t mode, int *err)
50{ 50{
51 struct super_block *sb = dir->i_sb; 51 struct super_block *sb = dir->i_sb;
52 struct udf_sb_info *sbi = UDF_SB(sb); 52 struct udf_sb_info *sbi = UDF_SB(sb);
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 4fd1d809738c..4598904be1bb 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -48,7 +48,7 @@ MODULE_LICENSE("GPL");
48 48
49#define EXTENT_MERGE_SIZE 5 49#define EXTENT_MERGE_SIZE 5
50 50
51static mode_t udf_convert_permissions(struct fileEntry *); 51static umode_t udf_convert_permissions(struct fileEntry *);
52static int udf_update_inode(struct inode *, int); 52static int udf_update_inode(struct inode *, int);
53static void udf_fill_inode(struct inode *, struct buffer_head *); 53static void udf_fill_inode(struct inode *, struct buffer_head *);
54static int udf_sync_inode(struct inode *inode); 54static int udf_sync_inode(struct inode *inode);
@@ -1452,9 +1452,9 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
1452 return 0; 1452 return 0;
1453} 1453}
1454 1454
1455static mode_t udf_convert_permissions(struct fileEntry *fe) 1455static umode_t udf_convert_permissions(struct fileEntry *fe)
1456{ 1456{
1457 mode_t mode; 1457 umode_t mode;
1458 uint32_t permissions; 1458 uint32_t permissions;
1459 uint32_t flags; 1459 uint32_t flags;
1460 1460
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 4639e137222f..08bf46edf9c4 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -552,7 +552,7 @@ static int udf_delete_entry(struct inode *inode, struct fileIdentDesc *fi,
552 return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL); 552 return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL);
553} 553}
554 554
555static int udf_create(struct inode *dir, struct dentry *dentry, int mode, 555static int udf_create(struct inode *dir, struct dentry *dentry, umode_t mode,
556 struct nameidata *nd) 556 struct nameidata *nd)
557{ 557{
558 struct udf_fileident_bh fibh; 558 struct udf_fileident_bh fibh;
@@ -596,7 +596,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
596 return 0; 596 return 0;
597} 597}
598 598
599static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, 599static int udf_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
600 dev_t rdev) 600 dev_t rdev)
601{ 601{
602 struct inode *inode; 602 struct inode *inode;
@@ -640,7 +640,7 @@ out:
640 return err; 640 return err;
641} 641}
642 642
643static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) 643static int udf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
644{ 644{
645 struct inode *inode; 645 struct inode *inode;
646 struct udf_fileident_bh fibh; 646 struct udf_fileident_bh fibh;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index e185253470df..0c33225647a0 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -89,7 +89,7 @@ static void udf_open_lvid(struct super_block *);
89static void udf_close_lvid(struct super_block *); 89static void udf_close_lvid(struct super_block *);
90static unsigned int udf_count_free(struct super_block *); 90static unsigned int udf_count_free(struct super_block *);
91static int udf_statfs(struct dentry *, struct kstatfs *); 91static int udf_statfs(struct dentry *, struct kstatfs *);
92static int udf_show_options(struct seq_file *, struct vfsmount *); 92static int udf_show_options(struct seq_file *, struct dentry *);
93 93
94struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi) 94struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi)
95{ 95{
@@ -138,7 +138,6 @@ static struct inode *udf_alloc_inode(struct super_block *sb)
138static void udf_i_callback(struct rcu_head *head) 138static void udf_i_callback(struct rcu_head *head)
139{ 139{
140 struct inode *inode = container_of(head, struct inode, i_rcu); 140 struct inode *inode = container_of(head, struct inode, i_rcu);
141 INIT_LIST_HEAD(&inode->i_dentry);
142 kmem_cache_free(udf_inode_cachep, UDF_I(inode)); 141 kmem_cache_free(udf_inode_cachep, UDF_I(inode));
143} 142}
144 143
@@ -196,11 +195,11 @@ struct udf_options {
196 unsigned int fileset; 195 unsigned int fileset;
197 unsigned int rootdir; 196 unsigned int rootdir;
198 unsigned int flags; 197 unsigned int flags;
199 mode_t umask; 198 umode_t umask;
200 gid_t gid; 199 gid_t gid;
201 uid_t uid; 200 uid_t uid;
202 mode_t fmode; 201 umode_t fmode;
203 mode_t dmode; 202 umode_t dmode;
204 struct nls_table *nls_map; 203 struct nls_table *nls_map;
205}; 204};
206 205
@@ -250,9 +249,9 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
250 return 0; 249 return 0;
251} 250}
252 251
253static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt) 252static int udf_show_options(struct seq_file *seq, struct dentry *root)
254{ 253{
255 struct super_block *sb = mnt->mnt_sb; 254 struct super_block *sb = root->d_sb;
256 struct udf_sb_info *sbi = UDF_SB(sb); 255 struct udf_sb_info *sbi = UDF_SB(sb);
257 256
258 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT)) 257 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT))
@@ -280,11 +279,11 @@ static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt)
280 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET)) 279 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
281 seq_printf(seq, ",gid=%u", sbi->s_gid); 280 seq_printf(seq, ",gid=%u", sbi->s_gid);
282 if (sbi->s_umask != 0) 281 if (sbi->s_umask != 0)
283 seq_printf(seq, ",umask=%o", sbi->s_umask); 282 seq_printf(seq, ",umask=%ho", sbi->s_umask);
284 if (sbi->s_fmode != UDF_INVALID_MODE) 283 if (sbi->s_fmode != UDF_INVALID_MODE)
285 seq_printf(seq, ",mode=%o", sbi->s_fmode); 284 seq_printf(seq, ",mode=%ho", sbi->s_fmode);
286 if (sbi->s_dmode != UDF_INVALID_MODE) 285 if (sbi->s_dmode != UDF_INVALID_MODE)
287 seq_printf(seq, ",dmode=%o", sbi->s_dmode); 286 seq_printf(seq, ",dmode=%ho", sbi->s_dmode);
288 if (UDF_QUERY_FLAG(sb, UDF_FLAG_SESSION_SET)) 287 if (UDF_QUERY_FLAG(sb, UDF_FLAG_SESSION_SET))
289 seq_printf(seq, ",session=%u", sbi->s_session); 288 seq_printf(seq, ",session=%u", sbi->s_session);
290 if (UDF_QUERY_FLAG(sb, UDF_FLAG_LASTBLOCK_SET)) 289 if (UDF_QUERY_FLAG(sb, UDF_FLAG_LASTBLOCK_SET))
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 5142a82e3276..42ad69ac9576 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -50,7 +50,7 @@
50#define UDF_SPARABLE_MAP15 0x1522U 50#define UDF_SPARABLE_MAP15 0x1522U
51#define UDF_METADATA_MAP25 0x2511U 51#define UDF_METADATA_MAP25 0x2511U
52 52
53#define UDF_INVALID_MODE ((mode_t)-1) 53#define UDF_INVALID_MODE ((umode_t)-1)
54 54
55#pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */ 55#pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */
56 56
@@ -127,11 +127,11 @@ struct udf_sb_info {
127 struct buffer_head *s_lvid_bh; 127 struct buffer_head *s_lvid_bh;
128 128
129 /* Default permissions */ 129 /* Default permissions */
130 mode_t s_umask; 130 umode_t s_umask;
131 gid_t s_gid; 131 gid_t s_gid;
132 uid_t s_uid; 132 uid_t s_uid;
133 mode_t s_fmode; 133 umode_t s_fmode;
134 mode_t s_dmode; 134 umode_t s_dmode;
135 /* Lock protecting consistency of above permission settings */ 135 /* Lock protecting consistency of above permission settings */
136 rwlock_t s_cred_lock; 136 rwlock_t s_cred_lock;
137 137
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index f34e6fc0cdaa..ebe10314e512 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -215,7 +215,7 @@ extern int udf_CS0toUTF8(struct ustr *, const struct ustr *);
215 215
216/* ialloc.c */ 216/* ialloc.c */
217extern void udf_free_inode(struct inode *); 217extern void udf_free_inode(struct inode *);
218extern struct inode *udf_new_inode(struct inode *, int, int *); 218extern struct inode *udf_new_inode(struct inode *, umode_t, int *);
219 219
220/* truncate.c */ 220/* truncate.c */
221extern void udf_truncate_tail_extent(struct inode *); 221extern void udf_truncate_tail_extent(struct inode *);
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index 78a4c70d46b5..4ec5c1085a87 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -170,7 +170,7 @@ static void ufs2_init_inodes_chunk(struct super_block *sb,
170 * For other inodes, search forward from the parent directory's block 170 * For other inodes, search forward from the parent directory's block
171 * group to find a free inode. 171 * group to find a free inode.
172 */ 172 */
173struct inode * ufs_new_inode(struct inode * dir, int mode) 173struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
174{ 174{
175 struct super_block * sb; 175 struct super_block * sb;
176 struct ufs_sb_info * sbi; 176 struct ufs_sb_info * sbi;
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 879b13436fa4..9094e1d917be 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -583,7 +583,7 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
583{ 583{
584 struct ufs_inode_info *ufsi = UFS_I(inode); 584 struct ufs_inode_info *ufsi = UFS_I(inode);
585 struct super_block *sb = inode->i_sb; 585 struct super_block *sb = inode->i_sb;
586 mode_t mode; 586 umode_t mode;
587 587
588 /* 588 /*
589 * Copy data to the in-core inode. 589 * Copy data to the in-core inode.
@@ -630,7 +630,7 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
630{ 630{
631 struct ufs_inode_info *ufsi = UFS_I(inode); 631 struct ufs_inode_info *ufsi = UFS_I(inode);
632 struct super_block *sb = inode->i_sb; 632 struct super_block *sb = inode->i_sb;
633 mode_t mode; 633 umode_t mode;
634 634
635 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); 635 UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino);
636 /* 636 /*
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 639d49162241..38cac199edff 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -70,7 +70,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
70 * If the create succeeds, we fill in the inode information 70 * If the create succeeds, we fill in the inode information
71 * with d_instantiate(). 71 * with d_instantiate().
72 */ 72 */
73static int ufs_create (struct inode * dir, struct dentry * dentry, int mode, 73static int ufs_create (struct inode * dir, struct dentry * dentry, umode_t mode,
74 struct nameidata *nd) 74 struct nameidata *nd)
75{ 75{
76 struct inode *inode; 76 struct inode *inode;
@@ -94,7 +94,7 @@ static int ufs_create (struct inode * dir, struct dentry * dentry, int mode,
94 return err; 94 return err;
95} 95}
96 96
97static int ufs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev) 97static int ufs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev)
98{ 98{
99 struct inode *inode; 99 struct inode *inode;
100 int err; 100 int err;
@@ -180,7 +180,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
180 return error; 180 return error;
181} 181}
182 182
183static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode) 183static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
184{ 184{
185 struct inode * inode; 185 struct inode * inode;
186 int err = -EMLINK; 186 int err = -EMLINK;
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 3915ade6f9a8..5246ee3e5607 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -1351,9 +1351,9 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1351 return 0; 1351 return 0;
1352} 1352}
1353 1353
1354static int ufs_show_options(struct seq_file *seq, struct vfsmount *vfs) 1354static int ufs_show_options(struct seq_file *seq, struct dentry *root)
1355{ 1355{
1356 struct ufs_sb_info *sbi = UFS_SB(vfs->mnt_sb); 1356 struct ufs_sb_info *sbi = UFS_SB(root->d_sb);
1357 unsigned mval = sbi->s_mount_opt & UFS_MOUNT_UFSTYPE; 1357 unsigned mval = sbi->s_mount_opt & UFS_MOUNT_UFSTYPE;
1358 const struct match_token *tp = tokens; 1358 const struct match_token *tp = tokens;
1359 1359
@@ -1425,7 +1425,6 @@ static struct inode *ufs_alloc_inode(struct super_block *sb)
1425static void ufs_i_callback(struct rcu_head *head) 1425static void ufs_i_callback(struct rcu_head *head)
1426{ 1426{
1427 struct inode *inode = container_of(head, struct inode, i_rcu); 1427 struct inode *inode = container_of(head, struct inode, i_rcu);
1428 INIT_LIST_HEAD(&inode->i_dentry);
1429 kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); 1428 kmem_cache_free(ufs_inode_cachep, UFS_I(inode));
1430} 1429}
1431 1430
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index c26f2bcec264..528750b7e701 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -104,7 +104,7 @@ extern const struct address_space_operations ufs_aops;
104 104
105/* ialloc.c */ 105/* ialloc.c */
106extern void ufs_free_inode (struct inode *inode); 106extern void ufs_free_inode (struct inode *inode);
107extern struct inode * ufs_new_inode (struct inode *, int); 107extern struct inode * ufs_new_inode (struct inode *, umode_t);
108 108
109/* inode.c */ 109/* inode.c */
110extern struct inode *ufs_iget(struct super_block *, unsigned long); 110extern struct inode *ufs_iget(struct super_block *, unsigned long);
diff --git a/fs/xattr.c b/fs/xattr.c
index 67583de8218c..82f43376c7cd 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -397,7 +397,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
397 error = mnt_want_write_file(f); 397 error = mnt_want_write_file(f);
398 if (!error) { 398 if (!error) {
399 error = setxattr(dentry, name, value, size, flags); 399 error = setxattr(dentry, name, value, size, flags);
400 mnt_drop_write(f->f_path.mnt); 400 mnt_drop_write_file(f);
401 } 401 }
402 fput(f); 402 fput(f);
403 return error; 403 return error;
@@ -624,7 +624,7 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
624 error = mnt_want_write_file(f); 624 error = mnt_want_write_file(f);
625 if (!error) { 625 if (!error) {
626 error = removexattr(dentry, name); 626 error = removexattr(dentry, name);
627 mnt_drop_write(f->f_path.mnt); 627 mnt_drop_write_file(f);
628 } 628 }
629 fput(f); 629 fput(f);
630 return error; 630 return error;
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 169380e66057..dad1a31aa4fc 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -447,7 +447,7 @@ STATIC xfs_buf_t * /* allocation group buffer */
447xfs_ialloc_ag_select( 447xfs_ialloc_ag_select(
448 xfs_trans_t *tp, /* transaction pointer */ 448 xfs_trans_t *tp, /* transaction pointer */
449 xfs_ino_t parent, /* parent directory inode number */ 449 xfs_ino_t parent, /* parent directory inode number */
450 mode_t mode, /* bits set to indicate file type */ 450 umode_t mode, /* bits set to indicate file type */
451 int okalloc) /* ok to allocate more space */ 451 int okalloc) /* ok to allocate more space */
452{ 452{
453 xfs_buf_t *agbp; /* allocation group header buffer */ 453 xfs_buf_t *agbp; /* allocation group header buffer */
@@ -640,7 +640,7 @@ int
640xfs_dialloc( 640xfs_dialloc(
641 xfs_trans_t *tp, /* transaction pointer */ 641 xfs_trans_t *tp, /* transaction pointer */
642 xfs_ino_t parent, /* parent inode (directory) */ 642 xfs_ino_t parent, /* parent inode (directory) */
643 mode_t mode, /* mode bits for new inode */ 643 umode_t mode, /* mode bits for new inode */
644 int okalloc, /* ok to allocate more space */ 644 int okalloc, /* ok to allocate more space */
645 xfs_buf_t **IO_agbp, /* in/out ag header's buffer */ 645 xfs_buf_t **IO_agbp, /* in/out ag header's buffer */
646 boolean_t *alloc_done, /* true if we needed to replenish 646 boolean_t *alloc_done, /* true if we needed to replenish
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index bb5385475e1f..666a037398d6 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -81,7 +81,7 @@ int /* error */
81xfs_dialloc( 81xfs_dialloc(
82 struct xfs_trans *tp, /* transaction pointer */ 82 struct xfs_trans *tp, /* transaction pointer */
83 xfs_ino_t parent, /* parent inode (directory) */ 83 xfs_ino_t parent, /* parent inode (directory) */
84 mode_t mode, /* mode bits for new inode */ 84 umode_t mode, /* mode bits for new inode */
85 int okalloc, /* ok to allocate more space */ 85 int okalloc, /* ok to allocate more space */
86 struct xfs_buf **agbp, /* buf for a.g. inode header */ 86 struct xfs_buf **agbp, /* buf for a.g. inode header */
87 boolean_t *alloc_done, /* an allocation was done to replenish 87 boolean_t *alloc_done, /* an allocation was done to replenish
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 0fa98b1c70ea..3960a066d7ff 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -107,7 +107,6 @@ xfs_inode_free_callback(
107 struct inode *inode = container_of(head, struct inode, i_rcu); 107 struct inode *inode = container_of(head, struct inode, i_rcu);
108 struct xfs_inode *ip = XFS_I(inode); 108 struct xfs_inode *ip = XFS_I(inode);
109 109
110 INIT_LIST_HEAD(&inode->i_dentry);
111 kmem_zone_free(xfs_inode_zone, ip); 110 kmem_zone_free(xfs_inode_zone, ip);
112} 111}
113 112
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 755ee8164880..9dda7cc32848 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -961,7 +961,7 @@ int
961xfs_ialloc( 961xfs_ialloc(
962 xfs_trans_t *tp, 962 xfs_trans_t *tp,
963 xfs_inode_t *pip, 963 xfs_inode_t *pip,
964 mode_t mode, 964 umode_t mode,
965 xfs_nlink_t nlink, 965 xfs_nlink_t nlink,
966 xfs_dev_t rdev, 966 xfs_dev_t rdev,
967 prid_t prid, 967 prid_t prid,
@@ -1002,7 +1002,7 @@ xfs_ialloc(
1002 return error; 1002 return error;
1003 ASSERT(ip != NULL); 1003 ASSERT(ip != NULL);
1004 1004
1005 ip->i_d.di_mode = (__uint16_t)mode; 1005 ip->i_d.di_mode = mode;
1006 ip->i_d.di_onlink = 0; 1006 ip->i_d.di_onlink = 0;
1007 ip->i_d.di_nlink = nlink; 1007 ip->i_d.di_nlink = nlink;
1008 ASSERT(ip->i_d.di_nlink == nlink); 1008 ASSERT(ip->i_d.di_nlink == nlink);
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index b4cd4739f98e..f0e6b151ba37 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -481,7 +481,7 @@ void xfs_inode_free(struct xfs_inode *ip);
481/* 481/*
482 * xfs_inode.c prototypes. 482 * xfs_inode.c prototypes.
483 */ 483 */
484int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, 484int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, umode_t,
485 xfs_nlink_t, xfs_dev_t, prid_t, int, 485 xfs_nlink_t, xfs_dev_t, prid_t, int,
486 struct xfs_buf **, boolean_t *, xfs_inode_t **); 486 struct xfs_buf **, boolean_t *, xfs_inode_t **);
487 487
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index d99a90518909..76f3ca5cfc36 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -559,23 +559,23 @@ xfs_attrmulti_by_handle(
559 ops[i].am_flags); 559 ops[i].am_flags);
560 break; 560 break;
561 case ATTR_OP_SET: 561 case ATTR_OP_SET:
562 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); 562 ops[i].am_error = mnt_want_write_file(parfilp);
563 if (ops[i].am_error) 563 if (ops[i].am_error)
564 break; 564 break;
565 ops[i].am_error = xfs_attrmulti_attr_set( 565 ops[i].am_error = xfs_attrmulti_attr_set(
566 dentry->d_inode, attr_name, 566 dentry->d_inode, attr_name,
567 ops[i].am_attrvalue, ops[i].am_length, 567 ops[i].am_attrvalue, ops[i].am_length,
568 ops[i].am_flags); 568 ops[i].am_flags);
569 mnt_drop_write(parfilp->f_path.mnt); 569 mnt_drop_write_file(parfilp);
570 break; 570 break;
571 case ATTR_OP_REMOVE: 571 case ATTR_OP_REMOVE:
572 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); 572 ops[i].am_error = mnt_want_write_file(parfilp);
573 if (ops[i].am_error) 573 if (ops[i].am_error)
574 break; 574 break;
575 ops[i].am_error = xfs_attrmulti_attr_remove( 575 ops[i].am_error = xfs_attrmulti_attr_remove(
576 dentry->d_inode, attr_name, 576 dentry->d_inode, attr_name,
577 ops[i].am_flags); 577 ops[i].am_flags);
578 mnt_drop_write(parfilp->f_path.mnt); 578 mnt_drop_write_file(parfilp);
579 break; 579 break;
580 default: 580 default:
581 ops[i].am_error = EINVAL; 581 ops[i].am_error = EINVAL;
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index 54e623bfbb85..f9ccb7b7c043 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -454,23 +454,23 @@ xfs_compat_attrmulti_by_handle(
454 &ops[i].am_length, ops[i].am_flags); 454 &ops[i].am_length, ops[i].am_flags);
455 break; 455 break;
456 case ATTR_OP_SET: 456 case ATTR_OP_SET:
457 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); 457 ops[i].am_error = mnt_want_write_file(parfilp);
458 if (ops[i].am_error) 458 if (ops[i].am_error)
459 break; 459 break;
460 ops[i].am_error = xfs_attrmulti_attr_set( 460 ops[i].am_error = xfs_attrmulti_attr_set(
461 dentry->d_inode, attr_name, 461 dentry->d_inode, attr_name,
462 compat_ptr(ops[i].am_attrvalue), 462 compat_ptr(ops[i].am_attrvalue),
463 ops[i].am_length, ops[i].am_flags); 463 ops[i].am_length, ops[i].am_flags);
464 mnt_drop_write(parfilp->f_path.mnt); 464 mnt_drop_write_file(parfilp);
465 break; 465 break;
466 case ATTR_OP_REMOVE: 466 case ATTR_OP_REMOVE:
467 ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); 467 ops[i].am_error = mnt_want_write_file(parfilp);
468 if (ops[i].am_error) 468 if (ops[i].am_error)
469 break; 469 break;
470 ops[i].am_error = xfs_attrmulti_attr_remove( 470 ops[i].am_error = xfs_attrmulti_attr_remove(
471 dentry->d_inode, attr_name, 471 dentry->d_inode, attr_name,
472 ops[i].am_flags); 472 ops[i].am_flags);
473 mnt_drop_write(parfilp->f_path.mnt); 473 mnt_drop_write_file(parfilp);
474 break; 474 break;
475 default: 475 default:
476 ops[i].am_error = EINVAL; 476 ops[i].am_error = EINVAL;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 23ce927973a4..f9babd179223 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -168,7 +168,7 @@ STATIC int
168xfs_vn_mknod( 168xfs_vn_mknod(
169 struct inode *dir, 169 struct inode *dir,
170 struct dentry *dentry, 170 struct dentry *dentry,
171 int mode, 171 umode_t mode,
172 dev_t rdev) 172 dev_t rdev)
173{ 173{
174 struct inode *inode; 174 struct inode *inode;
@@ -231,7 +231,7 @@ STATIC int
231xfs_vn_create( 231xfs_vn_create(
232 struct inode *dir, 232 struct inode *dir,
233 struct dentry *dentry, 233 struct dentry *dentry,
234 int mode, 234 umode_t mode,
235 struct nameidata *nd) 235 struct nameidata *nd)
236{ 236{
237 return xfs_vn_mknod(dir, dentry, mode, 0); 237 return xfs_vn_mknod(dir, dentry, mode, 0);
@@ -241,7 +241,7 @@ STATIC int
241xfs_vn_mkdir( 241xfs_vn_mkdir(
242 struct inode *dir, 242 struct inode *dir,
243 struct dentry *dentry, 243 struct dentry *dentry,
244 int mode) 244 umode_t mode)
245{ 245{
246 return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0); 246 return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0);
247} 247}
@@ -366,7 +366,7 @@ xfs_vn_symlink(
366 struct xfs_inode *cip = NULL; 366 struct xfs_inode *cip = NULL;
367 struct xfs_name name; 367 struct xfs_name name;
368 int error; 368 int error;
369 mode_t mode; 369 umode_t mode;
370 370
371 mode = S_IFLNK | 371 mode = S_IFLNK |
372 (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO); 372 (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO);
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 8a899496fd5f..7b7669507ee3 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1238,9 +1238,9 @@ xfs_fs_unfreeze(
1238STATIC int 1238STATIC int
1239xfs_fs_show_options( 1239xfs_fs_show_options(
1240 struct seq_file *m, 1240 struct seq_file *m,
1241 struct vfsmount *mnt) 1241 struct dentry *root)
1242{ 1242{
1243 return -xfs_showargs(XFS_M(mnt->mnt_sb), m); 1243 return -xfs_showargs(XFS_M(root->d_sb), m);
1244} 1244}
1245 1245
1246/* 1246/*
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
index 8b32d1a4c5a1..89dbb4a50872 100644
--- a/fs/xfs/xfs_utils.c
+++ b/fs/xfs/xfs_utils.c
@@ -53,7 +53,7 @@ xfs_dir_ialloc(
53 output: may be a new transaction. */ 53 output: may be a new transaction. */
54 xfs_inode_t *dp, /* directory within whose allocate 54 xfs_inode_t *dp, /* directory within whose allocate
55 the inode. */ 55 the inode. */
56 mode_t mode, 56 umode_t mode,
57 xfs_nlink_t nlink, 57 xfs_nlink_t nlink,
58 xfs_dev_t rdev, 58 xfs_dev_t rdev,
59 prid_t prid, /* project id */ 59 prid_t prid, /* project id */
diff --git a/fs/xfs/xfs_utils.h b/fs/xfs/xfs_utils.h
index 456fca314933..5eeab4690cfe 100644
--- a/fs/xfs/xfs_utils.h
+++ b/fs/xfs/xfs_utils.h
@@ -18,7 +18,7 @@
18#ifndef __XFS_UTILS_H__ 18#ifndef __XFS_UTILS_H__
19#define __XFS_UTILS_H__ 19#define __XFS_UTILS_H__
20 20
21extern int xfs_dir_ialloc(xfs_trans_t **, xfs_inode_t *, mode_t, xfs_nlink_t, 21extern int xfs_dir_ialloc(xfs_trans_t **, xfs_inode_t *, umode_t, xfs_nlink_t,
22 xfs_dev_t, prid_t, int, xfs_inode_t **, int *); 22 xfs_dev_t, prid_t, int, xfs_inode_t **, int *);
23extern int xfs_droplink(xfs_trans_t *, xfs_inode_t *); 23extern int xfs_droplink(xfs_trans_t *, xfs_inode_t *);
24extern int xfs_bumplink(xfs_trans_t *, xfs_inode_t *); 24extern int xfs_bumplink(xfs_trans_t *, xfs_inode_t *);
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index ce9268a2f56b..f2fea868d4db 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -822,7 +822,7 @@ int
822xfs_create( 822xfs_create(
823 xfs_inode_t *dp, 823 xfs_inode_t *dp,
824 struct xfs_name *name, 824 struct xfs_name *name,
825 mode_t mode, 825 umode_t mode,
826 xfs_dev_t rdev, 826 xfs_dev_t rdev,
827 xfs_inode_t **ipp) 827 xfs_inode_t **ipp)
828{ 828{
@@ -1481,7 +1481,7 @@ xfs_symlink(
1481 xfs_inode_t *dp, 1481 xfs_inode_t *dp,
1482 struct xfs_name *link_name, 1482 struct xfs_name *link_name,
1483 const char *target_path, 1483 const char *target_path,
1484 mode_t mode, 1484 umode_t mode,
1485 xfs_inode_t **ipp) 1485 xfs_inode_t **ipp)
1486{ 1486{
1487 xfs_mount_t *mp = dp->i_mount; 1487 xfs_mount_t *mp = dp->i_mount;
diff --git a/fs/xfs/xfs_vnodeops.h b/fs/xfs/xfs_vnodeops.h
index 35d3d513e1e9..0c877cbde142 100644
--- a/fs/xfs/xfs_vnodeops.h
+++ b/fs/xfs/xfs_vnodeops.h
@@ -26,7 +26,7 @@ int xfs_release(struct xfs_inode *ip);
26int xfs_inactive(struct xfs_inode *ip); 26int xfs_inactive(struct xfs_inode *ip);
27int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name, 27int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name,
28 struct xfs_inode **ipp, struct xfs_name *ci_name); 28 struct xfs_inode **ipp, struct xfs_name *ci_name);
29int xfs_create(struct xfs_inode *dp, struct xfs_name *name, mode_t mode, 29int xfs_create(struct xfs_inode *dp, struct xfs_name *name, umode_t mode,
30 xfs_dev_t rdev, struct xfs_inode **ipp); 30 xfs_dev_t rdev, struct xfs_inode **ipp);
31int xfs_remove(struct xfs_inode *dp, struct xfs_name *name, 31int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
32 struct xfs_inode *ip); 32 struct xfs_inode *ip);
@@ -35,7 +35,7 @@ int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip,
35int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, 35int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize,
36 xfs_off_t *offset, filldir_t filldir); 36 xfs_off_t *offset, filldir_t filldir);
37int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name, 37int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name,
38 const char *target_path, mode_t mode, struct xfs_inode **ipp); 38 const char *target_path, umode_t mode, struct xfs_inode **ipp);
39int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state); 39int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state);
40int xfs_change_file_space(struct xfs_inode *ip, int cmd, 40int xfs_change_file_space(struct xfs_inode *ip, int cmd,
41 xfs_flock64_t *bf, xfs_off_t offset, int attr_flags); 41 xfs_flock64_t *bf, xfs_off_t offset, int attr_flags);