From 5ede7b1cfa8201418fb35e12f770e9e7c2559a4d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 23 Oct 2011 18:49:54 -0400 Subject: [PATCH 001/165] pull manipulations of rpc_cred inside alloc_nfs_open_context() No need to duplicate them in both callers; make it return ERR_PTR(-ENOMEM) on allocation failure instead of NULL and it'll be able to report rpc_lookup_cred() failures just fine. Callers are much happier that way... Signed-off-by: Al Viro --- fs/nfs/dir.c | 13 +------------ fs/nfs/inode.c | 40 ++++++++++++++++++++-------------------- include/linux/nfs_fs.h | 2 +- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index ac2899098147..23be134b3193 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1368,18 +1368,7 @@ static fmode_t flags_to_mode(int flags) static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags) { - struct nfs_open_context *ctx; - struct rpc_cred *cred; - fmode_t fmode = flags_to_mode(open_flags); - - cred = rpc_lookup_cred(); - if (IS_ERR(cred)) - return ERR_CAST(cred); - ctx = alloc_nfs_open_context(dentry, cred, fmode); - put_rpccred(cred); - if (ctx == NULL) - return ERR_PTR(-ENOMEM); - return ctx; + return alloc_nfs_open_context(dentry, flags_to_mode(open_flags)); } static int do_open(struct inode *inode, struct file *filp) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 50a15fa8cf98..efb66db04f99 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) nfs_revalidate_inode(server, inode); } -struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode) +struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode) { struct nfs_open_context *ctx; + struct rpc_cred *cred = rpc_lookup_cred(); + if (IS_ERR(cred)) + return ERR_CAST(cred); ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); - if (ctx != NULL) { - nfs_sb_active(dentry->d_sb); - ctx->dentry = dget(dentry); - ctx->cred = get_rpccred(cred); - ctx->state = NULL; - ctx->mode = f_mode; - ctx->flags = 0; - ctx->error = 0; - nfs_init_lock_context(&ctx->lock_context); - ctx->lock_context.open_context = ctx; - INIT_LIST_HEAD(&ctx->list); + if (!ctx) { + put_rpccred(cred); + return ERR_PTR(-ENOMEM); } + nfs_sb_active(dentry->d_sb); + ctx->dentry = dget(dentry); + ctx->cred = cred; + ctx->state = NULL; + ctx->mode = f_mode; + ctx->flags = 0; + ctx->error = 0; + nfs_init_lock_context(&ctx->lock_context); + ctx->lock_context.open_context = ctx; + INIT_LIST_HEAD(&ctx->list); return ctx; } @@ -738,15 +743,10 @@ static void nfs_file_clear_open_context(struct file *filp) int nfs_open(struct inode *inode, struct file *filp) { struct nfs_open_context *ctx; - struct rpc_cred *cred; - cred = rpc_lookup_cred(); - if (IS_ERR(cred)) - return PTR_ERR(cred); - ctx = alloc_nfs_open_context(filp->f_path.dentry, cred, filp->f_mode); - put_rpccred(cred); - if (ctx == NULL) - return -ENOMEM; + ctx = alloc_nfs_open_context(filp->f_path.dentry, filp->f_mode); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); nfs_file_set_open_context(filp, ctx); put_nfs_open_context(ctx); nfs_fscache_set_inode_cookie(inode, filp); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 92ecf5585fac..8c29950d2fa5 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -373,7 +373,7 @@ extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr); extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx); extern void put_nfs_open_context(struct nfs_open_context *ctx); extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode); -extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode); +extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode); extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx); extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx); extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx); From f47ec3f28354795f000c14bf18ed967ec81a3ec3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 21 Nov 2011 21:15:42 -0500 Subject: [PATCH 002/165] trim fs/internal.h some stuff in there can actually become static; some belongs to pnode.h as it's a private interface between namespace.c and pnode.c... Signed-off-by: Al Viro --- fs/block_dev.c | 7 ++++++- fs/exec.c | 2 +- fs/internal.h | 24 ------------------------ fs/pnode.h | 6 ++++++ fs/super.c | 4 ++-- 5 files changed, 15 insertions(+), 28 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index b07f1da1de4e..4b322a58a513 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -493,7 +493,7 @@ static struct file_system_type bd_type = { .kill_sb = kill_anon_super, }; -struct super_block *blockdev_superblock __read_mostly; +static struct super_block *blockdev_superblock __read_mostly; void __init bdev_cache_init(void) { @@ -639,6 +639,11 @@ static struct block_device *bd_acquire(struct inode *inode) return bdev; } +static inline int sb_is_blkdev_sb(struct super_block *sb) +{ + return sb == blockdev_superblock; +} + /* Call when you free inode */ void bd_forget(struct inode *inode) 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); * - the caller must hold ->cred_guard_mutex to protect against * PTRACE_ATTACH */ -int check_unsafe_exec(struct linux_binprm *bprm) +static int check_unsafe_exec(struct linux_binprm *bprm) { struct task_struct *p = current, *t; unsigned n_fs; diff --git a/fs/internal.h b/fs/internal.h index fe327c20af83..839d3f9e9173 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -20,14 +20,8 @@ struct path; * block_dev.c */ #ifdef CONFIG_BLOCK -extern struct super_block *blockdev_superblock; extern void __init bdev_cache_init(void); -static inline int sb_is_blkdev_sb(struct super_block *sb) -{ - return sb == blockdev_superblock; -} - extern int __sync_blockdev(struct block_device *bdev, int wait); #else @@ -35,11 +29,6 @@ static inline void bdev_cache_init(void) { } -static inline int sb_is_blkdev_sb(struct super_block *sb) -{ - return 0; -} - static inline int __sync_blockdev(struct block_device *bdev, int wait) { return 0; @@ -51,25 +40,14 @@ static inline int __sync_blockdev(struct block_device *bdev, int wait) */ extern void __init chrdev_init(void); -/* - * exec.c - */ -extern int check_unsafe_exec(struct linux_binprm *); - /* * namespace.c */ extern int copy_mount_options(const void __user *, unsigned long *); extern int copy_mount_string(const void __user *, char **); -extern unsigned int mnt_get_count(struct vfsmount *mnt); extern struct vfsmount *__lookup_mnt(struct vfsmount *, struct dentry *, int); extern struct vfsmount *lookup_mnt(struct path *); -extern void mnt_set_mountpoint(struct vfsmount *, struct dentry *, - struct vfsmount *); -extern void release_mounts(struct list_head *); -extern void umount_tree(struct vfsmount *, int, struct list_head *); -extern struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int); extern int finish_automount(struct vfsmount *, struct path *); extern void mnt_make_longterm(struct vfsmount *); @@ -98,8 +76,6 @@ extern struct file *get_empty_filp(void); */ extern int do_remount_sb(struct super_block *, int, void *, int); extern bool grab_super_passive(struct super_block *sb); -extern void __put_super(struct super_block *sb); -extern void put_super(struct super_block *sb); extern struct dentry *mount_fs(struct file_system_type *, int, const char *, void *); diff --git a/fs/pnode.h b/fs/pnode.h index 1ea4ae1efcd3..391287110274 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -36,4 +36,10 @@ int propagate_umount(struct list_head *); int propagate_mount_busy(struct vfsmount *, int); void mnt_release_group_id(struct vfsmount *); int get_dominating_id(struct vfsmount *mnt, const struct path *root); +unsigned int mnt_get_count(struct vfsmount *mnt); +void mnt_set_mountpoint(struct vfsmount *, struct dentry *, + struct vfsmount *); +void release_mounts(struct list_head *); +void umount_tree(struct vfsmount *, int, struct list_head *); +struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int); #endif /* _LINUX_PNODE_H */ diff --git a/fs/super.c b/fs/super.c index afd0f1ad45e0..66a12f9bfc20 100644 --- a/fs/super.c +++ b/fs/super.c @@ -210,7 +210,7 @@ static inline void destroy_super(struct super_block *s) /* * Drop a superblock's refcount. The caller must hold sb_lock. */ -void __put_super(struct super_block *sb) +static void __put_super(struct super_block *sb) { if (!--sb->s_count) { list_del_init(&sb->s_list); @@ -225,7 +225,7 @@ void __put_super(struct super_block *sb) * Drops a temporary reference, frees superblock if there's no * references left. */ -void put_super(struct super_block *sb) +static void put_super(struct super_block *sb) { spin_lock(&sb_lock); __put_super(sb); From a561be7100cd610bd2e082f3211c1dfb45835817 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 23 Nov 2011 11:57:51 -0500 Subject: [PATCH 003/165] switch a bunch of places to mnt_want_write_file() it's both faster (in case when file has been opened for write) and cleaner. Signed-off-by: Al Viro --- fs/btrfs/ioctl.c | 10 +++++----- fs/ext2/ioctl.c | 6 +++--- fs/ext3/ioctl.c | 10 +++++----- fs/ext4/ioctl.c | 14 +++++++------- fs/fat/file.c | 2 +- fs/gfs2/file.c | 2 +- fs/hfsplus/ioctl.c | 2 +- fs/jfs/ioctl.c | 2 +- fs/nfsd/nfs4recover.c | 6 +++--- fs/nilfs2/ioctl.c | 12 ++++++------ fs/ocfs2/ioctl.c | 2 +- fs/ocfs2/move_extents.c | 2 +- fs/reiserfs/ioctl.c | 4 ++-- fs/ubifs/ioctl.c | 2 +- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_ioctl32.c | 4 ++-- 16 files changed, 42 insertions(+), 42 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index c04f02c7d5bb..20dd8f3b6c72 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) } } - ret = mnt_want_write(file->f_path.mnt); + ret = mnt_want_write_file(file); if (ret) goto out_unlock; @@ -1855,7 +1855,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, goto out; } - err = mnt_want_write(file->f_path.mnt); + err = mnt_want_write_file(file); if (err) goto out; @@ -1987,7 +1987,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp) if (btrfs_root_readonly(root)) return -EROFS; - ret = mnt_want_write(file->f_path.mnt); + ret = mnt_want_write_file(file); if (ret) return ret; @@ -2195,7 +2195,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, if (btrfs_root_readonly(root)) return -EROFS; - ret = mnt_want_write(file->f_path.mnt); + ret = mnt_want_write_file(file); if (ret) return ret; @@ -2549,7 +2549,7 @@ static long btrfs_ioctl_trans_start(struct file *file) if (btrfs_root_readonly(root)) goto out; - ret = mnt_want_write(file->f_path.mnt); + ret = mnt_want_write_file(file); if (ret) goto out; diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c index f81e250ac5c4..61a3f9661728 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) case EXT2_IOC_SETFLAGS: { unsigned int oldflags; - ret = mnt_want_write(filp->f_path.mnt); + ret = mnt_want_write_file(filp); if (ret) return ret; @@ -91,7 +91,7 @@ setflags_out: case EXT2_IOC_SETVERSION: if (!inode_owner_or_capable(inode)) return -EPERM; - ret = mnt_want_write(filp->f_path.mnt); + ret = mnt_want_write_file(filp); if (ret) return ret; if (get_user(inode->i_generation, (int __user *) arg)) { @@ -121,7 +121,7 @@ setflags_out: if (get_user(rsv_window_size, (int __user *)arg)) return -EFAULT; - ret = mnt_want_write(filp->f_path.mnt); + ret = mnt_want_write_file(filp); if (ret) return ret; diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c index ba1b54e23cae..a02863a080d3 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) if (get_user(flags, (int __user *) arg)) return -EFAULT; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; @@ -126,7 +126,7 @@ flags_out: if (!inode_owner_or_capable(inode)) return -EPERM; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; if (get_user(generation, (int __user *) arg)) { @@ -164,7 +164,7 @@ setversion_out: if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode)) return -ENOTTY; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; @@ -206,7 +206,7 @@ setrsvsz_out: if (!capable(CAP_SYS_RESOURCE)) return -EPERM; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; @@ -232,7 +232,7 @@ group_extend_out: if (!capable(CAP_SYS_RESOURCE)) return -EPERM; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index a56796814d6a..9a49760b554d 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) if (get_user(flags, (int __user *) arg)) return -EFAULT; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; @@ -150,7 +150,7 @@ flags_out: if (!inode_owner_or_capable(inode)) return -EPERM; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; if (get_user(generation, (int __user *) arg)) { @@ -192,7 +192,7 @@ setversion_out: return -EOPNOTSUPP; } - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; @@ -240,7 +240,7 @@ setversion_out: return -EOPNOTSUPP; } - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) goto mext_out; @@ -277,7 +277,7 @@ mext_out: return -EOPNOTSUPP; } - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; @@ -301,7 +301,7 @@ mext_out: if (!inode_owner_or_capable(inode)) return -EACCES; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; /* @@ -323,7 +323,7 @@ mext_out: if (!inode_owner_or_capable(inode)) return -EACCES; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; err = ext4_alloc_da_blocks(inode); diff --git a/fs/fat/file.c b/fs/fat/file.c index c118acf16e43..50746a1a0789 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) goto out; mutex_lock(&inode->i_mutex); - err = mnt_want_write(file->f_path.mnt); + err = mnt_want_write_file(file); if (err) goto out_unlock_inode; diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index ce36a56dfeac..28fc6e3855f3 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) int error; u32 new_flags, flags; - error = mnt_want_write(filp->f_path.mnt); + error = mnt_want_write_file(filp); if (error) return error; diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c index fbaa6690c8e0..31d3fe576429 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) unsigned int flags; int err = 0; - err = mnt_want_write(file->f_path.mnt); + err = mnt_want_write_file(file); if (err) goto out; diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c index 6f98a1866776..73d9eaa91c05 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) unsigned int oldflags; int err; - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) return err; diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index ed083b9a731b..a9aa2f161262 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -147,7 +147,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp) status = -EEXIST; if (dentry->d_inode) goto out_put; - status = mnt_want_write(rec_file->f_path.mnt); + status = mnt_want_write_file(rec_file); if (status) goto out_put; status = vfs_mkdir(dir->d_inode, dentry, S_IRWXU); @@ -268,7 +268,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp) if (!rec_file || !clp->cl_firststate) return; - status = mnt_want_write(rec_file->f_path.mnt); + status = mnt_want_write_file(rec_file); if (status) goto out; clp->cl_firststate = 0; @@ -311,7 +311,7 @@ nfsd4_recdir_purge_old(void) { if (!rec_file) return; - status = mnt_want_write(rec_file->f_path.mnt); + status = mnt_want_write_file(rec_file); if (status) goto out; status = nfsd4_list_rec_dir(purge_old); diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index ac258beeda3c..b7697d1ccd61 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c @@ -27,7 +27,7 @@ #include /* copy_from_user(), copy_to_user() */ #include #include /* compat_ptr() */ -#include /* mnt_want_write(), mnt_drop_write() */ +#include /* mnt_want_write_file(), mnt_drop_write() */ #include #include #include "nilfs.h" @@ -119,7 +119,7 @@ static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp, if (get_user(flags, (int __user *)argp)) return -EFAULT; - ret = mnt_want_write(filp->f_path.mnt); + ret = mnt_want_write_file(filp); if (ret) return ret; @@ -174,7 +174,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp, if (!capable(CAP_SYS_ADMIN)) return -EPERM; - ret = mnt_want_write(filp->f_path.mnt); + ret = mnt_want_write_file(filp); if (ret) return ret; @@ -210,7 +210,7 @@ nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp, if (!capable(CAP_SYS_ADMIN)) return -EPERM; - ret = mnt_want_write(filp->f_path.mnt); + ret = mnt_want_write_file(filp); if (ret) return ret; @@ -591,7 +591,7 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp, if (!capable(CAP_SYS_ADMIN)) return -EPERM; - ret = mnt_want_write(filp->f_path.mnt); + ret = mnt_want_write_file(filp); if (ret) return ret; @@ -710,7 +710,7 @@ static int nilfs_ioctl_resize(struct inode *inode, struct file *filp, if (!capable(CAP_SYS_ADMIN)) goto out; - ret = mnt_want_write(filp->f_path.mnt); + ret = mnt_want_write_file(filp); if (ret) goto out; diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index 726ff265b296..892ace253f97 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -906,7 +906,7 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (get_user(flags, (int __user *) arg)) return -EFAULT; - status = mnt_want_write(filp->f_path.mnt); + status = mnt_want_write_file(filp); if (status) return status; status = ocfs2_set_inode_attr(inode, flags, diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index 184c76b8c293..1d3bf83f8b85 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) struct ocfs2_move_extents range; struct ocfs2_move_extents_context *context = NULL; - status = mnt_want_write(filp->f_path.mnt); + status = mnt_want_write_file(filp); if (status) return status; diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c index 4e153051bc75..0b94d7b2b11f 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) break; } - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) break; @@ -107,7 +107,7 @@ setflags_out: err = -EPERM; break; } - err = mnt_want_write(filp->f_path.mnt); + err = mnt_want_write_file(filp); if (err) break; if (get_user(inode->i_generation, (int __user *)arg)) { diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c index 548acf494afd..e52c84598feb 100644 --- a/fs/ubifs/ioctl.c +++ b/fs/ubifs/ioctl.c @@ -173,7 +173,7 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) * Make sure the file-system is read-write and make sure it * will not become read-only while we are changing the flags. */ - err = mnt_want_write(file->f_path.mnt); + err = mnt_want_write_file(file); if (err) return err; dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags); diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index d99a90518909..b436e17c753e 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -559,7 +559,7 @@ xfs_attrmulti_by_handle( ops[i].am_flags); break; case ATTR_OP_SET: - ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); + ops[i].am_error = mnt_want_write_file(parfilp); if (ops[i].am_error) break; ops[i].am_error = xfs_attrmulti_attr_set( @@ -569,7 +569,7 @@ xfs_attrmulti_by_handle( mnt_drop_write(parfilp->f_path.mnt); break; case ATTR_OP_REMOVE: - ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); + ops[i].am_error = mnt_want_write_file(parfilp); if (ops[i].am_error) break; ops[i].am_error = xfs_attrmulti_attr_remove( diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 54e623bfbb85..dd4ba1d4c582 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -454,7 +454,7 @@ xfs_compat_attrmulti_by_handle( &ops[i].am_length, ops[i].am_flags); break; case ATTR_OP_SET: - ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); + ops[i].am_error = mnt_want_write_file(parfilp); if (ops[i].am_error) break; ops[i].am_error = xfs_attrmulti_attr_set( @@ -464,7 +464,7 @@ xfs_compat_attrmulti_by_handle( mnt_drop_write(parfilp->f_path.mnt); break; case ATTR_OP_REMOVE: - ops[i].am_error = mnt_want_write(parfilp->f_path.mnt); + ops[i].am_error = mnt_want_write_file(parfilp); if (ops[i].am_error) break; ops[i].am_error = xfs_attrmulti_attr_remove( From bad0dcffc21d17a07dbb83a2bf764f35a57feba5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 23 Nov 2011 12:03:18 -0500 Subject: [PATCH 004/165] new helpers: fh_{want,drop}_write() A bunch of places in nfsd does mnt_{want,drop}_write on vfsmount of export of given fhandle. Switched to obvious inlined helpers... Signed-off-by: Al Viro --- fs/nfsd/nfs4proc.c | 4 ++-- fs/nfsd/vfs.c | 34 +++++++++++++++++----------------- fs/nfsd/vfs.h | 10 ++++++++++ 3 files changed, 29 insertions(+), 19 deletions(-) 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, return status; } } - status = mnt_want_write(cstate->current_fh.fh_export->ex_path.mnt); + status = fh_want_write(&cstate->current_fh); if (status) return status; status = nfs_ok; @@ -856,7 +856,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, status = nfsd_setattr(rqstp, &cstate->current_fh, &setattr->sa_iattr, 0, (time_t)0); out: - mnt_drop_write(cstate->current_fh.fh_export->ex_path.mnt); + fh_drop_write(&cstate->current_fh); return status; } diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 7a2e442623c8..29b1202313e9 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1300,7 +1300,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, goto out; } - host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); + host_err = fh_want_write(fhp); if (host_err) goto out_nfserr; @@ -1325,7 +1325,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, break; } if (host_err < 0) { - mnt_drop_write(fhp->fh_export->ex_path.mnt); + fh_drop_write(fhp); goto out_nfserr; } @@ -1339,7 +1339,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, err2 = nfserrno(commit_metadata(fhp)); if (err2) err = err2; - mnt_drop_write(fhp->fh_export->ex_path.mnt); + fh_drop_write(fhp); /* * Update the file handle to get the new inode info. */ @@ -1430,7 +1430,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, v_atime = verifier[1]&0x7fffffff; } - host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); + host_err = fh_want_write(fhp); if (host_err) goto out_nfserr; if (dchild->d_inode) { @@ -1469,13 +1469,13 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, case NFS3_CREATE_GUARDED: err = nfserr_exist; } - mnt_drop_write(fhp->fh_export->ex_path.mnt); + fh_drop_write(fhp); goto out; } host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL); if (host_err < 0) { - mnt_drop_write(fhp->fh_export->ex_path.mnt); + fh_drop_write(fhp); goto out_nfserr; } if (created) @@ -1503,7 +1503,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, if (!err) err = nfserrno(commit_metadata(fhp)); - mnt_drop_write(fhp->fh_export->ex_path.mnt); + fh_drop_write(fhp); /* * Update the filehandle to get the new inode info. */ @@ -1600,7 +1600,7 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, if (IS_ERR(dnew)) goto out_nfserr; - host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); + host_err = fh_want_write(fhp); if (host_err) goto out_nfserr; @@ -1621,7 +1621,7 @@ nfsd_symlink(struct svc_rqst *rqstp, struct svc_fh *fhp, err = nfserrno(commit_metadata(fhp)); fh_unlock(fhp); - mnt_drop_write(fhp->fh_export->ex_path.mnt); + fh_drop_write(fhp); cerr = fh_compose(resfhp, fhp->fh_export, dnew, fhp); dput(dnew); @@ -1674,7 +1674,7 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp, dold = tfhp->fh_dentry; - host_err = mnt_want_write(tfhp->fh_export->ex_path.mnt); + host_err = fh_want_write(tfhp); if (host_err) { err = nfserrno(host_err); goto out_dput; @@ -1699,7 +1699,7 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp, err = nfserrno(host_err); } out_drop_write: - mnt_drop_write(tfhp->fh_export->ex_path.mnt); + fh_drop_write(tfhp); out_dput: dput(dnew); out_unlock: @@ -1776,7 +1776,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen, host_err = -EXDEV; if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt) goto out_dput_new; - host_err = mnt_want_write(ffhp->fh_export->ex_path.mnt); + host_err = fh_want_write(ffhp); if (host_err) goto out_dput_new; @@ -1795,7 +1795,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen, host_err = commit_metadata(ffhp); } out_drop_write: - mnt_drop_write(ffhp->fh_export->ex_path.mnt); + fh_drop_write(ffhp); out_dput_new: dput(ndentry); out_dput_old: @@ -1854,7 +1854,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, if (!type) type = rdentry->d_inode->i_mode & S_IFMT; - host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); + host_err = fh_want_write(fhp); if (host_err) goto out_put; @@ -1868,7 +1868,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, if (!host_err) host_err = commit_metadata(fhp); out_drop_write: - mnt_drop_write(fhp->fh_export->ex_path.mnt); + fh_drop_write(fhp); out_put: dput(rdentry); @@ -2270,7 +2270,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl) } else size = 0; - error = mnt_want_write(fhp->fh_export->ex_path.mnt); + error = fh_want_write(fhp); if (error) goto getout; if (size) @@ -2284,7 +2284,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl) error = 0; } } - mnt_drop_write(fhp->fh_export->ex_path.mnt); + fh_drop_write(fhp); getout: kfree(value); diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index 3f54ad03bb2b..cee6a12296e8 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -106,4 +106,14 @@ struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int); int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *); #endif +static inline int fh_want_write(struct svc_fh *fh) +{ + return mnt_want_write(fh->fh_export->ex_path.mnt); +} + +static inline void fh_drop_write(struct svc_fh *fh) +{ + mnt_drop_write(fh->fh_export->ex_path.mnt); +} + #endif /* LINUX_NFSD_VFS_H */ From aa9c0e07bb90589186f3b5a0ca97660c2cb50806 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 23 Nov 2011 19:04:52 -0500 Subject: [PATCH 005/165] vfs: kill pointless helpers in namespace.c mnt_{inc,dec}_count() is not cleaner than doing the corresponding mnt_add_count() directly and mnt_set_count() is not used at all. Signed-off-by: Al Viro --- fs/namespace.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index cfc6d4448aa5..31d357450f7f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -152,31 +152,6 @@ static inline void mnt_add_count(struct vfsmount *mnt, int n) #endif } -static inline void mnt_set_count(struct vfsmount *mnt, int n) -{ -#ifdef CONFIG_SMP - this_cpu_write(mnt->mnt_pcp->mnt_count, n); -#else - mnt->mnt_count = n; -#endif -} - -/* - * vfsmount lock must be held for read - */ -static inline void mnt_inc_count(struct vfsmount *mnt) -{ - mnt_add_count(mnt, 1); -} - -/* - * vfsmount lock must be held for read - */ -static inline void mnt_dec_count(struct vfsmount *mnt) -{ - mnt_add_count(mnt, -1); -} - /* * vfsmount lock must be held for write */ @@ -780,20 +755,20 @@ put_again: #ifdef CONFIG_SMP br_read_lock(vfsmount_lock); if (likely(atomic_read(&mnt->mnt_longterm))) { - mnt_dec_count(mnt); + mnt_add_count(mnt, -1); br_read_unlock(vfsmount_lock); return; } br_read_unlock(vfsmount_lock); br_write_lock(vfsmount_lock); - mnt_dec_count(mnt); + mnt_add_count(mnt, -1); if (mnt_get_count(mnt)) { br_write_unlock(vfsmount_lock); return; } #else - mnt_dec_count(mnt); + mnt_add_count(mnt, -1); if (likely(mnt_get_count(mnt))) return; br_write_lock(vfsmount_lock); @@ -823,7 +798,7 @@ EXPORT_SYMBOL(mntput); struct vfsmount *mntget(struct vfsmount *mnt) { if (mnt) - mnt_inc_count(mnt); + mnt_add_count(mnt, 1); return mnt; } EXPORT_SYMBOL(mntget); @@ -840,7 +815,7 @@ void mnt_unpin(struct vfsmount *mnt) { br_write_lock(vfsmount_lock); if (mnt->mnt_pinned) { - mnt_inc_count(mnt); + mnt_add_count(mnt, 1); mnt->mnt_pinned--; } br_write_unlock(vfsmount_lock); From b2dba1af3c4157040303a76d25216b1713d333d0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 23 Nov 2011 19:26:23 -0500 Subject: [PATCH 006/165] vfs: new internal helper: mnt_has_parent(mnt) vfsmounts have ->mnt_parent pointing either to a different vfsmount or to itself; it's never NULL and termination condition in loops traversing the tree towards root is mnt == mnt->mnt_parent. At least one place (see the next patch) is confused about what's going on; let's add an explicit helper checking it right way and use it in all places where we need it. Not that there had been too many, but... Signed-off-by: Al Viro --- fs/dcache.c | 6 +++--- fs/mount.h | 6 ++++++ fs/namespace.c | 14 +++++++------- fs/pnode.c | 2 +- fs/pnode.h | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 fs/mount.h diff --git a/fs/dcache.c b/fs/dcache.c index 89509b5a090e..8a75e3b0f49d 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -38,6 +38,7 @@ #include #include #include "internal.h" +#include "mount.h" /* * Usage: @@ -2460,9 +2461,8 @@ static int prepend_path(const struct path *path, if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { /* Global root? */ - if (vfsmnt->mnt_parent == vfsmnt) { + if (!mnt_has_parent(vfsmnt)) goto global_root; - } dentry = vfsmnt->mnt_mountpoint; vfsmnt = vfsmnt->mnt_parent; continue; @@ -2862,7 +2862,7 @@ int path_is_under(struct path *path1, struct path *path2) br_read_lock(vfsmount_lock); if (mnt != path2->mnt) { for (;;) { - if (mnt->mnt_parent == mnt) { + if (!mnt_has_parent(mnt)) { br_read_unlock(vfsmount_lock); return 0; } diff --git a/fs/mount.h b/fs/mount.h new file mode 100644 index 000000000000..7890e49f74ef --- /dev/null +++ b/fs/mount.h @@ -0,0 +1,6 @@ +#include + +static inline int mnt_has_parent(struct vfsmount *mnt) +{ + return mnt != mnt->mnt_parent; +} diff --git a/fs/namespace.c b/fs/namespace.c index 31d357450f7f..ec8512478b04 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1182,7 +1182,7 @@ void release_mounts(struct list_head *head) while (!list_empty(head)) { mnt = list_first_entry(head, struct vfsmount, mnt_hash); list_del_init(&mnt->mnt_hash); - if (mnt->mnt_parent != mnt) { + if (mnt_has_parent(mnt)) { struct dentry *dentry; struct vfsmount *m; @@ -1222,7 +1222,7 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) p->mnt_ns = NULL; __mnt_make_shortterm(p); list_del_init(&p->mnt_child); - if (p->mnt_parent != p) { + if (mnt_has_parent(p)) { p->mnt_parent->mnt_ghosts++; dentry_reset_mounted(p->mnt_parent, p->mnt_mountpoint); } @@ -1867,7 +1867,7 @@ static int do_move_mount(struct path *path, char *old_name) if (old_path.dentry != old_path.mnt->mnt_root) goto out1; - if (old_path.mnt == old_path.mnt->mnt_parent) + if (!mnt_has_parent(old_path.mnt)) goto out1; if (S_ISDIR(path->dentry->d_inode->i_mode) != @@ -1887,7 +1887,7 @@ static int do_move_mount(struct path *path, char *old_name) tree_contains_unbindable(old_path.mnt)) goto out1; err = -ELOOP; - for (p = path->mnt; p->mnt_parent != p; p = p->mnt_parent) + for (p = path->mnt; mnt_has_parent(p); p = p->mnt_parent) if (p == old_path.mnt) goto out1; @@ -2604,17 +2604,17 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, error = -EINVAL; if (root.mnt->mnt_root != root.dentry) goto out4; /* not a mountpoint */ - if (root.mnt->mnt_parent == root.mnt) + if (!mnt_has_parent(root.mnt)) goto out4; /* not attached */ if (new.mnt->mnt_root != new.dentry) goto out4; /* not a mountpoint */ - if (new.mnt->mnt_parent == new.mnt) + if (!mnt_has_parent(new.mnt)) goto out4; /* not attached */ /* make sure we can reach put_old from new_root */ tmp = old.mnt; if (tmp != new.mnt) { for (;;) { - if (tmp->mnt_parent == tmp) + if (!mnt_has_parent(tmp)) goto out4; /* already mounted on put_old */ if (tmp->mnt_parent == new.mnt) break; diff --git a/fs/pnode.c b/fs/pnode.c index d42514e32380..f1cd958b92e5 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -36,7 +36,7 @@ static inline struct vfsmount *next_slave(struct vfsmount *p) static bool is_path_reachable(struct vfsmount *mnt, struct dentry *dentry, const struct path *root) { - while (mnt != root->mnt && mnt->mnt_parent != mnt) { + while (mnt != root->mnt && mnt_has_parent(mnt)) { dentry = mnt->mnt_mountpoint; mnt = mnt->mnt_parent; } diff --git a/fs/pnode.h b/fs/pnode.h index 391287110274..7f0c13ae9484 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -9,7 +9,7 @@ #define _LINUX_PNODE_H #include -#include +#include "mount.h" #define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED) #define IS_MNT_SLAVE(mnt) (mnt->mnt_master) From afac7cba7ed31968a95e181dc25e204e45009ea8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 23 Nov 2011 19:34:49 -0500 Subject: [PATCH 007/165] vfs: more mnt_parent cleanups a) mount --move is checking that ->mnt_parent is non-NULL before looking if that parent happens to be shared; ->mnt_parent is never NULL and it's not even an misspelled !mnt_has_parent() b) pivot_root open-codes is_path_reachable(), poorly. c) so does path_is_under(), while we are at it. Signed-off-by: Al Viro --- fs/dcache.c | 25 ------------------------- fs/namespace.c | 42 +++++++++++++++++++++++++++--------------- fs/pnode.c | 15 --------------- fs/pnode.h | 2 ++ 4 files changed, 29 insertions(+), 55 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 8a75e3b0f49d..64c8ce4c147f 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2853,31 +2853,6 @@ int is_subdir(struct dentry *new_dentry, struct dentry *old_dentry) return result; } -int path_is_under(struct path *path1, struct path *path2) -{ - struct vfsmount *mnt = path1->mnt; - struct dentry *dentry = path1->dentry; - int res; - - br_read_lock(vfsmount_lock); - if (mnt != path2->mnt) { - for (;;) { - if (!mnt_has_parent(mnt)) { - br_read_unlock(vfsmount_lock); - return 0; - } - if (mnt->mnt_parent == path2->mnt) - break; - mnt = mnt->mnt_parent; - } - dentry = mnt->mnt_mountpoint; - } - res = is_subdir(dentry, path2->dentry); - br_read_unlock(vfsmount_lock); - return res; -} -EXPORT_SYMBOL(path_is_under); - void d_genocide(struct dentry *root) { struct dentry *this_parent; diff --git a/fs/namespace.c b/fs/namespace.c index ec8512478b04..7aad258dcaf6 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1876,8 +1876,7 @@ static int do_move_mount(struct path *path, char *old_name) /* * Don't move a mount residing in a shared parent. */ - if (old_path.mnt->mnt_parent && - IS_MNT_SHARED(old_path.mnt->mnt_parent)) + if (IS_MNT_SHARED(old_path.mnt->mnt_parent)) goto out1; /* * Don't move a mount tree containing unbindable mounts to a destination @@ -2533,6 +2532,31 @@ out_type: return ret; } +/* + * Return true if path is reachable from root + * + * namespace_sem or vfsmount_lock is held + */ +bool is_path_reachable(struct vfsmount *mnt, struct dentry *dentry, + const struct path *root) +{ + while (mnt != root->mnt && mnt_has_parent(mnt)) { + dentry = mnt->mnt_mountpoint; + mnt = mnt->mnt_parent; + } + return mnt == root->mnt && is_subdir(dentry, root->dentry); +} + +int path_is_under(struct path *path1, struct path *path2) +{ + int res; + br_read_lock(vfsmount_lock); + res = is_path_reachable(path1->mnt, path1->dentry, path2); + br_read_unlock(vfsmount_lock); + return res; +} +EXPORT_SYMBOL(path_is_under); + /* * pivot_root Semantics: * Moves the root file system of the current process to the directory put_old, @@ -2561,7 +2585,6 @@ out_type: SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, const char __user *, put_old) { - struct vfsmount *tmp; struct path new, old, parent_path, root_parent, root; int error; @@ -2611,18 +2634,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, if (!mnt_has_parent(new.mnt)) goto out4; /* not attached */ /* make sure we can reach put_old from new_root */ - tmp = old.mnt; - if (tmp != new.mnt) { - for (;;) { - if (!mnt_has_parent(tmp)) - goto out4; /* already mounted on put_old */ - if (tmp->mnt_parent == new.mnt) - break; - tmp = tmp->mnt_parent; - } - if (!is_subdir(tmp->mnt_mountpoint, new.dentry)) - goto out4; - } else if (!is_subdir(old.dentry, new.dentry)) + if (!is_path_reachable(old.mnt, old.dentry, &new)) goto out4; br_write_lock(vfsmount_lock); detach_mnt(new.mnt, &parent_path); diff --git a/fs/pnode.c b/fs/pnode.c index f1cd958b92e5..4d5a06ea57a2 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -28,21 +28,6 @@ static inline struct vfsmount *next_slave(struct vfsmount *p) return list_entry(p->mnt_slave.next, struct vfsmount, mnt_slave); } -/* - * Return true if path is reachable from root - * - * namespace_sem is held, and mnt is attached - */ -static bool is_path_reachable(struct vfsmount *mnt, struct dentry *dentry, - const struct path *root) -{ - while (mnt != root->mnt && mnt_has_parent(mnt)) { - dentry = mnt->mnt_mountpoint; - mnt = mnt->mnt_parent; - } - return mnt == root->mnt && is_subdir(dentry, root->dentry); -} - static struct vfsmount *get_peer_under_root(struct vfsmount *mnt, struct mnt_namespace *ns, const struct path *root) diff --git a/fs/pnode.h b/fs/pnode.h index 7f0c13ae9484..723399e76134 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -42,4 +42,6 @@ void mnt_set_mountpoint(struct vfsmount *, struct dentry *, void release_mounts(struct list_head *); void umount_tree(struct vfsmount *, int, struct list_head *); struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int); +bool is_path_reachable(struct vfsmount *, struct dentry *, + const struct path *root); #endif /* _LINUX_PNODE_H */ From aafd08dad019ecc858b31fb89064f4de623c64f7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 23 Nov 2011 12:27:01 -0500 Subject: [PATCH 008/165] vfs: add missing parens in pnode.h macros Signed-off-by: Al Viro --- fs/pnode.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/pnode.h b/fs/pnode.h index 723399e76134..5c234e742193 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -11,11 +11,11 @@ #include #include "mount.h" -#define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED) -#define IS_MNT_SLAVE(mnt) (mnt->mnt_master) -#define IS_MNT_NEW(mnt) (!mnt->mnt_ns) -#define CLEAR_MNT_SHARED(mnt) (mnt->mnt_flags &= ~MNT_SHARED) -#define IS_MNT_UNBINDABLE(mnt) (mnt->mnt_flags & MNT_UNBINDABLE) +#define IS_MNT_SHARED(mnt) ((mnt)->mnt_flags & MNT_SHARED) +#define IS_MNT_SLAVE(mnt) ((mnt)->mnt_master) +#define IS_MNT_NEW(mnt) (!(mnt)->mnt_ns) +#define CLEAR_MNT_SHARED(mnt) ((mnt)->mnt_flags &= ~MNT_SHARED) +#define IS_MNT_UNBINDABLE(mnt) ((mnt)->mnt_flags & MNT_UNBINDABLE) #define CL_EXPIRE 0x01 #define CL_SLAVE 0x02 From 6c449c8dfe30142b3ced5f052e8ed3cce308801a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 16 Nov 2011 22:01:36 -0500 Subject: [PATCH 009/165] unexport put_mnt_ns(), make create_mnt_ns() static outright Signed-off-by: Al Viro --- fs/namespace.c | 4 +--- include/linux/mnt_namespace.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 7aad258dcaf6..0953a3a6d45e 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2444,7 +2444,7 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, * create_mnt_ns - creates a private namespace and adds a root filesystem * @mnt: pointer to the new root filesystem mountpoint */ -struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) +static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) { struct mnt_namespace *new_ns; @@ -2459,7 +2459,6 @@ struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) } return new_ns; } -EXPORT_SYMBOL(create_mnt_ns); struct dentry *mount_subtree(struct vfsmount *mnt, const char *name) { @@ -2734,7 +2733,6 @@ void put_mnt_ns(struct mnt_namespace *ns) release_mounts(&umount_list); kfree(ns); } -EXPORT_SYMBOL(put_mnt_ns); struct vfsmount *kern_mount_data(struct file_system_type *type, void *data) { diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h index 29304855652d..e87ec01aac9d 100644 --- a/include/linux/mnt_namespace.h +++ b/include/linux/mnt_namespace.h @@ -22,7 +22,6 @@ struct proc_mounts { struct fs_struct; -extern struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt); extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, struct fs_struct *); extern void put_mnt_ns(struct mnt_namespace *ns); From aa0a4cf0ab4b03db21133a0ba62f558ed1bfcd1d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 19:31:36 -0500 Subject: [PATCH 010/165] vfs: dentry_reset_mounted() doesn't use vfsmount argument lose it Signed-off-by: Al Viro --- fs/namespace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 0953a3a6d45e..ed21ac4f7c69 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -523,7 +523,7 @@ static void __touch_mnt_namespace(struct mnt_namespace *ns) * Clear dentry's mounted state if it has no remaining mounts. * vfsmount_lock must be held for write. */ -static void dentry_reset_mounted(struct vfsmount *mnt, struct dentry *dentry) +static void dentry_reset_mounted(struct dentry *dentry) { unsigned u; @@ -551,7 +551,7 @@ static void detach_mnt(struct vfsmount *mnt, struct path *old_path) mnt->mnt_mountpoint = mnt->mnt_root; list_del_init(&mnt->mnt_child); list_del_init(&mnt->mnt_hash); - dentry_reset_mounted(old_path->mnt, old_path->dentry); + dentry_reset_mounted(old_path->dentry); } /* @@ -1224,7 +1224,7 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) list_del_init(&p->mnt_child); if (mnt_has_parent(p)) { p->mnt_parent->mnt_ghosts++; - dentry_reset_mounted(p->mnt_parent, p->mnt_mountpoint); + dentry_reset_mounted(p->mnt_mountpoint); } change_mnt_propagation(p, MS_PRIVATE); } From c5dc332eb93881fc8234d652f6e91a2825b06503 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 20:08:53 -0500 Subject: [PATCH 011/165] tomoyo: stop including hell knows what tomoyo/realpath.c needs exactly one include - that of common.h. It pulls everything the thing needs, without doing ridiculous garbage such as trying to include ../../fs/internal.h. If that alone doesn't scream "layering violation", I don't know what does; and these days it's all for nothing, since it fortunately does not use any symbols defined in there... Signed-off-by: Al Viro --- security/tomoyo/realpath.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index d9f3ced8756e..2cb5db589c9d 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c @@ -4,15 +4,7 @@ * Copyright (C) 2005-2011 NTT DATA CORPORATION */ -#include -#include -#include -#include -#include -#include -#include #include "common.h" -#include "../../fs/internal.h" /** * tomoyo_encode2 - Encode binary string to ascii string. From e407699ef56ed948739dd57a5578ba8cb5bd81b2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 20:14:54 -0500 Subject: [PATCH 012/165] btrfs, nfs, apparmor: don't pull mnt_namespace.h for no reason... it's not needed anymore; we used to, back when we had to do mount_subtree() by hand, complete with put_mnt_ns() in it. No more... Apparmor didn't need it since the __d_path() fix. Signed-off-by: Al Viro --- fs/btrfs/super.c | 1 - fs/nfs/super.c | 1 - security/apparmor/path.c | 1 - 3 files changed, 3 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 200f63bc6675..dc62d3cc68fd 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include "compat.h" #include "delayed-inode.h" diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 134777406ee3..73d87f9bab58 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/security/apparmor/path.c b/security/apparmor/path.c index b566eba4a65c..9d070a7c3ffc 100644 --- a/security/apparmor/path.c +++ b/security/apparmor/path.c @@ -13,7 +13,6 @@ */ #include -#include #include #include #include From 5ffc2836a2514e3f402327536b5dcc4a5b2d5571 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 02:22:06 -0500 Subject: [PATCH 013/165] vfs: kill ->mnt_devname use in afs printks Signed-off-by: Al Viro --- fs/afs/mntpt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) { struct vfsmount *newmnt; - _enter("{%s,%s}", path->mnt->mnt_devname, path->dentry->d_name.name); + _enter("{%s}", path->dentry->d_name.name); newmnt = afs_mntpt_do_automount(path->dentry); if (IS_ERR(newmnt)) @@ -252,7 +252,7 @@ struct vfsmount *afs_d_automount(struct path *path) mnt_set_expiry(newmnt, &afs_vfsmounts); queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer, afs_mntpt_expiry_timeout * HZ); - _leave(" = %p {%s}", newmnt, newmnt->mnt_devname); + _leave(" = %p", newmnt); return newmnt; } From 5352d3b65ae6f38e71e16f704414c1db4b4f7228 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 16 Nov 2011 21:52:06 -0500 Subject: [PATCH 014/165] make nfs_follow_remote_path() handle ERR_PTR() passed as root_mnt ... rather than duplicating that in callers Signed-off-by: Al Viro --- fs/nfs/super.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 73d87f9bab58..0e6dd56a9f1e 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -2787,11 +2787,15 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt, const char *export_path) { struct dentry *dentry; - int ret = nfs_referral_loop_protect(); + int err; - if (ret) { + if (IS_ERR(root_mnt)) + return ERR_CAST(root_mnt); + + err = nfs_referral_loop_protect(); + if (err) { mntput(root_mnt); - return ERR_PTR(ret); + return ERR_PTR(err); } dentry = mount_subtree(root_mnt, export_path); @@ -2815,9 +2819,7 @@ static struct dentry *nfs4_try_mount(int flags, const char *dev_name, data->nfs_server.hostname); data->nfs_server.export_path = export_path; - res = ERR_CAST(root_mnt); - if (!IS_ERR(root_mnt)) - res = nfs_follow_remote_path(root_mnt, export_path); + res = nfs_follow_remote_path(root_mnt, export_path); dfprintk(MOUNT, "<-- nfs4_try_mount() = %ld%s\n", IS_ERR(res) ? PTR_ERR(res) : 0, @@ -3078,9 +3080,7 @@ static struct dentry *nfs4_referral_mount(struct file_system_type *fs_type, flags, data, data->hostname); data->mnt_path = export_path; - res = ERR_CAST(root_mnt); - if (!IS_ERR(root_mnt)) - res = nfs_follow_remote_path(root_mnt, export_path); + res = nfs_follow_remote_path(root_mnt, export_path); dprintk("<-- nfs4_referral_mount() = %ld%s\n", IS_ERR(res) ? PTR_ERR(res) : 0, IS_ERR(res) ? " [error]" : ""); From a5166169f9b920cae3c503910cb66a3ac5dd846d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 12 Dec 2011 22:53:00 -0500 Subject: [PATCH 015/165] vfs: convert fs_supers to hlist Signed-off-by: Al Viro --- fs/filesystems.c | 1 - fs/super.c | 26 ++++++++++++++------------ include/linux/fs.h | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) 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) BUG_ON(strchr(fs->name, '.')); if (fs->next) return -EBUSY; - INIT_LIST_HEAD(&fs->fs_supers); write_lock(&file_systems_lock); p = find_filesystem(fs->name, strlen(fs->name)); if (*p) diff --git a/fs/super.c b/fs/super.c index 66a12f9bfc20..bab11bad13ba 100644 --- a/fs/super.c +++ b/fs/super.c @@ -136,7 +136,7 @@ static struct super_block *alloc_super(struct file_system_type *type) INIT_LIST_HEAD(&s->s_files); #endif s->s_bdi = &default_backing_dev_info; - INIT_LIST_HEAD(&s->s_instances); + INIT_HLIST_NODE(&s->s_instances); INIT_HLIST_BL_HEAD(&s->s_anon); INIT_LIST_HEAD(&s->s_inodes); INIT_LIST_HEAD(&s->s_dentry_lru); @@ -328,7 +328,7 @@ static int grab_super(struct super_block *s) __releases(sb_lock) bool grab_super_passive(struct super_block *sb) { spin_lock(&sb_lock); - if (list_empty(&sb->s_instances)) { + if (hlist_unhashed(&sb->s_instances)) { spin_unlock(&sb_lock); return false; } @@ -400,7 +400,7 @@ void generic_shutdown_super(struct super_block *sb) } spin_lock(&sb_lock); /* should be initialized for __put_super_and_need_restart() */ - list_del_init(&sb->s_instances); + hlist_del_init(&sb->s_instances); spin_unlock(&sb_lock); up_write(&sb->s_umount); } @@ -420,13 +420,14 @@ struct super_block *sget(struct file_system_type *type, void *data) { struct super_block *s = NULL; + struct hlist_node *node; struct super_block *old; int err; retry: spin_lock(&sb_lock); if (test) { - list_for_each_entry(old, &type->fs_supers, s_instances) { + hlist_for_each_entry(old, node, &type->fs_supers, s_instances) { if (!test(old, data)) continue; if (!grab_super(old)) @@ -462,7 +463,7 @@ retry: s->s_type = type; strlcpy(s->s_id, type->name, sizeof(s->s_id)); list_add_tail(&s->s_list, &super_blocks); - list_add(&s->s_instances, &type->fs_supers); + hlist_add_head(&s->s_instances, &type->fs_supers); spin_unlock(&sb_lock); get_filesystem(type); register_shrinker(&s->s_shrink); @@ -497,7 +498,7 @@ void sync_supers(void) spin_lock(&sb_lock); list_for_each_entry(sb, &super_blocks, s_list) { - if (list_empty(&sb->s_instances)) + if (hlist_unhashed(&sb->s_instances)) continue; if (sb->s_op->write_super && sb->s_dirt) { sb->s_count++; @@ -533,7 +534,7 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg) spin_lock(&sb_lock); list_for_each_entry(sb, &super_blocks, s_list) { - if (list_empty(&sb->s_instances)) + if (hlist_unhashed(&sb->s_instances)) continue; sb->s_count++; spin_unlock(&sb_lock); @@ -566,9 +567,10 @@ void iterate_supers_type(struct file_system_type *type, void (*f)(struct super_block *, void *), void *arg) { struct super_block *sb, *p = NULL; + struct hlist_node *node; spin_lock(&sb_lock); - list_for_each_entry(sb, &type->fs_supers, s_instances) { + hlist_for_each_entry(sb, node, &type->fs_supers, s_instances) { sb->s_count++; spin_unlock(&sb_lock); @@ -607,7 +609,7 @@ struct super_block *get_super(struct block_device *bdev) spin_lock(&sb_lock); rescan: list_for_each_entry(sb, &super_blocks, s_list) { - if (list_empty(&sb->s_instances)) + if (hlist_unhashed(&sb->s_instances)) continue; if (sb->s_bdev == bdev) { sb->s_count++; @@ -647,7 +649,7 @@ struct super_block *get_active_super(struct block_device *bdev) restart: spin_lock(&sb_lock); list_for_each_entry(sb, &super_blocks, s_list) { - if (list_empty(&sb->s_instances)) + if (hlist_unhashed(&sb->s_instances)) continue; if (sb->s_bdev == bdev) { if (grab_super(sb)) /* drops sb_lock */ @@ -667,7 +669,7 @@ struct super_block *user_get_super(dev_t dev) spin_lock(&sb_lock); rescan: list_for_each_entry(sb, &super_blocks, s_list) { - if (list_empty(&sb->s_instances)) + if (hlist_unhashed(&sb->s_instances)) continue; if (sb->s_dev == dev) { sb->s_count++; @@ -756,7 +758,7 @@ static void do_emergency_remount(struct work_struct *work) spin_lock(&sb_lock); list_for_each_entry(sb, &super_blocks, s_list) { - if (list_empty(&sb->s_instances)) + if (hlist_unhashed(&sb->s_instances)) continue; sb->s_count++; spin_unlock(&sb_lock); diff --git a/include/linux/fs.h b/include/linux/fs.h index e0bc4ffb8e7f..ed17e54fd204 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1440,7 +1440,7 @@ struct super_block { struct block_device *s_bdev; struct backing_dev_info *s_bdi; struct mtd_info *s_mtd; - struct list_head s_instances; + struct hlist_node s_instances; struct quota_info s_dquot; /* Diskquota specific options */ int s_frozen; @@ -1864,7 +1864,7 @@ struct file_system_type { void (*kill_sb) (struct super_block *); struct module *owner; struct file_system_type * next; - struct list_head fs_supers; + struct hlist_head fs_supers; struct lock_class_key s_lock_key; struct lock_class_key s_umount_key; From 79e801a906db46cb8efad66c400b01df874b3f12 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 12 Dec 2011 23:07:05 -0500 Subject: [PATCH 016/165] vfs: make do_kern_mount() static the only user outside of fs/namespace.c has died Signed-off-by: Al Viro --- fs/namespace.c | 3 +-- include/linux/mount.h | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index ed21ac4f7c69..7a8f949cec1b 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1929,7 +1929,7 @@ static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype) return ERR_PTR(err); } -struct vfsmount * +static struct vfsmount * do_kern_mount(const char *fstype, int flags, const char *name, void *data) { struct file_system_type *type = get_fs_type(fstype); @@ -1943,7 +1943,6 @@ do_kern_mount(const char *fstype, int flags, const char *name, void *data) put_filesystem(type); return mnt; } -EXPORT_SYMBOL_GPL(do_kern_mount); /* * add a mount into a namespace's mount tree diff --git a/include/linux/mount.h b/include/linux/mount.h index 33fe53d78110..65c1bb013836 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -100,9 +100,6 @@ extern void mnt_pin(struct vfsmount *mnt); extern void mnt_unpin(struct vfsmount *mnt); extern int __mnt_is_readonly(struct vfsmount *mnt); -extern struct vfsmount *do_kern_mount(const char *fstype, int flags, - const char *name, void *data); - struct file_system_type; extern struct vfsmount *vfs_kern_mount(struct file_system_type *type, int flags, const char *name, From 8c9379e972e984d11c2b99121847ba9fa7a0c56c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Dec 2011 20:18:57 -0500 Subject: [PATCH 017/165] constify seq_file stuff Signed-off-by: Al Viro --- fs/seq_file.c | 10 +++++----- include/linux/seq_file.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) 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); * Returns pointer past last written character in @s, or NULL in case of * failure. */ -char *mangle_path(char *s, char *p, char *esc) +char *mangle_path(char *s, const char *p, const char *esc) { while (s <= p) { char c = *p++; @@ -427,7 +427,7 @@ EXPORT_SYMBOL(mangle_path); * return the absolute path of 'path', as represented by the * dentry / mnt pair in the path parameter. */ -int seq_path(struct seq_file *m, struct path *path, char *esc) +int seq_path(struct seq_file *m, const struct path *path, const char *esc) { char *buf; size_t size = seq_get_buf(m, &buf); @@ -450,8 +450,8 @@ EXPORT_SYMBOL(seq_path); /* * Same as seq_path, but relative to supplied root. */ -int seq_path_root(struct seq_file *m, struct path *path, struct path *root, - char *esc) +int seq_path_root(struct seq_file *m, const struct path *path, + const struct path *root, const char *esc) { char *buf; 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, /* * returns the path of the 'dentry' from the root of its filesystem. */ -int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc) +int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc) { char *buf; size_t size = seq_get_buf(m, &buf); diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 0b69a4684216..44f1514b00ba 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -74,7 +74,7 @@ static inline void seq_commit(struct seq_file *m, int num) } } -char *mangle_path(char *s, char *p, char *esc); +char *mangle_path(char *s, const char *p, const char *esc); int seq_open(struct file *, const struct seq_operations *); ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); loff_t seq_lseek(struct file *, loff_t, int); @@ -86,10 +86,10 @@ int seq_write(struct seq_file *seq, const void *data, size_t len); __printf(2, 3) int seq_printf(struct seq_file *, const char *, ...); -int seq_path(struct seq_file *, struct path *, char *); -int seq_dentry(struct seq_file *, struct dentry *, char *); -int seq_path_root(struct seq_file *m, struct path *path, struct path *root, - char *esc); +int seq_path(struct seq_file *, const struct path *, const char *); +int seq_dentry(struct seq_file *, struct dentry *, const char *); +int seq_path_root(struct seq_file *m, const struct path *path, + const struct path *root, const char *esc); int seq_bitmap(struct seq_file *m, const unsigned long *bits, unsigned int nr_bits); static inline int seq_cpumask(struct seq_file *m, const struct cpumask *mask) From 2a79f17e4a641a2f463cb512cb0ec349844a147b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 9 Dec 2011 08:06:57 -0500 Subject: [PATCH 018/165] vfs: mnt_drop_write_file() new helper (wrapper around mnt_drop_write()) to be used in pair with mnt_want_write_file(). Signed-off-by: Al Viro --- fs/btrfs/ioctl.c | 12 ++++++------ fs/ext2/ioctl.c | 6 +++--- fs/ext3/ioctl.c | 10 +++++----- fs/ext4/ioctl.c | 14 +++++++------- fs/fat/file.c | 2 +- fs/gfs2/file.c | 2 +- fs/hfsplus/ioctl.c | 2 +- fs/inode.c | 2 +- fs/jfs/ioctl.c | 2 +- fs/namespace.c | 6 ++++++ fs/ncpfs/ioctl.c | 2 +- fs/nfsd/nfs4recover.c | 6 +++--- fs/nilfs2/ioctl.c | 12 ++++++------ fs/ocfs2/ioctl.c | 2 +- fs/ocfs2/move_extents.c | 2 +- fs/open.c | 2 +- fs/reiserfs/ioctl.c | 4 ++-- fs/ubifs/ioctl.c | 2 +- fs/xattr.c | 4 ++-- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_ioctl32.c | 4 ++-- include/linux/mount.h | 1 + 22 files changed, 55 insertions(+), 48 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 20dd8f3b6c72..5441ff1480fd 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -259,7 +259,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) btrfs_end_transaction(trans, root); - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); ret = 0; out_unlock: @@ -1971,7 +1971,7 @@ out_dput: dput(dentry); out_unlock_dir: mutex_unlock(&dir->i_mutex); - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); out: kfree(vol_args); return err; @@ -2040,7 +2040,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp) ret = -EINVAL; } out: - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); return ret; } @@ -2510,7 +2510,7 @@ out_unlock: out_fput: fput(src_file); out_drop_write: - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); return ret; } @@ -2565,7 +2565,7 @@ static long btrfs_ioctl_trans_start(struct file *file) out_drop: atomic_dec(&root->fs_info->open_ioctl_trans); - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); out: return ret; } @@ -2800,7 +2800,7 @@ long btrfs_ioctl_trans_end(struct file *file) atomic_dec(&root->fs_info->open_ioctl_trans); - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); return 0; } diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c index 61a3f9661728..1089f760c847 100644 --- a/fs/ext2/ioctl.c +++ b/fs/ext2/ioctl.c @@ -83,7 +83,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) inode->i_ctime = CURRENT_TIME_SEC; mark_inode_dirty(inode); setflags_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return ret; } case EXT2_IOC_GETVERSION: @@ -100,7 +100,7 @@ setflags_out: inode->i_ctime = CURRENT_TIME_SEC; mark_inode_dirty(inode); } - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return ret; case EXT2_IOC_GETRSVSZ: if (test_opt(inode->i_sb, RESERVATION) @@ -145,7 +145,7 @@ setflags_out: rsv->rsv_goal_size = rsv_window_size; } mutex_unlock(&ei->truncate_mutex); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return 0; } default: diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c index a02863a080d3..8e37c41a071b 100644 --- a/fs/ext3/ioctl.c +++ b/fs/ext3/ioctl.c @@ -110,7 +110,7 @@ flags_err: err = ext3_change_inode_journal_flag(inode, jflag); flags_out: mutex_unlock(&inode->i_mutex); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } case EXT3_IOC_GETVERSION: @@ -147,7 +147,7 @@ flags_out: } ext3_journal_stop(handle); setversion_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } case EXT3_IOC_GETRSVSZ: @@ -195,7 +195,7 @@ setversion_out: } mutex_unlock(&ei->truncate_mutex); setrsvsz_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } case EXT3_IOC_GROUP_EXTEND: { @@ -221,7 +221,7 @@ setrsvsz_out: if (err == 0) err = err2; group_extend_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } case EXT3_IOC_GROUP_ADD: { @@ -249,7 +249,7 @@ group_extend_out: if (err == 0) err = err2; group_add_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } case FITRIM: { diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 9a49760b554d..d37b3bb2a3b8 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -134,7 +134,7 @@ flags_err: err = ext4_ext_migrate(inode); flags_out: mutex_unlock(&inode->i_mutex); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } case EXT4_IOC_GETVERSION: @@ -171,7 +171,7 @@ flags_out: } ext4_journal_stop(handle); setversion_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } case EXT4_IOC_GROUP_EXTEND: { @@ -204,7 +204,7 @@ setversion_out: } if (err == 0) err = err2; - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); ext4_resize_end(sb); return err; @@ -246,7 +246,7 @@ setversion_out: err = ext4_move_extents(filp, donor_filp, me.orig_start, me.donor_start, me.len, &me.moved_len); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); if (me.moved_len > 0) file_remove_suid(donor_filp); @@ -289,7 +289,7 @@ mext_out: } if (err == 0) err = err2; - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); ext4_resize_end(sb); return err; @@ -313,7 +313,7 @@ mext_out: mutex_lock(&(inode->i_mutex)); err = ext4_ext_migrate(inode); mutex_unlock(&(inode->i_mutex)); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } @@ -327,7 +327,7 @@ mext_out: if (err) return err; err = ext4_alloc_da_blocks(inode); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } diff --git a/fs/fat/file.c b/fs/fat/file.c index 50746a1a0789..d81d01a99b2c 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -108,7 +108,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr) fat_save_attrs(inode, attr); mark_inode_dirty(inode); out_drop_write: - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); out_unlock_inode: mutex_unlock(&inode->i_mutex); out: diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 28fc6e3855f3..b8927d4f3bf2 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -285,7 +285,7 @@ out_trans_end: out: gfs2_glock_dq_uninit(&gh); out_drop_write: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return error; } diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c index 31d3fe576429..f66c7655b3f7 100644 --- a/fs/hfsplus/ioctl.c +++ b/fs/hfsplus/ioctl.c @@ -94,7 +94,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags) out_unlock_inode: mutex_unlock(&inode->i_mutex); out_drop_write: - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); out: return err; } diff --git a/fs/inode.c b/fs/inode.c index ee4e66b998f4..4fda5ee85518 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1508,7 +1508,7 @@ void file_update_time(struct file *file) if (sync_it & S_MTIME) inode->i_mtime = now; mark_inode_dirty_sync(inode); - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); } EXPORT_SYMBOL(file_update_time); diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c index 73d9eaa91c05..f19d1e04a374 100644 --- a/fs/jfs/ioctl.c +++ b/fs/jfs/ioctl.c @@ -120,7 +120,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) inode->i_ctime = CURRENT_TIME_SEC; mark_inode_dirty(inode); setflags_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return err; } default: diff --git a/fs/namespace.c b/fs/namespace.c index 7a8f949cec1b..86b4f6406470 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -392,6 +392,12 @@ void mnt_drop_write(struct vfsmount *mnt) } EXPORT_SYMBOL_GPL(mnt_drop_write); +void mnt_drop_write_file(struct file *file) +{ + mnt_drop_write(file->f_path.mnt); +} +EXPORT_SYMBOL(mnt_drop_write_file); + static int mnt_make_readonly(struct vfsmount *mnt) { int ret = 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) ret = __ncp_ioctl(inode, cmd, arg); outDropWrite: if (need_drop_write) - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); out: return ret; } diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index a9aa2f161262..80a0be9ed008 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -151,7 +151,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp) if (status) goto out_put; status = vfs_mkdir(dir->d_inode, dentry, S_IRWXU); - mnt_drop_write(rec_file->f_path.mnt); + mnt_drop_write_file(rec_file); out_put: dput(dentry); out_unlock: @@ -281,7 +281,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp) nfs4_reset_creds(original_cred); if (status == 0) vfs_fsync(rec_file, 0); - mnt_drop_write(rec_file->f_path.mnt); + mnt_drop_write_file(rec_file); out: if (status) printk("NFSD: Failed to remove expired client state directory" @@ -317,7 +317,7 @@ nfsd4_recdir_purge_old(void) { status = nfsd4_list_rec_dir(purge_old); if (status == 0) vfs_fsync(rec_file, 0); - mnt_drop_write(rec_file->f_path.mnt); + mnt_drop_write_file(rec_file); out: if (status) printk("nfsd4: failed to purge old clients from recovery" diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index b7697d1ccd61..886649627c3d 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c @@ -27,7 +27,7 @@ #include /* copy_from_user(), copy_to_user() */ #include #include /* compat_ptr() */ -#include /* mnt_want_write_file(), mnt_drop_write() */ +#include /* mnt_want_write_file(), mnt_drop_write_file() */ #include #include #include "nilfs.h" @@ -154,7 +154,7 @@ static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp, ret = nilfs_transaction_commit(inode->i_sb); out: mutex_unlock(&inode->i_mutex); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return ret; } @@ -194,7 +194,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp, up_read(&inode->i_sb->s_umount); out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return ret; } @@ -225,7 +225,7 @@ nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp, else nilfs_transaction_commit(inode->i_sb); /* never fails */ out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return ret; } @@ -675,7 +675,7 @@ out_free: vfree(kbufs[n]); kfree(kbufs[4]); out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return ret; } @@ -721,7 +721,7 @@ static int nilfs_ioctl_resize(struct inode *inode, struct file *filp, ret = nilfs_resize_fs(inode->i_sb, newsize); out_drop_write: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); out: return ret; } diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index 892ace253f97..a6fda3c188aa 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -911,7 +911,7 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return status; status = ocfs2_set_inode_attr(inode, flags, OCFS2_FL_MODIFIABLE); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return status; case OCFS2_IOC_RESVSP: case OCFS2_IOC_RESVSP64: diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index 1d3bf83f8b85..b1e3fce72ea4 100644 --- a/fs/ocfs2/move_extents.c +++ b/fs/ocfs2/move_extents.c @@ -1145,7 +1145,7 @@ out: kfree(context); - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); return status; } diff --git a/fs/open.c b/fs/open.c index 22c41b543f2d..4ef8d868a448 100644 --- a/fs/open.c +++ b/fs/open.c @@ -608,7 +608,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group) dentry = file->f_path.dentry; audit_inode(NULL, dentry); error = chown_common(&file->f_path, user, group); - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); out_fput: fput(file); out: diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c index 0b94d7b2b11f..950e3d1b5c9e 100644 --- a/fs/reiserfs/ioctl.c +++ b/fs/reiserfs/ioctl.c @@ -96,7 +96,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) inode->i_ctime = CURRENT_TIME_SEC; mark_inode_dirty(inode); setflags_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); break; } case REISERFS_IOC_GETVERSION: @@ -117,7 +117,7 @@ setflags_out: inode->i_ctime = CURRENT_TIME_SEC; mark_inode_dirty(inode); setversion_out: - mnt_drop_write(filp->f_path.mnt); + mnt_drop_write_file(filp); break; default: err = -ENOTTY; diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c index e52c84598feb..1a7e2d8bdbe9 100644 --- a/fs/ubifs/ioctl.c +++ b/fs/ubifs/ioctl.c @@ -178,7 +178,7 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return err; dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags); err = setflags(inode, flags); - mnt_drop_write(file->f_path.mnt); + mnt_drop_write_file(file); return err; } 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, error = mnt_want_write_file(f); if (!error) { error = setxattr(dentry, name, value, size, flags); - mnt_drop_write(f->f_path.mnt); + mnt_drop_write_file(f); } fput(f); return error; @@ -624,7 +624,7 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) error = mnt_want_write_file(f); if (!error) { error = removexattr(dentry, name); - mnt_drop_write(f->f_path.mnt); + mnt_drop_write_file(f); } fput(f); return error; diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index b436e17c753e..76f3ca5cfc36 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -566,7 +566,7 @@ xfs_attrmulti_by_handle( dentry->d_inode, attr_name, ops[i].am_attrvalue, ops[i].am_length, ops[i].am_flags); - mnt_drop_write(parfilp->f_path.mnt); + mnt_drop_write_file(parfilp); break; case ATTR_OP_REMOVE: ops[i].am_error = mnt_want_write_file(parfilp); @@ -575,7 +575,7 @@ xfs_attrmulti_by_handle( ops[i].am_error = xfs_attrmulti_attr_remove( dentry->d_inode, attr_name, ops[i].am_flags); - mnt_drop_write(parfilp->f_path.mnt); + mnt_drop_write_file(parfilp); break; default: ops[i].am_error = EINVAL; diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index dd4ba1d4c582..f9ccb7b7c043 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -461,7 +461,7 @@ xfs_compat_attrmulti_by_handle( dentry->d_inode, attr_name, compat_ptr(ops[i].am_attrvalue), ops[i].am_length, ops[i].am_flags); - mnt_drop_write(parfilp->f_path.mnt); + mnt_drop_write_file(parfilp); break; case ATTR_OP_REMOVE: ops[i].am_error = mnt_want_write_file(parfilp); @@ -470,7 +470,7 @@ xfs_compat_attrmulti_by_handle( ops[i].am_error = xfs_attrmulti_attr_remove( dentry->d_inode, attr_name, ops[i].am_flags); - mnt_drop_write(parfilp->f_path.mnt); + mnt_drop_write_file(parfilp); break; default: ops[i].am_error = EINVAL; diff --git a/include/linux/mount.h b/include/linux/mount.h index 65c1bb013836..00f5c4f2160b 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -94,6 +94,7 @@ extern int mnt_want_write(struct vfsmount *mnt); extern int mnt_want_write_file(struct file *file); extern int mnt_clone_write(struct vfsmount *mnt); extern void mnt_drop_write(struct vfsmount *mnt); +extern void mnt_drop_write_file(struct file *file); extern void mntput(struct vfsmount *mnt); extern struct vfsmount *mntget(struct vfsmount *mnt); extern void mnt_pin(struct vfsmount *mnt); From 6b520e0565422966cdf1c3759bd73df77b0f248c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 12 Dec 2011 15:51:45 -0500 Subject: [PATCH 019/165] vfs: fix the stupidity with i_dentry in inode destructors Seeing that just about every destructor got that INIT_LIST_HEAD() copied into it, there is no point whatsoever keeping this INIT_LIST_HEAD in inode_init_once(); the cost of taking it into inode_init_always() will be negligible for pipes and sockets and negative for everything else. Not to mention the removal of boilerplate code from ->destroy_inode() instances... Signed-off-by: Al Viro --- arch/powerpc/platforms/cell/spufs/inode.c | 1 - drivers/staging/pohmelfs/inode.c | 1 - fs/9p/vfs_inode.c | 1 - fs/affs/super.c | 1 - fs/afs/super.c | 1 - fs/befs/linuxvfs.c | 1 - fs/bfs/inode.c | 1 - fs/block_dev.c | 1 - fs/btrfs/inode.c | 1 - fs/ceph/inode.c | 1 - fs/coda/inode.c | 1 - fs/ecryptfs/super.c | 1 - fs/efs/super.c | 1 - fs/exofs/super.c | 1 - fs/ext2/super.c | 1 - fs/ext3/super.c | 1 - fs/ext4/super.c | 1 - fs/fat/inode.c | 1 - fs/freevxfs/vxfs_inode.c | 1 - fs/fuse/inode.c | 1 - fs/gfs2/super.c | 1 - fs/hfs/super.c | 1 - fs/hfsplus/super.c | 1 - fs/hostfs/hostfs_kern.c | 1 - fs/hpfs/super.c | 1 - fs/hppfs/hppfs.c | 1 - fs/hugetlbfs/inode.c | 1 - fs/inode.c | 3 +-- fs/isofs/inode.c | 1 - fs/jffs2/super.c | 1 - fs/jfs/super.c | 1 - fs/logfs/inode.c | 1 - fs/minix/inode.c | 1 - fs/ncpfs/inode.c | 1 - fs/nfs/inode.c | 1 - fs/nilfs2/super.c | 2 -- fs/ntfs/inode.c | 1 - fs/ocfs2/dlmfs/dlmfs.c | 1 - fs/ocfs2/super.c | 1 - fs/openpromfs/inode.c | 1 - fs/proc/inode.c | 1 - fs/qnx4/inode.c | 1 - fs/reiserfs/super.c | 1 - fs/romfs/super.c | 1 - fs/squashfs/super.c | 1 - fs/sysv/inode.c | 1 - fs/ubifs/super.c | 1 - fs/udf/super.c | 1 - fs/ufs/super.c | 1 - fs/xfs/xfs_iget.c | 1 - ipc/mqueue.c | 1 - mm/shmem.c | 1 - net/sunrpc/rpc_pipe.c | 1 - 53 files changed, 1 insertion(+), 55 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index e481f6b9a789..d85f8cbdc8b3 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -74,7 +74,6 @@ spufs_alloc_inode(struct super_block *sb) static void spufs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(spufs_inode_cache, SPUFS_I(inode)); } diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c index 7a1955583b7d..6c12516826ad 100644 --- a/drivers/staging/pohmelfs/inode.c +++ b/drivers/staging/pohmelfs/inode.c @@ -830,7 +830,6 @@ const struct address_space_operations pohmelfs_aops = { static void pohmelfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(pohmelfs_inode_cache, POHMELFS_I(inode)); } diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 879ed8851737..2310cc9eb402 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -251,7 +251,6 @@ struct inode *v9fs_alloc_inode(struct super_block *sb) static void v9fs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(v9fs_inode_cache, V9FS_I(inode)); } 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) static void affs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); } 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) { struct inode *inode = container_of(head, struct inode, i_rcu); struct afs_vnode *vnode = AFS_FS_I(inode); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(afs_inode_cachep, vnode); } 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) static void befs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); } 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) static void bfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); } diff --git a/fs/block_dev.c b/fs/block_dev.c index 4b322a58a513..7866cdd9fe70 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -425,7 +425,6 @@ static void bdev_i_callback(struct rcu_head *head) struct inode *inode = container_of(head, struct inode, i_rcu); struct bdev_inode *bdi = BDEV_I(inode); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(bdev_cachep, bdi); } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index fd1a06df5bc6..f8ff9738558a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6761,7 +6761,6 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) static void btrfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); } 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) struct inode *inode = container_of(head, struct inode, i_rcu); struct ceph_inode_info *ci = ceph_inode(inode); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ceph_inode_cachep, ci); } 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) static void coda_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(coda_inode_cachep, ITOC(inode)); } diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c index dbd52d40df4c..da485f0b4d1e 100644 --- a/fs/ecryptfs/super.c +++ b/fs/ecryptfs/super.c @@ -69,7 +69,6 @@ static void ecryptfs_i_callback(struct rcu_head *head) struct ecryptfs_inode_info *inode_info; inode_info = ecryptfs_inode_to_private(inode); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ecryptfs_inode_info_cache, inode_info); } 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) static void efs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); } 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) static void exofs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(exofs_inode_cachep, exofs_i(inode)); } diff --git a/fs/ext2/super.c b/fs/ext2/super.c index bd8ac164a3bf..67b5e752ec9d 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) static void ext2_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); } diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 922d289aeeb3..668c931b2214 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -511,7 +511,6 @@ static int ext3_drop_inode(struct inode *inode) static void ext3_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); } diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 3e1329e2f826..2a1a9e63cffa 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -930,7 +930,6 @@ static int ext4_drop_inode(struct inode *inode) static void ext4_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); } diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 808cac7edcfb..ef44e5f98ced 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) static void fat_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); } diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c index 7b2af5abe2fa..41ef6e715d2f 100644 --- a/fs/freevxfs/vxfs_inode.c +++ b/fs/freevxfs/vxfs_inode.c @@ -340,7 +340,6 @@ vxfs_iget(struct super_block *sbp, ino_t ino) static void vxfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(vxfs_inode_cachep, inode->i_private); } diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index aa83109b9431..3d3622a1ceac 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) static void fuse_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(fuse_inode_cachep, inode); } diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 71e420989f77..9e89d94be003 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -1582,7 +1582,6 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb) static void gfs2_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(gfs2_inode_cachep, inode); } diff --git a/fs/hfs/super.c b/fs/hfs/super.c index 1b55f704fb22..32dc2fbb26d5 100644 --- a/fs/hfs/super.c +++ b/fs/hfs/super.c @@ -170,7 +170,6 @@ static struct inode *hfs_alloc_inode(struct super_block *sb) static void hfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(hfs_inode_cachep, HFS_I(inode)); } 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) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(hfsplus_inode_cachep, HFSPLUS_I(inode)); } diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 2f72da5ae686..343ea632b97c 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) static void hostfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kfree(HOSTFS_I(inode)); } 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) static void hpfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); } diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c index f590b1160c6c..30883a7adacb 100644 --- a/fs/hppfs/hppfs.c +++ b/fs/hppfs/hppfs.c @@ -622,7 +622,6 @@ void hppfs_evict_inode(struct inode *ino) static void hppfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kfree(HPPFS_I(inode)); } diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 0be5a78598d0..9c4ec538725b 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -666,7 +666,6 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) static void hugetlbfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); } diff --git a/fs/inode.c b/fs/inode.c index 4fda5ee85518..24d02907e196 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -191,6 +191,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode) } inode->i_private = NULL; inode->i_mapping = mapping; + INIT_LIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */ #ifdef CONFIG_FS_POSIX_ACL inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED; #endif @@ -254,7 +255,6 @@ EXPORT_SYMBOL(__destroy_inode); static void i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(inode_cachep, inode); } @@ -290,7 +290,6 @@ void inode_init_once(struct inode *inode) { memset(inode, 0, sizeof(*inode)); INIT_HLIST_NODE(&inode->i_hash); - INIT_LIST_HEAD(&inode->i_dentry); INIT_LIST_HEAD(&inode->i_devices); INIT_LIST_HEAD(&inode->i_wb_list); INIT_LIST_HEAD(&inode->i_lru); diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index f950059525fc..b71f6311a337 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) static void isofs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); } diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index e7e974454115..804e1292d63e 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) static void jffs2_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); } diff --git a/fs/jfs/super.c b/fs/jfs/super.c index a44eff076c17..1b8f4ca29adf 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -119,7 +119,6 @@ static void jfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); struct jfs_inode_info *ji = JFS_IP(inode); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(jfs_inode_cachep, ji); } diff --git a/fs/logfs/inode.c b/fs/logfs/inode.c index 7e441ad5f792..4d1af42bfd24 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) static void logfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(logfs_inode_cache, logfs_inode(inode)); } diff --git a/fs/minix/inode.c b/fs/minix/inode.c index 1d9e33966db0..c811c19d31be 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) static void minix_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(minix_inode_cachep, minix_i(inode)); } diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index cbd1a61c110a..f3f07cd392b3 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c @@ -60,7 +60,6 @@ static struct inode *ncp_alloc_inode(struct super_block *sb) static void ncp_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); } diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index efb66db04f99..6f00086e340f 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1464,7 +1464,6 @@ struct inode *nfs_alloc_inode(struct super_block *sb) static void nfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(nfs_inode_cachep, NFS_I(inode)); } diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 8351c44a7320..5356c7169d50 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -175,8 +175,6 @@ static void nilfs_i_callback(struct rcu_head *head) struct inode *inode = container_of(head, struct inode, i_rcu); struct nilfs_mdt_info *mdi = NILFS_MDT(inode); - INIT_LIST_HEAD(&inode->i_dentry); - if (mdi) { kfree(mdi->mi_bgl); /* kfree(NULL) is safe */ kfree(mdi); diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 97e2dacbc867..fea40bb6fb68 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) static void ntfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode)); } diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index b42076797049..a9f007de1da8 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) static void dlmfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(dlmfs_inode_cache, DLMFS_I(inode)); } diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 4994f8b0e604..c05ff25c356c 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -569,7 +569,6 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb) static void ocfs2_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode)); } 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) static void openprom_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(op_inode_cachep, OP_I(inode)); } 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) static void proc_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(proc_inode_cachep, PROC_I(inode)); } 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) static void qnx4_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); } diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 14363b96b6af..5a4cae7efc43 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -532,7 +532,6 @@ static struct inode *reiserfs_alloc_inode(struct super_block *sb) static void reiserfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); } 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) static void romfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); } 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) static void squashfs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(squashfs_inode_cachep, squashfs_i(inode)); } 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) static void sysv_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); } diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index ae0e76bb6ebf..d93a3fadf53c 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -276,7 +276,6 @@ static void ubifs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); struct ubifs_inode *ui = ubifs_inode(inode); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ubifs_inode_slab, ui); } diff --git a/fs/udf/super.c b/fs/udf/super.c index e185253470df..7cbe669e1026 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -138,7 +138,6 @@ static struct inode *udf_alloc_inode(struct super_block *sb) static void udf_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(udf_inode_cachep, UDF_I(inode)); } diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 3915ade6f9a8..d6961eb5b774 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -1425,7 +1425,6 @@ static struct inode *ufs_alloc_inode(struct super_block *sb) static void ufs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); } 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( struct inode *inode = container_of(head, struct inode, i_rcu); struct xfs_inode *ip = XFS_I(inode); - INIT_LIST_HEAD(&inode->i_dentry); kmem_zone_free(xfs_inode_zone, ip); } diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 5b4293d9819d..4e0be364aa36 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -243,7 +243,6 @@ static struct inode *mqueue_alloc_inode(struct super_block *sb) static void mqueue_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(mqueue_inode_cachep, MQUEUE_I(inode)); } diff --git a/mm/shmem.c b/mm/shmem.c index d6722506d2da..c58594c06569 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2234,7 +2234,6 @@ static struct inode *shmem_alloc_inode(struct super_block *sb) static void shmem_destroy_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode)); } diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index bfddd68b31d3..60564bcb8067 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -185,7 +185,6 @@ static void rpc_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu); - INIT_LIST_HEAD(&inode->i_dentry); kmem_cache_free(rpc_inode_cachep, RPC_I(inode)); } From 84b92d39f98f669a3073168f88692782aec525a8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 18 Dec 2011 20:17:41 -0500 Subject: [PATCH 020/165] vfs: pipe.c is really non-modular ... so no exitcalls there. Not much would work if pipe(2) would stop working, after all... Signed-off-by: Al Viro --- fs/pipe.c | 7 ------- 1 file changed, 7 deletions(-) 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) return err; } -static void __exit exit_pipe_fs(void) -{ - kern_unmount(pipe_mnt); - unregister_filesystem(&pipe_fs_type); -} - fs_initcall(init_pipe_fs); -module_exit(exit_pipe_fs); From 32dc730860155b235f13e0cd3fe58b263279baf9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Dec 2011 20:08:42 -0500 Subject: [PATCH 021/165] get rid of timer in kern/acct.c ... and clean it up a bit, while we are at it Signed-off-by: Al Viro --- kernel/acct.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/kernel/acct.c b/kernel/acct.c index fa7eb3de2ddc..8cba12429d82 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -84,26 +84,16 @@ static void do_acct_process(struct bsd_acct_struct *acct, * the cache line to have the data after getting the lock. */ struct bsd_acct_struct { - volatile int active; - volatile int needcheck; + int active; + unsigned long needcheck; struct file *file; struct pid_namespace *ns; - struct timer_list timer; struct list_head list; }; static DEFINE_SPINLOCK(acct_lock); static LIST_HEAD(acct_list); -/* - * Called whenever the timer says to check the free space. - */ -static void acct_timeout(unsigned long x) -{ - struct bsd_acct_struct *acct = (struct bsd_acct_struct *)x; - acct->needcheck = 1; -} - /* * Check the amount of free space and suspend/resume accordingly. */ @@ -112,12 +102,12 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file) struct kstatfs sbuf; int res; int act; - sector_t resume; - sector_t suspend; + u64 resume; + u64 suspend; spin_lock(&acct_lock); res = acct->active; - if (!file || !acct->needcheck) + if (!file || time_is_before_jiffies(acct->needcheck)) goto out; spin_unlock(&acct_lock); @@ -127,8 +117,8 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file) suspend = sbuf.f_blocks * SUSPEND; resume = sbuf.f_blocks * RESUME; - sector_div(suspend, 100); - sector_div(resume, 100); + do_div(suspend, 100); + do_div(resume, 100); if (sbuf.f_bavail <= suspend) act = -1; @@ -160,10 +150,7 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file) } } - del_timer(&acct->timer); - acct->needcheck = 0; - acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; - add_timer(&acct->timer); + acct->needcheck = jiffies + ACCT_TIMEOUT*HZ; res = acct->active; out: spin_unlock(&acct_lock); @@ -185,9 +172,7 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file, if (acct->file) { old_acct = acct->file; old_ns = acct->ns; - del_timer(&acct->timer); acct->active = 0; - acct->needcheck = 0; acct->file = NULL; acct->ns = NULL; list_del(&acct->list); @@ -195,13 +180,9 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file, if (file) { acct->file = file; acct->ns = ns; - acct->needcheck = 0; + acct->needcheck = jiffies + ACCT_TIMEOUT*HZ; acct->active = 1; list_add(&acct->list, &acct_list); - /* It's been deleted if it was used before so this is safe */ - setup_timer(&acct->timer, acct_timeout, (unsigned long)acct); - acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; - add_timer(&acct->timer); } if (old_acct) { mnt_unpin(old_acct->f_path.mnt); @@ -348,7 +329,6 @@ void acct_exit_ns(struct pid_namespace *ns) if (acct == NULL) return; - del_timer_sync(&acct->timer); spin_lock(&acct_lock); if (acct->file != NULL) acct_file_reopen(acct, NULL, NULL); @@ -498,7 +478,7 @@ static void do_acct_process(struct bsd_acct_struct *acct, * Fill the accounting struct with the needed info as recorded * by the different kernel functions. */ - memset((caddr_t)&ac, 0, sizeof(acct_t)); + memset(&ac, 0, sizeof(acct_t)); ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER; strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm)); From 4c1d5a64f134b254552b6211f6f79a1da667eab7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 7 Dec 2011 18:21:57 -0500 Subject: [PATCH 022/165] vfs: for usbfs, etc. internal vfsmounts ->mnt_sb->s_root == ->mnt_root Signed-off-by: Al Viro --- arch/ia64/kernel/perfmon.c | 2 +- drivers/usb/core/inode.c | 6 +++--- fs/configfs/dir.c | 2 +- fs/debugfs/inode.c | 2 +- fs/hppfs/hppfs.c | 2 +- security/inode.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index 89accc626b86..b2c65e034f5d 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c @@ -2228,7 +2228,7 @@ pfm_alloc_file(pfm_context_t *ctx) /* * allocate a new dcache entry */ - path.dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this); + path.dentry = d_alloc(pfmfs_mnt->mnt_root, &this); if (!path.dentry) { iput(inode); return ERR_PTR(-ENOMEM); diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 2278dad886e2..0a4613df6c30 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c @@ -501,7 +501,7 @@ static int fs_create_by_name (const char *name, mode_t mode, */ if (!parent ) { if (usbfs_mount && usbfs_mount->mnt_sb) { - parent = usbfs_mount->mnt_sb->s_root; + parent = usbfs_mount->mnt_root; } } @@ -608,7 +608,7 @@ static int create_special_files (void) ignore_mount = 0; - parent = usbfs_mount->mnt_sb->s_root; + parent = usbfs_mount->mnt_root; devices_usbfs_dentry = fs_create_file ("devices", listmode | S_IFREG, parent, NULL, &usbfs_devices_fops, @@ -662,7 +662,7 @@ static void usbfs_add_bus(struct usb_bus *bus) sprintf (name, "%03d", bus->busnum); - parent = usbfs_mount->mnt_sb->s_root; + parent = usbfs_mount->mnt_root; bus->usbfs_dentry = fs_create_file (name, busmode | S_IFDIR, parent, bus, NULL, busuid, busgid); if (bus->usbfs_dentry == NULL) { diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 9a37a9b6de3a..36b1d7aadba1 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -312,7 +312,7 @@ static int configfs_create_dir(struct config_item * item, struct dentry *dentry) if (item->ci_parent) parent = item->ci_parent->ci_dentry; else if (configfs_mount && configfs_mount->mnt_sb) - parent = configfs_mount->mnt_sb->s_root; + parent = configfs_mount->mnt_root; else return -EFAULT; diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index f3a257d7a985..c9dc08d0c100 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -160,7 +160,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode, * have around. */ if (!parent) - parent = debugfs_mount->mnt_sb->s_root; + parent = debugfs_mount->mnt_root; *dentry = NULL; mutex_lock(&parent->d_inode->i_mutex); diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c index 30883a7adacb..d92f4ce80925 100644 --- a/fs/hppfs/hppfs.c +++ b/fs/hppfs/hppfs.c @@ -725,7 +725,7 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent) sb->s_fs_info = proc_mnt; err = -ENOMEM; - root_inode = get_inode(sb, dget(proc_mnt->mnt_sb->s_root)); + root_inode = get_inode(sb, dget(proc_mnt->mnt_root)); if (!root_inode) goto out_mntput; diff --git a/security/inode.c b/security/inode.c index c4df2fbebe6b..a67004f9d106 100644 --- a/security/inode.c +++ b/security/inode.c @@ -159,7 +159,7 @@ static int create_by_name(const char *name, mode_t mode, * have around. */ if (!parent) - parent = mount->mnt_sb->s_root; + parent = mount->mnt_root; mutex_lock(&parent->d_inode->i_mutex); *dentry = lookup_one_len(name, parent, strlen(name)); From c972b4bc8331b432f51a5f1bc3ca7e020172717f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Dec 2011 23:01:06 -0500 Subject: [PATCH 023/165] vfs: live vfsmounts never have NULL ->mnt_sb Signed-off-by: Al Viro --- drivers/usb/core/inode.c | 5 ++--- fs/configfs/dir.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 0a4613df6c30..783fde7f44c8 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c @@ -264,7 +264,7 @@ static int remount(struct super_block *sb, int *flags, char *data) return -EINVAL; } - if (usbfs_mount && usbfs_mount->mnt_sb) + if (usbfs_mount) update_sb(usbfs_mount->mnt_sb); return 0; @@ -500,9 +500,8 @@ static int fs_create_by_name (const char *name, mode_t mode, * have around. */ if (!parent ) { - if (usbfs_mount && usbfs_mount->mnt_sb) { + if (usbfs_mount) parent = usbfs_mount->mnt_root; - } } if (!parent) { diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 36b1d7aadba1..1c5296911104 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -311,7 +311,7 @@ static int configfs_create_dir(struct config_item * item, struct dentry *dentry) if (item->ci_parent) parent = item->ci_parent->ci_dentry; - else if (configfs_mount && configfs_mount->mnt_sb) + else if (configfs_mount) parent = configfs_mount->mnt_root; else return -EFAULT; From cf31e70d6cf93f19fe9bf1144966ef40991ac723 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 2 Jan 2012 22:28:36 -0500 Subject: [PATCH 024/165] vfs: new helper - vfs_ustat() ... and bury user_get_super()/statfs_by_dentry() - they are purely internal now. Signed-off-by: Al Viro --- arch/parisc/hpux/sys_hpux.c | 9 +-------- fs/compat.c | 9 +-------- fs/internal.h | 1 + fs/statfs.c | 21 +++++++++++++-------- include/linux/fs.h | 3 +-- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/arch/parisc/hpux/sys_hpux.c b/arch/parisc/hpux/sys_hpux.c index 6ab9580b0b00..d9dc6cd3b7d2 100644 --- a/arch/parisc/hpux/sys_hpux.c +++ b/arch/parisc/hpux/sys_hpux.c @@ -136,16 +136,9 @@ struct hpux_ustat { */ static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf) { - struct super_block *s; struct hpux_ustat tmp; /* Changed to hpux_ustat */ struct kstatfs sbuf; - int err = -EINVAL; - - s = user_get_super(dev); - if (s == NULL) - goto out; - err = statfs_by_dentry(s->s_root, &sbuf); - drop_super(s); + int err = vfs_ustat(dev, &sbuf); if (err) goto out; diff --git a/fs/compat.c b/fs/compat.c index c98787536bb8..9db5a6076610 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 */ asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u) { - struct super_block *sb; struct compat_ustat tmp; struct kstatfs sbuf; - int err; - - sb = user_get_super(new_decode_dev(dev)); - if (!sb) - return -EINVAL; - err = statfs_by_dentry(sb->s_root, &sbuf); - drop_super(sb); + int err = vfs_ustat(new_decode_dev(dev), &sbuf); if (err) return err; diff --git a/fs/internal.h b/fs/internal.h index 839d3f9e9173..7b1cb1528ac2 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -78,6 +78,7 @@ extern int do_remount_sb(struct super_block *, int, void *, int); extern bool grab_super_passive(struct super_block *sb); extern struct dentry *mount_fs(struct file_system_type *, int, const char *, void *); +extern struct super_block *user_get_super(dev_t); /* * open.c 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 @@ #include #include #include +#include "internal.h" static int flags_by_mnt(int mnt_flags) { @@ -45,7 +46,7 @@ static int calculate_f_flags(struct vfsmount *mnt) flags_by_sb(mnt->mnt_sb->s_flags); } -int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf) +static int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf) { int retval; @@ -205,19 +206,23 @@ SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user return error; } -SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf) +int vfs_ustat(dev_t dev, struct kstatfs *sbuf) { - struct super_block *s; - struct ustat tmp; - struct kstatfs sbuf; + struct super_block *s = user_get_super(dev); int err; - - s = user_get_super(new_decode_dev(dev)); if (!s) return -EINVAL; - err = statfs_by_dentry(s->s_root, &sbuf); + err = statfs_by_dentry(s->s_root, sbuf); drop_super(s); + return err; +} + +SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf) +{ + struct ustat tmp; + struct kstatfs sbuf; + int err = vfs_ustat(new_decode_dev(dev), &sbuf); if (err) return err; diff --git a/include/linux/fs.h b/include/linux/fs.h index ed17e54fd204..cec429d76ab0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1939,7 +1939,7 @@ extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, extern int vfs_statfs(struct path *, struct kstatfs *); extern int user_statfs(const char __user *, struct kstatfs *); extern int fd_statfs(int, struct kstatfs *); -extern int statfs_by_dentry(struct dentry *, struct kstatfs *); +extern int vfs_ustat(dev_t, struct kstatfs *); extern int freeze_super(struct super_block *super); extern int thaw_super(struct super_block *super); extern bool our_mnt(struct vfsmount *mnt); @@ -2531,7 +2531,6 @@ extern void put_filesystem(struct file_system_type *fs); extern struct file_system_type *get_fs_type(const char *name); extern struct super_block *get_super(struct block_device *); extern struct super_block *get_active_super(struct block_device *bdev); -extern struct super_block *user_get_super(dev_t); extern void drop_super(struct super_block *sb); extern void iterate_supers(void (*)(struct super_block *, void *), void *); extern void iterate_supers_type(struct file_system_type *, From dabe0dc194d5d56d379a8994fff47392744b6491 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 3 Jan 2012 21:01:29 -0500 Subject: [PATCH 025/165] vfs: fix the rest of sget() races unfortunately, just checking MS_BORN after having grabbed ->s_umount in sget() is not enough; places that pick superblock from a list and grab s_umount shared need the same check in addition to checking for ->s_root; otherwise three-way race between failing mount, sget() and such list-walker can leave us with list-walker coming *second*, when temporary active ref grabbed by sget() (to be dropped when sget() notices that original mount has failed by checking MS_BORN) has lead to deactivate_locked_super() from failing ->mount() *not* doing ->kill_sb() and just releasing ->s_umount. Once sget() gets through and notices that MS_BORN had never been set it will drop the active ref and fs will be shut down and kicked out of all lists, but it's too late for something like sync_supers(). Signed-off-by: Al Viro --- fs/super.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/fs/super.c b/fs/super.c index bab11bad13ba..0413f51a9f0f 100644 --- a/fs/super.c +++ b/fs/super.c @@ -337,7 +337,7 @@ bool grab_super_passive(struct super_block *sb) spin_unlock(&sb_lock); if (down_read_trylock(&sb->s_umount)) { - if (sb->s_root) + if (sb->s_root && (sb->s_flags & MS_BORN)) return true; up_read(&sb->s_umount); } @@ -505,7 +505,7 @@ void sync_supers(void) spin_unlock(&sb_lock); down_read(&sb->s_umount); - if (sb->s_root && sb->s_dirt) + if (sb->s_root && sb->s_dirt && (sb->s_flags & MS_BORN)) sb->s_op->write_super(sb); up_read(&sb->s_umount); @@ -540,7 +540,7 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg) spin_unlock(&sb_lock); down_read(&sb->s_umount); - if (sb->s_root) + if (sb->s_root && (sb->s_flags & MS_BORN)) f(sb, arg); up_read(&sb->s_umount); @@ -575,7 +575,7 @@ void iterate_supers_type(struct file_system_type *type, spin_unlock(&sb_lock); down_read(&sb->s_umount); - if (sb->s_root) + if (sb->s_root && (sb->s_flags & MS_BORN)) f(sb, arg); up_read(&sb->s_umount); @@ -616,7 +616,7 @@ rescan: spin_unlock(&sb_lock); down_read(&sb->s_umount); /* still alive? */ - if (sb->s_root) + if (sb->s_root && (sb->s_flags & MS_BORN)) return sb; up_read(&sb->s_umount); /* nope, got unmounted */ @@ -676,7 +676,7 @@ rescan: spin_unlock(&sb_lock); down_read(&sb->s_umount); /* still alive? */ - if (sb->s_root) + if (sb->s_root && (sb->s_flags & MS_BORN)) return sb; up_read(&sb->s_umount); /* nope, got unmounted */ @@ -763,7 +763,8 @@ static void do_emergency_remount(struct work_struct *work) sb->s_count++; spin_unlock(&sb_lock); down_write(&sb->s_umount); - if (sb->s_root && sb->s_bdev && !(sb->s_flags & MS_RDONLY)) { + if (sb->s_root && sb->s_bdev && (sb->s_flags & MS_BORN) && + !(sb->s_flags & MS_RDONLY)) { /* * What lock protects sb->s_flags?? */ @@ -1146,6 +1147,11 @@ int freeze_super(struct super_block *sb) return -EBUSY; } + if (!(sb->s_flags & MS_BORN)) { + up_write(&sb->s_umount); + return 0; /* sic - it's "nothing to do" */ + } + if (sb->s_flags & MS_RDONLY) { sb->s_frozen = SB_FREEZE_TRANS; smp_wmb(); From 4752bc309b7604d507c973c7b7678ac2ce10a058 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 16 Sep 2011 00:21:54 -0400 Subject: [PATCH 026/165] make register_disk() static Signed-off-by: Al Viro --- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index 02e9fca80825..bf443a71b93e 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -507,7 +507,7 @@ static int exact_lock(dev_t devt, void *data) return 0; } -void register_disk(struct gendisk *disk) +static void register_disk(struct gendisk *disk) { struct device *ddev = disk_to_dev(disk); struct block_device *bdev; From 9be96f3fd10187f185d84cf878cf032465bcced3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 16 Sep 2011 00:25:05 -0400 Subject: [PATCH 027/165] move fs/partitions to block/ Signed-off-by: Al Viro --- block/Kconfig | 6 ++++++ block/Makefile | 3 ++- {fs => block}/partitions/Kconfig | 0 {fs => block}/partitions/Makefile | 0 {fs => block}/partitions/acorn.c | 0 {fs => block}/partitions/acorn.h | 0 {fs => block}/partitions/amiga.c | 0 {fs => block}/partitions/amiga.h | 0 {fs => block}/partitions/atari.c | 0 {fs => block}/partitions/atari.h | 0 {fs => block}/partitions/check.c | 0 {fs => block}/partitions/check.h | 0 {fs => block}/partitions/efi.c | 0 {fs => block}/partitions/efi.h | 0 {fs => block}/partitions/ibm.c | 0 {fs => block}/partitions/ibm.h | 0 {fs => block}/partitions/karma.c | 0 {fs => block}/partitions/karma.h | 0 {fs => block}/partitions/ldm.c | 0 {fs => block}/partitions/ldm.h | 0 {fs => block}/partitions/mac.c | 0 {fs => block}/partitions/mac.h | 0 {fs => block}/partitions/msdos.c | 0 {fs => block}/partitions/msdos.h | 0 {fs => block}/partitions/osf.c | 0 {fs => block}/partitions/osf.h | 0 {fs => block}/partitions/sgi.c | 0 {fs => block}/partitions/sgi.h | 0 {fs => block}/partitions/sun.c | 0 {fs => block}/partitions/sun.h | 0 {fs => block}/partitions/sysv68.c | 0 {fs => block}/partitions/sysv68.h | 0 {fs => block}/partitions/ultrix.c | 0 {fs => block}/partitions/ultrix.h | 0 fs/Kconfig | 8 -------- fs/Makefile | 1 - 36 files changed, 8 insertions(+), 10 deletions(-) rename {fs => block}/partitions/Kconfig (100%) rename {fs => block}/partitions/Makefile (100%) rename {fs => block}/partitions/acorn.c (100%) rename {fs => block}/partitions/acorn.h (100%) rename {fs => block}/partitions/amiga.c (100%) rename {fs => block}/partitions/amiga.h (100%) rename {fs => block}/partitions/atari.c (100%) rename {fs => block}/partitions/atari.h (100%) rename {fs => block}/partitions/check.c (100%) rename {fs => block}/partitions/check.h (100%) rename {fs => block}/partitions/efi.c (100%) rename {fs => block}/partitions/efi.h (100%) rename {fs => block}/partitions/ibm.c (100%) rename {fs => block}/partitions/ibm.h (100%) rename {fs => block}/partitions/karma.c (100%) rename {fs => block}/partitions/karma.h (100%) rename {fs => block}/partitions/ldm.c (100%) rename {fs => block}/partitions/ldm.h (100%) rename {fs => block}/partitions/mac.c (100%) rename {fs => block}/partitions/mac.h (100%) rename {fs => block}/partitions/msdos.c (100%) rename {fs => block}/partitions/msdos.h (100%) rename {fs => block}/partitions/osf.c (100%) rename {fs => block}/partitions/osf.h (100%) rename {fs => block}/partitions/sgi.c (100%) rename {fs => block}/partitions/sgi.h (100%) rename {fs => block}/partitions/sun.c (100%) rename {fs => block}/partitions/sun.h (100%) rename {fs => block}/partitions/sysv68.c (100%) rename {fs => block}/partitions/sysv68.h (100%) rename {fs => block}/partitions/ultrix.c (100%) rename {fs => block}/partitions/ultrix.h (100%) diff --git a/block/Kconfig b/block/Kconfig index e97934eececa..09acf1b39905 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -99,6 +99,12 @@ config BLK_DEV_THROTTLING See Documentation/cgroups/blkio-controller.txt for more information. +menu "Partition Types" + +source "block/partitions/Kconfig" + +endmenu + endif # BLOCK config BLOCK_COMPAT diff --git a/block/Makefile b/block/Makefile index 514c6e4f427a..3199c0cdef5a 100644 --- a/block/Makefile +++ b/block/Makefile @@ -5,7 +5,8 @@ obj-$(CONFIG_BLOCK) := elevator.o blk-core.o blk-tag.o blk-sysfs.o \ blk-flush.o blk-settings.o blk-ioc.o blk-map.o \ blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \ - blk-iopoll.o blk-lib.o ioctl.o genhd.o scsi_ioctl.o + blk-iopoll.o blk-lib.o ioctl.o genhd.o scsi_ioctl.o \ + partitions/ obj-$(CONFIG_BLK_DEV_BSG) += bsg.o obj-$(CONFIG_BLK_DEV_BSGLIB) += bsg-lib.o diff --git a/fs/partitions/Kconfig b/block/partitions/Kconfig similarity index 100% rename from fs/partitions/Kconfig rename to block/partitions/Kconfig diff --git a/fs/partitions/Makefile b/block/partitions/Makefile similarity index 100% rename from fs/partitions/Makefile rename to block/partitions/Makefile diff --git a/fs/partitions/acorn.c b/block/partitions/acorn.c similarity index 100% rename from fs/partitions/acorn.c rename to block/partitions/acorn.c diff --git a/fs/partitions/acorn.h b/block/partitions/acorn.h similarity index 100% rename from fs/partitions/acorn.h rename to block/partitions/acorn.h diff --git a/fs/partitions/amiga.c b/block/partitions/amiga.c similarity index 100% rename from fs/partitions/amiga.c rename to block/partitions/amiga.c diff --git a/fs/partitions/amiga.h b/block/partitions/amiga.h similarity index 100% rename from fs/partitions/amiga.h rename to block/partitions/amiga.h diff --git a/fs/partitions/atari.c b/block/partitions/atari.c similarity index 100% rename from fs/partitions/atari.c rename to block/partitions/atari.c diff --git a/fs/partitions/atari.h b/block/partitions/atari.h similarity index 100% rename from fs/partitions/atari.h rename to block/partitions/atari.h diff --git a/fs/partitions/check.c b/block/partitions/check.c similarity index 100% rename from fs/partitions/check.c rename to block/partitions/check.c diff --git a/fs/partitions/check.h b/block/partitions/check.h similarity index 100% rename from fs/partitions/check.h rename to block/partitions/check.h diff --git a/fs/partitions/efi.c b/block/partitions/efi.c similarity index 100% rename from fs/partitions/efi.c rename to block/partitions/efi.c diff --git a/fs/partitions/efi.h b/block/partitions/efi.h similarity index 100% rename from fs/partitions/efi.h rename to block/partitions/efi.h diff --git a/fs/partitions/ibm.c b/block/partitions/ibm.c similarity index 100% rename from fs/partitions/ibm.c rename to block/partitions/ibm.c diff --git a/fs/partitions/ibm.h b/block/partitions/ibm.h similarity index 100% rename from fs/partitions/ibm.h rename to block/partitions/ibm.h diff --git a/fs/partitions/karma.c b/block/partitions/karma.c similarity index 100% rename from fs/partitions/karma.c rename to block/partitions/karma.c diff --git a/fs/partitions/karma.h b/block/partitions/karma.h similarity index 100% rename from fs/partitions/karma.h rename to block/partitions/karma.h diff --git a/fs/partitions/ldm.c b/block/partitions/ldm.c similarity index 100% rename from fs/partitions/ldm.c rename to block/partitions/ldm.c diff --git a/fs/partitions/ldm.h b/block/partitions/ldm.h similarity index 100% rename from fs/partitions/ldm.h rename to block/partitions/ldm.h diff --git a/fs/partitions/mac.c b/block/partitions/mac.c similarity index 100% rename from fs/partitions/mac.c rename to block/partitions/mac.c diff --git a/fs/partitions/mac.h b/block/partitions/mac.h similarity index 100% rename from fs/partitions/mac.h rename to block/partitions/mac.h diff --git a/fs/partitions/msdos.c b/block/partitions/msdos.c similarity index 100% rename from fs/partitions/msdos.c rename to block/partitions/msdos.c diff --git a/fs/partitions/msdos.h b/block/partitions/msdos.h similarity index 100% rename from fs/partitions/msdos.h rename to block/partitions/msdos.h diff --git a/fs/partitions/osf.c b/block/partitions/osf.c similarity index 100% rename from fs/partitions/osf.c rename to block/partitions/osf.c diff --git a/fs/partitions/osf.h b/block/partitions/osf.h similarity index 100% rename from fs/partitions/osf.h rename to block/partitions/osf.h diff --git a/fs/partitions/sgi.c b/block/partitions/sgi.c similarity index 100% rename from fs/partitions/sgi.c rename to block/partitions/sgi.c diff --git a/fs/partitions/sgi.h b/block/partitions/sgi.h similarity index 100% rename from fs/partitions/sgi.h rename to block/partitions/sgi.h diff --git a/fs/partitions/sun.c b/block/partitions/sun.c similarity index 100% rename from fs/partitions/sun.c rename to block/partitions/sun.c diff --git a/fs/partitions/sun.h b/block/partitions/sun.h similarity index 100% rename from fs/partitions/sun.h rename to block/partitions/sun.h diff --git a/fs/partitions/sysv68.c b/block/partitions/sysv68.c similarity index 100% rename from fs/partitions/sysv68.c rename to block/partitions/sysv68.c diff --git a/fs/partitions/sysv68.h b/block/partitions/sysv68.h similarity index 100% rename from fs/partitions/sysv68.h rename to block/partitions/sysv68.h diff --git a/fs/partitions/ultrix.c b/block/partitions/ultrix.c similarity index 100% rename from fs/partitions/ultrix.c rename to block/partitions/ultrix.c diff --git a/fs/partitions/ultrix.h b/block/partitions/ultrix.h similarity index 100% rename from fs/partitions/ultrix.h rename to block/partitions/ultrix.h 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" endif # NETWORK_FILESYSTEMS -if BLOCK -menu "Partition Types" - -source "fs/partitions/Kconfig" - -endmenu -endif - source "fs/nls/Kconfig" source "fs/dlm/Kconfig" diff --git a/fs/Makefile b/fs/Makefile index d2c3353d5477..c36ebec298b8 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -52,7 +52,6 @@ obj-$(CONFIG_FHANDLE) += fhandle.o obj-y += quota/ obj-$(CONFIG_PROC_FS) += proc/ -obj-y += partitions/ obj-$(CONFIG_SYSFS) += sysfs/ obj-$(CONFIG_CONFIGFS_FS) += configfs/ obj-y += devpts/ From 94ea4158f1733e3b10cef067d535f504866e0c41 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 16 Sep 2011 00:45:36 -0400 Subject: [PATCH 028/165] separate partition format handling from generic code Signed-off-by: Al Viro --- block/Makefile | 2 +- block/partition-generic.c | 537 ++++++++++++++++++++++++++++++++++++++ block/partitions/check.c | 523 +------------------------------------ block/partitions/check.h | 3 + 4 files changed, 542 insertions(+), 523 deletions(-) create mode 100644 block/partition-generic.c diff --git a/block/Makefile b/block/Makefile index 3199c0cdef5a..39b76ba66ffd 100644 --- a/block/Makefile +++ b/block/Makefile @@ -6,7 +6,7 @@ obj-$(CONFIG_BLOCK) := elevator.o blk-core.o blk-tag.o blk-sysfs.o \ blk-flush.o blk-settings.o blk-ioc.o blk-map.o \ blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \ blk-iopoll.o blk-lib.o ioctl.o genhd.o scsi_ioctl.o \ - partitions/ + partition-generic.o partitions/ obj-$(CONFIG_BLK_DEV_BSG) += bsg.o obj-$(CONFIG_BLK_DEV_BSGLIB) += bsg-lib.o diff --git a/block/partition-generic.c b/block/partition-generic.c new file mode 100644 index 000000000000..d06ec1c829c2 --- /dev/null +++ b/block/partition-generic.c @@ -0,0 +1,537 @@ +/* + * Code extracted from drivers/block/genhd.c + * Copyright (C) 1991-1998 Linus Torvalds + * Re-organised Feb 1998 Russell King + * + * We now have independent partition support from the + * block drivers, which allows all the partition code to + * be grouped in one location, and it to be mostly self + * contained. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "partitions/check.h" + +#ifdef CONFIG_BLK_DEV_MD +extern void md_autodetect_dev(dev_t dev); +#endif + +/* + * disk_name() is used by partition check code and the genhd driver. + * It formats the devicename of the indicated disk into + * the supplied buffer (of size at least 32), and returns + * a pointer to that same buffer (for convenience). + */ + +char *disk_name(struct gendisk *hd, int partno, char *buf) +{ + if (!partno) + snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name); + else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1])) + snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, partno); + else + snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, partno); + + return buf; +} + +const char *bdevname(struct block_device *bdev, char *buf) +{ + return disk_name(bdev->bd_disk, bdev->bd_part->partno, buf); +} + +EXPORT_SYMBOL(bdevname); + +/* + * There's very little reason to use this, you should really + * have a struct block_device just about everywhere and use + * bdevname() instead. + */ +const char *__bdevname(dev_t dev, char *buffer) +{ + scnprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)", + MAJOR(dev), MINOR(dev)); + return buffer; +} + +EXPORT_SYMBOL(__bdevname); + +static ssize_t part_partition_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + + return sprintf(buf, "%d\n", p->partno); +} + +static ssize_t part_start_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + + return sprintf(buf, "%llu\n",(unsigned long long)p->start_sect); +} + +ssize_t part_size_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + return sprintf(buf, "%llu\n",(unsigned long long)p->nr_sects); +} + +static ssize_t part_ro_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + return sprintf(buf, "%d\n", p->policy ? 1 : 0); +} + +static ssize_t part_alignment_offset_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + return sprintf(buf, "%llu\n", (unsigned long long)p->alignment_offset); +} + +static ssize_t part_discard_alignment_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + return sprintf(buf, "%u\n", p->discard_alignment); +} + +ssize_t part_stat_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + int cpu; + + cpu = part_stat_lock(); + part_round_stats(cpu, p); + part_stat_unlock(); + return sprintf(buf, + "%8lu %8lu %8llu %8u " + "%8lu %8lu %8llu %8u " + "%8u %8u %8u" + "\n", + part_stat_read(p, ios[READ]), + part_stat_read(p, merges[READ]), + (unsigned long long)part_stat_read(p, sectors[READ]), + jiffies_to_msecs(part_stat_read(p, ticks[READ])), + part_stat_read(p, ios[WRITE]), + part_stat_read(p, merges[WRITE]), + (unsigned long long)part_stat_read(p, sectors[WRITE]), + jiffies_to_msecs(part_stat_read(p, ticks[WRITE])), + part_in_flight(p), + jiffies_to_msecs(part_stat_read(p, io_ticks)), + jiffies_to_msecs(part_stat_read(p, time_in_queue))); +} + +ssize_t part_inflight_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + + return sprintf(buf, "%8u %8u\n", atomic_read(&p->in_flight[0]), + atomic_read(&p->in_flight[1])); +} + +#ifdef CONFIG_FAIL_MAKE_REQUEST +ssize_t part_fail_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hd_struct *p = dev_to_part(dev); + + return sprintf(buf, "%d\n", p->make_it_fail); +} + +ssize_t part_fail_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct hd_struct *p = dev_to_part(dev); + int i; + + if (count > 0 && sscanf(buf, "%d", &i) > 0) + p->make_it_fail = (i == 0) ? 0 : 1; + + return count; +} +#endif + +static DEVICE_ATTR(partition, S_IRUGO, part_partition_show, NULL); +static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL); +static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); +static DEVICE_ATTR(ro, S_IRUGO, part_ro_show, NULL); +static DEVICE_ATTR(alignment_offset, S_IRUGO, part_alignment_offset_show, NULL); +static DEVICE_ATTR(discard_alignment, S_IRUGO, part_discard_alignment_show, + NULL); +static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); +static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL); +#ifdef CONFIG_FAIL_MAKE_REQUEST +static struct device_attribute dev_attr_fail = + __ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store); +#endif + +static struct attribute *part_attrs[] = { + &dev_attr_partition.attr, + &dev_attr_start.attr, + &dev_attr_size.attr, + &dev_attr_ro.attr, + &dev_attr_alignment_offset.attr, + &dev_attr_discard_alignment.attr, + &dev_attr_stat.attr, + &dev_attr_inflight.attr, +#ifdef CONFIG_FAIL_MAKE_REQUEST + &dev_attr_fail.attr, +#endif + NULL +}; + +static struct attribute_group part_attr_group = { + .attrs = part_attrs, +}; + +static const struct attribute_group *part_attr_groups[] = { + &part_attr_group, +#ifdef CONFIG_BLK_DEV_IO_TRACE + &blk_trace_attr_group, +#endif + NULL +}; + +static void part_release(struct device *dev) +{ + struct hd_struct *p = dev_to_part(dev); + free_part_stats(p); + free_part_info(p); + kfree(p); +} + +struct device_type part_type = { + .name = "partition", + .groups = part_attr_groups, + .release = part_release, +}; + +static void delete_partition_rcu_cb(struct rcu_head *head) +{ + struct hd_struct *part = container_of(head, struct hd_struct, rcu_head); + + part->start_sect = 0; + part->nr_sects = 0; + part_stat_set_all(part, 0); + put_device(part_to_dev(part)); +} + +void __delete_partition(struct hd_struct *part) +{ + call_rcu(&part->rcu_head, delete_partition_rcu_cb); +} + +void delete_partition(struct gendisk *disk, int partno) +{ + struct disk_part_tbl *ptbl = disk->part_tbl; + struct hd_struct *part; + + if (partno >= ptbl->len) + return; + + part = ptbl->part[partno]; + if (!part) + return; + + blk_free_devt(part_devt(part)); + rcu_assign_pointer(ptbl->part[partno], NULL); + rcu_assign_pointer(ptbl->last_lookup, NULL); + kobject_put(part->holder_dir); + device_del(part_to_dev(part)); + + hd_struct_put(part); +} + +static ssize_t whole_disk_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return 0; +} +static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, + whole_disk_show, NULL); + +struct hd_struct *add_partition(struct gendisk *disk, int partno, + sector_t start, sector_t len, int flags, + struct partition_meta_info *info) +{ + struct hd_struct *p; + dev_t devt = MKDEV(0, 0); + struct device *ddev = disk_to_dev(disk); + struct device *pdev; + struct disk_part_tbl *ptbl; + const char *dname; + int err; + + err = disk_expand_part_tbl(disk, partno); + if (err) + return ERR_PTR(err); + ptbl = disk->part_tbl; + + if (ptbl->part[partno]) + return ERR_PTR(-EBUSY); + + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (!p) + return ERR_PTR(-EBUSY); + + if (!init_part_stats(p)) { + err = -ENOMEM; + goto out_free; + } + pdev = part_to_dev(p); + + p->start_sect = start; + p->alignment_offset = + queue_limit_alignment_offset(&disk->queue->limits, start); + p->discard_alignment = + queue_limit_discard_alignment(&disk->queue->limits, start); + p->nr_sects = len; + p->partno = partno; + p->policy = get_disk_ro(disk); + + if (info) { + struct partition_meta_info *pinfo = alloc_part_info(disk); + if (!pinfo) + goto out_free_stats; + memcpy(pinfo, info, sizeof(*info)); + p->info = pinfo; + } + + dname = dev_name(ddev); + if (isdigit(dname[strlen(dname) - 1])) + dev_set_name(pdev, "%sp%d", dname, partno); + else + dev_set_name(pdev, "%s%d", dname, partno); + + device_initialize(pdev); + pdev->class = &block_class; + pdev->type = &part_type; + pdev->parent = ddev; + + err = blk_alloc_devt(p, &devt); + if (err) + goto out_free_info; + pdev->devt = devt; + + /* delay uevent until 'holders' subdir is created */ + dev_set_uevent_suppress(pdev, 1); + err = device_add(pdev); + if (err) + goto out_put; + + err = -ENOMEM; + p->holder_dir = kobject_create_and_add("holders", &pdev->kobj); + if (!p->holder_dir) + goto out_del; + + dev_set_uevent_suppress(pdev, 0); + if (flags & ADDPART_FLAG_WHOLEDISK) { + err = device_create_file(pdev, &dev_attr_whole_disk); + if (err) + goto out_del; + } + + /* everything is up and running, commence */ + rcu_assign_pointer(ptbl->part[partno], p); + + /* suppress uevent if the disk suppresses it */ + if (!dev_get_uevent_suppress(ddev)) + kobject_uevent(&pdev->kobj, KOBJ_ADD); + + hd_ref_init(p); + return p; + +out_free_info: + free_part_info(p); +out_free_stats: + free_part_stats(p); +out_free: + kfree(p); + return ERR_PTR(err); +out_del: + kobject_put(p->holder_dir); + device_del(pdev); +out_put: + put_device(pdev); + blk_free_devt(devt); + return ERR_PTR(err); +} + +static bool disk_unlock_native_capacity(struct gendisk *disk) +{ + const struct block_device_operations *bdops = disk->fops; + + if (bdops->unlock_native_capacity && + !(disk->flags & GENHD_FL_NATIVE_CAPACITY)) { + printk(KERN_CONT "enabling native capacity\n"); + bdops->unlock_native_capacity(disk); + disk->flags |= GENHD_FL_NATIVE_CAPACITY; + return true; + } else { + printk(KERN_CONT "truncated\n"); + return false; + } +} + +int rescan_partitions(struct gendisk *disk, struct block_device *bdev) +{ + struct parsed_partitions *state = NULL; + struct disk_part_iter piter; + struct hd_struct *part; + int p, highest, res; +rescan: + if (state && !IS_ERR(state)) { + kfree(state); + state = NULL; + } + + if (bdev->bd_part_count) + return -EBUSY; + res = invalidate_partition(disk, 0); + if (res) + return res; + + disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY); + while ((part = disk_part_iter_next(&piter))) + delete_partition(disk, part->partno); + disk_part_iter_exit(&piter); + + if (disk->fops->revalidate_disk) + disk->fops->revalidate_disk(disk); + check_disk_size_change(disk, bdev); + bdev->bd_invalidated = 0; + if (!get_capacity(disk) || !(state = check_partition(disk, bdev))) + return 0; + if (IS_ERR(state)) { + /* + * I/O error reading the partition table. If any + * partition code tried to read beyond EOD, retry + * after unlocking native capacity. + */ + if (PTR_ERR(state) == -ENOSPC) { + printk(KERN_WARNING "%s: partition table beyond EOD, ", + disk->disk_name); + if (disk_unlock_native_capacity(disk)) + goto rescan; + } + return -EIO; + } + /* + * If any partition code tried to read beyond EOD, try + * unlocking native capacity even if partition table is + * successfully read as we could be missing some partitions. + */ + if (state->access_beyond_eod) { + printk(KERN_WARNING + "%s: partition table partially beyond EOD, ", + disk->disk_name); + if (disk_unlock_native_capacity(disk)) + goto rescan; + } + + /* tell userspace that the media / partition table may have changed */ + kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); + + /* Detect the highest partition number and preallocate + * disk->part_tbl. This is an optimization and not strictly + * necessary. + */ + for (p = 1, highest = 0; p < state->limit; p++) + if (state->parts[p].size) + highest = p; + + disk_expand_part_tbl(disk, highest); + + /* add partitions */ + for (p = 1; p < state->limit; p++) { + sector_t size, from; + struct partition_meta_info *info = NULL; + + size = state->parts[p].size; + if (!size) + continue; + + from = state->parts[p].from; + if (from >= get_capacity(disk)) { + printk(KERN_WARNING + "%s: p%d start %llu is beyond EOD, ", + disk->disk_name, p, (unsigned long long) from); + if (disk_unlock_native_capacity(disk)) + goto rescan; + continue; + } + + if (from + size > get_capacity(disk)) { + printk(KERN_WARNING + "%s: p%d size %llu extends beyond EOD, ", + disk->disk_name, p, (unsigned long long) size); + + if (disk_unlock_native_capacity(disk)) { + /* free state and restart */ + goto rescan; + } else { + /* + * we can not ignore partitions of broken tables + * created by for example camera firmware, but + * we limit them to the end of the disk to avoid + * creating invalid block devices + */ + size = get_capacity(disk) - from; + } + } + + if (state->parts[p].has_info) + info = &state->parts[p].info; + part = add_partition(disk, p, from, size, + state->parts[p].flags, + &state->parts[p].info); + if (IS_ERR(part)) { + printk(KERN_ERR " %s: p%d could not be added: %ld\n", + disk->disk_name, p, -PTR_ERR(part)); + continue; + } +#ifdef CONFIG_BLK_DEV_MD + if (state->parts[p].flags & ADDPART_FLAG_RAID) + md_autodetect_dev(part_to_dev(part)->devt); +#endif + } + kfree(state); + return 0; +} + +unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p) +{ + struct address_space *mapping = bdev->bd_inode->i_mapping; + struct page *page; + + page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_CACHE_SHIFT-9)), + NULL); + if (!IS_ERR(page)) { + if (PageError(page)) + goto fail; + p->v = page; + return (unsigned char *)page_address(page) + ((n & ((1 << (PAGE_CACHE_SHIFT - 9)) - 1)) << 9); +fail: + page_cache_release(page); + } + p->v = NULL; + return NULL; +} + +EXPORT_SYMBOL(read_dev_sector); diff --git a/block/partitions/check.c b/block/partitions/check.c index e3c63d1c5e13..bc908672c976 100644 --- a/block/partitions/check.c +++ b/block/partitions/check.c @@ -13,14 +13,9 @@ * Added needed MAJORS for new pairs, {hdi,hdj}, {hdk,hdl} */ -#include -#include -#include #include -#include #include #include -#include #include "check.h" @@ -39,10 +34,6 @@ #include "karma.h" #include "sysv68.h" -#ifdef CONFIG_BLK_DEV_MD -extern void md_autodetect_dev(dev_t dev); -#endif - int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/ static int (*check_part[])(struct parsed_partitions *) = { @@ -114,48 +105,8 @@ static int (*check_part[])(struct parsed_partitions *) = { #endif NULL }; - -/* - * disk_name() is used by partition check code and the genhd driver. - * It formats the devicename of the indicated disk into - * the supplied buffer (of size at least 32), and returns - * a pointer to that same buffer (for convenience). - */ -char *disk_name(struct gendisk *hd, int partno, char *buf) -{ - if (!partno) - snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name); - else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1])) - snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, partno); - else - snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, partno); - - return buf; -} - -const char *bdevname(struct block_device *bdev, char *buf) -{ - return disk_name(bdev->bd_disk, bdev->bd_part->partno, buf); -} - -EXPORT_SYMBOL(bdevname); - -/* - * There's very little reason to use this, you should really - * have a struct block_device just about everywhere and use - * bdevname() instead. - */ -const char *__bdevname(dev_t dev, char *buffer) -{ - scnprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)", - MAJOR(dev), MINOR(dev)); - return buffer; -} - -EXPORT_SYMBOL(__bdevname); - -static struct parsed_partitions * +struct parsed_partitions * check_partition(struct gendisk *hd, struct block_device *bdev) { struct parsed_partitions *state; @@ -213,475 +164,3 @@ check_partition(struct gendisk *hd, struct block_device *bdev) kfree(state); return ERR_PTR(res); } - -static ssize_t part_partition_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - - return sprintf(buf, "%d\n", p->partno); -} - -static ssize_t part_start_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - - return sprintf(buf, "%llu\n",(unsigned long long)p->start_sect); -} - -ssize_t part_size_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - return sprintf(buf, "%llu\n",(unsigned long long)p->nr_sects); -} - -static ssize_t part_ro_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - return sprintf(buf, "%d\n", p->policy ? 1 : 0); -} - -static ssize_t part_alignment_offset_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - return sprintf(buf, "%llu\n", (unsigned long long)p->alignment_offset); -} - -static ssize_t part_discard_alignment_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - return sprintf(buf, "%u\n", p->discard_alignment); -} - -ssize_t part_stat_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - int cpu; - - cpu = part_stat_lock(); - part_round_stats(cpu, p); - part_stat_unlock(); - return sprintf(buf, - "%8lu %8lu %8llu %8u " - "%8lu %8lu %8llu %8u " - "%8u %8u %8u" - "\n", - part_stat_read(p, ios[READ]), - part_stat_read(p, merges[READ]), - (unsigned long long)part_stat_read(p, sectors[READ]), - jiffies_to_msecs(part_stat_read(p, ticks[READ])), - part_stat_read(p, ios[WRITE]), - part_stat_read(p, merges[WRITE]), - (unsigned long long)part_stat_read(p, sectors[WRITE]), - jiffies_to_msecs(part_stat_read(p, ticks[WRITE])), - part_in_flight(p), - jiffies_to_msecs(part_stat_read(p, io_ticks)), - jiffies_to_msecs(part_stat_read(p, time_in_queue))); -} - -ssize_t part_inflight_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - - return sprintf(buf, "%8u %8u\n", atomic_read(&p->in_flight[0]), - atomic_read(&p->in_flight[1])); -} - -#ifdef CONFIG_FAIL_MAKE_REQUEST -ssize_t part_fail_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct hd_struct *p = dev_to_part(dev); - - return sprintf(buf, "%d\n", p->make_it_fail); -} - -ssize_t part_fail_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct hd_struct *p = dev_to_part(dev); - int i; - - if (count > 0 && sscanf(buf, "%d", &i) > 0) - p->make_it_fail = (i == 0) ? 0 : 1; - - return count; -} -#endif - -static DEVICE_ATTR(partition, S_IRUGO, part_partition_show, NULL); -static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL); -static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); -static DEVICE_ATTR(ro, S_IRUGO, part_ro_show, NULL); -static DEVICE_ATTR(alignment_offset, S_IRUGO, part_alignment_offset_show, NULL); -static DEVICE_ATTR(discard_alignment, S_IRUGO, part_discard_alignment_show, - NULL); -static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); -static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL); -#ifdef CONFIG_FAIL_MAKE_REQUEST -static struct device_attribute dev_attr_fail = - __ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store); -#endif - -static struct attribute *part_attrs[] = { - &dev_attr_partition.attr, - &dev_attr_start.attr, - &dev_attr_size.attr, - &dev_attr_ro.attr, - &dev_attr_alignment_offset.attr, - &dev_attr_discard_alignment.attr, - &dev_attr_stat.attr, - &dev_attr_inflight.attr, -#ifdef CONFIG_FAIL_MAKE_REQUEST - &dev_attr_fail.attr, -#endif - NULL -}; - -static struct attribute_group part_attr_group = { - .attrs = part_attrs, -}; - -static const struct attribute_group *part_attr_groups[] = { - &part_attr_group, -#ifdef CONFIG_BLK_DEV_IO_TRACE - &blk_trace_attr_group, -#endif - NULL -}; - -static void part_release(struct device *dev) -{ - struct hd_struct *p = dev_to_part(dev); - free_part_stats(p); - free_part_info(p); - kfree(p); -} - -struct device_type part_type = { - .name = "partition", - .groups = part_attr_groups, - .release = part_release, -}; - -static void delete_partition_rcu_cb(struct rcu_head *head) -{ - struct hd_struct *part = container_of(head, struct hd_struct, rcu_head); - - part->start_sect = 0; - part->nr_sects = 0; - part_stat_set_all(part, 0); - put_device(part_to_dev(part)); -} - -void __delete_partition(struct hd_struct *part) -{ - call_rcu(&part->rcu_head, delete_partition_rcu_cb); -} - -void delete_partition(struct gendisk *disk, int partno) -{ - struct disk_part_tbl *ptbl = disk->part_tbl; - struct hd_struct *part; - - if (partno >= ptbl->len) - return; - - part = ptbl->part[partno]; - if (!part) - return; - - blk_free_devt(part_devt(part)); - rcu_assign_pointer(ptbl->part[partno], NULL); - rcu_assign_pointer(ptbl->last_lookup, NULL); - kobject_put(part->holder_dir); - device_del(part_to_dev(part)); - - hd_struct_put(part); -} - -static ssize_t whole_disk_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return 0; -} -static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, - whole_disk_show, NULL); - -struct hd_struct *add_partition(struct gendisk *disk, int partno, - sector_t start, sector_t len, int flags, - struct partition_meta_info *info) -{ - struct hd_struct *p; - dev_t devt = MKDEV(0, 0); - struct device *ddev = disk_to_dev(disk); - struct device *pdev; - struct disk_part_tbl *ptbl; - const char *dname; - int err; - - err = disk_expand_part_tbl(disk, partno); - if (err) - return ERR_PTR(err); - ptbl = disk->part_tbl; - - if (ptbl->part[partno]) - return ERR_PTR(-EBUSY); - - p = kzalloc(sizeof(*p), GFP_KERNEL); - if (!p) - return ERR_PTR(-EBUSY); - - if (!init_part_stats(p)) { - err = -ENOMEM; - goto out_free; - } - pdev = part_to_dev(p); - - p->start_sect = start; - p->alignment_offset = - queue_limit_alignment_offset(&disk->queue->limits, start); - p->discard_alignment = - queue_limit_discard_alignment(&disk->queue->limits, start); - p->nr_sects = len; - p->partno = partno; - p->policy = get_disk_ro(disk); - - if (info) { - struct partition_meta_info *pinfo = alloc_part_info(disk); - if (!pinfo) - goto out_free_stats; - memcpy(pinfo, info, sizeof(*info)); - p->info = pinfo; - } - - dname = dev_name(ddev); - if (isdigit(dname[strlen(dname) - 1])) - dev_set_name(pdev, "%sp%d", dname, partno); - else - dev_set_name(pdev, "%s%d", dname, partno); - - device_initialize(pdev); - pdev->class = &block_class; - pdev->type = &part_type; - pdev->parent = ddev; - - err = blk_alloc_devt(p, &devt); - if (err) - goto out_free_info; - pdev->devt = devt; - - /* delay uevent until 'holders' subdir is created */ - dev_set_uevent_suppress(pdev, 1); - err = device_add(pdev); - if (err) - goto out_put; - - err = -ENOMEM; - p->holder_dir = kobject_create_and_add("holders", &pdev->kobj); - if (!p->holder_dir) - goto out_del; - - dev_set_uevent_suppress(pdev, 0); - if (flags & ADDPART_FLAG_WHOLEDISK) { - err = device_create_file(pdev, &dev_attr_whole_disk); - if (err) - goto out_del; - } - - /* everything is up and running, commence */ - rcu_assign_pointer(ptbl->part[partno], p); - - /* suppress uevent if the disk suppresses it */ - if (!dev_get_uevent_suppress(ddev)) - kobject_uevent(&pdev->kobj, KOBJ_ADD); - - hd_ref_init(p); - return p; - -out_free_info: - free_part_info(p); -out_free_stats: - free_part_stats(p); -out_free: - kfree(p); - return ERR_PTR(err); -out_del: - kobject_put(p->holder_dir); - device_del(pdev); -out_put: - put_device(pdev); - blk_free_devt(devt); - return ERR_PTR(err); -} - -static bool disk_unlock_native_capacity(struct gendisk *disk) -{ - const struct block_device_operations *bdops = disk->fops; - - if (bdops->unlock_native_capacity && - !(disk->flags & GENHD_FL_NATIVE_CAPACITY)) { - printk(KERN_CONT "enabling native capacity\n"); - bdops->unlock_native_capacity(disk); - disk->flags |= GENHD_FL_NATIVE_CAPACITY; - return true; - } else { - printk(KERN_CONT "truncated\n"); - return false; - } -} - -int rescan_partitions(struct gendisk *disk, struct block_device *bdev) -{ - struct parsed_partitions *state = NULL; - struct disk_part_iter piter; - struct hd_struct *part; - int p, highest, res; -rescan: - if (state && !IS_ERR(state)) { - kfree(state); - state = NULL; - } - - if (bdev->bd_part_count) - return -EBUSY; - res = invalidate_partition(disk, 0); - if (res) - return res; - - disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY); - while ((part = disk_part_iter_next(&piter))) - delete_partition(disk, part->partno); - disk_part_iter_exit(&piter); - - if (disk->fops->revalidate_disk) - disk->fops->revalidate_disk(disk); - check_disk_size_change(disk, bdev); - bdev->bd_invalidated = 0; - if (!get_capacity(disk) || !(state = check_partition(disk, bdev))) - return 0; - if (IS_ERR(state)) { - /* - * I/O error reading the partition table. If any - * partition code tried to read beyond EOD, retry - * after unlocking native capacity. - */ - if (PTR_ERR(state) == -ENOSPC) { - printk(KERN_WARNING "%s: partition table beyond EOD, ", - disk->disk_name); - if (disk_unlock_native_capacity(disk)) - goto rescan; - } - return -EIO; - } - /* - * If any partition code tried to read beyond EOD, try - * unlocking native capacity even if partition table is - * successfully read as we could be missing some partitions. - */ - if (state->access_beyond_eod) { - printk(KERN_WARNING - "%s: partition table partially beyond EOD, ", - disk->disk_name); - if (disk_unlock_native_capacity(disk)) - goto rescan; - } - - /* tell userspace that the media / partition table may have changed */ - kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); - - /* Detect the highest partition number and preallocate - * disk->part_tbl. This is an optimization and not strictly - * necessary. - */ - for (p = 1, highest = 0; p < state->limit; p++) - if (state->parts[p].size) - highest = p; - - disk_expand_part_tbl(disk, highest); - - /* add partitions */ - for (p = 1; p < state->limit; p++) { - sector_t size, from; - struct partition_meta_info *info = NULL; - - size = state->parts[p].size; - if (!size) - continue; - - from = state->parts[p].from; - if (from >= get_capacity(disk)) { - printk(KERN_WARNING - "%s: p%d start %llu is beyond EOD, ", - disk->disk_name, p, (unsigned long long) from); - if (disk_unlock_native_capacity(disk)) - goto rescan; - continue; - } - - if (from + size > get_capacity(disk)) { - printk(KERN_WARNING - "%s: p%d size %llu extends beyond EOD, ", - disk->disk_name, p, (unsigned long long) size); - - if (disk_unlock_native_capacity(disk)) { - /* free state and restart */ - goto rescan; - } else { - /* - * we can not ignore partitions of broken tables - * created by for example camera firmware, but - * we limit them to the end of the disk to avoid - * creating invalid block devices - */ - size = get_capacity(disk) - from; - } - } - - if (state->parts[p].has_info) - info = &state->parts[p].info; - part = add_partition(disk, p, from, size, - state->parts[p].flags, - &state->parts[p].info); - if (IS_ERR(part)) { - printk(KERN_ERR " %s: p%d could not be added: %ld\n", - disk->disk_name, p, -PTR_ERR(part)); - continue; - } -#ifdef CONFIG_BLK_DEV_MD - if (state->parts[p].flags & ADDPART_FLAG_RAID) - md_autodetect_dev(part_to_dev(part)->devt); -#endif - } - kfree(state); - return 0; -} - -unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p) -{ - struct address_space *mapping = bdev->bd_inode->i_mapping; - struct page *page; - - page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_CACHE_SHIFT-9)), - NULL); - if (!IS_ERR(page)) { - if (PageError(page)) - goto fail; - p->v = page; - return (unsigned char *)page_address(page) + ((n & ((1 << (PAGE_CACHE_SHIFT - 9)) - 1)) << 9); -fail: - page_cache_release(page); - } - p->v = NULL; - return NULL; -} - -EXPORT_SYMBOL(read_dev_sector); diff --git a/block/partitions/check.h b/block/partitions/check.h index d68bf4dc3bc2..52b100311ec3 100644 --- a/block/partitions/check.h +++ b/block/partitions/check.h @@ -22,6 +22,9 @@ struct parsed_partitions { char *pp_buf; }; +struct parsed_partitions * +check_partition(struct gendisk *, struct block_device *); + static inline void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p) { From ff01bb4832651c6d25ac509a06a10fcbd75c461c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 16 Sep 2011 02:31:11 -0400 Subject: [PATCH 029/165] fs: move code out of buffer.c Move invalidate_bdev, block_sync_page into fs/block_dev.c. Export kill_bdev as well, so brd doesn't have to open code it. Reduce buffer_head.h requirement accordingly. Removed a rather large comment from invalidate_bdev, as it looked a bit obsolete to bother moving. The small comment replacing it says enough. Signed-off-by: Nick Piggin Cc: Al Viro Cc: Christoph Hellwig Signed-off-by: Andrew Morton Signed-off-by: Al Viro --- arch/powerpc/sysdev/axonram.c | 1 - block/genhd.c | 1 - block/ioctl.c | 2 +- drivers/block/amiflop.c | 2 +- drivers/block/brd.c | 9 +++--- drivers/block/floppy.c | 1 - drivers/block/loop.c | 1 - drivers/cdrom/cdrom.c | 1 - drivers/md/dm.c | 1 - drivers/md/md.c | 3 +- drivers/mtd/devices/block2mtd.c | 1 - drivers/s390/block/dasd.c | 1 - drivers/scsi/scsicam.c | 1 - drivers/tty/sysrq.c | 2 +- fs/block_dev.c | 30 ++++++++++++++++++-- fs/buffer.c | 50 --------------------------------- fs/cachefiles/interface.c | 1 - fs/cramfs/inode.c | 1 - fs/fs-writeback.c | 1 - fs/libfs.c | 2 +- fs/quota/dquot.c | 1 - fs/quota/quota.c | 1 - fs/splice.c | 1 - fs/sync.c | 1 - include/linux/fs.h | 3 ++ kernel/power/swap.c | 1 - mm/page-writeback.c | 2 +- mm/swap_state.c | 1 - 28 files changed, 40 insertions(+), 83 deletions(-) diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c index ba4271919062..1c16141c031c 100644 --- a/arch/powerpc/sysdev/axonram.c +++ b/arch/powerpc/sysdev/axonram.c @@ -25,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/block/genhd.c b/block/genhd.c index bf443a71b93e..b7d1a0e42686 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/block/ioctl.c b/block/ioctl.c index ca939fc1030f..91e7b19c86f4 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 8eba86bba599..386146d792d1 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/block/brd.c b/drivers/block/brd.c index d22119d49e53..ec246437f5a4 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -17,7 +17,7 @@ #include #include #include -#include /* invalidate_bh_lrus() */ +#include #include #include @@ -402,14 +402,13 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode, error = -EBUSY; if (bdev->bd_openers <= 1) { /* - * Invalidate the cache first, so it isn't written - * back to the device. + * Kill the cache first, so it isn't written back to the + * device. * * Another thread might instantiate more buffercache here, * but there is not much we can do to close that race. */ - invalidate_bh_lrus(); - truncate_inode_pages(bdev->bd_inode->i_mapping, 0); + kill_bdev(bdev); brd_free_pages(brd); error = 0; } diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 9955a53733b2..510fb10ec45a 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -188,7 +188,6 @@ static int print_unex = 1; #include #include #include -#include /* for invalidate_buffers() */ #include #include #include diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 1e888c9e85b3..f00257782fcc 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -69,7 +69,6 @@ #include #include #include -#include /* for invalidate_bdev() */ #include #include #include diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index f997c27d79e2..2118211aff99 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -267,7 +267,6 @@ #include #include -#include #include #include #include diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 4720f68f817e..b89c548ec3f8 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/md/md.c b/drivers/md/md.c index f47f1f8ac44b..5d1b6762f108 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -36,8 +36,7 @@ #include #include #include -#include -#include /* for invalidate_bdev */ +#include #include #include #include diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index b78f23169d4e..ebeabc727f70 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 65894f05a801..2de5b60ee8c8 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/scsi/scsicam.c b/drivers/scsi/scsicam.c index 6803b1e26ecc..92d24d6dcb39 100644 --- a/drivers/scsi/scsicam.c +++ b/drivers/scsi/scsicam.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 43db715f1502..7867b7c4538e 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -32,7 +32,6 @@ #include #include #include -#include /* for fsync_bdev() */ #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/fs/block_dev.c b/fs/block_dev.c index 7866cdd9fe70..69a5b6fbee2b 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include "internal.h" @@ -82,13 +84,35 @@ static sector_t max_block(struct block_device *bdev) } /* Kill _all_ buffers and pagecache , dirty or not.. */ -static void kill_bdev(struct block_device *bdev) +void kill_bdev(struct block_device *bdev) { - if (bdev->bd_inode->i_mapping->nrpages == 0) + struct address_space *mapping = bdev->bd_inode->i_mapping; + + if (mapping->nrpages == 0) return; + invalidate_bh_lrus(); - truncate_inode_pages(bdev->bd_inode->i_mapping, 0); + truncate_inode_pages(mapping, 0); } +EXPORT_SYMBOL(kill_bdev); + +/* Invalidate clean unused buffers and pagecache. */ +void invalidate_bdev(struct block_device *bdev) +{ + struct address_space *mapping = bdev->bd_inode->i_mapping; + + if (mapping->nrpages == 0) + return; + + invalidate_bh_lrus(); + lru_add_drain_all(); /* make sure all lru add caches are flushed */ + invalidate_mapping_pages(mapping, 0, -1); + /* 99% of the time, we don't need to flush the cleancache on the bdev. + * But, for the strange corners, lets be cautious + */ + cleancache_flush_inode(mapping); +} +EXPORT_SYMBOL(invalidate_bdev); int set_blocksize(struct block_device *bdev, int size) { 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 @@ #include #include #include -#include static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); @@ -231,55 +230,6 @@ out: return ret; } -/* If invalidate_buffers() will trash dirty buffers, it means some kind - of fs corruption is going on. Trashing dirty data always imply losing - information that was supposed to be just stored on the physical layer - by the user. - - Thus invalidate_buffers in general usage is not allwowed to trash - dirty buffers. For example ioctl(FLSBLKBUF) expects dirty data to - be preserved. These buffers are simply skipped. - - We also skip buffers which are still in use. For example this can - happen if a userspace program is reading the block device. - - NOTE: In the case where the user removed a removable-media-disk even if - there's still dirty data not synced on disk (due a bug in the device driver - or due an error of the user), by not destroying the dirty buffers we could - generate corruption also on the next media inserted, thus a parameter is - necessary to handle this case in the most safe way possible (trying - to not corrupt also the new disk inserted with the data belonging to - the old now corrupted disk). Also for the ramdisk the natural thing - to do in order to release the ramdisk memory is to destroy dirty buffers. - - These are two special cases. Normal usage imply the device driver - to issue a sync on the device (without waiting I/O completion) and - then an invalidate_buffers call that doesn't trash dirty buffers. - - For handling cache coherency with the blkdev pagecache the 'update' case - is been introduced. It is needed to re-read from disk any pinned - buffer. NOTE: re-reading from disk is destructive so we can do it only - when we assume nobody is changing the buffercache under our I/O and when - we think the disk contains more recent information than the buffercache. - The update == 1 pass marks the buffers we need to update, the update == 2 - pass does the actual I/O. */ -void invalidate_bdev(struct block_device *bdev) -{ - struct address_space *mapping = bdev->bd_inode->i_mapping; - - if (mapping->nrpages == 0) - return; - - invalidate_bh_lrus(); - lru_add_drain_all(); /* make sure all lru add caches are flushed */ - invalidate_mapping_pages(mapping, 0, -1); - /* 99% of the time, we don't need to flush the cleancache on the bdev. - * But, for the strange corners, lets be cautious - */ - cleancache_flush_inode(mapping); -} -EXPORT_SYMBOL(invalidate_bdev); - /* * Kick the writeback threads then try to free up some ZONE_NORMAL memory. */ 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 @@ #include #include -#include #include "internal.h" #define list_to_page(head) (list_entry((head)->prev, struct page, lru)) diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 739fb59bcdc2..c37adb222113 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include 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 @@ #include #include #include -#include #include #include "internal.h" 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 @@ #include #include #include -#include +#include /* sync_mapping_buffers */ #include diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 5b572c89e6c4..5d81e92daf83 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -73,7 +73,6 @@ #include #include #include -#include #include #include #include "../internal.h" /* ugh */ 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 @@ #include #include #include -#include #include #include #include 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 @@ #include #include #include -#include #include #include #include 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 @@ #include #include #include -#include #include #include "internal.h" diff --git a/include/linux/fs.h b/include/linux/fs.h index cec429d76ab0..e853ba5eddd4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2092,6 +2092,7 @@ extern void bd_forget(struct inode *inode); extern void bdput(struct block_device *); extern void invalidate_bdev(struct block_device *); extern int sync_blockdev(struct block_device *bdev); +extern void kill_bdev(struct block_device *); extern struct super_block *freeze_bdev(struct block_device *); extern void emergency_thaw_all(void); extern int thaw_bdev(struct block_device *bdev, struct super_block *sb); @@ -2099,6 +2100,7 @@ extern int fsync_bdev(struct block_device *); #else static inline void bd_forget(struct inode *inode) {} static inline int sync_blockdev(struct block_device *bdev) { return 0; } +static inline void kill_bdev(struct block_device *bdev) {} static inline void invalidate_bdev(struct block_device *bdev) {} static inline struct super_block *freeze_bdev(struct block_device *sb) @@ -2415,6 +2417,7 @@ extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, int datasync); +extern void block_sync_page(struct page *page); /* fs/splice.c */ extern ssize_t generic_file_splice_read(struct file *, loff_t *, diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 11a594c4ba25..3739ecced085 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 50f08241f981..8616ef3025a4 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include /* __set_page_dirty_buffers */ #include #include diff --git a/mm/swap_state.c b/mm/swap_state.c index 78cc4d1f6cce..ea6b32d61873 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include From 8208a22bb8bd3c52ef634b4ff194f14892ab1713 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 25 Jul 2011 17:32:17 -0400 Subject: [PATCH 030/165] switch sys_mknodat(2) to umode_t Signed-off-by: Al Viro --- fs/namei.c | 4 ++-- include/linux/syscalls.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 5008f01787f5..f6b3c73e862c 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2489,7 +2489,7 @@ static int may_mknod(mode_t mode) } } -SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, int, mode, +SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode, unsigned, dev) { struct dentry *dentry; @@ -2536,7 +2536,7 @@ out_dput: return error; } -SYSCALL_DEFINE3(mknod, const char __user *, filename, int, mode, unsigned, dev) +SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, dev) { return sys_mknodat(AT_FDCWD, filename, mode, dev); } diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 86a24b1166d1..b3c16d8a6383 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -475,7 +475,7 @@ asmlinkage long sys_mincore(unsigned long start, size_t len, asmlinkage long sys_pivot_root(const char __user *new_root, const char __user *put_old); asmlinkage long sys_chroot(const char __user *filename); -asmlinkage long sys_mknod(const char __user *filename, int mode, +asmlinkage long sys_mknod(const char __user *filename, umode_t mode, unsigned dev); asmlinkage long sys_link(const char __user *oldname, const char __user *newname); @@ -755,7 +755,7 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, asmlinkage long sys_spu_create(const char __user *name, unsigned int flags, mode_t mode, int fd); -asmlinkage long sys_mknodat(int dfd, const char __user * filename, int mode, +asmlinkage long sys_mknodat(int dfd, const char __user * filename, umode_t mode, unsigned dev); asmlinkage long sys_mkdirat(int dfd, const char __user * pathname, int mode); asmlinkage long sys_unlinkat(int dfd, const char __user * pathname, int flag); From 18bb1db3e7607e4a997d50991a6f9fa5b0f8722c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 01:41:39 -0400 Subject: [PATCH 031/165] switch vfs_mkdir() and ->mkdir() to umode_t vfs_mkdir() gets int, but immediately drops everything that might not fit into umode_t and that's the only caller of ->mkdir()... Signed-off-by: Al Viro --- Documentation/filesystems/Locking | 2 +- Documentation/filesystems/vfs.txt | 2 +- drivers/staging/pohmelfs/dir.c | 2 +- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 2 +- fs/affs/affs.h | 2 +- fs/affs/namei.c | 4 ++-- fs/afs/dir.c | 6 +++--- fs/autofs4/root.c | 4 ++-- fs/bad_inode.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/dir.c | 4 ++-- fs/cifs/cifsfs.h | 2 +- fs/cifs/inode.c | 4 ++-- fs/coda/dir.c | 4 ++-- fs/configfs/dir.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/exofs/namei.c | 2 +- fs/ext2/namei.c | 2 +- fs/ext3/namei.c | 2 +- fs/ext4/namei.c | 2 +- fs/fat/namei_msdos.c | 2 +- fs/fat/namei_vfat.c | 2 +- fs/fuse/dir.c | 2 +- fs/gfs2/inode.c | 2 +- fs/hfs/dir.c | 2 +- fs/hfsplus/dir.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/namei.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/jffs2/dir.c | 4 ++-- fs/jfs/namei.c | 2 +- fs/logfs/dir.c | 2 +- fs/minix/namei.c | 2 +- fs/namei.c | 2 +- fs/ncpfs/dir.c | 4 ++-- fs/nfs/dir.c | 4 ++-- fs/nilfs2/namei.c | 2 +- fs/ocfs2/dlmfs/dlmfs.c | 2 +- fs/ocfs2/namei.c | 2 +- fs/omfs/dir.c | 2 +- fs/ramfs/inode.c | 2 +- fs/reiserfs/namei.c | 2 +- fs/reiserfs/xattr.c | 2 +- fs/sysv/namei.c | 2 +- fs/ubifs/dir.c | 4 ++-- fs/udf/namei.c | 2 +- fs/ufs/namei.c | 2 +- fs/xfs/xfs_iops.c | 2 +- include/linux/fs.h | 4 ++-- include/linux/security.h | 4 ++-- kernel/cgroup.c | 4 ++-- mm/shmem.c | 2 +- security/capability.c | 2 +- security/security.c | 2 +- security/selinux/hooks.c | 2 +- 56 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index d819ba16a0c7..6c7676d9c0ea 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -43,7 +43,7 @@ ata *); int (*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *); int (*symlink) (struct inode *,struct dentry *,const char *); - int (*mkdir) (struct inode *,struct dentry *,int); + int (*mkdir) (struct inode *,struct dentry *,umode_t); int (*rmdir) (struct inode *,struct dentry *); int (*mknod) (struct inode *,struct dentry *,int,dev_t); int (*rename) (struct inode *, struct dentry *, diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 43cbd0821721..0c147c79cdd8 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -346,7 +346,7 @@ struct inode_operations { int (*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *); int (*symlink) (struct inode *,struct dentry *,const char *); - int (*mkdir) (struct inode *,struct dentry *,int); + int (*mkdir) (struct inode *,struct dentry *,umode_t); int (*rmdir) (struct inode *,struct dentry *); int (*mknod) (struct inode *,struct dentry *,int,dev_t); int (*rename) (struct inode *, struct dentry *, diff --git a/drivers/staging/pohmelfs/dir.c b/drivers/staging/pohmelfs/dir.c index 7598e77672a5..d3ad4dde991f 100644 --- a/drivers/staging/pohmelfs/dir.c +++ b/drivers/staging/pohmelfs/dir.c @@ -667,7 +667,7 @@ static int pohmelfs_create(struct inode *dir, struct dentry *dentry, int mode, return pohmelfs_create_entry(dir, dentry, 0, mode); } -static int pohmelfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int pohmelfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int err; diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 2310cc9eb402..3e54900f3b7e 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -785,7 +785,7 @@ error: * */ -static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int err; u32 perm; diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 0b5745e21946..87e46b19b21b 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -395,7 +395,7 @@ err_clunk_old_fid: */ static int v9fs_vfs_mkdir_dotl(struct inode *dir, - struct dentry *dentry, int omode) + struct dentry *dentry, umode_t omode) { int err; struct v9fs_session_info *v9ses; diff --git a/fs/affs/affs.h b/fs/affs/affs.h index c2b9c79eb64e..8abcad7c935f 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -157,7 +157,7 @@ extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int l extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *); extern int affs_unlink(struct inode *dir, struct dentry *dentry); extern int affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *); -extern int affs_mkdir(struct inode *dir, struct dentry *dentry, int mode); +extern int affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); extern int affs_rmdir(struct inode *dir, struct dentry *dentry); extern int affs_link(struct dentry *olddentry, struct inode *dir, struct dentry *dentry); diff --git a/fs/affs/namei.c b/fs/affs/namei.c index 780a11dc6318..7bb7660f805d 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -285,12 +285,12 @@ affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata } int -affs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; int error; - pr_debug("AFFS: mkdir(%lu,\"%.*s\",0%o)\n",dir->i_ino, + pr_debug("AFFS: mkdir(%lu,\"%.*s\",0%ho)\n",dir->i_ino, (int)dentry->d_name.len,dentry->d_name.name,mode); inode = affs_new_inode(dir); diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 1b0b19550015..e6ea58abde3b 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -30,7 +30,7 @@ static int afs_lookup_filldir(void *_cookie, const char *name, int nlen, loff_t fpos, u64 ino, unsigned dtype); static int afs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd); -static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode); +static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); static int afs_rmdir(struct inode *dir, struct dentry *dentry); static int afs_unlink(struct inode *dir, struct dentry *dentry); static int afs_link(struct dentry *from, struct inode *dir, @@ -764,7 +764,7 @@ static void afs_d_release(struct dentry *dentry) /* * create a directory on an AFS filesystem */ -static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct afs_file_status status; struct afs_callback cb; @@ -777,7 +777,7 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode) dvnode = AFS_FS_I(dir); - _enter("{%x:%u},{%s},%o", + _enter("{%x:%u},{%s},%ho", dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); ret = -ENAMETOOLONG; 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 @@ static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *); static int autofs4_dir_unlink(struct inode *,struct dentry *); static int autofs4_dir_rmdir(struct inode *,struct dentry *); -static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); +static int autofs4_dir_mkdir(struct inode *,struct dentry *,umode_t); static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); #ifdef CONFIG_COMPAT static 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) return 0; } -static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); struct autofs_info *ino = autofs4_dentry_ino(dentry); diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 9205cf25f1c6..5a2738c1f315 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c @@ -202,7 +202,7 @@ static int bad_inode_symlink (struct inode *dir, struct dentry *dentry, } static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry, - int mode) + umode_t mode) { return -EIO; } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index f8ff9738558a..e30de56e6b62 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4792,7 +4792,7 @@ fail: return err; } -static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode = NULL; struct btrfs_trans_handle *trans; diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 98954003a8d3..96141ae3d8be 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -753,7 +753,7 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry, return err; } -static int ceph_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb); struct ceph_mds_client *mdsc = fsc->mdsc; @@ -767,7 +767,7 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, int mode) dout("mksnap dir %p snap '%.*s' dn %p\n", dir, dentry->d_name.len, dentry->d_name.name, dentry); } else if (ceph_snap(dir) == CEPH_NOSNAP) { - dout("mkdir dir %p dn %p mode 0%o\n", dir, dentry, mode); + dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); op = CEPH_MDS_OP_MKDIR; } else { goto out; diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 30ff56005d8f..add64454fd51 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -51,7 +51,7 @@ extern struct dentry *cifs_lookup(struct inode *, struct dentry *, extern int cifs_unlink(struct inode *dir, struct dentry *dentry); extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *); extern int cifs_mknod(struct inode *, struct dentry *, int, dev_t); -extern int cifs_mkdir(struct inode *, struct dentry *, int); +extern int cifs_mkdir(struct inode *, struct dentry *, umode_t); extern int cifs_rmdir(struct inode *, struct dentry *); extern int cifs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); 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: return rc; } -int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) +int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode) { int rc = 0, tmprc; int xid; @@ -1275,7 +1275,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) struct inode *newinode = NULL; struct cifs_fattr fattr; - cFYI(1, "In cifs_mkdir, mode = 0x%x inode = 0x%p", mode, inode); + cFYI(1, "In cifs_mkdir, mode = 0x%hx inode = 0x%p", mode, inode); cifs_sb = CIFS_SB(inode->i_sb); tlink = cifs_sb_tlink(cifs_sb); diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 28e7e135cfab..a74ae6fcfb7e 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c @@ -37,7 +37,7 @@ static int coda_link(struct dentry *old_dentry, struct inode *dir_inode, static int coda_unlink(struct inode *dir_inode, struct dentry *entry); static int coda_symlink(struct inode *dir_inode, struct dentry *entry, const char *symname); -static int coda_mkdir(struct inode *dir_inode, struct dentry *entry, int mode); +static int coda_mkdir(struct inode *dir_inode, struct dentry *entry, umode_t mode); static int coda_rmdir(struct inode *dir_inode, struct dentry *entry); static int coda_rename(struct inode *old_inode, struct dentry *old_dentry, struct inode *new_inode, struct dentry *new_dentry); @@ -223,7 +223,7 @@ err_out: return error; } -static int coda_mkdir(struct inode *dir, struct dentry *de, int mode) +static int coda_mkdir(struct inode *dir, struct dentry *de, umode_t mode) { struct inode *inode; struct coda_vattr attrs; diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 1c5296911104..5ddd7ebd9dcd 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -1170,7 +1170,7 @@ void configfs_undepend_item(struct configfs_subsystem *subsys, } EXPORT_SYMBOL(configfs_undepend_item); -static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int configfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int ret = 0; int module_got = 0; diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 32f90a3ae63e..ebf8726482b6 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -559,7 +559,7 @@ out_lock: return rc; } -static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int rc; struct dentry *lower_dentry; diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c index b54c43775f17..ff1c8286cd69 100644 --- a/fs/exofs/namei.c +++ b/fs/exofs/namei.c @@ -153,7 +153,7 @@ static int exofs_link(struct dentry *old_dentry, struct inode *dir, return exofs_add_nondir(dentry, inode); } -static int exofs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int exofs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; int err = -EMLINK; diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 761fde807fc9..e3f3672b2020 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c @@ -214,7 +214,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir, return err; } -static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) +static int ext2_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) { struct inode * inode; int err = -EMLINK; diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 642dc6d66dfd..08ecb53a33ea 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1768,7 +1768,7 @@ retry: return err; } -static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode) +static int ext3_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) { handle_t *handle; struct inode * inode; diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index aa4c782c9dd7..e506746724cf 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1806,7 +1806,7 @@ retry: return err; } -static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { handle_t *handle; struct inode *inode; diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c index 216b419f30e2..d1f53cae897c 100644 --- a/fs/fat/namei_msdos.c +++ b/fs/fat/namei_msdos.c @@ -346,7 +346,7 @@ out: } /***** Make a directory */ -static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct super_block *sb = dir->i_sb; struct fat_slot_info sinfo; diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index a87a65663c25..fde2eda6332e 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c @@ -870,7 +870,7 @@ out: return err; } -static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct super_block *sb = dir->i_sb; struct inode *inode; diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 9f63e493a9b6..4848a1acb3bb 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -585,7 +585,7 @@ static int fuse_create(struct inode *dir, struct dentry *entry, int mode, return fuse_mknod(dir, entry, mode, 0); } -static int fuse_mkdir(struct inode *dir, struct dentry *entry, int mode) +static int fuse_mkdir(struct inode *dir, struct dentry *entry, umode_t mode) { struct fuse_mkdir_in inarg; struct fuse_conn *fc = get_fuse_conn(dir); diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index cfd4959b218c..eecfc39c07e6 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1129,7 +1129,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry, * Returns: errno */ -static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { return gfs2_create_inode(dir, dentry, S_IFDIR | mode, 0, NULL, 0, 0); } diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c index bce4eef91a06..06dc161e911c 100644 --- a/fs/hfs/dir.c +++ b/fs/hfs/dir.c @@ -216,7 +216,7 @@ static int hfs_create(struct inode *dir, struct dentry *dentry, int mode, * in a directory, given the inode for the parent directory and the * name (and its length) of the new directory. */ -static int hfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int hfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; int res; diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 4536cd3f15ae..ed321f0384d7 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -459,7 +459,7 @@ static int hfsplus_create(struct inode *dir, struct dentry *dentry, int mode, return hfsplus_mknod(dir, dentry, mode, 0); } -static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int hfsplus_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { return hfsplus_mknod(dir, dentry, mode | S_IFDIR, 0); } diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 343ea632b97c..d35240fbbd73 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -676,7 +676,7 @@ int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to) return err; } -int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode) +int hostfs_mkdir(struct inode *ino, struct dentry *dentry, umode_t mode) { char *file; int err; diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index ea91fcb0ef9b..a2f89f2b9503 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c @@ -8,7 +8,7 @@ #include #include "hpfs_fn.h" -static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { const unsigned char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 9c4ec538725b..ba269706e798 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -523,7 +523,7 @@ static int hugetlbfs_mknod(struct inode *dir, return error; } -static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int retval = hugetlbfs_mknod(dir, dentry, mode | S_IFDIR, 0); if (!retval) diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index be6169bd8acd..5dc458f19bc9 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c @@ -29,7 +29,7 @@ static struct dentry *jffs2_lookup (struct inode *,struct dentry *, static int jffs2_link (struct dentry *,struct inode *,struct dentry *); static int jffs2_unlink (struct inode *,struct dentry *); static int jffs2_symlink (struct inode *,struct dentry *,const char *); -static int jffs2_mkdir (struct inode *,struct dentry *,int); +static int jffs2_mkdir (struct inode *,struct dentry *,umode_t); static int jffs2_rmdir (struct inode *,struct dentry *); static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t); static int jffs2_rename (struct inode *, struct dentry *, @@ -450,7 +450,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char } -static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) +static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode) { struct jffs2_inode_info *f, *dir_f; struct jffs2_sb_info *c; diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index a112ad96e474..17ea85835715 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -205,7 +205,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, * note: * EACCESS: user needs search+write permission on the parent directory */ -static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) +static int jfs_mkdir(struct inode *dip, struct dentry *dentry, umode_t mode) { int rc = 0; tid_t tid; /* transaction id */ diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c index b7d7f67cee5a..25c5cbf8c123 100644 --- a/fs/logfs/dir.c +++ b/fs/logfs/dir.c @@ -482,7 +482,7 @@ out: return ret; } -static int logfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int logfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; diff --git a/fs/minix/namei.c b/fs/minix/namei.c index 6e6777f1b4b2..0e7a1a22e554 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c @@ -103,7 +103,7 @@ static int minix_link(struct dentry * old_dentry, struct inode * dir, return add_nondir(dentry, inode); } -static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode) +static int minix_mkdir(struct inode * dir, struct dentry *dentry, umode_t mode) { struct inode * inode; int err = -EMLINK; diff --git a/fs/namei.c b/fs/namei.c index f6b3c73e862c..443c703249b3 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2541,7 +2541,7 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, d return sys_mknodat(AT_FDCWD, filename, mode, dev); } -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int error = may_create(dir, dentry); diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 9c51f621e901..dfb51f084407 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -33,7 +33,7 @@ static int ncp_readdir(struct file *, void *, filldir_t); static int ncp_create(struct inode *, struct dentry *, int, struct nameidata *); static struct dentry *ncp_lookup(struct inode *, struct dentry *, struct nameidata *); static int ncp_unlink(struct inode *, struct dentry *); -static int ncp_mkdir(struct inode *, struct dentry *, int); +static int ncp_mkdir(struct inode *, struct dentry *, umode_t); static int ncp_rmdir(struct inode *, struct dentry *); static int ncp_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); @@ -985,7 +985,7 @@ static int ncp_create(struct inode *dir, struct dentry *dentry, int mode, return ncp_create_new(dir, dentry, mode, 0, 0); } -static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int ncp_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct ncp_entry_info finfo; struct ncp_server *server = NCP_SERVER(dir); diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 23be134b3193..5d67d92a4248 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -48,7 +48,7 @@ static int nfs_closedir(struct inode *, struct file *); static int nfs_readdir(struct file *, void *, filldir_t); static struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *); static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *); -static int nfs_mkdir(struct inode *, struct dentry *, int); +static int nfs_mkdir(struct inode *, struct dentry *, umode_t); static int nfs_rmdir(struct inode *, struct dentry *); static int nfs_unlink(struct inode *, struct dentry *); static int nfs_symlink(struct inode *, struct dentry *, const char *); @@ -1719,7 +1719,7 @@ out_err: /* * See comments for nfs_proc_create regarding failed operations. */ -static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int nfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct iattr attr; int error; diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 768982de10e4..e5e7311f1b92 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -213,7 +213,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir, return err; } -static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; struct nilfs_transaction_info ti; diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index a9f007de1da8..77c8d8069461 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -488,7 +488,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent, /* SMP-safe */ static int dlmfs_mkdir(struct inode * dir, struct dentry * dentry, - int mode) + umode_t mode) { int status; struct inode *inode = NULL; diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index a8b2bfea574e..c779f8bfc8a6 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -602,7 +602,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, static int ocfs2_mkdir(struct inode *dir, struct dentry *dentry, - int mode) + umode_t mode) { int ret; diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c index 98e544274390..667dc7ff28c0 100644 --- a/fs/omfs/dir.c +++ b/fs/omfs/dir.c @@ -279,7 +279,7 @@ out_free_inode: return err; } -static int omfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int omfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { return omfs_add_node(dir, dentry, mode | S_IFDIR); } diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index 462ceb38fec6..61972bee0561 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -106,7 +106,7 @@ ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) return error; } -static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode) +static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) { int retval = ramfs_mknod(dir, dentry, mode | S_IFDIR, 0); if (!retval) diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 80058e8ce361..763239a7e8dd 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@ -721,7 +721,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode, return retval; } -static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int retval; struct inode *inode; 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) } #endif -static int xattr_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int xattr_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { BUG_ON(!mutex_is_locked(&dir->i_mutex)); return dir->i_op->mkdir(dir, dentry, mode); diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index e474fbcf8bde..3368425a4ce2 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -131,7 +131,7 @@ static int sysv_link(struct dentry * old_dentry, struct inode * dir, return add_nondir(dentry, inode); } -static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode) +static int sysv_mkdir(struct inode * dir, struct dentry *dentry, umode_t mode) { struct inode * inode; int err = -EMLINK; diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 683492043317..f5102f368160 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -712,7 +712,7 @@ out_cancel: return err; } -static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; struct ubifs_inode *dir_ui = ubifs_inode(dir); @@ -725,7 +725,7 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, int mode) * directory inode. */ - dbg_gen("dent '%.*s', mode %#x in dir ino %lu", + dbg_gen("dent '%.*s', mode %#hx in dir ino %lu", dentry->d_name.len, dentry->d_name.name, mode, dir->i_ino); err = ubifs_budget_space(c, &req); diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 4639e137222f..7f8ee32842be 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -640,7 +640,7 @@ out: return err; } -static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int udf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct inode *inode; struct udf_fileident_bh fibh; diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 639d49162241..fa743aaa327c 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -180,7 +180,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir, return error; } -static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode) +static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) { struct inode * inode; int err = -EMLINK; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 23ce927973a4..99b324d43c98 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -241,7 +241,7 @@ STATIC int xfs_vn_mkdir( struct inode *dir, struct dentry *dentry, - int mode) + umode_t mode) { return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0); } diff --git a/include/linux/fs.h b/include/linux/fs.h index cec429d76ab0..3f7bd8b12e37 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1517,7 +1517,7 @@ extern void unlock_super(struct super_block *); * VFS helper functions.. */ extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *); -extern int vfs_mkdir(struct inode *, struct dentry *, int); +extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t); extern int vfs_symlink(struct inode *, struct dentry *, const char *); extern int vfs_link(struct dentry *, struct inode *, struct dentry *); @@ -1623,7 +1623,7 @@ struct inode_operations { int (*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *); int (*symlink) (struct inode *,struct dentry *,const char *); - int (*mkdir) (struct inode *,struct dentry *,int); + int (*mkdir) (struct inode *,struct dentry *,umode_t); int (*rmdir) (struct inode *,struct dentry *); int (*mknod) (struct inode *,struct dentry *,int,dev_t); int (*rename) (struct inode *, struct dentry *, diff --git a/include/linux/security.h b/include/linux/security.h index e8c619d39291..16cbc58cb13b 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1453,7 +1453,7 @@ struct security_operations { int (*inode_unlink) (struct inode *dir, struct dentry *dentry); int (*inode_symlink) (struct inode *dir, struct dentry *dentry, const char *old_name); - int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode); + int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, umode_t mode); int (*inode_rmdir) (struct inode *dir, struct dentry *dentry); int (*inode_mknod) (struct inode *dir, struct dentry *dentry, int mode, dev_t dev); @@ -1722,7 +1722,7 @@ int security_inode_link(struct dentry *old_dentry, struct inode *dir, int security_inode_unlink(struct inode *dir, struct dentry *dentry); int security_inode_symlink(struct inode *dir, struct dentry *dentry, const char *old_name); -int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode); +int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); int security_inode_rmdir(struct inode *dir, struct dentry *dentry); int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev); int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, diff --git a/kernel/cgroup.c b/kernel/cgroup.c index a184470cf9b5..b37a0ea55114 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -760,7 +760,7 @@ EXPORT_SYMBOL_GPL(cgroup_unlock); * -> cgroup_mkdir. */ -static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, int mode); +static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); static struct dentry *cgroup_lookup(struct inode *, struct dentry *, struct nameidata *); static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry); static int cgroup_populate_dir(struct cgroup *cgrp); @@ -3846,7 +3846,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, return err; } -static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct cgroup *c_parent = dentry->d_parent->d_fsdata; diff --git a/mm/shmem.c b/mm/shmem.c index c58594c06569..b8a8ddf069d0 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1489,7 +1489,7 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) return error; } -static int shmem_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int shmem_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int error; diff --git a/security/capability.c b/security/capability.c index 2984ea4f776f..ddd17892826a 100644 --- a/security/capability.c +++ b/security/capability.c @@ -148,7 +148,7 @@ static int cap_inode_symlink(struct inode *inode, struct dentry *dentry, } static int cap_inode_mkdir(struct inode *inode, struct dentry *dentry, - int mask) + umode_t mask) { return 0; } diff --git a/security/security.c b/security/security.c index e2f684aeb70c..be49eb5768bc 100644 --- a/security/security.c +++ b/security/security.c @@ -506,7 +506,7 @@ int security_inode_symlink(struct inode *dir, struct dentry *dentry, return security_ops->inode_symlink(dir, dentry, old_name); } -int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode) +int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { if (unlikely(IS_PRIVATE(dir))) return 0; diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 1126c10a5e82..ad74ad24ce2a 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2618,7 +2618,7 @@ static int selinux_inode_symlink(struct inode *dir, struct dentry *dentry, const return may_create(dir, dentry, SECCLASS_LNK_FILE); } -static int selinux_inode_mkdir(struct inode *dir, struct dentry *dentry, int mask) +static int selinux_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mask) { return may_create(dir, dentry, SECCLASS_DIR); } From 4acdaf27ebe2034c342f3be57ef49aed1ad885ef Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 01:42:34 -0400 Subject: [PATCH 032/165] switch ->create() to umode_t vfs_create() ignores everything outside of 16bit subset of its mode argument; switching it to umode_t is obviously equivalent and it's the only caller of the method Signed-off-by: Al Viro --- Documentation/filesystems/Locking | 2 +- Documentation/filesystems/vfs.txt | 2 +- drivers/staging/pohmelfs/dir.c | 2 +- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 4 ++-- fs/affs/affs.h | 2 +- fs/affs/namei.c | 4 ++-- fs/afs/dir.c | 6 +++--- fs/bad_inode.c | 2 +- fs/bfs/dir.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/dir.c | 2 +- fs/cifs/cifsfs.h | 2 +- fs/cifs/dir.c | 2 +- fs/coda/dir.c | 4 ++-- fs/ecryptfs/inode.c | 2 +- fs/exofs/namei.c | 2 +- fs/ext2/namei.c | 2 +- fs/ext3/namei.c | 2 +- fs/ext4/namei.c | 2 +- fs/fat/namei_msdos.c | 2 +- fs/fat/namei_vfat.c | 2 +- fs/fuse/dir.c | 2 +- fs/gfs2/inode.c | 2 +- fs/hfs/dir.c | 2 +- fs/hfsplus/dir.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/namei.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/jffs2/dir.c | 6 +++--- fs/jfs/namei.c | 2 +- fs/logfs/dir.c | 2 +- fs/minix/namei.c | 2 +- fs/namei.c | 2 +- fs/ncpfs/dir.c | 4 ++-- fs/nfs/dir.c | 12 ++++++------ fs/nilfs2/namei.c | 2 +- fs/ocfs2/dlmfs/dlmfs.c | 2 +- fs/ocfs2/namei.c | 2 +- fs/omfs/dir.c | 2 +- fs/ramfs/inode.c | 2 +- fs/reiserfs/namei.c | 2 +- fs/sysv/namei.c | 2 +- fs/ubifs/dir.c | 4 ++-- fs/udf/namei.c | 2 +- fs/ufs/namei.c | 2 +- fs/xfs/xfs_iops.c | 2 +- include/linux/fs.h | 4 ++-- include/linux/security.h | 6 +++--- ipc/mqueue.c | 4 ++-- mm/shmem.c | 2 +- security/capability.c | 2 +- security/security.c | 2 +- security/selinux/hooks.c | 2 +- 54 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 6c7676d9c0ea..38d00c8898b9 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -37,7 +37,7 @@ d_manage: no no yes (ref-walk) maybe --------------------------- inode_operations --------------------------- prototypes: - int (*create) (struct inode *,struct dentry *,int, struct nameidata *); + int (*create) (struct inode *,struct dentry *,umode_t, struct nameidata *); struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameid ata *); int (*link) (struct dentry *,struct inode *,struct dentry *); diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 0c147c79cdd8..e7b900bc6285 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -341,7 +341,7 @@ This describes how the VFS can manipulate an inode in your filesystem. As of kernel 2.6.22, the following members are defined: struct inode_operations { - int (*create) (struct inode *,struct dentry *,int, struct nameidata *); + int (*create) (struct inode *,struct dentry *, umode_t, struct nameidata *); struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *); int (*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *); diff --git a/drivers/staging/pohmelfs/dir.c b/drivers/staging/pohmelfs/dir.c index d3ad4dde991f..c33e959b6efe 100644 --- a/drivers/staging/pohmelfs/dir.c +++ b/drivers/staging/pohmelfs/dir.c @@ -661,7 +661,7 @@ static int pohmelfs_create_entry(struct inode *dir, struct dentry *dentry, u64 s /* * VFS create and mkdir callbacks. */ -static int pohmelfs_create(struct inode *dir, struct dentry *dentry, int mode, +static int pohmelfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { return pohmelfs_create_entry(dir, dentry, 0, mode); diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 3e54900f3b7e..15cd5cef4485 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -702,7 +702,7 @@ error: */ static int -v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, +v9fs_vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { int err; diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 87e46b19b21b..c4731381f0c5 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -253,7 +253,7 @@ int v9fs_open_to_dotl_flags(int flags) */ static int -v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, +v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, umode_t omode, struct nameidata *nd) { int err = 0; @@ -284,7 +284,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, name = (char *) dentry->d_name.name; P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x " - "mode:0x%x\n", name, flags, omode); + "mode:0x%hx\n", name, flags, omode); dfid = v9fs_fid_lookup(dentry->d_parent); if (IS_ERR(dfid)) { diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 8abcad7c935f..9cad9b4a9af7 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -156,7 +156,7 @@ extern void affs_free_bitmap(struct super_block *sb); extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len); extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *); extern int affs_unlink(struct inode *dir, struct dentry *dentry); -extern int affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *); +extern int affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *); extern int affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); extern int affs_rmdir(struct inode *dir, struct dentry *dentry); extern int affs_link(struct dentry *olddentry, struct inode *dir, diff --git a/fs/affs/namei.c b/fs/affs/namei.c index 7bb7660f805d..47806940aac0 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -255,13 +255,13 @@ affs_unlink(struct inode *dir, struct dentry *dentry) } int -affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) +affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct super_block *sb = dir->i_sb; struct inode *inode; int error; - pr_debug("AFFS: create(%lu,\"%.*s\",0%o)\n",dir->i_ino,(int)dentry->d_name.len, + pr_debug("AFFS: create(%lu,\"%.*s\",0%ho)\n",dir->i_ino,(int)dentry->d_name.len, dentry->d_name.name,mode); inode = affs_new_inode(dir); diff --git a/fs/afs/dir.c b/fs/afs/dir.c index e6ea58abde3b..e22dc4b4a503 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -28,7 +28,7 @@ static int afs_d_delete(const struct dentry *dentry); static void afs_d_release(struct dentry *dentry); static int afs_lookup_filldir(void *_cookie, const char *name, int nlen, loff_t fpos, u64 ino, unsigned dtype); -static int afs_create(struct inode *dir, struct dentry *dentry, int mode, +static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd); static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); static int afs_rmdir(struct inode *dir, struct dentry *dentry); @@ -948,7 +948,7 @@ error: /* * create a regular file on an AFS filesystem */ -static int afs_create(struct inode *dir, struct dentry *dentry, int mode, +static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct afs_file_status status; @@ -962,7 +962,7 @@ static int afs_create(struct inode *dir, struct dentry *dentry, int mode, dvnode = AFS_FS_I(dir); - _enter("{%x:%u},{%s},%o,", + _enter("{%x:%u},{%s},%ho,", dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); ret = -ENAMETOOLONG; diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 5a2738c1f315..8087fbc35f43 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c @@ -173,7 +173,7 @@ static const struct file_operations bad_file_ops = }; static int bad_inode_create (struct inode *dir, struct dentry *dentry, - int mode, struct nameidata *nd) + umode_t mode, struct nameidata *nd) { return -EIO; } 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 = { extern void dump_imap(const char *, struct super_block *); -static int bfs_create(struct inode *dir, struct dentry *dentry, int mode, +static int bfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { int err; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e30de56e6b62..19630aacb320 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4665,7 +4665,7 @@ out_unlock: } static int btrfs_create(struct inode *dir, struct dentry *dentry, - int mode, struct nameidata *nd) + umode_t mode, struct nameidata *nd) { struct btrfs_trans_handle *trans; struct btrfs_root *root = BTRFS_I(dir)->root; diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 96141ae3d8be..9848d686591c 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -699,7 +699,7 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry, return err; } -static int ceph_create(struct inode *dir, struct dentry *dentry, int mode, +static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { dout("create in dir %p dentry %p name '%.*s'\n", diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index add64454fd51..358724df558b 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -44,7 +44,7 @@ extern const struct address_space_operations cifs_addr_ops_smallbuf; /* Functions related to inodes */ extern const struct inode_operations cifs_dir_inode_ops; extern struct inode *cifs_root_iget(struct super_block *); -extern int cifs_create(struct inode *, struct dentry *, int, +extern int cifs_create(struct inode *, struct dentry *, umode_t, struct nameidata *); extern struct dentry *cifs_lookup(struct inode *, struct dentry *, struct nameidata *); diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index d7eeb9d3ed6f..2dc8be86be09 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -136,7 +136,7 @@ cifs_bp_rename_retry: /* Inode operations in similar order to how they appear in Linux file fs.h */ int -cifs_create(struct inode *inode, struct dentry *direntry, int mode, +cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode, struct nameidata *nd) { int rc = -ENOENT; diff --git a/fs/coda/dir.c b/fs/coda/dir.c index a74ae6fcfb7e..83d2fd8ec24b 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c @@ -30,7 +30,7 @@ #include "coda_int.h" /* dir inode-ops */ -static int coda_create(struct inode *dir, struct dentry *new, int mode, struct nameidata *nd); +static int coda_create(struct inode *dir, struct dentry *new, umode_t mode, struct nameidata *nd); static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd); static int coda_link(struct dentry *old_dentry, struct inode *dir_inode, struct dentry *entry); @@ -191,7 +191,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir) } /* creation routines: create, mknod, mkdir, link, symlink */ -static int coda_create(struct inode *dir, struct dentry *de, int mode, struct nameidata *nd) +static int coda_create(struct inode *dir, struct dentry *de, umode_t mode, struct nameidata *nd) { int error; const char *name=de->d_name.name; diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index ebf8726482b6..81e6542ab20f 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -267,7 +267,7 @@ out: */ static int ecryptfs_create(struct inode *directory_inode, struct dentry *ecryptfs_dentry, - int mode, struct nameidata *nd) + umode_t mode, struct nameidata *nd) { struct inode *ecryptfs_inode; int rc; diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c index ff1c8286cd69..58644544849d 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, return d_splice_alias(inode, dentry); } -static int exofs_create(struct inode *dir, struct dentry *dentry, int mode, +static int exofs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct inode *inode = exofs_new_inode(dir, mode); diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index e3f3672b2020..cb759e661b15 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c @@ -94,7 +94,7 @@ struct dentry *ext2_get_parent(struct dentry *child) * If the create succeeds, we fill in the inode information * with d_instantiate(). */ -static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd) +static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode, struct nameidata *nd) { struct inode *inode; diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 08ecb53a33ea..6047d121f537 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1698,7 +1698,7 @@ static int ext3_add_nondir(handle_t *handle, * If the create succeeds, we fill in the inode information * with d_instantiate(). */ -static int ext3_create (struct inode * dir, struct dentry * dentry, int mode, +static int ext3_create (struct inode * dir, struct dentry * dentry, umode_t mode, struct nameidata *nd) { handle_t *handle; diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index e506746724cf..77306f36a610 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1736,7 +1736,7 @@ static int ext4_add_nondir(handle_t *handle, * If the create succeeds, we fill in the inode information * with d_instantiate(). */ -static int ext4_create(struct inode *dir, struct dentry *dentry, int mode, +static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { handle_t *handle; diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c index d1f53cae897c..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, } /***** Create a file */ -static int msdos_create(struct inode *dir, struct dentry *dentry, int mode, +static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct super_block *sb = dir->i_sb; diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index fde2eda6332e..3a444b4e2368 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c @@ -781,7 +781,7 @@ error: return ERR_PTR(err); } -static int vfat_create(struct inode *dir, struct dentry *dentry, int mode, +static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct super_block *sb = dir->i_sb; diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 4848a1acb3bb..603bb8a9b8ca 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -573,7 +573,7 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, return create_new_entry(fc, req, dir, entry, mode); } -static int fuse_create(struct inode *dir, struct dentry *entry, int mode, +static int fuse_create(struct inode *dir, struct dentry *entry, umode_t mode, struct nameidata *nd) { if (nd) { diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index eecfc39c07e6..aadf792be750 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -760,7 +760,7 @@ fail: */ static int gfs2_create(struct inode *dir, struct dentry *dentry, - int mode, struct nameidata *nd) + umode_t mode, struct nameidata *nd) { int excl = 0; if (nd && (nd->flags & LOOKUP_EXCL)) diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c index 06dc161e911c..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) * a directory and return a corresponding inode, given the inode for * the directory and the name (and its length) of the new file. */ -static int hfs_create(struct inode *dir, struct dentry *dentry, int mode, +static int hfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct inode *inode; diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index ed321f0384d7..ef6547ca4214 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -453,7 +453,7 @@ out: return res; } -static int hfsplus_create(struct inode *dir, struct dentry *dentry, int mode, +static int hfsplus_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { return hfsplus_mknod(dir, dentry, mode, 0); diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index d35240fbbd73..3a3a530f5bad 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -551,7 +551,7 @@ static int read_name(struct inode *ino, char *name) return 0; } -int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, +int hostfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct inode *inode; diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index a2f89f2b9503..769f76c7303a 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c @@ -115,7 +115,7 @@ bail: return err; } -static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) +static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { const unsigned char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index ba269706e798..57996c3d8d0c 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -531,7 +531,7 @@ static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mod return retval; } -static int hugetlbfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) +static int hugetlbfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { return hugetlbfs_mknod(dir, dentry, mode | S_IFREG, 0); } diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 5dc458f19bc9..16a75e9a038d 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c @@ -22,7 +22,7 @@ static int jffs2_readdir (struct file *, void *, filldir_t); -static int jffs2_create (struct inode *,struct dentry *,int, +static int jffs2_create (struct inode *,struct dentry *,umode_t, struct nameidata *); static struct dentry *jffs2_lookup (struct inode *,struct dentry *, struct nameidata *); @@ -169,8 +169,8 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) /***********************************************************************/ -static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode, - struct nameidata *nd) +static int jffs2_create(struct inode *dir_i, struct dentry *dentry, + umode_t mode, struct nameidata *nd) { struct jffs2_raw_inode *ri; struct jffs2_inode_info *f, *dir_f; diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 17ea85835715..6c0b1ab8107d 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -72,7 +72,7 @@ static inline void free_ea_wmap(struct inode *inode) * RETURN: Errors from subroutines * */ -static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, +static int jfs_create(struct inode *dip, struct dentry *dentry, umode_t mode, struct nameidata *nd) { int rc = 0; diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c index 25c5cbf8c123..a74aa461d53c 100644 --- a/fs/logfs/dir.c +++ b/fs/logfs/dir.c @@ -501,7 +501,7 @@ static int logfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) return __logfs_create(dir, dentry, inode, NULL, 0); } -static int logfs_create(struct inode *dir, struct dentry *dentry, int mode, +static int logfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct inode *inode; diff --git a/fs/minix/namei.c b/fs/minix/namei.c index 0e7a1a22e554..c652650bf5a3 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c @@ -54,7 +54,7 @@ static int minix_mknod(struct inode * dir, struct dentry *dentry, int mode, dev_ return error; } -static int minix_create(struct inode * dir, struct dentry *dentry, int mode, +static int minix_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { return minix_mknod(dir, dentry, mode, 0); diff --git a/fs/namei.c b/fs/namei.c index 443c703249b3..05d1c2ceb131 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1976,7 +1976,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2) } } -int vfs_create(struct inode *dir, struct dentry *dentry, int mode, +int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { int error = may_create(dir, dentry); diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index dfb51f084407..98d1b8c6fd8c 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -30,7 +30,7 @@ static void ncp_do_readdir(struct file *, void *, filldir_t, static int ncp_readdir(struct file *, void *, filldir_t); -static int ncp_create(struct inode *, struct dentry *, int, struct nameidata *); +static int ncp_create(struct inode *, struct dentry *, umode_t, struct nameidata *); static struct dentry *ncp_lookup(struct inode *, struct dentry *, struct nameidata *); static int ncp_unlink(struct inode *, struct dentry *); static int ncp_mkdir(struct inode *, struct dentry *, umode_t); @@ -979,7 +979,7 @@ out: return error; } -static int ncp_create(struct inode *dir, struct dentry *dentry, int mode, +static int ncp_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { return ncp_create_new(dir, dentry, mode, 0, 0); diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 5d67d92a4248..7cdee1d4160f 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -47,7 +47,7 @@ static int nfs_opendir(struct inode *, struct file *); static int nfs_closedir(struct inode *, struct file *); static int nfs_readdir(struct file *, void *, filldir_t); static struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *); -static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *); +static int nfs_create(struct inode *, struct dentry *, umode_t, struct nameidata *); static int nfs_mkdir(struct inode *, struct dentry *, umode_t); static int nfs_rmdir(struct inode *, struct dentry *); static int nfs_unlink(struct inode *, struct dentry *); @@ -112,7 +112,7 @@ const struct inode_operations nfs3_dir_inode_operations = { #ifdef CONFIG_NFS_V4 static struct dentry *nfs_atomic_lookup(struct inode *, struct dentry *, struct nameidata *); -static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd); +static int nfs_open_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd); const struct inode_operations nfs4_dir_inode_operations = { .create = nfs_open_create, .lookup = nfs_atomic_lookup, @@ -1573,8 +1573,8 @@ no_open: return nfs_lookup_revalidate(dentry, nd); } -static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode, - struct nameidata *nd) +static int nfs_open_create(struct inode *dir, struct dentry *dentry, + umode_t mode, struct nameidata *nd) { struct nfs_open_context *ctx = NULL; struct iattr attr; @@ -1664,8 +1664,8 @@ out_error: * that the operation succeeded on the server, but an error in the * reply path made it appear to have failed. */ -static int nfs_create(struct inode *dir, struct dentry *dentry, int mode, - struct nameidata *nd) +static int nfs_create(struct inode *dir, struct dentry *dentry, + umode_t mode, struct nameidata *nd) { struct iattr attr; int error; diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index e5e7311f1b92..fcd86c38f968 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) * If the create succeeds, we fill in the inode information * with d_instantiate(). */ -static int nilfs_create(struct inode *dir, struct dentry *dentry, int mode, +static int nilfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct inode *inode; diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 77c8d8069461..ccb33289c29a 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -536,7 +536,7 @@ bail: static int dlmfs_create(struct inode *dir, struct dentry *dentry, - int mode, + umode_t mode, struct nameidata *nd) { int status = 0; diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index c779f8bfc8a6..46f46ffe77c5 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -617,7 +617,7 @@ static int ocfs2_mkdir(struct inode *dir, static int ocfs2_create(struct inode *dir, struct dentry *dentry, - int mode, + umode_t mode, struct nameidata *nd) { int ret; diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c index 667dc7ff28c0..d82599f49f6d 100644 --- a/fs/omfs/dir.c +++ b/fs/omfs/dir.c @@ -284,7 +284,7 @@ static int omfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) return omfs_add_node(dir, dentry, mode | S_IFDIR); } -static int omfs_create(struct inode *dir, struct dentry *dentry, int mode, +static int omfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { return omfs_add_node(dir, dentry, mode | S_IFREG); diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index 61972bee0561..c2ed2a36094e 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -114,7 +114,7 @@ static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) return retval; } -static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) +static int ramfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { return ramfs_mknod(dir, dentry, mode | S_IFREG, 0); } diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 763239a7e8dd..46db3b9fa7cf 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@ -572,7 +572,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, int mode) return 0; } -static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode, +static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { int retval; diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index 3368425a4ce2..d306eebeb6c1 100644 --- a/fs/sysv/namei.c +++ b/fs/sysv/namei.c @@ -80,7 +80,7 @@ static int sysv_mknod(struct inode * dir, struct dentry * dentry, int mode, dev_ return err; } -static int sysv_create(struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd) +static int sysv_create(struct inode * dir, struct dentry * dentry, umode_t mode, struct nameidata *nd) { return sysv_mknod(dir, dentry, mode, 0); } diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index f5102f368160..f332878ce4de 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -253,7 +253,7 @@ out: return ERR_PTR(err); } -static int ubifs_create(struct inode *dir, struct dentry *dentry, int mode, +static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct inode *inode; @@ -268,7 +268,7 @@ static int ubifs_create(struct inode *dir, struct dentry *dentry, int mode, * parent directory inode. */ - dbg_gen("dent '%.*s', mode %#x in dir ino %lu", + dbg_gen("dent '%.*s', mode %#hx in dir ino %lu", dentry->d_name.len, dentry->d_name.name, mode, dir->i_ino); err = ubifs_budget_space(c, &req); diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 7f8ee32842be..135a4ca01038 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, return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL); } -static int udf_create(struct inode *dir, struct dentry *dentry, int mode, +static int udf_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { struct udf_fileident_bh fibh; diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index fa743aaa327c..ba2a9d6c0314 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 * If the create succeeds, we fill in the inode information * with d_instantiate(). */ -static int ufs_create (struct inode * dir, struct dentry * dentry, int mode, +static int ufs_create (struct inode * dir, struct dentry * dentry, umode_t mode, struct nameidata *nd) { struct inode *inode; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 99b324d43c98..0efa4e51bebf 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -231,7 +231,7 @@ STATIC int xfs_vn_create( struct inode *dir, struct dentry *dentry, - int mode, + umode_t mode, struct nameidata *nd) { return xfs_vn_mknod(dir, dentry, mode, 0); diff --git a/include/linux/fs.h b/include/linux/fs.h index 3f7bd8b12e37..e40321a6e239 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1516,7 +1516,7 @@ extern void unlock_super(struct super_block *); /* * VFS helper functions.. */ -extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *); +extern int vfs_create(struct inode *, struct dentry *, umode_t, struct nameidata *); extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t); extern int vfs_symlink(struct inode *, struct dentry *, const char *); @@ -1619,7 +1619,7 @@ struct inode_operations { int (*readlink) (struct dentry *, char __user *,int); void (*put_link) (struct dentry *, struct nameidata *, void *); - int (*create) (struct inode *,struct dentry *,int, struct nameidata *); + int (*create) (struct inode *,struct dentry *,umode_t,struct nameidata *); int (*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *); int (*symlink) (struct inode *,struct dentry *,const char *); diff --git a/include/linux/security.h b/include/linux/security.h index 16cbc58cb13b..8fc22373db34 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1447,7 +1447,7 @@ struct security_operations { const struct qstr *qstr, char **name, void **value, size_t *len); int (*inode_create) (struct inode *dir, - struct dentry *dentry, int mode); + struct dentry *dentry, umode_t mode); int (*inode_link) (struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry); int (*inode_unlink) (struct inode *dir, struct dentry *dentry); @@ -1716,7 +1716,7 @@ int security_inode_init_security(struct inode *inode, struct inode *dir, int security_old_inode_init_security(struct inode *inode, struct inode *dir, const struct qstr *qstr, char **name, void **value, size_t *len); -int security_inode_create(struct inode *dir, struct dentry *dentry, int mode); +int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode); int security_inode_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry); int security_inode_unlink(struct inode *dir, struct dentry *dentry); @@ -2061,7 +2061,7 @@ static inline int security_old_inode_init_security(struct inode *inode, static inline int security_inode_create(struct inode *dir, struct dentry *dentry, - int mode) + umode_t mode) { return 0; } diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 4e0be364aa36..57ed704d2ca7 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -295,7 +295,7 @@ static void mqueue_evict_inode(struct inode *inode) } static int mqueue_create(struct inode *dir, struct dentry *dentry, - int mode, struct nameidata *nd) + umode_t mode, struct nameidata *nd) { struct inode *inode; struct mq_attr *attr = dentry->d_fsdata; @@ -610,7 +610,7 @@ static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr) * Invoked when creating a new queue via sys_mq_open */ static struct file *do_create(struct ipc_namespace *ipc_ns, struct dentry *dir, - struct dentry *dentry, int oflag, mode_t mode, + struct dentry *dentry, int oflag, umode_t mode, struct mq_attr *attr) { const struct cred *cred = current_cred(); diff --git a/mm/shmem.c b/mm/shmem.c index b8a8ddf069d0..542aad28928d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1499,7 +1499,7 @@ static int shmem_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) return 0; } -static int shmem_create(struct inode *dir, struct dentry *dentry, int mode, +static int shmem_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd) { return shmem_mknod(dir, dentry, mode | S_IFREG, 0); diff --git a/security/capability.c b/security/capability.c index ddd17892826a..ff18d0ca30bf 100644 --- a/security/capability.c +++ b/security/capability.c @@ -125,7 +125,7 @@ static int cap_inode_init_security(struct inode *inode, struct inode *dir, } static int cap_inode_create(struct inode *inode, struct dentry *dentry, - int mask) + umode_t mask) { return 0; } diff --git a/security/security.c b/security/security.c index be49eb5768bc..2420eed87639 100644 --- a/security/security.c +++ b/security/security.c @@ -475,7 +475,7 @@ int security_path_chroot(struct path *path) } #endif -int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) +int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode) { if (unlikely(IS_PRIVATE(dir))) return 0; diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index ad74ad24ce2a..a1eba2b9ea5c 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2598,7 +2598,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, return 0; } -static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int mask) +static int selinux_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode) { return may_create(dir, dentry, SECCLASS_FILE); } From 1a67aafb5f72a436ca044293309fa7e6351d6a35 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 01:52:52 -0400 Subject: [PATCH 033/165] switch ->mknod() to umode_t Signed-off-by: Al Viro --- Documentation/filesystems/Locking | 2 +- Documentation/filesystems/vfs.txt | 2 +- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 6 +++--- fs/bad_inode.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/dir.c | 4 ++-- fs/cifs/cifsfs.h | 2 +- fs/cifs/dir.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/exofs/namei.c | 2 +- fs/ext2/namei.c | 2 +- fs/ext3/namei.c | 2 +- fs/ext4/namei.c | 2 +- fs/fuse/dir.c | 2 +- fs/gfs2/inode.c | 2 +- fs/hfsplus/dir.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/namei.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/jffs2/dir.c | 4 ++-- fs/jfs/namei.c | 2 +- fs/logfs/dir.c | 2 +- fs/minix/namei.c | 2 +- fs/namei.c | 2 +- fs/ncpfs/dir.c | 6 +++--- fs/nfs/dir.c | 4 ++-- fs/nilfs2/namei.c | 2 +- fs/ocfs2/namei.c | 2 +- fs/ramfs/inode.c | 2 +- fs/reiserfs/namei.c | 2 +- fs/sysv/namei.c | 2 +- fs/ubifs/dir.c | 2 +- fs/udf/namei.c | 2 +- fs/ufs/namei.c | 2 +- fs/xfs/xfs_iops.c | 2 +- include/linux/fs.h | 4 ++-- include/linux/security.h | 4 ++-- mm/shmem.c | 2 +- security/capability.c | 2 +- security/security.c | 2 +- security/selinux/hooks.c | 2 +- 42 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 38d00c8898b9..9e9f30b9f46b 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -45,7 +45,7 @@ ata *); int (*symlink) (struct inode *,struct dentry *,const char *); int (*mkdir) (struct inode *,struct dentry *,umode_t); int (*rmdir) (struct inode *,struct dentry *); - int (*mknod) (struct inode *,struct dentry *,int,dev_t); + int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); int (*rename) (struct inode *, struct dentry *, struct inode *, struct dentry *); int (*readlink) (struct dentry *, char __user *,int); diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index e7b900bc6285..4b9f0d092a79 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -348,7 +348,7 @@ struct inode_operations { int (*symlink) (struct inode *,struct dentry *,const char *); int (*mkdir) (struct inode *,struct dentry *,umode_t); int (*rmdir) (struct inode *,struct dentry *); - int (*mknod) (struct inode *,struct dentry *,int,dev_t); + int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); int (*rename) (struct inode *, struct dentry *, struct inode *, struct dentry *); int (*readlink) (struct dentry *, char __user *,int); diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 15cd5cef4485..f54a26859fcc 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1397,7 +1397,7 @@ clunk_fid: */ static int -v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) +v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { int retval; char *name; diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index c4731381f0c5..259f0cd248c8 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -48,7 +48,7 @@ #include "acl.h" static int -v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, +v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode, dev_t rdev); /** @@ -799,7 +799,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir, * */ static int -v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, +v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode, dev_t rdev) { int err; @@ -814,7 +814,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode, struct posix_acl *dacl = NULL, *pacl = NULL; P9_DPRINTK(P9_DEBUG_VFS, - " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, + " %lu,%s mode: %hx MAJOR: %u MINOR: %u\n", dir->i_ino, dentry->d_name.name, omode, MAJOR(rdev), MINOR(rdev)); if (!new_valid_dev(rdev)) diff --git a/fs/bad_inode.c b/fs/bad_inode.c index 8087fbc35f43..22e9a78872ff 100644 --- a/fs/bad_inode.c +++ b/fs/bad_inode.c @@ -213,7 +213,7 @@ static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry) } static int bad_inode_mknod (struct inode *dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { return -EIO; } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 19630aacb320..0060875d6af6 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4596,7 +4596,7 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans, } static int btrfs_mknod(struct inode *dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { struct btrfs_trans_handle *trans; struct btrfs_root *root = BTRFS_I(dir)->root; diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 9848d686591c..f011ed295bf7 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) } static int ceph_mknod(struct inode *dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb); struct ceph_mds_client *mdsc = fsc->mdsc; @@ -676,7 +676,7 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry, if (ceph_snap(dir) != CEPH_NOSNAP) return -EROFS; - dout("mknod in dir %p dentry %p mode 0%o rdev %d\n", + dout("mknod in dir %p dentry %p mode 0%ho rdev %d\n", dir, dentry, mode, rdev); req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_MKNOD, USE_AUTH_MDS); if (IS_ERR(req)) { diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 358724df558b..fe5ecf1b422a 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -50,7 +50,7 @@ extern struct dentry *cifs_lookup(struct inode *, struct dentry *, struct nameidata *); extern int cifs_unlink(struct inode *dir, struct dentry *dentry); extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *); -extern int cifs_mknod(struct inode *, struct dentry *, int, dev_t); +extern int cifs_mknod(struct inode *, struct dentry *, umode_t, dev_t); extern int cifs_mkdir(struct inode *, struct dentry *, umode_t); extern int cifs_rmdir(struct inode *, struct dentry *); extern int cifs_rename(struct inode *, struct dentry *, struct inode *, diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 2dc8be86be09..df8fecb5b993 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -355,7 +355,7 @@ cifs_create_out: return rc; } -int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, +int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, dev_t device_number) { int rc = -EPERM; diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 81e6542ab20f..be20cbfca7e9 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -607,7 +607,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry) } static int -ecryptfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) +ecryptfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { int rc; struct dentry *lower_dentry; diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c index 58644544849d..9dbf0c301030 100644 --- a/fs/exofs/namei.c +++ b/fs/exofs/namei.c @@ -74,7 +74,7 @@ static int exofs_create(struct inode *dir, struct dentry *dentry, umode_t mode, return err; } -static int exofs_mknod(struct inode *dir, struct dentry *dentry, int mode, +static int exofs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct inode *inode; diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index cb759e661b15..080419814bae 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c @@ -119,7 +119,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode return ext2_add_nondir(dentry, inode); } -static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev) +static int ext2_mknod (struct inode * dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct inode * inode; int err; diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 6047d121f537..4f35b2f315d4 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1732,7 +1732,7 @@ retry: } static int ext3_mknod (struct inode * dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { handle_t *handle; struct inode *inode; diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 77306f36a610..86edc45b52a4 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1770,7 +1770,7 @@ retry: } static int ext4_mknod(struct inode *dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { handle_t *handle; struct inode *inode; diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 603bb8a9b8ca..b4c09c5ed8dc 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -547,7 +547,7 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, return err; } -static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, +static int fuse_mknod(struct inode *dir, struct dentry *entry, umode_t mode, dev_t rdev) { struct fuse_mknod_in inarg; diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index aadf792be750..ea4edf510559 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1143,7 +1143,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) * */ -static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, +static int gfs2_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { return gfs2_create_inode(dir, dentry, mode, dev, NULL, 0, 0); diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index ef6547ca4214..88e155f895c6 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -424,7 +424,7 @@ out: } static int hfsplus_mknod(struct inode *dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb); struct inode *inode; diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 3a3a530f5bad..a7340e710a90 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -700,7 +700,7 @@ int hostfs_rmdir(struct inode *ino, struct dentry *dentry) return err; } -int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) +static int hostfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { struct inode *inode; char *name; diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index 769f76c7303a..30dd7b10b507 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c @@ -201,7 +201,7 @@ bail: return err; } -static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) +static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { const unsigned char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 57996c3d8d0c..698485ce5f3f 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -500,7 +500,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, * File creation. Allocate an inode, and we're done.. */ static int hugetlbfs_mknod(struct inode *dir, - struct dentry *dentry, int mode, dev_t dev) + struct dentry *dentry, umode_t mode, dev_t dev) { struct inode *inode; int error = -ENOSPC; diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 16a75e9a038d..973ac5822bd7 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c @@ -31,7 +31,7 @@ static int jffs2_unlink (struct inode *,struct dentry *); static int jffs2_symlink (struct inode *,struct dentry *,const char *); static int jffs2_mkdir (struct inode *,struct dentry *,umode_t); static int jffs2_rmdir (struct inode *,struct dentry *); -static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t); +static int jffs2_mknod (struct inode *,struct dentry *,umode_t,dev_t); static int jffs2_rename (struct inode *, struct dentry *, struct inode *, struct dentry *); @@ -618,7 +618,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) return ret; } -static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, dev_t rdev) +static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode, dev_t rdev) { struct jffs2_inode_info *f, *dir_f; struct jffs2_sb_info *c; diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 6c0b1ab8107d..5f7c160ea64f 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -1353,7 +1353,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, * FUNCTION: Create a special file (device) */ static int jfs_mknod(struct inode *dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { struct jfs_inode_info *jfs_ip; struct btstack btstack; diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c index a74aa461d53c..501043e8966c 100644 --- a/fs/logfs/dir.c +++ b/fs/logfs/dir.c @@ -517,7 +517,7 @@ static int logfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, return __logfs_create(dir, dentry, inode, NULL, 0); } -static int logfs_mknod(struct inode *dir, struct dentry *dentry, int mode, +static int logfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct inode *inode; diff --git a/fs/minix/namei.c b/fs/minix/namei.c index c652650bf5a3..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 return NULL; } -static int minix_mknod(struct inode * dir, struct dentry *dentry, int mode, dev_t rdev) +static int minix_mknod(struct inode * dir, struct dentry *dentry, umode_t mode, dev_t rdev) { int error; struct inode *inode; diff --git a/fs/namei.c b/fs/namei.c index 05d1c2ceb131..85bb44f222c9 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2444,7 +2444,7 @@ struct dentry *user_path_create(int dfd, const char __user *pathname, struct pat } EXPORT_SYMBOL(user_path_create); -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) +int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { int error = may_create(dir, dentry); diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index 98d1b8c6fd8c..a2d50f803a17 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -38,7 +38,7 @@ static int ncp_rmdir(struct inode *, struct dentry *); static int ncp_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); static int ncp_mknod(struct inode * dir, struct dentry *dentry, - int mode, dev_t rdev); + umode_t mode, dev_t rdev); #if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS) extern int ncp_symlink(struct inode *, struct dentry *, const char *); #else @@ -1201,12 +1201,12 @@ out: } static int ncp_mknod(struct inode * dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { if (!new_valid_dev(rdev)) return -EINVAL; if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber)) { - DPRINTK(KERN_DEBUG "ncp_mknod: mode = 0%o\n", mode); + DPRINTK(KERN_DEBUG "ncp_mknod: mode = 0%ho\n", mode); return ncp_create_new(dir, dentry, mode, rdev, 0); } return -EPERM; /* Strange, but true */ diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 7cdee1d4160f..fd9a872fada0 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -53,7 +53,7 @@ static int nfs_rmdir(struct inode *, struct dentry *); static int nfs_unlink(struct inode *, struct dentry *); static int nfs_symlink(struct inode *, struct dentry *, const char *); static int nfs_link(struct dentry *, struct inode *, struct dentry *); -static int nfs_mknod(struct inode *, struct dentry *, int, dev_t); +static int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t); static int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); static int nfs_fsync_dir(struct file *, loff_t, loff_t, int); @@ -1693,7 +1693,7 @@ out_err: * See comments for nfs_proc_create regarding failed operations. */ static int -nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) +nfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct iattr attr; int status; diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index fcd86c38f968..1cd3f624dffc 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -112,7 +112,7 @@ static int nilfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, } static int -nilfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) +nilfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct inode *inode; struct nilfs_transaction_info ti; diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 46f46ffe77c5..11c62e20054c 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -207,7 +207,7 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode) static int ocfs2_mknod(struct inode *dir, struct dentry *dentry, - int mode, + umode_t mode, dev_t dev) { int status = 0; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index c2ed2a36094e..145680e9d581 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -92,7 +92,7 @@ struct inode *ramfs_get_inode(struct super_block *sb, */ /* SMP-safe */ static int -ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) +ramfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev); int error = -ENOSPC; diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 46db3b9fa7cf..a8614bd7cc8d 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@ -643,7 +643,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mod return retval; } -static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode, +static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { int retval; diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c index d306eebeb6c1..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 return NULL; } -static int sysv_mknod(struct inode * dir, struct dentry * dentry, int mode, dev_t rdev) +static int sysv_mknod(struct inode * dir, struct dentry * dentry, umode_t mode, dev_t rdev) { struct inode * inode; int err; diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index f332878ce4de..d9aec2fc90a6 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -769,7 +769,7 @@ out_budg: } static int ubifs_mknod(struct inode *dir, struct dentry *dentry, - int mode, dev_t rdev) + umode_t mode, dev_t rdev) { struct inode *inode; struct ubifs_inode *ui; diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 135a4ca01038..08bf46edf9c4 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -596,7 +596,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, umode_t mode, return 0; } -static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, +static int udf_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct inode *inode; diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index ba2a9d6c0314..38cac199edff 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -94,7 +94,7 @@ static int ufs_create (struct inode * dir, struct dentry * dentry, umode_t mode, return err; } -static int ufs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev) +static int ufs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { struct inode *inode; int err; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 0efa4e51bebf..c2cf9bb60863 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -168,7 +168,7 @@ STATIC int xfs_vn_mknod( struct inode *dir, struct dentry *dentry, - int mode, + umode_t mode, dev_t rdev) { struct inode *inode; diff --git a/include/linux/fs.h b/include/linux/fs.h index e40321a6e239..b89eef1d1752 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1518,7 +1518,7 @@ extern void unlock_super(struct super_block *); */ extern int vfs_create(struct inode *, struct dentry *, umode_t, struct nameidata *); extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t); +extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t); extern int vfs_symlink(struct inode *, struct dentry *, const char *); extern int vfs_link(struct dentry *, struct inode *, struct dentry *); extern int vfs_rmdir(struct inode *, struct dentry *); @@ -1625,7 +1625,7 @@ struct inode_operations { int (*symlink) (struct inode *,struct dentry *,const char *); int (*mkdir) (struct inode *,struct dentry *,umode_t); int (*rmdir) (struct inode *,struct dentry *); - int (*mknod) (struct inode *,struct dentry *,int,dev_t); + int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); int (*rename) (struct inode *, struct dentry *, struct inode *, struct dentry *); void (*truncate) (struct inode *); diff --git a/include/linux/security.h b/include/linux/security.h index 8fc22373db34..0e5aeb86dfc4 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1456,7 +1456,7 @@ struct security_operations { int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, umode_t mode); int (*inode_rmdir) (struct inode *dir, struct dentry *dentry); int (*inode_mknod) (struct inode *dir, struct dentry *dentry, - int mode, dev_t dev); + umode_t mode, dev_t dev); int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); int (*inode_readlink) (struct dentry *dentry); @@ -1724,7 +1724,7 @@ int security_inode_symlink(struct inode *dir, struct dentry *dentry, const char *old_name); int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); int security_inode_rmdir(struct inode *dir, struct dentry *dentry); -int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev); +int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev); int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); int security_inode_readlink(struct dentry *dentry); diff --git a/mm/shmem.c b/mm/shmem.c index 542aad28928d..4000f370948c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1456,7 +1456,7 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf) * File creation. Allocate an inode, and we're done.. */ static int -shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) +shmem_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { struct inode *inode; int error = -ENOSPC; diff --git a/security/capability.c b/security/capability.c index ff18d0ca30bf..9def035cd572 100644 --- a/security/capability.c +++ b/security/capability.c @@ -159,7 +159,7 @@ static int cap_inode_rmdir(struct inode *inode, struct dentry *dentry) } static int cap_inode_mknod(struct inode *inode, struct dentry *dentry, - int mode, dev_t dev) + umode_t mode, dev_t dev) { return 0; } diff --git a/security/security.c b/security/security.c index 2420eed87639..8cc0f0caa640 100644 --- a/security/security.c +++ b/security/security.c @@ -521,7 +521,7 @@ int security_inode_rmdir(struct inode *dir, struct dentry *dentry) return security_ops->inode_rmdir(dir, dentry); } -int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) +int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { if (unlikely(IS_PRIVATE(dir))) return 0; diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index a1eba2b9ea5c..8878370c13bf 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2628,7 +2628,7 @@ static int selinux_inode_rmdir(struct inode *dir, struct dentry *dentry) return may_link(dir, dentry, MAY_RMDIR); } -static int selinux_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) +static int selinux_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { return may_create(dir, dentry, inode_mode_to_security_class(mode)); } From 7d54fa6472609f2b0f2ea27e51ec2cf1fb27bd57 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 20:20:48 -0400 Subject: [PATCH 034/165] hugetlbfs: switch to inode_init_owner() ... rather than open-coding it Signed-off-by: Al Viro --- fs/hugetlbfs/inode.c | 57 ++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 698485ce5f3f..aa93f9532607 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) return 0; } -static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, - gid_t gid, int mode, dev_t dev) +static struct inode *hugetlbfs_get_root(struct super_block *sb, + struct hugetlbfs_config *config) { struct inode *inode; @@ -456,9 +456,31 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, if (inode) { struct hugetlbfs_inode_info *info; inode->i_ino = get_next_ino(); - inode->i_mode = mode; - inode->i_uid = uid; - inode->i_gid = gid; + inode->i_mode = S_IFDIR | config->mode; + inode->i_uid = config->uid; + inode->i_gid = config->gid; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + info = HUGETLBFS_I(inode); + mpol_shared_policy_init(&info->policy, NULL); + inode->i_op = &hugetlbfs_dir_inode_operations; + inode->i_fop = &simple_dir_operations; + /* directory inodes start off with i_nlink == 2 (for "." entry) */ + inc_nlink(inode); + } + return inode; +} + +static struct inode *hugetlbfs_get_inode(struct super_block *sb, + struct inode *dir, + int mode, dev_t dev) +{ + struct inode *inode; + + inode = new_inode(sb); + if (inode) { + struct hugetlbfs_inode_info *info; + inode->i_ino = get_next_ino(); + inode_init_owner(inode, dir, mode); inode->i_mapping->a_ops = &hugetlbfs_aops; inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; @@ -504,16 +526,8 @@ static int hugetlbfs_mknod(struct inode *dir, { struct inode *inode; int error = -ENOSPC; - gid_t gid; - if (dir->i_mode & S_ISGID) { - gid = dir->i_gid; - if (S_ISDIR(mode)) - mode |= S_ISGID; - } else { - gid = current_fsgid(); - } - inode = hugetlbfs_get_inode(dir->i_sb, current_fsuid(), gid, mode, dev); + inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev); if (inode) { dir->i_ctime = dir->i_mtime = CURRENT_TIME; d_instantiate(dentry, inode); @@ -541,15 +555,8 @@ static int hugetlbfs_symlink(struct inode *dir, { struct inode *inode; int error = -ENOSPC; - gid_t gid; - if (dir->i_mode & S_ISGID) - gid = dir->i_gid; - else - gid = current_fsgid(); - - inode = hugetlbfs_get_inode(dir->i_sb, current_fsuid(), - gid, S_IFLNK|S_IRWXUGO, 0); + inode = hugetlbfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0); if (inode) { int l = strlen(symname)+1; error = page_symlink(inode, symname, l); @@ -857,8 +864,7 @@ hugetlbfs_fill_super(struct super_block *sb, void *data, int silent) sb->s_magic = HUGETLBFS_MAGIC; sb->s_op = &hugetlbfs_ops; sb->s_time_gran = 1; - inode = hugetlbfs_get_inode(sb, config.uid, config.gid, - S_IFDIR | config.mode, 0); + inode = hugetlbfs_get_root(sb, &config); if (!inode) goto out_free; @@ -956,8 +962,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, path.mnt = mntget(hugetlbfs_vfsmount); error = -ENOSPC; - inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), - current_fsgid(), S_IFREG | S_IRWXUGO, 0); + inode = hugetlbfs_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0); if (!inode) goto out_dentry; From 2c9ede55ecec58099b72e4bb8eab719f32f72c31 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 23 Jul 2011 20:24:48 -0400 Subject: [PATCH 035/165] switch device_get_devnode() and ->devnode() to umode_t * both callers of device_get_devnode() are only interested in lower 16bits and nobody tries to return anything wider than 16bit anyway. Signed-off-by: Al Viro --- arch/x86/kernel/cpuid.c | 2 +- arch/x86/kernel/msr.c | 2 +- block/bsg.c | 2 +- block/genhd.c | 2 +- drivers/base/core.c | 4 ++-- drivers/base/devtmpfs.c | 2 +- drivers/block/aoe/aoechr.c | 2 +- drivers/block/pktcdvd.c | 2 +- drivers/char/mem.c | 4 ++-- drivers/char/misc.c | 2 +- drivers/char/raw.c | 2 +- drivers/char/tile-srom.c | 2 +- drivers/gpu/drm/drm_sysfs.c | 2 +- drivers/hid/usbhid/hiddev.c | 2 +- drivers/infiniband/core/cm.c | 2 +- drivers/infiniband/core/user_mad.c | 2 +- drivers/infiniband/core/uverbs_main.c | 2 +- drivers/input/input.c | 2 +- drivers/media/dvb/ddbridge/ddbridge-core.c | 2 +- drivers/media/dvb/dvb-core/dvbdev.c | 2 +- drivers/media/rc/rc-main.c | 2 +- drivers/tty/tty_io.c | 2 +- drivers/usb/class/usblp.c | 2 +- drivers/usb/core/file.c | 2 +- drivers/usb/core/usb.c | 2 +- drivers/usb/misc/iowarrior.c | 2 +- drivers/usb/misc/legousbtower.c | 2 +- include/linux/device.h | 6 +++--- include/linux/genhd.h | 2 +- include/linux/usb.h | 2 +- sound/sound_core.c | 2 +- 31 files changed, 35 insertions(+), 35 deletions(-) diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index 212a6a42527c..a524353d93f2 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c @@ -177,7 +177,7 @@ static struct notifier_block __refdata cpuid_class_cpu_notifier = .notifier_call = cpuid_class_cpu_callback, }; -static char *cpuid_devnode(struct device *dev, mode_t *mode) +static char *cpuid_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "cpu/%u/cpuid", MINOR(dev->devt)); } diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index 12fcbe2c143e..96356762a51d 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -236,7 +236,7 @@ static struct notifier_block __refdata msr_class_cpu_notifier = { .notifier_call = msr_class_cpu_callback, }; -static char *msr_devnode(struct device *dev, mode_t *mode) +static char *msr_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "cpu/%u/msr", MINOR(dev->devt)); } diff --git a/block/bsg.c b/block/bsg.c index 702f1316bb8f..9651ec7b87c2 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -1070,7 +1070,7 @@ EXPORT_SYMBOL_GPL(bsg_register_queue); static struct cdev bsg_cdev; -static char *bsg_devnode(struct device *dev, mode_t *mode) +static char *bsg_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "bsg/%s", dev_name(dev)); } diff --git a/block/genhd.c b/block/genhd.c index 02e9fca80825..80578f3176ef 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1109,7 +1109,7 @@ struct class block_class = { .name = "block", }; -static char *block_devnode(struct device *dev, mode_t *mode) +static char *block_devnode(struct device *dev, umode_t *mode) { struct gendisk *disk = dev_to_disk(dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index 919daa7cd5b1..1dfa1d616fa5 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -198,7 +198,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, if (MAJOR(dev->devt)) { const char *tmp; const char *name; - mode_t mode = 0; + umode_t mode = 0; add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt)); add_uevent_var(env, "MINOR=%u", MINOR(dev->devt)); @@ -1182,7 +1182,7 @@ static struct device *next_device(struct klist_iter *i) * freed by the caller. */ const char *device_get_devnode(struct device *dev, - mode_t *mode, const char **tmp) + umode_t *mode, const char **tmp) { char *s; diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index a4760e095ff5..3990f682e690 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -40,7 +40,7 @@ static struct req { struct completion done; int err; const char *name; - mode_t mode; /* 0 => delete */ + umode_t mode; /* 0 => delete */ struct device *dev; } *requests; diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c index 5f8e39c43ae5..e86d2062a164 100644 --- a/drivers/block/aoe/aoechr.c +++ b/drivers/block/aoe/aoechr.c @@ -270,7 +270,7 @@ static const struct file_operations aoe_fops = { .llseek = noop_llseek, }; -static char *aoe_devnode(struct device *dev, mode_t *mode) +static char *aoe_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "etherd/%s", dev_name(dev)); } diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index a63b0a2b7805..d59edeabd93f 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2817,7 +2817,7 @@ static const struct block_device_operations pktcdvd_ops = { .check_events = pkt_check_events, }; -static char *pktcdvd_devnode(struct gendisk *gd, mode_t *mode) +static char *pktcdvd_devnode(struct gendisk *gd, umode_t *mode) { return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name); } diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 145179033716..d6e9d081c8b1 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -847,7 +847,7 @@ static const struct file_operations kmsg_fops = { static const struct memdev { const char *name; - mode_t mode; + umode_t mode; const struct file_operations *fops; struct backing_dev_info *dev_info; } devlist[] = { @@ -901,7 +901,7 @@ static const struct file_operations memory_fops = { .llseek = noop_llseek, }; -static char *mem_devnode(struct device *dev, mode_t *mode) +static char *mem_devnode(struct device *dev, umode_t *mode) { if (mode && devlist[MINOR(dev->devt)].mode) *mode = devlist[MINOR(dev->devt)].mode; diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 778273c93242..522136d40843 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -258,7 +258,7 @@ int misc_deregister(struct miscdevice *misc) EXPORT_SYMBOL(misc_register); EXPORT_SYMBOL(misc_deregister); -static char *misc_devnode(struct device *dev, mode_t *mode) +static char *misc_devnode(struct device *dev, umode_t *mode) { struct miscdevice *c = dev_get_drvdata(dev); diff --git a/drivers/char/raw.c b/drivers/char/raw.c index b6de2c047145..54a3a6d09819 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c @@ -308,7 +308,7 @@ static const struct file_operations raw_ctl_fops = { static struct cdev raw_cdev; -static char *raw_devnode(struct device *dev, mode_t *mode) +static char *raw_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "raw/%s", dev_name(dev)); } diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c index cf3ee008dca2..4dc019408fac 100644 --- a/drivers/char/tile-srom.c +++ b/drivers/char/tile-srom.c @@ -329,7 +329,7 @@ static struct device_attribute srom_dev_attrs[] = { __ATTR_NULL }; -static char *srom_devnode(struct device *dev, mode_t *mode) +static char *srom_devnode(struct device *dev, umode_t *mode) { *mode = S_IRUGO | S_IWUSR; return kasprintf(GFP_KERNEL, "srom/%s", dev_name(dev)); diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 0f9ef9bf6730..62c3675045ac 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -72,7 +72,7 @@ static int drm_class_resume(struct device *dev) return 0; } -static char *drm_devnode(struct device *dev, mode_t *mode) +static char *drm_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); } diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 4ef02b269a71..7c297d305d5d 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c @@ -859,7 +859,7 @@ static const struct file_operations hiddev_fops = { .llseek = noop_llseek, }; -static char *hiddev_devnode(struct device *dev, mode_t *mode) +static char *hiddev_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); } diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 8b72f39202fb..c889aaef3416 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -3659,7 +3659,7 @@ static struct kobj_type cm_port_obj_type = { .release = cm_release_port_obj }; -static char *cm_devnode(struct device *dev, mode_t *mode) +static char *cm_devnode(struct device *dev, umode_t *mode) { if (mode) *mode = 0666; diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index 07db22997e97..f0d588f8859e 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c @@ -1175,7 +1175,7 @@ static void ib_umad_remove_one(struct ib_device *device) kref_put(&umad_dev->ref, ib_umad_release_dev); } -static char *umad_devnode(struct device *dev, mode_t *mode) +static char *umad_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev)); } diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 879636746373..604556d73d25 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -846,7 +846,7 @@ static void ib_uverbs_remove_one(struct ib_device *device) kfree(uverbs_dev); } -static char *uverbs_devnode(struct device *dev, mode_t *mode) +static char *uverbs_devnode(struct device *dev, umode_t *mode) { if (mode) *mode = 0666; diff --git a/drivers/input/input.c b/drivers/input/input.c index da38d97a51b1..1f78c957a75a 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1624,7 +1624,7 @@ static struct device_type input_dev_type = { #endif }; -static char *input_devnode(struct device *dev, mode_t *mode) +static char *input_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "input/%s", dev_name(dev)); } diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c index ba9a643b9c6a..d1e91bc80e78 100644 --- a/drivers/media/dvb/ddbridge/ddbridge-core.c +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c @@ -1480,7 +1480,7 @@ static const struct file_operations ddb_fops = { .open = ddb_open, }; -static char *ddb_devnode(struct device *device, mode_t *mode) +static char *ddb_devnode(struct device *device, umode_t *mode) { struct ddb *dev = dev_get_drvdata(device); diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index f73287775953..00a67326c193 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c @@ -450,7 +450,7 @@ static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env) return 0; } -static char *dvb_devnode(struct device *dev, mode_t *mode) +static char *dvb_devnode(struct device *dev, umode_t *mode) { struct dvb_device *dvbdev = dev_get_drvdata(dev); diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 29f900065d8a..f5db8b949bc3 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -715,7 +715,7 @@ static void ir_close(struct input_dev *idev) } /* class for /sys/class/rc */ -static char *ir_devnode(struct device *dev, mode_t *mode) +static char *ir_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "rc/%s", dev_name(dev)); } diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 05085beb83db..3fdebd306b94 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3267,7 +3267,7 @@ void __init console_init(void) } } -static char *tty_devnode(struct device *dev, mode_t *mode) +static char *tty_devnode(struct device *dev, umode_t *mode) { if (!mode) return NULL; diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index cb3a93243a05..bc5089f76cec 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -1045,7 +1045,7 @@ static const struct file_operations usblp_fops = { .llseek = noop_llseek, }; -static char *usblp_devnode(struct device *dev, mode_t *mode) +static char *usblp_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); } diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 99458c843d60..d95760de9e8b 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c @@ -66,7 +66,7 @@ static struct usb_class { struct class *class; } *usb_class; -static char *usb_devnode(struct device *dev, mode_t *mode) +static char *usb_devnode(struct device *dev, umode_t *mode) { struct usb_class_driver *drv; diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 73cd90012ec5..1382c90d0834 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -326,7 +326,7 @@ static const struct dev_pm_ops usb_device_pm_ops = { #endif /* CONFIG_PM */ -static char *usb_devnode(struct device *dev, mode_t *mode) +static char *usb_devnode(struct device *dev, umode_t *mode) { struct usb_device *usb_dev; diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 81457904d6ba..5bd4b0526de5 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -734,7 +734,7 @@ static const struct file_operations iowarrior_fops = { .llseek = noop_llseek, }; -static char *iowarrior_devnode(struct device *dev, mode_t *mode) +static char *iowarrior_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); } diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index a989356f693e..94f6566b99f8 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -269,7 +269,7 @@ static const struct file_operations tower_fops = { .llseek = tower_llseek, }; -static char *legousbtower_devnode(struct device *dev, mode_t *mode) +static char *legousbtower_devnode(struct device *dev, umode_t *mode) { return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev)); } diff --git a/include/linux/device.h b/include/linux/device.h index 3136ede5a1e1..2fe0005543ed 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -294,7 +294,7 @@ struct class { struct kobject *dev_kobj; int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); - char *(*devnode)(struct device *dev, mode_t *mode); + char *(*devnode)(struct device *dev, umode_t *mode); void (*class_release)(struct class *class); void (*dev_release)(struct device *dev); @@ -423,7 +423,7 @@ struct device_type { const char *name; const struct attribute_group **groups; int (*uevent)(struct device *dev, struct kobj_uevent_env *env); - char *(*devnode)(struct device *dev, mode_t *mode); + char *(*devnode)(struct device *dev, umode_t *mode); void (*release)(struct device *dev); const struct dev_pm_ops *pm; @@ -720,7 +720,7 @@ extern int device_rename(struct device *dev, const char *new_name); extern int device_move(struct device *dev, struct device *new_parent, enum dpm_order dpm_order); extern const char *device_get_devnode(struct device *dev, - mode_t *mode, const char **tmp); + umode_t *mode, const char **tmp); extern void *dev_get_drvdata(const struct device *dev); extern int dev_set_drvdata(struct device *dev, void *data); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 6d18f3531f18..fe23ee768589 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -163,7 +163,7 @@ struct gendisk { * disks that can't be partitioned. */ char disk_name[DISK_NAME_LEN]; /* name of major driver */ - char *(*devnode)(struct gendisk *gd, mode_t *mode); + char *(*devnode)(struct gendisk *gd, umode_t *mode); unsigned int events; /* supported events */ unsigned int async_events; /* async events, subset of all */ diff --git a/include/linux/usb.h b/include/linux/usb.h index d3d0c1374334..a59321779f8b 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -935,7 +935,7 @@ extern struct bus_type usb_bus_type; */ struct usb_class_driver { char *name; - char *(*devnode)(struct device *dev, mode_t *mode); + char *(*devnode)(struct device *dev, umode_t *mode); const struct file_operations *fops; int minor_base; }; diff --git a/sound/sound_core.c b/sound/sound_core.c index 6ce277860fd7..c6e81fb928e9 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -29,7 +29,7 @@ MODULE_DESCRIPTION("Core sound module"); MODULE_AUTHOR("Alan Cox"); MODULE_LICENSE("GPL"); -static char *sound_devnode(struct device *dev, mode_t *mode) +static char *sound_devnode(struct device *dev, umode_t *mode) { if (MAJOR(dev->devt) == SOUND_MAJOR) return NULL; From 9104e427f3e21ddb380ddc39752624365b5bffea Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 23 Jul 2011 23:10:46 -0400 Subject: [PATCH 036/165] switch sysfs attr->mode to umode_t Signed-off-by: Al Viro --- drivers/platform/x86/intel_menlow.c | 2 +- include/linux/sysfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c index abddc83e9fd7..3271ac85115e 100644 --- a/drivers/platform/x86/intel_menlow.c +++ b/drivers/platform/x86/intel_menlow.c @@ -389,7 +389,7 @@ static ssize_t bios_enabled_show(struct device *dev, return sprintf(buf, "%s\n", bios_enabled ? "enabled" : "disabled"); } -static int intel_menlow_add_one_attribute(char *name, int mode, void *show, +static int intel_menlow_add_one_attribute(char *name, umode_t mode, void *show, void *store, struct device *dev, acpi_handle handle) { diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index dac0859e6440..d1994ec02c89 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -25,7 +25,7 @@ enum kobj_ns_type; struct attribute { const char *name; - mode_t mode; + umode_t mode; #ifdef CONFIG_DEBUG_LOCK_ALLOC struct lock_class_key *key; struct lock_class_key skey; From 587a1f1659e8b330b8738ef4901832a2b63f0bed Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 23 Jul 2011 23:11:19 -0400 Subject: [PATCH 037/165] switch ->is_visible() to returning umode_t Signed-off-by: Al Viro --- drivers/firmware/iscsi_ibft.c | 12 ++++++------ drivers/hwmon/jc42.c | 2 +- drivers/hwmon/max1668.c | 4 ++-- drivers/hwmon/max6650.c | 2 +- drivers/hwmon/tmp421.c | 2 +- drivers/infiniband/ulp/iser/iscsi_iser.c | 2 +- drivers/input/touchscreen/ad7877.c | 4 ++-- drivers/input/touchscreen/tsc2005.c | 4 ++-- drivers/pci/pci-label.c | 4 ++-- drivers/platform/x86/asus-laptop.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/power/power_supply_sysfs.c | 4 ++-- drivers/scsi/be2iscsi/be_iscsi.c | 2 +- drivers/scsi/be2iscsi/be_iscsi.h | 2 +- drivers/scsi/be2iscsi/be_main.c | 12 ++++++------ drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +- drivers/scsi/cxgbi/libcxgbi.c | 2 +- drivers/scsi/cxgbi/libcxgbi.h | 2 +- drivers/scsi/iscsi_boot_sysfs.c | 14 +++++++------- drivers/scsi/iscsi_tcp.c | 2 +- drivers/scsi/qla4xxx/ql4_os.c | 10 +++++----- drivers/scsi/scsi_transport_iscsi.c | 8 ++++---- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/staging/iio/adc/ad7192.c | 4 ++-- drivers/staging/iio/adc/ad7606_core.c | 4 ++-- drivers/staging/iio/dac/ad5446.c | 4 ++-- drivers/staging/iio/dds/ad9834.c | 4 ++-- drivers/usb/core/sysfs.c | 4 ++-- fs/sysfs/group.c | 2 +- include/linux/iscsi_boot_sysfs.h | 8 ++++---- include/linux/sysfs.h | 2 +- include/scsi/scsi_transport_iscsi.h | 2 +- 33 files changed, 70 insertions(+), 70 deletions(-) diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c index 2cce44a1d7d0..3ee852c9925b 100644 --- a/drivers/firmware/iscsi_ibft.c +++ b/drivers/firmware/iscsi_ibft.c @@ -433,11 +433,11 @@ static int __init ibft_check_device(void) * Helper routiners to check to determine if the entry is valid * in the proper iBFT structure. */ -static mode_t ibft_check_nic_for(void *data, int type) +static umode_t ibft_check_nic_for(void *data, int type) { struct ibft_kobject *entry = data; struct ibft_nic *nic = entry->nic; - mode_t rc = 0; + umode_t rc = 0; switch (type) { case ISCSI_BOOT_ETH_INDEX: @@ -488,11 +488,11 @@ static mode_t ibft_check_nic_for(void *data, int type) return rc; } -static mode_t __init ibft_check_tgt_for(void *data, int type) +static umode_t __init ibft_check_tgt_for(void *data, int type) { struct ibft_kobject *entry = data; struct ibft_tgt *tgt = entry->tgt; - mode_t rc = 0; + umode_t rc = 0; switch (type) { case ISCSI_BOOT_TGT_INDEX: @@ -524,11 +524,11 @@ static mode_t __init ibft_check_tgt_for(void *data, int type) return rc; } -static mode_t __init ibft_check_initiator_for(void *data, int type) +static umode_t __init ibft_check_initiator_for(void *data, int type) { struct ibft_kobject *entry = data; struct ibft_initiator *init = entry->initiator; - mode_t rc = 0; + umode_t rc = 0; switch (type) { case ISCSI_BOOT_INI_INDEX: diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c index 2d3d72805ff4..1a92951f4031 100644 --- a/drivers/hwmon/jc42.c +++ b/drivers/hwmon/jc42.c @@ -413,7 +413,7 @@ static struct attribute *jc42_attributes[] = { NULL }; -static mode_t jc42_attribute_mode(struct kobject *kobj, +static umode_t jc42_attribute_mode(struct kobject *kobj, struct attribute *attr, int index) { struct device *dev = container_of(kobj, struct device, kobj); diff --git a/drivers/hwmon/max1668.c b/drivers/hwmon/max1668.c index 20d1b2ddffb6..6914195cfd35 100644 --- a/drivers/hwmon/max1668.c +++ b/drivers/hwmon/max1668.c @@ -335,10 +335,10 @@ static struct attribute *max1668_attribute_unique[] = { NULL }; -static mode_t max1668_attribute_mode(struct kobject *kobj, +static umode_t max1668_attribute_mode(struct kobject *kobj, struct attribute *attr, int index) { - int ret = S_IRUGO; + umode_t ret = S_IRUGO; if (read_only) return ret; if (attr == &sensor_dev_attr_temp1_max.dev_attr.attr || diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index ece3aafa54b3..2fc034aeca09 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c @@ -464,7 +464,7 @@ static SENSOR_DEVICE_ATTR(gpio1_alarm, S_IRUGO, get_alarm, NULL, static SENSOR_DEVICE_ATTR(gpio2_alarm, S_IRUGO, get_alarm, NULL, MAX6650_ALRM_GPIO2); -static mode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a, +static umode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a, int n) { struct device *dev = container_of(kobj, struct device, kobj); diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c index 0517a8f09d35..c48381f2cd02 100644 --- a/drivers/hwmon/tmp421.c +++ b/drivers/hwmon/tmp421.c @@ -157,7 +157,7 @@ static ssize_t show_fault(struct device *dev, return sprintf(buf, "0\n"); } -static mode_t tmp421_is_visible(struct kobject *kobj, struct attribute *a, +static umode_t tmp421_is_visible(struct kobject *kobj, struct attribute *a, int n) { struct device *dev = container_of(kobj, struct device, kobj); diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 7e7373a700e6..9a43cb07f294 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -638,7 +638,7 @@ iscsi_iser_ep_disconnect(struct iscsi_endpoint *ep) iser_conn_terminate(ib_conn); } -static mode_t iser_attr_is_visible(int param_type, int param) +static umode_t iser_attr_is_visible(int param_type, int param) { switch (param_type) { case ISCSI_HOST_PARAM: diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c index 400131df677b..baa43df6502d 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c @@ -612,10 +612,10 @@ static struct attribute *ad7877_attributes[] = { NULL }; -static mode_t ad7877_attr_is_visible(struct kobject *kobj, +static umode_t ad7877_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { - mode_t mode = attr->mode; + umode_t mode = attr->mode; if (attr == &dev_attr_aux3.attr) { if (gpio3) diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c index cbf0ff322676..067d95662997 100644 --- a/drivers/input/touchscreen/tsc2005.c +++ b/drivers/input/touchscreen/tsc2005.c @@ -450,13 +450,13 @@ static struct attribute *tsc2005_attrs[] = { NULL }; -static mode_t tsc2005_attr_is_visible(struct kobject *kobj, +static umode_t tsc2005_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); struct spi_device *spi = to_spi_device(dev); struct tsc2005 *ts = spi_get_drvdata(spi); - mode_t mode = attr->mode; + umode_t mode = attr->mode; if (attr == &dev_attr_selftest.attr) { if (!ts->set_reset) diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c index 81525ae5d869..edaed6f4da6c 100644 --- a/drivers/pci/pci-label.c +++ b/drivers/pci/pci-label.c @@ -89,7 +89,7 @@ find_smbios_instance_string(struct pci_dev *pdev, char *buf, return 0; } -static mode_t +static umode_t smbios_instance_string_exist(struct kobject *kobj, struct attribute *attr, int n) { @@ -275,7 +275,7 @@ device_has_dsm(struct device *dev) return FALSE; } -static mode_t +static umode_t acpi_index_string_exist(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev; diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index edaccad9b5bf..b7944f903886 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -1477,7 +1477,7 @@ static struct attribute *asus_attributes[] = { NULL }; -static mode_t asus_sysfs_is_visible(struct kobject *kobj, +static umode_t asus_sysfs_is_visible(struct kobject *kobj, struct attribute *attr, int idx) { diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index d1049ee3c9e8..72d731c21d45 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -992,7 +992,7 @@ static struct attribute *hwmon_attributes[] = { NULL }; -static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, +static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, struct attribute *attr, int idx) { struct device *dev = container_of(kobj, struct device, kobj); @@ -1357,7 +1357,7 @@ static struct attribute *platform_attributes[] = { NULL }; -static mode_t asus_sysfs_is_visible(struct kobject *kobj, +static umode_t asus_sysfs_is_visible(struct kobject *kobj, struct attribute *attr, int idx) { struct device *dev = container_of(kobj, struct device, kobj); diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index a36addf106a0..ac902f7a9baa 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -368,7 +368,7 @@ static struct attribute *ideapad_attributes[] = { NULL }; -static mode_t ideapad_is_visible(struct kobject *kobj, +static umode_t ideapad_is_visible(struct kobject *kobj, struct attribute *attr, int idx) { diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index e15d4c9d3988..e95cd657dac2 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c @@ -176,13 +176,13 @@ static struct device_attribute power_supply_attrs[] = { static struct attribute * __power_supply_attrs[ARRAY_SIZE(power_supply_attrs) + 1]; -static mode_t power_supply_attr_is_visible(struct kobject *kobj, +static umode_t power_supply_attr_is_visible(struct kobject *kobj, struct attribute *attr, int attrno) { struct device *dev = container_of(kobj, struct device, kobj); struct power_supply *psy = dev_get_drvdata(dev); - mode_t mode = S_IRUSR | S_IRGRP | S_IROTH; + umode_t mode = S_IRUSR | S_IRGRP | S_IROTH; int i; if (attrno == POWER_SUPPLY_PROP_TYPE) diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index 8b002f6db6ca..33c8f09c7ac1 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c @@ -733,7 +733,7 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep) iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep); } -mode_t be2iscsi_attr_is_visible(int param_type, int param) +umode_t be2iscsi_attr_is_visible(int param_type, int param) { switch (param_type) { case ISCSI_HOST_PARAM: diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h index 4a1f2e393f31..5c45be134501 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.h +++ b/drivers/scsi/be2iscsi/be_iscsi.h @@ -26,7 +26,7 @@ #define BE2_IPV4 0x1 #define BE2_IPV6 0x10 -mode_t be2iscsi_attr_is_visible(int param_type, int param); +umode_t be2iscsi_attr_is_visible(int param_type, int param); void beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, struct beiscsi_offload_params *params); diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 379c696dac19..797a43994b55 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -325,9 +325,9 @@ static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf) } -static mode_t beiscsi_tgt_get_attr_visibility(void *data, int type) +static umode_t beiscsi_tgt_get_attr_visibility(void *data, int type) { - int rc; + umode_t rc; switch (type) { case ISCSI_BOOT_TGT_NAME: @@ -348,9 +348,9 @@ static mode_t beiscsi_tgt_get_attr_visibility(void *data, int type) return rc; } -static mode_t beiscsi_ini_get_attr_visibility(void *data, int type) +static umode_t beiscsi_ini_get_attr_visibility(void *data, int type) { - int rc; + umode_t rc; switch (type) { case ISCSI_BOOT_INI_INITIATOR_NAME: @@ -364,9 +364,9 @@ static mode_t beiscsi_ini_get_attr_visibility(void *data, int type) } -static mode_t beiscsi_eth_get_attr_visibility(void *data, int type) +static umode_t beiscsi_eth_get_attr_visibility(void *data, int type) { - int rc; + umode_t rc; switch (type) { case ISCSI_BOOT_ETH_FLAGS: diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index d1e697190970..1a44b45e7bef 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -2177,7 +2177,7 @@ static int bnx2i_nl_set_path(struct Scsi_Host *shost, struct iscsi_path *params) return 0; } -static mode_t bnx2i_attr_is_visible(int param_type, int param) +static umode_t bnx2i_attr_is_visible(int param_type, int param) { switch (param_type) { case ISCSI_HOST_PARAM: diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index c10f74a566f2..997fa36999be 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -2569,7 +2569,7 @@ void cxgbi_iscsi_cleanup(struct iscsi_transport *itp, } EXPORT_SYMBOL_GPL(cxgbi_iscsi_cleanup); -mode_t cxgbi_attr_is_visible(int param_type, int param) +umode_t cxgbi_attr_is_visible(int param_type, int param) { switch (param_type) { case ISCSI_HOST_PARAM: diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h index 20c88279c7a6..80fa99b3d384 100644 --- a/drivers/scsi/cxgbi/libcxgbi.h +++ b/drivers/scsi/cxgbi/libcxgbi.h @@ -709,7 +709,7 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *); void cxgbi_cleanup_task(struct iscsi_task *task); -mode_t cxgbi_attr_is_visible(int param_type, int param); +umode_t cxgbi_attr_is_visible(int param_type, int param); void cxgbi_get_conn_stats(struct iscsi_cls_conn *, struct iscsi_stats *); int cxgbi_set_conn_param(struct iscsi_cls_conn *, enum iscsi_param, char *, int); diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c index 89700cbca16e..14c1c8f6a95e 100644 --- a/drivers/scsi/iscsi_boot_sysfs.c +++ b/drivers/scsi/iscsi_boot_sysfs.c @@ -112,7 +112,7 @@ static struct attribute *target_attrs[] = { NULL }; -static mode_t iscsi_boot_tgt_attr_is_visible(struct kobject *kobj, +static umode_t iscsi_boot_tgt_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i) { struct iscsi_boot_kobj *boot_kobj = @@ -193,7 +193,7 @@ static struct attribute *ethernet_attrs[] = { NULL }; -static mode_t iscsi_boot_eth_attr_is_visible(struct kobject *kobj, +static umode_t iscsi_boot_eth_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i) { struct iscsi_boot_kobj *boot_kobj = @@ -265,7 +265,7 @@ static struct attribute *initiator_attrs[] = { NULL }; -static mode_t iscsi_boot_ini_attr_is_visible(struct kobject *kobj, +static umode_t iscsi_boot_ini_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i) { struct iscsi_boot_kobj *boot_kobj = @@ -306,7 +306,7 @@ iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset, struct attribute_group *attr_group, const char *name, int index, void *data, ssize_t (*show) (void *data, int type, char *buf), - mode_t (*is_visible) (void *data, int type), + umode_t (*is_visible) (void *data, int type), void (*release) (void *data)) { struct iscsi_boot_kobj *boot_kobj; @@ -369,7 +369,7 @@ struct iscsi_boot_kobj * iscsi_boot_create_target(struct iscsi_boot_kset *boot_kset, int index, void *data, ssize_t (*show) (void *data, int type, char *buf), - mode_t (*is_visible) (void *data, int type), + umode_t (*is_visible) (void *data, int type), void (*release) (void *data)) { return iscsi_boot_create_kobj(boot_kset, &iscsi_boot_target_attr_group, @@ -394,7 +394,7 @@ struct iscsi_boot_kobj * iscsi_boot_create_initiator(struct iscsi_boot_kset *boot_kset, int index, void *data, ssize_t (*show) (void *data, int type, char *buf), - mode_t (*is_visible) (void *data, int type), + umode_t (*is_visible) (void *data, int type), void (*release) (void *data)) { return iscsi_boot_create_kobj(boot_kset, @@ -420,7 +420,7 @@ struct iscsi_boot_kobj * iscsi_boot_create_ethernet(struct iscsi_boot_kset *boot_kset, int index, void *data, ssize_t (*show) (void *data, int type, char *buf), - mode_t (*is_visible) (void *data, int type), + umode_t (*is_visible) (void *data, int type), void (*release) (void *data)) { return iscsi_boot_create_kobj(boot_kset, diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 7c34d8e7cc75..db47158e0dde 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -873,7 +873,7 @@ static void iscsi_sw_tcp_session_destroy(struct iscsi_cls_session *cls_session) iscsi_host_free(shost); } -static mode_t iscsi_sw_tcp_attr_is_visible(int param_type, int param) +static umode_t iscsi_sw_tcp_attr_is_visible(int param_type, int param) { switch (param_type) { case ISCSI_HOST_PARAM: diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 4169c8baa112..78bf700b365f 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -128,7 +128,7 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd); static int qla4xxx_slave_alloc(struct scsi_device *device); static int qla4xxx_slave_configure(struct scsi_device *device); static void qla4xxx_slave_destroy(struct scsi_device *sdev); -static mode_t ql4_attr_is_visible(int param_type, int param); +static umode_t ql4_attr_is_visible(int param_type, int param); static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type); static struct qla4_8xxx_legacy_intr_set legacy_intr[] = @@ -197,7 +197,7 @@ static struct iscsi_transport qla4xxx_iscsi_transport = { static struct scsi_transport_template *qla4xxx_scsi_transport; -static mode_t ql4_attr_is_visible(int param_type, int param) +static umode_t ql4_attr_is_visible(int param_type, int param) { switch (param_type) { case ISCSI_HOST_PARAM: @@ -3039,7 +3039,7 @@ static ssize_t qla4xxx_show_boot_eth_info(void *data, int type, char *buf) return rc; } -static mode_t qla4xxx_eth_get_attr_visibility(void *data, int type) +static umode_t qla4xxx_eth_get_attr_visibility(void *data, int type) { int rc; @@ -3073,7 +3073,7 @@ static ssize_t qla4xxx_show_boot_ini_info(void *data, int type, char *buf) return rc; } -static mode_t qla4xxx_ini_get_attr_visibility(void *data, int type) +static umode_t qla4xxx_ini_get_attr_visibility(void *data, int type) { int rc; @@ -3160,7 +3160,7 @@ static ssize_t qla4xxx_show_boot_tgt_sec_info(void *data, int type, char *buf) return qla4xxx_show_boot_tgt_info(boot_sess, type, buf); } -static mode_t qla4xxx_tgt_get_attr_visibility(void *data, int type) +static umode_t qla4xxx_tgt_get_attr_visibility(void *data, int type) { int rc; diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 96029e6d027f..e8447fbc31f3 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -328,7 +328,7 @@ iscsi_iface_net_attr(iface, vlan_enabled, ISCSI_NET_PARAM_VLAN_ENABLED); iscsi_iface_net_attr(iface, mtu, ISCSI_NET_PARAM_MTU); iscsi_iface_net_attr(iface, port, ISCSI_NET_PARAM_PORT); -static mode_t iscsi_iface_attr_is_visible(struct kobject *kobj, +static umode_t iscsi_iface_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i) { struct device *dev = container_of(kobj, struct device, kobj); @@ -2199,7 +2199,7 @@ static struct attribute *iscsi_conn_attrs[] = { NULL, }; -static mode_t iscsi_conn_attr_is_visible(struct kobject *kobj, +static umode_t iscsi_conn_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i) { struct device *cdev = container_of(kobj, struct device, kobj); @@ -2370,7 +2370,7 @@ static struct attribute *iscsi_session_attrs[] = { NULL, }; -static mode_t iscsi_session_attr_is_visible(struct kobject *kobj, +static umode_t iscsi_session_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i) { struct device *cdev = container_of(kobj, struct device, kobj); @@ -2468,7 +2468,7 @@ static struct attribute *iscsi_host_attrs[] = { NULL, }; -static mode_t iscsi_host_attr_is_visible(struct kobject *kobj, +static umode_t iscsi_host_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i) { struct device *cdev = container_of(kobj, struct device, kobj); diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 5fbeadd96819..a2715c31e754 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -1434,7 +1434,7 @@ static int spi_host_configure(struct transport_container *tc, (si->f->show_##name ? S_IRUGO : 0) | \ (si->f->set_##name ? S_IWUSR : 0) -static mode_t target_attribute_is_visible(struct kobject *kobj, +static umode_t target_attribute_is_visible(struct kobject *kobj, struct attribute *attr, int i) { struct device *cdev = container_of(kobj, struct device, kobj); diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 31c376b9d5eb..e7bf32461736 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -838,14 +838,14 @@ static struct attribute *ad7192_attributes[] = { NULL }; -static mode_t ad7192_attr_is_visible(struct kobject *kobj, +static umode_t ad7192_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad7192_state *st = iio_priv(indio_dev); - mode_t mode = attr->mode; + umode_t mode = attr->mode; if ((st->devid != ID_AD7195) && (attr == &iio_dev_attr_ac_excitation_en.dev_attr.attr)) diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index 54423ab196fe..e3ecd3d2ef3a 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c @@ -205,14 +205,14 @@ static struct attribute *ad7606_attributes[] = { NULL, }; -static mode_t ad7606_attr_is_visible(struct kobject *kobj, +static umode_t ad7606_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad7606_state *st = iio_priv(indio_dev); - mode_t mode = attr->mode; + umode_t mode = attr->mode; if (!(gpio_is_valid(st->pdata->gpio_os0) && gpio_is_valid(st->pdata->gpio_os1) && diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c index e1c204d51d8c..dc46b6d6eaa3 100644 --- a/drivers/staging/iio/dac/ad5446.c +++ b/drivers/staging/iio/dac/ad5446.c @@ -197,14 +197,14 @@ static struct attribute *ad5446_attributes[] = { NULL, }; -static mode_t ad5446_attr_is_visible(struct kobject *kobj, +static umode_t ad5446_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad5446_state *st = iio_priv(indio_dev); - mode_t mode = attr->mode; + umode_t mode = attr->mode; if (!st->chip_info->store_pwr_down && (attr == &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr || diff --git a/drivers/staging/iio/dds/ad9834.c b/drivers/staging/iio/dds/ad9834.c index c468f696fe25..cc3293a9f496 100644 --- a/drivers/staging/iio/dds/ad9834.c +++ b/drivers/staging/iio/dds/ad9834.c @@ -281,14 +281,14 @@ static struct attribute *ad9834_attributes[] = { NULL, }; -static mode_t ad9834_attr_is_visible(struct kobject *kobj, +static umode_t ad9834_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) { struct device *dev = container_of(kobj, struct device, kobj); struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad9834_state *st = iio_priv(indio_dev); - mode_t mode = attr->mode; + umode_t mode = attr->mode; if (((st->devid == ID_AD9833) || (st->devid == ID_AD9837)) && ((attr == &iio_dev_attr_dds0_out1_enable.dev_attr.attr) || diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 662c0cf3a3e1..9e491ca2e5c4 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -642,7 +642,7 @@ static struct attribute *dev_string_attrs[] = { NULL }; -static mode_t dev_string_attrs_are_visible(struct kobject *kobj, +static umode_t dev_string_attrs_are_visible(struct kobject *kobj, struct attribute *a, int n) { struct device *dev = container_of(kobj, struct device, kobj); @@ -877,7 +877,7 @@ static struct attribute *intf_assoc_attrs[] = { NULL, }; -static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj, +static umode_t intf_assoc_attrs_are_visible(struct kobject *kobj, struct attribute *a, int n) { struct device *dev = container_of(kobj, struct device, kobj); 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, int error = 0, i; for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) { - mode_t mode = 0; + umode_t mode = 0; /* in update mode, we're changing the permissions or * visibility. Do this by first removing then diff --git a/include/linux/iscsi_boot_sysfs.h b/include/linux/iscsi_boot_sysfs.h index f0a2f8b0aa13..2a8b1659bf35 100644 --- a/include/linux/iscsi_boot_sysfs.h +++ b/include/linux/iscsi_boot_sysfs.h @@ -91,7 +91,7 @@ struct iscsi_boot_kobj { * The enum of the type. This can be any value of the above * properties. */ - mode_t (*is_visible) (void *data, int type); + umode_t (*is_visible) (void *data, int type); /* * Driver specific release function. @@ -110,20 +110,20 @@ struct iscsi_boot_kobj * iscsi_boot_create_initiator(struct iscsi_boot_kset *boot_kset, int index, void *data, ssize_t (*show) (void *data, int type, char *buf), - mode_t (*is_visible) (void *data, int type), + umode_t (*is_visible) (void *data, int type), void (*release) (void *data)); struct iscsi_boot_kobj * iscsi_boot_create_ethernet(struct iscsi_boot_kset *boot_kset, int index, void *data, ssize_t (*show) (void *data, int type, char *buf), - mode_t (*is_visible) (void *data, int type), + umode_t (*is_visible) (void *data, int type), void (*release) (void *data)); struct iscsi_boot_kobj * iscsi_boot_create_target(struct iscsi_boot_kset *boot_kset, int index, void *data, ssize_t (*show) (void *data, int type, char *buf), - mode_t (*is_visible) (void *data, int type), + umode_t (*is_visible) (void *data, int type), void (*release) (void *data)); struct iscsi_boot_kset *iscsi_boot_create_kset(const char *set_name); diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index d1994ec02c89..e90eea7afb4e 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -55,7 +55,7 @@ do { \ struct attribute_group { const char *name; - mode_t (*is_visible)(struct kobject *, + umode_t (*is_visible)(struct kobject *, struct attribute *, int); struct attribute **attrs; }; diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 5994bcc1b017..87f34c3d447d 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -142,7 +142,7 @@ struct iscsi_transport { int (*get_iface_param) (struct iscsi_iface *iface, enum iscsi_param_type param_type, int param, char *buf); - mode_t (*attr_is_visible)(int param_type, int param); + umode_t (*attr_is_visible)(int param_type, int param); int (*bsg_request)(struct bsg_job *job); }; From d161a13f974c72fd7ff0069d39a3ae57cb5694ff Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 03:36:29 -0400 Subject: [PATCH 038/165] switch procfs to umode_t use both proc_dir_entry ->mode and populating functions Signed-off-by: Al Viro --- arch/powerpc/kernel/lparcfg.c | 2 +- drivers/acpi/battery.c | 2 +- drivers/message/i2o/i2o_proc.c | 2 +- drivers/misc/sgi-gru/gruprocfs.c | 2 +- drivers/platform/x86/asus_acpi.c | 4 ++-- drivers/platform/x86/thinkpad_acpi.c | 4 ++-- drivers/scsi/sg.c | 7 +++---- fs/proc/base.c | 2 +- fs/proc/generic.c | 8 ++++---- fs/proc/proc_net.c | 2 +- include/linux/ide.h | 2 +- include/linux/proc_fs.h | 24 ++++++++++++------------ include/sound/info.h | 2 +- 13 files changed, 31 insertions(+), 32 deletions(-) diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c index 84daabe2fcba..578f35f18723 100644 --- a/arch/powerpc/kernel/lparcfg.c +++ b/arch/powerpc/kernel/lparcfg.c @@ -783,7 +783,7 @@ static const struct file_operations lparcfg_fops = { static int __init lparcfg_init(void) { struct proc_dir_entry *ent; - mode_t mode = S_IRUSR | S_IRGRP | S_IROTH; + umode_t mode = S_IRUSR | S_IRGRP | S_IROTH; /* Allow writing if we have FW_FEATURE_SPLPAR */ if (firmware_has_feature(FW_FEATURE_SPLPAR) && diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 7711d94a0409..86933ca8b472 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -873,7 +873,7 @@ DECLARE_FILE_FUNCTIONS(alarm); static const struct battery_file { struct file_operations ops; - mode_t mode; + umode_t mode; const char *name; } acpi_battery_file[] = { FILE_DESCRIPTION_RO(info), diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c index 07dbeaf9df99..6d115c7208ab 100644 --- a/drivers/message/i2o/i2o_proc.c +++ b/drivers/message/i2o/i2o_proc.c @@ -56,7 +56,7 @@ /* Structure used to define /proc entries */ typedef struct _i2o_proc_entry_t { char *name; /* entry name */ - mode_t mode; /* mode */ + umode_t mode; /* mode */ const struct file_operations *fops; /* open function */ } i2o_proc_entry; diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c index 7768b87d995b..950dbe9ecb36 100644 --- a/drivers/misc/sgi-gru/gruprocfs.c +++ b/drivers/misc/sgi-gru/gruprocfs.c @@ -324,7 +324,7 @@ static const struct file_operations gru_fops = { static struct proc_entry { char *name; - int mode; + umode_t mode; const struct file_operations *fops; struct proc_dir_entry *entry; } proc_files[] = { diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c index d9312b3073e5..6f966d6c062b 100644 --- a/drivers/platform/x86/asus_acpi.c +++ b/drivers/platform/x86/asus_acpi.c @@ -1053,7 +1053,7 @@ static const struct file_operations disp_proc_fops = { }; static int -asus_proc_add(char *name, const struct file_operations *proc_fops, mode_t mode, +asus_proc_add(char *name, const struct file_operations *proc_fops, umode_t mode, struct acpi_device *device) { struct proc_dir_entry *proc; @@ -1072,7 +1072,7 @@ asus_proc_add(char *name, const struct file_operations *proc_fops, mode_t mode, static int asus_hotk_add_fs(struct acpi_device *device) { struct proc_dir_entry *proc; - mode_t mode; + umode_t mode; if ((asus_uid == 0) && (asus_gid == 0)) { mode = S_IFREG | S_IRUGO | S_IWUSR | S_IWGRP; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 7b828680b21d..455e1522253e 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -297,7 +297,7 @@ struct ibm_init_struct { char param[32]; int (*init) (struct ibm_init_struct *); - mode_t base_procfs_mode; + umode_t base_procfs_mode; struct ibm_struct *data; }; @@ -8542,7 +8542,7 @@ static int __init ibm_init(struct ibm_init_struct *iibm) "%s installed\n", ibm->name); if (ibm->read) { - mode_t mode = iibm->base_procfs_mode; + umode_t mode = iibm->base_procfs_mode; if (!mode) mode = S_IRUGO; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 441a1c5b8974..02d99982a74d 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -2325,16 +2325,15 @@ static struct sg_proc_leaf sg_proc_leaf_arr[] = { static int sg_proc_init(void) { - int k, mask; int num_leaves = ARRAY_SIZE(sg_proc_leaf_arr); - struct sg_proc_leaf * leaf; + int k; sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL); if (!sg_proc_sgp) return 1; for (k = 0; k < num_leaves; ++k) { - leaf = &sg_proc_leaf_arr[k]; - mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO; + struct sg_proc_leaf *leaf = &sg_proc_leaf_arr[k]; + umode_t mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO; proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops); } return 0; diff --git a/fs/proc/base.c b/fs/proc/base.c index 851ba3dcdc29..65054d38ca23 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -101,7 +101,7 @@ struct pid_entry { char *name; int len; - mode_t mode; + umode_t mode; const struct inode_operations *iop; const struct file_operations *fop; union proc_op op; 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 static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, const char *name, - mode_t mode, + umode_t mode, nlink_t nlink) { struct proc_dir_entry *ent = NULL; @@ -659,7 +659,7 @@ struct proc_dir_entry *proc_symlink(const char *name, } EXPORT_SYMBOL(proc_symlink); -struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, +struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode, struct proc_dir_entry *parent) { struct proc_dir_entry *ent; @@ -699,7 +699,7 @@ struct proc_dir_entry *proc_mkdir(const char *name, } EXPORT_SYMBOL(proc_mkdir); -struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, +struct proc_dir_entry *create_proc_entry(const char *name, umode_t mode, struct proc_dir_entry *parent) { struct proc_dir_entry *ent; @@ -728,7 +728,7 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, } EXPORT_SYMBOL(create_proc_entry); -struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, +struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops, void *data) 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 = { struct proc_dir_entry *proc_net_fops_create(struct net *net, - const char *name, mode_t mode, const struct file_operations *fops) + const char *name, umode_t mode, const struct file_operations *fops) { return proc_create(name, mode, net->proc_net, fops); } diff --git a/include/linux/ide.h b/include/linux/ide.h index 42557851b12e..501370b61ee5 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -920,7 +920,7 @@ __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL) typedef struct { const char *name; - mode_t mode; + umode_t mode; const struct file_operations *proc_fops; } ide_proc_entry_t; diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 643b96c7a94f..6d9e575519cc 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -50,7 +50,7 @@ typedef int (write_proc_t)(struct file *file, const char __user *buffer, struct proc_dir_entry { unsigned int low_ino; - mode_t mode; + umode_t mode; nlink_t nlink; uid_t uid; gid_t gid; @@ -106,9 +106,9 @@ extern void proc_root_init(void); void proc_flush_task(struct task_struct *task); -extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, +extern struct proc_dir_entry *create_proc_entry(const char *name, umode_t mode, struct proc_dir_entry *parent); -struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, +struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops, void *data); @@ -146,17 +146,17 @@ extern void proc_device_tree_update_prop(struct proc_dir_entry *pde, extern struct proc_dir_entry *proc_symlink(const char *, struct proc_dir_entry *, const char *); extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); -extern struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, +extern struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode, struct proc_dir_entry *parent); -static inline struct proc_dir_entry *proc_create(const char *name, mode_t mode, +static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops) { return proc_create_data(name, mode, parent, proc_fops, NULL); } static inline struct proc_dir_entry *create_proc_read_entry(const char *name, - mode_t mode, struct proc_dir_entry *base, + umode_t mode, struct proc_dir_entry *base, read_proc_t *read_proc, void * data) { struct proc_dir_entry *res=create_proc_entry(name,mode,base); @@ -168,7 +168,7 @@ static inline struct proc_dir_entry *create_proc_read_entry(const char *name, } extern struct proc_dir_entry *proc_net_fops_create(struct net *net, - const char *name, mode_t mode, const struct file_operations *fops); + const char *name, umode_t mode, const struct file_operations *fops); extern void proc_net_remove(struct net *net, const char *name); extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, struct proc_dir_entry *parent); @@ -185,15 +185,15 @@ static inline void proc_flush_task(struct task_struct *task) } static inline struct proc_dir_entry *create_proc_entry(const char *name, - mode_t mode, struct proc_dir_entry *parent) { return NULL; } + umode_t mode, struct proc_dir_entry *parent) { return NULL; } static inline struct proc_dir_entry *proc_create(const char *name, - mode_t mode, struct proc_dir_entry *parent, + umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops) { return NULL; } static inline struct proc_dir_entry *proc_create_data(const char *name, - mode_t mode, struct proc_dir_entry *parent, + umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops, void *data) { return NULL; @@ -205,10 +205,10 @@ static inline struct proc_dir_entry *proc_symlink(const char *name, static inline struct proc_dir_entry *proc_mkdir(const char *name, struct proc_dir_entry *parent) {return NULL;} static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, - mode_t mode, struct proc_dir_entry *parent) { return NULL; } + umode_t mode, struct proc_dir_entry *parent) { return NULL; } static inline struct proc_dir_entry *create_proc_read_entry(const char *name, - mode_t mode, struct proc_dir_entry *base, + umode_t mode, struct proc_dir_entry *base, read_proc_t *read_proc, void * data) { return NULL; } struct tty_driver; diff --git a/include/sound/info.h b/include/sound/info.h index 5492cc40dc57..9ca1a493d370 100644 --- a/include/sound/info.h +++ b/include/sound/info.h @@ -72,7 +72,7 @@ struct snd_info_entry_ops { struct snd_info_entry { const char *name; - mode_t mode; + umode_t mode; long size; unsigned short content; union { From 48176a973d65572e61d0ce95495e5072887e6fb6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 03:40:40 -0400 Subject: [PATCH 039/165] switch sysfs_chmod_file() to umode_t Signed-off-by: Al Viro --- drivers/hwmon/dme1737.c | 6 +++--- fs/sysfs/file.c | 2 +- include/linux/sysfs.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c index d9c592713919..d9803958e49f 100644 --- a/drivers/hwmon/dme1737.c +++ b/drivers/hwmon/dme1737.c @@ -1223,7 +1223,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, } static struct attribute *dme1737_pwm_chmod_attr[]; -static void dme1737_chmod_file(struct device*, struct attribute*, mode_t); +static void dme1737_chmod_file(struct device*, struct attribute*, umode_t); static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1961,7 +1961,7 @@ static inline void dme1737_sio_outb(int sio_cip, int reg, int val) static int dme1737_i2c_get_features(int, struct dme1737_data*); static void dme1737_chmod_file(struct device *dev, - struct attribute *attr, mode_t mode) + struct attribute *attr, umode_t mode) { if (sysfs_chmod_file(&dev->kobj, attr, mode)) { dev_warn(dev, "Failed to change permissions of %s.\n", @@ -1971,7 +1971,7 @@ static void dme1737_chmod_file(struct device *dev, static void dme1737_chmod_group(struct device *dev, const struct attribute_group *group, - mode_t mode) + umode_t mode) { struct attribute **attr; diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index d4e6080b4b20..120c3adff6b0 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -618,7 +618,7 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group); * */ int sysfs_chmod_file(struct kobject *kobj, const struct attribute *attr, - mode_t mode) + umode_t mode) { struct sysfs_dirent *sd; struct iattr newattrs; diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index e90eea7afb4e..0010009b2f00 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -133,7 +133,7 @@ int __must_check sysfs_create_file(struct kobject *kobj, int __must_check sysfs_create_files(struct kobject *kobj, const struct attribute **attr); int __must_check sysfs_chmod_file(struct kobject *kobj, - const struct attribute *attr, mode_t mode); + const struct attribute *attr, umode_t mode); void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); @@ -221,7 +221,7 @@ static inline int sysfs_create_files(struct kobject *kobj, } static inline int sysfs_chmod_file(struct kobject *kobj, - const struct attribute *attr, mode_t mode) + const struct attribute *attr, umode_t mode) { return 0; } From f4ae40a6a50a98ac23d4b285f739455e926a473e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 04:33:43 -0400 Subject: [PATCH 040/165] switch debugfs to umode_t Signed-off-by: Al Viro --- Documentation/filesystems/debugfs.txt | 24 +++++----- arch/arm/mach-msm/smd_debug.c | 2 +- arch/s390/include/asm/debug.h | 4 +- arch/s390/kernel/debug.c | 8 ++-- arch/x86/xen/debugfs.c | 2 +- arch/x86/xen/debugfs.h | 2 +- drivers/acpi/ec_sys.c | 2 +- drivers/mmc/card/mmc_test.c | 2 +- .../ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 2 +- drivers/net/wireless/ath/carl9170/debug.c | 2 +- drivers/net/wireless/libertas/debugfs.c | 2 +- drivers/s390/block/dasd.c | 4 +- drivers/scsi/bfa/bfad_debugfs.c | 2 +- fs/debugfs/file.c | 22 ++++----- fs/debugfs/inode.c | 14 +++--- fs/ocfs2/cluster/netdebug.c | 2 +- include/linux/debugfs.h | 46 +++++++++---------- include/linux/relay.h | 2 +- kernel/relay.c | 2 +- kernel/trace/blktrace.c | 2 +- kernel/trace/trace.c | 2 +- kernel/trace/trace.h | 2 +- lib/fault-inject.c | 8 ++-- mm/failslab.c | 2 +- mm/page_alloc.c | 2 +- 25 files changed, 82 insertions(+), 82 deletions(-) diff --git a/Documentation/filesystems/debugfs.txt b/Documentation/filesystems/debugfs.txt index 742cc06e138f..9281a95d689f 100644 --- a/Documentation/filesystems/debugfs.txt +++ b/Documentation/filesystems/debugfs.txt @@ -35,7 +35,7 @@ described below will work. The most general way to create a file within a debugfs directory is with: - struct dentry *debugfs_create_file(const char *name, mode_t mode, + struct dentry *debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); @@ -53,13 +53,13 @@ actually necessary; the debugfs code provides a number of helper functions for simple situations. Files containing a single integer value can be created with any of: - struct dentry *debugfs_create_u8(const char *name, mode_t mode, + struct dentry *debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, u8 *value); - struct dentry *debugfs_create_u16(const char *name, mode_t mode, + struct dentry *debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, u16 *value); - struct dentry *debugfs_create_u32(const char *name, mode_t mode, + struct dentry *debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, u32 *value); - struct dentry *debugfs_create_u64(const char *name, mode_t mode, + struct dentry *debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, u64 *value); These files support both reading and writing the given value; if a specific @@ -67,13 +67,13 @@ file should not be written to, simply set the mode bits accordingly. The values in these files are in decimal; if hexadecimal is more appropriate, the following functions can be used instead: - struct dentry *debugfs_create_x8(const char *name, mode_t mode, + struct dentry *debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value); - struct dentry *debugfs_create_x16(const char *name, mode_t mode, + struct dentry *debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value); - struct dentry *debugfs_create_x32(const char *name, mode_t mode, + struct dentry *debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, u32 *value); - struct dentry *debugfs_create_x64(const char *name, mode_t mode, + struct dentry *debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, u64 *value); These functions are useful as long as the developer knows the size of the @@ -81,7 +81,7 @@ value to be exported. Some types can have different widths on different architectures, though, complicating the situation somewhat. There is a function meant to help out in one special case: - struct dentry *debugfs_create_size_t(const char *name, mode_t mode, + struct dentry *debugfs_create_size_t(const char *name, umode_t mode, struct dentry *parent, size_t *value); @@ -90,7 +90,7 @@ a variable of type size_t. Boolean values can be placed in debugfs with: - struct dentry *debugfs_create_bool(const char *name, mode_t mode, + struct dentry *debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, u32 *value); A read on the resulting file will yield either Y (for non-zero values) or @@ -104,7 +104,7 @@ Finally, a block of arbitrary binary data can be exported with: unsigned long size; }; - struct dentry *debugfs_create_blob(const char *name, mode_t mode, + struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob); diff --git a/arch/arm/mach-msm/smd_debug.c b/arch/arm/mach-msm/smd_debug.c index 8736afff82f3..0c56a5aaf588 100644 --- a/arch/arm/mach-msm/smd_debug.c +++ b/arch/arm/mach-msm/smd_debug.c @@ -215,7 +215,7 @@ static const struct file_operations debug_ops = { .llseek = default_llseek, }; -static void debug_create(const char *name, mode_t mode, +static void debug_create(const char *name, umode_t mode, struct dentry *dent, int (*fill)(char *buf, int max)) { diff --git a/arch/s390/include/asm/debug.h b/arch/s390/include/asm/debug.h index 18124b75a7ab..9d88db1f55d0 100644 --- a/arch/s390/include/asm/debug.h +++ b/arch/s390/include/asm/debug.h @@ -73,7 +73,7 @@ typedef struct debug_info { struct dentry* debugfs_entries[DEBUG_MAX_VIEWS]; struct debug_view* views[DEBUG_MAX_VIEWS]; char name[DEBUG_MAX_NAME_LEN]; - mode_t mode; + umode_t mode; } debug_info_t; typedef int (debug_header_proc_t) (debug_info_t* id, @@ -124,7 +124,7 @@ debug_info_t *debug_register(const char *name, int pages, int nr_areas, int buf_size); debug_info_t *debug_register_mode(const char *name, int pages, int nr_areas, - int buf_size, mode_t mode, uid_t uid, + int buf_size, umode_t mode, uid_t uid, gid_t gid); void debug_unregister(debug_info_t* id); diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c index 5ad6bc078bfd..6848828b962e 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c @@ -74,7 +74,7 @@ static ssize_t debug_input(struct file *file, const char __user *user_buf, static int debug_open(struct inode *inode, struct file *file); static int debug_close(struct inode *inode, struct file *file); static debug_info_t *debug_info_create(const char *name, int pages_per_area, - int nr_areas, int buf_size, mode_t mode); + int nr_areas, int buf_size, umode_t mode); static void debug_info_get(debug_info_t *); static void debug_info_put(debug_info_t *); static int debug_prolog_level_fn(debug_info_t * id, @@ -330,7 +330,7 @@ debug_info_free(debug_info_t* db_info){ static debug_info_t* debug_info_create(const char *name, int pages_per_area, int nr_areas, - int buf_size, mode_t mode) + int buf_size, umode_t mode) { debug_info_t* rc; @@ -688,7 +688,7 @@ debug_close(struct inode *inode, struct file *file) */ debug_info_t *debug_register_mode(const char *name, int pages_per_area, - int nr_areas, int buf_size, mode_t mode, + int nr_areas, int buf_size, umode_t mode, uid_t uid, gid_t gid) { debug_info_t *rc = NULL; @@ -1090,7 +1090,7 @@ debug_register_view(debug_info_t * id, struct debug_view *view) int rc = 0; int i; unsigned long flags; - mode_t mode; + umode_t mode; struct dentry *pde; if (!id) diff --git a/arch/x86/xen/debugfs.c b/arch/x86/xen/debugfs.c index 7c0fedd98ea0..ef1db1900d86 100644 --- a/arch/x86/xen/debugfs.c +++ b/arch/x86/xen/debugfs.c @@ -109,7 +109,7 @@ static const struct file_operations u32_array_fops = { .llseek = no_llseek, }; -struct dentry *xen_debugfs_create_u32_array(const char *name, mode_t mode, +struct dentry *xen_debugfs_create_u32_array(const char *name, umode_t mode, struct dentry *parent, u32 *array, unsigned elements) { diff --git a/arch/x86/xen/debugfs.h b/arch/x86/xen/debugfs.h index e28132084832..78d25499be5b 100644 --- a/arch/x86/xen/debugfs.h +++ b/arch/x86/xen/debugfs.h @@ -3,7 +3,7 @@ struct dentry * __init xen_init_debugfs(void); -struct dentry *xen_debugfs_create_u32_array(const char *name, mode_t mode, +struct dentry *xen_debugfs_create_u32_array(const char *name, umode_t mode, struct dentry *parent, u32 *array, unsigned elements); diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c index 6c47ae9793a7..b258cab9061c 100644 --- a/drivers/acpi/ec_sys.c +++ b/drivers/acpi/ec_sys.c @@ -105,7 +105,7 @@ int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) { struct dentry *dev_dir; char name[64]; - mode_t mode = 0400; + umode_t mode = 0400; if (ec_device_count == 0) { acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL); diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index b038c4a9468b..e99bdc18002d 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c @@ -2949,7 +2949,7 @@ static void mmc_test_free_dbgfs_file(struct mmc_card *card) } static int __mmc_test_register_dbgfs_file(struct mmc_card *card, - const char *name, mode_t mode, const struct file_operations *fops) + const char *name, umode_t mode, const struct file_operations *fops) { struct dentry *file = NULL; struct mmc_test_dbgfs_file *df; diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index da9072bfca8b..f5a24d99ef4f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@ -2000,7 +2000,7 @@ static const struct file_operations interfaces_proc_fops = { */ struct cxgb4vf_debugfs_entry { const char *name; /* name of debugfs node */ - mode_t mode; /* file system mode */ + umode_t mode; /* file system mode */ const struct file_operations *fops; }; diff --git a/drivers/net/wireless/ath/carl9170/debug.c b/drivers/net/wireless/ath/carl9170/debug.c index de57f90e1d5f..3c164226687f 100644 --- a/drivers/net/wireless/ath/carl9170/debug.c +++ b/drivers/net/wireless/ath/carl9170/debug.c @@ -56,7 +56,7 @@ static int carl9170_debugfs_open(struct inode *inode, struct file *file) struct carl9170_debugfs_fops { unsigned int read_bufsize; - mode_t attr; + umode_t attr; char *(*read)(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len); ssize_t (*write)(struct ar9170 *aru, const char *buf, size_t size); diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c index d8d8f0d0899f..c192671610fc 100644 --- a/drivers/net/wireless/libertas/debugfs.c +++ b/drivers/net/wireless/libertas/debugfs.c @@ -704,7 +704,7 @@ out_unlock: struct lbs_debugfs_files { const char *name; - int perm; + umode_t perm; struct file_operations fops; }; diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 65894f05a801..42986d7bcf9d 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -1073,7 +1073,7 @@ static const struct file_operations dasd_stats_global_fops = { static void dasd_profile_init(struct dasd_profile *profile, struct dentry *base_dentry) { - mode_t mode; + umode_t mode; struct dentry *pde; if (!base_dentry) @@ -1112,7 +1112,7 @@ static void dasd_statistics_removeroot(void) static void dasd_statistics_createroot(void) { - mode_t mode; + umode_t mode; struct dentry *pde; dasd_debugfs_root_entry = NULL; diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c index dee1a094c2c2..caca9b7c8309 100644 --- a/drivers/scsi/bfa/bfad_debugfs.c +++ b/drivers/scsi/bfa/bfad_debugfs.c @@ -472,7 +472,7 @@ static const struct file_operations bfad_debugfs_op_regwr = { struct bfad_debugfs_entry { const char *name; - mode_t mode; + umode_t mode; const struct file_operations *fops; }; diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 90f76575c056..d5016606fb27 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -95,7 +95,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u8_wo, NULL, debugfs_u8_set, "%llu\n"); * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling * code. */ -struct dentry *debugfs_create_u8(const char *name, mode_t mode, +struct dentry *debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, u8 *value) { /* if there are no write bits set, make read only */ @@ -147,7 +147,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u16_wo, NULL, debugfs_u16_set, "%llu\n"); * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling * code. */ -struct dentry *debugfs_create_u16(const char *name, mode_t mode, +struct dentry *debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, u16 *value) { /* if there are no write bits set, make read only */ @@ -199,7 +199,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u32_wo, NULL, debugfs_u32_set, "%llu\n"); * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling * code. */ -struct dentry *debugfs_create_u32(const char *name, mode_t mode, +struct dentry *debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, u32 *value) { /* if there are no write bits set, make read only */ @@ -252,7 +252,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u64_wo, NULL, debugfs_u64_set, "%llu\n"); * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling * code. */ -struct dentry *debugfs_create_u64(const char *name, mode_t mode, +struct dentry *debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, u64 *value) { /* if there are no write bits set, make read only */ @@ -298,7 +298,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_x64, debugfs_u64_get, debugfs_u64_set, "0x%016llx\n * @value: a pointer to the variable that the file should read to and write * from. */ -struct dentry *debugfs_create_x8(const char *name, mode_t mode, +struct dentry *debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value) { /* if there are no write bits set, make read only */ @@ -322,7 +322,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_x8); * @value: a pointer to the variable that the file should read to and write * from. */ -struct dentry *debugfs_create_x16(const char *name, mode_t mode, +struct dentry *debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value) { /* if there are no write bits set, make read only */ @@ -346,7 +346,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_x16); * @value: a pointer to the variable that the file should read to and write * from. */ -struct dentry *debugfs_create_x32(const char *name, mode_t mode, +struct dentry *debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, u32 *value) { /* if there are no write bits set, make read only */ @@ -370,7 +370,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_x32); * @value: a pointer to the variable that the file should read to and write * from. */ -struct dentry *debugfs_create_x64(const char *name, mode_t mode, +struct dentry *debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, u64 *value) { return debugfs_create_file(name, mode, parent, value, &fops_x64); @@ -401,7 +401,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_size_t, debugfs_size_t_get, debugfs_size_t_set, * @value: a pointer to the variable that the file should read to and write * from. */ -struct dentry *debugfs_create_size_t(const char *name, mode_t mode, +struct dentry *debugfs_create_size_t(const char *name, umode_t mode, struct dentry *parent, size_t *value) { return debugfs_create_file(name, mode, parent, value, &fops_size_t); @@ -473,7 +473,7 @@ static const struct file_operations fops_bool = { * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling * code. */ -struct dentry *debugfs_create_bool(const char *name, mode_t mode, +struct dentry *debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, u32 *value) { return debugfs_create_file(name, mode, parent, value, &fops_bool); @@ -518,7 +518,7 @@ static const struct file_operations fops_blob = { * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling * code. */ -struct dentry *debugfs_create_blob(const char *name, mode_t mode, +struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob) { diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index c9dc08d0c100..956d5ddddf6e 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -30,7 +30,7 @@ static struct vfsmount *debugfs_mount; static int debugfs_mount_count; static bool debugfs_registered; -static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t dev, +static struct inode *debugfs_get_inode(struct super_block *sb, umode_t mode, dev_t dev, void *data, const struct file_operations *fops) { @@ -69,7 +69,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d /* SMP-safe */ static int debugfs_mknod(struct inode *dir, struct dentry *dentry, - int mode, dev_t dev, void *data, + umode_t mode, dev_t dev, void *data, const struct file_operations *fops) { struct inode *inode; @@ -87,7 +87,7 @@ static int debugfs_mknod(struct inode *dir, struct dentry *dentry, return error; } -static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode, +static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode, void *data, const struct file_operations *fops) { int res; @@ -101,14 +101,14 @@ static int debugfs_mkdir(struct inode *dir, struct dentry *dentry, int mode, return res; } -static int debugfs_link(struct inode *dir, struct dentry *dentry, int mode, +static int debugfs_link(struct inode *dir, struct dentry *dentry, umode_t mode, void *data, const struct file_operations *fops) { mode = (mode & S_IALLUGO) | S_IFLNK; return debugfs_mknod(dir, dentry, mode, 0, data, fops); } -static int debugfs_create(struct inode *dir, struct dentry *dentry, int mode, +static int debugfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, void *data, const struct file_operations *fops) { int res; @@ -146,7 +146,7 @@ static struct file_system_type debug_fs_type = { .kill_sb = kill_litter_super, }; -static int debugfs_create_by_name(const char *name, mode_t mode, +static int debugfs_create_by_name(const char *name, umode_t mode, struct dentry *parent, struct dentry **dentry, void *data, @@ -214,7 +214,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode, * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned. */ -struct dentry *debugfs_create_file(const char *name, mode_t mode, +struct dentry *debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops) { 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) int o2net_debugfs_init(void) { - mode_t mode = S_IFREG|S_IRUSR; + umode_t mode = S_IFREG|S_IRUSR; o2net_dentry = debugfs_create_dir(O2NET_DEBUG_DIR, NULL); if (o2net_dentry) diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index e7d9b20ddc5b..d1ac841e8dc7 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -34,7 +34,7 @@ extern struct dentry *arch_debugfs_dir; extern const struct file_operations debugfs_file_operations; extern const struct inode_operations debugfs_link_operations; -struct dentry *debugfs_create_file(const char *name, mode_t mode, +struct dentry *debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); @@ -49,28 +49,28 @@ void debugfs_remove_recursive(struct dentry *dentry); struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, struct dentry *new_dir, const char *new_name); -struct dentry *debugfs_create_u8(const char *name, mode_t mode, +struct dentry *debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, u8 *value); -struct dentry *debugfs_create_u16(const char *name, mode_t mode, +struct dentry *debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, u16 *value); -struct dentry *debugfs_create_u32(const char *name, mode_t mode, +struct dentry *debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, u32 *value); -struct dentry *debugfs_create_u64(const char *name, mode_t mode, +struct dentry *debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, u64 *value); -struct dentry *debugfs_create_x8(const char *name, mode_t mode, +struct dentry *debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value); -struct dentry *debugfs_create_x16(const char *name, mode_t mode, +struct dentry *debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value); -struct dentry *debugfs_create_x32(const char *name, mode_t mode, +struct dentry *debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, u32 *value); -struct dentry *debugfs_create_x64(const char *name, mode_t mode, +struct dentry *debugfs_create_x64(const char *name, umode_t mode, struct dentry *parent, u64 *value); -struct dentry *debugfs_create_size_t(const char *name, mode_t mode, +struct dentry *debugfs_create_size_t(const char *name, umode_t mode, struct dentry *parent, size_t *value); -struct dentry *debugfs_create_bool(const char *name, mode_t mode, +struct dentry *debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, u32 *value); -struct dentry *debugfs_create_blob(const char *name, mode_t mode, +struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob); @@ -86,7 +86,7 @@ bool debugfs_initialized(void); * want to duplicate the design decision mistakes of procfs and devfs again. */ -static inline struct dentry *debugfs_create_file(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops) { @@ -118,70 +118,70 @@ static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentr return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_u8(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, u8 *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_u16(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_u16(const char *name, umode_t mode, struct dentry *parent, u16 *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, u32 *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_u64(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, u64 *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_x8(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_x16(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_x16(const char *name, umode_t mode, struct dentry *parent, u16 *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_x32(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_x32(const char *name, umode_t mode, struct dentry *parent, u32 *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_size_t(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_size_t(const char *name, umode_t mode, struct dentry *parent, size_t *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent, u32 *value) { return ERR_PTR(-ENODEV); } -static inline struct dentry *debugfs_create_blob(const char *name, mode_t mode, +static inline struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob) { diff --git a/include/linux/relay.h b/include/linux/relay.h index 14a86bc7102b..a822fd71fd64 100644 --- a/include/linux/relay.h +++ b/include/linux/relay.h @@ -144,7 +144,7 @@ struct rchan_callbacks */ struct dentry *(*create_buf_file)(const char *filename, struct dentry *parent, - int mode, + umode_t mode, struct rchan_buf *buf, int *is_global); diff --git a/kernel/relay.c b/kernel/relay.c index 226fade4d727..4335e1d7ee2d 100644 --- a/kernel/relay.c +++ b/kernel/relay.c @@ -302,7 +302,7 @@ static void buf_unmapped_default_callback(struct rchan_buf *buf, */ static struct dentry *create_buf_file_default_callback(const char *filename, struct dentry *parent, - int mode, + umode_t mode, struct rchan_buf *buf, int *is_global) { diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 16fc34a0806f..cdea7b56b0c9 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -402,7 +402,7 @@ static int blk_remove_buf_file_callback(struct dentry *dentry) static struct dentry *blk_create_buf_file_callback(const char *filename, struct dentry *parent, - int mode, + umode_t mode, struct rchan_buf *buf, int *is_global) { diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index f2bd275bb60f..660b069a0f99 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -4385,7 +4385,7 @@ static const struct file_operations trace_options_core_fops = { }; struct dentry *trace_create_file(const char *name, - mode_t mode, + umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 092e1f8d18dc..0154c0b850de 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -312,7 +312,7 @@ void tracing_reset_current(int cpu); void tracing_reset_current_online_cpus(void); int tracing_open_generic(struct inode *inode, struct file *filp); struct dentry *trace_create_file(const char *name, - mode_t mode, + umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); diff --git a/lib/fault-inject.c b/lib/fault-inject.c index 4f7554025e30..b4801f51b607 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c @@ -149,7 +149,7 @@ static int debugfs_ul_get(void *data, u64 *val) DEFINE_SIMPLE_ATTRIBUTE(fops_ul, debugfs_ul_get, debugfs_ul_set, "%llu\n"); -static struct dentry *debugfs_create_ul(const char *name, mode_t mode, +static struct dentry *debugfs_create_ul(const char *name, umode_t mode, struct dentry *parent, unsigned long *value) { return debugfs_create_file(name, mode, parent, value, &fops_ul); @@ -169,7 +169,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_stacktrace_depth, debugfs_ul_get, debugfs_stacktrace_depth_set, "%llu\n"); static struct dentry *debugfs_create_stacktrace_depth( - const char *name, mode_t mode, + const char *name, umode_t mode, struct dentry *parent, unsigned long *value) { return debugfs_create_file(name, mode, parent, value, @@ -193,7 +193,7 @@ static int debugfs_atomic_t_get(void *data, u64 *val) DEFINE_SIMPLE_ATTRIBUTE(fops_atomic_t, debugfs_atomic_t_get, debugfs_atomic_t_set, "%lld\n"); -static struct dentry *debugfs_create_atomic_t(const char *name, mode_t mode, +static struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, struct dentry *parent, atomic_t *value) { return debugfs_create_file(name, mode, parent, value, &fops_atomic_t); @@ -202,7 +202,7 @@ static struct dentry *debugfs_create_atomic_t(const char *name, mode_t mode, struct dentry *fault_create_debugfs_attr(const char *name, struct dentry *parent, struct fault_attr *attr) { - mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; + umode_t mode = S_IFREG | S_IRUSR | S_IWUSR; struct dentry *dir; dir = debugfs_create_dir(name, parent); diff --git a/mm/failslab.c b/mm/failslab.c index 0dd7b8fec71c..fefaabaab76d 100644 --- a/mm/failslab.c +++ b/mm/failslab.c @@ -35,7 +35,7 @@ __setup("failslab=", setup_failslab); static int __init failslab_debugfs_init(void) { struct dentry *dir; - mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; + umode_t mode = S_IFREG | S_IRUSR | S_IWUSR; dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr); if (IS_ERR(dir)) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2b8ba3aebf6e..99930ec7d140 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1408,7 +1408,7 @@ static int should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) static int __init fail_page_alloc_debugfs(void) { - mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; + umode_t mode = S_IFREG | S_IRUSR | S_IWUSR; struct dentry *dir; dir = fault_create_debugfs_attr("fail_page_alloc", NULL, From fbd48a69a0b576dd8cba01b2b4fc24fad76f1b68 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 10:47:56 -0400 Subject: [PATCH 041/165] switch devtmpfs to umode_t Signed-off-by: Al Viro --- drivers/base/devtmpfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 3990f682e690..393f450cf43c 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -142,7 +142,7 @@ int devtmpfs_delete_node(struct device *dev) return req.err; } -static int dev_mkdir(const char *name, mode_t mode) +static int dev_mkdir(const char *name, umode_t mode) { struct dentry *dentry; struct path path; @@ -189,7 +189,7 @@ static int create_path(const char *nodepath) return err; } -static int handle_create(const char *nodename, mode_t mode, struct device *dev) +static int handle_create(const char *nodename, umode_t mode, struct device *dev) { struct dentry *dentry; struct path path; @@ -378,7 +378,7 @@ int devtmpfs_mount(const char *mntdir) static DECLARE_COMPLETION(setup_done); -static int handle(const char *name, mode_t mode, struct device *dev) +static int handle(const char *name, umode_t mode, struct device *dev) { if (mode) return handle_create(name, mode, dev); From 439475140bed762c04567c325d48409862341ae4 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 25 Jul 2011 00:05:26 -0400 Subject: [PATCH 042/165] configfs: convert to umode_t Signed-off-by: Al Viro --- Documentation/filesystems/configfs/configfs.txt | 2 +- fs/configfs/configfs_internal.h | 4 ++-- fs/configfs/inode.c | 6 +++--- include/linux/configfs.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/filesystems/configfs/configfs.txt b/Documentation/filesystems/configfs/configfs.txt index dd57bb6bb390..b40fec9d3f53 100644 --- a/Documentation/filesystems/configfs/configfs.txt +++ b/Documentation/filesystems/configfs/configfs.txt @@ -192,7 +192,7 @@ attribute value uses the store_attribute() method. struct configfs_attribute { char *ca_name; struct module *ca_owner; - mode_t ca_mode; + umode_t ca_mode; }; When a config_item wants an attribute to appear as a file in the item's 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; extern int configfs_is_root(struct config_item *item); -extern struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent *); -extern int configfs_create(struct dentry *, int mode, int (*init)(struct inode *)); +extern struct inode * configfs_new_inode(umode_t mode, struct configfs_dirent *); +extern int configfs_create(struct dentry *, umode_t mode, int (*init)(struct inode *)); extern int configfs_inode_init(void); extern void configfs_inode_exit(void); 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) return error; } -static inline void set_default_inode_attr(struct inode * inode, mode_t mode) +static inline void set_default_inode_attr(struct inode * inode, umode_t mode) { inode->i_mode = mode; 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) inode->i_ctime = iattr->ia_ctime; } -struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd) +struct inode *configfs_new_inode(umode_t mode, struct configfs_dirent * sd) { struct inode * inode = new_inode(configfs_sb); if (inode) { @@ -185,7 +185,7 @@ static void configfs_set_inode_lock_class(struct configfs_dirent *sd, #endif /* CONFIG_LOCKDEP */ -int configfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *)) +int configfs_create(struct dentry * dentry, umode_t mode, int (*init)(struct inode *)) { int error = 0; struct inode * inode = NULL; diff --git a/include/linux/configfs.h b/include/linux/configfs.h index 3081c58d696e..34025df61829 100644 --- a/include/linux/configfs.h +++ b/include/linux/configfs.h @@ -124,7 +124,7 @@ extern struct config_item *config_group_find_item(struct config_group *, struct configfs_attribute { const char *ca_name; struct module *ca_owner; - mode_t ca_mode; + umode_t ca_mode; }; /* From 18cb1b08d2e1ff6907130fc0ce78a5912efa0ba5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 13:47:19 -0400 Subject: [PATCH 043/165] kill ecryptfs_create_underlying_file() it's a just a wrapper for vfs_create() Signed-off-by: Al Viro --- fs/ecryptfs/inode.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index be20cbfca7e9..13303830ec8b 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -143,24 +143,6 @@ static int ecryptfs_interpose(struct dentry *lower_dentry, return 0; } -/** - * ecryptfs_create_underlying_file - * @lower_dir_inode: inode of the parent in the lower fs of the new file - * @dentry: New file's dentry - * @mode: The mode of the new file - * - * Creates the file in the lower file system. - * - * Returns zero on success; non-zero on error condition - */ -static int -ecryptfs_create_underlying_file(struct inode *lower_dir_inode, - struct dentry *dentry, int mode) -{ - struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); - return vfs_create(lower_dir_inode, lower_dentry, mode, NULL); -} - /** * ecryptfs_do_create * @directory_inode: inode of the new file's dentry's parent in ecryptfs @@ -191,8 +173,7 @@ ecryptfs_do_create(struct inode *directory_inode, inode = ERR_CAST(lower_dir_dentry); goto out; } - rc = ecryptfs_create_underlying_file(lower_dir_dentry->d_inode, - ecryptfs_dentry, mode); + rc = vfs_create(lower_dir_dentry->d_inode, lower_dentry, mode, NULL); if (rc) { printk(KERN_ERR "%s: Failure to create dentry in lower fs; " "rc = [%d]\n", __func__, rc); From c2837de73e8081bd33bc72ad73f49d6bcba9d1b6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 18:59:07 -0400 Subject: [PATCH 044/165] 9p: don't bother with unixmode2p9mode() for link() and symlink() Pass perm to v9fs_vfs_mkspecial() instead of passing mode; calculate in caller when done for mknod(), use known value for link() and symlink(). As the result, we avoid a bit of work *and* stop mixing mode_t with P9_DMLINK. Signed-off-by: Al Viro --- fs/9p/vfs_inode.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index f54a26859fcc..cde57a850adb 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; * */ -static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) +static u32 unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) { int res; res = mode & 0777; if (S_ISDIR(mode)) res |= P9_DMDIR; if (v9fs_proto_dotu(v9ses)) { - if (S_ISLNK(mode)) - res |= P9_DMSYMLINK; if (v9ses->nodev == 0) { if (S_ISSOCK(mode)) res |= P9_DMSOCKET; @@ -85,10 +83,7 @@ static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) res |= P9_DMSETGID; if ((mode & S_ISVTX) == S_ISVTX) res |= P9_DMSETVTX; - if ((mode & P9_DMLINK)) - res |= P9_DMLINK; } - return res; } @@ -1303,9 +1298,8 @@ v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) */ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, - int mode, const char *extension) + u32 perm, const char *extension) { - u32 perm; struct p9_fid *fid; struct v9fs_session_info *v9ses; @@ -1315,7 +1309,6 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, return -EPERM; } - perm = unixmode2p9mode(v9ses, mode); fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm, P9_OREAD); if (IS_ERR(fid)) @@ -1342,7 +1335,7 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name, symname); - return v9fs_vfs_mkspecial(dir, dentry, S_IFLNK, symname); + return v9fs_vfs_mkspecial(dir, dentry, P9_DMSYMLINK, symname); } /** @@ -1399,11 +1392,13 @@ clunk_fid: static int v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) { + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); int retval; char *name; + u32 perm; P9_DPRINTK(P9_DEBUG_VFS, - " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino, + " %lu,%s mode: %hx MAJOR: %u MINOR: %u\n", dir->i_ino, dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); if (!new_valid_dev(rdev)) @@ -1426,7 +1421,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rde return -EINVAL; } - retval = v9fs_vfs_mkspecial(dir, dentry, mode, name); + perm = unixmode2p9mode(v9ses, mode); + retval = v9fs_vfs_mkspecial(dir, dentry, perm, name); __putname(name); return retval; From 3ea40bc9471ae5a24b7e07cbf085fcd3c9572c91 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:46:18 -0400 Subject: [PATCH 045/165] ext2: propagate umode_t Signed-off-by: Al Viro --- fs/ext2/dir.c | 2 +- fs/ext2/ext2.h | 2 +- fs/ext2/ialloc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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] = { static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode) { - mode_t mode = inode->i_mode; + umode_t mode = inode->i_mode; if (EXT2_HAS_INCOMPAT_FEATURE(inode->i_sb, EXT2_FEATURE_INCOMPAT_FILETYPE)) de->file_type = ext2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; 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 **); extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int); /* ialloc.c */ -extern struct inode * ext2_new_inode (struct inode *, int, const struct qstr *); +extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *); extern void ext2_free_inode (struct inode *); extern unsigned long ext2_count_free_inodes (struct super_block *); extern 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: return group; } -struct inode *ext2_new_inode(struct inode *dir, int mode, +struct inode *ext2_new_inode(struct inode *dir, umode_t mode, const struct qstr *qstr) { struct super_block *sb; From 69b34f3ab30836bb736b5108f40bf76de9f656f3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:46:57 -0400 Subject: [PATCH 046/165] ext3: propagate umode_t Signed-off-by: Al Viro --- fs/ext3/ialloc.c | 2 +- include/linux/ext3_fs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) * group to find a free inode. */ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, - const struct qstr *qstr, int mode) + const struct qstr *qstr, umode_t mode) { struct super_block *sb; struct buffer_head *bitmap_bh = NULL; diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h index dec99116a0e4..f957085d40ed 100644 --- a/include/linux/ext3_fs.h +++ b/include/linux/ext3_fs.h @@ -884,7 +884,7 @@ extern int ext3fs_dirhash(const char *name, int len, struct /* ialloc.c */ extern struct inode * ext3_new_inode (handle_t *, struct inode *, - const struct qstr *, int); + const struct qstr *, umode_t); extern void ext3_free_inode (handle_t *, struct inode *); extern struct inode * ext3_orphan_get (struct super_block *, unsigned long); extern unsigned long ext3_count_free_inodes (struct super_block *); From dcca3fec9f6436dae8693e38cc69c241ea0860cd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:48:06 -0400 Subject: [PATCH 047/165] ext4: propagate umode_t Signed-off-by: Al Viro --- fs/ext4/ext4.h | 2 +- fs/ext4/ialloc.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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 dx_hash_info *hinfo); /* ialloc.c */ -extern struct inode *ext4_new_inode(handle_t *, struct inode *, int, +extern struct inode *ext4_new_inode(handle_t *, struct inode *, umode_t, const struct qstr *qstr, __u32 goal, uid_t *owner); extern 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, */ static int find_group_orlov(struct super_block *sb, struct inode *parent, - ext4_group_t *group, int mode, + ext4_group_t *group, umode_t mode, const struct qstr *qstr) { ext4_group_t parent_group = EXT4_I(parent)->i_block_group; @@ -497,7 +497,7 @@ fallback_retry: } static int find_group_other(struct super_block *sb, struct inode *parent, - ext4_group_t *group, int mode) + ext4_group_t *group, umode_t mode) { ext4_group_t parent_group = EXT4_I(parent)->i_block_group; 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, */ static int ext4_claim_inode(struct super_block *sb, struct buffer_head *inode_bitmap_bh, - unsigned long ino, ext4_group_t group, int mode) + unsigned long ino, ext4_group_t group, umode_t mode) { int free = 0, retval = 0, count; struct ext4_sb_info *sbi = EXT4_SB(sb); @@ -690,7 +690,7 @@ err_ret: * For other inodes, search forward from the parent directory's block * group to find a free inode. */ -struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode, +struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, umode_t mode, const struct qstr *qstr, __u32 goal, uid_t *owner) { struct super_block *sb; From 4f45ba3d101fd882ed122059e6797786c81e2c17 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:48:39 -0400 Subject: [PATCH 048/165] minix: propagate umode_t Signed-off-by: Al Viro --- fs/minix/bitmap.c | 2 +- fs/minix/minix.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) mark_buffer_dirty(bh); } -struct inode *minix_new_inode(const struct inode *dir, int mode, int *error) +struct inode *minix_new_inode(const struct inode *dir, umode_t mode, int *error) { struct super_block *sb = dir->i_sb; struct minix_sb_info *sbi = minix_sb(sb); 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 { extern struct inode *minix_iget(struct super_block *, unsigned long); extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **); extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **); -extern struct inode * minix_new_inode(const struct inode *, int, int *); +extern struct inode * minix_new_inode(const struct inode *, umode_t, int *); extern void minix_free_inode(struct inode * inode); extern unsigned long minix_count_free_inodes(struct super_block *sb); extern int minix_new_block(struct inode * inode); From 6a9a06d9ca3d307bd83d93e442ad964f5de7ec2c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:49:13 -0400 Subject: [PATCH 049/165] ufs: propagate umode_t Signed-off-by: Al Viro --- fs/ufs/ialloc.c | 2 +- fs/ufs/inode.c | 4 ++-- fs/ufs/ufs.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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, * For other inodes, search forward from the parent directory's block * group to find a free inode. */ -struct inode * ufs_new_inode(struct inode * dir, int mode) +struct inode *ufs_new_inode(struct inode *dir, umode_t mode) { struct super_block * sb; 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) { struct ufs_inode_info *ufsi = UFS_I(inode); struct super_block *sb = inode->i_sb; - mode_t mode; + umode_t mode; /* * Copy data to the in-core inode. @@ -630,7 +630,7 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode) { struct ufs_inode_info *ufsi = UFS_I(inode); struct super_block *sb = inode->i_sb; - mode_t mode; + umode_t mode; UFSD("Reading ufs2 inode, ino %lu\n", inode->i_ino); /* 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; /* ialloc.c */ extern void ufs_free_inode (struct inode *inode); -extern struct inode * ufs_new_inode (struct inode *, int); +extern struct inode * ufs_new_inode (struct inode *, umode_t); /* inode.c */ extern struct inode *ufs_iget(struct super_block *, unsigned long); From dd716e64d60f2ad40e0da7db426d4bfc7eabd5d7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:49:38 -0400 Subject: [PATCH 050/165] sysv: propagate umode_t Signed-off-by: Al Viro --- fs/sysv/ialloc.c | 2 +- fs/sysv/sysv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) brelse(bh); } -struct inode * sysv_new_inode(const struct inode * dir, mode_t mode) +struct inode * sysv_new_inode(const struct inode * dir, umode_t mode) { struct super_block *sb = dir->i_sb; struct sysv_sb_info *sbi = SYSV_SB(sb); 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) /* ialloc.c */ extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned, struct buffer_head **); -extern struct inode * sysv_new_inode(const struct inode *, mode_t); +extern struct inode * sysv_new_inode(const struct inode *, umode_t); extern void sysv_free_inode(struct inode *); extern unsigned long sysv_count_free_inodes(struct super_block *); From 576b1d67ce949e7542ff765b00eb5357e706768b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:50:15 -0400 Subject: [PATCH 051/165] xfs: propagate umode_t Signed-off-by: Al Viro --- fs/xfs/xfs_ialloc.c | 4 ++-- fs/xfs/xfs_ialloc.h | 2 +- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode.h | 2 +- fs/xfs/xfs_iops.c | 2 +- fs/xfs/xfs_utils.c | 2 +- fs/xfs/xfs_utils.h | 2 +- fs/xfs/xfs_vnodeops.c | 4 ++-- fs/xfs/xfs_vnodeops.h | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) 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 */ xfs_ialloc_ag_select( xfs_trans_t *tp, /* transaction pointer */ xfs_ino_t parent, /* parent directory inode number */ - mode_t mode, /* bits set to indicate file type */ + umode_t mode, /* bits set to indicate file type */ int okalloc) /* ok to allocate more space */ { xfs_buf_t *agbp; /* allocation group header buffer */ @@ -640,7 +640,7 @@ int xfs_dialloc( xfs_trans_t *tp, /* transaction pointer */ xfs_ino_t parent, /* parent inode (directory) */ - mode_t mode, /* mode bits for new inode */ + umode_t mode, /* mode bits for new inode */ int okalloc, /* ok to allocate more space */ xfs_buf_t **IO_agbp, /* in/out ag header's buffer */ 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 */ xfs_dialloc( struct xfs_trans *tp, /* transaction pointer */ xfs_ino_t parent, /* parent inode (directory) */ - mode_t mode, /* mode bits for new inode */ + umode_t mode, /* mode bits for new inode */ int okalloc, /* ok to allocate more space */ struct xfs_buf **agbp, /* buf for a.g. inode header */ boolean_t *alloc_done, /* an allocation was done to replenish 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 xfs_ialloc( xfs_trans_t *tp, xfs_inode_t *pip, - mode_t mode, + umode_t mode, xfs_nlink_t nlink, xfs_dev_t rdev, prid_t prid, @@ -1002,7 +1002,7 @@ xfs_ialloc( return error; ASSERT(ip != NULL); - ip->i_d.di_mode = (__uint16_t)mode; + ip->i_d.di_mode = mode; ip->i_d.di_onlink = 0; ip->i_d.di_nlink = nlink; 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); /* * xfs_inode.c prototypes. */ -int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, +int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, umode_t, xfs_nlink_t, xfs_dev_t, prid_t, int, struct xfs_buf **, boolean_t *, xfs_inode_t **); diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index c2cf9bb60863..f9babd179223 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -366,7 +366,7 @@ xfs_vn_symlink( struct xfs_inode *cip = NULL; struct xfs_name name; int error; - mode_t mode; + umode_t mode; mode = S_IFLNK | (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO); 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( output: may be a new transaction. */ xfs_inode_t *dp, /* directory within whose allocate the inode. */ - mode_t mode, + umode_t mode, xfs_nlink_t nlink, xfs_dev_t rdev, 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 @@ #ifndef __XFS_UTILS_H__ #define __XFS_UTILS_H__ -extern int xfs_dir_ialloc(xfs_trans_t **, xfs_inode_t *, mode_t, xfs_nlink_t, +extern int xfs_dir_ialloc(xfs_trans_t **, xfs_inode_t *, umode_t, xfs_nlink_t, xfs_dev_t, prid_t, int, xfs_inode_t **, int *); extern int xfs_droplink(xfs_trans_t *, xfs_inode_t *); extern 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 xfs_create( xfs_inode_t *dp, struct xfs_name *name, - mode_t mode, + umode_t mode, xfs_dev_t rdev, xfs_inode_t **ipp) { @@ -1481,7 +1481,7 @@ xfs_symlink( xfs_inode_t *dp, struct xfs_name *link_name, const char *target_path, - mode_t mode, + umode_t mode, xfs_inode_t **ipp) { 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); int xfs_inactive(struct xfs_inode *ip); int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name, struct xfs_inode **ipp, struct xfs_name *ci_name); -int xfs_create(struct xfs_inode *dp, struct xfs_name *name, mode_t mode, +int xfs_create(struct xfs_inode *dp, struct xfs_name *name, umode_t mode, xfs_dev_t rdev, struct xfs_inode **ipp); int xfs_remove(struct xfs_inode *dp, struct xfs_name *name, struct xfs_inode *ip); @@ -35,7 +35,7 @@ int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip, int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, xfs_off_t *offset, filldir_t filldir); int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name, - const char *target_path, mode_t mode, struct xfs_inode **ipp); + const char *target_path, umode_t mode, struct xfs_inode **ipp); int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state); int xfs_change_file_space(struct xfs_inode *ip, int cmd, xfs_flock64_t *bf, xfs_off_t offset, int attr_flags); From 8e0718924e7d7eaf6104e54aeaeda477570e1e06 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:50:53 -0400 Subject: [PATCH 052/165] reiserfs: propagate umode_t Signed-off-by: Al Viro --- fs/reiserfs/inode.c | 2 +- fs/reiserfs/namei.c | 2 +- include/linux/reiserfs_fs.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 for the fresh inode. This can only be done outside a transaction, so if we return non-zero, we also end the transaction. */ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, - struct inode *dir, int mode, const char *symname, + struct inode *dir, umode_t mode, const char *symname, /* 0 for regular, EMTRY_DIR_SIZE for dirs, strlen (symname) for symlinks) */ loff_t i_size, struct dentry *dentry, diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index a8614bd7cc8d..146378865239 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c @@ -559,7 +559,7 @@ static int drop_new_inode(struct inode *inode) ** outside of a transaction, so we had to pull some bits of ** reiserfs_new_inode out into this func. */ -static int new_inode_init(struct inode *inode, struct inode *dir, int mode) +static int new_inode_init(struct inode *inode, struct inode *dir, umode_t mode) { /* Make inode invalid - just in case we are going to drop it before * the initialization happens */ diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h index 96d465f8d3e6..26be28fd7b76 100644 --- a/include/linux/reiserfs_fs.h +++ b/include/linux/reiserfs_fs.h @@ -2056,7 +2056,7 @@ struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key); struct reiserfs_security_handle; int reiserfs_new_inode(struct reiserfs_transaction_handle *th, - struct inode *dir, int mode, + struct inode *dir, umode_t mode, const char *symname, loff_t i_size, struct dentry *dentry, struct inode *inode, struct reiserfs_security_handle *security); From 587228be4a43c28c402c1cc8a5f185252d8e2231 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 22:58:10 -0400 Subject: [PATCH 053/165] omfs: propagate umode_t Signed-off-by: Al Viro --- fs/omfs/dir.c | 2 +- fs/omfs/inode.c | 2 +- fs/omfs/omfs.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c index d82599f49f6d..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) return 0; } -static int omfs_add_node(struct inode *dir, struct dentry *dentry, int mode) +static int omfs_add_node(struct inode *dir, struct dentry *dentry, umode_t mode) { int err; struct inode *inode = omfs_new_inode(dir, mode); 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) return sb_bread(sb, clus_to_blk(sbi, block)); } -struct inode *omfs_new_inode(struct inode *dir, int mode) +struct inode *omfs_new_inode(struct inode *dir, umode_t mode) { struct inode *inode; 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); /* inode.c */ extern struct buffer_head *omfs_bread(struct super_block *sb, sector_t block); extern struct inode *omfs_iget(struct super_block *sb, ino_t inode); -extern struct inode *omfs_new_inode(struct inode *dir, int mode); +extern struct inode *omfs_new_inode(struct inode *dir, umode_t mode); extern int omfs_reserve_block(struct super_block *sb, sector_t block); extern int omfs_find_empty_block(struct super_block *sb, int mode, ino_t *ino); extern int omfs_sync_inode(struct inode *inode); From 3eda0de677b5756be09a76ac0399e1a3db00f0e0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:53:22 -0400 Subject: [PATCH 054/165] 9p: propagate umode_t Signed-off-by: Al Viro --- fs/9p/v9fs_vfs.h | 4 ++-- fs/9p/vfs_inode.c | 21 +++++++++++---------- fs/9p/vfs_inode_dotl.c | 2 +- fs/9p/vfs_super.c | 2 +- 4 files changed, 15 insertions(+), 14 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; struct inode *v9fs_alloc_inode(struct super_block *sb); void v9fs_destroy_inode(struct inode *inode); -struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t); +struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t); int v9fs_init_inode(struct v9fs_session_info *v9ses, - struct inode *inode, int mode, dev_t); + struct inode *inode, umode_t mode, dev_t); void v9fs_evict_inode(struct inode *inode); ino_t v9fs_qid2ino(struct p9_qid *qid); void 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 cde57a850adb..e0f20de6aa2b 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -59,7 +59,7 @@ static const struct inode_operations v9fs_symlink_inode_operations; * */ -static u32 unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) +static u32 unixmode2p9mode(struct v9fs_session_info *v9ses, umode_t mode) { int res; res = mode & 0777; @@ -94,11 +94,11 @@ static u32 unixmode2p9mode(struct v9fs_session_info *v9ses, int mode) * @rdev: major number, minor number in case of device files. * */ -static int p9mode2unixmode(struct v9fs_session_info *v9ses, - struct p9_wstat *stat, dev_t *rdev) +static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses, + struct p9_wstat *stat, dev_t *rdev) { int res; - int mode = stat->mode; + u32 mode = stat->mode; res = mode & S_IALLUGO; *rdev = 0; @@ -255,7 +255,7 @@ void v9fs_destroy_inode(struct inode *inode) } int v9fs_init_inode(struct v9fs_session_info *v9ses, - struct inode *inode, int mode, dev_t rdev) + struct inode *inode, umode_t mode, dev_t rdev) { int err = 0; @@ -329,7 +329,7 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses, break; default: - P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n", + P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%hx S_IFMT 0x%x\n", mode, mode & S_IFMT); err = -EINVAL; goto error; @@ -346,13 +346,13 @@ error: * */ -struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t rdev) +struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev) { int err; struct inode *inode; struct v9fs_session_info *v9ses = sb->s_fs_info; - P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); + P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %ho\n", sb, mode); inode = new_inode(sb); if (!inode) { @@ -486,7 +486,8 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, int new) { dev_t rdev; - int retval, umode; + int retval; + umode_t umode; unsigned long i_ino; struct inode *inode; struct v9fs_session_info *v9ses = sb->s_fs_info; @@ -1125,7 +1126,7 @@ void v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, struct super_block *sb) { - mode_t mode; + umode_t mode; char ext[32]; char tag_name[14]; unsigned int i_nlink; diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 259f0cd248c8..8ef152ac6a16 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -594,7 +594,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr) void v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode) { - mode_t mode; + umode_t mode; struct v9fs_inode *v9inode = V9FS_I(inode); if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) { 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, struct inode *inode = NULL; struct dentry *root = NULL; struct v9fs_session_info *v9ses = NULL; - int mode = S_IRWXUGO | S_ISVTX; + umode_t mode = S_IRWXUGO | S_ISVTX; struct p9_fid *fid; int retval = 0; From 2b15ad068418a91687c2d5819c6c03c227d391f2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 13:43:19 -0400 Subject: [PATCH 055/165] dlmfs: use inode_init_owner() don't open-code it... Signed-off-by: Al Viro --- fs/ocfs2/dlmfs/dlmfs.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index ccb33289c29a..9e1090b8dd3b 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -407,9 +407,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb) ip = DLMFS_I(inode); inode->i_ino = get_next_ino(); - inode->i_mode = mode; - inode->i_uid = current_fsuid(); - inode->i_gid = current_fsgid(); + inode_init_owner(inode, NULL, mode); inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inc_nlink(inode); @@ -433,9 +431,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent, return NULL; inode->i_ino = get_next_ino(); - inode->i_mode = mode; - inode->i_uid = current_fsuid(); - inode->i_gid = current_fsgid(); + inode_init_owner(inode, parent, mode); inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; @@ -472,13 +468,6 @@ static struct inode *dlmfs_get_inode(struct inode *parent, inc_nlink(inode); break; } - - if (parent->i_mode & S_ISGID) { - inode->i_gid = parent->i_gid; - if (S_ISDIR(mode)) - inode->i_mode |= S_ISGID; - } - return inode; } From 67697cbdccb8b63eae892a9437bcc79d08b79578 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 02:55:32 -0400 Subject: [PATCH 056/165] ocfs2: propagate umode_t Signed-off-by: Al Viro --- fs/ocfs2/dlmfs/dlmfs.c | 4 ++-- fs/ocfs2/namei.c | 2 +- fs/ocfs2/xattr.c | 2 +- fs/ocfs2/xattr.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 9e1090b8dd3b..abfac0d7ae9c 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -400,7 +400,7 @@ static struct backing_dev_info dlmfs_backing_dev_info = { static struct inode *dlmfs_get_root_inode(struct super_block *sb) { struct inode *inode = new_inode(sb); - int mode = S_IFDIR | 0755; + umode_t mode = S_IFDIR | 0755; struct dlmfs_inode_private *ip; if (inode) { @@ -421,7 +421,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb) static struct inode *dlmfs_get_inode(struct inode *parent, struct dentry *dentry, - int mode) + umode_t mode) { struct super_block *sb = parent->i_sb; struct inode * inode = new_inode(sb); diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 11c62e20054c..be244692550d 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -185,7 +185,7 @@ bail: return ret; } -static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode) +static struct inode *ocfs2_get_init_inode(struct inode *dir, umode_t mode) { struct inode *inode; 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, int ocfs2_calc_xattr_init(struct inode *dir, struct buffer_head *dir_bh, - int mode, + umode_t mode, struct ocfs2_security_xattr_info *si, int *want_clusters, 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 *, struct ocfs2_security_xattr_info *, int *, int *, struct ocfs2_alloc_context **); int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *, - int, struct ocfs2_security_xattr_info *, + umode_t, struct ocfs2_security_xattr_info *, int *, int *, int *); /* From fec0ebaed9ed074392551ea7324c6668f7d527fd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 23:30:19 -0400 Subject: [PATCH 057/165] hypfs: umode_t noise and properly spelled S_ISDIR/S_ISREG Signed-off-by: Al Viro --- arch/s390/hypfs/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 481f4f76f664..98efd2d6207a 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c @@ -97,7 +97,7 @@ static void hypfs_delete_tree(struct dentry *root) } } -static struct inode *hypfs_make_inode(struct super_block *sb, int mode) +static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode) { struct inode *ret = new_inode(sb); @@ -107,7 +107,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, int mode) ret->i_uid = hypfs_info->uid; ret->i_gid = hypfs_info->gid; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; - if (mode & S_IFDIR) + if (S_ISDIR(mode)) set_nlink(ret, 2); } return ret; @@ -333,7 +333,7 @@ static void hypfs_kill_super(struct super_block *sb) static struct dentry *hypfs_create_file(struct super_block *sb, struct dentry *parent, const char *name, - char *data, mode_t mode) + char *data, umode_t mode) { struct dentry *dentry; struct inode *inode; @@ -350,13 +350,13 @@ static struct dentry *hypfs_create_file(struct super_block *sb, dentry = ERR_PTR(-ENOMEM); goto fail; } - if (mode & S_IFREG) { + if (S_ISREG(mode)) { inode->i_fop = &hypfs_file_ops; if (data) inode->i_size = strlen(data); else inode->i_size = 0; - } else if (mode & S_IFDIR) { + } else if (S_ISDIR(mode)) { inode->i_op = &simple_dir_inode_operations; inode->i_fop = &simple_dir_operations; inc_nlink(parent->d_inode); From 5b91aca0bd462c80cf509cbc1014f803eabdc205 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 23:36:12 -0400 Subject: [PATCH 058/165] usbfs: propagate umode_t Signed-off-by: Al Viro --- drivers/usb/core/inode.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 783fde7f44c8..2b60af2ce3ba 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c @@ -270,15 +270,13 @@ static int remount(struct super_block *sb, int *flags, char *data) return 0; } -static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t dev) +static struct inode *usbfs_get_inode (struct super_block *sb, umode_t mode, dev_t dev) { struct inode *inode = new_inode(sb); if (inode) { inode->i_ino = get_next_ino(); - inode->i_mode = mode; - inode->i_uid = current_fsuid(); - inode->i_gid = current_fsgid(); + inode_init_owner(inode, NULL, mode); inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; switch (mode & S_IFMT) { default: @@ -300,7 +298,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de } /* SMP-safe */ -static int usbfs_mknod (struct inode *dir, struct dentry *dentry, int mode, +static int usbfs_mknod (struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { struct inode *inode = usbfs_get_inode(dir->i_sb, mode, dev); @@ -317,7 +315,7 @@ static int usbfs_mknod (struct inode *dir, struct dentry *dentry, int mode, return error; } -static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) +static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, umode_t mode) { int res; @@ -328,7 +326,7 @@ static int usbfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) return res; } -static int usbfs_create (struct inode *dir, struct dentry *dentry, int mode) +static int usbfs_create (struct inode *dir, struct dentry *dentry, umode_t mode) { mode = (mode & S_IALLUGO) | S_IFREG; return usbfs_mknod (dir, dentry, mode, 0); @@ -489,7 +487,7 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent) * * This function handles both regular files and directories. */ -static int fs_create_by_name (const char *name, mode_t mode, +static int fs_create_by_name (const char *name, umode_t mode, struct dentry *parent, struct dentry **dentry) { int error = 0; @@ -513,7 +511,7 @@ static int fs_create_by_name (const char *name, mode_t mode, mutex_lock(&parent->d_inode->i_mutex); *dentry = lookup_one_len(name, parent, strlen(name)); if (!IS_ERR(*dentry)) { - if ((mode & S_IFMT) == S_IFDIR) + if (S_ISDIR(mode)) error = usbfs_mkdir (parent->d_inode, *dentry, mode); else error = usbfs_create (parent->d_inode, *dentry, mode); @@ -524,7 +522,7 @@ static int fs_create_by_name (const char *name, mode_t mode, return error; } -static struct dentry *fs_create_file (const char *name, mode_t mode, +static struct dentry *fs_create_file (const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops, uid_t uid, gid_t gid) From faef2b6c9960b5ae288899f461a2218ec6bb7928 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 23:44:53 -0400 Subject: [PATCH 059/165] sysfs: propagate umode_t Signed-off-by: Al Viro --- Documentation/filesystems/sysfs.txt | 2 +- fs/sysfs/file.c | 2 +- fs/sysfs/inode.c | 2 +- fs/sysfs/sysfs.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt index 07235caec22c..a6619b7064b9 100644 --- a/Documentation/filesystems/sysfs.txt +++ b/Documentation/filesystems/sysfs.txt @@ -70,7 +70,7 @@ An attribute definition is simply: struct attribute { char * name; struct module *owner; - mode_t mode; + umode_t mode; }; diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 120c3adff6b0..62f4fb37789e 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -518,7 +518,7 @@ out: } int sysfs_add_file_mode(struct sysfs_dirent *dir_sd, - const struct attribute *attr, int type, mode_t amode) + const struct attribute *attr, int type, umode_t amode) { umode_t mode = (amode & S_IALLUGO) | S_IFREG; struct sysfs_addrm_cxt acxt; 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: return error; } -static inline void set_default_inode_attr(struct inode * inode, mode_t mode) +static inline void set_default_inode_attr(struct inode * inode, umode_t mode) { inode->i_mode = mode; 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 { }; unsigned int s_flags; - unsigned short s_mode; + umode_t s_mode; ino_t s_ino; struct sysfs_inode_attrs *s_iattr; }; @@ -229,7 +229,7 @@ int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr, int type); int sysfs_add_file_mode(struct sysfs_dirent *dir_sd, - const struct attribute *attr, int type, mode_t amode); + const struct attribute *attr, int type, umode_t amode); /* * bin.c */ From f9ec80061af2116e9b6298a6334a6f288d7ea878 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 23:27:00 -0400 Subject: [PATCH 060/165] infiniband: umode_t noise, including open-coded S_ISDIR() Signed-off-by: Al Viro --- drivers/infiniband/hw/ipath/ipath_fs.c | 6 +++--- drivers/infiniband/hw/qib/qib_fs.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c index 31ae1b108aea..b7d4216db3c3 100644 --- a/drivers/infiniband/hw/ipath/ipath_fs.c +++ b/drivers/infiniband/hw/ipath/ipath_fs.c @@ -46,7 +46,7 @@ static struct super_block *ipath_super; static int ipathfs_mknod(struct inode *dir, struct dentry *dentry, - int mode, const struct file_operations *fops, + umode_t mode, const struct file_operations *fops, void *data) { int error; @@ -61,7 +61,7 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry, inode->i_mode = mode; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_private = data; - if ((mode & S_IFMT) == S_IFDIR) { + if (S_ISDIR(mode)) { inode->i_op = &simple_dir_inode_operations; inc_nlink(inode); inc_nlink(dir); @@ -76,7 +76,7 @@ bail: return error; } -static int create_file(const char *name, mode_t mode, +static int create_file(const char *name, umode_t mode, struct dentry *parent, struct dentry **dentry, const struct file_operations *fops, void *data) { diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c index df7fa251dcdc..05e0f17c5b44 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c @@ -47,7 +47,7 @@ static struct super_block *qib_super; #define private2dd(file) ((file)->f_dentry->d_inode->i_private) static int qibfs_mknod(struct inode *dir, struct dentry *dentry, - int mode, const struct file_operations *fops, + umode_t mode, const struct file_operations *fops, void *data) { int error; @@ -67,7 +67,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry, inode->i_mtime = inode->i_atime; inode->i_ctime = inode->i_atime; inode->i_private = data; - if ((mode & S_IFMT) == S_IFDIR) { + if (S_ISDIR(mode)) { inode->i_op = &simple_dir_inode_operations; inc_nlink(inode); inc_nlink(dir); @@ -82,7 +82,7 @@ bail: return error; } -static int create_file(const char *name, mode_t mode, +static int create_file(const char *name, umode_t mode, struct dentry *parent, struct dentry **dentry, const struct file_operations *fops, void *data) { From a5e7ed3287e45f2eafbcf9e7e6fdc5a0191acf40 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 01:55:55 -0400 Subject: [PATCH 061/165] cgroup: propagate mode_t Signed-off-by: Al Viro --- include/linux/cgroup.h | 2 +- kernel/cgroup.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 1b7f9d525013..a17becc36ca1 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -319,7 +319,7 @@ struct cftype { * If not 0, file mode is set to this value, otherwise it will * be figured out automatically */ - mode_t mode; + umode_t mode; /* * If non-zero, defines the maximum length of string that can diff --git a/kernel/cgroup.c b/kernel/cgroup.c index b37a0ea55114..86ebacfd9431 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -775,7 +775,7 @@ static struct backing_dev_info cgroup_backing_dev_info = { static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent, struct cgroup *child); -static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb) +static struct inode *cgroup_new_inode(umode_t mode, struct super_block *sb) { struct inode *inode = new_inode(sb); @@ -2585,7 +2585,7 @@ static inline struct cftype *__file_cft(struct file *file) return __d_cft(file->f_dentry); } -static int cgroup_create_file(struct dentry *dentry, mode_t mode, +static int cgroup_create_file(struct dentry *dentry, umode_t mode, struct super_block *sb) { struct inode *inode; @@ -2626,7 +2626,7 @@ static int cgroup_create_file(struct dentry *dentry, mode_t mode, * @mode: mode to set on new directory. */ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry, - mode_t mode) + umode_t mode) { struct dentry *parent; int error = 0; @@ -2653,9 +2653,9 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry, * returns S_IRUGO if it has only a read handler * returns S_IWUSR if it has only a write hander */ -static mode_t cgroup_file_mode(const struct cftype *cft) +static umode_t cgroup_file_mode(const struct cftype *cft) { - mode_t mode = 0; + umode_t mode = 0; if (cft->mode) return cft->mode; @@ -2678,7 +2678,7 @@ int cgroup_add_file(struct cgroup *cgrp, struct dentry *dir = cgrp->dentry; struct dentry *dentry; int error; - mode_t mode; + umode_t mode; char name[MAX_CGROUP_TYPE_NAMELEN + MAX_CFTYPE_NAME + 2] = { 0 }; if (subsys && !test_bit(ROOT_NOPREFIX, &cgrp->root->flags)) { @@ -3752,7 +3752,7 @@ static void cgroup_unlock_hierarchy(struct cgroupfs_root *root) * Must be called with the mutex on the parent inode held */ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, - mode_t mode) + umode_t mode) { struct cgroup *cgrp; struct cgroupfs_root *root = parent->root; From a760b03dc0ac4c9663577ca45de5e0fe1c35dc13 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:04:30 -0400 Subject: [PATCH 062/165] affs: propagate umode_t Signed-off-by: Al Viro --- fs/affs/affs.h | 2 +- fs/affs/amigaffs.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 9cad9b4a9af7..45a0ce45d7b4 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -136,7 +136,7 @@ extern int affs_remove_header(struct dentry *dentry); extern u32 affs_checksum_block(struct super_block *sb, struct buffer_head *bh); extern void affs_fix_checksum(struct super_block *sb, struct buffer_head *bh); extern void secs_to_datestamp(time_t secs, struct affs_date *ds); -extern mode_t prot_to_mode(u32 prot); +extern umode_t prot_to_mode(u32 prot); extern void mode_to_prot(struct inode *inode); extern void affs_error(struct super_block *sb, const char *function, const char *fmt, ...); extern void affs_warning(struct super_block *sb, const char *function, const char *fmt, ...); 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) ds->ticks = cpu_to_be32(secs * 50); } -mode_t +umode_t prot_to_mode(u32 prot) { - int mode = 0; + umode_t mode = 0; if (!(prot & FIBF_NOWRITE)) mode |= S_IWUSR; @@ -421,7 +421,7 @@ void mode_to_prot(struct inode *inode) { u32 prot = AFFS_I(inode)->i_protect; - mode_t mode = inode->i_mode; + umode_t mode = inode->i_mode; if (!(mode & S_IXUSR)) prot |= FIBF_NOEXECUTE; From 64f1426f3c4f8dde9ac9bf3f3b19b88d17f2bae6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 25 Jul 2011 00:35:13 -0400 Subject: [PATCH 063/165] sunrpc: propagate umode_t Signed-off-by: Al Viro --- include/linux/sunrpc/cache.h | 2 +- include/linux/sunrpc/rpc_pipe_fs.h | 2 +- net/sunrpc/cache.c | 2 +- net/sunrpc/rpc_pipe.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 5efd8cef389e..57531f8e5956 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h @@ -203,7 +203,7 @@ extern void cache_unregister(struct cache_detail *cd); extern void cache_unregister_net(struct cache_detail *cd, struct net *net); extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, - mode_t, struct cache_detail *); + umode_t, struct cache_detail *); extern void sunrpc_cache_unregister_pipefs(struct cache_detail *); extern void qword_add(char **bpp, int *lp, char *str); diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h index e4ea43058d8f..2bb03d77375a 100644 --- a/include/linux/sunrpc/rpc_pipe_fs.h +++ b/include/linux/sunrpc/rpc_pipe_fs.h @@ -55,7 +55,7 @@ extern int rpc_remove_client_dir(struct dentry *); struct cache_detail; extern struct dentry *rpc_create_cache_dir(struct dentry *, struct qstr *, - mode_t umode, + umode_t umode, struct cache_detail *); extern void rpc_remove_cache_dir(struct dentry *); diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 72ad836e4fe0..03b56bc3b659 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1778,7 +1778,7 @@ const struct file_operations cache_flush_operations_pipefs = { }; int sunrpc_cache_register_pipefs(struct dentry *parent, - const char *name, mode_t umode, + const char *name, umode_t umode, struct cache_detail *cd) { struct qstr q; diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 60564bcb8067..63a7a7add21e 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -953,7 +953,7 @@ static void rpc_cachedir_depopulate(struct dentry *dentry) } struct dentry *rpc_create_cache_dir(struct dentry *parent, struct qstr *name, - mode_t umode, struct cache_detail *cd) + umode_t umode, struct cache_detail *cd) { return rpc_mkdir_populate(parent, name, umode, NULL, rpc_cachedir_populate, cd); From c6e49e3f266dbe62773941dca8afa65f53b5415f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:07:14 -0400 Subject: [PATCH 064/165] nilfs: propagate umode_t Signed-off-by: Al Viro --- fs/nilfs2/dir.c | 2 +- fs/nilfs2/inode.c | 2 +- fs/nilfs2/nilfs.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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] = { static void nilfs_set_de_type(struct nilfs_dir_entry *de, struct inode *inode) { - mode_t mode = inode->i_mode; + umode_t mode = inode->i_mode; de->file_type = nilfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; } 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 = { .is_partially_uptodate = block_is_partially_uptodate, }; -struct inode *nilfs_new_inode(struct inode *dir, int mode) +struct inode *nilfs_new_inode(struct inode *dir, umode_t mode) { struct super_block *sb = dir->i_sb; struct the_nilfs *nilfs = sb->s_fs_info; 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 *, /* inode.c */ void nilfs_inode_add_blocks(struct inode *inode, int n); void nilfs_inode_sub_blocks(struct inode *inode, int n); -extern struct inode *nilfs_new_inode(struct inode *, int); +extern struct inode *nilfs_new_inode(struct inode *, umode_t); extern void nilfs_free_inode(struct inode *); extern int nilfs_get_block(struct inode *, sector_t, struct buffer_head *, int); extern void nilfs_set_inode_flags(struct inode *); From bef41c267e2b903f411c0f56236027f68553b721 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:07:49 -0400 Subject: [PATCH 065/165] exofs: propagate umode_t Signed-off-by: Al Viro --- fs/exofs/dir.c | 2 +- fs/exofs/exofs.h | 2 +- fs/exofs/inode.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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] = { static inline void exofs_set_de_type(struct exofs_dir_entry *de, struct inode *inode) { - mode_t mode = inode->i_mode; + umode_t mode = inode->i_mode; de->file_type = exofs_type_by_mode[(mode & S_IFMT) >> S_SHIFT]; } 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, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata); extern struct inode *exofs_iget(struct super_block *, unsigned long); -struct inode *exofs_new_inode(struct inode *, int); +struct inode *exofs_new_inode(struct inode *, umode_t); extern int exofs_write_inode(struct inode *, struct writeback_control *wbc); extern void exofs_evict_inode(struct inode *); 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) /* * Set up a new inode and create an object for it on the OSD */ -struct inode *exofs_new_inode(struct inode *dir, int mode) +struct inode *exofs_new_inode(struct inode *dir, umode_t mode) { struct super_block *sb = dir->i_sb; struct exofs_sb_info *sbi = sb->s_fs_info; From 18df22524202ebd3416f391393e5aa986a31dc9d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 23:17:40 -0400 Subject: [PATCH 066/165] hugetlbfs: propagate umode_t Signed-off-by: Al Viro --- fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index aa93f9532607..e425ad9d0490 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -472,7 +472,7 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb, static struct inode *hugetlbfs_get_inode(struct super_block *sb, struct inode *dir, - int mode, dev_t dev) + umode_t mode, dev_t dev) { struct inode *inode; From 5eee25cacde61c37f1545a33d7fed88b14349976 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:12:16 -0400 Subject: [PATCH 067/165] ncpfs: propagate umode_t Signed-off-by: Al Viro --- fs/ncpfs/dir.c | 4 ++-- fs/ncpfs/ncplib_kernel.h | 2 +- fs/ncpfs/symlink.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index a2d50f803a17..aeed93a6bde0 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c @@ -919,7 +919,7 @@ out_close: goto out; } -int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode, +int ncp_create_new(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev, __le32 attributes) { struct ncp_server *server = NCP_SERVER(dir); @@ -928,7 +928,7 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode, int opmode; __u8 __name[NCP_MAXPATHLEN + 1]; - PPRINTK("ncp_create_new: creating %s/%s, mode=%x\n", + PPRINTK("ncp_create_new: creating %s/%s, mode=%hx\n", dentry->d_parent->d_name.name, dentry->d_name.name, mode); ncp_age_dentry(server, dentry); 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 int ncp_dirhandle_free(struct ncp_server *, __u8 dirhandle); int ncp_create_new(struct inode *dir, struct dentry *dentry, - int mode, dev_t rdev, __le32 attributes); + umode_t mode, dev_t rdev, __le32 attributes); static inline int ncp_is_nfs_extras(struct ncp_server* server, unsigned int volnum) { #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) { char *rawlink; int length, err, i, outlen; int kludge; - int mode; + umode_t mode; __le32 attr; unsigned int hdr; From ad44be5c7820f5b8ce97292f4bcb3de73625c35b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:12:59 -0400 Subject: [PATCH 068/165] ubifs: propagate umode_t Signed-off-by: Al Viro --- fs/ubifs/dir.c | 4 ++-- fs/ubifs/ubifs.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index d9aec2fc90a6..d6fe1c79f18b 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -56,7 +56,7 @@ * * This function returns the inherited flags. */ -static int inherit_flags(const struct inode *dir, int mode) +static int inherit_flags(const struct inode *dir, umode_t mode) { int flags; const struct ubifs_inode *ui = ubifs_inode(dir); @@ -86,7 +86,7 @@ static int inherit_flags(const struct inode *dir, int mode) * case of failure. */ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, - int mode) + umode_t mode) { struct inode *inode; struct ubifs_inode *ui; 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); /* dir.c */ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, - int mode); + umode_t mode); int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); From 881764461165d69814194b6fe97d4352bbd0ae82 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:13:21 -0400 Subject: [PATCH 069/165] logfs: propagate umode_t Signed-off-by: Al Viro --- fs/logfs/inode.c | 2 +- fs/logfs/logfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/logfs/inode.c b/fs/logfs/inode.c index 4d1af42bfd24..388df1aa35e5 100644 --- a/fs/logfs/inode.c +++ b/fs/logfs/inode.c @@ -323,7 +323,7 @@ static void logfs_set_ino_generation(struct super_block *sb, mutex_unlock(&super->s_journal_mutex); } -struct inode *logfs_new_inode(struct inode *dir, int mode) +struct inode *logfs_new_inode(struct inode *dir, umode_t mode) { struct super_block *sb = dir->i_sb; 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; struct inode *logfs_iget(struct super_block *sb, ino_t ino); struct inode *logfs_safe_iget(struct super_block *sb, ino_t ino, int *cookie); void logfs_safe_iput(struct inode *inode, int cookie); -struct inode *logfs_new_inode(struct inode *dir, int mode); +struct inode *logfs_new_inode(struct inode *dir, umode_t mode); struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino); struct inode *logfs_read_meta_inode(struct super_block *sb, u64 ino); int logfs_init_inode_cache(void); From 09208d150b5cda009b666238a7102cb45ecec2ee Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:15:03 -0400 Subject: [PATCH 070/165] shmem, ramfs: propagate umode_t, open-coded S_ISREG Signed-off-by: Al Viro --- include/linux/shmem_fs.h | 2 +- mm/shmem.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index 9291ac3cc627..e4c711c6f321 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -30,7 +30,7 @@ struct shmem_sb_info { spinlock_t stat_lock; /* Serialize shmem_sb_info changes */ uid_t uid; /* Mount uid for root directory */ gid_t gid; /* Mount gid for root directory */ - mode_t mode; /* Mount mode for root directory */ + umode_t mode; /* Mount mode for root directory */ struct mempolicy *mpol; /* default memory policy for mappings */ }; diff --git a/mm/shmem.c b/mm/shmem.c index 4000f370948c..86a19efc36fb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1092,7 +1092,7 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma) } static struct inode *shmem_get_inode(struct super_block *sb, const struct inode *dir, - int mode, dev_t dev, unsigned long flags) + umode_t mode, dev_t dev, unsigned long flags) { struct inode *inode; struct shmem_inode_info *info; @@ -2128,7 +2128,7 @@ static int shmem_show_options(struct seq_file *seq, struct vfsmount *vfs) if (sbinfo->max_inodes != shmem_default_max_inodes()) seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes); if (sbinfo->mode != (S_IRWXUGO | S_ISVTX)) - seq_printf(seq, ",mode=%03o", sbinfo->mode); + seq_printf(seq, ",mode=%03ho", sbinfo->mode); if (sbinfo->uid != 0) seq_printf(seq, ",uid=%u", sbinfo->uid); if (sbinfo->gid != 0) @@ -2239,7 +2239,7 @@ static void shmem_destroy_callback(struct rcu_head *head) static void shmem_destroy_inode(struct inode *inode) { - if ((inode->i_mode & S_IFMT) == S_IFREG) + if (S_ISREG(inode->i_mode)) mpol_free_shared_policy(&SHMEM_I(inode)->policy); call_rcu(&inode->i_rcu, shmem_destroy_callback); } From 632861f05a8e5878a267d173000880ceb608b56e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:16:55 -0400 Subject: [PATCH 071/165] pohmelfs: propagate umode_t Signed-off-by: Al Viro --- drivers/staging/pohmelfs/dir.c | 7 ++++--- drivers/staging/pohmelfs/netfs.h | 2 +- fs/ramfs/inode.c | 2 +- include/linux/ramfs.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/pohmelfs/dir.c b/drivers/staging/pohmelfs/dir.c index c33e959b6efe..2ee4491b7136 100644 --- a/drivers/staging/pohmelfs/dir.c +++ b/drivers/staging/pohmelfs/dir.c @@ -590,13 +590,13 @@ out: * during writeback for given inode. */ struct pohmelfs_inode *pohmelfs_create_entry_local(struct pohmelfs_sb *psb, - struct pohmelfs_inode *parent, struct qstr *str, u64 start, int mode) + struct pohmelfs_inode *parent, struct qstr *str, u64 start, umode_t mode) { struct pohmelfs_inode *npi; int err = -ENOMEM; struct netfs_inode_info info; - dprintk("%s: name: '%s', mode: %o, start: %llu.\n", + dprintk("%s: name: '%s', mode: %ho, start: %llu.\n", __func__, str->name, mode, start); info.mode = mode; @@ -630,7 +630,8 @@ err_out_unlock: /* * Create local object and bind it to dentry. */ -static int pohmelfs_create_entry(struct inode *dir, struct dentry *dentry, u64 start, int mode) +static int pohmelfs_create_entry(struct inode *dir, struct dentry *dentry, + u64 start, umode_t mode) { struct pohmelfs_sb *psb = POHMELFS_SB(dir->i_sb); struct pohmelfs_inode *npi, *parent; diff --git a/drivers/staging/pohmelfs/netfs.h b/drivers/staging/pohmelfs/netfs.h index 985b6b755d5d..f26894f2a57f 100644 --- a/drivers/staging/pohmelfs/netfs.h +++ b/drivers/staging/pohmelfs/netfs.h @@ -776,7 +776,7 @@ struct pohmelfs_name *pohmelfs_search_hash(struct pohmelfs_inode *pi, u32 hash); void pohmelfs_inode_del_inode(struct pohmelfs_sb *psb, struct pohmelfs_inode *pi); struct pohmelfs_inode *pohmelfs_create_entry_local(struct pohmelfs_sb *psb, - struct pohmelfs_inode *parent, struct qstr *str, u64 start, int mode); + struct pohmelfs_inode *parent, struct qstr *str, u64 start, umode_t mode); int pohmelfs_write_create_inode(struct pohmelfs_inode *pi); diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index 145680e9d581..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 = { }; struct inode *ramfs_get_inode(struct super_block *sb, - const struct inode *dir, int mode, dev_t dev) + const struct inode *dir, umode_t mode, dev_t dev) { struct inode * inode = new_inode(sb); diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h index 3a8f0c9b2933..5bf5500db83d 100644 --- a/include/linux/ramfs.h +++ b/include/linux/ramfs.h @@ -2,7 +2,7 @@ #define _LINUX_RAMFS_H struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir, - int mode, dev_t dev); + umode_t mode, dev_t dev); extern struct dentry *ramfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data); From 541af6a07474352e2143a0527c2b62b732439815 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:17:33 -0400 Subject: [PATCH 072/165] fuse: propagate umode_t Signed-off-by: Al Viro --- fs/fuse/dir.c | 6 +++--- fs/fuse/fuse_i.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index b4c09c5ed8dc..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, * If the filesystem doesn't support this, then fall back to separate * 'mknod' + 'open' requests. */ -static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, - struct nameidata *nd) +static int fuse_create_open(struct inode *dir, struct dentry *entry, + umode_t mode, struct nameidata *nd) { int err; struct inode *inode; @@ -480,7 +480,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, */ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, struct inode *dir, struct dentry *entry, - int mode) + umode_t mode) { struct fuse_entry_out outarg; struct inode *inode; 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 { /** The sticky bit in inode->i_mode may have been removed, so preserve the original mode */ - mode_t orig_i_mode; + umode_t orig_i_mode; /** Version of last attribute change */ u64 attr_version; From faa17292fd3a5a80345511ea341a59ac40ab59dc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:18:29 -0400 Subject: [PATCH 073/165] udf: propagate umode_t note re mount options: fmask and dmask are explicitly truncated to 12bit, UDF_INVALID_MODE just needs to be guaranteed to differ from any such value. And umask is used only in &= with umode_t, so we ignore other bits anyway. Signed-off-by: Al Viro --- fs/udf/ialloc.c | 2 +- fs/udf/inode.c | 6 +++--- fs/udf/super.c | 12 ++++++------ fs/udf/udf_sb.h | 8 ++++---- fs/udf/udfdecl.h | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) 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) udf_free_blocks(sb, NULL, &UDF_I(inode)->i_location, 0, 1); } -struct inode *udf_new_inode(struct inode *dir, int mode, int *err) +struct inode *udf_new_inode(struct inode *dir, umode_t mode, int *err) { struct super_block *sb = dir->i_sb; 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"); #define EXTENT_MERGE_SIZE 5 -static mode_t udf_convert_permissions(struct fileEntry *); +static umode_t udf_convert_permissions(struct fileEntry *); static int udf_update_inode(struct inode *, int); static void udf_fill_inode(struct inode *, struct buffer_head *); static int udf_sync_inode(struct inode *inode); @@ -1452,9 +1452,9 @@ static int udf_alloc_i_data(struct inode *inode, size_t size) return 0; } -static mode_t udf_convert_permissions(struct fileEntry *fe) +static umode_t udf_convert_permissions(struct fileEntry *fe) { - mode_t mode; + umode_t mode; uint32_t permissions; uint32_t flags; diff --git a/fs/udf/super.c b/fs/udf/super.c index 7cbe669e1026..c94fc889a486 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -195,11 +195,11 @@ struct udf_options { unsigned int fileset; unsigned int rootdir; unsigned int flags; - mode_t umask; + umode_t umask; gid_t gid; uid_t uid; - mode_t fmode; - mode_t dmode; + umode_t fmode; + umode_t dmode; struct nls_table *nls_map; }; @@ -279,11 +279,11 @@ static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt) if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET)) seq_printf(seq, ",gid=%u", sbi->s_gid); if (sbi->s_umask != 0) - seq_printf(seq, ",umask=%o", sbi->s_umask); + seq_printf(seq, ",umask=%ho", sbi->s_umask); if (sbi->s_fmode != UDF_INVALID_MODE) - seq_printf(seq, ",mode=%o", sbi->s_fmode); + seq_printf(seq, ",mode=%ho", sbi->s_fmode); if (sbi->s_dmode != UDF_INVALID_MODE) - seq_printf(seq, ",dmode=%o", sbi->s_dmode); + seq_printf(seq, ",dmode=%ho", sbi->s_dmode); if (UDF_QUERY_FLAG(sb, UDF_FLAG_SESSION_SET)) seq_printf(seq, ",session=%u", sbi->s_session); 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 @@ #define UDF_SPARABLE_MAP15 0x1522U #define UDF_METADATA_MAP25 0x2511U -#define UDF_INVALID_MODE ((mode_t)-1) +#define UDF_INVALID_MODE ((umode_t)-1) #pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */ @@ -127,11 +127,11 @@ struct udf_sb_info { struct buffer_head *s_lvid_bh; /* Default permissions */ - mode_t s_umask; + umode_t s_umask; gid_t s_gid; uid_t s_uid; - mode_t s_fmode; - mode_t s_dmode; + umode_t s_fmode; + umode_t s_dmode; /* Lock protecting consistency of above permission settings */ rwlock_t s_cred_lock; 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 *); /* ialloc.c */ extern void udf_free_inode(struct inode *); -extern struct inode *udf_new_inode(struct inode *, int, int *); +extern struct inode *udf_new_inode(struct inode *, umode_t, int *); /* truncate.c */ extern void udf_truncate_tail_extent(struct inode *); From 7328bdd6cf5e032a2c54e4b1cf555ff769af08e7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:19:52 -0400 Subject: [PATCH 074/165] isofs: propagate umode_t situation with mount options is the same as for udf Signed-off-by: Al Viro --- fs/isofs/inode.c | 4 ++-- fs/isofs/isofs.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index b71f6311a337..7b99f5f460be 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -169,8 +169,8 @@ struct iso9660_options{ unsigned char map; unsigned char check; unsigned int blocksize; - mode_t fmode; - mode_t dmode; + umode_t fmode; + umode_t dmode; gid_t gid; uid_t uid; 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 { unsigned int s_uid_set:1; unsigned int s_gid_set:1; - mode_t s_fmode; - mode_t s_dmode; + umode_t s_fmode; + umode_t s_dmode; gid_t s_gid; uid_t s_uid; struct nls_table *s_nls_iocharset; /* Native language support table */ }; -#define ISOFS_INVALID_MODE ((mode_t) -1) +#define ISOFS_INVALID_MODE ((umode_t) -1) static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb) { From d0c00d0671fbbaf6c5e192544de551a6ea5c8833 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:20:46 -0400 Subject: [PATCH 075/165] ntfs: propagate umode_t same story as with isofs and udf... Signed-off-by: Al Viro --- fs/ntfs/super.c | 6 +++--- fs/ntfs/volume.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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) int errors = 0, sloppy = 0; uid_t uid = (uid_t)-1; gid_t gid = (gid_t)-1; - mode_t fmask = (mode_t)-1, dmask = (mode_t)-1; + umode_t fmask = (umode_t)-1, dmask = (umode_t)-1; int mft_zone_multiplier = -1, on_errors = -1; int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1; struct nls_table *nls_map = NULL, *old_nls; @@ -287,9 +287,9 @@ no_mount_options: vol->uid = uid; if (gid != (gid_t)-1) vol->gid = gid; - if (fmask != (mode_t)-1) + if (fmask != (umode_t)-1) vol->fmask = fmask; - if (dmask != (mode_t)-1) + if (dmask != (umode_t)-1) vol->dmask = dmask; if (show_sys_files != -1) { 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 { unsigned long flags; /* Miscellaneous flags, see below. */ uid_t uid; /* uid that files will be mounted as. */ gid_t gid; /* gid that files will be mounted as. */ - mode_t fmask; /* The mask for file permissions. */ - mode_t dmask; /* The mask for directory + umode_t fmask; /* The mask for file permissions. */ + umode_t dmask; /* The mask for directory permissions. */ u8 mft_zone_multiplier; /* Initial mft zone multiplier. */ u8 on_errors; /* What to do on filesystem errors. */ From dacd0e7b392dfaf888461741dbcaccf8b6a15bac Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:21:30 -0400 Subject: [PATCH 076/165] fat: propagate umode_t Signed-off-by: Al Viro --- fs/fat/fat.h | 6 +++--- fs/fat/file.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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) static inline int fat_mode_can_hold_ro(struct inode *inode) { struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); - mode_t mask; + umode_t mask; if (S_ISDIR(inode->i_mode)) { if (!sbi->options.rodir) @@ -156,8 +156,8 @@ static inline int fat_mode_can_hold_ro(struct inode *inode) } /* Convert attribute bits and a mask to the UNIX mode. */ -static inline mode_t fat_make_mode(struct msdos_sb_info *sbi, - u8 attrs, mode_t mode) +static inline umode_t fat_make_mode(struct msdos_sb_info *sbi, + u8 attrs, umode_t mode) { if (attrs & ATTR_RO && !((attrs & ATTR_DIR) && !sbi->options.rodir)) mode &= ~S_IWUGO; diff --git a/fs/fat/file.c b/fs/fat/file.c index d81d01a99b2c..a71fe3715ee8 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -314,7 +314,7 @@ EXPORT_SYMBOL_GPL(fat_getattr); static int fat_sanitize_mode(const struct msdos_sb_info *sbi, struct inode *inode, umode_t *mode_ptr) { - mode_t mask, perm; + umode_t mask, perm; /* * 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, static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode) { - mode_t allow_utime = sbi->options.allow_utime; + umode_t allow_utime = sbi->options.allow_utime; if (current_fsuid() != inode->i_uid) { if (in_group_p(inode->i_gid)) From 5206efd62ce49cf5c7940d81c22bc556fc843de2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:22:14 -0400 Subject: [PATCH 077/165] cifs: propagate umode_t Signed-off-by: Al Viro --- fs/cifs/cifs_fs_sb.h | 4 ++-- fs/cifs/cifsfs.c | 2 +- fs/cifs/cifsglob.h | 4 ++-- fs/cifs/connect.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) 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 { gid_t mnt_gid; uid_t mnt_backupuid; gid_t mnt_backupgid; - mode_t mnt_file_mode; - mode_t mnt_dir_mode; + umode_t mnt_file_mode; + umode_t mnt_dir_mode; unsigned int mnt_cifs_flags; char *mountdata; /* options received at mount time or via DFS refs */ struct backing_dev_info bdi; diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 8f1fe324162b..5bb961c13c4d 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -393,7 +393,7 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) cifs_show_address(s, tcon->ses->server); if (!tcon->unix_ext) - seq_printf(s, ",file_mode=0%o,dir_mode=0%o", + seq_printf(s, ",file_mode=0%ho,dir_mode=0%ho", cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode); if (tcon->seal) 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 { gid_t linux_gid; uid_t backupuid; gid_t backupgid; - mode_t file_mode; - mode_t dir_mode; + umode_t file_mode; + umode_t dir_mode; unsigned secFlg; bool retry:1; bool intr:1; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 8cd4b52d4217..be1e8f91c0ad 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, cifs_sb->mnt_backupgid = pvolume_info->backupgid; cifs_sb->mnt_file_mode = pvolume_info->file_mode; cifs_sb->mnt_dir_mode = pvolume_info->dir_mode; - cFYI(1, "file mode: 0x%x dir mode: 0x%x", + cFYI(1, "file mode: 0x%hx dir mode: 0x%hx", cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode); cifs_sb->actimeo = pvolume_info->actimeo; From e021d7b7fd364e0ad1b8d65af80995c72f321419 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:26:05 -0400 Subject: [PATCH 078/165] hfs: propagate umode_t Signed-off-by: Al Viro --- fs/hfs/hfs_fs.h | 2 +- fs/hfs/inode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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); extern const struct address_space_operations hfs_aops; extern const struct address_space_operations hfs_btree_aops; -extern struct inode *hfs_new_inode(struct inode *, struct qstr *, int); +extern struct inode *hfs_new_inode(struct inode *, struct qstr *, umode_t); extern void hfs_inode_write_fork(struct inode *, struct hfs_extent *, __be32 *, __be32 *); extern int hfs_write_inode(struct inode *, struct writeback_control *); extern 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 = { /* * hfs_new_inode */ -struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode) +struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, umode_t mode) { struct super_block *sb = dir->i_sb; struct inode *inode = new_inode(sb); From c47da79851d5f8629c6715e681315dd8e0a3d7d8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:26:51 -0400 Subject: [PATCH 079/165] hfsplus: propagate umode_t Signed-off-by: Al Viro --- fs/hfsplus/hfsplus_fs.h | 2 +- fs/hfsplus/inode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index d7674d051f52..3a6c025414e2 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 *); void hfsplus_inode_write_fork(struct inode *, struct hfsplus_fork_raw *); int hfsplus_cat_read_inode(struct inode *, struct hfs_find_data *); int hfsplus_cat_write_inode(struct inode *); -struct inode *hfsplus_new_inode(struct super_block *, int); +struct inode *hfsplus_new_inode(struct super_block *, umode_t); void hfsplus_delete_inode(struct inode *); int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, int datasync); 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 = { .unlocked_ioctl = hfsplus_ioctl, }; -struct inode *hfsplus_new_inode(struct super_block *sb, int mode) +struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode) { struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); struct inode *inode = new_inode(sb); From 030a8ba48fa6fa2a1304bab5b0f49360613c4af2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:29:03 -0400 Subject: [PATCH 080/165] autofs4: propagate umode_t Signed-off-by: Al Viro --- fs/autofs4/autofs_i.h | 2 +- fs/autofs4/inode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) return 0; } -struct inode *autofs4_get_inode(struct super_block *, mode_t); +struct inode *autofs4_get_inode(struct super_block *, umode_t); void autofs4_free_ino(struct autofs_info *); /* Expiration */ diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index 8179f1ab8175..f799efad52a8 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c @@ -326,7 +326,7 @@ fail_unlock: return -EINVAL; } -struct inode *autofs4_get_inode(struct super_block *sb, mode_t mode) +struct inode *autofs4_get_inode(struct super_block *sb, umode_t mode) { struct inode *inode = new_inode(sb); From 175a4eb7ea531cdbf6d574f5d5ba9aa0f5e8ed13 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:30:54 -0400 Subject: [PATCH 081/165] fs: propagate umode_t, misc bits Signed-off-by: Al Viro --- fs/btrfs/inode.c | 4 ++-- fs/cramfs/inode.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/freevxfs/vxfs_inode.c | 4 ++-- fs/gfs2/inode.c | 10 +++++----- fs/nfsd/nfsfh.c | 4 ++-- fs/nfsd/nfsfh.h | 2 +- fs/nfsd/vfs.c | 4 ++-- fs/nfsd/vfs.h | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0060875d6af6..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, struct btrfs_root *root, struct inode *dir, const char *name, int name_len, - u64 ref_objectid, u64 objectid, int mode, - u64 *index) + u64 ref_objectid, u64 objectid, + umode_t mode, u64 *index) { struct inode *inode; struct btrfs_inode_item *inode_item; diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 739fb59bcdc2..69fef5b9060c 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -378,7 +378,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir) unsigned long nextoffset; char *name; ino_t ino; - mode_t mode; + umode_t mode; int namelen, error; mutex_lock(&read_mutex); diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 13303830ec8b..19a8ca4ab1dd 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -158,7 +158,7 @@ static int ecryptfs_interpose(struct dentry *lower_dentry, */ static struct inode * ecryptfs_do_create(struct inode *directory_inode, - struct dentry *ecryptfs_dentry, int mode) + struct dentry *ecryptfs_dentry, umode_t mode) { int rc; struct dentry *lower_dentry; diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c index 41ef6e715d2f..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) * vxfs_transmod returns a Linux mode_t for a given * VxFS inode structure. */ -static __inline__ mode_t +static __inline__ umode_t vxfs_transmod(struct vxfs_inode_info *vip) { - mode_t ret = vip->vii_mode & ~VXFS_TYPE_MASK; + umode_t ret = vip->vii_mode & ~VXFS_TYPE_MASK; if (VXFS_ISFIFO(vip)) ret |= S_IFIFO; diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index ea4edf510559..4b0e59e0a249 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -333,7 +333,7 @@ out: */ static int create_ok(struct gfs2_inode *dip, const struct qstr *name, - unsigned int mode) + umode_t mode) { int error; @@ -364,7 +364,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name, return 0; } -static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode, +static void munge_mode_uid_gid(struct gfs2_inode *dip, umode_t *mode, unsigned int *uid, unsigned int *gid) { if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir && @@ -447,7 +447,7 @@ static void gfs2_init_dir(struct buffer_head *dibh, */ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, - const struct gfs2_inum_host *inum, unsigned int mode, + const struct gfs2_inum_host *inum, umode_t mode, unsigned int uid, unsigned int gid, const u64 *generation, dev_t dev, const char *symname, unsigned size, struct buffer_head **bhp) @@ -516,7 +516,7 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, } static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, - unsigned int mode, const struct gfs2_inum_host *inum, + umode_t mode, const struct gfs2_inum_host *inum, const u64 *generation, dev_t dev, const char *symname, unsigned int size, struct buffer_head **bhp) { @@ -659,7 +659,7 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip, */ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, - unsigned int mode, dev_t dev, const char *symname, + umode_t mode, dev_t dev, const char *symname, unsigned int size, int excl) { const struct qstr *name = &dentry->d_name; 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) * the write call). */ static inline __be32 -nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int requested) +nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, umode_t requested) { mode &= S_IFMT; @@ -293,7 +293,7 @@ out: * include/linux/nfsd/nfsd.h. */ __be32 -fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) +fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access) { struct svc_export *exp; 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); /* * Function prototypes */ -__be32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int); +__be32 fh_verify(struct svc_rqst *, struct svc_fh *, umode_t, int); __be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *); __be32 fh_update(struct svc_fh *); void fh_put(struct svc_fh *); diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 29b1202313e9..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, struct dentry *dentry; struct inode *inode; int accmode = NFSD_MAY_SATTR; - int ftype = 0; + umode_t ftype = 0; __be32 err; int host_err; int size_change = 0; @@ -730,7 +730,7 @@ static int nfsd_open_break_lease(struct inode *inode, int access) * N.B. After this call fhp needs an fh_put */ __be32 -nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, +nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access, struct file **filp) { struct dentry *dentry; diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index cee6a12296e8..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 *, __be32 nfsd_commit(struct svc_rqst *, struct svc_fh *, loff_t, unsigned long); #endif /* CONFIG_NFSD_V3 */ -__be32 nfsd_open(struct svc_rqst *, struct svc_fh *, int, +__be32 nfsd_open(struct svc_rqst *, struct svc_fh *, umode_t, int, struct file **); void nfsd_close(struct file *); __be32 nfsd_read(struct svc_rqst *, struct svc_fh *, From 62bb109170375f82eb3c51c8080b72954f02dca7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 23:20:18 -0400 Subject: [PATCH 082/165] switch inode_init_owner() to umode_t Signed-off-by: Al Viro --- fs/inode.c | 2 +- include/linux/fs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 24d02907e196..961355d00e38 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1646,7 +1646,7 @@ EXPORT_SYMBOL(init_special_inode); * @mode: mode of the new inode */ void inode_init_owner(struct inode *inode, const struct inode *dir, - mode_t mode) + umode_t mode) { inode->i_uid = current_fsuid(); if (dir && dir->i_mode & S_ISGID) { diff --git a/include/linux/fs.h b/include/linux/fs.h index b89eef1d1752..9db9f6e6c98b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1534,7 +1534,7 @@ extern void dentry_unhash(struct dentry *dentry); * VFS file helper functions. */ extern void inode_init_owner(struct inode *inode, const struct inode *dir, - mode_t mode); + umode_t mode); /* * VFS FS_IOC_FIEMAP helper definitions. */ From 8d334acdd2c1f57c7a574c6f24d08e4c95582ff0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 23:21:59 -0400 Subject: [PATCH 083/165] switch is_sxid() to umode_t Signed-off-by: Al Viro --- fs/attr.c | 4 ++-- include/linux/fs.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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); int notify_change(struct dentry * dentry, struct iattr * attr) { struct inode *inode = dentry->d_inode; - mode_t mode = inode->i_mode; + umode_t mode = inode->i_mode; int error; struct timespec now; unsigned int ia_valid = attr->ia_valid; @@ -177,7 +177,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr) } if ((ia_valid & ATTR_MODE)) { - mode_t amode = attr->ia_mode; + umode_t amode = attr->ia_mode; /* Flag setting protected by i_mutex */ if (is_sxid(amode)) inode->i_flags &= ~S_NOSEC; diff --git a/include/linux/fs.h b/include/linux/fs.h index 9db9f6e6c98b..9d02fab420c6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2690,7 +2690,7 @@ int __init get_filesystem_list(char *buf); #define OPEN_FMODE(flag) ((__force fmode_t)(((flag + 1) & O_ACCMODE) | \ (flag & __FMODE_NONOTIFY))) -static inline int is_sxid(mode_t mode) +static inline int is_sxid(umode_t mode) { return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP)); } From 1b9d5ff7644ddf2723c9205f4726c95ec01bf033 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 24 Jul 2011 14:18:20 -0400 Subject: [PATCH 084/165] mqueue: propagate umode_t Signed-off-by: Al Viro --- ipc/mqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 57ed704d2ca7..5eaecf4fc04e 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -108,7 +108,7 @@ static struct ipc_namespace *get_ns_from_inode(struct inode *inode) } static struct inode *mqueue_get_inode(struct super_block *sb, - struct ipc_namespace *ipc_ns, int mode, + struct ipc_namespace *ipc_ns, umode_t mode, struct mq_attr *attr) { struct user_struct *u = current_user(); From dba19c6064766730dd64757a010ec3aec503ecdb Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 25 Jul 2011 20:49:29 -0400 Subject: [PATCH 085/165] get rid of open-coded S_ISREG(), etc. Signed-off-by: Al Viro --- fs/ceph/dir.c | 2 +- security/inode.c | 2 +- security/selinux/hooks.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index f011ed295bf7..74fd74719dc2 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -870,7 +870,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry) } else if (ceph_snap(dir) == CEPH_NOSNAP) { dout("unlink/rmdir dir %p dn %p inode %p\n", dir, dentry, inode); - op = ((dentry->d_inode->i_mode & S_IFMT) == S_IFDIR) ? + op = S_ISDIR(dentry->d_inode->i_mode) ? CEPH_MDS_OP_RMDIR : CEPH_MDS_OP_UNLINK; } else goto out; diff --git a/security/inode.c b/security/inode.c index a67004f9d106..bfe02e68f92e 100644 --- a/security/inode.c +++ b/security/inode.c @@ -164,7 +164,7 @@ static int create_by_name(const char *name, mode_t mode, mutex_lock(&parent->d_inode->i_mutex); *dentry = lookup_one_len(name, parent, strlen(name)); if (!IS_ERR(*dentry)) { - if ((mode & S_IFMT) == S_IFDIR) + if (S_ISDIR(mode)) error = mkdir(parent->d_inode, *dentry, mode); else error = create(parent->d_inode, *dentry, mode); diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 8878370c13bf..4def4d92aaee 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1740,7 +1740,7 @@ static inline u32 file_mask_to_av(int mode, int mask) { u32 av = 0; - if ((mode & S_IFMT) != S_IFDIR) { + if (!S_ISDIR(mode)) { if (mask & MAY_EXEC) av |= FILE__EXECUTE; if (mask & MAY_READ) From 36fcb589e752fa9c71f8a447db94126d102fd937 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 03:47:31 -0400 Subject: [PATCH 086/165] sysctl: use umode_t for table permissions Signed-off-by: Al Viro --- include/linux/sysctl.h | 2 +- kernel/sched.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 703cfa33a3ca..bb9127dd814b 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -1038,7 +1038,7 @@ struct ctl_table const char *procname; /* Text ID for /proc/sys, or zero */ void *data; int maxlen; - mode_t mode; + umode_t mode; struct ctl_table *child; struct ctl_table *parent; /* Automatically set */ proc_handler *proc_handler; /* Callback for text formatting */ diff --git a/kernel/sched.c b/kernel/sched.c index d6b149ccf925..e64f45741e0e 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -6480,7 +6480,7 @@ static void sd_free_ctl_entry(struct ctl_table **tablep) static void set_table_entry(struct ctl_table *entry, const char *procname, void *data, int maxlen, - mode_t mode, proc_handler *proc_handler) + umode_t mode, proc_handler *proc_handler) { entry->procname = procname; entry->data = data; From 49f0a0767211d3076974e59a26f36b567cbe8621 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:22:01 -0400 Subject: [PATCH 087/165] switch sys_chmod()/sys_fchmod()/sys_fchmodat() to umode_t SYSCALLx magic should take care of things, according to Linus... Signed-off-by: Al Viro --- fs/open.c | 6 +++--- include/linux/syscalls.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/open.c b/fs/open.c index 4ef8d868a448..834e3e1adeb9 100644 --- a/fs/open.c +++ b/fs/open.c @@ -468,7 +468,7 @@ out_unlock: return error; } -SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode) +SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode) { struct file * file; int err = -EBADF; @@ -482,7 +482,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode) return err; } -SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode) +SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, umode_t, mode) { struct path path; int error; @@ -495,7 +495,7 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode) return error; } -SYSCALL_DEFINE2(chmod, const char __user *, filename, mode_t, mode) +SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode) { return sys_fchmodat(AT_FDCWD, filename, mode); } diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index b3c16d8a6383..e1a4b9b81cf2 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -483,8 +483,8 @@ asmlinkage long sys_symlink(const char __user *old, const char __user *new); asmlinkage long sys_unlink(const char __user *pathname); asmlinkage long sys_rename(const char __user *oldname, const char __user *newname); -asmlinkage long sys_chmod(const char __user *filename, mode_t mode); -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode); +asmlinkage long sys_chmod(const char __user *filename, umode_t mode); +asmlinkage long sys_fchmod(unsigned int fd, umode_t mode); asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg); #if BITS_PER_LONG == 32 @@ -769,7 +769,7 @@ asmlinkage long sys_futimesat(int dfd, const char __user *filename, struct timeval __user *utimes); asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode); asmlinkage long sys_fchmodat(int dfd, const char __user * filename, - mode_t mode); + umode_t mode); asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, int flag); asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, From 910f4ecef3f67714ebff69d0bc34313e48afaed2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:25:58 -0400 Subject: [PATCH 088/165] switch security_path_chmod() to umode_t Signed-off-by: Al Viro --- include/linux/security.h | 6 +++--- security/apparmor/lsm.c | 2 +- security/capability.c | 2 +- security/security.c | 2 +- security/tomoyo/tomoyo.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/security.h b/include/linux/security.h index 0e5aeb86dfc4..f2c1fd7978a5 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1436,7 +1436,7 @@ struct security_operations { int (*path_rename) (struct path *old_dir, struct dentry *old_dentry, struct path *new_dir, struct dentry *new_dentry); int (*path_chmod) (struct dentry *dentry, struct vfsmount *mnt, - mode_t mode); + umode_t mode); int (*path_chown) (struct path *path, uid_t uid, gid_t gid); int (*path_chroot) (struct path *path); #endif @@ -2867,7 +2867,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir, int security_path_rename(struct path *old_dir, struct dentry *old_dentry, struct path *new_dir, struct dentry *new_dentry); int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - mode_t mode); + umode_t mode); int security_path_chown(struct path *path, uid_t uid, gid_t gid); int security_path_chroot(struct path *path); #else /* CONFIG_SECURITY_PATH */ @@ -2921,7 +2921,7 @@ static inline int security_path_rename(struct path *old_dir, static inline int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - mode_t mode) + umode_t mode) { return 0; } diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index 37832026e58a..afbe49822bed 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -345,7 +345,7 @@ static int apparmor_path_rename(struct path *old_dir, struct dentry *old_dentry, } static int apparmor_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - mode_t mode) + umode_t mode) { if (!mediated_filesystem(dentry->d_inode)) return 0; diff --git a/security/capability.c b/security/capability.c index 9def035cd572..4f24bee49f26 100644 --- a/security/capability.c +++ b/security/capability.c @@ -280,7 +280,7 @@ static int cap_path_truncate(struct path *path) } static int cap_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - mode_t mode) + umode_t mode) { return 0; } diff --git a/security/security.c b/security/security.c index 8cc0f0caa640..3635a13cd4ab 100644 --- a/security/security.c +++ b/security/security.c @@ -455,7 +455,7 @@ int security_path_truncate(struct path *path) } int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - mode_t mode) + umode_t mode) { if (unlikely(IS_PRIVATE(dentry->d_inode))) return 0; diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c index 4b327b691745..a4b840ea0078 100644 --- a/security/tomoyo/tomoyo.c +++ b/security/tomoyo/tomoyo.c @@ -360,7 +360,7 @@ static int tomoyo_file_ioctl(struct file *file, unsigned int cmd, * Returns 0 on success, negative value otherwise. */ static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - mode_t mode) + umode_t mode) { struct path path = { mnt, dentry }; return tomoyo_path_number_perm(TOMOYO_TYPE_CHMOD, &path, From 52ef0c042bf06f6aef382fade175075627beebc1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:30:04 -0400 Subject: [PATCH 089/165] switch securityfs_create_file() to umode_t Signed-off-by: Al Viro --- include/linux/security.h | 4 ++-- security/apparmor/apparmorfs.c | 2 +- security/inode.c | 12 ++++++------ security/tomoyo/securityfs_if.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/linux/security.h b/include/linux/security.h index f2c1fd7978a5..fab659edf11a 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -3010,7 +3010,7 @@ static inline void security_audit_rule_free(void *lsmrule) #ifdef CONFIG_SECURITYFS -extern struct dentry *securityfs_create_file(const char *name, mode_t mode, +extern struct dentry *securityfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent); @@ -3025,7 +3025,7 @@ static inline struct dentry *securityfs_create_dir(const char *name, } static inline struct dentry *securityfs_create_file(const char *name, - mode_t mode, + umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops) diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 69ddb47787b2..e39df6d43779 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -165,7 +165,7 @@ static void __init aafs_remove(const char *name) * * Used aafs_remove to remove entries created with this fn. */ -static int __init aafs_create(const char *name, int mask, +static int __init aafs_create(const char *name, umode_t mask, const struct file_operations *fops) { struct dentry *dentry; diff --git a/security/inode.c b/security/inode.c index bfe02e68f92e..90a70a67d835 100644 --- a/security/inode.c +++ b/security/inode.c @@ -56,7 +56,7 @@ static const struct file_operations default_file_ops = { .llseek = noop_llseek, }; -static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev) +static struct inode *get_inode(struct super_block *sb, umode_t mode, dev_t dev) { struct inode *inode = new_inode(sb); @@ -85,7 +85,7 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev) /* SMP-safe */ static int mknod(struct inode *dir, struct dentry *dentry, - int mode, dev_t dev) + umode_t mode, dev_t dev) { struct inode *inode; int error = -ENOMEM; @@ -102,7 +102,7 @@ static int mknod(struct inode *dir, struct dentry *dentry, return error; } -static int mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int res; @@ -113,7 +113,7 @@ static int mkdir(struct inode *dir, struct dentry *dentry, int mode) return res; } -static int create(struct inode *dir, struct dentry *dentry, int mode) +static int create(struct inode *dir, struct dentry *dentry, umode_t mode) { mode = (mode & S_IALLUGO) | S_IFREG; return mknod(dir, dentry, mode, 0); @@ -145,7 +145,7 @@ static struct file_system_type fs_type = { .kill_sb = kill_litter_super, }; -static int create_by_name(const char *name, mode_t mode, +static int create_by_name(const char *name, umode_t mode, struct dentry *parent, struct dentry **dentry) { @@ -205,7 +205,7 @@ static int create_by_name(const char *name, mode_t mode, * If securityfs is not enabled in the kernel, the value %-ENODEV is * returned. */ -struct dentry *securityfs_create_file(const char *name, mode_t mode, +struct dentry *securityfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops) { diff --git a/security/tomoyo/securityfs_if.c b/security/tomoyo/securityfs_if.c index 2672ac4f3beb..482b2a5f48f0 100644 --- a/security/tomoyo/securityfs_if.c +++ b/security/tomoyo/securityfs_if.c @@ -224,7 +224,7 @@ static const struct file_operations tomoyo_operations = { * * Returns nothing. */ -static void __init tomoyo_create_entry(const char *name, const mode_t mode, +static void __init tomoyo_create_entry(const char *name, const umode_t mode, struct dentry *parent, const u8 key) { securityfs_create_file(name, mode, parent, ((u8 *) NULL) + key, From 649fc7b1b046eb98bf9e3fe20c9d11f629293140 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:31:05 -0400 Subject: [PATCH 090/165] should_remove_suid(): inode->i_mode is umode_t Signed-off-by: Al Viro --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index 5f0a3c91fdac..a0701e6eec10 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1968,7 +1968,7 @@ EXPORT_SYMBOL(read_cache_page); */ int should_remove_suid(struct dentry *dentry) { - mode_t mode = dentry->d_inode->i_mode; + umode_t mode = dentry->d_inode->i_mode; int kill = 0; /* suid always must be killed */ From f69aac0006c303a98da9d2db04b71fd1c600d503 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:31:40 -0400 Subject: [PATCH 091/165] switch may_mknod() to umode_t Signed-off-by: Al Viro --- fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namei.c b/fs/namei.c index 85bb44f222c9..e275dc36d7c5 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2472,7 +2472,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) return error; } -static int may_mknod(mode_t mode) +static int may_mknod(umode_t mode) { switch (mode & S_IFMT) { case S_IFREG: From 685dd2d5bea3e6368cea8002caf404d1b0b5c9f1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:34:13 -0400 Subject: [PATCH 092/165] init/initramfs.c: should use umode_t Signed-off-by: Al Viro --- init/initramfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 2531811d42cb..8216c303b082 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -22,7 +22,7 @@ static void __init error(char *x) static __initdata struct hash { int ino, minor, major; - mode_t mode; + umode_t mode; struct hash *next; char name[N_ALIGN(PATH_MAX)]; } *head[32]; @@ -35,7 +35,7 @@ static inline int hash(int major, int minor, int ino) } static char __init *find_link(int major, int minor, int ino, - mode_t mode, char *name) + umode_t mode, char *name) { struct hash **p, *q; for (p = head + hash(major, minor, ino); *p; p = &(*p)->next) { @@ -120,7 +120,7 @@ static __initdata time_t mtime; /* cpio header parsing */ static __initdata unsigned long ino, major, minor, nlink; -static __initdata mode_t mode; +static __initdata umode_t mode; static __initdata unsigned long body_len, name_len; static __initdata uid_t uid; static __initdata gid_t gid; @@ -276,7 +276,7 @@ static int __init maybe_link(void) return 0; } -static void __init clean_path(char *path, mode_t mode) +static void __init clean_path(char *path, umode_t mode) { struct stat st; From c6684b26854000d406c9fa0698443c50f2bf2cba Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:47:14 -0400 Subject: [PATCH 093/165] switch spufs guts to umode_t Signed-off-by: Al Viro --- arch/powerpc/include/asm/spu.h | 2 +- arch/powerpc/platforms/cell/spufs/inode.c | 16 ++++++++-------- arch/powerpc/platforms/cell/spufs/spufs.h | 4 ++-- arch/powerpc/platforms/cell/spufs/syscalls.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/include/asm/spu.h b/arch/powerpc/include/asm/spu.h index 4e360bd4a35a..c52640089c93 100644 --- a/arch/powerpc/include/asm/spu.h +++ b/arch/powerpc/include/asm/spu.h @@ -237,7 +237,7 @@ extern long spu_sys_callback(struct spu_syscall_block *s); struct file; struct spufs_calls { long (*create_thread)(const char __user *name, - unsigned int flags, mode_t mode, + unsigned int flags, umode_t mode, struct file *neighbor); long (*spu_run)(struct file *filp, __u32 __user *unpc, __u32 __user *ustatus); diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index d85f8cbdc8b3..d4a094ca96f3 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -91,7 +91,7 @@ spufs_init_once(void *p) } static struct inode * -spufs_new_inode(struct super_block *sb, int mode) +spufs_new_inode(struct super_block *sb, umode_t mode) { struct inode *inode; @@ -123,7 +123,7 @@ spufs_setattr(struct dentry *dentry, struct iattr *attr) static int spufs_new_file(struct super_block *sb, struct dentry *dentry, - const struct file_operations *fops, int mode, + const struct file_operations *fops, umode_t mode, size_t size, struct spu_context *ctx) { static const struct inode_operations spufs_file_iops = { @@ -193,7 +193,7 @@ static int spufs_rmdir(struct inode *parent, struct dentry *dir) } static int spufs_fill_dir(struct dentry *dir, - const struct spufs_tree_descr *files, int mode, + const struct spufs_tree_descr *files, umode_t mode, struct spu_context *ctx) { struct dentry *dentry, *tmp; @@ -263,7 +263,7 @@ EXPORT_SYMBOL_GPL(spufs_context_fops); static int spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags, - int mode) + umode_t mode) { int ret; struct inode *inode; @@ -446,7 +446,7 @@ spufs_set_affinity(unsigned int flags, struct spu_context *ctx, static int spufs_create_context(struct inode *inode, struct dentry *dentry, - struct vfsmount *mnt, int flags, int mode, + struct vfsmount *mnt, int flags, umode_t mode, struct file *aff_filp) { int ret; @@ -520,7 +520,7 @@ out: } static int -spufs_mkgang(struct inode *dir, struct dentry *dentry, int mode) +spufs_mkgang(struct inode *dir, struct dentry *dentry, umode_t mode) { int ret; struct inode *inode; @@ -583,7 +583,7 @@ out: static int spufs_create_gang(struct inode *inode, struct dentry *dentry, - struct vfsmount *mnt, int mode) + struct vfsmount *mnt, umode_t mode) { int ret; @@ -611,7 +611,7 @@ out: static struct file_system_type spufs_type; long spufs_create(struct path *path, struct dentry *dentry, - unsigned int flags, mode_t mode, struct file *filp) + unsigned int flags, umode_t mode, struct file *filp) { int ret; diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h index 099245f230b2..67852ade4c01 100644 --- a/arch/powerpc/platforms/cell/spufs/spufs.h +++ b/arch/powerpc/platforms/cell/spufs/spufs.h @@ -237,7 +237,7 @@ struct spufs_inode_info { struct spufs_tree_descr { const char *name; const struct file_operations *ops; - int mode; + umode_t mode; size_t size; }; @@ -249,7 +249,7 @@ extern const struct spufs_tree_descr spufs_dir_debug_contents[]; extern struct spufs_calls spufs_calls; long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *status); long spufs_create(struct path *nd, struct dentry *dentry, unsigned int flags, - mode_t mode, struct file *filp); + umode_t mode, struct file *filp); /* ELF coredump callbacks for writing SPU ELF notes */ extern int spufs_coredump_extra_notes_size(void); extern int spufs_coredump_extra_notes_write(struct file *file, loff_t *foffset); diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c index 71a5b5207266..8591bb62d7fc 100644 --- a/arch/powerpc/platforms/cell/spufs/syscalls.c +++ b/arch/powerpc/platforms/cell/spufs/syscalls.c @@ -60,7 +60,7 @@ out: } static long do_spu_create(const char __user *pathname, unsigned int flags, - mode_t mode, struct file *neighbor) + umode_t mode, struct file *neighbor) { struct path path; struct dentry *dentry; From a85cfdaec935ede36be6c54f98878624b0d9fbad Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:47:38 -0400 Subject: [PATCH 094/165] switch miscdevice to umode_t Signed-off-by: Al Viro --- include/linux/miscdevice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index c41d7270c6c6..32085249e9cb 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h @@ -54,7 +54,7 @@ struct miscdevice { struct device *parent; struct device *this_device; const char *nodename; - mode_t mode; + umode_t mode; }; extern int misc_register(struct miscdevice * misc); From 138d570de290ee7dbb18ef75d4f5735340352c56 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:48:59 -0400 Subject: [PATCH 095/165] switch hostfs_iattr to explicit unsigned short It's shared between kernel-compiled hostfs_kern and userland-compiled hostfs_user (it's uml stuff). Use explicit type instead of playing silly buggers with mode_t. It's not a userland API per se; it interacts between code compiled with types same as for host kernel and, directly linked to it, code talking to libc. Both sides come from the same kernel source... Signed-off-by: Al Viro --- fs/hostfs/hostfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ struct hostfs_iattr { unsigned int ia_valid; - mode_t ia_mode; + unsigned short ia_mode; uid_t ia_uid; gid_t ia_gid; loff_t ia_size; From 5706b27deae29ceee26d0c20112f087a9b841575 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 04:52:22 -0400 Subject: [PATCH 096/165] ceph: propagate umode_t Signed-off-by: Al Viro --- fs/ceph/caps.c | 4 ++-- fs/ceph/super.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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, u64 size, u64 max_size, struct timespec *mtime, struct timespec *atime, u64 time_warp_seq, - uid_t uid, gid_t gid, mode_t mode, + uid_t uid, gid_t gid, umode_t mode, u64 xattr_version, struct ceph_buffer *xattrs_buf, u64 follows) @@ -1078,7 +1078,7 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, u64 size, max_size; struct timespec mtime, atime; int wake = 0; - mode_t mode; + umode_t mode; uid_t uid; gid_t gid; struct ceph_mds_session *session; 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 { int issued, dirty; struct ceph_snap_context *context; - mode_t mode; + umode_t mode; uid_t uid; gid_t gid; From df0a42837b86567a130c44515ab620d23e7f182b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 05:26:10 -0400 Subject: [PATCH 097/165] switch mq_open() to umode_t --- include/linux/audit.h | 4 ++-- include/linux/syscalls.h | 2 +- ipc/mqueue.c | 2 +- kernel/auditsc.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 2f81c6f3b630..75ed193b11f8 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -474,7 +474,7 @@ extern void audit_socketcall(int nargs, unsigned long *args); extern int audit_sockaddr(int len, void *addr); extern void __audit_fd_pair(int fd1, int fd2); extern int audit_set_macxattr(const char *name); -extern void __audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr); +extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout); extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification); extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); @@ -499,7 +499,7 @@ static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid if (unlikely(!audit_dummy_context())) __audit_ipc_set_perm(qbytes, uid, gid, mode); } -static inline void audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr) +static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr) { if (unlikely(!audit_dummy_context())) __audit_mq_open(oflag, mode, attr); diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index e1a4b9b81cf2..d86e5253f84f 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -679,7 +679,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf); asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second, unsigned long third, void __user *ptr, long fifth); -asmlinkage long sys_mq_open(const char __user *name, int oflag, mode_t mode, struct mq_attr __user *attr); +asmlinkage long sys_mq_open(const char __user *name, int oflag, umode_t mode, struct mq_attr __user *attr); asmlinkage long sys_mq_unlink(const char __user *name); asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec __user *abs_timeout); asmlinkage long sys_mq_timedreceive(mqd_t mqdes, char __user *msg_ptr, size_t msg_len, unsigned int __user *msg_prio, const struct timespec __user *abs_timeout); diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 5eaecf4fc04e..9a142a290749 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -679,7 +679,7 @@ err: return ERR_PTR(ret); } -SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode, +SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, umode_t, mode, struct mq_attr __user *, u_attr) { struct dentry *dentry; diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 47b7fc1ea893..9849213e501c 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -234,7 +234,7 @@ struct audit_context { } mq_sendrecv; struct { int oflag; - mode_t mode; + umode_t mode; struct mq_attr attr; } mq_open; struct { @@ -1278,7 +1278,7 @@ static void show_special(struct audit_context *context, int *call_panic) break; } case AUDIT_MQ_OPEN: { audit_log_format(ab, - "oflag=0x%x mode=%#o mq_flags=0x%lx mq_maxmsg=%ld " + "oflag=0x%x mode=%#ho mq_flags=0x%lx mq_maxmsg=%ld " "mq_msgsize=%ld mq_curmsgs=%ld", context->mq_open.oflag, context->mq_open.mode, context->mq_open.attr.mq_flags, @@ -2160,7 +2160,7 @@ int audit_set_loginuid(struct task_struct *task, uid_t loginuid) * @attr: queue attributes * */ -void __audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr) +void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr) { struct audit_context *context = current->audit_context; From 1bc94226d5c642b78cf6b2e3e843ef24eb740df0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 16:50:23 -0400 Subject: [PATCH 098/165] switch spu_create(2) to use of SYSCALL_DEFINE4, make it use umode_t Signed-off-by: Al Viro --- arch/powerpc/platforms/cell/spu_syscalls.c | 4 ++-- include/linux/syscalls.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c index 75530d99eda6..714bbfc3162c 100644 --- a/arch/powerpc/platforms/cell/spu_syscalls.c +++ b/arch/powerpc/platforms/cell/spu_syscalls.c @@ -65,8 +65,8 @@ static inline void spufs_calls_put(struct spufs_calls *calls) { } #endif /* CONFIG_SPU_FS_MODULE */ -asmlinkage long sys_spu_create(const char __user *name, - unsigned int flags, mode_t mode, int neighbor_fd) +SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags, + umode_t, mode, int, neighbor_fd) { long ret; struct file *neighbor; diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index d86e5253f84f..b25621476316 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -753,7 +753,7 @@ asmlinkage long sys_inotify_rm_watch(int fd, __s32 wd); asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus); asmlinkage long sys_spu_create(const char __user *name, - unsigned int flags, mode_t mode, int fd); + unsigned int flags, umode_t mode, int fd); asmlinkage long sys_mknodat(int dfd, const char __user * filename, umode_t mode, unsigned dev); From 0583fcc96bb117763c0fa74c123573c0112dec65 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Jul 2011 17:04:15 -0400 Subject: [PATCH 099/165] consolidate umode_t declarations Signed-off-by: Al Viro --- arch/alpha/include/asm/types.h | 5 ----- arch/arm/include/asm/types.h | 6 ------ arch/avr32/include/asm/types.h | 6 ------ arch/cris/include/asm/types.h | 6 ------ arch/frv/include/asm/types.h | 6 ------ arch/h8300/include/asm/types.h | 17 ----------------- arch/ia64/include/asm/types.h | 2 -- arch/m32r/include/asm/types.h | 6 ------ arch/m68k/include/asm/types.h | 6 ------ arch/mips/include/asm/types.h | 6 ------ arch/mn10300/include/asm/types.h | 6 ------ arch/parisc/include/asm/types.h | 6 ------ arch/powerpc/include/asm/types.h | 6 ------ arch/s390/include/asm/types.h | 2 -- arch/sparc/include/asm/posix_types.h | 2 -- arch/sparc/include/asm/types.h | 6 ------ arch/xtensa/include/asm/types.h | 2 -- include/asm-generic/types.h | 6 ------ include/linux/types.h | 1 + 19 files changed, 1 insertion(+), 102 deletions(-) diff --git a/arch/alpha/include/asm/types.h b/arch/alpha/include/asm/types.h index 881544339c21..0a0579076f4a 100644 --- a/arch/alpha/include/asm/types.h +++ b/arch/alpha/include/asm/types.h @@ -15,9 +15,4 @@ #include #endif -#ifndef __ASSEMBLY__ - -typedef unsigned int umode_t; - -#endif /* __ASSEMBLY__ */ #endif /* _ALPHA_TYPES_H */ diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h index 48192ac3a23a..28beab917ffc 100644 --- a/arch/arm/include/asm/types.h +++ b/arch/arm/include/asm/types.h @@ -3,12 +3,6 @@ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/avr32/include/asm/types.h b/arch/avr32/include/asm/types.h index 72667a3b1af7..9bb2d8b2e6ca 100644 --- a/arch/avr32/include/asm/types.h +++ b/arch/avr32/include/asm/types.h @@ -10,12 +10,6 @@ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/cris/include/asm/types.h b/arch/cris/include/asm/types.h index 551a12c0aa01..adaf82780bb4 100644 --- a/arch/cris/include/asm/types.h +++ b/arch/cris/include/asm/types.h @@ -3,12 +3,6 @@ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/frv/include/asm/types.h b/arch/frv/include/asm/types.h index aa3e7fdc7f29..390a612f3a58 100644 --- a/arch/frv/include/asm/types.h +++ b/arch/frv/include/asm/types.h @@ -14,12 +14,6 @@ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/h8300/include/asm/types.h b/arch/h8300/include/asm/types.h index bb2c91a3522e..07257d9487d8 100644 --- a/arch/h8300/include/asm/types.h +++ b/arch/h8300/include/asm/types.h @@ -3,27 +3,10 @@ #include -#if !defined(__ASSEMBLY__) - -/* - * This file is never included by application software unless - * explicitly requested (e.g., via linux/types.h) in which case the - * application is Linux specific so (user-) name space pollution is - * not a major issue. However, for interoperability, libraries still - * need to be careful to avoid a name clashes. - */ - -typedef unsigned short umode_t; - -/* - * These aren't exported outside the kernel to avoid name space clashes - */ #ifdef __KERNEL__ #define BITS_PER_LONG 32 #endif /* __KERNEL__ */ -#endif /* __ASSEMBLY__ */ - #endif /* _H8300_TYPES_H */ diff --git a/arch/ia64/include/asm/types.h b/arch/ia64/include/asm/types.h index 82b3939d2718..3f5b122d9975 100644 --- a/arch/ia64/include/asm/types.h +++ b/arch/ia64/include/asm/types.h @@ -28,8 +28,6 @@ # define __IA64_UL(x) ((unsigned long)(x)) # define __IA64_UL_CONST(x) x##UL -typedef unsigned int umode_t; - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/m32r/include/asm/types.h b/arch/m32r/include/asm/types.h index bd0035597b3b..bb2eeadecf99 100644 --- a/arch/m32r/include/asm/types.h +++ b/arch/m32r/include/asm/types.h @@ -3,12 +3,6 @@ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/m68k/include/asm/types.h b/arch/m68k/include/asm/types.h index b17fd115a4e7..89705adcbd52 100644 --- a/arch/m68k/include/asm/types.h +++ b/arch/m68k/include/asm/types.h @@ -10,12 +10,6 @@ */ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/mips/include/asm/types.h b/arch/mips/include/asm/types.h index 533812b61881..43bf70ebd3a2 100644 --- a/arch/mips/include/asm/types.h +++ b/arch/mips/include/asm/types.h @@ -21,12 +21,6 @@ # include #endif -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/mn10300/include/asm/types.h b/arch/mn10300/include/asm/types.h index c1833eb192e3..713d4ba108a5 100644 --- a/arch/mn10300/include/asm/types.h +++ b/arch/mn10300/include/asm/types.h @@ -13,12 +13,6 @@ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/arch/parisc/include/asm/types.h b/arch/parisc/include/asm/types.h index 80e415c9936d..8866f9bbdeaf 100644 --- a/arch/parisc/include/asm/types.h +++ b/arch/parisc/include/asm/types.h @@ -3,10 +3,4 @@ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - #endif diff --git a/arch/powerpc/include/asm/types.h b/arch/powerpc/include/asm/types.h index 8947b9827bc4..b15a52e84b37 100644 --- a/arch/powerpc/include/asm/types.h +++ b/arch/powerpc/include/asm/types.h @@ -27,12 +27,6 @@ * 2 of the License, or (at your option) any later version. */ -#ifdef __powerpc64__ -typedef unsigned int umode_t; -#else -typedef unsigned short umode_t; -#endif - typedef struct { __u32 u[4]; } __attribute__((aligned(16))) __vector128; diff --git a/arch/s390/include/asm/types.h b/arch/s390/include/asm/types.h index eeb52ccf499f..05ebbcdbbf6b 100644 --- a/arch/s390/include/asm/types.h +++ b/arch/s390/include/asm/types.h @@ -13,8 +13,6 @@ #ifndef __ASSEMBLY__ -typedef unsigned short umode_t; - /* A address type so that arithmetic can be done on it & it can be upgraded to 64 bit when necessary */ diff --git a/arch/sparc/include/asm/posix_types.h b/arch/sparc/include/asm/posix_types.h index 98d6ebb922fb..dbfc1a34b3a2 100644 --- a/arch/sparc/include/asm/posix_types.h +++ b/arch/sparc/include/asm/posix_types.h @@ -20,7 +20,6 @@ typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; typedef unsigned long __kernel_ino_t; typedef unsigned int __kernel_mode_t; -typedef unsigned short __kernel_umode_t; typedef unsigned int __kernel_nlink_t; typedef int __kernel_daddr_t; typedef long __kernel_off_t; @@ -55,7 +54,6 @@ typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; -typedef unsigned short __kernel_umode_t; typedef short __kernel_nlink_t; typedef long __kernel_daddr_t; typedef long __kernel_off_t; diff --git a/arch/sparc/include/asm/types.h b/arch/sparc/include/asm/types.h index 91e5a034f987..383d156cde9c 100644 --- a/arch/sparc/include/asm/types.h +++ b/arch/sparc/include/asm/types.h @@ -12,12 +12,6 @@ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - #endif /* defined(__sparc__) */ #endif /* defined(_SPARC_TYPES_H) */ diff --git a/arch/xtensa/include/asm/types.h b/arch/xtensa/include/asm/types.h index b1c981e39b52..6d4db7e8ffac 100644 --- a/arch/xtensa/include/asm/types.h +++ b/arch/xtensa/include/asm/types.h @@ -23,8 +23,6 @@ #ifndef __ASSEMBLY__ -typedef unsigned short umode_t; - /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/include/asm-generic/types.h b/include/asm-generic/types.h index 7a0f69e6c618..bd39806013b5 100644 --- a/include/asm-generic/types.h +++ b/include/asm-generic/types.h @@ -6,10 +6,4 @@ */ #include -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t; - -#endif /* __ASSEMBLY__ */ - #endif /* _ASM_GENERIC_TYPES_H */ diff --git a/include/linux/types.h b/include/linux/types.h index 57a97234bec1..f0ac9bda0f78 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -24,6 +24,7 @@ typedef __kernel_fd_set fd_set; typedef __kernel_dev_t dev_t; typedef __kernel_ino_t ino_t; typedef __kernel_mode_t mode_t; +typedef unsigned short umode_t; typedef __kernel_nlink_t nlink_t; typedef __kernel_off_t off_t; typedef __kernel_pid_t pid_t; From 2570ebbd1f1ce1ef31f568b0660354fc59424be2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 27 Jul 2011 14:03:22 -0400 Subject: [PATCH 100/165] switch kern_ipc_perm to umode_t Signed-off-by: Al Viro --- include/linux/audit.h | 4 ++-- include/linux/ipc.h | 2 +- kernel/auditsc.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index 75ed193b11f8..426ab9f4dd85 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -468,7 +468,7 @@ extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid); #define audit_get_sessionid(t) ((t)->sessionid) extern void audit_log_task_context(struct audit_buffer *ab); extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp); -extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode); +extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode); extern int audit_bprm(struct linux_binprm *bprm); extern void audit_socketcall(int nargs, unsigned long *args); extern int audit_sockaddr(int len, void *addr); @@ -494,7 +494,7 @@ static inline void audit_fd_pair(int fd1, int fd2) if (unlikely(!audit_dummy_context())) __audit_fd_pair(fd1, fd2); } -static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) +static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode) { if (unlikely(!audit_dummy_context())) __audit_ipc_set_perm(qbytes, uid, gid, mode); diff --git a/include/linux/ipc.h b/include/linux/ipc.h index 3b1594d662b0..30e816148df4 100644 --- a/include/linux/ipc.h +++ b/include/linux/ipc.h @@ -93,7 +93,7 @@ struct kern_ipc_perm gid_t gid; uid_t cuid; gid_t cgid; - mode_t mode; + umode_t mode; unsigned long seq; void *security; }; diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 9849213e501c..7a074d65fff4 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -210,12 +210,12 @@ struct audit_context { struct { uid_t uid; gid_t gid; - mode_t mode; + umode_t mode; u32 osid; int has_perm; uid_t perm_uid; gid_t perm_gid; - mode_t perm_mode; + umode_t perm_mode; unsigned long qbytes; } ipc; struct { @@ -1249,7 +1249,7 @@ static void show_special(struct audit_context *context, int *call_panic) case AUDIT_IPC: { u32 osid = context->ipc.osid; - audit_log_format(ab, "ouid=%u ogid=%u mode=%#o", + audit_log_format(ab, "ouid=%u ogid=%u mode=%#ho", context->ipc.uid, context->ipc.gid, context->ipc.mode); if (osid) { char *ctx = NULL; @@ -1267,7 +1267,7 @@ static void show_special(struct audit_context *context, int *call_panic) ab = audit_log_start(context, GFP_KERNEL, AUDIT_IPC_SET_PERM); audit_log_format(ab, - "qbytes=%lx ouid=%u ogid=%u mode=%#o", + "qbytes=%lx ouid=%u ogid=%u mode=%#ho", context->ipc.qbytes, context->ipc.perm_uid, context->ipc.perm_gid, @@ -2260,7 +2260,7 @@ void __audit_ipc_obj(struct kern_ipc_perm *ipcp) * * Called only after audit_ipc_obj(). */ -void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) +void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode) { struct audit_context *context = current->audit_context; From 93d3a10ef4fdfd4b6d1a3f09b645cd08f74a8115 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 27 Jul 2011 14:04:25 -0400 Subject: [PATCH 101/165] auditsc: propage umode_t Signed-off-by: Al Viro --- kernel/auditsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 7a074d65fff4..e7fe2b0d29b3 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -308,7 +308,7 @@ static int audit_match_perm(struct audit_context *ctx, int mask) static int audit_match_filetype(struct audit_context *ctx, int which) { unsigned index = which & ~S_IFMT; - mode_t mode = which & S_IFMT; + umode_t mode = which & S_IFMT; if (unlikely(!ctx)) return 0; @@ -1502,7 +1502,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts if (n->ino != (unsigned long)-1) { audit_log_format(ab, " inode=%lu" - " dev=%02x:%02x mode=%#o" + " dev=%02x:%02x mode=%#ho" " ouid=%u ogid=%u rdev=%02x:%02x", n->ino, MAJOR(n->dev), From 84dfa9897ef913771af44484fefbe0de29fdce51 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 27 Jul 2011 14:54:36 -0400 Subject: [PATCH 102/165] consolidate a bunch of ipcbuf.h instances ... some still remain weird :-/ Signed-off-by: Al Viro --- arch/alpha/include/asm/ipcbuf.h | 29 +---------------------------- arch/arm/include/asm/ipcbuf.h | 30 +----------------------------- arch/avr32/include/asm/ipcbuf.h | 30 +----------------------------- arch/cris/include/asm/ipcbuf.h | 30 +----------------------------- arch/frv/include/asm/ipcbuf.h | 31 +------------------------------ arch/h8300/include/asm/ipcbuf.h | 30 +----------------------------- arch/ia64/include/asm/ipcbuf.h | 29 +---------------------------- arch/m32r/include/asm/ipcbuf.h | 30 +----------------------------- arch/m68k/include/asm/ipcbuf.h | 30 +----------------------------- arch/mips/include/asm/ipcbuf.h | 29 +---------------------------- arch/mn10300/include/asm/ipcbuf.h | 30 +----------------------------- 11 files changed, 11 insertions(+), 317 deletions(-) diff --git a/arch/alpha/include/asm/ipcbuf.h b/arch/alpha/include/asm/ipcbuf.h index d9c0e1a50702..84c7e51cb6d0 100644 --- a/arch/alpha/include/asm/ipcbuf.h +++ b/arch/alpha/include/asm/ipcbuf.h @@ -1,28 +1 @@ -#ifndef _ALPHA_IPCBUF_H -#define _ALPHA_IPCBUF_H - -/* - * The ipc64_perm structure for alpha architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit seq - * - 2 miscellaneous 64-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid_t uid; - __kernel_gid_t gid; - __kernel_uid_t cuid; - __kernel_gid_t cgid; - __kernel_mode_t mode; - unsigned short seq; - unsigned short __pad1; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* _ALPHA_IPCBUF_H */ +#include diff --git a/arch/arm/include/asm/ipcbuf.h b/arch/arm/include/asm/ipcbuf.h index 97683975f7df..84c7e51cb6d0 100644 --- a/arch/arm/include/asm/ipcbuf.h +++ b/arch/arm/include/asm/ipcbuf.h @@ -1,29 +1 @@ -#ifndef __ASMARM_IPCBUF_H -#define __ASMARM_IPCBUF_H - -/* - * The ipc64_perm structure for arm architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit mode_t and seq - * - 2 miscellaneous 32-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - __kernel_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* __ASMARM_IPCBUF_H */ +#include diff --git a/arch/avr32/include/asm/ipcbuf.h b/arch/avr32/include/asm/ipcbuf.h index 1552c9698f5e..84c7e51cb6d0 100644 --- a/arch/avr32/include/asm/ipcbuf.h +++ b/arch/avr32/include/asm/ipcbuf.h @@ -1,29 +1 @@ -#ifndef __ASM_AVR32_IPCBUF_H -#define __ASM_AVR32_IPCBUF_H - -/* -* The user_ipc_perm structure for AVR32 architecture. -* Note extra padding because this structure is passed back and forth -* between kernel and user space. -* -* Pad space is left for: -* - 32-bit mode_t and seq -* - 2 miscellaneous 32-bit values -*/ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - __kernel_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* __ASM_AVR32_IPCBUF_H */ +#include diff --git a/arch/cris/include/asm/ipcbuf.h b/arch/cris/include/asm/ipcbuf.h index 8b0c18b02844..84c7e51cb6d0 100644 --- a/arch/cris/include/asm/ipcbuf.h +++ b/arch/cris/include/asm/ipcbuf.h @@ -1,29 +1 @@ -#ifndef __CRIS_IPCBUF_H__ -#define __CRIS_IPCBUF_H__ - -/* - * The user_ipc_perm structure for CRIS architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit mode_t and seq - * - 2 miscellaneous 32-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - __kernel_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* __CRIS_IPCBUF_H__ */ +#include diff --git a/arch/frv/include/asm/ipcbuf.h b/arch/frv/include/asm/ipcbuf.h index b546f67e455f..84c7e51cb6d0 100644 --- a/arch/frv/include/asm/ipcbuf.h +++ b/arch/frv/include/asm/ipcbuf.h @@ -1,30 +1 @@ -#ifndef __ASM_IPCBUF_H__ -#define __ASM_IPCBUF_H__ - -/* - * The user_ipc_perm structure for FR-V architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit mode_t and seq - * - 2 miscellaneous 32-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - __kernel_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* __ASM_IPCBUF_H__ */ - +#include diff --git a/arch/h8300/include/asm/ipcbuf.h b/arch/h8300/include/asm/ipcbuf.h index 2cd1ebcc109d..84c7e51cb6d0 100644 --- a/arch/h8300/include/asm/ipcbuf.h +++ b/arch/h8300/include/asm/ipcbuf.h @@ -1,29 +1 @@ -#ifndef __H8300_IPCBUF_H__ -#define __H8300_IPCBUF_H__ - -/* - * The user_ipc_perm structure for H8/300 architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit mode_t and seq - * - 2 miscellaneous 32-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - __kernel_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* __H8300_IPCBUF_H__ */ +#include diff --git a/arch/ia64/include/asm/ipcbuf.h b/arch/ia64/include/asm/ipcbuf.h index 079899ae7d32..84c7e51cb6d0 100644 --- a/arch/ia64/include/asm/ipcbuf.h +++ b/arch/ia64/include/asm/ipcbuf.h @@ -1,28 +1 @@ -#ifndef _ASM_IA64_IPCBUF_H -#define _ASM_IA64_IPCBUF_H - -/* - * The ipc64_perm structure for IA-64 architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit seq - * - 2 miscellaneous 64-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid_t uid; - __kernel_gid_t gid; - __kernel_uid_t cuid; - __kernel_gid_t cgid; - __kernel_mode_t mode; - unsigned short seq; - unsigned short __pad1; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* _ASM_IA64_IPCBUF_H */ +#include diff --git a/arch/m32r/include/asm/ipcbuf.h b/arch/m32r/include/asm/ipcbuf.h index 8d2d7c8ffdb0..84c7e51cb6d0 100644 --- a/arch/m32r/include/asm/ipcbuf.h +++ b/arch/m32r/include/asm/ipcbuf.h @@ -1,29 +1 @@ -#ifndef _ASM_M32R_IPCBUF_H -#define _ASM_M32R_IPCBUF_H - -/* - * The ipc64_perm structure for m32r architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit mode_t and seq - * - 2 miscellaneous 32-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - __kernel_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* _ASM_M32R_IPCBUF_H */ +#include diff --git a/arch/m68k/include/asm/ipcbuf.h b/arch/m68k/include/asm/ipcbuf.h index a623ea3f0955..84c7e51cb6d0 100644 --- a/arch/m68k/include/asm/ipcbuf.h +++ b/arch/m68k/include/asm/ipcbuf.h @@ -1,29 +1 @@ -#ifndef __m68k_IPCBUF_H__ -#define __m68k_IPCBUF_H__ - -/* - * The user_ipc_perm structure for m68k architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit mode_t and seq - * - 2 miscellaneous 32-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - __kernel_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* __m68k_IPCBUF_H__ */ +#include diff --git a/arch/mips/include/asm/ipcbuf.h b/arch/mips/include/asm/ipcbuf.h index d47d08f264e7..84c7e51cb6d0 100644 --- a/arch/mips/include/asm/ipcbuf.h +++ b/arch/mips/include/asm/ipcbuf.h @@ -1,28 +1 @@ -#ifndef _ASM_IPCBUF_H -#define _ASM_IPCBUF_H - -/* - * The ipc64_perm structure for alpha architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit seq - * - 2 miscellaneous 64-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid_t uid; - __kernel_gid_t gid; - __kernel_uid_t cuid; - __kernel_gid_t cgid; - __kernel_mode_t mode; - unsigned short seq; - unsigned short __pad1; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* _ASM_IPCBUF_H */ +#include diff --git a/arch/mn10300/include/asm/ipcbuf.h b/arch/mn10300/include/asm/ipcbuf.h index f6f63d448272..84c7e51cb6d0 100644 --- a/arch/mn10300/include/asm/ipcbuf.h +++ b/arch/mn10300/include/asm/ipcbuf.h @@ -1,29 +1 @@ -#ifndef _ASM_IPCBUF_H -#define _ASM_IPCBUF_H - -/* - * The ipc64_perm structure for MN10300 architecture. - * Note extra padding because this structure is passed back and forth - * between kernel and user space. - * - * Pad space is left for: - * - 32-bit mode_t and seq - * - 2 miscellaneous 32-bit values - */ - -struct ipc64_perm -{ - __kernel_key_t key; - __kernel_uid32_t uid; - __kernel_gid32_t gid; - __kernel_uid32_t cuid; - __kernel_gid32_t cgid; - __kernel_mode_t mode; - unsigned short __pad1; - unsigned short seq; - unsigned short __pad2; - unsigned long __unused1; - unsigned long __unused2; -}; - -#endif /* _ASM_IPCBUF_H */ +#include From d179333f37d33533f4c77118f757b9e7835ccb7c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 26 Aug 2011 23:03:17 -0400 Subject: [PATCH 103/165] tomoyo_mini_stat: switch to umode_t Signed-off-by: Al Viro --- security/tomoyo/audit.c | 4 ++-- security/tomoyo/common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/security/tomoyo/audit.c b/security/tomoyo/audit.c index 075c3a6d1649..5ca47ea3049f 100644 --- a/security/tomoyo/audit.c +++ b/security/tomoyo/audit.c @@ -112,7 +112,7 @@ out: * * Returns file type string. */ -static inline const char *tomoyo_filetype(const mode_t mode) +static inline const char *tomoyo_filetype(const umode_t mode) { switch (mode & S_IFMT) { case S_IFREG: @@ -180,7 +180,7 @@ static char *tomoyo_print_header(struct tomoyo_request_info *r) for (i = 0; i < TOMOYO_MAX_PATH_STAT; i++) { struct tomoyo_mini_stat *stat; unsigned int dev; - mode_t mode; + umode_t mode; if (!obj->stat_valid[i]) continue; stat = &obj->stat[i]; diff --git a/security/tomoyo/common.h b/security/tomoyo/common.h index ed311d7a8ce0..deeab7be5b97 100644 --- a/security/tomoyo/common.h +++ b/security/tomoyo/common.h @@ -564,7 +564,7 @@ struct tomoyo_mini_stat { uid_t uid; gid_t gid; ino_t ino; - mode_t mode; + umode_t mode; dev_t dev; dev_t rdev; }; From 4572befe248fd0d94aedc98775e3f0ddc8a26651 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 21 Nov 2011 14:56:21 -0500 Subject: [PATCH 104/165] switch ->path_mkdir() to umode_t Signed-off-by: Al Viro --- include/linux/security.h | 6 +++--- security/apparmor/lsm.c | 2 +- security/capability.c | 2 +- security/security.c | 2 +- security/tomoyo/tomoyo.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/security.h b/include/linux/security.h index fab659edf11a..24cd7cf48564 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1424,7 +1424,7 @@ struct security_operations { #ifdef CONFIG_SECURITY_PATH int (*path_unlink) (struct path *dir, struct dentry *dentry); - int (*path_mkdir) (struct path *dir, struct dentry *dentry, int mode); + int (*path_mkdir) (struct path *dir, struct dentry *dentry, umode_t mode); int (*path_rmdir) (struct path *dir, struct dentry *dentry); int (*path_mknod) (struct path *dir, struct dentry *dentry, int mode, unsigned int dev); @@ -2855,7 +2855,7 @@ static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi #ifdef CONFIG_SECURITY_PATH int security_path_unlink(struct path *dir, struct dentry *dentry); -int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode); +int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode); int security_path_rmdir(struct path *dir, struct dentry *dentry); int security_path_mknod(struct path *dir, struct dentry *dentry, int mode, unsigned int dev); @@ -2877,7 +2877,7 @@ static inline int security_path_unlink(struct path *dir, struct dentry *dentry) } static inline int security_path_mkdir(struct path *dir, struct dentry *dentry, - int mode) + umode_t mode) { return 0; } diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index afbe49822bed..3271bd38d860 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -262,7 +262,7 @@ static int apparmor_path_unlink(struct path *dir, struct dentry *dentry) } static int apparmor_path_mkdir(struct path *dir, struct dentry *dentry, - int mode) + umode_t mode) { return common_perm_create(OP_MKDIR, dir, dentry, AA_MAY_CREATE, S_IFDIR); diff --git a/security/capability.c b/security/capability.c index 4f24bee49f26..2e1fe45d1486 100644 --- a/security/capability.c +++ b/security/capability.c @@ -241,7 +241,7 @@ static int cap_path_mknod(struct path *dir, struct dentry *dentry, int mode, return 0; } -static int cap_path_mkdir(struct path *dir, struct dentry *dentry, int mode) +static int cap_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode) { return 0; } diff --git a/security/security.c b/security/security.c index 3635a13cd4ab..e9724e058b43 100644 --- a/security/security.c +++ b/security/security.c @@ -397,7 +397,7 @@ int security_path_mknod(struct path *dir, struct dentry *dentry, int mode, } EXPORT_SYMBOL(security_path_mknod); -int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode) +int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode) { if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) return 0; diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c index a4b840ea0078..95e4a7db8b86 100644 --- a/security/tomoyo/tomoyo.c +++ b/security/tomoyo/tomoyo.c @@ -186,7 +186,7 @@ static int tomoyo_path_unlink(struct path *parent, struct dentry *dentry) * Returns 0 on success, negative value otherwise. */ static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry, - int mode) + umode_t mode) { struct path path = { parent->mnt, dentry }; return tomoyo_path_number_perm(TOMOYO_TYPE_MKDIR, &path, From 04fc66e789a896e684bfdca30208e57eb832dd96 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 21 Nov 2011 14:58:38 -0500 Subject: [PATCH 105/165] switch ->path_mknod() to umode_t Signed-off-by: Al Viro --- include/linux/security.h | 6 +++--- net/unix/af_unix.c | 2 +- security/apparmor/lsm.c | 2 +- security/capability.c | 2 +- security/security.c | 2 +- security/tomoyo/tomoyo.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/security.h b/include/linux/security.h index 24cd7cf48564..535721cc374a 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1426,7 +1426,7 @@ struct security_operations { int (*path_unlink) (struct path *dir, struct dentry *dentry); int (*path_mkdir) (struct path *dir, struct dentry *dentry, umode_t mode); int (*path_rmdir) (struct path *dir, struct dentry *dentry); - int (*path_mknod) (struct path *dir, struct dentry *dentry, int mode, + int (*path_mknod) (struct path *dir, struct dentry *dentry, umode_t mode, unsigned int dev); int (*path_truncate) (struct path *path); int (*path_symlink) (struct path *dir, struct dentry *dentry, @@ -2857,7 +2857,7 @@ static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi int security_path_unlink(struct path *dir, struct dentry *dentry); int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode); int security_path_rmdir(struct path *dir, struct dentry *dentry); -int security_path_mknod(struct path *dir, struct dentry *dentry, int mode, +int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode, unsigned int dev); int security_path_truncate(struct path *path); int security_path_symlink(struct path *dir, struct dentry *dentry, @@ -2888,7 +2888,7 @@ static inline int security_path_rmdir(struct path *dir, struct dentry *dentry) } static inline int security_path_mknod(struct path *dir, struct dentry *dentry, - int mode, unsigned int dev) + umode_t mode, unsigned int dev) { return 0; } diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index b595a3d8679f..412a99f4a3f7 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -847,7 +847,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) atomic_set(&addr->refcnt, 1); if (sun_path[0]) { - unsigned int mode; + umode_t mode; err = 0; /* * Get the parent directory, calculate the hash for last diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index 3271bd38d860..c0a399ec1df9 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -274,7 +274,7 @@ static int apparmor_path_rmdir(struct path *dir, struct dentry *dentry) } static int apparmor_path_mknod(struct path *dir, struct dentry *dentry, - int mode, unsigned int dev) + umode_t mode, unsigned int dev) { return common_perm_create(OP_MKNOD, dir, dentry, AA_MAY_CREATE, mode); } diff --git a/security/capability.c b/security/capability.c index 2e1fe45d1486..156816d451ba 100644 --- a/security/capability.c +++ b/security/capability.c @@ -235,7 +235,7 @@ static void cap_inode_getsecid(const struct inode *inode, u32 *secid) } #ifdef CONFIG_SECURITY_PATH -static int cap_path_mknod(struct path *dir, struct dentry *dentry, int mode, +static int cap_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode, unsigned int dev) { return 0; diff --git a/security/security.c b/security/security.c index e9724e058b43..151152de1a0a 100644 --- a/security/security.c +++ b/security/security.c @@ -388,7 +388,7 @@ int security_old_inode_init_security(struct inode *inode, struct inode *dir, EXPORT_SYMBOL(security_old_inode_init_security); #ifdef CONFIG_SECURITY_PATH -int security_path_mknod(struct path *dir, struct dentry *dentry, int mode, +int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode, unsigned int dev) { if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c index 95e4a7db8b86..75c956a51e75 100644 --- a/security/tomoyo/tomoyo.c +++ b/security/tomoyo/tomoyo.c @@ -234,7 +234,7 @@ static int tomoyo_path_symlink(struct path *parent, struct dentry *dentry, * Returns 0 on success, negative value otherwise. */ static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry, - int mode, unsigned int dev) + umode_t mode, unsigned int dev) { struct path path = { parent->mnt, dentry }; int type = TOMOYO_TYPE_CREATE; From a218d0fdc5f9004164ff151d274487f6799907d0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 21 Nov 2011 14:59:34 -0500 Subject: [PATCH 106/165] switch open and mkdir syscalls to umode_t Signed-off-by: Al Viro --- fs/compat.c | 4 ++-- fs/internal.h | 2 +- fs/namei.c | 6 +++--- fs/open.c | 12 ++++++------ include/linux/compat.h | 4 ++-- include/linux/fs.h | 4 ++-- include/linux/syscalls.h | 10 +++++----- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fs/compat.c b/fs/compat.c index 9db5a6076610..fa9d721ecfee 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -1281,7 +1281,7 @@ compat_sys_vmsplice(int fd, const struct compat_iovec __user *iov32, * O_LARGEFILE flag. */ asmlinkage long -compat_sys_open(const char __user *filename, int flags, int mode) +compat_sys_open(const char __user *filename, int flags, umode_t mode) { return do_sys_open(AT_FDCWD, filename, flags, mode); } @@ -1291,7 +1291,7 @@ compat_sys_open(const char __user *filename, int flags, int mode) * O_LARGEFILE flag. */ asmlinkage long -compat_sys_openat(unsigned int dfd, const char __user *filename, int flags, int mode) +compat_sys_openat(unsigned int dfd, const char __user *filename, int flags, umode_t mode) { return do_sys_open(dfd, filename, flags, mode); } diff --git a/fs/internal.h b/fs/internal.h index 7b1cb1528ac2..23599f88d1a5 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -88,7 +88,7 @@ extern struct file *nameidata_to_filp(struct nameidata *); extern void release_open_intent(struct nameidata *); struct open_flags { int open_flag; - int mode; + umode_t mode; int acc_mode; int intent; }; diff --git a/fs/namei.c b/fs/namei.c index e275dc36d7c5..afd5876cd072 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2177,7 +2177,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path, /* Negative dentry, just create the file */ if (!dentry->d_inode) { - int mode = op->mode; + umode_t mode = op->mode; if (!IS_POSIXACL(dir->d_inode)) mode &= ~current_umask(); /* @@ -2562,7 +2562,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) return error; } -SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, int, mode) +SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode) { struct dentry *dentry; struct path path; @@ -2590,7 +2590,7 @@ out_dput: return error; } -SYSCALL_DEFINE2(mkdir, const char __user *, pathname, int, mode) +SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode) { return sys_mkdirat(AT_FDCWD, pathname, mode); } diff --git a/fs/open.c b/fs/open.c index 834e3e1adeb9..2659f596f4c5 100644 --- a/fs/open.c +++ b/fs/open.c @@ -877,7 +877,7 @@ void fd_install(unsigned int fd, struct file *file) EXPORT_SYMBOL(fd_install); -static inline int build_open_flags(int flags, int mode, struct open_flags *op) +static inline int build_open_flags(int flags, umode_t mode, struct open_flags *op) { int lookup_flags = 0; int acc_mode; @@ -948,7 +948,7 @@ static inline int build_open_flags(int flags, int mode, struct open_flags *op) * have to. But in generally you should not do this, so please move * along, nothing to see here.. */ -struct file *filp_open(const char *filename, int flags, int mode) +struct file *filp_open(const char *filename, int flags, umode_t mode) { struct open_flags op; int lookup = build_open_flags(flags, mode, &op); @@ -970,7 +970,7 @@ struct file *file_open_root(struct dentry *dentry, struct vfsmount *mnt, } EXPORT_SYMBOL(file_open_root); -long do_sys_open(int dfd, const char __user *filename, int flags, int mode) +long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) { struct open_flags op; 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) return fd; } -SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode) +SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) { long ret; @@ -1008,7 +1008,7 @@ SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode) } SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, - int, mode) + umode_t, mode) { long ret; @@ -1027,7 +1027,7 @@ SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, * For backward compatibility? Maybe this should be moved * into arch/i386 instead? */ -SYSCALL_DEFINE2(creat, const char __user *, pathname, int, mode) +SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, mode) { return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode); } diff --git a/include/linux/compat.h b/include/linux/compat.h index 66ed067fb729..41c9f6515f46 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -422,9 +422,9 @@ asmlinkage long compat_sys_getdents64(unsigned int fd, asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *, unsigned int nr_segs, unsigned int flags); asmlinkage long compat_sys_open(const char __user *filename, int flags, - int mode); + umode_t mode); asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename, - int flags, int mode); + int flags, umode_t mode); asmlinkage long compat_sys_open_by_handle_at(int mountdirfd, struct file_handle __user *handle, int flags); diff --git a/include/linux/fs.h b/include/linux/fs.h index 9d02fab420c6..f0e57b7e4297 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2054,8 +2054,8 @@ extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, extern int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len); extern long do_sys_open(int dfd, const char __user *filename, int flags, - int mode); -extern struct file *filp_open(const char *, int, int); + umode_t mode); +extern struct file *filp_open(const char *, int, umode_t); extern struct file *file_open_root(struct dentry *, struct vfsmount *, const char *, int); extern struct file * dentry_open(struct dentry *, struct vfsmount *, int, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index b25621476316..515669fa3c1d 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -517,9 +517,9 @@ asmlinkage long sys_sendfile64(int out_fd, int in_fd, loff_t __user *offset, size_t count); asmlinkage long sys_readlink(const char __user *path, char __user *buf, int bufsiz); -asmlinkage long sys_creat(const char __user *pathname, int mode); +asmlinkage long sys_creat(const char __user *pathname, umode_t mode); asmlinkage long sys_open(const char __user *filename, - int flags, int mode); + int flags, umode_t mode); asmlinkage long sys_close(unsigned int fd); asmlinkage long sys_access(const char __user *filename, int mode); asmlinkage long sys_vhangup(void); @@ -582,7 +582,7 @@ asmlinkage long sys_preadv(unsigned long fd, const struct iovec __user *vec, asmlinkage long sys_pwritev(unsigned long fd, const struct iovec __user *vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h); asmlinkage long sys_getcwd(char __user *buf, unsigned long size); -asmlinkage long sys_mkdir(const char __user *pathname, int mode); +asmlinkage long sys_mkdir(const char __user *pathname, umode_t mode); asmlinkage long sys_chdir(const char __user *filename); asmlinkage long sys_fchdir(unsigned int fd); asmlinkage long sys_rmdir(const char __user *pathname); @@ -757,7 +757,7 @@ asmlinkage long sys_spu_create(const char __user *name, asmlinkage long sys_mknodat(int dfd, const char __user * filename, umode_t mode, unsigned dev); -asmlinkage long sys_mkdirat(int dfd, const char __user * pathname, int mode); +asmlinkage long sys_mkdirat(int dfd, const char __user * pathname, umode_t mode); asmlinkage long sys_unlinkat(int dfd, const char __user * pathname, int flag); asmlinkage long sys_symlinkat(const char __user * oldname, int newdfd, const char __user * newname); @@ -773,7 +773,7 @@ asmlinkage long sys_fchmodat(int dfd, const char __user * filename, asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, int flag); asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, - int mode); + umode_t mode); asmlinkage long sys_newfstatat(int dfd, const char __user *filename, struct stat __user *statbuf, int flag); asmlinkage long sys_fstatat64(int dfd, const char __user *filename, From 7d6fec45a5131918b51dcd76da52f2ec86a85be6 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 23 Nov 2011 12:14:10 -0500 Subject: [PATCH 107/165] vfs: start hiding vfsmount guts series Almost all fields of struct vfsmount are used only by core VFS (and a fairly small part of it, at that). The plan: embed struct vfsmount into struct mount, making the latter visible only to core parts of VFS. Then move fields from vfsmount to mount, eventually leaving only mnt_root/mnt_sb/mnt_flags in struct vfsmount. Filesystem code still gets pointers to struct vfsmount and remains unchanged; all such pointers go to struct vfsmount embedded into the instances of struct mount allocated by fs/namespace.c. When fs/namespace.c et.al. get a pointer to vfsmount, they turn it into pointer to mount (using container_of) and work with that. This is the first part of series; struct mount is introduced, allocation switched to using it. Signed-off-by: Al Viro --- fs/mount.h | 9 +++++++++ fs/namespace.c | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 7890e49f74ef..47da8163e1f4 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -1,5 +1,14 @@ #include +struct mount { + struct vfsmount mnt; +}; + +static inline struct mount *real_mount(struct vfsmount *mnt) +{ + return container_of(mnt, struct mount, mnt); +} + static inline int mnt_has_parent(struct vfsmount *mnt) { return mnt != mnt->mnt_parent; diff --git a/fs/namespace.c b/fs/namespace.c index 86b4f6406470..dda47fee6fdf 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -173,8 +173,9 @@ unsigned int mnt_get_count(struct vfsmount *mnt) static struct vfsmount *alloc_vfsmnt(const char *name) { - struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); - if (mnt) { + struct mount *p = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); + if (p) { + struct vfsmount *mnt = &p->mnt; int err; err = mnt_alloc_id(mnt); @@ -210,16 +211,16 @@ static struct vfsmount *alloc_vfsmnt(const char *name) INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks); #endif } - return mnt; + return &p->mnt; #ifdef CONFIG_SMP out_free_devname: - kfree(mnt->mnt_devname); + kfree(p->mnt.mnt_devname); #endif out_free_id: - mnt_free_id(mnt); + mnt_free_id(&p->mnt); out_free_cache: - kmem_cache_free(mnt_cache, mnt); + kmem_cache_free(mnt_cache, p); return NULL; } @@ -449,12 +450,13 @@ static void __mnt_unmake_readonly(struct vfsmount *mnt) static void free_vfsmnt(struct vfsmount *mnt) { + struct mount *p = real_mount(mnt); kfree(mnt->mnt_devname); mnt_free_id(mnt); #ifdef CONFIG_SMP free_percpu(mnt->mnt_pcp); #endif - kmem_cache_free(mnt_cache, mnt); + kmem_cache_free(mnt_cache, p); } /* @@ -2698,7 +2700,7 @@ void __init mnt_init(void) init_rwsem(&namespace_sem); - mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct vfsmount), + mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount), 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL); mount_hashtable = (struct list_head *)__get_free_page(GFP_ATOMIC); From c71053659e3bb27d44b79da0bb4abf5838c2060a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 18:22:03 -0500 Subject: [PATCH 108/165] vfs: spread struct mount - __lookup_mnt() result switch __lookup_mnt() to returning struct mount *; callers adjusted. Signed-off-by: Al Viro --- fs/internal.h | 2 +- fs/mount.h | 2 ++ fs/namei.c | 13 +++++++------ fs/namespace.c | 23 ++++++++++++++--------- fs/pnode.c | 13 +++++++------ 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index 7b1cb1528ac2..6aab61a4f36f 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -15,6 +15,7 @@ struct super_block; struct file_system_type; struct linux_binprm; struct path; +struct mount; /* * block_dev.c @@ -46,7 +47,6 @@ extern void __init chrdev_init(void); extern int copy_mount_options(const void __user *, unsigned long *); extern int copy_mount_string(const void __user *, char **); -extern struct vfsmount *__lookup_mnt(struct vfsmount *, struct dentry *, int); extern struct vfsmount *lookup_mnt(struct path *); extern int finish_automount(struct vfsmount *, struct path *); diff --git a/fs/mount.h b/fs/mount.h index 47da8163e1f4..44e5b6f54b7e 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -13,3 +13,5 @@ static inline int mnt_has_parent(struct vfsmount *mnt) { return mnt != mnt->mnt_parent; } + +extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int); diff --git a/fs/namei.c b/fs/namei.c index 5008f01787f5..d1c6a559f8f0 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -36,6 +36,7 @@ #include #include "internal.h" +#include "mount.h" /* [Feb-1997 T. Schoebel-Theuer] * Fundamental changes in the pathname lookup mechanisms (namei) @@ -884,7 +885,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, struct inode **inode) { for (;;) { - struct vfsmount *mounted; + struct mount *mounted; /* * Don't forget we might have a non-mountpoint managed dentry * that wants to block transit. @@ -898,8 +899,8 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, mounted = __lookup_mnt(path->mnt, path->dentry, 1); if (!mounted) break; - path->mnt = mounted; - path->dentry = mounted->mnt_root; + path->mnt = &mounted->mnt; + path->dentry = mounted->mnt.mnt_root; nd->flags |= LOOKUP_JUMPED; nd->seq = read_seqcount_begin(&path->dentry->d_seq); /* @@ -915,12 +916,12 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, static void follow_mount_rcu(struct nameidata *nd) { while (d_mountpoint(nd->path.dentry)) { - struct vfsmount *mounted; + struct mount *mounted; mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry, 1); if (!mounted) break; - nd->path.mnt = mounted; - nd->path.dentry = mounted->mnt_root; + nd->path.mnt = &mounted->mnt; + nd->path.dentry = mounted->mnt.mnt_root; nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq); } } diff --git a/fs/namespace.c b/fs/namespace.c index dda47fee6fdf..398eb2421494 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -464,20 +464,20 @@ static void free_vfsmnt(struct vfsmount *mnt) * @dir. If @dir is set return the first mount else return the last mount. * vfsmount_lock must be held for read or write. */ -struct vfsmount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, +struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, int dir) { struct list_head *head = mount_hashtable + hash(mnt, dentry); struct list_head *tmp = head; - struct vfsmount *p, *found = NULL; + struct mount *p, *found = NULL; for (;;) { tmp = dir ? tmp->next : tmp->prev; p = NULL; if (tmp == head) break; - p = list_entry(tmp, struct vfsmount, mnt_hash); - if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry) { + p = list_entry(tmp, struct mount, mnt.mnt_hash); + if (p->mnt.mnt_parent == mnt && p->mnt.mnt_mountpoint == dentry) { found = p; break; } @@ -491,13 +491,18 @@ struct vfsmount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, */ struct vfsmount *lookup_mnt(struct path *path) { - struct vfsmount *child_mnt; + struct mount *child_mnt; br_read_lock(vfsmount_lock); - if ((child_mnt = __lookup_mnt(path->mnt, path->dentry, 1))) - mntget(child_mnt); - br_read_unlock(vfsmount_lock); - return child_mnt; + child_mnt = __lookup_mnt(path->mnt, path->dentry, 1); + if (child_mnt) { + mnt_add_count(child_mnt, 1); + br_read_unlock(vfsmount_lock); + return &child_mnt->mnt; + } else { + br_read_unlock(vfsmount_lock); + return NULL; + } } static inline int check_mnt(struct vfsmount *mnt) diff --git a/fs/pnode.c b/fs/pnode.c index 4d5a06ea57a2..e996d039c0f2 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -289,7 +289,8 @@ static inline int do_refcount_check(struct vfsmount *mnt, int count) */ int propagate_mount_busy(struct vfsmount *mnt, int refcnt) { - struct vfsmount *m, *child; + struct vfsmount *m; + struct mount *child; struct vfsmount *parent = mnt->mnt_parent; int ret = 0; @@ -307,8 +308,8 @@ int propagate_mount_busy(struct vfsmount *mnt, int refcnt) for (m = propagation_next(parent, parent); m; m = propagation_next(m, parent)) { child = __lookup_mnt(m, mnt->mnt_mountpoint, 0); - if (child && list_empty(&child->mnt_mounts) && - (ret = do_refcount_check(child, 1))) + if (child && list_empty(&child->mnt.mnt_mounts) && + (ret = do_refcount_check(&child->mnt, 1))) break; } return ret; @@ -328,14 +329,14 @@ static void __propagate_umount(struct vfsmount *mnt) for (m = propagation_next(parent, parent); m; m = propagation_next(m, parent)) { - struct vfsmount *child = __lookup_mnt(m, + struct mount *child = __lookup_mnt(m, mnt->mnt_mountpoint, 0); /* * umount the child only if the child has no * other children */ - if (child && list_empty(&child->mnt_mounts)) - list_move_tail(&child->mnt_hash, &mnt->mnt_hash); + if (child && list_empty(&child->mnt.mnt_mounts)) + list_move_tail(&child->mnt.mnt_hash, &mnt->mnt_hash); } } From 61ef47b1e4ba9f2b939e6772e2f96082df0ae7eb Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 18:25:28 -0500 Subject: [PATCH 109/165] vfs: spread struct mount - __propagate_umount() argument Signed-off-by: Al Viro --- fs/pnode.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/pnode.c b/fs/pnode.c index e996d039c0f2..ae5b1bda31ba 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -319,24 +319,24 @@ int propagate_mount_busy(struct vfsmount *mnt, int refcnt) * NOTE: unmounting 'mnt' naturally propagates to all other mounts its * parent propagates to. */ -static void __propagate_umount(struct vfsmount *mnt) +static void __propagate_umount(struct mount *mnt) { - struct vfsmount *parent = mnt->mnt_parent; + struct vfsmount *parent = mnt->mnt.mnt_parent; struct vfsmount *m; - BUG_ON(parent == mnt); + BUG_ON(parent == &mnt->mnt); for (m = propagation_next(parent, parent); m; m = propagation_next(m, parent)) { struct mount *child = __lookup_mnt(m, - mnt->mnt_mountpoint, 0); + mnt->mnt.mnt_mountpoint, 0); /* * umount the child only if the child has no * other children */ if (child && list_empty(&child->mnt.mnt_mounts)) - list_move_tail(&child->mnt.mnt_hash, &mnt->mnt_hash); + list_move_tail(&child->mnt.mnt_hash, &mnt->mnt.mnt_hash); } } @@ -349,9 +349,9 @@ static void __propagate_umount(struct vfsmount *mnt) */ int propagate_umount(struct list_head *list) { - struct vfsmount *mnt; + struct mount *mnt; - list_for_each_entry(mnt, list, mnt_hash) + list_for_each_entry(mnt, list, mnt.mnt_hash) __propagate_umount(mnt); return 0; } From 315fc83e56c6998f67af24b49c619f40a6ff2803 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 18:57:30 -0500 Subject: [PATCH 110/165] vfs: spread struct mount - namespace.c internal iterators next_mnt() return value, first argument skip_mnt_tree() return value and argument Signed-off-by: Al Viro --- fs/namespace.c | 145 +++++++++++++++++++++++++------------------------ 1 file changed, 74 insertions(+), 71 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 398eb2421494..7226dc514b3b 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -632,28 +632,28 @@ static void commit_tree(struct vfsmount *mnt) touch_mnt_namespace(n); } -static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root) +static struct mount *next_mnt(struct mount *p, struct vfsmount *root) { - struct list_head *next = p->mnt_mounts.next; - if (next == &p->mnt_mounts) { + struct list_head *next = p->mnt.mnt_mounts.next; + if (next == &p->mnt.mnt_mounts) { while (1) { - if (p == root) + if (&p->mnt == root) return NULL; - next = p->mnt_child.next; - if (next != &p->mnt_parent->mnt_mounts) + next = p->mnt.mnt_child.next; + if (next != &p->mnt.mnt_parent->mnt_mounts) break; - p = p->mnt_parent; + p = real_mount(p->mnt.mnt_parent); } } - return list_entry(next, struct vfsmount, mnt_child); + return list_entry(next, struct mount, mnt.mnt_child); } -static struct vfsmount *skip_mnt_tree(struct vfsmount *p) +static struct mount *skip_mnt_tree(struct mount *p) { - struct list_head *prev = p->mnt_mounts.prev; - while (prev != &p->mnt_mounts) { - p = list_entry(prev, struct vfsmount, mnt_child); - prev = p->mnt_mounts.prev; + struct list_head *prev = p->mnt.mnt_mounts.prev; + while (prev != &p->mnt.mnt_mounts) { + p = list_entry(prev, struct mount, mnt.mnt_child); + prev = p->mnt.mnt_mounts.prev; } return p; } @@ -1144,12 +1144,13 @@ int may_umount_tree(struct vfsmount *mnt) { int actual_refs = 0; int minimum_refs = 0; - struct vfsmount *p; + struct mount *p; + BUG_ON(!mnt); /* write lock needed for mnt_get_count */ br_write_lock(vfsmount_lock); - for (p = mnt; p; p = next_mnt(p, mnt)) { - actual_refs += mnt_get_count(p); + for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) { + actual_refs += mnt_get_count(&p->mnt); minimum_refs += 2; } br_write_unlock(vfsmount_lock); @@ -1220,26 +1221,26 @@ void release_mounts(struct list_head *head) void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) { LIST_HEAD(tmp_list); - struct vfsmount *p; + struct mount *p; - for (p = mnt; p; p = next_mnt(p, mnt)) - list_move(&p->mnt_hash, &tmp_list); + for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) + list_move(&p->mnt.mnt_hash, &tmp_list); if (propagate) propagate_umount(&tmp_list); - list_for_each_entry(p, &tmp_list, mnt_hash) { - list_del_init(&p->mnt_expire); - list_del_init(&p->mnt_list); - __touch_mnt_namespace(p->mnt_ns); - p->mnt_ns = NULL; - __mnt_make_shortterm(p); - list_del_init(&p->mnt_child); - if (mnt_has_parent(p)) { - p->mnt_parent->mnt_ghosts++; - dentry_reset_mounted(p->mnt_mountpoint); + list_for_each_entry(p, &tmp_list, mnt.mnt_hash) { + list_del_init(&p->mnt.mnt_expire); + list_del_init(&p->mnt.mnt_list); + __touch_mnt_namespace(p->mnt.mnt_ns); + p->mnt.mnt_ns = NULL; + __mnt_make_shortterm(&p->mnt); + list_del_init(&p->mnt.mnt_child); + if (mnt_has_parent(&p->mnt)) { + p->mnt.mnt_parent->mnt_ghosts++; + dentry_reset_mounted(p->mnt.mnt_mountpoint); } - change_mnt_propagation(p, MS_PRIVATE); + change_mnt_propagation(&p->mnt, MS_PRIVATE); } list_splice(&tmp_list, kill); } @@ -1411,7 +1412,7 @@ static int mount_is_safe(struct path *path) struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, int flag) { - struct vfsmount *res, *p, *q, *r, *s; + struct vfsmount *res, *p, *q, *r; struct path path; if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt)) @@ -1424,19 +1425,20 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, p = mnt; list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) { + struct mount *s; if (!is_subdir(r->mnt_mountpoint, dentry)) continue; - for (s = r; s; s = next_mnt(s, r)) { - if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(s)) { + for (s = real_mount(r); s; s = next_mnt(s, r)) { + if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(&s->mnt)) { s = skip_mnt_tree(s); continue; } - while (p != s->mnt_parent) { + while (p != s->mnt.mnt_parent) { p = p->mnt_parent; q = q->mnt_parent; } - p = s; + p = &s->mnt; path.mnt = q; path.dentry = p->mnt_mountpoint; q = clone_mnt(p, p->mnt_root, flag); @@ -1497,23 +1499,23 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end) { - struct vfsmount *p; + struct mount *p; - for (p = mnt; p != end; p = next_mnt(p, mnt)) { - if (p->mnt_group_id && !IS_MNT_SHARED(p)) - mnt_release_group_id(p); + for (p = real_mount(mnt); &p->mnt != end; p = next_mnt(p, mnt)) { + if (p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) + mnt_release_group_id(&p->mnt); } } static int invent_group_ids(struct vfsmount *mnt, bool recurse) { - struct vfsmount *p; + struct mount *p; - for (p = mnt; p; p = recurse ? next_mnt(p, mnt) : NULL) { - if (!p->mnt_group_id && !IS_MNT_SHARED(p)) { - int err = mnt_alloc_group_id(p); + for (p = real_mount(mnt); p; p = recurse ? next_mnt(p, mnt) : NULL) { + if (!p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) { + int err = mnt_alloc_group_id(&p->mnt); if (err) { - cleanup_group_ids(mnt, p); + cleanup_group_ids(mnt, &p->mnt); return err; } } @@ -1591,7 +1593,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, LIST_HEAD(tree_list); struct vfsmount *dest_mnt = path->mnt; struct dentry *dest_dentry = path->dentry; - struct vfsmount *child, *p; + struct mount *child, *p; int err; if (IS_MNT_SHARED(dest_mnt)) { @@ -1606,8 +1608,8 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, br_write_lock(vfsmount_lock); if (IS_MNT_SHARED(dest_mnt)) { - for (p = source_mnt; p; p = next_mnt(p, source_mnt)) - set_mnt_shared(p); + for (p = real_mount(source_mnt); p; p = next_mnt(p, source_mnt)) + set_mnt_shared(&p->mnt); } if (parent_path) { detach_mnt(source_mnt, parent_path); @@ -1618,9 +1620,9 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, commit_tree(source_mnt); } - list_for_each_entry_safe(child, p, &tree_list, mnt_hash) { - list_del_init(&child->mnt_hash); - commit_tree(child); + list_for_each_entry_safe(child, p, &tree_list, mnt.mnt_hash) { + list_del_init(&child->mnt.mnt_hash); + commit_tree(&child->mnt); } br_write_unlock(vfsmount_lock); @@ -1697,7 +1699,8 @@ static int flags_to_propagation_type(int flags) */ static int do_change_type(struct path *path, int flag) { - struct vfsmount *m, *mnt = path->mnt; + struct mount *m; + struct vfsmount *mnt = path->mnt; int recurse = flag & MS_REC; int type; int err = 0; @@ -1720,8 +1723,8 @@ static int do_change_type(struct path *path, int flag) } br_write_lock(vfsmount_lock); - for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) - change_mnt_propagation(m, type); + for (m = real_mount(mnt); m; m = (recurse ? next_mnt(m, mnt) : NULL)) + change_mnt_propagation(&m->mnt, type); br_write_unlock(vfsmount_lock); out_unlock: @@ -1844,9 +1847,9 @@ static int do_remount(struct path *path, int flags, int mnt_flags, static inline int tree_contains_unbindable(struct vfsmount *mnt) { - struct vfsmount *p; - for (p = mnt; p; p = next_mnt(p, mnt)) { - if (IS_MNT_UNBINDABLE(p)) + struct mount *p; + for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) { + if (IS_MNT_UNBINDABLE(&p->mnt)) return 1; } return 0; @@ -2379,7 +2382,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, { struct mnt_namespace *new_ns; struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; - struct vfsmount *p, *q; + struct mount *p, *q; new_ns = alloc_mnt_ns(); if (IS_ERR(new_ns)) @@ -2403,23 +2406,23 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, * as belonging to new namespace. We have already acquired a private * fs_struct, so tsk->fs->lock is not needed. */ - p = mnt_ns->root; - q = new_ns->root; + p = real_mount(mnt_ns->root); + q = real_mount(new_ns->root); while (p) { - q->mnt_ns = new_ns; - __mnt_make_longterm(q); + q->mnt.mnt_ns = new_ns; + __mnt_make_longterm(&q->mnt); if (fs) { - if (p == fs->root.mnt) { - fs->root.mnt = mntget(q); - __mnt_make_longterm(q); - mnt_make_shortterm(p); - rootmnt = p; + if (&p->mnt == fs->root.mnt) { + fs->root.mnt = mntget(&q->mnt); + __mnt_make_longterm(&q->mnt); + mnt_make_shortterm(&p->mnt); + rootmnt = &p->mnt; } - if (p == fs->pwd.mnt) { - fs->pwd.mnt = mntget(q); - __mnt_make_longterm(q); - mnt_make_shortterm(p); - pwdmnt = p; + if (&p->mnt == fs->pwd.mnt) { + fs->pwd.mnt = mntget(&q->mnt); + __mnt_make_longterm(&q->mnt); + mnt_make_shortterm(&p->mnt); + pwdmnt = &p->mnt; } } p = next_mnt(p, mnt_ns->root); From 419148da6e76dd0d379b5ec33c461cee1015322e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 19:41:16 -0500 Subject: [PATCH 111/165] vfs: spread struct mount - attach_mnt/detach_mnt Signed-off-by: Al Viro --- fs/namespace.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 7226dc514b3b..444557e04b38 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -556,14 +556,14 @@ static void dentry_reset_mounted(struct dentry *dentry) /* * vfsmount lock must be held for write */ -static void detach_mnt(struct vfsmount *mnt, struct path *old_path) +static void detach_mnt(struct mount *mnt, struct path *old_path) { - old_path->dentry = mnt->mnt_mountpoint; - old_path->mnt = mnt->mnt_parent; - mnt->mnt_parent = mnt; - mnt->mnt_mountpoint = mnt->mnt_root; - list_del_init(&mnt->mnt_child); - list_del_init(&mnt->mnt_hash); + old_path->dentry = mnt->mnt.mnt_mountpoint; + old_path->mnt = mnt->mnt.mnt_parent; + mnt->mnt.mnt_parent = &mnt->mnt; + mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; + list_del_init(&mnt->mnt.mnt_child); + list_del_init(&mnt->mnt.mnt_hash); dentry_reset_mounted(old_path->dentry); } @@ -583,12 +583,12 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, /* * vfsmount lock must be held for write */ -static void attach_mnt(struct vfsmount *mnt, struct path *path) +static void attach_mnt(struct mount *mnt, struct path *path) { - mnt_set_mountpoint(path->mnt, path->dentry, mnt); - list_add_tail(&mnt->mnt_hash, mount_hashtable + + mnt_set_mountpoint(path->mnt, path->dentry, &mnt->mnt); + list_add_tail(&mnt->mnt.mnt_hash, mount_hashtable + hash(path->mnt, path->dentry)); - list_add_tail(&mnt->mnt_child, &path->mnt->mnt_mounts); + list_add_tail(&mnt->mnt.mnt_child, &path->mnt->mnt_mounts); } static inline void __mnt_make_longterm(struct vfsmount *mnt) @@ -1446,7 +1446,7 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, goto Enomem; br_write_lock(vfsmount_lock); list_add_tail(&q->mnt_list, &res->mnt_list); - attach_mnt(q, &path); + attach_mnt(real_mount(q), &path); br_write_unlock(vfsmount_lock); } } @@ -1612,8 +1612,8 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, set_mnt_shared(&p->mnt); } if (parent_path) { - detach_mnt(source_mnt, parent_path); - attach_mnt(source_mnt, path); + detach_mnt(real_mount(source_mnt), parent_path); + attach_mnt(real_mount(source_mnt), path); touch_mnt_namespace(parent_path->mnt->mnt_ns); } else { mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); @@ -2600,6 +2600,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, const char __user *, put_old) { struct path new, old, parent_path, root_parent, root; + struct mount *new_mnt, *root_mnt; int error; if (!capable(CAP_SYS_ADMIN)) @@ -2623,6 +2624,8 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, goto out3; error = -EINVAL; + new_mnt = real_mount(new.mnt); + root_mnt = real_mount(root.mnt); if (IS_MNT_SHARED(old.mnt) || IS_MNT_SHARED(new.mnt->mnt_parent) || IS_MNT_SHARED(root.mnt->mnt_parent)) @@ -2651,12 +2654,12 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, if (!is_path_reachable(old.mnt, old.dentry, &new)) goto out4; br_write_lock(vfsmount_lock); - detach_mnt(new.mnt, &parent_path); - detach_mnt(root.mnt, &root_parent); + detach_mnt(new_mnt, &parent_path); + detach_mnt(root_mnt, &root_parent); /* mount old root on put_old */ - attach_mnt(root.mnt, &old); + attach_mnt(root_mnt, &old); /* mount new_root on / */ - attach_mnt(new.mnt, &root_parent); + attach_mnt(new_mnt, &root_parent); touch_mnt_namespace(current->nsproxy->mnt_ns); br_write_unlock(vfsmount_lock); chroot_fs_refs(&root, &new); From 4b2619a571f9fbb46649f968eea284103734f718 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 19:47:15 -0500 Subject: [PATCH 112/165] vfs: spread struct mount - commit_tree Signed-off-by: Al Viro --- fs/namespace.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 444557e04b38..fad3b218679d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -609,16 +609,16 @@ static inline void __mnt_make_shortterm(struct vfsmount *mnt) /* * vfsmount lock must be held for write */ -static void commit_tree(struct vfsmount *mnt) +static void commit_tree(struct mount *mnt) { - struct vfsmount *parent = mnt->mnt_parent; + struct vfsmount *parent = mnt->mnt.mnt_parent; struct vfsmount *m; LIST_HEAD(head); struct mnt_namespace *n = parent->mnt_ns; - BUG_ON(parent == mnt); + BUG_ON(parent == &mnt->mnt); - list_add_tail(&head, &mnt->mnt_list); + list_add_tail(&head, &mnt->mnt.mnt_list); list_for_each_entry(m, &head, mnt_list) { m->mnt_ns = n; __mnt_make_longterm(m); @@ -626,9 +626,9 @@ static void commit_tree(struct vfsmount *mnt) list_splice(&head, n->list.prev); - list_add_tail(&mnt->mnt_hash, mount_hashtable + - hash(parent, mnt->mnt_mountpoint)); - list_add_tail(&mnt->mnt_child, &parent->mnt_mounts); + list_add_tail(&mnt->mnt.mnt_hash, mount_hashtable + + hash(parent, mnt->mnt.mnt_mountpoint)); + list_add_tail(&mnt->mnt.mnt_child, &parent->mnt_mounts); touch_mnt_namespace(n); } @@ -1617,12 +1617,12 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, touch_mnt_namespace(parent_path->mnt->mnt_ns); } else { mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); - commit_tree(source_mnt); + commit_tree(real_mount(source_mnt)); } list_for_each_entry_safe(child, p, &tree_list, mnt.mnt_hash) { list_del_init(&child->mnt.mnt_hash); - commit_tree(&child->mnt); + commit_tree(child); } br_write_unlock(vfsmount_lock); From 4b8b21f4fe16ee15eec5c69ea5fb41b30e428e59 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 19:54:23 -0500 Subject: [PATCH 113/165] vfs: spread struct mount - mount group id handling Signed-off-by: Al Viro --- fs/namespace.c | 36 ++++++++++++++++++------------------ fs/pnode.c | 2 +- fs/pnode.h | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index fad3b218679d..60d5c15c0879 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -110,7 +110,7 @@ static void mnt_free_id(struct vfsmount *mnt) * * mnt_group_ida is protected by namespace_sem */ -static int mnt_alloc_group_id(struct vfsmount *mnt) +static int mnt_alloc_group_id(struct mount *mnt) { int res; @@ -119,9 +119,9 @@ static int mnt_alloc_group_id(struct vfsmount *mnt) res = ida_get_new_above(&mnt_group_ida, mnt_group_start, - &mnt->mnt_group_id); + &mnt->mnt.mnt_group_id); if (!res) - mnt_group_start = mnt->mnt_group_id + 1; + mnt_group_start = mnt->mnt.mnt_group_id + 1; return res; } @@ -129,13 +129,13 @@ static int mnt_alloc_group_id(struct vfsmount *mnt) /* * Release a peer group ID */ -void mnt_release_group_id(struct vfsmount *mnt) +void mnt_release_group_id(struct mount *mnt) { - int id = mnt->mnt_group_id; + int id = mnt->mnt.mnt_group_id; ida_remove(&mnt_group_ida, id); if (mnt_group_start > id) mnt_group_start = id; - mnt->mnt_group_id = 0; + mnt->mnt.mnt_group_id = 0; } /* @@ -701,7 +701,7 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, mnt->mnt_group_id = old->mnt_group_id; if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) { - int err = mnt_alloc_group_id(mnt); + int err = mnt_alloc_group_id(real_mount(mnt)); if (err) goto out_free; } @@ -1497,25 +1497,25 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, return 0; } -static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end) +static void cleanup_group_ids(struct mount *mnt, struct mount *end) { struct mount *p; - for (p = real_mount(mnt); &p->mnt != end; p = next_mnt(p, mnt)) { + for (p = mnt; p != end; p = next_mnt(p, &mnt->mnt)) { if (p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) - mnt_release_group_id(&p->mnt); + mnt_release_group_id(p); } } -static int invent_group_ids(struct vfsmount *mnt, bool recurse) +static int invent_group_ids(struct mount *mnt, bool recurse) { struct mount *p; - for (p = real_mount(mnt); p; p = recurse ? next_mnt(p, mnt) : NULL) { + for (p = mnt; p; p = recurse ? next_mnt(p, &mnt->mnt) : NULL) { if (!p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) { - int err = mnt_alloc_group_id(&p->mnt); + int err = mnt_alloc_group_id(p); if (err) { - cleanup_group_ids(mnt, &p->mnt); + cleanup_group_ids(mnt, p); return err; } } @@ -1597,7 +1597,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, int err; if (IS_MNT_SHARED(dest_mnt)) { - err = invent_group_ids(source_mnt, true); + err = invent_group_ids(real_mount(source_mnt), true); if (err) goto out; } @@ -1630,7 +1630,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, out_cleanup_ids: if (IS_MNT_SHARED(dest_mnt)) - cleanup_group_ids(source_mnt, NULL); + cleanup_group_ids(real_mount(source_mnt), NULL); out: return err; } @@ -1700,7 +1700,7 @@ static int flags_to_propagation_type(int flags) static int do_change_type(struct path *path, int flag) { struct mount *m; - struct vfsmount *mnt = path->mnt; + struct mount *mnt = real_mount(path->mnt); int recurse = flag & MS_REC; int type; int err = 0; @@ -1723,7 +1723,7 @@ static int do_change_type(struct path *path, int flag) } br_write_lock(vfsmount_lock); - for (m = real_mount(mnt); m; m = (recurse ? next_mnt(m, mnt) : NULL)) + for (m = mnt; m; m = (recurse ? next_mnt(m, &mnt->mnt) : NULL)) change_mnt_propagation(&m->mnt, type); br_write_unlock(vfsmount_lock); diff --git a/fs/pnode.c b/fs/pnode.c index ae5b1bda31ba..a824a097b523 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -83,7 +83,7 @@ static int do_make_slave(struct vfsmount *mnt) peer_mnt = NULL; } if (IS_MNT_SHARED(mnt) && list_empty(&mnt->mnt_share)) - mnt_release_group_id(mnt); + mnt_release_group_id(real_mount(mnt)); list_del_init(&mnt->mnt_share); mnt->mnt_group_id = 0; diff --git a/fs/pnode.h b/fs/pnode.h index 5c234e742193..23dfe22139da 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -34,7 +34,7 @@ int propagate_mnt(struct vfsmount *, struct dentry *, struct vfsmount *, struct list_head *); int propagate_umount(struct list_head *); int propagate_mount_busy(struct vfsmount *, int); -void mnt_release_group_id(struct vfsmount *); +void mnt_release_group_id(struct mount *); int get_dominating_id(struct vfsmount *mnt, const struct path *root); unsigned int mnt_get_count(struct vfsmount *mnt); void mnt_set_mountpoint(struct vfsmount *, struct dentry *, From 0fb54e50562d8d6f4b1a4517ba9783a9c7c5c2b7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 19:59:16 -0500 Subject: [PATCH 114/165] vfs: spread struct mount - attach_recursive_mnt Signed-off-by: Al Viro --- fs/namespace.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 60d5c15c0879..64ae40c91079 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1587,7 +1587,7 @@ static int invent_group_ids(struct mount *mnt, bool recurse) * Must be called without spinlocks held, since this function can sleep * in allocations. */ -static int attach_recursive_mnt(struct vfsmount *source_mnt, +static int attach_recursive_mnt(struct mount *source_mnt, struct path *path, struct path *parent_path) { LIST_HEAD(tree_list); @@ -1597,27 +1597,27 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, int err; if (IS_MNT_SHARED(dest_mnt)) { - err = invent_group_ids(real_mount(source_mnt), true); + err = invent_group_ids(source_mnt, true); if (err) goto out; } - err = propagate_mnt(dest_mnt, dest_dentry, source_mnt, &tree_list); + err = propagate_mnt(dest_mnt, dest_dentry, &source_mnt->mnt, &tree_list); if (err) goto out_cleanup_ids; br_write_lock(vfsmount_lock); if (IS_MNT_SHARED(dest_mnt)) { - for (p = real_mount(source_mnt); p; p = next_mnt(p, source_mnt)) + for (p = source_mnt; p; p = next_mnt(p, &source_mnt->mnt)) set_mnt_shared(&p->mnt); } if (parent_path) { - detach_mnt(real_mount(source_mnt), parent_path); - attach_mnt(real_mount(source_mnt), path); + detach_mnt(source_mnt, parent_path); + attach_mnt(source_mnt, path); touch_mnt_namespace(parent_path->mnt->mnt_ns); } else { - mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); - commit_tree(real_mount(source_mnt)); + mnt_set_mountpoint(dest_mnt, dest_dentry, &source_mnt->mnt); + commit_tree(source_mnt); } list_for_each_entry_safe(child, p, &tree_list, mnt.mnt_hash) { @@ -1630,7 +1630,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, out_cleanup_ids: if (IS_MNT_SHARED(dest_mnt)) - cleanup_group_ids(real_mount(source_mnt), NULL); + cleanup_group_ids(source_mnt, NULL); out: return err; } @@ -1674,7 +1674,7 @@ static int graft_tree(struct vfsmount *mnt, struct path *path) if (d_unlinked(path->dentry)) return -ENOENT; - return attach_recursive_mnt(mnt, path, NULL); + return attach_recursive_mnt(real_mount(mnt), path, NULL); } /* @@ -1859,6 +1859,7 @@ static int do_move_mount(struct path *path, char *old_name) { struct path old_path, parent_path; struct vfsmount *p; + struct mount *old; int err = 0; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -1883,6 +1884,8 @@ static int do_move_mount(struct path *path, char *old_name) if (old_path.dentry != old_path.mnt->mnt_root) goto out1; + old = real_mount(old_path.mnt); + if (!mnt_has_parent(old_path.mnt)) goto out1; @@ -1906,7 +1909,7 @@ static int do_move_mount(struct path *path, char *old_name) if (p == old_path.mnt) goto out1; - err = attach_recursive_mnt(old_path.mnt, path, &parent_path); + err = attach_recursive_mnt(old, path, &parent_path); if (err) goto out1; From cbbe362cd68441edf1ebbafeea1c8e09cce4a7f9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 20:01:19 -0500 Subject: [PATCH 115/165] vfs: spread struct mount - tree_contains_unbindable Signed-off-by: Al Viro --- fs/namespace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 64ae40c91079..91bd15d9b2cd 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1845,10 +1845,10 @@ static int do_remount(struct path *path, int flags, int mnt_flags, return err; } -static inline int tree_contains_unbindable(struct vfsmount *mnt) +static inline int tree_contains_unbindable(struct mount *mnt) { struct mount *p; - for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) { + for (p = mnt; p; p = next_mnt(p, &mnt->mnt)) { if (IS_MNT_UNBINDABLE(&p->mnt)) return 1; } @@ -1902,7 +1902,7 @@ static int do_move_mount(struct path *path, char *old_name) * mount which is shared. */ if (IS_MNT_SHARED(path->mnt) && - tree_contains_unbindable(old_path.mnt)) + tree_contains_unbindable(old)) goto out1; err = -ELOOP; for (p = path->mnt; mnt_has_parent(p); p = p->mnt_parent) From b105e270b4e9419f4b9536f6862b1b32985bc9d2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 20:38:33 -0500 Subject: [PATCH 116/165] vfs: spread struct mount - alloc_vfsmnt/free_vfsmnt/mnt_alloc_id/mnt_free_id Signed-off-by: Al Viro --- fs/namespace.c | 81 +++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 91bd15d9b2cd..98b49351fbde 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -78,16 +78,16 @@ static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) * allocation is serialized by namespace_sem, but we need the spinlock to * serialize with freeing. */ -static int mnt_alloc_id(struct vfsmount *mnt) +static int mnt_alloc_id(struct mount *mnt) { int res; retry: ida_pre_get(&mnt_id_ida, GFP_KERNEL); spin_lock(&mnt_id_lock); - res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt_id); + res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt.mnt_id); if (!res) - mnt_id_start = mnt->mnt_id + 1; + mnt_id_start = mnt->mnt.mnt_id + 1; spin_unlock(&mnt_id_lock); if (res == -EAGAIN) goto retry; @@ -95,9 +95,9 @@ retry: return res; } -static void mnt_free_id(struct vfsmount *mnt) +static void mnt_free_id(struct mount *mnt) { - int id = mnt->mnt_id; + int id = mnt->mnt.mnt_id; spin_lock(&mnt_id_lock); ida_remove(&mnt_id_ida, id); if (mnt_id_start > id) @@ -171,14 +171,14 @@ unsigned int mnt_get_count(struct vfsmount *mnt) #endif } -static struct vfsmount *alloc_vfsmnt(const char *name) +static struct mount *alloc_vfsmnt(const char *name) { struct mount *p = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); if (p) { struct vfsmount *mnt = &p->mnt; int err; - err = mnt_alloc_id(mnt); + err = mnt_alloc_id(p); if (err) goto out_free_cache; @@ -211,14 +211,14 @@ static struct vfsmount *alloc_vfsmnt(const char *name) INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks); #endif } - return &p->mnt; + return p; #ifdef CONFIG_SMP out_free_devname: kfree(p->mnt.mnt_devname); #endif out_free_id: - mnt_free_id(&p->mnt); + mnt_free_id(p); out_free_cache: kmem_cache_free(mnt_cache, p); return NULL; @@ -448,15 +448,14 @@ static void __mnt_unmake_readonly(struct vfsmount *mnt) br_write_unlock(vfsmount_lock); } -static void free_vfsmnt(struct vfsmount *mnt) +static void free_vfsmnt(struct mount *mnt) { - struct mount *p = real_mount(mnt); - kfree(mnt->mnt_devname); + kfree(mnt->mnt.mnt_devname); mnt_free_id(mnt); #ifdef CONFIG_SMP - free_percpu(mnt->mnt_pcp); + free_percpu(mnt->mnt.mnt_pcp); #endif - kmem_cache_free(mnt_cache, p); + kmem_cache_free(mnt_cache, mnt); } /* @@ -661,7 +660,7 @@ static struct mount *skip_mnt_tree(struct mount *p) struct vfsmount * vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) { - struct vfsmount *mnt; + struct mount *mnt; struct dentry *root; if (!type) @@ -672,7 +671,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void return ERR_PTR(-ENOMEM); if (flags & MS_KERNMOUNT) - mnt->mnt_flags = MNT_INTERNAL; + mnt->mnt.mnt_flags = MNT_INTERNAL; root = mount_fs(type, flags, name, data); if (IS_ERR(root)) { @@ -680,11 +679,11 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void return ERR_CAST(root); } - mnt->mnt_root = root; - mnt->mnt_sb = root->d_sb; - mnt->mnt_mountpoint = mnt->mnt_root; - mnt->mnt_parent = mnt; - return mnt; + mnt->mnt.mnt_root = root; + mnt->mnt.mnt_sb = root->d_sb; + mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt.mnt_parent = &mnt->mnt; + return &mnt->mnt; } EXPORT_SYMBOL_GPL(vfs_kern_mount); @@ -692,49 +691,49 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, int flag) { struct super_block *sb = old->mnt_sb; - struct vfsmount *mnt = alloc_vfsmnt(old->mnt_devname); + struct mount *mnt = alloc_vfsmnt(old->mnt_devname); if (mnt) { if (flag & (CL_SLAVE | CL_PRIVATE)) - mnt->mnt_group_id = 0; /* not a peer of original */ + mnt->mnt.mnt_group_id = 0; /* not a peer of original */ else - mnt->mnt_group_id = old->mnt_group_id; + mnt->mnt.mnt_group_id = old->mnt_group_id; - if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) { - int err = mnt_alloc_group_id(real_mount(mnt)); + if ((flag & CL_MAKE_SHARED) && !mnt->mnt.mnt_group_id) { + int err = mnt_alloc_group_id(mnt); if (err) goto out_free; } - mnt->mnt_flags = old->mnt_flags & ~MNT_WRITE_HOLD; + mnt->mnt.mnt_flags = old->mnt_flags & ~MNT_WRITE_HOLD; atomic_inc(&sb->s_active); - mnt->mnt_sb = sb; - mnt->mnt_root = dget(root); - mnt->mnt_mountpoint = mnt->mnt_root; - mnt->mnt_parent = mnt; + mnt->mnt.mnt_sb = sb; + mnt->mnt.mnt_root = dget(root); + mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt.mnt_parent = &mnt->mnt; if (flag & CL_SLAVE) { - list_add(&mnt->mnt_slave, &old->mnt_slave_list); - mnt->mnt_master = old; - CLEAR_MNT_SHARED(mnt); + list_add(&mnt->mnt.mnt_slave, &old->mnt_slave_list); + mnt->mnt.mnt_master = old; + CLEAR_MNT_SHARED(&mnt->mnt); } else if (!(flag & CL_PRIVATE)) { if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) - list_add(&mnt->mnt_share, &old->mnt_share); + list_add(&mnt->mnt.mnt_share, &old->mnt_share); if (IS_MNT_SLAVE(old)) - list_add(&mnt->mnt_slave, &old->mnt_slave); - mnt->mnt_master = old->mnt_master; + list_add(&mnt->mnt.mnt_slave, &old->mnt_slave); + mnt->mnt.mnt_master = old->mnt_master; } if (flag & CL_MAKE_SHARED) - set_mnt_shared(mnt); + set_mnt_shared(&mnt->mnt); /* stick the duplicate mount on the same expiry list * as the original if that was on one */ if (flag & CL_EXPIRE) { if (!list_empty(&old->mnt_expire)) - list_add(&mnt->mnt_expire, &old->mnt_expire); + list_add(&mnt->mnt.mnt_expire, &old->mnt_expire); } } - return mnt; + return &mnt->mnt; out_free: free_vfsmnt(mnt); @@ -758,7 +757,7 @@ static inline void mntfree(struct vfsmount *mnt) WARN_ON(mnt_get_writers(mnt)); fsnotify_vfsmount_delete(mnt); dput(mnt->mnt_root); - free_vfsmnt(mnt); + free_vfsmnt(real_mount(mnt)); deactivate_super(sb); } From 0f0afb1dcf01afc44581b3c0da251ac07dfb6e4a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 20:43:10 -0500 Subject: [PATCH 117/165] vfs: spread struct mount - change_mnt_propagation/set_mnt_shared Signed-off-by: Al Viro --- fs/namespace.c | 8 ++++---- fs/pnode.c | 12 ++++++------ fs/pnode.h | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 98b49351fbde..c7fa75f0fd92 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -724,7 +724,7 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, mnt->mnt.mnt_master = old->mnt_master; } if (flag & CL_MAKE_SHARED) - set_mnt_shared(&mnt->mnt); + set_mnt_shared(mnt); /* stick the duplicate mount on the same expiry list * as the original if that was on one */ @@ -1239,7 +1239,7 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) p->mnt.mnt_parent->mnt_ghosts++; dentry_reset_mounted(p->mnt.mnt_mountpoint); } - change_mnt_propagation(&p->mnt, MS_PRIVATE); + change_mnt_propagation(p, MS_PRIVATE); } list_splice(&tmp_list, kill); } @@ -1608,7 +1608,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, if (IS_MNT_SHARED(dest_mnt)) { for (p = source_mnt; p; p = next_mnt(p, &source_mnt->mnt)) - set_mnt_shared(&p->mnt); + set_mnt_shared(p); } if (parent_path) { detach_mnt(source_mnt, parent_path); @@ -1723,7 +1723,7 @@ static int do_change_type(struct path *path, int flag) br_write_lock(vfsmount_lock); for (m = mnt; m; m = (recurse ? next_mnt(m, &mnt->mnt) : NULL)) - change_mnt_propagation(&m->mnt, type); + change_mnt_propagation(m, type); br_write_unlock(vfsmount_lock); out_unlock: diff --git a/fs/pnode.c b/fs/pnode.c index a824a097b523..4bd3721867a7 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -114,20 +114,20 @@ static int do_make_slave(struct vfsmount *mnt) /* * vfsmount lock must be held for write */ -void change_mnt_propagation(struct vfsmount *mnt, int type) +void change_mnt_propagation(struct mount *mnt, int type) { if (type == MS_SHARED) { set_mnt_shared(mnt); return; } - do_make_slave(mnt); + do_make_slave(&mnt->mnt); if (type != MS_SLAVE) { - list_del_init(&mnt->mnt_slave); - mnt->mnt_master = NULL; + list_del_init(&mnt->mnt.mnt_slave); + mnt->mnt.mnt_master = NULL; if (type == MS_UNBINDABLE) - mnt->mnt_flags |= MNT_UNBINDABLE; + mnt->mnt.mnt_flags |= MNT_UNBINDABLE; else - mnt->mnt_flags &= ~MNT_UNBINDABLE; + mnt->mnt.mnt_flags &= ~MNT_UNBINDABLE; } } diff --git a/fs/pnode.h b/fs/pnode.h index 23dfe22139da..a2ad95435c48 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -23,13 +23,13 @@ #define CL_MAKE_SHARED 0x08 #define CL_PRIVATE 0x10 -static inline void set_mnt_shared(struct vfsmount *mnt) +static inline void set_mnt_shared(struct mount *mnt) { - mnt->mnt_flags &= ~MNT_SHARED_MASK; - mnt->mnt_flags |= MNT_SHARED; + mnt->mnt.mnt_flags &= ~MNT_SHARED_MASK; + mnt->mnt.mnt_flags |= MNT_SHARED; } -void change_mnt_propagation(struct vfsmount *, int); +void change_mnt_propagation(struct mount *, int); int propagate_mnt(struct vfsmount *, struct dentry *, struct vfsmount *, struct list_head *); int propagate_umount(struct list_head *); From cb338d06e9716c92d5a7855e7c67b8f111ced722 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 20:55:08 -0500 Subject: [PATCH 118/165] vfs: spread struct mount - clone_mnt/copy_tree result Signed-off-by: Al Viro --- fs/namespace.c | 39 +++++++++++++++++++++------------------ fs/pnode.c | 15 ++++++++------- fs/pnode.h | 2 +- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index c7fa75f0fd92..6051a034db96 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -687,7 +687,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void } EXPORT_SYMBOL_GPL(vfs_kern_mount); -static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, +static struct mount *clone_mnt(struct vfsmount *old, struct dentry *root, int flag) { struct super_block *sb = old->mnt_sb; @@ -733,7 +733,7 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root, list_add(&mnt->mnt.mnt_expire, &old->mnt_expire); } } - return &mnt->mnt; + return mnt; out_free: free_vfsmnt(mnt); @@ -1408,10 +1408,11 @@ static int mount_is_safe(struct path *path) #endif } -struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, +struct mount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, int flag) { - struct vfsmount *res, *p, *q, *r; + struct mount *res, *q; + struct vfsmount *p, *r; struct path path; if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt)) @@ -1420,7 +1421,7 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, res = q = clone_mnt(mnt, dentry, flag); if (!q) goto Enomem; - q->mnt_mountpoint = mnt->mnt_mountpoint; + q->mnt.mnt_mountpoint = mnt->mnt_mountpoint; p = mnt; list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) { @@ -1435,17 +1436,17 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, } while (p != s->mnt.mnt_parent) { p = p->mnt_parent; - q = q->mnt_parent; + q = real_mount(q->mnt.mnt_parent); } p = &s->mnt; - path.mnt = q; + path.mnt = &q->mnt; path.dentry = p->mnt_mountpoint; q = clone_mnt(p, p->mnt_root, flag); if (!q) goto Enomem; br_write_lock(vfsmount_lock); - list_add_tail(&q->mnt_list, &res->mnt_list); - attach_mnt(real_mount(q), &path); + list_add_tail(&q->mnt.mnt_list, &res->mnt.mnt_list); + attach_mnt(q, &path); br_write_unlock(vfsmount_lock); } } @@ -1454,7 +1455,7 @@ Enomem: if (res) { LIST_HEAD(umount_list); br_write_lock(vfsmount_lock); - umount_tree(res, 0, &umount_list); + umount_tree(&res->mnt, 0, &umount_list); br_write_unlock(vfsmount_lock); release_mounts(&umount_list); } @@ -1463,11 +1464,11 @@ Enomem: struct vfsmount *collect_mounts(struct path *path) { - struct vfsmount *tree; + struct mount *tree; down_write(&namespace_sem); tree = copy_tree(path->mnt, path->dentry, CL_COPY_ALL | CL_PRIVATE); up_write(&namespace_sem); - return tree; + return tree ? &tree->mnt : NULL; } void drop_collected_mounts(struct vfsmount *mnt) @@ -1739,7 +1740,7 @@ static int do_loopback(struct path *path, char *old_name, { LIST_HEAD(umount_list); struct path old_path; - struct vfsmount *mnt = NULL; + struct mount *mnt = NULL; int err = mount_is_safe(path); if (err) return err; @@ -1769,10 +1770,10 @@ static int do_loopback(struct path *path, char *old_name, if (!mnt) goto out2; - err = graft_tree(mnt, path); + err = graft_tree(&mnt->mnt, path); if (err) { br_write_lock(vfsmount_lock); - umount_tree(mnt, 0, &umount_list); + umount_tree(&mnt->mnt, 0, &umount_list); br_write_unlock(vfsmount_lock); } out2: @@ -2385,6 +2386,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, struct mnt_namespace *new_ns; struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; struct mount *p, *q; + struct mount *new; new_ns = alloc_mnt_ns(); if (IS_ERR(new_ns)) @@ -2392,13 +2394,14 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, down_write(&namespace_sem); /* First pass: copy the tree topology */ - new_ns->root = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root, + new = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root, CL_COPY_ALL | CL_EXPIRE); - if (!new_ns->root) { + if (!new) { up_write(&namespace_sem); kfree(new_ns); return ERR_PTR(-ENOMEM); } + new_ns->root = &new->mnt; br_write_lock(vfsmount_lock); list_add_tail(&new_ns->list, &new_ns->root->mnt_list); br_write_unlock(vfsmount_lock); @@ -2409,7 +2412,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, * fs_struct, so tsk->fs->lock is not needed. */ p = real_mount(mnt_ns->root); - q = real_mount(new_ns->root); + q = new; while (p) { q->mnt.mnt_ns = new_ns; __mnt_make_longterm(&q->mnt); diff --git a/fs/pnode.c b/fs/pnode.c index 4bd3721867a7..916c8e87cf4e 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -221,7 +221,8 @@ static struct vfsmount *get_source(struct vfsmount *dest, int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, struct vfsmount *source_mnt, struct list_head *tree_list) { - struct vfsmount *m, *child; + struct vfsmount *m; + struct mount *child; int ret = 0; struct vfsmount *prev_dest_mnt = dest_mnt; struct vfsmount *prev_src_mnt = source_mnt; @@ -245,23 +246,23 @@ int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, } if (is_subdir(dest_dentry, m->mnt_root)) { - mnt_set_mountpoint(m, dest_dentry, child); - list_add_tail(&child->mnt_hash, tree_list); + mnt_set_mountpoint(m, dest_dentry, &child->mnt); + list_add_tail(&child->mnt.mnt_hash, tree_list); } else { /* * This can happen if the parent mount was bind mounted * on some subdirectory of a shared/slave mount. */ - list_add_tail(&child->mnt_hash, &tmp_list); + list_add_tail(&child->mnt.mnt_hash, &tmp_list); } prev_dest_mnt = m; - prev_src_mnt = child; + prev_src_mnt = &child->mnt; } out: br_write_lock(vfsmount_lock); while (!list_empty(&tmp_list)) { - child = list_first_entry(&tmp_list, struct vfsmount, mnt_hash); - umount_tree(child, 0, &umount_list); + child = list_first_entry(&tmp_list, struct mount, mnt.mnt_hash); + umount_tree(&child->mnt, 0, &umount_list); } br_write_unlock(vfsmount_lock); release_mounts(&umount_list); diff --git a/fs/pnode.h b/fs/pnode.h index a2ad95435c48..ed8a84d6d78f 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -41,7 +41,7 @@ void mnt_set_mountpoint(struct vfsmount *, struct dentry *, struct vfsmount *); void release_mounts(struct list_head *); void umount_tree(struct vfsmount *, int, struct list_head *); -struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int); +struct mount *copy_tree(struct vfsmount *, struct dentry *, int); bool is_path_reachable(struct vfsmount *, struct dentry *, const struct path *root); #endif /* _LINUX_PNODE_H */ From d5e50f74dd2ed6dd1bb4bf6fe58e5a7de4b77953 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 20:58:57 -0500 Subject: [PATCH 119/165] vfs: spread struct mount to remaining users of ->mnt_hash Signed-off-by: Al Viro --- fs/namespace.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 6051a034db96..76412348d5be 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -199,7 +199,7 @@ static struct mount *alloc_vfsmnt(const char *name) mnt->mnt_writers = 0; #endif - INIT_LIST_HEAD(&mnt->mnt_hash); + INIT_LIST_HEAD(&p->mnt.mnt_hash); INIT_LIST_HEAD(&mnt->mnt_child); INIT_LIST_HEAD(&mnt->mnt_mounts); INIT_LIST_HEAD(&mnt->mnt_list); @@ -540,10 +540,10 @@ static void dentry_reset_mounted(struct dentry *dentry) unsigned u; for (u = 0; u < HASH_SIZE; u++) { - struct vfsmount *p; + struct mount *p; - list_for_each_entry(p, &mount_hashtable[u], mnt_hash) { - if (p->mnt_mountpoint == dentry) + list_for_each_entry(p, &mount_hashtable[u], mnt.mnt_hash) { + if (p->mnt.mnt_mountpoint == dentry) return; } } @@ -1191,25 +1191,25 @@ EXPORT_SYMBOL(may_umount); void release_mounts(struct list_head *head) { - struct vfsmount *mnt; + struct mount *mnt; while (!list_empty(head)) { - mnt = list_first_entry(head, struct vfsmount, mnt_hash); - list_del_init(&mnt->mnt_hash); - if (mnt_has_parent(mnt)) { + mnt = list_first_entry(head, struct mount, mnt.mnt_hash); + list_del_init(&mnt->mnt.mnt_hash); + if (mnt_has_parent(&mnt->mnt)) { struct dentry *dentry; struct vfsmount *m; br_write_lock(vfsmount_lock); - dentry = mnt->mnt_mountpoint; - m = mnt->mnt_parent; - mnt->mnt_mountpoint = mnt->mnt_root; - mnt->mnt_parent = mnt; + dentry = mnt->mnt.mnt_mountpoint; + m = mnt->mnt.mnt_parent; + mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt.mnt_parent = &mnt->mnt; m->mnt_ghosts--; br_write_unlock(vfsmount_lock); dput(dentry); mntput(m); } - mntput(mnt); + mntput(&mnt->mnt); } } From 1b8e5564b9d34cbeb3047dd2be8ec9cd5e2785e2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 21:01:32 -0500 Subject: [PATCH 120/165] vfs: the first spoils - mnt_hash moved taken out of struct vfsmount into struct mount Signed-off-by: Al Viro --- fs/mount.h | 1 + fs/namespace.c | 24 ++++++++++++------------ fs/pnode.c | 10 +++++----- include/linux/mount.h | 1 - 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 44e5b6f54b7e..831e7c86835b 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -1,6 +1,7 @@ #include struct mount { + struct list_head mnt_hash; struct vfsmount mnt; }; diff --git a/fs/namespace.c b/fs/namespace.c index 76412348d5be..121e0032c9de 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -199,7 +199,7 @@ static struct mount *alloc_vfsmnt(const char *name) mnt->mnt_writers = 0; #endif - INIT_LIST_HEAD(&p->mnt.mnt_hash); + INIT_LIST_HEAD(&p->mnt_hash); INIT_LIST_HEAD(&mnt->mnt_child); INIT_LIST_HEAD(&mnt->mnt_mounts); INIT_LIST_HEAD(&mnt->mnt_list); @@ -475,7 +475,7 @@ struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, p = NULL; if (tmp == head) break; - p = list_entry(tmp, struct mount, mnt.mnt_hash); + p = list_entry(tmp, struct mount, mnt_hash); if (p->mnt.mnt_parent == mnt && p->mnt.mnt_mountpoint == dentry) { found = p; break; @@ -542,7 +542,7 @@ static void dentry_reset_mounted(struct dentry *dentry) for (u = 0; u < HASH_SIZE; u++) { struct mount *p; - list_for_each_entry(p, &mount_hashtable[u], mnt.mnt_hash) { + list_for_each_entry(p, &mount_hashtable[u], mnt_hash) { if (p->mnt.mnt_mountpoint == dentry) return; } @@ -562,7 +562,7 @@ static void detach_mnt(struct mount *mnt, struct path *old_path) mnt->mnt.mnt_parent = &mnt->mnt; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; list_del_init(&mnt->mnt.mnt_child); - list_del_init(&mnt->mnt.mnt_hash); + list_del_init(&mnt->mnt_hash); dentry_reset_mounted(old_path->dentry); } @@ -585,7 +585,7 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, static void attach_mnt(struct mount *mnt, struct path *path) { mnt_set_mountpoint(path->mnt, path->dentry, &mnt->mnt); - list_add_tail(&mnt->mnt.mnt_hash, mount_hashtable + + list_add_tail(&mnt->mnt_hash, mount_hashtable + hash(path->mnt, path->dentry)); list_add_tail(&mnt->mnt.mnt_child, &path->mnt->mnt_mounts); } @@ -625,7 +625,7 @@ static void commit_tree(struct mount *mnt) list_splice(&head, n->list.prev); - list_add_tail(&mnt->mnt.mnt_hash, mount_hashtable + + list_add_tail(&mnt->mnt_hash, mount_hashtable + hash(parent, mnt->mnt.mnt_mountpoint)); list_add_tail(&mnt->mnt.mnt_child, &parent->mnt_mounts); touch_mnt_namespace(n); @@ -1193,8 +1193,8 @@ void release_mounts(struct list_head *head) { struct mount *mnt; while (!list_empty(head)) { - mnt = list_first_entry(head, struct mount, mnt.mnt_hash); - list_del_init(&mnt->mnt.mnt_hash); + mnt = list_first_entry(head, struct mount, mnt_hash); + list_del_init(&mnt->mnt_hash); if (mnt_has_parent(&mnt->mnt)) { struct dentry *dentry; struct vfsmount *m; @@ -1223,12 +1223,12 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) struct mount *p; for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) - list_move(&p->mnt.mnt_hash, &tmp_list); + list_move(&p->mnt_hash, &tmp_list); if (propagate) propagate_umount(&tmp_list); - list_for_each_entry(p, &tmp_list, mnt.mnt_hash) { + list_for_each_entry(p, &tmp_list, mnt_hash) { list_del_init(&p->mnt.mnt_expire); list_del_init(&p->mnt.mnt_list); __touch_mnt_namespace(p->mnt.mnt_ns); @@ -1620,8 +1620,8 @@ static int attach_recursive_mnt(struct mount *source_mnt, commit_tree(source_mnt); } - list_for_each_entry_safe(child, p, &tree_list, mnt.mnt_hash) { - list_del_init(&child->mnt.mnt_hash); + list_for_each_entry_safe(child, p, &tree_list, mnt_hash) { + list_del_init(&child->mnt_hash); commit_tree(child); } br_write_unlock(vfsmount_lock); diff --git a/fs/pnode.c b/fs/pnode.c index 916c8e87cf4e..a2f0f3e0e127 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -247,13 +247,13 @@ int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, if (is_subdir(dest_dentry, m->mnt_root)) { mnt_set_mountpoint(m, dest_dentry, &child->mnt); - list_add_tail(&child->mnt.mnt_hash, tree_list); + list_add_tail(&child->mnt_hash, tree_list); } else { /* * This can happen if the parent mount was bind mounted * on some subdirectory of a shared/slave mount. */ - list_add_tail(&child->mnt.mnt_hash, &tmp_list); + list_add_tail(&child->mnt_hash, &tmp_list); } prev_dest_mnt = m; prev_src_mnt = &child->mnt; @@ -261,7 +261,7 @@ int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, out: br_write_lock(vfsmount_lock); while (!list_empty(&tmp_list)) { - child = list_first_entry(&tmp_list, struct mount, mnt.mnt_hash); + child = list_first_entry(&tmp_list, struct mount, mnt_hash); umount_tree(&child->mnt, 0, &umount_list); } br_write_unlock(vfsmount_lock); @@ -337,7 +337,7 @@ static void __propagate_umount(struct mount *mnt) * other children */ if (child && list_empty(&child->mnt.mnt_mounts)) - list_move_tail(&child->mnt.mnt_hash, &mnt->mnt.mnt_hash); + list_move_tail(&child->mnt_hash, &mnt->mnt_hash); } } @@ -352,7 +352,7 @@ int propagate_umount(struct list_head *list) { struct mount *mnt; - list_for_each_entry(mnt, list, mnt.mnt_hash) + list_for_each_entry(mnt, list, mnt_hash) __propagate_umount(mnt); return 0; } diff --git a/include/linux/mount.h b/include/linux/mount.h index 00f5c4f2160b..77c913dc7397 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -53,7 +53,6 @@ struct mnt_pcp { }; struct vfsmount { - struct list_head mnt_hash; struct vfsmount *mnt_parent; /* fs we are mounted on */ struct dentry *mnt_mountpoint; /* dentry of mountpoint */ struct dentry *mnt_root; /* root of the mounted tree */ From 761d5c38eb3d8e2aa7394726dccab245bfe2f41c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 21:07:43 -0500 Subject: [PATCH 121/165] vfs: spread struct mount - umount_tree argument Signed-off-by: Al Viro --- fs/namespace.c | 36 ++++++++++++++++++------------------ fs/pnode.c | 2 +- fs/pnode.h | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 121e0032c9de..5bb40c52b2af 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1217,12 +1217,12 @@ void release_mounts(struct list_head *head) * vfsmount lock must be held for write * namespace_sem must be held for write */ -void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) +void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) { LIST_HEAD(tmp_list); struct mount *p; - for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) + for (p = mnt; p; p = next_mnt(p, &mnt->mnt)) list_move(&p->mnt_hash, &tmp_list); if (propagate) @@ -1327,7 +1327,7 @@ static int do_umount(struct vfsmount *mnt, int flags) retval = -EBUSY; if (flags & MNT_DETACH || !propagate_mount_busy(mnt, 2)) { if (!list_empty(&mnt->mnt_list)) - umount_tree(mnt, 1, &umount_list); + umount_tree(real_mount(mnt), 1, &umount_list); retval = 0; } br_write_unlock(vfsmount_lock); @@ -1455,7 +1455,7 @@ Enomem: if (res) { LIST_HEAD(umount_list); br_write_lock(vfsmount_lock); - umount_tree(&res->mnt, 0, &umount_list); + umount_tree(res, 0, &umount_list); br_write_unlock(vfsmount_lock); release_mounts(&umount_list); } @@ -1476,7 +1476,7 @@ void drop_collected_mounts(struct vfsmount *mnt) LIST_HEAD(umount_list); down_write(&namespace_sem); br_write_lock(vfsmount_lock); - umount_tree(mnt, 0, &umount_list); + umount_tree(real_mount(mnt), 0, &umount_list); br_write_unlock(vfsmount_lock); up_write(&namespace_sem); release_mounts(&umount_list); @@ -1773,7 +1773,7 @@ static int do_loopback(struct path *path, char *old_name, err = graft_tree(&mnt->mnt, path); if (err) { br_write_lock(vfsmount_lock); - umount_tree(&mnt->mnt, 0, &umount_list); + umount_tree(mnt, 0, &umount_list); br_write_unlock(vfsmount_lock); } out2: @@ -2080,7 +2080,7 @@ EXPORT_SYMBOL(mnt_set_expiry); */ void mark_mounts_for_expiry(struct list_head *mounts) { - struct vfsmount *mnt, *next; + struct mount *mnt, *next; LIST_HEAD(graveyard); LIST_HEAD(umounts); @@ -2096,15 +2096,15 @@ void mark_mounts_for_expiry(struct list_head *mounts) * - still marked for expiry (marked on the last call here; marks are * cleared by mntput()) */ - list_for_each_entry_safe(mnt, next, mounts, mnt_expire) { - if (!xchg(&mnt->mnt_expiry_mark, 1) || - propagate_mount_busy(mnt, 1)) + list_for_each_entry_safe(mnt, next, mounts, mnt.mnt_expire) { + if (!xchg(&mnt->mnt.mnt_expiry_mark, 1) || + propagate_mount_busy(&mnt->mnt, 1)) continue; - list_move(&mnt->mnt_expire, &graveyard); + list_move(&mnt->mnt.mnt_expire, &graveyard); } while (!list_empty(&graveyard)) { - mnt = list_first_entry(&graveyard, struct vfsmount, mnt_expire); - touch_mnt_namespace(mnt->mnt_ns); + mnt = list_first_entry(&graveyard, struct mount, mnt.mnt_expire); + touch_mnt_namespace(mnt->mnt.mnt_ns); umount_tree(mnt, 1, &umounts); } br_write_unlock(vfsmount_lock); @@ -2170,14 +2170,14 @@ resume: static void shrink_submounts(struct vfsmount *mnt, struct list_head *umounts) { LIST_HEAD(graveyard); - struct vfsmount *m; + struct mount *m; /* extract submounts of 'mountpoint' from the expiration list */ while (select_submounts(mnt, &graveyard)) { while (!list_empty(&graveyard)) { - m = list_first_entry(&graveyard, struct vfsmount, - mnt_expire); - touch_mnt_namespace(m->mnt_ns); + m = list_first_entry(&graveyard, struct mount, + mnt.mnt_expire); + touch_mnt_namespace(m->mnt.mnt_ns); umount_tree(m, 1, umounts); } } @@ -2750,7 +2750,7 @@ void put_mnt_ns(struct mnt_namespace *ns) return; down_write(&namespace_sem); br_write_lock(vfsmount_lock); - umount_tree(ns->root, 0, &umount_list); + umount_tree(real_mount(ns->root), 0, &umount_list); br_write_unlock(vfsmount_lock); up_write(&namespace_sem); release_mounts(&umount_list); diff --git a/fs/pnode.c b/fs/pnode.c index a2f0f3e0e127..efbe0c0d3f0d 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -262,7 +262,7 @@ out: br_write_lock(vfsmount_lock); while (!list_empty(&tmp_list)) { child = list_first_entry(&tmp_list, struct mount, mnt_hash); - umount_tree(&child->mnt, 0, &umount_list); + umount_tree(child, 0, &umount_list); } br_write_unlock(vfsmount_lock); release_mounts(&umount_list); diff --git a/fs/pnode.h b/fs/pnode.h index ed8a84d6d78f..3f9ab4f4e0e5 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -40,7 +40,7 @@ unsigned int mnt_get_count(struct vfsmount *mnt); void mnt_set_mountpoint(struct vfsmount *, struct dentry *, struct vfsmount *); void release_mounts(struct list_head *); -void umount_tree(struct vfsmount *, int, struct list_head *); +void umount_tree(struct mount *, int, struct list_head *); struct mount *copy_tree(struct vfsmount *, struct dentry *, int); bool is_path_reachable(struct vfsmount *, struct dentry *, const struct path *root); From 692afc312b38c9367a1125927941d33ab2ce852a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 21:15:14 -0500 Subject: [PATCH 122/165] vfs: spread struct mount - shrink_submounts/select_submounts Signed-off-by: Al Viro --- fs/namespace.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 5bb40c52b2af..fa0f30d862c6 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1244,7 +1244,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) list_splice(&tmp_list, kill); } -static void shrink_submounts(struct vfsmount *mnt, struct list_head *umounts); +static void shrink_submounts(struct mount *mnt, struct list_head *umounts); static int do_umount(struct vfsmount *mnt, int flags) { @@ -1322,7 +1322,7 @@ static int do_umount(struct vfsmount *mnt, int flags) event++; if (!(flags & MNT_DETACH)) - shrink_submounts(mnt, &umount_list); + shrink_submounts(real_mount(mnt), &umount_list); retval = -EBUSY; if (flags & MNT_DETACH || !propagate_mount_busy(mnt, 2)) { @@ -2121,32 +2121,32 @@ EXPORT_SYMBOL_GPL(mark_mounts_for_expiry); * search the list of submounts for a given mountpoint, and move any * shrinkable submounts to the 'graveyard' list. */ -static int select_submounts(struct vfsmount *parent, struct list_head *graveyard) +static int select_submounts(struct mount *parent, struct list_head *graveyard) { - struct vfsmount *this_parent = parent; + struct mount *this_parent = parent; struct list_head *next; int found = 0; repeat: - next = this_parent->mnt_mounts.next; + next = this_parent->mnt.mnt_mounts.next; resume: - while (next != &this_parent->mnt_mounts) { + while (next != &this_parent->mnt.mnt_mounts) { struct list_head *tmp = next; - struct vfsmount *mnt = list_entry(tmp, struct vfsmount, mnt_child); + struct mount *mnt = list_entry(tmp, struct mount, mnt.mnt_child); next = tmp->next; - if (!(mnt->mnt_flags & MNT_SHRINKABLE)) + if (!(mnt->mnt.mnt_flags & MNT_SHRINKABLE)) continue; /* * Descend a level if the d_mounts list is non-empty. */ - if (!list_empty(&mnt->mnt_mounts)) { + if (!list_empty(&mnt->mnt.mnt_mounts)) { this_parent = mnt; goto repeat; } - if (!propagate_mount_busy(mnt, 1)) { - list_move_tail(&mnt->mnt_expire, graveyard); + if (!propagate_mount_busy(&mnt->mnt, 1)) { + list_move_tail(&mnt->mnt.mnt_expire, graveyard); found++; } } @@ -2154,8 +2154,8 @@ resume: * All done at this level ... ascend and resume the search */ if (this_parent != parent) { - next = this_parent->mnt_child.next; - this_parent = this_parent->mnt_parent; + next = this_parent->mnt.mnt_child.next; + this_parent = real_mount(this_parent->mnt.mnt_parent); goto resume; } return found; @@ -2167,7 +2167,7 @@ resume: * * vfsmount_lock must be held for write */ -static void shrink_submounts(struct vfsmount *mnt, struct list_head *umounts) +static void shrink_submounts(struct mount *mnt, struct list_head *umounts) { LIST_HEAD(graveyard); struct mount *m; From 87129cc0e3fcd89a1db3e99d62dc710e05749f77 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 21:24:27 -0500 Subject: [PATCH 123/165] vfs: spread struct mount - clone_mnt/copy_tree argument Signed-off-by: Al Viro --- fs/namespace.c | 63 ++++++++++++++++++++++++++------------------------ fs/pnode.c | 2 +- fs/pnode.h | 2 +- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index fa0f30d862c6..211455e2cd17 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -687,17 +687,17 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void } EXPORT_SYMBOL_GPL(vfs_kern_mount); -static struct mount *clone_mnt(struct vfsmount *old, struct dentry *root, +static struct mount *clone_mnt(struct mount *old, struct dentry *root, int flag) { - struct super_block *sb = old->mnt_sb; - struct mount *mnt = alloc_vfsmnt(old->mnt_devname); + struct super_block *sb = old->mnt.mnt_sb; + struct mount *mnt = alloc_vfsmnt(old->mnt.mnt_devname); if (mnt) { if (flag & (CL_SLAVE | CL_PRIVATE)) mnt->mnt.mnt_group_id = 0; /* not a peer of original */ else - mnt->mnt.mnt_group_id = old->mnt_group_id; + mnt->mnt.mnt_group_id = old->mnt.mnt_group_id; if ((flag & CL_MAKE_SHARED) && !mnt->mnt.mnt_group_id) { int err = mnt_alloc_group_id(mnt); @@ -705,7 +705,7 @@ static struct mount *clone_mnt(struct vfsmount *old, struct dentry *root, goto out_free; } - mnt->mnt.mnt_flags = old->mnt_flags & ~MNT_WRITE_HOLD; + mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~MNT_WRITE_HOLD; atomic_inc(&sb->s_active); mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_root = dget(root); @@ -713,15 +713,15 @@ static struct mount *clone_mnt(struct vfsmount *old, struct dentry *root, mnt->mnt.mnt_parent = &mnt->mnt; if (flag & CL_SLAVE) { - list_add(&mnt->mnt.mnt_slave, &old->mnt_slave_list); - mnt->mnt.mnt_master = old; + list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave_list); + mnt->mnt.mnt_master = &old->mnt; CLEAR_MNT_SHARED(&mnt->mnt); } else if (!(flag & CL_PRIVATE)) { - if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) - list_add(&mnt->mnt.mnt_share, &old->mnt_share); - if (IS_MNT_SLAVE(old)) - list_add(&mnt->mnt.mnt_slave, &old->mnt_slave); - mnt->mnt.mnt_master = old->mnt_master; + if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(&old->mnt)) + list_add(&mnt->mnt.mnt_share, &old->mnt.mnt_share); + if (IS_MNT_SLAVE(&old->mnt)) + list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave); + mnt->mnt.mnt_master = old->mnt.mnt_master; } if (flag & CL_MAKE_SHARED) set_mnt_shared(mnt); @@ -729,8 +729,8 @@ static struct mount *clone_mnt(struct vfsmount *old, struct dentry *root, /* stick the duplicate mount on the same expiry list * as the original if that was on one */ if (flag & CL_EXPIRE) { - if (!list_empty(&old->mnt_expire)) - list_add(&mnt->mnt.mnt_expire, &old->mnt_expire); + if (!list_empty(&old->mnt.mnt_expire)) + list_add(&mnt->mnt.mnt_expire, &old->mnt.mnt_expire); } } return mnt; @@ -1408,23 +1408,23 @@ static int mount_is_safe(struct path *path) #endif } -struct mount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, +struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, int flag) { - struct mount *res, *q; - struct vfsmount *p, *r; + struct mount *res, *p, *q; + struct vfsmount *r; struct path path; - if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt)) + if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(&mnt->mnt)) return NULL; res = q = clone_mnt(mnt, dentry, flag); if (!q) goto Enomem; - q->mnt.mnt_mountpoint = mnt->mnt_mountpoint; + q->mnt.mnt_mountpoint = mnt->mnt.mnt_mountpoint; p = mnt; - list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) { + list_for_each_entry(r, &mnt->mnt.mnt_mounts, mnt_child) { struct mount *s; if (!is_subdir(r->mnt_mountpoint, dentry)) continue; @@ -1434,14 +1434,14 @@ struct mount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, s = skip_mnt_tree(s); continue; } - while (p != s->mnt.mnt_parent) { - p = p->mnt_parent; + while (p != real_mount(s->mnt.mnt_parent)) { + p = real_mount(p->mnt.mnt_parent); q = real_mount(q->mnt.mnt_parent); } - p = &s->mnt; + p = s; path.mnt = &q->mnt; - path.dentry = p->mnt_mountpoint; - q = clone_mnt(p, p->mnt_root, flag); + path.dentry = p->mnt.mnt_mountpoint; + q = clone_mnt(p, p->mnt.mnt_root, flag); if (!q) goto Enomem; br_write_lock(vfsmount_lock); @@ -1466,7 +1466,8 @@ struct vfsmount *collect_mounts(struct path *path) { struct mount *tree; down_write(&namespace_sem); - tree = copy_tree(path->mnt, path->dentry, CL_COPY_ALL | CL_PRIVATE); + tree = copy_tree(real_mount(path->mnt), path->dentry, + CL_COPY_ALL | CL_PRIVATE); up_write(&namespace_sem); return tree ? &tree->mnt : NULL; } @@ -1740,7 +1741,7 @@ static int do_loopback(struct path *path, char *old_name, { LIST_HEAD(umount_list); struct path old_path; - struct mount *mnt = NULL; + struct mount *mnt = NULL, *old; int err = mount_is_safe(path); if (err) return err; @@ -1754,6 +1755,8 @@ static int do_loopback(struct path *path, char *old_name, if (err) goto out; + old = real_mount(old_path.mnt); + err = -EINVAL; if (IS_MNT_UNBINDABLE(old_path.mnt)) goto out2; @@ -1763,9 +1766,9 @@ static int do_loopback(struct path *path, char *old_name, err = -ENOMEM; if (recurse) - mnt = copy_tree(old_path.mnt, old_path.dentry, 0); + mnt = copy_tree(old, old_path.dentry, 0); else - mnt = clone_mnt(old_path.mnt, old_path.dentry, 0); + mnt = clone_mnt(old, old_path.dentry, 0); if (!mnt) goto out2; @@ -2394,7 +2397,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, down_write(&namespace_sem); /* First pass: copy the tree topology */ - new = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root, + new = copy_tree(real_mount(mnt_ns->root), mnt_ns->root->mnt_root, CL_COPY_ALL | CL_EXPIRE); if (!new) { up_write(&namespace_sem); diff --git a/fs/pnode.c b/fs/pnode.c index efbe0c0d3f0d..5d79f38e3e8a 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -239,7 +239,7 @@ int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); - if (!(child = copy_tree(source, source->mnt_root, type))) { + if (!(child = copy_tree(real_mount(source), source->mnt_root, type))) { ret = -ENOMEM; list_splice(tree_list, tmp_list.prev); goto out; diff --git a/fs/pnode.h b/fs/pnode.h index 3f9ab4f4e0e5..609ec008d5ce 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -41,7 +41,7 @@ void mnt_set_mountpoint(struct vfsmount *, struct dentry *, struct vfsmount *); void release_mounts(struct list_head *); void umount_tree(struct mount *, int, struct list_head *); -struct mount *copy_tree(struct vfsmount *, struct dentry *, int); +struct mount *copy_tree(struct mount *, struct dentry *, int); bool is_path_reachable(struct vfsmount *, struct dentry *, const struct path *root); #endif /* _LINUX_PNODE_H */ From 44d964d609c7c11b330a3d1caf30767fa13c7be3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 21:28:22 -0500 Subject: [PATCH 124/165] vfs: spread struct mount mnt_set_mountpoint child argument Signed-off-by: Al Viro --- fs/namespace.c | 10 +++++----- fs/pnode.c | 2 +- fs/pnode.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 211455e2cd17..c11b99af53cf 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -570,10 +570,10 @@ static void detach_mnt(struct mount *mnt, struct path *old_path) * vfsmount lock must be held for write */ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, - struct vfsmount *child_mnt) + struct mount *child_mnt) { - child_mnt->mnt_parent = mntget(mnt); - child_mnt->mnt_mountpoint = dget(dentry); + child_mnt->mnt.mnt_parent = mntget(mnt); + child_mnt->mnt.mnt_mountpoint = dget(dentry); spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_MOUNTED; spin_unlock(&dentry->d_lock); @@ -584,7 +584,7 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, */ static void attach_mnt(struct mount *mnt, struct path *path) { - mnt_set_mountpoint(path->mnt, path->dentry, &mnt->mnt); + mnt_set_mountpoint(path->mnt, path->dentry, mnt); list_add_tail(&mnt->mnt_hash, mount_hashtable + hash(path->mnt, path->dentry)); list_add_tail(&mnt->mnt.mnt_child, &path->mnt->mnt_mounts); @@ -1617,7 +1617,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, attach_mnt(source_mnt, path); touch_mnt_namespace(parent_path->mnt->mnt_ns); } else { - mnt_set_mountpoint(dest_mnt, dest_dentry, &source_mnt->mnt); + mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); commit_tree(source_mnt); } diff --git a/fs/pnode.c b/fs/pnode.c index 5d79f38e3e8a..89ea50dc2af3 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -246,7 +246,7 @@ int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, } if (is_subdir(dest_dentry, m->mnt_root)) { - mnt_set_mountpoint(m, dest_dentry, &child->mnt); + mnt_set_mountpoint(m, dest_dentry, child); list_add_tail(&child->mnt_hash, tree_list); } else { /* diff --git a/fs/pnode.h b/fs/pnode.h index 609ec008d5ce..bfd0bbcabf6d 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -38,7 +38,7 @@ void mnt_release_group_id(struct mount *); int get_dominating_id(struct vfsmount *mnt, const struct path *root); unsigned int mnt_get_count(struct vfsmount *mnt); void mnt_set_mountpoint(struct vfsmount *, struct dentry *, - struct vfsmount *); + struct mount *); void release_mounts(struct list_head *); void umount_tree(struct mount *, int, struct list_head *); struct mount *copy_tree(struct mount *, struct dentry *, int); From 1ab597386205f8dc757cf8750465502aeae65154 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 21:35:16 -0500 Subject: [PATCH 125/165] vfs: spread struct mount - do_umount/propagate_mount_busy Signed-off-by: Al Viro --- fs/namespace.c | 28 ++++++++++++++-------------- fs/pnode.c | 16 ++++++++-------- fs/pnode.h | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index c11b99af53cf..17927f9eeca4 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1180,7 +1180,7 @@ int may_umount(struct vfsmount *mnt) int ret = 1; down_read(&namespace_sem); br_write_lock(vfsmount_lock); - if (propagate_mount_busy(mnt, 2)) + if (propagate_mount_busy(real_mount(mnt), 2)) ret = 0; br_write_unlock(vfsmount_lock); up_read(&namespace_sem); @@ -1246,13 +1246,13 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) static void shrink_submounts(struct mount *mnt, struct list_head *umounts); -static int do_umount(struct vfsmount *mnt, int flags) +static int do_umount(struct mount *mnt, int flags) { - struct super_block *sb = mnt->mnt_sb; + struct super_block *sb = mnt->mnt.mnt_sb; int retval; LIST_HEAD(umount_list); - retval = security_sb_umount(mnt, flags); + retval = security_sb_umount(&mnt->mnt, flags); if (retval) return retval; @@ -1263,7 +1263,7 @@ static int do_umount(struct vfsmount *mnt, int flags) * (2) the usage count == 1 [parent vfsmount] + 1 [sys_umount] */ if (flags & MNT_EXPIRE) { - if (mnt == current->fs->root.mnt || + if (&mnt->mnt == current->fs->root.mnt || flags & (MNT_FORCE | MNT_DETACH)) return -EINVAL; @@ -1272,13 +1272,13 @@ static int do_umount(struct vfsmount *mnt, int flags) * all race cases, but it's a slowpath. */ br_write_lock(vfsmount_lock); - if (mnt_get_count(mnt) != 2) { + if (mnt_get_count(&mnt->mnt) != 2) { br_write_unlock(vfsmount_lock); return -EBUSY; } br_write_unlock(vfsmount_lock); - if (!xchg(&mnt->mnt_expiry_mark, 1)) + if (!xchg(&mnt->mnt.mnt_expiry_mark, 1)) return -EAGAIN; } @@ -1305,7 +1305,7 @@ static int do_umount(struct vfsmount *mnt, int flags) * /reboot - static binary that would close all descriptors and * call reboot(9). Then init(8) could umount root and exec /reboot. */ - if (mnt == current->fs->root.mnt && !(flags & MNT_DETACH)) { + if (&mnt->mnt == current->fs->root.mnt && !(flags & MNT_DETACH)) { /* * Special case for "unmounting" root ... * we just try to remount it readonly. @@ -1322,12 +1322,12 @@ static int do_umount(struct vfsmount *mnt, int flags) event++; if (!(flags & MNT_DETACH)) - shrink_submounts(real_mount(mnt), &umount_list); + shrink_submounts(mnt, &umount_list); retval = -EBUSY; if (flags & MNT_DETACH || !propagate_mount_busy(mnt, 2)) { - if (!list_empty(&mnt->mnt_list)) - umount_tree(real_mount(mnt), 1, &umount_list); + if (!list_empty(&mnt->mnt.mnt_list)) + umount_tree(mnt, 1, &umount_list); retval = 0; } br_write_unlock(vfsmount_lock); @@ -1369,7 +1369,7 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) if (!capable(CAP_SYS_ADMIN)) goto dput_and_out; - retval = do_umount(path.mnt, flags); + retval = do_umount(real_mount(path.mnt), flags); dput_and_out: /* we mustn't call path_put() as that would clear mnt_expiry_mark */ dput(path.dentry); @@ -2101,7 +2101,7 @@ void mark_mounts_for_expiry(struct list_head *mounts) */ list_for_each_entry_safe(mnt, next, mounts, mnt.mnt_expire) { if (!xchg(&mnt->mnt.mnt_expiry_mark, 1) || - propagate_mount_busy(&mnt->mnt, 1)) + propagate_mount_busy(mnt, 1)) continue; list_move(&mnt->mnt.mnt_expire, &graveyard); } @@ -2148,7 +2148,7 @@ resume: goto repeat; } - if (!propagate_mount_busy(&mnt->mnt, 1)) { + if (!propagate_mount_busy(mnt, 1)) { list_move_tail(&mnt->mnt.mnt_expire, graveyard); found++; } diff --git a/fs/pnode.c b/fs/pnode.c index 89ea50dc2af3..3105cca197ec 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -272,9 +272,9 @@ out: /* * return true if the refcount is greater than count */ -static inline int do_refcount_check(struct vfsmount *mnt, int count) +static inline int do_refcount_check(struct mount *mnt, int count) { - int mycount = mnt_get_count(mnt) - mnt->mnt_ghosts; + int mycount = mnt_get_count(&mnt->mnt) - mnt->mnt.mnt_ghosts; return (mycount > count); } @@ -288,14 +288,14 @@ static inline int do_refcount_check(struct vfsmount *mnt, int count) * * vfsmount lock must be held for write */ -int propagate_mount_busy(struct vfsmount *mnt, int refcnt) +int propagate_mount_busy(struct mount *mnt, int refcnt) { struct vfsmount *m; struct mount *child; - struct vfsmount *parent = mnt->mnt_parent; + struct vfsmount *parent = mnt->mnt.mnt_parent; int ret = 0; - if (mnt == parent) + if (&mnt->mnt == parent) return do_refcount_check(mnt, refcnt); /* @@ -303,14 +303,14 @@ int propagate_mount_busy(struct vfsmount *mnt, int refcnt) * If not, we don't have to go checking for all other * mounts */ - if (!list_empty(&mnt->mnt_mounts) || do_refcount_check(mnt, refcnt)) + if (!list_empty(&mnt->mnt.mnt_mounts) || do_refcount_check(mnt, refcnt)) return 1; for (m = propagation_next(parent, parent); m; m = propagation_next(m, parent)) { - child = __lookup_mnt(m, mnt->mnt_mountpoint, 0); + child = __lookup_mnt(m, mnt->mnt.mnt_mountpoint, 0); if (child && list_empty(&child->mnt.mnt_mounts) && - (ret = do_refcount_check(&child->mnt, 1))) + (ret = do_refcount_check(child, 1))) break; } return ret; diff --git a/fs/pnode.h b/fs/pnode.h index bfd0bbcabf6d..f1d251d3771e 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -33,7 +33,7 @@ void change_mnt_propagation(struct mount *, int); int propagate_mnt(struct vfsmount *, struct dentry *, struct vfsmount *, struct list_head *); int propagate_umount(struct list_head *); -int propagate_mount_busy(struct vfsmount *, int); +int propagate_mount_busy(struct mount *, int); void mnt_release_group_id(struct mount *); int get_dominating_id(struct vfsmount *mnt, const struct path *root); unsigned int mnt_get_count(struct vfsmount *mnt); From 676da58df740f325034b8641311413c2393588e1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 21:47:05 -0500 Subject: [PATCH 126/165] vfs: spread struct mount - mnt_has_parent Signed-off-by: Al Viro --- fs/dcache.c | 3 ++- fs/mount.h | 4 ++-- fs/namespace.c | 18 +++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 64c8ce4c147f..1834e715f814 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2460,8 +2460,9 @@ static int prepend_path(const struct path *path, struct dentry * parent; if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { + struct mount *mnt = real_mount(vfsmnt); /* Global root? */ - if (!mnt_has_parent(vfsmnt)) + if (!mnt_has_parent(mnt)) goto global_root; dentry = vfsmnt->mnt_mountpoint; vfsmnt = vfsmnt->mnt_parent; diff --git a/fs/mount.h b/fs/mount.h index 831e7c86835b..541daf568f63 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -10,9 +10,9 @@ static inline struct mount *real_mount(struct vfsmount *mnt) return container_of(mnt, struct mount, mnt); } -static inline int mnt_has_parent(struct vfsmount *mnt) +static inline int mnt_has_parent(struct mount *mnt) { - return mnt != mnt->mnt_parent; + return &mnt->mnt != mnt->mnt.mnt_parent; } extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int); diff --git a/fs/namespace.c b/fs/namespace.c index 17927f9eeca4..ced3aa53fb38 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1195,7 +1195,7 @@ void release_mounts(struct list_head *head) while (!list_empty(head)) { mnt = list_first_entry(head, struct mount, mnt_hash); list_del_init(&mnt->mnt_hash); - if (mnt_has_parent(&mnt->mnt)) { + if (mnt_has_parent(mnt)) { struct dentry *dentry; struct vfsmount *m; @@ -1235,7 +1235,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) p->mnt.mnt_ns = NULL; __mnt_make_shortterm(&p->mnt); list_del_init(&p->mnt.mnt_child); - if (mnt_has_parent(&p->mnt)) { + if (mnt_has_parent(p)) { p->mnt.mnt_parent->mnt_ghosts++; dentry_reset_mounted(p->mnt.mnt_mountpoint); } @@ -1861,7 +1861,7 @@ static inline int tree_contains_unbindable(struct mount *mnt) static int do_move_mount(struct path *path, char *old_name) { struct path old_path, parent_path; - struct vfsmount *p; + struct mount *p; struct mount *old; int err = 0; if (!capable(CAP_SYS_ADMIN)) @@ -1889,7 +1889,7 @@ static int do_move_mount(struct path *path, char *old_name) old = real_mount(old_path.mnt); - if (!mnt_has_parent(old_path.mnt)) + if (!mnt_has_parent(old)) goto out1; if (S_ISDIR(path->dentry->d_inode->i_mode) != @@ -1908,8 +1908,8 @@ static int do_move_mount(struct path *path, char *old_name) tree_contains_unbindable(old)) goto out1; err = -ELOOP; - for (p = path->mnt; mnt_has_parent(p); p = p->mnt_parent) - if (p == old_path.mnt) + for (p = real_mount(path->mnt); mnt_has_parent(p); p = real_mount(p->mnt.mnt_parent)) + if (p == old) goto out1; err = attach_recursive_mnt(old, path, &parent_path); @@ -2562,7 +2562,7 @@ out_type: bool is_path_reachable(struct vfsmount *mnt, struct dentry *dentry, const struct path *root) { - while (mnt != root->mnt && mnt_has_parent(mnt)) { + while (mnt != root->mnt && mnt_has_parent(real_mount(mnt))) { dentry = mnt->mnt_mountpoint; mnt = mnt->mnt_parent; } @@ -2652,11 +2652,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, error = -EINVAL; if (root.mnt->mnt_root != root.dentry) goto out4; /* not a mountpoint */ - if (!mnt_has_parent(root.mnt)) + if (!mnt_has_parent(root_mnt)) goto out4; /* not attached */ if (new.mnt->mnt_root != new.dentry) goto out4; /* not a mountpoint */ - if (!mnt_has_parent(new.mnt)) + if (!mnt_has_parent(new_mnt)) goto out4; /* not attached */ /* make sure we can reach put_old from new_root */ if (!is_path_reachable(old.mnt, old.dentry, &new)) From 643822b41e5e0f133438883b0be574cdaf168a2a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 22:00:28 -0500 Subject: [PATCH 127/165] vfs: spread struct mount - is_path_reachable Signed-off-by: Al Viro --- fs/namespace.c | 14 +++++++------- fs/pnode.c | 10 +++++----- fs/pnode.h | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index ced3aa53fb38..b117d94fcdc1 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2559,21 +2559,21 @@ out_type: * * namespace_sem or vfsmount_lock is held */ -bool is_path_reachable(struct vfsmount *mnt, struct dentry *dentry, +bool is_path_reachable(struct mount *mnt, struct dentry *dentry, const struct path *root) { - while (mnt != root->mnt && mnt_has_parent(real_mount(mnt))) { - dentry = mnt->mnt_mountpoint; - mnt = mnt->mnt_parent; + while (&mnt->mnt != root->mnt && mnt_has_parent(mnt)) { + dentry = mnt->mnt.mnt_mountpoint; + mnt = real_mount(mnt->mnt.mnt_parent); } - return mnt == root->mnt && is_subdir(dentry, root->dentry); + return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry); } int path_is_under(struct path *path1, struct path *path2) { int res; br_read_lock(vfsmount_lock); - res = is_path_reachable(path1->mnt, path1->dentry, path2); + res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2); br_read_unlock(vfsmount_lock); return res; } @@ -2659,7 +2659,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, if (!mnt_has_parent(new_mnt)) goto out4; /* not attached */ /* make sure we can reach put_old from new_root */ - if (!is_path_reachable(old.mnt, old.dentry, &new)) + if (!is_path_reachable(real_mount(old.mnt), old.dentry, &new)) goto out4; br_write_lock(vfsmount_lock); detach_mnt(new_mnt, &parent_path); diff --git a/fs/pnode.c b/fs/pnode.c index 3105cca197ec..25f74b53dea6 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -32,15 +32,15 @@ static struct vfsmount *get_peer_under_root(struct vfsmount *mnt, struct mnt_namespace *ns, const struct path *root) { - struct vfsmount *m = mnt; + struct mount *m = real_mount(mnt); do { /* Check the namespace first for optimization */ - if (m->mnt_ns == ns && is_path_reachable(m, m->mnt_root, root)) - return m; + if (m->mnt.mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root)) + return &m->mnt; - m = next_peer(m); - } while (m != mnt); + m = real_mount(next_peer(&m->mnt)); + } while (&m->mnt != mnt); return NULL; } diff --git a/fs/pnode.h b/fs/pnode.h index f1d251d3771e..866b3e292887 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -42,6 +42,6 @@ void mnt_set_mountpoint(struct vfsmount *, struct dentry *, void release_mounts(struct list_head *); void umount_tree(struct mount *, int, struct list_head *); struct mount *copy_tree(struct mount *, struct dentry *, int); -bool is_path_reachable(struct vfsmount *, struct dentry *, +bool is_path_reachable(struct mount *, struct dentry *, const struct path *root); #endif /* _LINUX_PNODE_H */ From 3376f34fff5be9954fd9a9c4fd68f4a0a36d480e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 22:05:19 -0500 Subject: [PATCH 128/165] vfs: mnt_parent moved to struct mount the second victim... Signed-off-by: Al Viro --- fs/dcache.c | 2 +- fs/mount.h | 3 ++- fs/namei.c | 4 ++-- fs/namespace.c | 45 ++++++++++++++++++++++--------------------- fs/pnode.c | 4 ++-- include/linux/mount.h | 1 - 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 1834e715f814..eef2d5472f9c 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2465,7 +2465,7 @@ static int prepend_path(const struct path *path, if (!mnt_has_parent(mnt)) goto global_root; dentry = vfsmnt->mnt_mountpoint; - vfsmnt = vfsmnt->mnt_parent; + vfsmnt = mnt->mnt_parent; continue; } parent = dentry->d_parent; diff --git a/fs/mount.h b/fs/mount.h index 541daf568f63..5126c0861102 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -2,6 +2,7 @@ struct mount { struct list_head mnt_hash; + struct vfsmount *mnt_parent; struct vfsmount mnt; }; @@ -12,7 +13,7 @@ static inline struct mount *real_mount(struct vfsmount *mnt) static inline int mnt_has_parent(struct mount *mnt) { - return &mnt->mnt != mnt->mnt.mnt_parent; + return &mnt->mnt != mnt->mnt_parent; } extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int); diff --git a/fs/namei.c b/fs/namei.c index d1c6a559f8f0..89248bf1b906 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -680,7 +680,7 @@ static int follow_up_rcu(struct path *path) struct vfsmount *parent; struct dentry *mountpoint; - parent = path->mnt->mnt_parent; + parent = real_mount(path->mnt)->mnt_parent; if (parent == path->mnt) return 0; mountpoint = path->mnt->mnt_mountpoint; @@ -695,7 +695,7 @@ int follow_up(struct path *path) struct dentry *mountpoint; br_read_lock(vfsmount_lock); - parent = path->mnt->mnt_parent; + parent = real_mount(path->mnt)->mnt_parent; if (parent == path->mnt) { br_read_unlock(vfsmount_lock); return 0; diff --git a/fs/namespace.c b/fs/namespace.c index b117d94fcdc1..c6384bc39db1 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -476,7 +476,7 @@ struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, if (tmp == head) break; p = list_entry(tmp, struct mount, mnt_hash); - if (p->mnt.mnt_parent == mnt && p->mnt.mnt_mountpoint == dentry) { + if (p->mnt_parent == mnt && p->mnt.mnt_mountpoint == dentry) { found = p; break; } @@ -558,8 +558,8 @@ static void dentry_reset_mounted(struct dentry *dentry) static void detach_mnt(struct mount *mnt, struct path *old_path) { old_path->dentry = mnt->mnt.mnt_mountpoint; - old_path->mnt = mnt->mnt.mnt_parent; - mnt->mnt.mnt_parent = &mnt->mnt; + old_path->mnt = mnt->mnt_parent; + mnt->mnt_parent = &mnt->mnt; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; list_del_init(&mnt->mnt.mnt_child); list_del_init(&mnt->mnt_hash); @@ -572,7 +572,7 @@ static void detach_mnt(struct mount *mnt, struct path *old_path) void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, struct mount *child_mnt) { - child_mnt->mnt.mnt_parent = mntget(mnt); + child_mnt->mnt_parent = mntget(mnt); child_mnt->mnt.mnt_mountpoint = dget(dentry); spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_MOUNTED; @@ -610,7 +610,7 @@ static inline void __mnt_make_shortterm(struct vfsmount *mnt) */ static void commit_tree(struct mount *mnt) { - struct vfsmount *parent = mnt->mnt.mnt_parent; + struct vfsmount *parent = mnt->mnt_parent; struct vfsmount *m; LIST_HEAD(head); struct mnt_namespace *n = parent->mnt_ns; @@ -639,9 +639,9 @@ static struct mount *next_mnt(struct mount *p, struct vfsmount *root) if (&p->mnt == root) return NULL; next = p->mnt.mnt_child.next; - if (next != &p->mnt.mnt_parent->mnt_mounts) + if (next != &p->mnt_parent->mnt_mounts) break; - p = real_mount(p->mnt.mnt_parent); + p = real_mount(p->mnt_parent); } } return list_entry(next, struct mount, mnt.mnt_child); @@ -682,7 +682,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void mnt->mnt.mnt_root = root; mnt->mnt.mnt_sb = root->d_sb; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; - mnt->mnt.mnt_parent = &mnt->mnt; + mnt->mnt_parent = &mnt->mnt; return &mnt->mnt; } EXPORT_SYMBOL_GPL(vfs_kern_mount); @@ -710,7 +710,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_root = dget(root); mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; - mnt->mnt.mnt_parent = &mnt->mnt; + mnt->mnt_parent = &mnt->mnt; if (flag & CL_SLAVE) { list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave_list); @@ -1021,12 +1021,13 @@ static int show_mountinfo(struct seq_file *m, void *v) { struct proc_mounts *p = m->private; struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); + struct mount *r = real_mount(mnt); struct super_block *sb = mnt->mnt_sb; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; struct path root = p->root; int err = 0; - seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id, + seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, r->mnt_parent->mnt_id, MAJOR(sb->s_dev), MINOR(sb->s_dev)); if (sb->s_op->show_path) err = sb->s_op->show_path(m, mnt); @@ -1201,9 +1202,9 @@ void release_mounts(struct list_head *head) br_write_lock(vfsmount_lock); dentry = mnt->mnt.mnt_mountpoint; - m = mnt->mnt.mnt_parent; + m = mnt->mnt_parent; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; - mnt->mnt.mnt_parent = &mnt->mnt; + mnt->mnt_parent = &mnt->mnt; m->mnt_ghosts--; br_write_unlock(vfsmount_lock); dput(dentry); @@ -1236,7 +1237,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) __mnt_make_shortterm(&p->mnt); list_del_init(&p->mnt.mnt_child); if (mnt_has_parent(p)) { - p->mnt.mnt_parent->mnt_ghosts++; + p->mnt_parent->mnt_ghosts++; dentry_reset_mounted(p->mnt.mnt_mountpoint); } change_mnt_propagation(p, MS_PRIVATE); @@ -1434,9 +1435,9 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, s = skip_mnt_tree(s); continue; } - while (p != real_mount(s->mnt.mnt_parent)) { - p = real_mount(p->mnt.mnt_parent); - q = real_mount(q->mnt.mnt_parent); + while (p != real_mount(s->mnt_parent)) { + p = real_mount(p->mnt_parent); + q = real_mount(q->mnt_parent); } p = s; path.mnt = &q->mnt; @@ -1898,7 +1899,7 @@ static int do_move_mount(struct path *path, char *old_name) /* * Don't move a mount residing in a shared parent. */ - if (IS_MNT_SHARED(old_path.mnt->mnt_parent)) + if (IS_MNT_SHARED(old->mnt_parent)) goto out1; /* * Don't move a mount tree containing unbindable mounts to a destination @@ -1908,7 +1909,7 @@ static int do_move_mount(struct path *path, char *old_name) tree_contains_unbindable(old)) goto out1; err = -ELOOP; - for (p = real_mount(path->mnt); mnt_has_parent(p); p = real_mount(p->mnt.mnt_parent)) + for (p = real_mount(path->mnt); mnt_has_parent(p); p = real_mount(p->mnt_parent)) if (p == old) goto out1; @@ -2158,7 +2159,7 @@ resume: */ if (this_parent != parent) { next = this_parent->mnt.mnt_child.next; - this_parent = real_mount(this_parent->mnt.mnt_parent); + this_parent = real_mount(this_parent->mnt_parent); goto resume; } return found; @@ -2564,7 +2565,7 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry, { while (&mnt->mnt != root->mnt && mnt_has_parent(mnt)) { dentry = mnt->mnt.mnt_mountpoint; - mnt = real_mount(mnt->mnt.mnt_parent); + mnt = real_mount(mnt->mnt_parent); } return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry); } @@ -2635,8 +2636,8 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, new_mnt = real_mount(new.mnt); root_mnt = real_mount(root.mnt); if (IS_MNT_SHARED(old.mnt) || - IS_MNT_SHARED(new.mnt->mnt_parent) || - IS_MNT_SHARED(root.mnt->mnt_parent)) + IS_MNT_SHARED(new_mnt->mnt_parent) || + IS_MNT_SHARED(root_mnt->mnt_parent)) goto out4; if (!check_mnt(root.mnt) || !check_mnt(new.mnt)) goto out4; diff --git a/fs/pnode.c b/fs/pnode.c index 25f74b53dea6..2ff4dfa018e1 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -292,7 +292,7 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) { struct vfsmount *m; struct mount *child; - struct vfsmount *parent = mnt->mnt.mnt_parent; + struct vfsmount *parent = mnt->mnt_parent; int ret = 0; if (&mnt->mnt == parent) @@ -322,7 +322,7 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) */ static void __propagate_umount(struct mount *mnt) { - struct vfsmount *parent = mnt->mnt.mnt_parent; + struct vfsmount *parent = mnt->mnt_parent; struct vfsmount *m; BUG_ON(parent == &mnt->mnt); diff --git a/include/linux/mount.h b/include/linux/mount.h index 77c913dc7397..b69362d2b5b2 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -53,7 +53,6 @@ struct mnt_pcp { }; struct vfsmount { - struct vfsmount *mnt_parent; /* fs we are mounted on */ struct dentry *mnt_mountpoint; /* dentry of mountpoint */ struct dentry *mnt_root; /* root of the mounted tree */ struct super_block *mnt_sb; /* pointer to superblock */ From 0714a533805a0f8ebfc6fdb6bda9f129b8c7c6d7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 22:19:58 -0500 Subject: [PATCH 129/165] vfs: now it can be done - make mnt_parent point to struct mount Signed-off-by: Al Viro --- fs/dcache.c | 7 ++++--- fs/mount.h | 4 ++-- fs/namei.c | 24 ++++++++++++----------- fs/namespace.c | 52 +++++++++++++++++++++++++------------------------- fs/pnode.c | 16 ++++++++-------- 5 files changed, 53 insertions(+), 50 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index eef2d5472f9c..98b48753f77b 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2452,6 +2452,7 @@ static int prepend_path(const struct path *path, { struct dentry *dentry = path->dentry; struct vfsmount *vfsmnt = path->mnt; + struct mount *mnt = real_mount(vfsmnt); bool slash = false; int error = 0; @@ -2460,12 +2461,12 @@ static int prepend_path(const struct path *path, struct dentry * parent; if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { - struct mount *mnt = real_mount(vfsmnt); /* Global root? */ if (!mnt_has_parent(mnt)) goto global_root; - dentry = vfsmnt->mnt_mountpoint; - vfsmnt = mnt->mnt_parent; + dentry = mnt->mnt.mnt_mountpoint; + mnt = mnt->mnt_parent; + vfsmnt = &mnt->mnt; continue; } parent = dentry->d_parent; diff --git a/fs/mount.h b/fs/mount.h index 5126c0861102..201dd616e6c4 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -2,7 +2,7 @@ struct mount { struct list_head mnt_hash; - struct vfsmount *mnt_parent; + struct mount *mnt_parent; struct vfsmount mnt; }; @@ -13,7 +13,7 @@ static inline struct mount *real_mount(struct vfsmount *mnt) static inline int mnt_has_parent(struct mount *mnt) { - return &mnt->mnt != mnt->mnt_parent; + return mnt != mnt->mnt_parent; } extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int); diff --git a/fs/namei.c b/fs/namei.c index 89248bf1b906..2e9110a37c0e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -677,36 +677,38 @@ follow_link(struct path *link, struct nameidata *nd, void **p) static int follow_up_rcu(struct path *path) { - struct vfsmount *parent; + struct mount *mnt = real_mount(path->mnt); + struct mount *parent; struct dentry *mountpoint; - parent = real_mount(path->mnt)->mnt_parent; - if (parent == path->mnt) + parent = mnt->mnt_parent; + if (&parent->mnt == path->mnt) return 0; - mountpoint = path->mnt->mnt_mountpoint; + mountpoint = mnt->mnt.mnt_mountpoint; path->dentry = mountpoint; - path->mnt = parent; + path->mnt = &parent->mnt; return 1; } int follow_up(struct path *path) { - struct vfsmount *parent; + struct mount *mnt = real_mount(path->mnt); + struct mount *parent; struct dentry *mountpoint; br_read_lock(vfsmount_lock); - parent = real_mount(path->mnt)->mnt_parent; - if (parent == path->mnt) { + parent = mnt->mnt_parent; + if (&parent->mnt == path->mnt) { br_read_unlock(vfsmount_lock); return 0; } - mntget(parent); - mountpoint = dget(path->mnt->mnt_mountpoint); + mntget(&parent->mnt); + mountpoint = dget(mnt->mnt.mnt_mountpoint); br_read_unlock(vfsmount_lock); dput(path->dentry); path->dentry = mountpoint; mntput(path->mnt); - path->mnt = parent; + path->mnt = &parent->mnt; return 1; } diff --git a/fs/namespace.c b/fs/namespace.c index c6384bc39db1..5e700c6df579 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -476,7 +476,7 @@ struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, if (tmp == head) break; p = list_entry(tmp, struct mount, mnt_hash); - if (p->mnt_parent == mnt && p->mnt.mnt_mountpoint == dentry) { + if (&p->mnt_parent->mnt == mnt && p->mnt.mnt_mountpoint == dentry) { found = p; break; } @@ -558,8 +558,8 @@ static void dentry_reset_mounted(struct dentry *dentry) static void detach_mnt(struct mount *mnt, struct path *old_path) { old_path->dentry = mnt->mnt.mnt_mountpoint; - old_path->mnt = mnt->mnt_parent; - mnt->mnt_parent = &mnt->mnt; + old_path->mnt = &mnt->mnt_parent->mnt; + mnt->mnt_parent = mnt; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; list_del_init(&mnt->mnt.mnt_child); list_del_init(&mnt->mnt_hash); @@ -572,7 +572,7 @@ static void detach_mnt(struct mount *mnt, struct path *old_path) void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, struct mount *child_mnt) { - child_mnt->mnt_parent = mntget(mnt); + child_mnt->mnt_parent = real_mount(mntget(mnt)); child_mnt->mnt.mnt_mountpoint = dget(dentry); spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_MOUNTED; @@ -610,12 +610,12 @@ static inline void __mnt_make_shortterm(struct vfsmount *mnt) */ static void commit_tree(struct mount *mnt) { - struct vfsmount *parent = mnt->mnt_parent; + struct mount *parent = mnt->mnt_parent; struct vfsmount *m; LIST_HEAD(head); - struct mnt_namespace *n = parent->mnt_ns; + struct mnt_namespace *n = parent->mnt.mnt_ns; - BUG_ON(parent == &mnt->mnt); + BUG_ON(parent == mnt); list_add_tail(&head, &mnt->mnt.mnt_list); list_for_each_entry(m, &head, mnt_list) { @@ -626,8 +626,8 @@ static void commit_tree(struct mount *mnt) list_splice(&head, n->list.prev); list_add_tail(&mnt->mnt_hash, mount_hashtable + - hash(parent, mnt->mnt.mnt_mountpoint)); - list_add_tail(&mnt->mnt.mnt_child, &parent->mnt_mounts); + hash(&parent->mnt, mnt->mnt.mnt_mountpoint)); + list_add_tail(&mnt->mnt.mnt_child, &parent->mnt.mnt_mounts); touch_mnt_namespace(n); } @@ -639,9 +639,9 @@ static struct mount *next_mnt(struct mount *p, struct vfsmount *root) if (&p->mnt == root) return NULL; next = p->mnt.mnt_child.next; - if (next != &p->mnt_parent->mnt_mounts) + if (next != &p->mnt_parent->mnt.mnt_mounts) break; - p = real_mount(p->mnt_parent); + p = p->mnt_parent; } } return list_entry(next, struct mount, mnt.mnt_child); @@ -682,7 +682,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void mnt->mnt.mnt_root = root; mnt->mnt.mnt_sb = root->d_sb; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; - mnt->mnt_parent = &mnt->mnt; + mnt->mnt_parent = mnt; return &mnt->mnt; } EXPORT_SYMBOL_GPL(vfs_kern_mount); @@ -710,7 +710,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_root = dget(root); mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; - mnt->mnt_parent = &mnt->mnt; + mnt->mnt_parent = mnt; if (flag & CL_SLAVE) { list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave_list); @@ -1027,7 +1027,7 @@ static int show_mountinfo(struct seq_file *m, void *v) struct path root = p->root; int err = 0; - seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, r->mnt_parent->mnt_id, + seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, r->mnt_parent->mnt.mnt_id, MAJOR(sb->s_dev), MINOR(sb->s_dev)); if (sb->s_op->show_path) err = sb->s_op->show_path(m, mnt); @@ -1202,9 +1202,9 @@ void release_mounts(struct list_head *head) br_write_lock(vfsmount_lock); dentry = mnt->mnt.mnt_mountpoint; - m = mnt->mnt_parent; + m = &mnt->mnt_parent->mnt; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; - mnt->mnt_parent = &mnt->mnt; + mnt->mnt_parent = mnt; m->mnt_ghosts--; br_write_unlock(vfsmount_lock); dput(dentry); @@ -1237,7 +1237,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) __mnt_make_shortterm(&p->mnt); list_del_init(&p->mnt.mnt_child); if (mnt_has_parent(p)) { - p->mnt_parent->mnt_ghosts++; + p->mnt_parent->mnt.mnt_ghosts++; dentry_reset_mounted(p->mnt.mnt_mountpoint); } change_mnt_propagation(p, MS_PRIVATE); @@ -1435,9 +1435,9 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, s = skip_mnt_tree(s); continue; } - while (p != real_mount(s->mnt_parent)) { - p = real_mount(p->mnt_parent); - q = real_mount(q->mnt_parent); + while (p != s->mnt_parent) { + p = p->mnt_parent; + q = q->mnt_parent; } p = s; path.mnt = &q->mnt; @@ -1899,7 +1899,7 @@ static int do_move_mount(struct path *path, char *old_name) /* * Don't move a mount residing in a shared parent. */ - if (IS_MNT_SHARED(old->mnt_parent)) + if (IS_MNT_SHARED(&old->mnt_parent->mnt)) goto out1; /* * Don't move a mount tree containing unbindable mounts to a destination @@ -1909,7 +1909,7 @@ static int do_move_mount(struct path *path, char *old_name) tree_contains_unbindable(old)) goto out1; err = -ELOOP; - for (p = real_mount(path->mnt); mnt_has_parent(p); p = real_mount(p->mnt_parent)) + for (p = real_mount(path->mnt); mnt_has_parent(p); p = p->mnt_parent) if (p == old) goto out1; @@ -2159,7 +2159,7 @@ resume: */ if (this_parent != parent) { next = this_parent->mnt.mnt_child.next; - this_parent = real_mount(this_parent->mnt_parent); + this_parent = this_parent->mnt_parent; goto resume; } return found; @@ -2565,7 +2565,7 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry, { while (&mnt->mnt != root->mnt && mnt_has_parent(mnt)) { dentry = mnt->mnt.mnt_mountpoint; - mnt = real_mount(mnt->mnt_parent); + mnt = mnt->mnt_parent; } return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry); } @@ -2636,8 +2636,8 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, new_mnt = real_mount(new.mnt); root_mnt = real_mount(root.mnt); if (IS_MNT_SHARED(old.mnt) || - IS_MNT_SHARED(new_mnt->mnt_parent) || - IS_MNT_SHARED(root_mnt->mnt_parent)) + IS_MNT_SHARED(&new_mnt->mnt_parent->mnt) || + IS_MNT_SHARED(&root_mnt->mnt_parent->mnt)) goto out4; if (!check_mnt(root.mnt) || !check_mnt(new.mnt)) goto out4; diff --git a/fs/pnode.c b/fs/pnode.c index 2ff4dfa018e1..7fddc671f729 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -292,10 +292,10 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) { struct vfsmount *m; struct mount *child; - struct vfsmount *parent = mnt->mnt_parent; + struct mount *parent = mnt->mnt_parent; int ret = 0; - if (&mnt->mnt == parent) + if (mnt == parent) return do_refcount_check(mnt, refcnt); /* @@ -306,8 +306,8 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) if (!list_empty(&mnt->mnt.mnt_mounts) || do_refcount_check(mnt, refcnt)) return 1; - for (m = propagation_next(parent, parent); m; - m = propagation_next(m, parent)) { + for (m = propagation_next(&parent->mnt, &parent->mnt); m; + m = propagation_next(m, &parent->mnt)) { child = __lookup_mnt(m, mnt->mnt.mnt_mountpoint, 0); if (child && list_empty(&child->mnt.mnt_mounts) && (ret = do_refcount_check(child, 1))) @@ -322,13 +322,13 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) */ static void __propagate_umount(struct mount *mnt) { - struct vfsmount *parent = mnt->mnt_parent; + struct mount *parent = mnt->mnt_parent; struct vfsmount *m; - BUG_ON(parent == &mnt->mnt); + BUG_ON(parent == mnt); - for (m = propagation_next(parent, parent); m; - m = propagation_next(m, parent)) { + for (m = propagation_next(&parent->mnt, &parent->mnt); m; + m = propagation_next(m, &parent->mnt)) { struct mount *child = __lookup_mnt(m, mnt->mnt.mnt_mountpoint, 0); From a73324da7af4052e1d1ddec6a5980f552420e58b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 22:25:07 -0500 Subject: [PATCH 130/165] vfs: move mnt_mountpoint to struct mount Signed-off-by: Al Viro --- fs/dcache.c | 2 +- fs/mount.h | 1 + fs/namei.c | 4 ++-- fs/namespace.c | 35 +++++++++++++++++------------------ fs/pnode.c | 4 ++-- include/linux/mount.h | 1 - 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 98b48753f77b..24790041ea76 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2464,7 +2464,7 @@ static int prepend_path(const struct path *path, /* Global root? */ if (!mnt_has_parent(mnt)) goto global_root; - dentry = mnt->mnt.mnt_mountpoint; + dentry = mnt->mnt_mountpoint; mnt = mnt->mnt_parent; vfsmnt = &mnt->mnt; continue; diff --git a/fs/mount.h b/fs/mount.h index 201dd616e6c4..853738f5897f 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -3,6 +3,7 @@ struct mount { struct list_head mnt_hash; struct mount *mnt_parent; + struct dentry *mnt_mountpoint; struct vfsmount mnt; }; diff --git a/fs/namei.c b/fs/namei.c index 2e9110a37c0e..87363aab43f0 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -684,7 +684,7 @@ static int follow_up_rcu(struct path *path) parent = mnt->mnt_parent; if (&parent->mnt == path->mnt) return 0; - mountpoint = mnt->mnt.mnt_mountpoint; + mountpoint = mnt->mnt_mountpoint; path->dentry = mountpoint; path->mnt = &parent->mnt; return 1; @@ -703,7 +703,7 @@ int follow_up(struct path *path) return 0; } mntget(&parent->mnt); - mountpoint = dget(mnt->mnt.mnt_mountpoint); + mountpoint = dget(mnt->mnt_mountpoint); br_read_unlock(vfsmount_lock); dput(path->dentry); path->dentry = mountpoint; diff --git a/fs/namespace.c b/fs/namespace.c index 5e700c6df579..ec798e77b726 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -476,7 +476,7 @@ struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, if (tmp == head) break; p = list_entry(tmp, struct mount, mnt_hash); - if (&p->mnt_parent->mnt == mnt && p->mnt.mnt_mountpoint == dentry) { + if (&p->mnt_parent->mnt == mnt && p->mnt_mountpoint == dentry) { found = p; break; } @@ -543,7 +543,7 @@ static void dentry_reset_mounted(struct dentry *dentry) struct mount *p; list_for_each_entry(p, &mount_hashtable[u], mnt_hash) { - if (p->mnt.mnt_mountpoint == dentry) + if (p->mnt_mountpoint == dentry) return; } } @@ -557,10 +557,10 @@ static void dentry_reset_mounted(struct dentry *dentry) */ static void detach_mnt(struct mount *mnt, struct path *old_path) { - old_path->dentry = mnt->mnt.mnt_mountpoint; + old_path->dentry = mnt->mnt_mountpoint; old_path->mnt = &mnt->mnt_parent->mnt; mnt->mnt_parent = mnt; - mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt_mountpoint = mnt->mnt.mnt_root; list_del_init(&mnt->mnt.mnt_child); list_del_init(&mnt->mnt_hash); dentry_reset_mounted(old_path->dentry); @@ -573,7 +573,7 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, struct mount *child_mnt) { child_mnt->mnt_parent = real_mount(mntget(mnt)); - child_mnt->mnt.mnt_mountpoint = dget(dentry); + child_mnt->mnt_mountpoint = dget(dentry); spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_MOUNTED; spin_unlock(&dentry->d_lock); @@ -626,7 +626,7 @@ static void commit_tree(struct mount *mnt) list_splice(&head, n->list.prev); list_add_tail(&mnt->mnt_hash, mount_hashtable + - hash(&parent->mnt, mnt->mnt.mnt_mountpoint)); + hash(&parent->mnt, mnt->mnt_mountpoint)); list_add_tail(&mnt->mnt.mnt_child, &parent->mnt.mnt_mounts); touch_mnt_namespace(n); } @@ -681,7 +681,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void mnt->mnt.mnt_root = root; mnt->mnt.mnt_sb = root->d_sb; - mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; return &mnt->mnt; } @@ -709,7 +709,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, atomic_inc(&sb->s_active); mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_root = dget(root); - mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; if (flag & CL_SLAVE) { @@ -1201,9 +1201,9 @@ void release_mounts(struct list_head *head) struct vfsmount *m; br_write_lock(vfsmount_lock); - dentry = mnt->mnt.mnt_mountpoint; + dentry = mnt->mnt_mountpoint; m = &mnt->mnt_parent->mnt; - mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; + mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; m->mnt_ghosts--; br_write_unlock(vfsmount_lock); @@ -1238,7 +1238,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) list_del_init(&p->mnt.mnt_child); if (mnt_has_parent(p)) { p->mnt_parent->mnt.mnt_ghosts++; - dentry_reset_mounted(p->mnt.mnt_mountpoint); + dentry_reset_mounted(p->mnt_mountpoint); } change_mnt_propagation(p, MS_PRIVATE); } @@ -1412,8 +1412,7 @@ static int mount_is_safe(struct path *path) struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, int flag) { - struct mount *res, *p, *q; - struct vfsmount *r; + struct mount *res, *p, *q, *r; struct path path; if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(&mnt->mnt)) @@ -1422,15 +1421,15 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, res = q = clone_mnt(mnt, dentry, flag); if (!q) goto Enomem; - q->mnt.mnt_mountpoint = mnt->mnt.mnt_mountpoint; + q->mnt_mountpoint = mnt->mnt_mountpoint; p = mnt; - list_for_each_entry(r, &mnt->mnt.mnt_mounts, mnt_child) { + list_for_each_entry(r, &mnt->mnt.mnt_mounts, mnt.mnt_child) { struct mount *s; if (!is_subdir(r->mnt_mountpoint, dentry)) continue; - for (s = real_mount(r); s; s = next_mnt(s, r)) { + for (s = r; s; s = next_mnt(s, &r->mnt)) { if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(&s->mnt)) { s = skip_mnt_tree(s); continue; @@ -1441,7 +1440,7 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, } p = s; path.mnt = &q->mnt; - path.dentry = p->mnt.mnt_mountpoint; + path.dentry = p->mnt_mountpoint; q = clone_mnt(p, p->mnt.mnt_root, flag); if (!q) goto Enomem; @@ -2564,7 +2563,7 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry, const struct path *root) { while (&mnt->mnt != root->mnt && mnt_has_parent(mnt)) { - dentry = mnt->mnt.mnt_mountpoint; + dentry = mnt->mnt_mountpoint; mnt = mnt->mnt_parent; } return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry); diff --git a/fs/pnode.c b/fs/pnode.c index 7fddc671f729..bd280200bd37 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -308,7 +308,7 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) for (m = propagation_next(&parent->mnt, &parent->mnt); m; m = propagation_next(m, &parent->mnt)) { - child = __lookup_mnt(m, mnt->mnt.mnt_mountpoint, 0); + child = __lookup_mnt(m, mnt->mnt_mountpoint, 0); if (child && list_empty(&child->mnt.mnt_mounts) && (ret = do_refcount_check(child, 1))) break; @@ -331,7 +331,7 @@ static void __propagate_umount(struct mount *mnt) m = propagation_next(m, &parent->mnt)) { struct mount *child = __lookup_mnt(m, - mnt->mnt.mnt_mountpoint, 0); + mnt->mnt_mountpoint, 0); /* * umount the child only if the child has no * other children diff --git a/include/linux/mount.h b/include/linux/mount.h index b69362d2b5b2..e3f005993d0f 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -53,7 +53,6 @@ struct mnt_pcp { }; struct vfsmount { - struct dentry *mnt_mountpoint; /* dentry of mountpoint */ struct dentry *mnt_root; /* root of the mounted tree */ struct super_block *mnt_sb; /* pointer to superblock */ #ifdef CONFIG_SMP From 83adc7532229f1909cf37c429780f02f06fe05ee Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 22:37:54 -0500 Subject: [PATCH 131/165] vfs: spread struct mount - work with counters Signed-off-by: Al Viro --- fs/namespace.c | 124 +++++++++++++++++++++++++------------------------ fs/pnode.c | 2 +- fs/pnode.h | 2 +- 3 files changed, 66 insertions(+), 62 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index ec798e77b726..a13165c871c2 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -141,13 +141,13 @@ void mnt_release_group_id(struct mount *mnt) /* * vfsmount lock must be held for read */ -static inline void mnt_add_count(struct vfsmount *mnt, int n) +static inline void mnt_add_count(struct mount *mnt, int n) { #ifdef CONFIG_SMP - this_cpu_add(mnt->mnt_pcp->mnt_count, n); + this_cpu_add(mnt->mnt.mnt_pcp->mnt_count, n); #else preempt_disable(); - mnt->mnt_count += n; + mnt->mnt.mnt_count += n; preempt_enable(); #endif } @@ -155,19 +155,19 @@ static inline void mnt_add_count(struct vfsmount *mnt, int n) /* * vfsmount lock must be held for write */ -unsigned int mnt_get_count(struct vfsmount *mnt) +unsigned int mnt_get_count(struct mount *mnt) { #ifdef CONFIG_SMP unsigned int count = 0; int cpu; for_each_possible_cpu(cpu) { - count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count; + count += per_cpu_ptr(mnt->mnt.mnt_pcp, cpu)->mnt_count; } return count; #else - return mnt->mnt_count; + return mnt->mnt.mnt_count; #endif } @@ -253,32 +253,32 @@ int __mnt_is_readonly(struct vfsmount *mnt) } EXPORT_SYMBOL_GPL(__mnt_is_readonly); -static inline void mnt_inc_writers(struct vfsmount *mnt) +static inline void mnt_inc_writers(struct mount *mnt) { #ifdef CONFIG_SMP - this_cpu_inc(mnt->mnt_pcp->mnt_writers); + this_cpu_inc(mnt->mnt.mnt_pcp->mnt_writers); #else - mnt->mnt_writers++; + mnt->mnt.mnt_writers++; #endif } -static inline void mnt_dec_writers(struct vfsmount *mnt) +static inline void mnt_dec_writers(struct mount *mnt) { #ifdef CONFIG_SMP - this_cpu_dec(mnt->mnt_pcp->mnt_writers); + this_cpu_dec(mnt->mnt.mnt_pcp->mnt_writers); #else - mnt->mnt_writers--; + mnt->mnt.mnt_writers--; #endif } -static unsigned int mnt_get_writers(struct vfsmount *mnt) +static unsigned int mnt_get_writers(struct mount *mnt) { #ifdef CONFIG_SMP unsigned int count = 0; int cpu; for_each_possible_cpu(cpu) { - count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_writers; + count += per_cpu_ptr(mnt->mnt.mnt_pcp, cpu)->mnt_writers; } return count; @@ -297,7 +297,7 @@ static unsigned int mnt_get_writers(struct vfsmount *mnt) */ /** * mnt_want_write - get write access to a mount - * @mnt: the mount on which to take a write + * @m: the mount on which to take a write * * This tells the low-level filesystem that a write is * about to be performed to it, and makes sure that @@ -305,8 +305,9 @@ static unsigned int mnt_get_writers(struct vfsmount *mnt) * the write operation is finished, mnt_drop_write() * must be called. This is effectively a refcount. */ -int mnt_want_write(struct vfsmount *mnt) +int mnt_want_write(struct vfsmount *m) { + struct mount *mnt = real_mount(m); int ret = 0; preempt_disable(); @@ -317,7 +318,7 @@ int mnt_want_write(struct vfsmount *mnt) * incremented count after it has set MNT_WRITE_HOLD. */ smp_mb(); - while (mnt->mnt_flags & MNT_WRITE_HOLD) + while (mnt->mnt.mnt_flags & MNT_WRITE_HOLD) cpu_relax(); /* * After the slowpath clears MNT_WRITE_HOLD, mnt_is_readonly will @@ -325,7 +326,7 @@ int mnt_want_write(struct vfsmount *mnt) * MNT_WRITE_HOLD is cleared. */ smp_rmb(); - if (__mnt_is_readonly(mnt)) { + if (__mnt_is_readonly(m)) { mnt_dec_writers(mnt); ret = -EROFS; goto out; @@ -354,7 +355,7 @@ int mnt_clone_write(struct vfsmount *mnt) if (__mnt_is_readonly(mnt)) return -EROFS; preempt_disable(); - mnt_inc_writers(mnt); + mnt_inc_writers(real_mount(mnt)); preempt_enable(); return 0; } @@ -388,7 +389,7 @@ EXPORT_SYMBOL_GPL(mnt_want_write_file); void mnt_drop_write(struct vfsmount *mnt) { preempt_disable(); - mnt_dec_writers(mnt); + mnt_dec_writers(real_mount(mnt)); preempt_enable(); } EXPORT_SYMBOL_GPL(mnt_drop_write); @@ -399,12 +400,12 @@ void mnt_drop_write_file(struct file *file) } EXPORT_SYMBOL(mnt_drop_write_file); -static int mnt_make_readonly(struct vfsmount *mnt) +static int mnt_make_readonly(struct mount *mnt) { int ret = 0; br_write_lock(vfsmount_lock); - mnt->mnt_flags |= MNT_WRITE_HOLD; + mnt->mnt.mnt_flags |= MNT_WRITE_HOLD; /* * After storing MNT_WRITE_HOLD, we'll read the counters. This store * should be visible before we do. @@ -430,21 +431,21 @@ static int mnt_make_readonly(struct vfsmount *mnt) if (mnt_get_writers(mnt) > 0) ret = -EBUSY; else - mnt->mnt_flags |= MNT_READONLY; + mnt->mnt.mnt_flags |= MNT_READONLY; /* * MNT_READONLY must become visible before ~MNT_WRITE_HOLD, so writers * that become unheld will see MNT_READONLY. */ smp_wmb(); - mnt->mnt_flags &= ~MNT_WRITE_HOLD; + mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; br_write_unlock(vfsmount_lock); return ret; } -static void __mnt_unmake_readonly(struct vfsmount *mnt) +static void __mnt_unmake_readonly(struct mount *mnt) { br_write_lock(vfsmount_lock); - mnt->mnt_flags &= ~MNT_READONLY; + mnt->mnt.mnt_flags &= ~MNT_READONLY; br_write_unlock(vfsmount_lock); } @@ -590,18 +591,18 @@ static void attach_mnt(struct mount *mnt, struct path *path) list_add_tail(&mnt->mnt.mnt_child, &path->mnt->mnt_mounts); } -static inline void __mnt_make_longterm(struct vfsmount *mnt) +static inline void __mnt_make_longterm(struct mount *mnt) { #ifdef CONFIG_SMP - atomic_inc(&mnt->mnt_longterm); + atomic_inc(&mnt->mnt.mnt_longterm); #endif } /* needs vfsmount lock for write */ -static inline void __mnt_make_shortterm(struct vfsmount *mnt) +static inline void __mnt_make_shortterm(struct mount *mnt) { #ifdef CONFIG_SMP - atomic_dec(&mnt->mnt_longterm); + atomic_dec(&mnt->mnt.mnt_longterm); #endif } @@ -611,15 +612,15 @@ static inline void __mnt_make_shortterm(struct vfsmount *mnt) static void commit_tree(struct mount *mnt) { struct mount *parent = mnt->mnt_parent; - struct vfsmount *m; + struct mount *m; LIST_HEAD(head); struct mnt_namespace *n = parent->mnt.mnt_ns; BUG_ON(parent == mnt); list_add_tail(&head, &mnt->mnt.mnt_list); - list_for_each_entry(m, &head, mnt_list) { - m->mnt_ns = n; + list_for_each_entry(m, &head, mnt.mnt_list) { + m->mnt.mnt_ns = n; __mnt_make_longterm(m); } @@ -740,9 +741,10 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, return NULL; } -static inline void mntfree(struct vfsmount *mnt) +static inline void mntfree(struct mount *mnt) { - struct super_block *sb = mnt->mnt_sb; + struct vfsmount *m = &mnt->mnt; + struct super_block *sb = m->mnt_sb; /* * This probably indicates that somebody messed @@ -755,18 +757,19 @@ static inline void mntfree(struct vfsmount *mnt) * so mnt_get_writers() below is safe. */ WARN_ON(mnt_get_writers(mnt)); - fsnotify_vfsmount_delete(mnt); - dput(mnt->mnt_root); - free_vfsmnt(real_mount(mnt)); + fsnotify_vfsmount_delete(m); + dput(m->mnt_root); + free_vfsmnt(mnt); deactivate_super(sb); } -static void mntput_no_expire(struct vfsmount *mnt) +static void mntput_no_expire(struct vfsmount *m) { + struct mount *mnt = real_mount(m); put_again: #ifdef CONFIG_SMP br_read_lock(vfsmount_lock); - if (likely(atomic_read(&mnt->mnt_longterm))) { + if (likely(atomic_read(&mnt->mnt.mnt_longterm))) { mnt_add_count(mnt, -1); br_read_unlock(vfsmount_lock); return; @@ -785,11 +788,11 @@ put_again: return; br_write_lock(vfsmount_lock); #endif - if (unlikely(mnt->mnt_pinned)) { - mnt_add_count(mnt, mnt->mnt_pinned + 1); - mnt->mnt_pinned = 0; + if (unlikely(mnt->mnt.mnt_pinned)) { + mnt_add_count(mnt, mnt->mnt.mnt_pinned + 1); + mnt->mnt.mnt_pinned = 0; br_write_unlock(vfsmount_lock); - acct_auto_close_mnt(mnt); + acct_auto_close_mnt(m); goto put_again; } br_write_unlock(vfsmount_lock); @@ -810,7 +813,7 @@ EXPORT_SYMBOL(mntput); struct vfsmount *mntget(struct vfsmount *mnt) { if (mnt) - mnt_add_count(mnt, 1); + mnt_add_count(real_mount(mnt), 1); return mnt; } EXPORT_SYMBOL(mntget); @@ -827,7 +830,7 @@ void mnt_unpin(struct vfsmount *mnt) { br_write_lock(vfsmount_lock); if (mnt->mnt_pinned) { - mnt_add_count(mnt, 1); + mnt_add_count(real_mount(mnt), 1); mnt->mnt_pinned--; } br_write_unlock(vfsmount_lock); @@ -1150,7 +1153,7 @@ int may_umount_tree(struct vfsmount *mnt) /* write lock needed for mnt_get_count */ br_write_lock(vfsmount_lock); for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) { - actual_refs += mnt_get_count(&p->mnt); + actual_refs += mnt_get_count(p); minimum_refs += 2; } br_write_unlock(vfsmount_lock); @@ -1234,7 +1237,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) list_del_init(&p->mnt.mnt_list); __touch_mnt_namespace(p->mnt.mnt_ns); p->mnt.mnt_ns = NULL; - __mnt_make_shortterm(&p->mnt); + __mnt_make_shortterm(p); list_del_init(&p->mnt.mnt_child); if (mnt_has_parent(p)) { p->mnt_parent->mnt.mnt_ghosts++; @@ -1273,7 +1276,7 @@ static int do_umount(struct mount *mnt, int flags) * all race cases, but it's a slowpath. */ br_write_lock(vfsmount_lock); - if (mnt_get_count(&mnt->mnt) != 2) { + if (mnt_get_count(mnt) != 2) { br_write_unlock(vfsmount_lock); return -EBUSY; } @@ -1798,9 +1801,9 @@ static int change_mount_flags(struct vfsmount *mnt, int ms_flags) return 0; if (readonly_request) - error = mnt_make_readonly(mnt); + error = mnt_make_readonly(real_mount(mnt)); else - __mnt_unmake_readonly(mnt); + __mnt_unmake_readonly(real_mount(mnt)); return error; } @@ -2034,7 +2037,7 @@ int finish_automount(struct vfsmount *m, struct path *path) /* The new mount record should have at least 2 refs to prevent it being * expired before we get a chance to add it */ - BUG_ON(mnt_get_count(m) < 2); + BUG_ON(mnt_get_count(real_mount(m)) < 2); if (m->mnt_sb == path->mnt->mnt_sb && m->mnt_root == path->dentry) { @@ -2365,16 +2368,17 @@ static struct mnt_namespace *alloc_mnt_ns(void) void mnt_make_longterm(struct vfsmount *mnt) { - __mnt_make_longterm(mnt); + __mnt_make_longterm(real_mount(mnt)); } -void mnt_make_shortterm(struct vfsmount *mnt) +void mnt_make_shortterm(struct vfsmount *m) { #ifdef CONFIG_SMP - if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) + struct mount *mnt = real_mount(m); + if (atomic_add_unless(&mnt->mnt.mnt_longterm, -1, 1)) return; br_write_lock(vfsmount_lock); - atomic_dec(&mnt->mnt_longterm); + atomic_dec(&mnt->mnt.mnt_longterm); br_write_unlock(vfsmount_lock); #endif } @@ -2418,17 +2422,17 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, q = new; while (p) { q->mnt.mnt_ns = new_ns; - __mnt_make_longterm(&q->mnt); + __mnt_make_longterm(q); if (fs) { if (&p->mnt == fs->root.mnt) { fs->root.mnt = mntget(&q->mnt); - __mnt_make_longterm(&q->mnt); + __mnt_make_longterm(q); mnt_make_shortterm(&p->mnt); rootmnt = &p->mnt; } if (&p->mnt == fs->pwd.mnt) { fs->pwd.mnt = mntget(&q->mnt); - __mnt_make_longterm(&q->mnt); + __mnt_make_longterm(q); mnt_make_shortterm(&p->mnt); pwdmnt = &p->mnt; } @@ -2474,7 +2478,7 @@ static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) new_ns = alloc_mnt_ns(); if (!IS_ERR(new_ns)) { mnt->mnt_ns = new_ns; - __mnt_make_longterm(mnt); + __mnt_make_longterm(real_mount(mnt)); new_ns->root = mnt; list_add(&new_ns->list, &new_ns->root->mnt_list); } else { diff --git a/fs/pnode.c b/fs/pnode.c index bd280200bd37..50fdb29eebfe 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -274,7 +274,7 @@ out: */ static inline int do_refcount_check(struct mount *mnt, int count) { - int mycount = mnt_get_count(&mnt->mnt) - mnt->mnt.mnt_ghosts; + int mycount = mnt_get_count(mnt) - mnt->mnt.mnt_ghosts; return (mycount > count); } diff --git a/fs/pnode.h b/fs/pnode.h index 866b3e292887..0a7a919d5efd 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -36,7 +36,7 @@ int propagate_umount(struct list_head *); int propagate_mount_busy(struct mount *, int); void mnt_release_group_id(struct mount *); int get_dominating_id(struct vfsmount *mnt, const struct path *root); -unsigned int mnt_get_count(struct vfsmount *mnt); +unsigned int mnt_get_count(struct mount *mnt); void mnt_set_mountpoint(struct vfsmount *, struct dentry *, struct mount *); void release_mounts(struct list_head *); From 68e8a9feab251f9d3c8fd9e9893c97843bcd4bd0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 22:53:09 -0500 Subject: [PATCH 132/165] vfs: all counters taken to struct mount Signed-off-by: Al Viro --- fs/mount.h | 12 ++++++++++++ fs/namespace.c | 40 ++++++++++++++++++++-------------------- include/linux/mount.h | 12 ------------ 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 853738f5897f..452ae41e0131 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -1,10 +1,22 @@ #include +struct mnt_pcp { + int mnt_count; + int mnt_writers; +}; + struct mount { struct list_head mnt_hash; struct mount *mnt_parent; struct dentry *mnt_mountpoint; struct vfsmount mnt; +#ifdef CONFIG_SMP + struct mnt_pcp __percpu *mnt_pcp; + atomic_t mnt_longterm; /* how many of the refs are longterm */ +#else + int mnt_count; + int mnt_writers; +#endif }; static inline struct mount *real_mount(struct vfsmount *mnt) diff --git a/fs/namespace.c b/fs/namespace.c index a13165c871c2..3fdd30add4f9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -144,10 +144,10 @@ void mnt_release_group_id(struct mount *mnt) static inline void mnt_add_count(struct mount *mnt, int n) { #ifdef CONFIG_SMP - this_cpu_add(mnt->mnt.mnt_pcp->mnt_count, n); + this_cpu_add(mnt->mnt_pcp->mnt_count, n); #else preempt_disable(); - mnt->mnt.mnt_count += n; + mnt->mnt_count += n; preempt_enable(); #endif } @@ -162,12 +162,12 @@ unsigned int mnt_get_count(struct mount *mnt) int cpu; for_each_possible_cpu(cpu) { - count += per_cpu_ptr(mnt->mnt.mnt_pcp, cpu)->mnt_count; + count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count; } return count; #else - return mnt->mnt.mnt_count; + return mnt->mnt_count; #endif } @@ -189,14 +189,14 @@ static struct mount *alloc_vfsmnt(const char *name) } #ifdef CONFIG_SMP - mnt->mnt_pcp = alloc_percpu(struct mnt_pcp); - if (!mnt->mnt_pcp) + p->mnt_pcp = alloc_percpu(struct mnt_pcp); + if (!p->mnt_pcp) goto out_free_devname; - this_cpu_add(mnt->mnt_pcp->mnt_count, 1); + this_cpu_add(p->mnt_pcp->mnt_count, 1); #else - mnt->mnt_count = 1; - mnt->mnt_writers = 0; + p->mnt_count = 1; + p->mnt_writers = 0; #endif INIT_LIST_HEAD(&p->mnt_hash); @@ -256,18 +256,18 @@ EXPORT_SYMBOL_GPL(__mnt_is_readonly); static inline void mnt_inc_writers(struct mount *mnt) { #ifdef CONFIG_SMP - this_cpu_inc(mnt->mnt.mnt_pcp->mnt_writers); + this_cpu_inc(mnt->mnt_pcp->mnt_writers); #else - mnt->mnt.mnt_writers++; + mnt->mnt_writers++; #endif } static inline void mnt_dec_writers(struct mount *mnt) { #ifdef CONFIG_SMP - this_cpu_dec(mnt->mnt.mnt_pcp->mnt_writers); + this_cpu_dec(mnt->mnt_pcp->mnt_writers); #else - mnt->mnt.mnt_writers--; + mnt->mnt_writers--; #endif } @@ -278,7 +278,7 @@ static unsigned int mnt_get_writers(struct mount *mnt) int cpu; for_each_possible_cpu(cpu) { - count += per_cpu_ptr(mnt->mnt.mnt_pcp, cpu)->mnt_writers; + count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_writers; } return count; @@ -454,7 +454,7 @@ static void free_vfsmnt(struct mount *mnt) kfree(mnt->mnt.mnt_devname); mnt_free_id(mnt); #ifdef CONFIG_SMP - free_percpu(mnt->mnt.mnt_pcp); + free_percpu(mnt->mnt_pcp); #endif kmem_cache_free(mnt_cache, mnt); } @@ -594,7 +594,7 @@ static void attach_mnt(struct mount *mnt, struct path *path) static inline void __mnt_make_longterm(struct mount *mnt) { #ifdef CONFIG_SMP - atomic_inc(&mnt->mnt.mnt_longterm); + atomic_inc(&mnt->mnt_longterm); #endif } @@ -602,7 +602,7 @@ static inline void __mnt_make_longterm(struct mount *mnt) static inline void __mnt_make_shortterm(struct mount *mnt) { #ifdef CONFIG_SMP - atomic_dec(&mnt->mnt.mnt_longterm); + atomic_dec(&mnt->mnt_longterm); #endif } @@ -769,7 +769,7 @@ static void mntput_no_expire(struct vfsmount *m) put_again: #ifdef CONFIG_SMP br_read_lock(vfsmount_lock); - if (likely(atomic_read(&mnt->mnt.mnt_longterm))) { + if (likely(atomic_read(&mnt->mnt_longterm))) { mnt_add_count(mnt, -1); br_read_unlock(vfsmount_lock); return; @@ -2375,10 +2375,10 @@ void mnt_make_shortterm(struct vfsmount *m) { #ifdef CONFIG_SMP struct mount *mnt = real_mount(m); - if (atomic_add_unless(&mnt->mnt.mnt_longterm, -1, 1)) + if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) return; br_write_lock(vfsmount_lock); - atomic_dec(&mnt->mnt.mnt_longterm); + atomic_dec(&mnt->mnt_longterm); br_write_unlock(vfsmount_lock); #endif } diff --git a/include/linux/mount.h b/include/linux/mount.h index e3f005993d0f..cc01ed1bc719 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -47,21 +47,9 @@ struct mnt_namespace; #define MNT_INTERNAL 0x4000 -struct mnt_pcp { - int mnt_count; - int mnt_writers; -}; - struct vfsmount { struct dentry *mnt_root; /* root of the mounted tree */ struct super_block *mnt_sb; /* pointer to superblock */ -#ifdef CONFIG_SMP - struct mnt_pcp __percpu *mnt_pcp; - atomic_t mnt_longterm; /* how many of the refs are longterm */ -#else - int mnt_count; - int mnt_writers; -#endif struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_child; /* and going through their mnt_child */ int mnt_flags; From 6b41d536f7c84e7cb1c1462073150277e46f6ea8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 23:24:33 -0500 Subject: [PATCH 133/165] vfs: take mnt_child/mnt_mounts to struct mount Signed-off-by: Al Viro --- fs/mount.h | 2 ++ fs/namespace.c | 42 +++++++++++++++++++++--------------------- fs/pnode.c | 6 +++--- include/linux/mount.h | 2 -- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 452ae41e0131..e4ecf59c9353 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -17,6 +17,8 @@ struct mount { int mnt_count; int mnt_writers; #endif + struct list_head mnt_mounts; /* list of children, anchored here */ + struct list_head mnt_child; /* and going through their mnt_child */ }; static inline struct mount *real_mount(struct vfsmount *mnt) diff --git a/fs/namespace.c b/fs/namespace.c index 3fdd30add4f9..9ceb03fe176f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -200,8 +200,8 @@ static struct mount *alloc_vfsmnt(const char *name) #endif INIT_LIST_HEAD(&p->mnt_hash); - INIT_LIST_HEAD(&mnt->mnt_child); - INIT_LIST_HEAD(&mnt->mnt_mounts); + INIT_LIST_HEAD(&p->mnt_child); + INIT_LIST_HEAD(&p->mnt_mounts); INIT_LIST_HEAD(&mnt->mnt_list); INIT_LIST_HEAD(&mnt->mnt_expire); INIT_LIST_HEAD(&mnt->mnt_share); @@ -562,7 +562,7 @@ static void detach_mnt(struct mount *mnt, struct path *old_path) old_path->mnt = &mnt->mnt_parent->mnt; mnt->mnt_parent = mnt; mnt->mnt_mountpoint = mnt->mnt.mnt_root; - list_del_init(&mnt->mnt.mnt_child); + list_del_init(&mnt->mnt_child); list_del_init(&mnt->mnt_hash); dentry_reset_mounted(old_path->dentry); } @@ -588,7 +588,7 @@ static void attach_mnt(struct mount *mnt, struct path *path) mnt_set_mountpoint(path->mnt, path->dentry, mnt); list_add_tail(&mnt->mnt_hash, mount_hashtable + hash(path->mnt, path->dentry)); - list_add_tail(&mnt->mnt.mnt_child, &path->mnt->mnt_mounts); + list_add_tail(&mnt->mnt_child, &real_mount(path->mnt)->mnt_mounts); } static inline void __mnt_make_longterm(struct mount *mnt) @@ -628,32 +628,32 @@ static void commit_tree(struct mount *mnt) list_add_tail(&mnt->mnt_hash, mount_hashtable + hash(&parent->mnt, mnt->mnt_mountpoint)); - list_add_tail(&mnt->mnt.mnt_child, &parent->mnt.mnt_mounts); + list_add_tail(&mnt->mnt_child, &parent->mnt_mounts); touch_mnt_namespace(n); } static struct mount *next_mnt(struct mount *p, struct vfsmount *root) { - struct list_head *next = p->mnt.mnt_mounts.next; - if (next == &p->mnt.mnt_mounts) { + struct list_head *next = p->mnt_mounts.next; + if (next == &p->mnt_mounts) { while (1) { if (&p->mnt == root) return NULL; - next = p->mnt.mnt_child.next; - if (next != &p->mnt_parent->mnt.mnt_mounts) + next = p->mnt_child.next; + if (next != &p->mnt_parent->mnt_mounts) break; p = p->mnt_parent; } } - return list_entry(next, struct mount, mnt.mnt_child); + return list_entry(next, struct mount, mnt_child); } static struct mount *skip_mnt_tree(struct mount *p) { - struct list_head *prev = p->mnt.mnt_mounts.prev; - while (prev != &p->mnt.mnt_mounts) { - p = list_entry(prev, struct mount, mnt.mnt_child); - prev = p->mnt.mnt_mounts.prev; + struct list_head *prev = p->mnt_mounts.prev; + while (prev != &p->mnt_mounts) { + p = list_entry(prev, struct mount, mnt_child); + prev = p->mnt_mounts.prev; } return p; } @@ -1238,7 +1238,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) __touch_mnt_namespace(p->mnt.mnt_ns); p->mnt.mnt_ns = NULL; __mnt_make_shortterm(p); - list_del_init(&p->mnt.mnt_child); + list_del_init(&p->mnt_child); if (mnt_has_parent(p)) { p->mnt_parent->mnt.mnt_ghosts++; dentry_reset_mounted(p->mnt_mountpoint); @@ -1427,7 +1427,7 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, q->mnt_mountpoint = mnt->mnt_mountpoint; p = mnt; - list_for_each_entry(r, &mnt->mnt.mnt_mounts, mnt.mnt_child) { + list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) { struct mount *s; if (!is_subdir(r->mnt_mountpoint, dentry)) continue; @@ -2134,11 +2134,11 @@ static int select_submounts(struct mount *parent, struct list_head *graveyard) int found = 0; repeat: - next = this_parent->mnt.mnt_mounts.next; + next = this_parent->mnt_mounts.next; resume: - while (next != &this_parent->mnt.mnt_mounts) { + while (next != &this_parent->mnt_mounts) { struct list_head *tmp = next; - struct mount *mnt = list_entry(tmp, struct mount, mnt.mnt_child); + struct mount *mnt = list_entry(tmp, struct mount, mnt_child); next = tmp->next; if (!(mnt->mnt.mnt_flags & MNT_SHRINKABLE)) @@ -2146,7 +2146,7 @@ resume: /* * Descend a level if the d_mounts list is non-empty. */ - if (!list_empty(&mnt->mnt.mnt_mounts)) { + if (!list_empty(&mnt->mnt_mounts)) { this_parent = mnt; goto repeat; } @@ -2160,7 +2160,7 @@ resume: * All done at this level ... ascend and resume the search */ if (this_parent != parent) { - next = this_parent->mnt.mnt_child.next; + next = this_parent->mnt_child.next; this_parent = this_parent->mnt_parent; goto resume; } diff --git a/fs/pnode.c b/fs/pnode.c index 50fdb29eebfe..8cd90d2ec05e 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -303,13 +303,13 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) * If not, we don't have to go checking for all other * mounts */ - if (!list_empty(&mnt->mnt.mnt_mounts) || do_refcount_check(mnt, refcnt)) + if (!list_empty(&mnt->mnt_mounts) || do_refcount_check(mnt, refcnt)) return 1; for (m = propagation_next(&parent->mnt, &parent->mnt); m; m = propagation_next(m, &parent->mnt)) { child = __lookup_mnt(m, mnt->mnt_mountpoint, 0); - if (child && list_empty(&child->mnt.mnt_mounts) && + if (child && list_empty(&child->mnt_mounts) && (ret = do_refcount_check(child, 1))) break; } @@ -336,7 +336,7 @@ static void __propagate_umount(struct mount *mnt) * umount the child only if the child has no * other children */ - if (child && list_empty(&child->mnt.mnt_mounts)) + if (child && list_empty(&child->mnt_mounts)) list_move_tail(&child->mnt_hash, &mnt->mnt_hash); } } diff --git a/include/linux/mount.h b/include/linux/mount.h index cc01ed1bc719..e9990254d4d0 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -50,8 +50,6 @@ struct mnt_namespace; struct vfsmount { struct dentry *mnt_root; /* root of the mounted tree */ struct super_block *mnt_sb; /* pointer to superblock */ - struct list_head mnt_mounts; /* list of children, anchored here */ - struct list_head mnt_child; /* and going through their mnt_child */ int mnt_flags; /* 4 bytes hole on 64bits arches without fsnotify */ #ifdef CONFIG_FSNOTIFY From 6fc7871fed915914ef441efbe0f9a7c3d0f3bff1 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 23:35:54 -0500 Subject: [PATCH 134/165] vfs: spread struct mount - get_dominating_id / do_make_slave next pile of horrors, similar to mnt_parent one; this time it's mnt_master. Signed-off-by: Al Viro --- fs/namespace.c | 2 +- fs/pnode.c | 58 +++++++++++++++++++++++++------------------------- fs/pnode.h | 2 +- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 9ceb03fe176f..65d011fe982f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1053,7 +1053,7 @@ static int show_mountinfo(struct seq_file *m, void *v) seq_printf(m, " shared:%i", mnt->mnt_group_id); if (IS_MNT_SLAVE(mnt)) { int master = mnt->mnt_master->mnt_group_id; - int dom = get_dominating_id(mnt, &p->root); + int dom = get_dominating_id(r, &p->root); seq_printf(m, " master:%i", master); if (dom && dom != master) seq_printf(m, " propagate_from:%i", dom); diff --git a/fs/pnode.c b/fs/pnode.c index 8cd90d2ec05e..29e366dec024 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -28,19 +28,19 @@ static inline struct vfsmount *next_slave(struct vfsmount *p) return list_entry(p->mnt_slave.next, struct vfsmount, mnt_slave); } -static struct vfsmount *get_peer_under_root(struct vfsmount *mnt, - struct mnt_namespace *ns, - const struct path *root) +static struct mount *get_peer_under_root(struct mount *mnt, + struct mnt_namespace *ns, + const struct path *root) { - struct mount *m = real_mount(mnt); + struct mount *m = mnt; do { /* Check the namespace first for optimization */ if (m->mnt.mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root)) - return &m->mnt; + return m; m = real_mount(next_peer(&m->mnt)); - } while (&m->mnt != mnt); + } while (m != mnt); return NULL; } @@ -51,22 +51,22 @@ static struct vfsmount *get_peer_under_root(struct vfsmount *mnt, * * Caller must hold namespace_sem */ -int get_dominating_id(struct vfsmount *mnt, const struct path *root) +int get_dominating_id(struct mount *mnt, const struct path *root) { - struct vfsmount *m; + struct mount *m; - for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) { - struct vfsmount *d = get_peer_under_root(m, mnt->mnt_ns, root); + for (m = real_mount(mnt->mnt.mnt_master); m != NULL; m = real_mount(m->mnt.mnt_master)) { + struct mount *d = get_peer_under_root(m, mnt->mnt.mnt_ns, root); if (d) - return d->mnt_group_id; + return d->mnt.mnt_group_id; } return 0; } -static int do_make_slave(struct vfsmount *mnt) +static int do_make_slave(struct mount *mnt) { - struct vfsmount *peer_mnt = mnt, *master = mnt->mnt_master; + struct mount *peer_mnt = mnt, *master = real_mount(mnt->mnt.mnt_master); struct vfsmount *slave_mnt; /* @@ -74,31 +74,31 @@ static int do_make_slave(struct vfsmount *mnt) * same root dentry. If none is available then * slave it to anything that is available. */ - while ((peer_mnt = next_peer(peer_mnt)) != mnt && - peer_mnt->mnt_root != mnt->mnt_root) ; + while ((peer_mnt = real_mount(next_peer(&peer_mnt->mnt))) != mnt && + peer_mnt->mnt.mnt_root != mnt->mnt.mnt_root) ; if (peer_mnt == mnt) { - peer_mnt = next_peer(mnt); + peer_mnt = real_mount(next_peer(&mnt->mnt)); if (peer_mnt == mnt) peer_mnt = NULL; } - if (IS_MNT_SHARED(mnt) && list_empty(&mnt->mnt_share)) - mnt_release_group_id(real_mount(mnt)); + if (IS_MNT_SHARED(&mnt->mnt) && list_empty(&mnt->mnt.mnt_share)) + mnt_release_group_id(mnt); - list_del_init(&mnt->mnt_share); - mnt->mnt_group_id = 0; + list_del_init(&mnt->mnt.mnt_share); + mnt->mnt.mnt_group_id = 0; if (peer_mnt) master = peer_mnt; if (master) { - list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave) - slave_mnt->mnt_master = master; - list_move(&mnt->mnt_slave, &master->mnt_slave_list); - list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev); - INIT_LIST_HEAD(&mnt->mnt_slave_list); + list_for_each_entry(slave_mnt, &mnt->mnt.mnt_slave_list, mnt_slave) + slave_mnt->mnt_master = &master->mnt; + list_move(&mnt->mnt.mnt_slave, &master->mnt.mnt_slave_list); + list_splice(&mnt->mnt.mnt_slave_list, master->mnt.mnt_slave_list.prev); + INIT_LIST_HEAD(&mnt->mnt.mnt_slave_list); } else { - struct list_head *p = &mnt->mnt_slave_list; + struct list_head *p = &mnt->mnt.mnt_slave_list; while (!list_empty(p)) { slave_mnt = list_first_entry(p, struct vfsmount, mnt_slave); @@ -106,8 +106,8 @@ static int do_make_slave(struct vfsmount *mnt) slave_mnt->mnt_master = NULL; } } - mnt->mnt_master = master; - CLEAR_MNT_SHARED(mnt); + mnt->mnt.mnt_master = &master->mnt; + CLEAR_MNT_SHARED(&mnt->mnt); return 0; } @@ -120,7 +120,7 @@ void change_mnt_propagation(struct mount *mnt, int type) set_mnt_shared(mnt); return; } - do_make_slave(&mnt->mnt); + do_make_slave(mnt); if (type != MS_SLAVE) { list_del_init(&mnt->mnt.mnt_slave); mnt->mnt.mnt_master = NULL; diff --git a/fs/pnode.h b/fs/pnode.h index 0a7a919d5efd..33f1e3cb3cd2 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -35,7 +35,7 @@ int propagate_mnt(struct vfsmount *, struct dentry *, struct vfsmount *, int propagate_umount(struct list_head *); int propagate_mount_busy(struct mount *, int); void mnt_release_group_id(struct mount *); -int get_dominating_id(struct vfsmount *mnt, const struct path *root); +int get_dominating_id(struct mount *mnt, const struct path *root); unsigned int mnt_get_count(struct mount *mnt); void mnt_set_mountpoint(struct vfsmount *, struct dentry *, struct mount *); From c937135d98f2306157fb8d8a03a4d8b0f1e3b511 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 23:56:26 -0500 Subject: [PATCH 135/165] vfs: spread struct mount - shared subtree iterators Signed-off-by: Al Viro --- fs/pnode.c | 97 ++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 50 deletions(-) diff --git a/fs/pnode.c b/fs/pnode.c index 29e366dec024..f86cd4bc31ce 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -13,19 +13,19 @@ #include "pnode.h" /* return the next shared peer mount of @p */ -static inline struct vfsmount *next_peer(struct vfsmount *p) +static inline struct mount *next_peer(struct mount *p) { - return list_entry(p->mnt_share.next, struct vfsmount, mnt_share); + return list_entry(p->mnt.mnt_share.next, struct mount, mnt.mnt_share); } -static inline struct vfsmount *first_slave(struct vfsmount *p) +static inline struct mount *first_slave(struct mount *p) { - return list_entry(p->mnt_slave_list.next, struct vfsmount, mnt_slave); + return list_entry(p->mnt.mnt_slave_list.next, struct mount, mnt.mnt_slave); } -static inline struct vfsmount *next_slave(struct vfsmount *p) +static inline struct mount *next_slave(struct mount *p) { - return list_entry(p->mnt_slave.next, struct vfsmount, mnt_slave); + return list_entry(p->mnt.mnt_slave.next, struct mount, mnt.mnt_slave); } static struct mount *get_peer_under_root(struct mount *mnt, @@ -39,7 +39,7 @@ static struct mount *get_peer_under_root(struct mount *mnt, if (m->mnt.mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root)) return m; - m = real_mount(next_peer(&m->mnt)); + m = next_peer(m); } while (m != mnt); return NULL; @@ -74,11 +74,11 @@ static int do_make_slave(struct mount *mnt) * same root dentry. If none is available then * slave it to anything that is available. */ - while ((peer_mnt = real_mount(next_peer(&peer_mnt->mnt))) != mnt && + while ((peer_mnt = next_peer(peer_mnt)) != mnt && peer_mnt->mnt.mnt_root != mnt->mnt.mnt_root) ; if (peer_mnt == mnt) { - peer_mnt = real_mount(next_peer(&mnt->mnt)); + peer_mnt = next_peer(mnt); if (peer_mnt == mnt) peer_mnt = NULL; } @@ -141,21 +141,20 @@ void change_mnt_propagation(struct mount *mnt, int type) * vfsmount found while iterating with propagation_next() is * a peer of one we'd found earlier. */ -static struct vfsmount *propagation_next(struct vfsmount *m, - struct vfsmount *origin) +static struct mount *propagation_next(struct mount *m, + struct mount *origin) { /* are there any slaves of this mount? */ - if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list)) + if (!IS_MNT_NEW(&m->mnt) && !list_empty(&m->mnt.mnt_slave_list)) return first_slave(m); while (1) { - struct vfsmount *next; - struct vfsmount *master = m->mnt_master; + struct mount *master = real_mount(m->mnt.mnt_master); - if (master == origin->mnt_master) { - next = next_peer(m); - return ((next == origin) ? NULL : next); - } else if (m->mnt_slave.next != &master->mnt_slave_list) + if (&master->mnt == origin->mnt.mnt_master) { + struct mount *next = next_peer(m); + return (next == origin) ? NULL : next; + } else if (m->mnt.mnt_slave.next != &master->mnt.mnt_slave_list) return next_slave(m); /* back at master */ @@ -172,25 +171,25 @@ static struct vfsmount *propagation_next(struct vfsmount *m, * @type return CL_SLAVE if the new mount has to be * cloned as a slave. */ -static struct vfsmount *get_source(struct vfsmount *dest, - struct vfsmount *last_dest, - struct vfsmount *last_src, - int *type) +static struct mount *get_source(struct mount *dest, + struct mount *last_dest, + struct mount *last_src, + int *type) { - struct vfsmount *p_last_src = NULL; - struct vfsmount *p_last_dest = NULL; + struct mount *p_last_src = NULL; + struct mount *p_last_dest = NULL; - while (last_dest != dest->mnt_master) { + while (&last_dest->mnt != dest->mnt.mnt_master) { p_last_dest = last_dest; p_last_src = last_src; - last_dest = last_dest->mnt_master; - last_src = last_src->mnt_master; + last_dest = real_mount(last_dest->mnt.mnt_master); + last_src = real_mount(last_src->mnt.mnt_master); } if (p_last_dest) { do { p_last_dest = next_peer(p_last_dest); - } while (IS_MNT_NEW(p_last_dest)); + } while (IS_MNT_NEW(&p_last_dest->mnt)); /* is that a peer of the earlier? */ if (dest == p_last_dest) { *type = CL_MAKE_SHARED; @@ -200,7 +199,7 @@ static struct vfsmount *get_source(struct vfsmount *dest, /* slave of the earlier, then */ *type = CL_SLAVE; /* beginning of peer group among the slaves? */ - if (IS_MNT_SHARED(dest)) + if (IS_MNT_SHARED(&dest->mnt)) *type |= CL_MAKE_SHARED; return last_src; } @@ -221,32 +220,31 @@ static struct vfsmount *get_source(struct vfsmount *dest, int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, struct vfsmount *source_mnt, struct list_head *tree_list) { - struct vfsmount *m; - struct mount *child; + struct mount *m, *child; int ret = 0; - struct vfsmount *prev_dest_mnt = dest_mnt; - struct vfsmount *prev_src_mnt = source_mnt; + struct mount *prev_dest_mnt = real_mount(dest_mnt); + struct mount *prev_src_mnt = real_mount(source_mnt); LIST_HEAD(tmp_list); LIST_HEAD(umount_list); - for (m = propagation_next(dest_mnt, dest_mnt); m; - m = propagation_next(m, dest_mnt)) { + for (m = propagation_next(real_mount(dest_mnt), real_mount(dest_mnt)); m; + m = propagation_next(m, real_mount(dest_mnt))) { int type; - struct vfsmount *source; + struct mount *source; - if (IS_MNT_NEW(m)) + if (IS_MNT_NEW(&m->mnt)) continue; source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); - if (!(child = copy_tree(real_mount(source), source->mnt_root, type))) { + if (!(child = copy_tree(source, source->mnt.mnt_root, type))) { ret = -ENOMEM; list_splice(tree_list, tmp_list.prev); goto out; } - if (is_subdir(dest_dentry, m->mnt_root)) { - mnt_set_mountpoint(m, dest_dentry, child); + if (is_subdir(dest_dentry, m->mnt.mnt_root)) { + mnt_set_mountpoint(&m->mnt, dest_dentry, child); list_add_tail(&child->mnt_hash, tree_list); } else { /* @@ -256,7 +254,7 @@ int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, list_add_tail(&child->mnt_hash, &tmp_list); } prev_dest_mnt = m; - prev_src_mnt = &child->mnt; + prev_src_mnt = child; } out: br_write_lock(vfsmount_lock); @@ -290,8 +288,7 @@ static inline int do_refcount_check(struct mount *mnt, int count) */ int propagate_mount_busy(struct mount *mnt, int refcnt) { - struct vfsmount *m; - struct mount *child; + struct mount *m, *child; struct mount *parent = mnt->mnt_parent; int ret = 0; @@ -306,9 +303,9 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) if (!list_empty(&mnt->mnt_mounts) || do_refcount_check(mnt, refcnt)) return 1; - for (m = propagation_next(&parent->mnt, &parent->mnt); m; - m = propagation_next(m, &parent->mnt)) { - child = __lookup_mnt(m, mnt->mnt_mountpoint, 0); + for (m = propagation_next(parent, parent); m; + m = propagation_next(m, parent)) { + child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint, 0); if (child && list_empty(&child->mnt_mounts) && (ret = do_refcount_check(child, 1))) break; @@ -323,14 +320,14 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) static void __propagate_umount(struct mount *mnt) { struct mount *parent = mnt->mnt_parent; - struct vfsmount *m; + struct mount *m; BUG_ON(parent == mnt); - for (m = propagation_next(&parent->mnt, &parent->mnt); m; - m = propagation_next(m, &parent->mnt)) { + for (m = propagation_next(parent, parent); m; + m = propagation_next(m, parent)) { - struct mount *child = __lookup_mnt(m, + struct mount *child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint, 0); /* * umount the child only if the child has no From a8d56d8e4fa0cb9a023834363f8d79415d277a1d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 24 Nov 2011 23:59:29 -0500 Subject: [PATCH 136/165] vfs: spread struct mount - propagate_mnt() Signed-off-by: Al Viro --- fs/namespace.c | 12 ++++++------ fs/pnode.c | 12 ++++++------ fs/pnode.h | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 65d011fe982f..8432344333da 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1595,23 +1595,23 @@ static int attach_recursive_mnt(struct mount *source_mnt, struct path *path, struct path *parent_path) { LIST_HEAD(tree_list); - struct vfsmount *dest_mnt = path->mnt; + struct mount *dest_mnt = real_mount(path->mnt); struct dentry *dest_dentry = path->dentry; struct mount *child, *p; int err; - if (IS_MNT_SHARED(dest_mnt)) { + if (IS_MNT_SHARED(&dest_mnt->mnt)) { err = invent_group_ids(source_mnt, true); if (err) goto out; } - err = propagate_mnt(dest_mnt, dest_dentry, &source_mnt->mnt, &tree_list); + err = propagate_mnt(dest_mnt, dest_dentry, source_mnt, &tree_list); if (err) goto out_cleanup_ids; br_write_lock(vfsmount_lock); - if (IS_MNT_SHARED(dest_mnt)) { + if (IS_MNT_SHARED(&dest_mnt->mnt)) { for (p = source_mnt; p; p = next_mnt(p, &source_mnt->mnt)) set_mnt_shared(p); } @@ -1620,7 +1620,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, attach_mnt(source_mnt, path); touch_mnt_namespace(parent_path->mnt->mnt_ns); } else { - mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); + mnt_set_mountpoint(&dest_mnt->mnt, dest_dentry, source_mnt); commit_tree(source_mnt); } @@ -1633,7 +1633,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, return 0; out_cleanup_ids: - if (IS_MNT_SHARED(dest_mnt)) + if (IS_MNT_SHARED(&dest_mnt->mnt)) cleanup_group_ids(source_mnt, NULL); out: return err; diff --git a/fs/pnode.c b/fs/pnode.c index f86cd4bc31ce..6519b3b4eb15 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -217,18 +217,18 @@ static struct mount *get_source(struct mount *dest, * @source_mnt: source mount. * @tree_list : list of heads of trees to be attached. */ -int propagate_mnt(struct vfsmount *dest_mnt, struct dentry *dest_dentry, - struct vfsmount *source_mnt, struct list_head *tree_list) +int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry, + struct mount *source_mnt, struct list_head *tree_list) { struct mount *m, *child; int ret = 0; - struct mount *prev_dest_mnt = real_mount(dest_mnt); - struct mount *prev_src_mnt = real_mount(source_mnt); + struct mount *prev_dest_mnt = dest_mnt; + struct mount *prev_src_mnt = source_mnt; LIST_HEAD(tmp_list); LIST_HEAD(umount_list); - for (m = propagation_next(real_mount(dest_mnt), real_mount(dest_mnt)); m; - m = propagation_next(m, real_mount(dest_mnt))) { + for (m = propagation_next(dest_mnt, dest_mnt); m; + m = propagation_next(m, dest_mnt)) { int type; struct mount *source; diff --git a/fs/pnode.h b/fs/pnode.h index 33f1e3cb3cd2..55546a2f9b51 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -30,7 +30,7 @@ static inline void set_mnt_shared(struct mount *mnt) } void change_mnt_propagation(struct mount *, int); -int propagate_mnt(struct vfsmount *, struct dentry *, struct vfsmount *, +int propagate_mnt(struct mount *, struct dentry *, struct mount *, struct list_head *); int propagate_umount(struct list_head *); int propagate_mount_busy(struct mount *, int); From 14cf1fa8f54353d9caf6174c1e4280c8c4dcfd7a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:01:17 -0500 Subject: [PATCH 137/165] vfs: spread struct mount - remaining argument of mnt_set_mountpoint() Signed-off-by: Al Viro --- fs/namespace.c | 8 ++++---- fs/pnode.c | 2 +- fs/pnode.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 8432344333da..ee42e671afdc 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -570,10 +570,10 @@ static void detach_mnt(struct mount *mnt, struct path *old_path) /* * vfsmount lock must be held for write */ -void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, +void mnt_set_mountpoint(struct mount *mnt, struct dentry *dentry, struct mount *child_mnt) { - child_mnt->mnt_parent = real_mount(mntget(mnt)); + child_mnt->mnt_parent = real_mount(mntget(&mnt->mnt)); child_mnt->mnt_mountpoint = dget(dentry); spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_MOUNTED; @@ -585,7 +585,7 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, */ static void attach_mnt(struct mount *mnt, struct path *path) { - mnt_set_mountpoint(path->mnt, path->dentry, mnt); + mnt_set_mountpoint(real_mount(path->mnt), path->dentry, mnt); list_add_tail(&mnt->mnt_hash, mount_hashtable + hash(path->mnt, path->dentry)); list_add_tail(&mnt->mnt_child, &real_mount(path->mnt)->mnt_mounts); @@ -1620,7 +1620,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, attach_mnt(source_mnt, path); touch_mnt_namespace(parent_path->mnt->mnt_ns); } else { - mnt_set_mountpoint(&dest_mnt->mnt, dest_dentry, source_mnt); + mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); commit_tree(source_mnt); } diff --git a/fs/pnode.c b/fs/pnode.c index 6519b3b4eb15..0e1de28b1b2e 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -244,7 +244,7 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry, } if (is_subdir(dest_dentry, m->mnt.mnt_root)) { - mnt_set_mountpoint(&m->mnt, dest_dentry, child); + mnt_set_mountpoint(m, dest_dentry, child); list_add_tail(&child->mnt_hash, tree_list); } else { /* diff --git a/fs/pnode.h b/fs/pnode.h index 55546a2f9b51..54deeda0cdb8 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -37,7 +37,7 @@ int propagate_mount_busy(struct mount *, int); void mnt_release_group_id(struct mount *); int get_dominating_id(struct mount *mnt, const struct path *root); unsigned int mnt_get_count(struct mount *mnt); -void mnt_set_mountpoint(struct vfsmount *, struct dentry *, +void mnt_set_mountpoint(struct mount *, struct dentry *, struct mount *); void release_mounts(struct list_head *); void umount_tree(struct mount *, int, struct list_head *); From d10e8def07fc87488c396d2eff2c26c43bb541dd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:07:16 -0500 Subject: [PATCH 138/165] vfs: take mnt_master to struct mount make IS_MNT_SLAVE take struct mount * at the same time Signed-off-by: Al Viro --- fs/mount.h | 2 ++ fs/namespace.c | 10 +++++----- fs/pnode.c | 26 +++++++++++++------------- include/linux/mount.h | 1 - 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index e4ecf59c9353..7071d8fa9307 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -19,6 +19,8 @@ struct mount { #endif struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_child; /* and going through their mnt_child */ + /* yet to be moved - up to mnt_slave */ + struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ }; static inline struct mount *real_mount(struct vfsmount *mnt) diff --git a/fs/namespace.c b/fs/namespace.c index ee42e671afdc..3439042fc9f2 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -715,14 +715,14 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, if (flag & CL_SLAVE) { list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave_list); - mnt->mnt.mnt_master = &old->mnt; + mnt->mnt_master = &old->mnt; CLEAR_MNT_SHARED(&mnt->mnt); } else if (!(flag & CL_PRIVATE)) { if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(&old->mnt)) list_add(&mnt->mnt.mnt_share, &old->mnt.mnt_share); - if (IS_MNT_SLAVE(&old->mnt)) + if (IS_MNT_SLAVE(old)) list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave); - mnt->mnt.mnt_master = old->mnt.mnt_master; + mnt->mnt_master = old->mnt_master; } if (flag & CL_MAKE_SHARED) set_mnt_shared(mnt); @@ -1051,8 +1051,8 @@ static int show_mountinfo(struct seq_file *m, void *v) /* Tagged fields ("foo:X" or "bar") */ if (IS_MNT_SHARED(mnt)) seq_printf(m, " shared:%i", mnt->mnt_group_id); - if (IS_MNT_SLAVE(mnt)) { - int master = mnt->mnt_master->mnt_group_id; + if (IS_MNT_SLAVE(r)) { + int master = r->mnt_master->mnt_group_id; int dom = get_dominating_id(r, &p->root); seq_printf(m, " master:%i", master); if (dom && dom != master) diff --git a/fs/pnode.c b/fs/pnode.c index 0e1de28b1b2e..3ac44d15fe58 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -55,7 +55,7 @@ int get_dominating_id(struct mount *mnt, const struct path *root) { struct mount *m; - for (m = real_mount(mnt->mnt.mnt_master); m != NULL; m = real_mount(m->mnt.mnt_master)) { + for (m = real_mount(mnt->mnt_master); m != NULL; m = real_mount(m->mnt_master)) { struct mount *d = get_peer_under_root(m, mnt->mnt.mnt_ns, root); if (d) return d->mnt.mnt_group_id; @@ -66,8 +66,8 @@ int get_dominating_id(struct mount *mnt, const struct path *root) static int do_make_slave(struct mount *mnt) { - struct mount *peer_mnt = mnt, *master = real_mount(mnt->mnt.mnt_master); - struct vfsmount *slave_mnt; + struct mount *peer_mnt = mnt, *master = real_mount(mnt->mnt_master); + struct mount *slave_mnt; /* * slave 'mnt' to a peer mount that has the @@ -92,7 +92,7 @@ static int do_make_slave(struct mount *mnt) master = peer_mnt; if (master) { - list_for_each_entry(slave_mnt, &mnt->mnt.mnt_slave_list, mnt_slave) + list_for_each_entry(slave_mnt, &mnt->mnt.mnt_slave_list, mnt.mnt_slave) slave_mnt->mnt_master = &master->mnt; list_move(&mnt->mnt.mnt_slave, &master->mnt.mnt_slave_list); list_splice(&mnt->mnt.mnt_slave_list, master->mnt.mnt_slave_list.prev); @@ -101,12 +101,12 @@ static int do_make_slave(struct mount *mnt) struct list_head *p = &mnt->mnt.mnt_slave_list; while (!list_empty(p)) { slave_mnt = list_first_entry(p, - struct vfsmount, mnt_slave); - list_del_init(&slave_mnt->mnt_slave); + struct mount, mnt.mnt_slave); + list_del_init(&slave_mnt->mnt.mnt_slave); slave_mnt->mnt_master = NULL; } } - mnt->mnt.mnt_master = &master->mnt; + mnt->mnt_master = &master->mnt; CLEAR_MNT_SHARED(&mnt->mnt); return 0; } @@ -123,7 +123,7 @@ void change_mnt_propagation(struct mount *mnt, int type) do_make_slave(mnt); if (type != MS_SLAVE) { list_del_init(&mnt->mnt.mnt_slave); - mnt->mnt.mnt_master = NULL; + mnt->mnt_master = NULL; if (type == MS_UNBINDABLE) mnt->mnt.mnt_flags |= MNT_UNBINDABLE; else @@ -149,9 +149,9 @@ static struct mount *propagation_next(struct mount *m, return first_slave(m); while (1) { - struct mount *master = real_mount(m->mnt.mnt_master); + struct mount *master = real_mount(m->mnt_master); - if (&master->mnt == origin->mnt.mnt_master) { + if (&master->mnt == origin->mnt_master) { struct mount *next = next_peer(m); return (next == origin) ? NULL : next; } else if (m->mnt.mnt_slave.next != &master->mnt.mnt_slave_list) @@ -179,11 +179,11 @@ static struct mount *get_source(struct mount *dest, struct mount *p_last_src = NULL; struct mount *p_last_dest = NULL; - while (&last_dest->mnt != dest->mnt.mnt_master) { + while (&last_dest->mnt != dest->mnt_master) { p_last_dest = last_dest; p_last_src = last_src; - last_dest = real_mount(last_dest->mnt.mnt_master); - last_src = real_mount(last_src->mnt.mnt_master); + last_dest = real_mount(last_dest->mnt_master); + last_src = real_mount(last_src->mnt_master); } if (p_last_dest) { diff --git a/include/linux/mount.h b/include/linux/mount.h index e9990254d4d0..2d5beb5e3a8c 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -62,7 +62,6 @@ struct vfsmount { struct list_head mnt_share; /* circular list of shared mounts */ struct list_head mnt_slave_list;/* list of slave mounts */ struct list_head mnt_slave; /* slave list entry */ - struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ struct mnt_namespace *mnt_ns; /* containing namespace */ int mnt_id; /* mount identifier */ int mnt_group_id; /* peer group identifier */ From 32301920f44a9334f57dd94bebfc6e593b99ad47 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:10:28 -0500 Subject: [PATCH 139/165] vfs: and now we can make ->mnt_master point to struct mount Signed-off-by: Al Viro --- fs/mount.h | 2 +- fs/namespace.c | 4 ++-- fs/pnode.c | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 7071d8fa9307..d4db4c7e1815 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -20,7 +20,7 @@ struct mount { struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_child; /* and going through their mnt_child */ /* yet to be moved - up to mnt_slave */ - struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ + struct mount *mnt_master; /* slave is on master->mnt_slave_list */ }; static inline struct mount *real_mount(struct vfsmount *mnt) diff --git a/fs/namespace.c b/fs/namespace.c index 3439042fc9f2..847b7240c512 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -715,7 +715,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, if (flag & CL_SLAVE) { list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave_list); - mnt->mnt_master = &old->mnt; + mnt->mnt_master = old; CLEAR_MNT_SHARED(&mnt->mnt); } else if (!(flag & CL_PRIVATE)) { if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(&old->mnt)) @@ -1052,7 +1052,7 @@ static int show_mountinfo(struct seq_file *m, void *v) if (IS_MNT_SHARED(mnt)) seq_printf(m, " shared:%i", mnt->mnt_group_id); if (IS_MNT_SLAVE(r)) { - int master = r->mnt_master->mnt_group_id; + int master = r->mnt_master->mnt.mnt_group_id; int dom = get_dominating_id(r, &p->root); seq_printf(m, " master:%i", master); if (dom && dom != master) diff --git a/fs/pnode.c b/fs/pnode.c index 3ac44d15fe58..9bf22b61f8fb 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -55,7 +55,7 @@ int get_dominating_id(struct mount *mnt, const struct path *root) { struct mount *m; - for (m = real_mount(mnt->mnt_master); m != NULL; m = real_mount(m->mnt_master)) { + for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) { struct mount *d = get_peer_under_root(m, mnt->mnt.mnt_ns, root); if (d) return d->mnt.mnt_group_id; @@ -66,7 +66,7 @@ int get_dominating_id(struct mount *mnt, const struct path *root) static int do_make_slave(struct mount *mnt) { - struct mount *peer_mnt = mnt, *master = real_mount(mnt->mnt_master); + struct mount *peer_mnt = mnt, *master = mnt->mnt_master; struct mount *slave_mnt; /* @@ -93,7 +93,7 @@ static int do_make_slave(struct mount *mnt) if (master) { list_for_each_entry(slave_mnt, &mnt->mnt.mnt_slave_list, mnt.mnt_slave) - slave_mnt->mnt_master = &master->mnt; + slave_mnt->mnt_master = master; list_move(&mnt->mnt.mnt_slave, &master->mnt.mnt_slave_list); list_splice(&mnt->mnt.mnt_slave_list, master->mnt.mnt_slave_list.prev); INIT_LIST_HEAD(&mnt->mnt.mnt_slave_list); @@ -106,7 +106,7 @@ static int do_make_slave(struct mount *mnt) slave_mnt->mnt_master = NULL; } } - mnt->mnt_master = &master->mnt; + mnt->mnt_master = master; CLEAR_MNT_SHARED(&mnt->mnt); return 0; } @@ -149,9 +149,9 @@ static struct mount *propagation_next(struct mount *m, return first_slave(m); while (1) { - struct mount *master = real_mount(m->mnt_master); + struct mount *master = m->mnt_master; - if (&master->mnt == origin->mnt_master) { + if (master == origin->mnt_master) { struct mount *next = next_peer(m); return (next == origin) ? NULL : next; } else if (m->mnt.mnt_slave.next != &master->mnt.mnt_slave_list) @@ -179,11 +179,11 @@ static struct mount *get_source(struct mount *dest, struct mount *p_last_src = NULL; struct mount *p_last_dest = NULL; - while (&last_dest->mnt != dest->mnt_master) { + while (last_dest != dest->mnt_master) { p_last_dest = last_dest; p_last_src = last_src; - last_dest = real_mount(last_dest->mnt_master); - last_src = real_mount(last_src->mnt_master); + last_dest = last_dest->mnt_master; + last_src = last_src->mnt_master; } if (p_last_dest) { From 6776db3d32b2a59198ec7ac6d32be0b9fdbd8a68 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:22:05 -0500 Subject: [PATCH 140/165] vfs: take mnt_share/mnt_slave/mnt_slave_list and mnt_expire to struct mount Signed-off-by: Al Viro --- fs/mount.h | 6 +++++- fs/namespace.c | 41 +++++++++++++++++++++-------------------- fs/pnode.c | 30 +++++++++++++++--------------- include/linux/mount.h | 4 ---- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index d4db4c7e1815..eb62ad232e4d 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -19,7 +19,11 @@ struct mount { #endif struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_child; /* and going through their mnt_child */ - /* yet to be moved - up to mnt_slave */ + /* yet to be moved - up to mnt_list */ + struct list_head mnt_expire; /* link in fs-specific expiry list */ + struct list_head mnt_share; /* circular list of shared mounts */ + struct list_head mnt_slave_list;/* list of slave mounts */ + struct list_head mnt_slave; /* slave list entry */ struct mount *mnt_master; /* slave is on master->mnt_slave_list */ }; diff --git a/fs/namespace.c b/fs/namespace.c index 847b7240c512..a14750be7a70 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -203,10 +203,10 @@ static struct mount *alloc_vfsmnt(const char *name) INIT_LIST_HEAD(&p->mnt_child); INIT_LIST_HEAD(&p->mnt_mounts); INIT_LIST_HEAD(&mnt->mnt_list); - INIT_LIST_HEAD(&mnt->mnt_expire); - INIT_LIST_HEAD(&mnt->mnt_share); - INIT_LIST_HEAD(&mnt->mnt_slave_list); - INIT_LIST_HEAD(&mnt->mnt_slave); + INIT_LIST_HEAD(&p->mnt_expire); + INIT_LIST_HEAD(&p->mnt_share); + INIT_LIST_HEAD(&p->mnt_slave_list); + INIT_LIST_HEAD(&p->mnt_slave); #ifdef CONFIG_FSNOTIFY INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks); #endif @@ -714,14 +714,14 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, mnt->mnt_parent = mnt; if (flag & CL_SLAVE) { - list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave_list); + list_add(&mnt->mnt_slave, &old->mnt_slave_list); mnt->mnt_master = old; CLEAR_MNT_SHARED(&mnt->mnt); } else if (!(flag & CL_PRIVATE)) { if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(&old->mnt)) - list_add(&mnt->mnt.mnt_share, &old->mnt.mnt_share); + list_add(&mnt->mnt_share, &old->mnt_share); if (IS_MNT_SLAVE(old)) - list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave); + list_add(&mnt->mnt_slave, &old->mnt_slave); mnt->mnt_master = old->mnt_master; } if (flag & CL_MAKE_SHARED) @@ -730,8 +730,8 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, /* stick the duplicate mount on the same expiry list * as the original if that was on one */ if (flag & CL_EXPIRE) { - if (!list_empty(&old->mnt.mnt_expire)) - list_add(&mnt->mnt.mnt_expire, &old->mnt.mnt_expire); + if (!list_empty(&old->mnt_expire)) + list_add(&mnt->mnt_expire, &old->mnt_expire); } } return mnt; @@ -1233,7 +1233,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) propagate_umount(&tmp_list); list_for_each_entry(p, &tmp_list, mnt_hash) { - list_del_init(&p->mnt.mnt_expire); + list_del_init(&p->mnt_expire); list_del_init(&p->mnt.mnt_list); __touch_mnt_namespace(p->mnt.mnt_ns); p->mnt.mnt_ns = NULL; @@ -1921,7 +1921,7 @@ static int do_move_mount(struct path *path, char *old_name) /* if the mount is moved, it should no longer be expire * automatically */ - list_del_init(&old_path.mnt->mnt_expire); + list_del_init(&old->mnt_expire); out1: unlock_mount(path); out: @@ -2033,11 +2033,12 @@ static int do_new_mount(struct path *path, char *type, int flags, int finish_automount(struct vfsmount *m, struct path *path) { + struct mount *mnt = real_mount(m); int err; /* The new mount record should have at least 2 refs to prevent it being * expired before we get a chance to add it */ - BUG_ON(mnt_get_count(real_mount(m)) < 2); + BUG_ON(mnt_get_count(mnt) < 2); if (m->mnt_sb == path->mnt->mnt_sb && m->mnt_root == path->dentry) { @@ -2050,10 +2051,10 @@ int finish_automount(struct vfsmount *m, struct path *path) return 0; fail: /* remove m from any expiration list it may be on */ - if (!list_empty(&m->mnt_expire)) { + if (!list_empty(&mnt->mnt_expire)) { down_write(&namespace_sem); br_write_lock(vfsmount_lock); - list_del_init(&m->mnt_expire); + list_del_init(&mnt->mnt_expire); br_write_unlock(vfsmount_lock); up_write(&namespace_sem); } @@ -2072,7 +2073,7 @@ void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list) down_write(&namespace_sem); br_write_lock(vfsmount_lock); - list_add_tail(&mnt->mnt_expire, expiry_list); + list_add_tail(&real_mount(mnt)->mnt_expire, expiry_list); br_write_unlock(vfsmount_lock); up_write(&namespace_sem); @@ -2102,14 +2103,14 @@ void mark_mounts_for_expiry(struct list_head *mounts) * - still marked for expiry (marked on the last call here; marks are * cleared by mntput()) */ - list_for_each_entry_safe(mnt, next, mounts, mnt.mnt_expire) { + list_for_each_entry_safe(mnt, next, mounts, mnt_expire) { if (!xchg(&mnt->mnt.mnt_expiry_mark, 1) || propagate_mount_busy(mnt, 1)) continue; - list_move(&mnt->mnt.mnt_expire, &graveyard); + list_move(&mnt->mnt_expire, &graveyard); } while (!list_empty(&graveyard)) { - mnt = list_first_entry(&graveyard, struct mount, mnt.mnt_expire); + mnt = list_first_entry(&graveyard, struct mount, mnt_expire); touch_mnt_namespace(mnt->mnt.mnt_ns); umount_tree(mnt, 1, &umounts); } @@ -2152,7 +2153,7 @@ resume: } if (!propagate_mount_busy(mnt, 1)) { - list_move_tail(&mnt->mnt.mnt_expire, graveyard); + list_move_tail(&mnt->mnt_expire, graveyard); found++; } } @@ -2182,7 +2183,7 @@ static void shrink_submounts(struct mount *mnt, struct list_head *umounts) while (select_submounts(mnt, &graveyard)) { while (!list_empty(&graveyard)) { m = list_first_entry(&graveyard, struct mount, - mnt.mnt_expire); + mnt_expire); touch_mnt_namespace(m->mnt.mnt_ns); umount_tree(m, 1, umounts); } diff --git a/fs/pnode.c b/fs/pnode.c index 9bf22b61f8fb..12cc1518e0cd 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -15,17 +15,17 @@ /* return the next shared peer mount of @p */ static inline struct mount *next_peer(struct mount *p) { - return list_entry(p->mnt.mnt_share.next, struct mount, mnt.mnt_share); + return list_entry(p->mnt_share.next, struct mount, mnt_share); } static inline struct mount *first_slave(struct mount *p) { - return list_entry(p->mnt.mnt_slave_list.next, struct mount, mnt.mnt_slave); + return list_entry(p->mnt_slave_list.next, struct mount, mnt_slave); } static inline struct mount *next_slave(struct mount *p) { - return list_entry(p->mnt.mnt_slave.next, struct mount, mnt.mnt_slave); + return list_entry(p->mnt_slave.next, struct mount, mnt_slave); } static struct mount *get_peer_under_root(struct mount *mnt, @@ -82,27 +82,27 @@ static int do_make_slave(struct mount *mnt) if (peer_mnt == mnt) peer_mnt = NULL; } - if (IS_MNT_SHARED(&mnt->mnt) && list_empty(&mnt->mnt.mnt_share)) + if (IS_MNT_SHARED(&mnt->mnt) && list_empty(&mnt->mnt_share)) mnt_release_group_id(mnt); - list_del_init(&mnt->mnt.mnt_share); + list_del_init(&mnt->mnt_share); mnt->mnt.mnt_group_id = 0; if (peer_mnt) master = peer_mnt; if (master) { - list_for_each_entry(slave_mnt, &mnt->mnt.mnt_slave_list, mnt.mnt_slave) + list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave) slave_mnt->mnt_master = master; - list_move(&mnt->mnt.mnt_slave, &master->mnt.mnt_slave_list); - list_splice(&mnt->mnt.mnt_slave_list, master->mnt.mnt_slave_list.prev); - INIT_LIST_HEAD(&mnt->mnt.mnt_slave_list); + list_move(&mnt->mnt_slave, &master->mnt_slave_list); + list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev); + INIT_LIST_HEAD(&mnt->mnt_slave_list); } else { - struct list_head *p = &mnt->mnt.mnt_slave_list; + struct list_head *p = &mnt->mnt_slave_list; while (!list_empty(p)) { slave_mnt = list_first_entry(p, - struct mount, mnt.mnt_slave); - list_del_init(&slave_mnt->mnt.mnt_slave); + struct mount, mnt_slave); + list_del_init(&slave_mnt->mnt_slave); slave_mnt->mnt_master = NULL; } } @@ -122,7 +122,7 @@ void change_mnt_propagation(struct mount *mnt, int type) } do_make_slave(mnt); if (type != MS_SLAVE) { - list_del_init(&mnt->mnt.mnt_slave); + list_del_init(&mnt->mnt_slave); mnt->mnt_master = NULL; if (type == MS_UNBINDABLE) mnt->mnt.mnt_flags |= MNT_UNBINDABLE; @@ -145,7 +145,7 @@ static struct mount *propagation_next(struct mount *m, struct mount *origin) { /* are there any slaves of this mount? */ - if (!IS_MNT_NEW(&m->mnt) && !list_empty(&m->mnt.mnt_slave_list)) + if (!IS_MNT_NEW(&m->mnt) && !list_empty(&m->mnt_slave_list)) return first_slave(m); while (1) { @@ -154,7 +154,7 @@ static struct mount *propagation_next(struct mount *m, if (master == origin->mnt_master) { struct mount *next = next_peer(m); return (next == origin) ? NULL : next; - } else if (m->mnt.mnt_slave.next != &master->mnt.mnt_slave_list) + } else if (m->mnt_slave.next != &master->mnt_slave_list) return next_slave(m); /* back at master */ diff --git a/include/linux/mount.h b/include/linux/mount.h index 2d5beb5e3a8c..2f5f3ae3bd2d 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -58,10 +58,6 @@ struct vfsmount { #endif const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; - struct list_head mnt_expire; /* link in fs-specific expiry list */ - struct list_head mnt_share; /* circular list of shared mounts */ - struct list_head mnt_slave_list;/* list of slave mounts */ - struct list_head mnt_slave; /* slave list entry */ struct mnt_namespace *mnt_ns; /* containing namespace */ int mnt_id; /* mount identifier */ int mnt_group_id; /* peer group identifier */ From 95bc5f25c10fcdf02c53af1eda987f58d0bc377c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:30:56 -0500 Subject: [PATCH 141/165] vfs: spread struct mount - do_add_mount and graft_tree Signed-off-by: Al Viro --- fs/namespace.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index a14750be7a70..6b5e0436acfd 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1666,19 +1666,19 @@ static void unlock_mount(struct path *path) mutex_unlock(&path->dentry->d_inode->i_mutex); } -static int graft_tree(struct vfsmount *mnt, struct path *path) +static int graft_tree(struct mount *mnt, struct path *path) { - if (mnt->mnt_sb->s_flags & MS_NOUSER) + if (mnt->mnt.mnt_sb->s_flags & MS_NOUSER) return -EINVAL; if (S_ISDIR(path->dentry->d_inode->i_mode) != - S_ISDIR(mnt->mnt_root->d_inode->i_mode)) + S_ISDIR(mnt->mnt.mnt_root->d_inode->i_mode)) return -ENOTDIR; if (d_unlinked(path->dentry)) return -ENOENT; - return attach_recursive_mnt(real_mount(mnt), path, NULL); + return attach_recursive_mnt(mnt, path, NULL); } /* @@ -1776,7 +1776,7 @@ static int do_loopback(struct path *path, char *old_name, if (!mnt) goto out2; - err = graft_tree(&mnt->mnt, path); + err = graft_tree(mnt, path); if (err) { br_write_lock(vfsmount_lock); umount_tree(mnt, 0, &umount_list); @@ -1972,7 +1972,7 @@ do_kern_mount(const char *fstype, int flags, const char *name, void *data) /* * add a mount into a namespace's mount tree */ -static int do_add_mount(struct vfsmount *newmnt, struct path *path, int mnt_flags) +static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags) { int err; @@ -1988,15 +1988,15 @@ static int do_add_mount(struct vfsmount *newmnt, struct path *path, int mnt_flag /* Refuse the same filesystem on the same mount point */ err = -EBUSY; - if (path->mnt->mnt_sb == newmnt->mnt_sb && + if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb && path->mnt->mnt_root == path->dentry) goto unlock; err = -EINVAL; - if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) + if (S_ISLNK(newmnt->mnt.mnt_root->d_inode->i_mode)) goto unlock; - newmnt->mnt_flags = mnt_flags; + newmnt->mnt.mnt_flags = mnt_flags; err = graft_tree(newmnt, path); unlock: @@ -2025,7 +2025,7 @@ static int do_new_mount(struct path *path, char *type, int flags, if (IS_ERR(mnt)) return PTR_ERR(mnt); - err = do_add_mount(mnt, path, mnt_flags); + err = do_add_mount(real_mount(mnt), path, mnt_flags); if (err) mntput(mnt); return err; @@ -2046,7 +2046,7 @@ int finish_automount(struct vfsmount *m, struct path *path) goto fail; } - err = do_add_mount(m, path, path->mnt->mnt_flags | MNT_SHRINKABLE); + err = do_add_mount(mnt, path, path->mnt->mnt_flags | MNT_SHRINKABLE); if (!err) return 0; fail: From 900148dcac6bc93ca688d64a7f9a9f8d706e0d1c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:33:11 -0500 Subject: [PATCH 142/165] vfs: spread struct mount - mntput_no_expire Signed-off-by: Al Viro --- fs/namespace.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 6b5e0436acfd..3e95cc26dda6 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -763,9 +763,8 @@ static inline void mntfree(struct mount *mnt) deactivate_super(sb); } -static void mntput_no_expire(struct vfsmount *m) +static void mntput_no_expire(struct mount *mnt) { - struct mount *mnt = real_mount(m); put_again: #ifdef CONFIG_SMP br_read_lock(vfsmount_lock); @@ -792,7 +791,7 @@ put_again: mnt_add_count(mnt, mnt->mnt.mnt_pinned + 1); mnt->mnt.mnt_pinned = 0; br_write_unlock(vfsmount_lock); - acct_auto_close_mnt(m); + acct_auto_close_mnt(&mnt->mnt); goto put_again; } br_write_unlock(vfsmount_lock); @@ -805,7 +804,7 @@ void mntput(struct vfsmount *mnt) /* avoid cacheline pingpong, hope gcc doesn't get "smart" */ if (unlikely(mnt->mnt_expiry_mark)) mnt->mnt_expiry_mark = 0; - mntput_no_expire(mnt); + mntput_no_expire(real_mount(mnt)); } } EXPORT_SYMBOL(mntput); @@ -1351,6 +1350,7 @@ static int do_umount(struct mount *mnt, int flags) SYSCALL_DEFINE2(umount, char __user *, name, int, flags) { struct path path; + struct mount *mnt; int retval; int lookup_flags = 0; @@ -1363,6 +1363,7 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) retval = user_path_at(AT_FDCWD, name, lookup_flags, &path); if (retval) goto out; + mnt = real_mount(path.mnt); retval = -EINVAL; if (path.dentry != path.mnt->mnt_root) goto dput_and_out; @@ -1373,11 +1374,11 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) if (!capable(CAP_SYS_ADMIN)) goto dput_and_out; - retval = do_umount(real_mount(path.mnt), flags); + retval = do_umount(mnt, flags); dput_and_out: /* we mustn't call path_put() as that would clear mnt_expiry_mark */ dput(path.dentry); - mntput_no_expire(path.mnt); + mntput_no_expire(mnt); out: return retval; } From 143c8c91cee7efdd732ec5f61b3471fc46192f20 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:46:35 -0500 Subject: [PATCH 143/165] vfs: mnt_ns moved to struct mount Signed-off-by: Al Viro --- fs/dcache.c | 2 +- fs/mount.h | 1 + fs/namespace.c | 45 ++++++++++++++++++++++--------------------- fs/pnode.c | 10 +++++----- include/linux/mount.h | 1 - 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 24790041ea76..9791b1e7eee4 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2503,7 +2503,7 @@ global_root: if (!slash) error = prepend(buffer, buflen, "/", 1); if (!error) - error = vfsmnt->mnt_ns ? 1 : 2; + error = real_mount(vfsmnt)->mnt_ns ? 1 : 2; goto out; } diff --git a/fs/mount.h b/fs/mount.h index eb62ad232e4d..4a5f1dca0c2e 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -25,6 +25,7 @@ struct mount { struct list_head mnt_slave_list;/* list of slave mounts */ struct list_head mnt_slave; /* slave list entry */ struct mount *mnt_master; /* slave is on master->mnt_slave_list */ + struct mnt_namespace *mnt_ns; /* containing namespace */ }; static inline struct mount *real_mount(struct vfsmount *mnt) diff --git a/fs/namespace.c b/fs/namespace.c index 3e95cc26dda6..4cdb7f698613 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -505,7 +505,7 @@ struct vfsmount *lookup_mnt(struct path *path) } } -static inline int check_mnt(struct vfsmount *mnt) +static inline int check_mnt(struct mount *mnt) { return mnt->mnt_ns == current->nsproxy->mnt_ns; } @@ -614,13 +614,13 @@ static void commit_tree(struct mount *mnt) struct mount *parent = mnt->mnt_parent; struct mount *m; LIST_HEAD(head); - struct mnt_namespace *n = parent->mnt.mnt_ns; + struct mnt_namespace *n = parent->mnt_ns; BUG_ON(parent == mnt); list_add_tail(&head, &mnt->mnt.mnt_list); list_for_each_entry(m, &head, mnt.mnt_list) { - m->mnt.mnt_ns = n; + m->mnt_ns = n; __mnt_make_longterm(m); } @@ -1234,8 +1234,8 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) list_for_each_entry(p, &tmp_list, mnt_hash) { list_del_init(&p->mnt_expire); list_del_init(&p->mnt.mnt_list); - __touch_mnt_namespace(p->mnt.mnt_ns); - p->mnt.mnt_ns = NULL; + __touch_mnt_namespace(p->mnt_ns); + p->mnt_ns = NULL; __mnt_make_shortterm(p); list_del_init(&p->mnt_child); if (mnt_has_parent(p)) { @@ -1367,7 +1367,7 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) retval = -EINVAL; if (path.dentry != path.mnt->mnt_root) goto dput_and_out; - if (!check_mnt(path.mnt)) + if (!check_mnt(mnt)) goto dput_and_out; retval = -EPERM; @@ -1619,7 +1619,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, if (parent_path) { detach_mnt(source_mnt, parent_path); attach_mnt(source_mnt, path); - touch_mnt_namespace(parent_path->mnt->mnt_ns); + touch_mnt_namespace(source_mnt->mnt_ns); } else { mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); commit_tree(source_mnt); @@ -1765,7 +1765,7 @@ static int do_loopback(struct path *path, char *old_name, if (IS_MNT_UNBINDABLE(old_path.mnt)) goto out2; - if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) + if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old)) goto out2; err = -ENOMEM; @@ -1818,11 +1818,12 @@ static int do_remount(struct path *path, int flags, int mnt_flags, { int err; struct super_block *sb = path->mnt->mnt_sb; + struct mount *mnt = real_mount(path->mnt); if (!capable(CAP_SYS_ADMIN)) return -EPERM; - if (!check_mnt(path->mnt)) + if (!check_mnt(mnt)) return -EINVAL; if (path->dentry != path->mnt->mnt_root) @@ -1839,14 +1840,14 @@ static int do_remount(struct path *path, int flags, int mnt_flags, err = do_remount_sb(sb, flags, data, 0); if (!err) { br_write_lock(vfsmount_lock); - mnt_flags |= path->mnt->mnt_flags & MNT_PROPAGATION_MASK; - path->mnt->mnt_flags = mnt_flags; + mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK; + mnt->mnt.mnt_flags = mnt_flags; br_write_unlock(vfsmount_lock); } up_write(&sb->s_umount); if (!err) { br_write_lock(vfsmount_lock); - touch_mnt_namespace(path->mnt->mnt_ns); + touch_mnt_namespace(mnt->mnt_ns); br_write_unlock(vfsmount_lock); } return err; @@ -1880,8 +1881,10 @@ static int do_move_mount(struct path *path, char *old_name) if (err < 0) goto out; + old = real_mount(old_path.mnt); + err = -EINVAL; - if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) + if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old)) goto out1; if (d_unlinked(path->dentry)) @@ -1891,8 +1894,6 @@ static int do_move_mount(struct path *path, char *old_name) if (old_path.dentry != old_path.mnt->mnt_root) goto out1; - old = real_mount(old_path.mnt); - if (!mnt_has_parent(old)) goto out1; @@ -1984,7 +1985,7 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags) return err; err = -EINVAL; - if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(path->mnt)) + if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(real_mount(path->mnt))) goto unlock; /* Refuse the same filesystem on the same mount point */ @@ -2112,7 +2113,7 @@ void mark_mounts_for_expiry(struct list_head *mounts) } while (!list_empty(&graveyard)) { mnt = list_first_entry(&graveyard, struct mount, mnt_expire); - touch_mnt_namespace(mnt->mnt.mnt_ns); + touch_mnt_namespace(mnt->mnt_ns); umount_tree(mnt, 1, &umounts); } br_write_unlock(vfsmount_lock); @@ -2185,7 +2186,7 @@ static void shrink_submounts(struct mount *mnt, struct list_head *umounts) while (!list_empty(&graveyard)) { m = list_first_entry(&graveyard, struct mount, mnt_expire); - touch_mnt_namespace(m->mnt.mnt_ns); + touch_mnt_namespace(m->mnt_ns); umount_tree(m, 1, umounts); } } @@ -2423,7 +2424,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, p = real_mount(mnt_ns->root); q = new; while (p) { - q->mnt.mnt_ns = new_ns; + q->mnt_ns = new_ns; __mnt_make_longterm(q); if (fs) { if (&p->mnt == fs->root.mnt) { @@ -2479,7 +2480,7 @@ static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) new_ns = alloc_mnt_ns(); if (!IS_ERR(new_ns)) { - mnt->mnt_ns = new_ns; + real_mount(mnt)->mnt_ns = new_ns; __mnt_make_longterm(real_mount(mnt)); new_ns->root = mnt; list_add(&new_ns->list, &new_ns->root->mnt_list); @@ -2644,7 +2645,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, IS_MNT_SHARED(&new_mnt->mnt_parent->mnt) || IS_MNT_SHARED(&root_mnt->mnt_parent->mnt)) goto out4; - if (!check_mnt(root.mnt) || !check_mnt(new.mnt)) + if (!check_mnt(root_mnt) || !check_mnt(new_mnt)) goto out4; error = -ENOENT; if (d_unlinked(new.dentry)) @@ -2793,5 +2794,5 @@ EXPORT_SYMBOL(kern_unmount); bool our_mnt(struct vfsmount *mnt) { - return check_mnt(mnt); + return check_mnt(real_mount(mnt)); } diff --git a/fs/pnode.c b/fs/pnode.c index 12cc1518e0cd..cec329822a16 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -36,7 +36,7 @@ static struct mount *get_peer_under_root(struct mount *mnt, do { /* Check the namespace first for optimization */ - if (m->mnt.mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root)) + if (m->mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root)) return m; m = next_peer(m); @@ -56,7 +56,7 @@ int get_dominating_id(struct mount *mnt, const struct path *root) struct mount *m; for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) { - struct mount *d = get_peer_under_root(m, mnt->mnt.mnt_ns, root); + struct mount *d = get_peer_under_root(m, mnt->mnt_ns, root); if (d) return d->mnt.mnt_group_id; } @@ -145,7 +145,7 @@ static struct mount *propagation_next(struct mount *m, struct mount *origin) { /* are there any slaves of this mount? */ - if (!IS_MNT_NEW(&m->mnt) && !list_empty(&m->mnt_slave_list)) + if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list)) return first_slave(m); while (1) { @@ -189,7 +189,7 @@ static struct mount *get_source(struct mount *dest, if (p_last_dest) { do { p_last_dest = next_peer(p_last_dest); - } while (IS_MNT_NEW(&p_last_dest->mnt)); + } while (IS_MNT_NEW(p_last_dest)); /* is that a peer of the earlier? */ if (dest == p_last_dest) { *type = CL_MAKE_SHARED; @@ -232,7 +232,7 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry, int type; struct mount *source; - if (IS_MNT_NEW(&m->mnt)) + if (IS_MNT_NEW(m)) continue; source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); diff --git a/include/linux/mount.h b/include/linux/mount.h index 2f5f3ae3bd2d..eb8c1f1be90c 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -58,7 +58,6 @@ struct vfsmount { #endif const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; - struct mnt_namespace *mnt_ns; /* containing namespace */ int mnt_id; /* mount identifier */ int mnt_group_id; /* peer group identifier */ int mnt_expiry_mark; /* true if marked for expiry */ From 15169fe784a9846b24cdb0840329d41aebc23249 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:50:41 -0500 Subject: [PATCH 144/165] vfs: mnt_id/mnt_group_id moved Signed-off-by: Al Viro --- fs/fhandle.c | 4 +++- fs/mount.h | 2 ++ fs/namespace.c | 30 +++++++++++++++--------------- fs/pnode.c | 4 ++-- include/linux/mount.h | 2 -- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/fs/fhandle.c b/fs/fhandle.c index 6b088641f5bf..5eff7116951e 100644 --- a/fs/fhandle.c +++ b/fs/fhandle.c @@ -10,6 +10,7 @@ #include #include #include "internal.h" +#include "mount.h" static long do_sys_name_to_handle(struct path *path, struct file_handle __user *ufh, @@ -66,7 +67,8 @@ static long do_sys_name_to_handle(struct path *path, } else retval = 0; /* copy the mount id */ - if (copy_to_user(mnt_id, &path->mnt->mnt_id, sizeof(*mnt_id)) || + if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id, + sizeof(*mnt_id)) || copy_to_user(ufh, handle, sizeof(struct file_handle) + handle_bytes)) retval = -EFAULT; diff --git a/fs/mount.h b/fs/mount.h index 4a5f1dca0c2e..c7bd401960ea 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -26,6 +26,8 @@ struct mount { struct list_head mnt_slave; /* slave list entry */ struct mount *mnt_master; /* slave is on master->mnt_slave_list */ struct mnt_namespace *mnt_ns; /* containing namespace */ + int mnt_id; /* mount identifier */ + int mnt_group_id; /* peer group identifier */ }; static inline struct mount *real_mount(struct vfsmount *mnt) diff --git a/fs/namespace.c b/fs/namespace.c index 4cdb7f698613..dfed9a25f204 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -85,9 +85,9 @@ static int mnt_alloc_id(struct mount *mnt) retry: ida_pre_get(&mnt_id_ida, GFP_KERNEL); spin_lock(&mnt_id_lock); - res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt.mnt_id); + res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt_id); if (!res) - mnt_id_start = mnt->mnt.mnt_id + 1; + mnt_id_start = mnt->mnt_id + 1; spin_unlock(&mnt_id_lock); if (res == -EAGAIN) goto retry; @@ -97,7 +97,7 @@ retry: static void mnt_free_id(struct mount *mnt) { - int id = mnt->mnt.mnt_id; + int id = mnt->mnt_id; spin_lock(&mnt_id_lock); ida_remove(&mnt_id_ida, id); if (mnt_id_start > id) @@ -119,9 +119,9 @@ static int mnt_alloc_group_id(struct mount *mnt) res = ida_get_new_above(&mnt_group_ida, mnt_group_start, - &mnt->mnt.mnt_group_id); + &mnt->mnt_group_id); if (!res) - mnt_group_start = mnt->mnt.mnt_group_id + 1; + mnt_group_start = mnt->mnt_group_id + 1; return res; } @@ -131,11 +131,11 @@ static int mnt_alloc_group_id(struct mount *mnt) */ void mnt_release_group_id(struct mount *mnt) { - int id = mnt->mnt.mnt_group_id; + int id = mnt->mnt_group_id; ida_remove(&mnt_group_ida, id); if (mnt_group_start > id) mnt_group_start = id; - mnt->mnt.mnt_group_id = 0; + mnt->mnt_group_id = 0; } /* @@ -696,11 +696,11 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, if (mnt) { if (flag & (CL_SLAVE | CL_PRIVATE)) - mnt->mnt.mnt_group_id = 0; /* not a peer of original */ + mnt->mnt_group_id = 0; /* not a peer of original */ else - mnt->mnt.mnt_group_id = old->mnt.mnt_group_id; + mnt->mnt_group_id = old->mnt_group_id; - if ((flag & CL_MAKE_SHARED) && !mnt->mnt.mnt_group_id) { + if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) { int err = mnt_alloc_group_id(mnt); if (err) goto out_free; @@ -1029,7 +1029,7 @@ static int show_mountinfo(struct seq_file *m, void *v) struct path root = p->root; int err = 0; - seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, r->mnt_parent->mnt.mnt_id, + seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id, MAJOR(sb->s_dev), MINOR(sb->s_dev)); if (sb->s_op->show_path) err = sb->s_op->show_path(m, mnt); @@ -1049,9 +1049,9 @@ static int show_mountinfo(struct seq_file *m, void *v) /* Tagged fields ("foo:X" or "bar") */ if (IS_MNT_SHARED(mnt)) - seq_printf(m, " shared:%i", mnt->mnt_group_id); + seq_printf(m, " shared:%i", r->mnt_group_id); if (IS_MNT_SLAVE(r)) { - int master = r->mnt_master->mnt.mnt_group_id; + int master = r->mnt_master->mnt_group_id; int dom = get_dominating_id(r, &p->root); seq_printf(m, " master:%i", master); if (dom && dom != master) @@ -1507,7 +1507,7 @@ static void cleanup_group_ids(struct mount *mnt, struct mount *end) struct mount *p; for (p = mnt; p != end; p = next_mnt(p, &mnt->mnt)) { - if (p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) + if (p->mnt_group_id && !IS_MNT_SHARED(&p->mnt)) mnt_release_group_id(p); } } @@ -1517,7 +1517,7 @@ static int invent_group_ids(struct mount *mnt, bool recurse) struct mount *p; for (p = mnt; p; p = recurse ? next_mnt(p, &mnt->mnt) : NULL) { - if (!p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) { + if (!p->mnt_group_id && !IS_MNT_SHARED(&p->mnt)) { int err = mnt_alloc_group_id(p); if (err) { cleanup_group_ids(mnt, p); diff --git a/fs/pnode.c b/fs/pnode.c index cec329822a16..001c8b0df379 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -58,7 +58,7 @@ int get_dominating_id(struct mount *mnt, const struct path *root) for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) { struct mount *d = get_peer_under_root(m, mnt->mnt_ns, root); if (d) - return d->mnt.mnt_group_id; + return d->mnt_group_id; } return 0; @@ -86,7 +86,7 @@ static int do_make_slave(struct mount *mnt) mnt_release_group_id(mnt); list_del_init(&mnt->mnt_share); - mnt->mnt.mnt_group_id = 0; + mnt->mnt_group_id = 0; if (peer_mnt) master = peer_mnt; diff --git a/include/linux/mount.h b/include/linux/mount.h index eb8c1f1be90c..b26dc40bfafc 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -58,8 +58,6 @@ struct vfsmount { #endif const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; - int mnt_id; /* mount identifier */ - int mnt_group_id; /* peer group identifier */ int mnt_expiry_mark; /* true if marked for expiry */ int mnt_pinned; int mnt_ghosts; From 863d684f946eb240c7dd57d265d88315950ca5cc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 00:57:42 -0500 Subject: [PATCH 145/165] vfs: move the rest of int fields to struct mount Signed-off-by: Al Viro --- fs/mount.h | 3 +++ fs/namespace.c | 32 +++++++++++++++++--------------- fs/pnode.c | 2 +- include/linux/mount.h | 3 --- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index c7bd401960ea..9217e03ba5e7 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -28,6 +28,9 @@ struct mount { struct mnt_namespace *mnt_ns; /* containing namespace */ int mnt_id; /* mount identifier */ int mnt_group_id; /* peer group identifier */ + int mnt_expiry_mark; /* true if marked for expiry */ + int mnt_pinned; + int mnt_ghosts; }; static inline struct mount *real_mount(struct vfsmount *mnt) diff --git a/fs/namespace.c b/fs/namespace.c index dfed9a25f204..c7b8dbc88fe5 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -787,9 +787,9 @@ put_again: return; br_write_lock(vfsmount_lock); #endif - if (unlikely(mnt->mnt.mnt_pinned)) { - mnt_add_count(mnt, mnt->mnt.mnt_pinned + 1); - mnt->mnt.mnt_pinned = 0; + if (unlikely(mnt->mnt_pinned)) { + mnt_add_count(mnt, mnt->mnt_pinned + 1); + mnt->mnt_pinned = 0; br_write_unlock(vfsmount_lock); acct_auto_close_mnt(&mnt->mnt); goto put_again; @@ -801,10 +801,11 @@ put_again: void mntput(struct vfsmount *mnt) { if (mnt) { + struct mount *m = real_mount(mnt); /* avoid cacheline pingpong, hope gcc doesn't get "smart" */ - if (unlikely(mnt->mnt_expiry_mark)) - mnt->mnt_expiry_mark = 0; - mntput_no_expire(real_mount(mnt)); + if (unlikely(m->mnt_expiry_mark)) + m->mnt_expiry_mark = 0; + mntput_no_expire(m); } } EXPORT_SYMBOL(mntput); @@ -820,16 +821,17 @@ EXPORT_SYMBOL(mntget); void mnt_pin(struct vfsmount *mnt) { br_write_lock(vfsmount_lock); - mnt->mnt_pinned++; + real_mount(mnt)->mnt_pinned++; br_write_unlock(vfsmount_lock); } EXPORT_SYMBOL(mnt_pin); -void mnt_unpin(struct vfsmount *mnt) +void mnt_unpin(struct vfsmount *m) { + struct mount *mnt = real_mount(m); br_write_lock(vfsmount_lock); if (mnt->mnt_pinned) { - mnt_add_count(real_mount(mnt), 1); + mnt_add_count(mnt, 1); mnt->mnt_pinned--; } br_write_unlock(vfsmount_lock); @@ -1200,17 +1202,17 @@ void release_mounts(struct list_head *head) list_del_init(&mnt->mnt_hash); if (mnt_has_parent(mnt)) { struct dentry *dentry; - struct vfsmount *m; + struct mount *m; br_write_lock(vfsmount_lock); dentry = mnt->mnt_mountpoint; - m = &mnt->mnt_parent->mnt; + m = mnt->mnt_parent; mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; m->mnt_ghosts--; br_write_unlock(vfsmount_lock); dput(dentry); - mntput(m); + mntput(&m->mnt); } mntput(&mnt->mnt); } @@ -1239,7 +1241,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) __mnt_make_shortterm(p); list_del_init(&p->mnt_child); if (mnt_has_parent(p)) { - p->mnt_parent->mnt.mnt_ghosts++; + p->mnt_parent->mnt_ghosts++; dentry_reset_mounted(p->mnt_mountpoint); } change_mnt_propagation(p, MS_PRIVATE); @@ -1281,7 +1283,7 @@ static int do_umount(struct mount *mnt, int flags) } br_write_unlock(vfsmount_lock); - if (!xchg(&mnt->mnt.mnt_expiry_mark, 1)) + if (!xchg(&mnt->mnt_expiry_mark, 1)) return -EAGAIN; } @@ -2106,7 +2108,7 @@ void mark_mounts_for_expiry(struct list_head *mounts) * cleared by mntput()) */ list_for_each_entry_safe(mnt, next, mounts, mnt_expire) { - if (!xchg(&mnt->mnt.mnt_expiry_mark, 1) || + if (!xchg(&mnt->mnt_expiry_mark, 1) || propagate_mount_busy(mnt, 1)) continue; list_move(&mnt->mnt_expire, &graveyard); diff --git a/fs/pnode.c b/fs/pnode.c index 001c8b0df379..a40abf20f35e 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -272,7 +272,7 @@ out: */ static inline int do_refcount_check(struct mount *mnt, int count) { - int mycount = mnt_get_count(mnt) - mnt->mnt.mnt_ghosts; + int mycount = mnt_get_count(mnt) - mnt->mnt_ghosts; return (mycount > count); } diff --git a/include/linux/mount.h b/include/linux/mount.h index b26dc40bfafc..080e3088ca81 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -58,9 +58,6 @@ struct vfsmount { #endif const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; - int mnt_expiry_mark; /* true if marked for expiry */ - int mnt_pinned; - int mnt_ghosts; }; struct file; /* forward dec */ From fc7be130c7e91cf693d4bc2d9b11f08a5a4893d0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 01:05:37 -0500 Subject: [PATCH 146/165] vfs: switch pnode.h macros to struct mount * Signed-off-by: Al Viro --- fs/namespace.c | 42 +++++++++++++++++++++--------------------- fs/pnode.c | 6 +++--- fs/pnode.h | 10 +++++----- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index c7b8dbc88fe5..bbe24defcac7 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -716,9 +716,9 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, if (flag & CL_SLAVE) { list_add(&mnt->mnt_slave, &old->mnt_slave_list); mnt->mnt_master = old; - CLEAR_MNT_SHARED(&mnt->mnt); + CLEAR_MNT_SHARED(mnt); } else if (!(flag & CL_PRIVATE)) { - if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(&old->mnt)) + if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) list_add(&mnt->mnt_share, &old->mnt_share); if (IS_MNT_SLAVE(old)) list_add(&mnt->mnt_slave, &old->mnt_slave); @@ -1050,7 +1050,7 @@ static int show_mountinfo(struct seq_file *m, void *v) show_mnt_opts(m, mnt); /* Tagged fields ("foo:X" or "bar") */ - if (IS_MNT_SHARED(mnt)) + if (IS_MNT_SHARED(r)) seq_printf(m, " shared:%i", r->mnt_group_id); if (IS_MNT_SLAVE(r)) { int master = r->mnt_master->mnt_group_id; @@ -1059,7 +1059,7 @@ static int show_mountinfo(struct seq_file *m, void *v) if (dom && dom != master) seq_printf(m, " propagate_from:%i", dom); } - if (IS_MNT_UNBINDABLE(mnt)) + if (IS_MNT_UNBINDABLE(r)) seq_puts(m, " unbindable"); /* Filesystem specific data */ @@ -1421,7 +1421,7 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, struct mount *res, *p, *q, *r; struct path path; - if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(&mnt->mnt)) + if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt)) return NULL; res = q = clone_mnt(mnt, dentry, flag); @@ -1436,7 +1436,7 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, continue; for (s = r; s; s = next_mnt(s, &r->mnt)) { - if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(&s->mnt)) { + if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(s)) { s = skip_mnt_tree(s); continue; } @@ -1509,7 +1509,7 @@ static void cleanup_group_ids(struct mount *mnt, struct mount *end) struct mount *p; for (p = mnt; p != end; p = next_mnt(p, &mnt->mnt)) { - if (p->mnt_group_id && !IS_MNT_SHARED(&p->mnt)) + if (p->mnt_group_id && !IS_MNT_SHARED(p)) mnt_release_group_id(p); } } @@ -1519,7 +1519,7 @@ static int invent_group_ids(struct mount *mnt, bool recurse) struct mount *p; for (p = mnt; p; p = recurse ? next_mnt(p, &mnt->mnt) : NULL) { - if (!p->mnt_group_id && !IS_MNT_SHARED(&p->mnt)) { + if (!p->mnt_group_id && !IS_MNT_SHARED(p)) { int err = mnt_alloc_group_id(p); if (err) { cleanup_group_ids(mnt, p); @@ -1603,7 +1603,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, struct mount *child, *p; int err; - if (IS_MNT_SHARED(&dest_mnt->mnt)) { + if (IS_MNT_SHARED(dest_mnt)) { err = invent_group_ids(source_mnt, true); if (err) goto out; @@ -1614,7 +1614,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, br_write_lock(vfsmount_lock); - if (IS_MNT_SHARED(&dest_mnt->mnt)) { + if (IS_MNT_SHARED(dest_mnt)) { for (p = source_mnt; p; p = next_mnt(p, &source_mnt->mnt)) set_mnt_shared(p); } @@ -1636,7 +1636,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, return 0; out_cleanup_ids: - if (IS_MNT_SHARED(&dest_mnt->mnt)) + if (IS_MNT_SHARED(dest_mnt)) cleanup_group_ids(source_mnt, NULL); out: return err; @@ -1764,7 +1764,7 @@ static int do_loopback(struct path *path, char *old_name, old = real_mount(old_path.mnt); err = -EINVAL; - if (IS_MNT_UNBINDABLE(old_path.mnt)) + if (IS_MNT_UNBINDABLE(old)) goto out2; if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old)) @@ -1859,7 +1859,7 @@ static inline int tree_contains_unbindable(struct mount *mnt) { struct mount *p; for (p = mnt; p; p = next_mnt(p, &mnt->mnt)) { - if (IS_MNT_UNBINDABLE(&p->mnt)) + if (IS_MNT_UNBINDABLE(p)) return 1; } return 0; @@ -1884,9 +1884,10 @@ static int do_move_mount(struct path *path, char *old_name) goto out; old = real_mount(old_path.mnt); + p = real_mount(path->mnt); err = -EINVAL; - if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old)) + if (!check_mnt(p) || !check_mnt(old)) goto out1; if (d_unlinked(path->dentry)) @@ -1905,17 +1906,16 @@ static int do_move_mount(struct path *path, char *old_name) /* * Don't move a mount residing in a shared parent. */ - if (IS_MNT_SHARED(&old->mnt_parent->mnt)) + if (IS_MNT_SHARED(old->mnt_parent)) goto out1; /* * Don't move a mount tree containing unbindable mounts to a destination * mount which is shared. */ - if (IS_MNT_SHARED(path->mnt) && - tree_contains_unbindable(old)) + if (IS_MNT_SHARED(p) && tree_contains_unbindable(old)) goto out1; err = -ELOOP; - for (p = real_mount(path->mnt); mnt_has_parent(p); p = p->mnt_parent) + for (; mnt_has_parent(p); p = p->mnt_parent) if (p == old) goto out1; @@ -2643,9 +2643,9 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, error = -EINVAL; new_mnt = real_mount(new.mnt); root_mnt = real_mount(root.mnt); - if (IS_MNT_SHARED(old.mnt) || - IS_MNT_SHARED(&new_mnt->mnt_parent->mnt) || - IS_MNT_SHARED(&root_mnt->mnt_parent->mnt)) + if (IS_MNT_SHARED(real_mount(old.mnt)) || + IS_MNT_SHARED(new_mnt->mnt_parent) || + IS_MNT_SHARED(root_mnt->mnt_parent)) goto out4; if (!check_mnt(root_mnt) || !check_mnt(new_mnt)) goto out4; diff --git a/fs/pnode.c b/fs/pnode.c index a40abf20f35e..ab5fa9e1a79a 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -82,7 +82,7 @@ static int do_make_slave(struct mount *mnt) if (peer_mnt == mnt) peer_mnt = NULL; } - if (IS_MNT_SHARED(&mnt->mnt) && list_empty(&mnt->mnt_share)) + if (IS_MNT_SHARED(mnt) && list_empty(&mnt->mnt_share)) mnt_release_group_id(mnt); list_del_init(&mnt->mnt_share); @@ -107,7 +107,7 @@ static int do_make_slave(struct mount *mnt) } } mnt->mnt_master = master; - CLEAR_MNT_SHARED(&mnt->mnt); + CLEAR_MNT_SHARED(mnt); return 0; } @@ -199,7 +199,7 @@ static struct mount *get_source(struct mount *dest, /* slave of the earlier, then */ *type = CL_SLAVE; /* beginning of peer group among the slaves? */ - if (IS_MNT_SHARED(&dest->mnt)) + if (IS_MNT_SHARED(dest)) *type |= CL_MAKE_SHARED; return last_src; } diff --git a/fs/pnode.h b/fs/pnode.h index 54deeda0cdb8..65c60979d541 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -11,11 +11,11 @@ #include #include "mount.h" -#define IS_MNT_SHARED(mnt) ((mnt)->mnt_flags & MNT_SHARED) -#define IS_MNT_SLAVE(mnt) ((mnt)->mnt_master) -#define IS_MNT_NEW(mnt) (!(mnt)->mnt_ns) -#define CLEAR_MNT_SHARED(mnt) ((mnt)->mnt_flags &= ~MNT_SHARED) -#define IS_MNT_UNBINDABLE(mnt) ((mnt)->mnt_flags & MNT_UNBINDABLE) +#define IS_MNT_SHARED(m) ((m)->mnt.mnt_flags & MNT_SHARED) +#define IS_MNT_SLAVE(m) ((m)->mnt_master) +#define IS_MNT_NEW(m) (!(m)->mnt_ns) +#define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED) +#define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE) #define CL_EXPIRE 0x01 #define CL_SLAVE 0x02 From 1a4eeaf2a8c07404e2d1c3ff99b393fd4c207170 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 02:19:55 -0500 Subject: [PATCH 147/165] vfs: move mnt_list to struct mount Signed-off-by: Al Viro --- fs/mount.h | 3 ++- fs/namespace.c | 47 ++++++++++++++++++++++--------------------- include/linux/mount.h | 1 - 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 9217e03ba5e7..7060d2a6f802 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -19,7 +19,8 @@ struct mount { #endif struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_child; /* and going through their mnt_child */ - /* yet to be moved - up to mnt_list */ + /* yet to be moved - up to mnt_devname */ + struct list_head mnt_list; struct list_head mnt_expire; /* link in fs-specific expiry list */ struct list_head mnt_share; /* circular list of shared mounts */ struct list_head mnt_slave_list;/* list of slave mounts */ diff --git a/fs/namespace.c b/fs/namespace.c index bbe24defcac7..e15125356ac1 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -202,7 +202,7 @@ static struct mount *alloc_vfsmnt(const char *name) INIT_LIST_HEAD(&p->mnt_hash); INIT_LIST_HEAD(&p->mnt_child); INIT_LIST_HEAD(&p->mnt_mounts); - INIT_LIST_HEAD(&mnt->mnt_list); + INIT_LIST_HEAD(&p->mnt_list); INIT_LIST_HEAD(&p->mnt_expire); INIT_LIST_HEAD(&p->mnt_share); INIT_LIST_HEAD(&p->mnt_slave_list); @@ -618,8 +618,8 @@ static void commit_tree(struct mount *mnt) BUG_ON(parent == mnt); - list_add_tail(&head, &mnt->mnt.mnt_list); - list_for_each_entry(m, &head, mnt.mnt_list) { + list_add_tail(&head, &mnt->mnt_list); + list_for_each_entry(m, &head, mnt_list) { m->mnt_ns = n; __mnt_make_longterm(m); } @@ -987,7 +987,8 @@ static void show_type(struct seq_file *m, struct super_block *sb) static int show_vfsmnt(struct seq_file *m, void *v) { - struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); + struct mount *r = list_entry(v, struct mount, mnt_list); + struct vfsmount *mnt = &r->mnt; int err = 0; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; @@ -1024,8 +1025,8 @@ const struct seq_operations mounts_op = { static int show_mountinfo(struct seq_file *m, void *v) { struct proc_mounts *p = m->private; - struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); - struct mount *r = real_mount(mnt); + struct mount *r = list_entry(v, struct mount, mnt_list); + struct vfsmount *mnt = &r->mnt; struct super_block *sb = mnt->mnt_sb; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; struct path root = p->root; @@ -1092,7 +1093,8 @@ const struct seq_operations mountinfo_op = { static int show_vfsstat(struct seq_file *m, void *v) { - struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); + struct mount *r = list_entry(v, struct mount, mnt_list); + struct vfsmount *mnt = &r->mnt; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; int err = 0; @@ -1235,7 +1237,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) list_for_each_entry(p, &tmp_list, mnt_hash) { list_del_init(&p->mnt_expire); - list_del_init(&p->mnt.mnt_list); + list_del_init(&p->mnt_list); __touch_mnt_namespace(p->mnt_ns); p->mnt_ns = NULL; __mnt_make_shortterm(p); @@ -1331,7 +1333,7 @@ static int do_umount(struct mount *mnt, int flags) retval = -EBUSY; if (flags & MNT_DETACH || !propagate_mount_busy(mnt, 2)) { - if (!list_empty(&mnt->mnt.mnt_list)) + if (!list_empty(&mnt->mnt_list)) umount_tree(mnt, 1, &umount_list); retval = 0; } @@ -1451,7 +1453,7 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, if (!q) goto Enomem; br_write_lock(vfsmount_lock); - list_add_tail(&q->mnt.mnt_list, &res->mnt.mnt_list); + list_add_tail(&q->mnt_list, &res->mnt_list); attach_mnt(q, &path); br_write_unlock(vfsmount_lock); } @@ -1492,12 +1494,12 @@ void drop_collected_mounts(struct vfsmount *mnt) int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, struct vfsmount *root) { - struct vfsmount *mnt; + struct mount *mnt; int res = f(root, arg); if (res) return res; - list_for_each_entry(mnt, &root->mnt_list, mnt_list) { - res = f(mnt, arg); + list_for_each_entry(mnt, &real_mount(root)->mnt_list, mnt_list) { + res = f(&mnt->mnt, arg); if (res) return res; } @@ -2415,7 +2417,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, } new_ns->root = &new->mnt; br_write_lock(vfsmount_lock); - list_add_tail(&new_ns->list, &new_ns->root->mnt_list); + list_add_tail(&new_ns->list, &new->mnt_list); br_write_unlock(vfsmount_lock); /* @@ -2476,18 +2478,17 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, * create_mnt_ns - creates a private namespace and adds a root filesystem * @mnt: pointer to the new root filesystem mountpoint */ -static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) +static struct mnt_namespace *create_mnt_ns(struct vfsmount *m) { - struct mnt_namespace *new_ns; - - new_ns = alloc_mnt_ns(); + struct mnt_namespace *new_ns = alloc_mnt_ns(); if (!IS_ERR(new_ns)) { - real_mount(mnt)->mnt_ns = new_ns; - __mnt_make_longterm(real_mount(mnt)); - new_ns->root = mnt; - list_add(&new_ns->list, &new_ns->root->mnt_list); + struct mount *mnt = real_mount(m); + mnt->mnt_ns = new_ns; + __mnt_make_longterm(mnt); + new_ns->root = m; + list_add(&new_ns->list, &mnt->mnt_list); } else { - mntput(mnt); + mntput(m); } return new_ns; } diff --git a/include/linux/mount.h b/include/linux/mount.h index 080e3088ca81..16ae3d46b30a 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -57,7 +57,6 @@ struct vfsmount { struct hlist_head mnt_fsnotify_marks; #endif const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ - struct list_head mnt_list; }; struct file; /* forward dec */ From 52ba1621de1479ce7e52b6d167860462e483313c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 02:25:17 -0500 Subject: [PATCH 148/165] vfs: move mnt_devname Signed-off-by: Al Viro --- fs/mount.h | 3 ++- fs/namespace.c | 18 +++++++++--------- include/linux/mount.h | 1 - 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 7060d2a6f802..c5fc3f7a9580 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -19,7 +19,8 @@ struct mount { #endif struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_child; /* and going through their mnt_child */ - /* yet to be moved - up to mnt_devname */ + /* yet to be moved - fsnotify ones go here */ + const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; struct list_head mnt_expire; /* link in fs-specific expiry list */ struct list_head mnt_share; /* circular list of shared mounts */ diff --git a/fs/namespace.c b/fs/namespace.c index e15125356ac1..b8a30928d0c1 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -183,8 +183,8 @@ static struct mount *alloc_vfsmnt(const char *name) goto out_free_cache; if (name) { - mnt->mnt_devname = kstrdup(name, GFP_KERNEL); - if (!mnt->mnt_devname) + p->mnt_devname = kstrdup(name, GFP_KERNEL); + if (!p->mnt_devname) goto out_free_id; } @@ -215,7 +215,7 @@ static struct mount *alloc_vfsmnt(const char *name) #ifdef CONFIG_SMP out_free_devname: - kfree(p->mnt.mnt_devname); + kfree(p->mnt_devname); #endif out_free_id: mnt_free_id(p); @@ -451,7 +451,7 @@ static void __mnt_unmake_readonly(struct mount *mnt) static void free_vfsmnt(struct mount *mnt) { - kfree(mnt->mnt.mnt_devname); + kfree(mnt->mnt_devname); mnt_free_id(mnt); #ifdef CONFIG_SMP free_percpu(mnt->mnt_pcp); @@ -692,7 +692,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, int flag) { struct super_block *sb = old->mnt.mnt_sb; - struct mount *mnt = alloc_vfsmnt(old->mnt.mnt_devname); + struct mount *mnt = alloc_vfsmnt(old->mnt_devname); if (mnt) { if (flag & (CL_SLAVE | CL_PRIVATE)) @@ -997,7 +997,7 @@ static int show_vfsmnt(struct seq_file *m, void *v) if (err) goto out; } else { - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none"); + mangle(m, r->mnt_devname ? r->mnt_devname : "none"); } seq_putc(m, ' '); seq_path(m, &mnt_path, " \t\n\\"); @@ -1070,7 +1070,7 @@ static int show_mountinfo(struct seq_file *m, void *v) if (sb->s_op->show_devname) err = sb->s_op->show_devname(m, mnt); else - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none"); + mangle(m, r->mnt_devname ? r->mnt_devname : "none"); if (err) goto out; seq_puts(m, sb->s_flags & MS_RDONLY ? " ro" : " rw"); @@ -1103,9 +1103,9 @@ static int show_vfsstat(struct seq_file *m, void *v) seq_puts(m, "device "); err = mnt->mnt_sb->s_op->show_devname(m, mnt); } else { - if (mnt->mnt_devname) { + if (r->mnt_devname) { seq_puts(m, "device "); - mangle(m, mnt->mnt_devname); + mangle(m, r->mnt_devname); } else seq_puts(m, "no device"); } diff --git a/include/linux/mount.h b/include/linux/mount.h index 16ae3d46b30a..f18dd1bfcbda 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -56,7 +56,6 @@ struct vfsmount { __u32 mnt_fsnotify_mask; struct hlist_head mnt_fsnotify_marks; #endif - const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ }; struct file; /* forward dec */ From c63181e6b6df89176b3984c6977bb5ec03d0df23 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 02:35:16 -0500 Subject: [PATCH 149/165] vfs: move fsnotify junk to struct mount Signed-off-by: Al Viro --- fs/mount.h | 5 +++- fs/namespace.c | 45 +++++++++++++++--------------- fs/notify/fanotify/fanotify_user.c | 6 ++-- fs/notify/fsnotify.c | 9 +++--- fs/notify/vfsmount_mark.c | 19 ++++++++----- include/linux/mount.h | 5 ---- 6 files changed, 47 insertions(+), 42 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index c5fc3f7a9580..e094c863c8af 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -19,7 +19,6 @@ struct mount { #endif struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_child; /* and going through their mnt_child */ - /* yet to be moved - fsnotify ones go here */ const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; struct list_head mnt_expire; /* link in fs-specific expiry list */ @@ -28,6 +27,10 @@ struct mount { struct list_head mnt_slave; /* slave list entry */ struct mount *mnt_master; /* slave is on master->mnt_slave_list */ struct mnt_namespace *mnt_ns; /* containing namespace */ +#ifdef CONFIG_FSNOTIFY + struct hlist_head mnt_fsnotify_marks; + __u32 mnt_fsnotify_mask; +#endif int mnt_id; /* mount identifier */ int mnt_group_id; /* peer group identifier */ int mnt_expiry_mark; /* true if marked for expiry */ diff --git a/fs/namespace.c b/fs/namespace.c index b8a30928d0c1..124a12555fe4 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -173,54 +173,53 @@ unsigned int mnt_get_count(struct mount *mnt) static struct mount *alloc_vfsmnt(const char *name) { - struct mount *p = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); - if (p) { - struct vfsmount *mnt = &p->mnt; + struct mount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); + if (mnt) { int err; - err = mnt_alloc_id(p); + err = mnt_alloc_id(mnt); if (err) goto out_free_cache; if (name) { - p->mnt_devname = kstrdup(name, GFP_KERNEL); - if (!p->mnt_devname) + mnt->mnt_devname = kstrdup(name, GFP_KERNEL); + if (!mnt->mnt_devname) goto out_free_id; } #ifdef CONFIG_SMP - p->mnt_pcp = alloc_percpu(struct mnt_pcp); - if (!p->mnt_pcp) + mnt->mnt_pcp = alloc_percpu(struct mnt_pcp); + if (!mnt->mnt_pcp) goto out_free_devname; - this_cpu_add(p->mnt_pcp->mnt_count, 1); + this_cpu_add(mnt->mnt_pcp->mnt_count, 1); #else - p->mnt_count = 1; - p->mnt_writers = 0; + mnt->mnt_count = 1; + mnt->mnt_writers = 0; #endif - INIT_LIST_HEAD(&p->mnt_hash); - INIT_LIST_HEAD(&p->mnt_child); - INIT_LIST_HEAD(&p->mnt_mounts); - INIT_LIST_HEAD(&p->mnt_list); - INIT_LIST_HEAD(&p->mnt_expire); - INIT_LIST_HEAD(&p->mnt_share); - INIT_LIST_HEAD(&p->mnt_slave_list); - INIT_LIST_HEAD(&p->mnt_slave); + INIT_LIST_HEAD(&mnt->mnt_hash); + INIT_LIST_HEAD(&mnt->mnt_child); + INIT_LIST_HEAD(&mnt->mnt_mounts); + INIT_LIST_HEAD(&mnt->mnt_list); + INIT_LIST_HEAD(&mnt->mnt_expire); + INIT_LIST_HEAD(&mnt->mnt_share); + INIT_LIST_HEAD(&mnt->mnt_slave_list); + INIT_LIST_HEAD(&mnt->mnt_slave); #ifdef CONFIG_FSNOTIFY INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks); #endif } - return p; + return mnt; #ifdef CONFIG_SMP out_free_devname: - kfree(p->mnt_devname); + kfree(mnt->mnt_devname); #endif out_free_id: - mnt_free_id(p); + mnt_free_id(mnt); out_free_cache: - kmem_cache_free(mnt_cache, p); + kmem_cache_free(mnt_cache, mnt); return NULL; } 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 @@ #include +#include "../../mount.h" + #define FANOTIFY_DEFAULT_MAX_EVENTS 16384 #define FANOTIFY_DEFAULT_MAX_MARKS 8192 #define FANOTIFY_DEFAULT_MAX_LISTENERS 128 @@ -546,7 +548,7 @@ static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group, removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags); fsnotify_put_mark(fsn_mark); - if (removed & mnt->mnt_fsnotify_mask) + if (removed & real_mount(mnt)->mnt_fsnotify_mask) fsnotify_recalc_vfsmount_mask(mnt); return 0; @@ -623,7 +625,7 @@ static int fanotify_add_vfsmount_mark(struct fsnotify_group *group, } added = fanotify_mark_add_to_mask(fsn_mark, mask, flags); - if (added & ~mnt->mnt_fsnotify_mask) + if (added & ~real_mount(mnt)->mnt_fsnotify_mask) fsnotify_recalc_vfsmount_mask(mnt); err: 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 @@ #include #include "fsnotify.h" +#include "../mount.h" /* * 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, struct fsnotify_mark *inode_mark = NULL, *vfsmount_mark = NULL; struct fsnotify_group *inode_group, *vfsmount_group; struct fsnotify_event *event = NULL; - struct vfsmount *mnt; + struct mount *mnt; int idx, ret = 0; /* global tests shouldn't care about events on child only the specific event */ __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); if (data_is == FSNOTIFY_EVENT_PATH) - mnt = ((struct path *)data)->mnt; + mnt = real_mount(((struct path *)data)->mnt); else mnt = NULL; @@ -262,11 +263,11 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, /* we didn't use the vfsmount_mark */ vfsmount_group = NULL; } else if (vfsmount_group > inode_group) { - ret = send_to_group(to_tell, mnt, NULL, vfsmount_mark, mask, data, + ret = send_to_group(to_tell, &mnt->mnt, NULL, vfsmount_mark, mask, data, data_is, cookie, file_name, &event); inode_group = NULL; } else { - ret = send_to_group(to_tell, mnt, inode_mark, vfsmount_mark, + ret = send_to_group(to_tell, &mnt->mnt, inode_mark, vfsmount_mark, mask, data, data_is, cookie, file_name, &event); } 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 @@ #include #include "fsnotify.h" +#include "../mount.h" void fsnotify_clear_marks_by_mount(struct vfsmount *mnt) { struct fsnotify_mark *mark, *lmark; struct hlist_node *pos, *n; + struct mount *m = real_mount(mnt); LIST_HEAD(free_list); spin_lock(&mnt->mnt_root->d_lock); - hlist_for_each_entry_safe(mark, pos, n, &mnt->mnt_fsnotify_marks, m.m_list) { + hlist_for_each_entry_safe(mark, pos, n, &m->mnt_fsnotify_marks, m.m_list) { list_add(&mark->m.free_m_list, &free_list); hlist_del_init_rcu(&mark->m.m_list); fsnotify_get_mark(mark); @@ -59,15 +61,16 @@ void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group) */ static void fsnotify_recalc_vfsmount_mask_locked(struct vfsmount *mnt) { + struct mount *m = real_mount(mnt); struct fsnotify_mark *mark; struct hlist_node *pos; __u32 new_mask = 0; assert_spin_locked(&mnt->mnt_root->d_lock); - hlist_for_each_entry(mark, pos, &mnt->mnt_fsnotify_marks, m.m_list) + hlist_for_each_entry(mark, pos, &m->mnt_fsnotify_marks, m.m_list) new_mask |= mark->mask; - mnt->mnt_fsnotify_mask = new_mask; + m->mnt_fsnotify_mask = new_mask; } /* @@ -101,12 +104,13 @@ void fsnotify_destroy_vfsmount_mark(struct fsnotify_mark *mark) static struct fsnotify_mark *fsnotify_find_vfsmount_mark_locked(struct fsnotify_group *group, struct vfsmount *mnt) { + struct mount *m = real_mount(mnt); struct fsnotify_mark *mark; struct hlist_node *pos; assert_spin_locked(&mnt->mnt_root->d_lock); - hlist_for_each_entry(mark, pos, &mnt->mnt_fsnotify_marks, m.m_list) { + hlist_for_each_entry(mark, pos, &m->mnt_fsnotify_marks, m.m_list) { if (mark->group == group) { fsnotify_get_mark(mark); return mark; @@ -140,6 +144,7 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark, struct fsnotify_group *group, struct vfsmount *mnt, int allow_dups) { + struct mount *m = real_mount(mnt); struct fsnotify_mark *lmark; struct hlist_node *node, *last = NULL; int ret = 0; @@ -154,13 +159,13 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark, mark->m.mnt = mnt; /* is mark the first mark? */ - if (hlist_empty(&mnt->mnt_fsnotify_marks)) { - hlist_add_head_rcu(&mark->m.m_list, &mnt->mnt_fsnotify_marks); + if (hlist_empty(&m->mnt_fsnotify_marks)) { + hlist_add_head_rcu(&mark->m.m_list, &m->mnt_fsnotify_marks); goto out; } /* should mark be in the middle of the current list? */ - hlist_for_each_entry(lmark, node, &mnt->mnt_fsnotify_marks, m.m_list) { + hlist_for_each_entry(lmark, node, &m->mnt_fsnotify_marks, m.m_list) { last = node; if ((lmark->group == group) && !allow_dups) { diff --git a/include/linux/mount.h b/include/linux/mount.h index f18dd1bfcbda..d7029f4a191a 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -51,11 +51,6 @@ struct vfsmount { struct dentry *mnt_root; /* root of the mounted tree */ struct super_block *mnt_sb; /* pointer to superblock */ int mnt_flags; - /* 4 bytes hole on 64bits arches without fsnotify */ -#ifdef CONFIG_FSNOTIFY - __u32 mnt_fsnotify_mask; - struct hlist_head mnt_fsnotify_marks; -#endif }; struct file; /* forward dec */ From 909b0a88ef2dc86bd5d2223edf48eb30c865cb69 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 03:06:56 -0500 Subject: [PATCH 150/165] vfs: spread struct mount - remaining argument of next_mnt() Signed-off-by: Al Viro --- fs/namespace.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 124a12555fe4..24e845671ad3 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -631,12 +631,12 @@ static void commit_tree(struct mount *mnt) touch_mnt_namespace(n); } -static struct mount *next_mnt(struct mount *p, struct vfsmount *root) +static struct mount *next_mnt(struct mount *p, struct mount *root) { struct list_head *next = p->mnt_mounts.next; if (next == &p->mnt_mounts) { while (1) { - if (&p->mnt == root) + if (p == root) return NULL; next = p->mnt_child.next; if (next != &p->mnt_parent->mnt_mounts) @@ -1145,16 +1145,17 @@ const struct seq_operations mountstats_op = { * open files, pwds, chroots or sub mounts that are * busy. */ -int may_umount_tree(struct vfsmount *mnt) +int may_umount_tree(struct vfsmount *m) { + struct mount *mnt = real_mount(m); int actual_refs = 0; int minimum_refs = 0; struct mount *p; - BUG_ON(!mnt); + BUG_ON(!m); /* write lock needed for mnt_get_count */ br_write_lock(vfsmount_lock); - for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) { + for (p = mnt; p; p = next_mnt(p, mnt)) { actual_refs += mnt_get_count(p); minimum_refs += 2; } @@ -1228,7 +1229,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) LIST_HEAD(tmp_list); struct mount *p; - for (p = mnt; p; p = next_mnt(p, &mnt->mnt)) + for (p = mnt; p; p = next_mnt(p, mnt)) list_move(&p->mnt_hash, &tmp_list); if (propagate) @@ -1436,7 +1437,7 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, if (!is_subdir(r->mnt_mountpoint, dentry)) continue; - for (s = r; s; s = next_mnt(s, &r->mnt)) { + for (s = r; s; s = next_mnt(s, r)) { if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(s)) { s = skip_mnt_tree(s); continue; @@ -1509,7 +1510,7 @@ static void cleanup_group_ids(struct mount *mnt, struct mount *end) { struct mount *p; - for (p = mnt; p != end; p = next_mnt(p, &mnt->mnt)) { + for (p = mnt; p != end; p = next_mnt(p, mnt)) { if (p->mnt_group_id && !IS_MNT_SHARED(p)) mnt_release_group_id(p); } @@ -1519,7 +1520,7 @@ static int invent_group_ids(struct mount *mnt, bool recurse) { struct mount *p; - for (p = mnt; p; p = recurse ? next_mnt(p, &mnt->mnt) : NULL) { + for (p = mnt; p; p = recurse ? next_mnt(p, mnt) : NULL) { if (!p->mnt_group_id && !IS_MNT_SHARED(p)) { int err = mnt_alloc_group_id(p); if (err) { @@ -1616,7 +1617,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, br_write_lock(vfsmount_lock); if (IS_MNT_SHARED(dest_mnt)) { - for (p = source_mnt; p; p = next_mnt(p, &source_mnt->mnt)) + for (p = source_mnt; p; p = next_mnt(p, source_mnt)) set_mnt_shared(p); } if (parent_path) { @@ -1731,7 +1732,7 @@ static int do_change_type(struct path *path, int flag) } br_write_lock(vfsmount_lock); - for (m = mnt; m; m = (recurse ? next_mnt(m, &mnt->mnt) : NULL)) + for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) change_mnt_propagation(m, type); br_write_unlock(vfsmount_lock); @@ -1859,7 +1860,7 @@ static int do_remount(struct path *path, int flags, int mnt_flags, static inline int tree_contains_unbindable(struct mount *mnt) { struct mount *p; - for (p = mnt; p; p = next_mnt(p, &mnt->mnt)) { + for (p = mnt; p; p = next_mnt(p, mnt)) { if (IS_MNT_UNBINDABLE(p)) return 1; } @@ -2399,6 +2400,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, struct mnt_namespace *new_ns; struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; struct mount *p, *q; + struct mount *old = real_mount(mnt_ns->root); struct mount *new; new_ns = alloc_mnt_ns(); @@ -2407,8 +2409,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, down_write(&namespace_sem); /* First pass: copy the tree topology */ - new = copy_tree(real_mount(mnt_ns->root), mnt_ns->root->mnt_root, - CL_COPY_ALL | CL_EXPIRE); + new = copy_tree(old, old->mnt.mnt_root, CL_COPY_ALL | CL_EXPIRE); if (!new) { up_write(&namespace_sem); kfree(new_ns); @@ -2424,7 +2425,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, * as belonging to new namespace. We have already acquired a private * fs_struct, so tsk->fs->lock is not needed. */ - p = real_mount(mnt_ns->root); + p = old; q = new; while (p) { q->mnt_ns = new_ns; @@ -2443,8 +2444,8 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, pwdmnt = &p->mnt; } } - p = next_mnt(p, mnt_ns->root); - q = next_mnt(q, new_ns->root); + p = next_mnt(p, old); + q = next_mnt(q, new); } up_write(&namespace_sem); From 3a2393d71d77b034669d495b49c212a87e04abdc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 25 Nov 2011 03:19:09 -0500 Subject: [PATCH 151/165] vfs: opencode mntget() mnt_set_mountpoint() Signed-off-by: Al Viro --- fs/namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index 24e845671ad3..cd6389387d1f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -572,8 +572,9 @@ static void detach_mnt(struct mount *mnt, struct path *old_path) void mnt_set_mountpoint(struct mount *mnt, struct dentry *dentry, struct mount *child_mnt) { - child_mnt->mnt_parent = real_mount(mntget(&mnt->mnt)); + mnt_add_count(mnt, 1); /* essentially, that's mntget */ child_mnt->mnt_mountpoint = dget(dentry); + child_mnt->mnt_parent = mnt; spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_MOUNTED; spin_unlock(&dentry->d_lock); From 0226f4923f6c9b40cfa1c1c1b19a6ac6b3924ead Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 6 Dec 2011 12:21:54 -0500 Subject: [PATCH 152/165] vfs: take /proc/*/mounts and friends to fs/proc_namespace.c rationale: that stuff is far tighter bound to fs/namespace.c than to the guts of procfs proper. Signed-off-by: Al Viro --- fs/Makefile | 2 + fs/mount.h | 24 +++ fs/namespace.c | 218 +--------------------- fs/proc/base.c | 114 ------------ fs/proc_namespace.c | 331 ++++++++++++++++++++++++++++++++++ include/linux/mnt_namespace.h | 30 +-- 6 files changed, 368 insertions(+), 351 deletions(-) create mode 100644 fs/proc_namespace.c diff --git a/fs/Makefile b/fs/Makefile index d2c3353d5477..310cfc4e69d3 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -19,6 +19,8 @@ else obj-y += no-block.o endif +obj-$(CONFIG_PROC_FS) += proc_namespace.o + obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o obj-y += notify/ obj-$(CONFIG_EPOLL) += eventpoll.o diff --git a/fs/mount.h b/fs/mount.h index e094c863c8af..c6e99e03350a 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -1,4 +1,14 @@ #include +#include +#include + +struct mnt_namespace { + atomic_t count; + struct vfsmount * root; + struct list_head list; + wait_queue_head_t poll; + int event; +}; struct mnt_pcp { int mnt_count; @@ -49,3 +59,17 @@ static inline int mnt_has_parent(struct mount *mnt) } extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int); + +static inline void get_mnt_ns(struct mnt_namespace *ns) +{ + atomic_inc(&ns->count); +} + +struct proc_mounts { + struct seq_file m; /* must be the first element */ + struct mnt_namespace *ns; + struct path root; + int (*show)(struct seq_file *, struct vfsmount *); +}; + +extern const struct seq_operations mounts_op; diff --git a/fs/namespace.c b/fs/namespace.c index cd6389387d1f..21a8261256dd 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -898,10 +898,10 @@ void replace_mount_options(struct super_block *sb, char *options) EXPORT_SYMBOL(replace_mount_options); #ifdef CONFIG_PROC_FS -/* iterator */ +/* iterator; we want it to have access to namespace_sem, thus here... */ static void *m_start(struct seq_file *m, loff_t *pos) { - struct proc_mounts *p = m->private; + struct proc_mounts *p = container_of(m, struct proc_mounts, m); down_read(&namespace_sem); return seq_list_start(&p->ns->list, *pos); @@ -909,7 +909,7 @@ static void *m_start(struct seq_file *m, loff_t *pos) static void *m_next(struct seq_file *m, void *v, loff_t *pos) { - struct proc_mounts *p = m->private; + struct proc_mounts *p = container_of(m, struct proc_mounts, m); return seq_list_next(v, &p->ns->list, pos); } @@ -919,222 +919,18 @@ static void m_stop(struct seq_file *m, void *v) up_read(&namespace_sem); } -int mnt_had_events(struct proc_mounts *p) -{ - struct mnt_namespace *ns = p->ns; - int res = 0; - - br_read_lock(vfsmount_lock); - if (p->m.poll_event != ns->event) { - p->m.poll_event = ns->event; - res = 1; - } - br_read_unlock(vfsmount_lock); - - return res; -} - -struct proc_fs_info { - int flag; - const char *str; -}; - -static int show_sb_opts(struct seq_file *m, struct super_block *sb) -{ - static const struct proc_fs_info fs_info[] = { - { MS_SYNCHRONOUS, ",sync" }, - { MS_DIRSYNC, ",dirsync" }, - { MS_MANDLOCK, ",mand" }, - { 0, NULL } - }; - const struct proc_fs_info *fs_infop; - - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) { - if (sb->s_flags & fs_infop->flag) - seq_puts(m, fs_infop->str); - } - - return security_sb_show_options(m, sb); -} - -static void show_mnt_opts(struct seq_file *m, struct vfsmount *mnt) -{ - static const struct proc_fs_info mnt_info[] = { - { MNT_NOSUID, ",nosuid" }, - { MNT_NODEV, ",nodev" }, - { MNT_NOEXEC, ",noexec" }, - { MNT_NOATIME, ",noatime" }, - { MNT_NODIRATIME, ",nodiratime" }, - { MNT_RELATIME, ",relatime" }, - { 0, NULL } - }; - const struct proc_fs_info *fs_infop; - - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) { - if (mnt->mnt_flags & fs_infop->flag) - seq_puts(m, fs_infop->str); - } -} - -static void show_type(struct seq_file *m, struct super_block *sb) -{ - mangle(m, sb->s_type->name); - if (sb->s_subtype && sb->s_subtype[0]) { - seq_putc(m, '.'); - mangle(m, sb->s_subtype); - } -} - -static int show_vfsmnt(struct seq_file *m, void *v) +static int m_show(struct seq_file *m, void *v) { + struct proc_mounts *p = container_of(m, struct proc_mounts, m); struct mount *r = list_entry(v, struct mount, mnt_list); - struct vfsmount *mnt = &r->mnt; - int err = 0; - struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; - - if (mnt->mnt_sb->s_op->show_devname) { - err = mnt->mnt_sb->s_op->show_devname(m, mnt); - if (err) - goto out; - } else { - mangle(m, r->mnt_devname ? r->mnt_devname : "none"); - } - seq_putc(m, ' '); - seq_path(m, &mnt_path, " \t\n\\"); - seq_putc(m, ' '); - show_type(m, mnt->mnt_sb); - seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw"); - err = show_sb_opts(m, mnt->mnt_sb); - if (err) - goto out; - show_mnt_opts(m, mnt); - if (mnt->mnt_sb->s_op->show_options) - err = mnt->mnt_sb->s_op->show_options(m, mnt); - seq_puts(m, " 0 0\n"); -out: - return err; + return p->show(m, &r->mnt); } const struct seq_operations mounts_op = { .start = m_start, .next = m_next, .stop = m_stop, - .show = show_vfsmnt -}; - -static int show_mountinfo(struct seq_file *m, void *v) -{ - struct proc_mounts *p = m->private; - struct mount *r = list_entry(v, struct mount, mnt_list); - struct vfsmount *mnt = &r->mnt; - struct super_block *sb = mnt->mnt_sb; - struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; - struct path root = p->root; - int err = 0; - - seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id, - MAJOR(sb->s_dev), MINOR(sb->s_dev)); - if (sb->s_op->show_path) - err = sb->s_op->show_path(m, mnt); - else - seq_dentry(m, mnt->mnt_root, " \t\n\\"); - if (err) - goto out; - seq_putc(m, ' '); - - /* mountpoints outside of chroot jail will give SEQ_SKIP on this */ - err = seq_path_root(m, &mnt_path, &root, " \t\n\\"); - if (err) - goto out; - - seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw"); - show_mnt_opts(m, mnt); - - /* Tagged fields ("foo:X" or "bar") */ - if (IS_MNT_SHARED(r)) - seq_printf(m, " shared:%i", r->mnt_group_id); - if (IS_MNT_SLAVE(r)) { - int master = r->mnt_master->mnt_group_id; - int dom = get_dominating_id(r, &p->root); - seq_printf(m, " master:%i", master); - if (dom && dom != master) - seq_printf(m, " propagate_from:%i", dom); - } - if (IS_MNT_UNBINDABLE(r)) - seq_puts(m, " unbindable"); - - /* Filesystem specific data */ - seq_puts(m, " - "); - show_type(m, sb); - seq_putc(m, ' '); - if (sb->s_op->show_devname) - err = sb->s_op->show_devname(m, mnt); - else - mangle(m, r->mnt_devname ? r->mnt_devname : "none"); - if (err) - goto out; - seq_puts(m, sb->s_flags & MS_RDONLY ? " ro" : " rw"); - err = show_sb_opts(m, sb); - if (err) - goto out; - if (sb->s_op->show_options) - err = sb->s_op->show_options(m, mnt); - seq_putc(m, '\n'); -out: - return err; -} - -const struct seq_operations mountinfo_op = { - .start = m_start, - .next = m_next, - .stop = m_stop, - .show = show_mountinfo, -}; - -static int show_vfsstat(struct seq_file *m, void *v) -{ - struct mount *r = list_entry(v, struct mount, mnt_list); - struct vfsmount *mnt = &r->mnt; - struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; - int err = 0; - - /* device */ - if (mnt->mnt_sb->s_op->show_devname) { - seq_puts(m, "device "); - err = mnt->mnt_sb->s_op->show_devname(m, mnt); - } else { - if (r->mnt_devname) { - seq_puts(m, "device "); - mangle(m, r->mnt_devname); - } else - seq_puts(m, "no device"); - } - - /* mount point */ - seq_puts(m, " mounted on "); - seq_path(m, &mnt_path, " \t\n\\"); - seq_putc(m, ' '); - - /* file system type */ - seq_puts(m, "with fstype "); - show_type(m, mnt->mnt_sb); - - /* optional statistics */ - if (mnt->mnt_sb->s_op->show_stats) { - seq_putc(m, ' '); - if (!err) - err = mnt->mnt_sb->s_op->show_stats(m, mnt); - } - - seq_putc(m, '\n'); - return err; -} - -const struct seq_operations mountstats_op = { - .start = m_start, - .next = m_next, - .stop = m_stop, - .show = show_vfsstat, + .show = m_show, }; #endif /* CONFIG_PROC_FS */ diff --git a/fs/proc/base.c b/fs/proc/base.c index 851ba3dcdc29..07446b55b7cc 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -631,120 +631,6 @@ static const struct inode_operations proc_def_inode_operations = { .setattr = proc_setattr, }; -static int mounts_open_common(struct inode *inode, struct file *file, - const struct seq_operations *op) -{ - struct task_struct *task = get_proc_task(inode); - struct nsproxy *nsp; - struct mnt_namespace *ns = NULL; - struct path root; - struct proc_mounts *p; - int ret = -EINVAL; - - if (task) { - rcu_read_lock(); - nsp = task_nsproxy(task); - if (nsp) { - ns = nsp->mnt_ns; - if (ns) - get_mnt_ns(ns); - } - rcu_read_unlock(); - if (ns && get_task_root(task, &root) == 0) - ret = 0; - put_task_struct(task); - } - - if (!ns) - goto err; - if (ret) - goto err_put_ns; - - ret = -ENOMEM; - p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL); - if (!p) - goto err_put_path; - - file->private_data = &p->m; - ret = seq_open(file, op); - if (ret) - goto err_free; - - p->m.private = p; - p->ns = ns; - p->root = root; - p->m.poll_event = ns->event; - - return 0; - - err_free: - kfree(p); - err_put_path: - path_put(&root); - err_put_ns: - put_mnt_ns(ns); - err: - return ret; -} - -static int mounts_release(struct inode *inode, struct file *file) -{ - struct proc_mounts *p = file->private_data; - path_put(&p->root); - put_mnt_ns(p->ns); - return seq_release(inode, file); -} - -static unsigned mounts_poll(struct file *file, poll_table *wait) -{ - struct proc_mounts *p = file->private_data; - unsigned res = POLLIN | POLLRDNORM; - - poll_wait(file, &p->ns->poll, wait); - if (mnt_had_events(p)) - res |= POLLERR | POLLPRI; - - return res; -} - -static int mounts_open(struct inode *inode, struct file *file) -{ - return mounts_open_common(inode, file, &mounts_op); -} - -static const struct file_operations proc_mounts_operations = { - .open = mounts_open, - .read = seq_read, - .llseek = seq_lseek, - .release = mounts_release, - .poll = mounts_poll, -}; - -static int mountinfo_open(struct inode *inode, struct file *file) -{ - return mounts_open_common(inode, file, &mountinfo_op); -} - -static const struct file_operations proc_mountinfo_operations = { - .open = mountinfo_open, - .read = seq_read, - .llseek = seq_lseek, - .release = mounts_release, - .poll = mounts_poll, -}; - -static int mountstats_open(struct inode *inode, struct file *file) -{ - return mounts_open_common(inode, file, &mountstats_op); -} - -static const struct file_operations proc_mountstats_operations = { - .open = mountstats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = mounts_release, -}; - #define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */ static ssize_t proc_info_read(struct file * file, char __user * buf, diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c new file mode 100644 index 000000000000..9dcd9543ca12 --- /dev/null +++ b/fs/proc_namespace.c @@ -0,0 +1,331 @@ +/* + * fs/proc_namespace.c - handling of /proc//{mounts,mountinfo,mountstats} + * + * In fact, that's a piece of procfs; it's *almost* isolated from + * the rest of fs/proc, but has rather close relationships with + * fs/namespace.c, thus here instead of fs/proc + * + */ +#include +#include +#include +#include +#include "proc/internal.h" /* only for get_proc_task() in ->open() */ + +#include "pnode.h" +#include "internal.h" + +static unsigned mounts_poll(struct file *file, poll_table *wait) +{ + struct proc_mounts *p = file->private_data; + struct mnt_namespace *ns = p->ns; + unsigned res = POLLIN | POLLRDNORM; + + poll_wait(file, &p->ns->poll, wait); + + br_read_lock(vfsmount_lock); + if (p->m.poll_event != ns->event) { + p->m.poll_event = ns->event; + res |= POLLERR | POLLPRI; + } + br_read_unlock(vfsmount_lock); + + return res; +} + +struct proc_fs_info { + int flag; + const char *str; +}; + +static int show_sb_opts(struct seq_file *m, struct super_block *sb) +{ + static const struct proc_fs_info fs_info[] = { + { MS_SYNCHRONOUS, ",sync" }, + { MS_DIRSYNC, ",dirsync" }, + { MS_MANDLOCK, ",mand" }, + { 0, NULL } + }; + const struct proc_fs_info *fs_infop; + + for (fs_infop = fs_info; fs_infop->flag; fs_infop++) { + if (sb->s_flags & fs_infop->flag) + seq_puts(m, fs_infop->str); + } + + return security_sb_show_options(m, sb); +} + +static void show_mnt_opts(struct seq_file *m, struct vfsmount *mnt) +{ + static const struct proc_fs_info mnt_info[] = { + { MNT_NOSUID, ",nosuid" }, + { MNT_NODEV, ",nodev" }, + { MNT_NOEXEC, ",noexec" }, + { MNT_NOATIME, ",noatime" }, + { MNT_NODIRATIME, ",nodiratime" }, + { MNT_RELATIME, ",relatime" }, + { 0, NULL } + }; + const struct proc_fs_info *fs_infop; + + for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) { + if (mnt->mnt_flags & fs_infop->flag) + seq_puts(m, fs_infop->str); + } +} + +static inline void mangle(struct seq_file *m, const char *s) +{ + seq_escape(m, s, " \t\n\\"); +} + +static void show_type(struct seq_file *m, struct super_block *sb) +{ + mangle(m, sb->s_type->name); + if (sb->s_subtype && sb->s_subtype[0]) { + seq_putc(m, '.'); + mangle(m, sb->s_subtype); + } +} + +static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt) +{ + struct mount *r = real_mount(mnt); + int err = 0; + struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; + + if (mnt->mnt_sb->s_op->show_devname) { + err = mnt->mnt_sb->s_op->show_devname(m, mnt); + if (err) + goto out; + } else { + mangle(m, r->mnt_devname ? r->mnt_devname : "none"); + } + seq_putc(m, ' '); + seq_path(m, &mnt_path, " \t\n\\"); + seq_putc(m, ' '); + show_type(m, mnt->mnt_sb); + seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw"); + err = show_sb_opts(m, mnt->mnt_sb); + if (err) + goto out; + show_mnt_opts(m, mnt); + if (mnt->mnt_sb->s_op->show_options) + err = mnt->mnt_sb->s_op->show_options(m, mnt); + seq_puts(m, " 0 0\n"); +out: + return err; +} + +static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) +{ + struct proc_mounts *p = m->private; + struct mount *r = real_mount(mnt); + struct super_block *sb = mnt->mnt_sb; + struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; + struct path root = p->root; + int err = 0; + + seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id, + MAJOR(sb->s_dev), MINOR(sb->s_dev)); + if (sb->s_op->show_path) + err = sb->s_op->show_path(m, mnt); + else + seq_dentry(m, mnt->mnt_root, " \t\n\\"); + if (err) + goto out; + seq_putc(m, ' '); + + /* mountpoints outside of chroot jail will give SEQ_SKIP on this */ + err = seq_path_root(m, &mnt_path, &root, " \t\n\\"); + if (err) + goto out; + + seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw"); + show_mnt_opts(m, mnt); + + /* Tagged fields ("foo:X" or "bar") */ + if (IS_MNT_SHARED(r)) + seq_printf(m, " shared:%i", r->mnt_group_id); + if (IS_MNT_SLAVE(r)) { + int master = r->mnt_master->mnt_group_id; + int dom = get_dominating_id(r, &p->root); + seq_printf(m, " master:%i", master); + if (dom && dom != master) + seq_printf(m, " propagate_from:%i", dom); + } + if (IS_MNT_UNBINDABLE(r)) + seq_puts(m, " unbindable"); + + /* Filesystem specific data */ + seq_puts(m, " - "); + show_type(m, sb); + seq_putc(m, ' '); + if (sb->s_op->show_devname) + err = sb->s_op->show_devname(m, mnt); + else + mangle(m, r->mnt_devname ? r->mnt_devname : "none"); + if (err) + goto out; + seq_puts(m, sb->s_flags & MS_RDONLY ? " ro" : " rw"); + err = show_sb_opts(m, sb); + if (err) + goto out; + if (sb->s_op->show_options) + err = sb->s_op->show_options(m, mnt); + seq_putc(m, '\n'); +out: + return err; +} + +static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) +{ + struct mount *r = real_mount(mnt); + struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; + int err = 0; + + /* device */ + if (mnt->mnt_sb->s_op->show_devname) { + seq_puts(m, "device "); + err = mnt->mnt_sb->s_op->show_devname(m, mnt); + } else { + if (r->mnt_devname) { + seq_puts(m, "device "); + mangle(m, r->mnt_devname); + } else + seq_puts(m, "no device"); + } + + /* mount point */ + seq_puts(m, " mounted on "); + seq_path(m, &mnt_path, " \t\n\\"); + seq_putc(m, ' '); + + /* file system type */ + seq_puts(m, "with fstype "); + show_type(m, mnt->mnt_sb); + + /* optional statistics */ + if (mnt->mnt_sb->s_op->show_stats) { + seq_putc(m, ' '); + if (!err) + err = mnt->mnt_sb->s_op->show_stats(m, mnt); + } + + seq_putc(m, '\n'); + return err; +} + +static int mounts_open_common(struct inode *inode, struct file *file, + int (*show)(struct seq_file *, struct vfsmount *)) +{ + struct task_struct *task = get_proc_task(inode); + struct nsproxy *nsp; + struct mnt_namespace *ns = NULL; + struct path root; + struct proc_mounts *p; + int ret = -EINVAL; + + if (!task) + goto err; + + rcu_read_lock(); + nsp = task_nsproxy(task); + if (!nsp) { + rcu_read_unlock(); + put_task_struct(task); + goto err; + } + ns = nsp->mnt_ns; + if (!ns) { + rcu_read_unlock(); + put_task_struct(task); + goto err; + } + get_mnt_ns(ns); + rcu_read_unlock(); + task_lock(task); + if (!task->fs) { + task_unlock(task); + put_task_struct(task); + ret = -ENOENT; + goto err_put_ns; + } + get_fs_root(task->fs, &root); + task_unlock(task); + put_task_struct(task); + + ret = -ENOMEM; + p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL); + if (!p) + goto err_put_path; + + file->private_data = &p->m; + ret = seq_open(file, &mounts_op); + if (ret) + goto err_free; + + p->m.private = p; + p->ns = ns; + p->root = root; + p->m.poll_event = ns->event; + p->show = show; + + return 0; + + err_free: + kfree(p); + err_put_path: + path_put(&root); + err_put_ns: + put_mnt_ns(ns); + err: + return ret; +} + +static int mounts_release(struct inode *inode, struct file *file) +{ + struct proc_mounts *p = file->private_data; + path_put(&p->root); + put_mnt_ns(p->ns); + return seq_release(inode, file); +} + +static int mounts_open(struct inode *inode, struct file *file) +{ + return mounts_open_common(inode, file, show_vfsmnt); +} + +static int mountinfo_open(struct inode *inode, struct file *file) +{ + return mounts_open_common(inode, file, show_mountinfo); +} + +static int mountstats_open(struct inode *inode, struct file *file) +{ + return mounts_open_common(inode, file, show_vfsstat); +} + +const struct file_operations proc_mounts_operations = { + .open = mounts_open, + .read = seq_read, + .llseek = seq_lseek, + .release = mounts_release, + .poll = mounts_poll, +}; + +const struct file_operations proc_mountinfo_operations = { + .open = mountinfo_open, + .read = seq_read, + .llseek = seq_lseek, + .release = mounts_release, + .poll = mounts_poll, +}; + +const struct file_operations proc_mountstats_operations = { + .open = mountstats_open, + .read = seq_read, + .llseek = seq_lseek, + .release = mounts_release, +}; diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h index e87ec01aac9d..5a8e3903d770 100644 --- a/include/linux/mnt_namespace.h +++ b/include/linux/mnt_namespace.h @@ -2,38 +2,16 @@ #define _NAMESPACE_H_ #ifdef __KERNEL__ -#include -#include -#include - -struct mnt_namespace { - atomic_t count; - struct vfsmount * root; - struct list_head list; - wait_queue_head_t poll; - int event; -}; - -struct proc_mounts { - struct seq_file m; /* must be the first element */ - struct mnt_namespace *ns; - struct path root; -}; - +struct mnt_namespace; struct fs_struct; extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, struct fs_struct *); extern void put_mnt_ns(struct mnt_namespace *ns); -static inline void get_mnt_ns(struct mnt_namespace *ns) -{ - atomic_inc(&ns->count); -} -extern const struct seq_operations mounts_op; -extern const struct seq_operations mountinfo_op; -extern const struct seq_operations mountstats_op; -extern int mnt_had_events(struct proc_mounts *); +extern const struct file_operations proc_mounts_operations; +extern const struct file_operations proc_mountinfo_operations; +extern const struct file_operations proc_mountstats_operations; #endif #endif From be08d6d260b6e7eb346162a1081cdf5f94fda569 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 6 Dec 2011 13:32:36 -0500 Subject: [PATCH 153/165] switch mnt_namespace ->root to struct mount Signed-off-by: Al Viro --- fs/mount.h | 2 +- fs/namespace.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index c6e99e03350a..0921b51e27e2 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -4,7 +4,7 @@ struct mnt_namespace { atomic_t count; - struct vfsmount * root; + struct mount * root; struct list_head list; wait_queue_head_t poll; int event; diff --git a/fs/namespace.c b/fs/namespace.c index 21a8261256dd..d4016f911ef9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2197,7 +2197,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, struct mnt_namespace *new_ns; struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; struct mount *p, *q; - struct mount *old = real_mount(mnt_ns->root); + struct mount *old = mnt_ns->root; struct mount *new; new_ns = alloc_mnt_ns(); @@ -2212,7 +2212,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, kfree(new_ns); return ERR_PTR(-ENOMEM); } - new_ns->root = &new->mnt; + new_ns->root = new; br_write_lock(vfsmount_lock); list_add_tail(&new_ns->list, &new->mnt_list); br_write_unlock(vfsmount_lock); @@ -2282,7 +2282,7 @@ static struct mnt_namespace *create_mnt_ns(struct vfsmount *m) struct mount *mnt = real_mount(m); mnt->mnt_ns = new_ns; __mnt_make_longterm(mnt); - new_ns->root = m; + new_ns->root = mnt; list_add(&new_ns->list, &mnt->mnt_list); } else { mntput(m); @@ -2512,8 +2512,8 @@ static void __init init_mount_tree(void) init_task.nsproxy->mnt_ns = ns; get_mnt_ns(ns); - root.mnt = ns->root; - root.dentry = ns->root->mnt_root; + root.mnt = mnt; + root.dentry = mnt->mnt_root; set_fs_pwd(current->fs, &root); set_fs_root(current->fs, &root); @@ -2560,7 +2560,7 @@ void put_mnt_ns(struct mnt_namespace *ns) return; down_write(&namespace_sem); br_write_lock(vfsmount_lock); - umount_tree(real_mount(ns->root), 0, &umount_list); + umount_tree(ns->root, 0, &umount_list); br_write_unlock(vfsmount_lock); up_write(&namespace_sem); release_mounts(&umount_list); From d10577a8d86a0c735488d66d32289a6d66bcfa20 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 7 Dec 2011 13:06:11 -0500 Subject: [PATCH 154/165] vfs: trim includes a bit [folded fix for missing magic.h from Tetsuo Handa] Signed-off-by: Al Viro --- fs/namespace.c | 25 ++++++------------------- fs/proc/namespaces.c | 1 - security/tomoyo/realpath.c | 1 + 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index d4016f911ef9..773435ca300d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -9,30 +9,17 @@ */ #include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include #include #include -#include #include -#include -#include -#include #include -#include -#include -#include -#include +#include /* acct_auto_close_mnt */ +#include /* init_rootfs */ +#include /* get_fs_root et.al. */ +#include /* fsnotify_vfsmount_delete */ +#include #include "pnode.h" #include "internal.h" 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 @@ #include #include #include -#include #include #include #include "internal.h" diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index 2cb5db589c9d..80a09c37cac8 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c @@ -5,6 +5,7 @@ */ #include "common.h" +#include /** * tomoyo_encode2 - Encode binary string to ascii string. From d8c9584ea2a92879f471fd3a2be3af6c534fb035 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 7 Dec 2011 18:16:57 -0500 Subject: [PATCH 155/165] vfs: prefer ->dentry->d_sb to ->mnt->mnt_sb Signed-off-by: Al Viro --- fs/autofs4/dev-ioctl.c | 10 +++++----- fs/binfmt_misc.c | 6 +++--- fs/ext3/super.c | 2 +- fs/ext4/super.c | 2 +- fs/fhandle.c | 4 ++-- fs/lockd/svcsubs.c | 2 +- fs/nfsd/nfsctl.c | 2 +- fs/quota/dquot.c | 2 +- fs/reiserfs/super.c | 2 +- fs/sysv/itree.c | 2 +- init/do_mounts.c | 10 ++++++---- kernel/acct.c | 2 +- security/selinux/hooks.c | 2 +- security/smack/smack_lsm.c | 4 ++-- 14 files changed, 27 insertions(+), 25 deletions(-) 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, return err; err = -ENOENT; while (path.dentry == path.mnt->mnt_root) { - if (path.mnt->mnt_sb->s_magic == AUTOFS_SUPER_MAGIC) { + if (path.dentry->d_sb->s_magic == AUTOFS_SUPER_MAGIC) { if (test(&path, data)) { path_get(&path); if (!err) /* already found some */ @@ -212,7 +212,7 @@ static int find_autofs_mount(const char *pathname, static int test_by_dev(struct path *path, void *p) { - return path->mnt->mnt_sb->s_dev == *(dev_t *)p; + return path->dentry->d_sb->s_dev == *(dev_t *)p; } static int test_by_type(struct path *path, void *p) @@ -538,11 +538,11 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp, err = find_autofs_mount(name, &path, test_by_type, &type); if (err) goto out; - devid = new_encode_dev(path.mnt->mnt_sb->s_dev); + devid = new_encode_dev(path.dentry->d_sb->s_dev); err = 0; if (path.mnt->mnt_root == path.dentry) { err = 1; - magic = path.mnt->mnt_sb->s_magic; + magic = path.dentry->d_sb->s_magic; } } else { dev_t dev = sbi->sb->s_dev; @@ -556,7 +556,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp, err = have_submounts(path.dentry); if (follow_down_one(&path)) - magic = path.mnt->mnt_sb->s_magic; + magic = path.dentry->d_sb->s_magic; } param->ismountpoint.out.devid = devid; 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, break; case 2: set_bit(Enabled, &e->flags); break; - case 3: root = dget(file->f_path.mnt->mnt_sb->s_root); + case 3: root = dget(file->f_path.dentry->d_sb->s_root); mutex_lock(&root->d_inode->i_mutex); kill_node(e); @@ -587,7 +587,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, Node *e; struct inode *inode; struct dentry *root, *dentry; - struct super_block *sb = file->f_path.mnt->mnt_sb; + struct super_block *sb = file->f_path.dentry->d_sb; int err = 0; e = create_entry(buffer, count); @@ -666,7 +666,7 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer, switch (res) { case 1: enabled = 0; break; case 2: enabled = 1; break; - case 3: root = dget(file->f_path.mnt->mnt_sb->s_root); + case 3: root = dget(file->f_path.dentry->d_sb->s_root); mutex_lock(&root->d_inode->i_mutex); while (!list_empty(&entries)) diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 668c931b2214..7e8944ee67c6 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -2909,7 +2909,7 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id, return -EINVAL; /* Quotafile not on the same filesystem? */ - if (path->mnt->mnt_sb != sb) + if (path->dentry->d_sb != sb) return -EXDEV; /* Journaling quota? */ if (EXT3_SB(sb)->s_qf_names[type]) { diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2a1a9e63cffa..b739b210a616 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4781,7 +4781,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, return -EINVAL; /* Quotafile not on the same filesystem? */ - if (path->mnt->mnt_sb != sb) + if (path->dentry->d_sb != sb) return -EXDEV; /* Journaling quota? */ if (EXT4_SB(sb)->s_qf_names[type]) { diff --git a/fs/fhandle.c b/fs/fhandle.c index 5eff7116951e..a48e4a139be1 100644 --- a/fs/fhandle.c +++ b/fs/fhandle.c @@ -25,8 +25,8 @@ static long do_sys_name_to_handle(struct path *path, * We need t make sure wether the file system * support decoding of the file handle */ - if (!path->mnt->mnt_sb->s_export_op || - !path->mnt->mnt_sb->s_export_op->fh_to_dentry) + if (!path->dentry->d_sb->s_export_op || + !path->dentry->d_sb->s_export_op->fh_to_dentry) return -EOPNOTSUPP; if (copy_from_user(&f_handle, ufh, sizeof(struct file_handle))) 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) { struct super_block *sb = datap; - return sb == file->f_file->f_path.mnt->mnt_sb; + return sb == file->f_file->f_path.dentry->d_sb; } /** 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) * 2. Is that directory a mount point, or * 3. Is that directory the root of an exported file system? */ - error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb); + error = nlmsvc_unlock_all_by_sb(path.dentry->d_sb); path_put(&path); return error; diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 5d81e92daf83..5ec59b20cf76 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2198,7 +2198,7 @@ int dquot_quota_on(struct super_block *sb, int type, int format_id, if (error) return error; /* Quota file not on the same filesystem? */ - if (path->mnt->mnt_sb != sb) + if (path->dentry->d_sb != sb) error = -EXDEV; else error = vfs_load_quota_inode(path->dentry->d_inode, type, diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 5a4cae7efc43..1abffa451529 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -2058,7 +2058,7 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, return -EINVAL; /* Quotafile not on the same filesystem? */ - if (path->mnt->mnt_sb != sb) { + if (path->dentry->d_sb != sb) { err = -EXDEV; goto out; } 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) int sysv_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { - struct super_block *s = mnt->mnt_sb; + struct super_block *s = dentry->d_sb; generic_fillattr(dentry->d_inode, stat); stat->blocks = (s->s_blocksize / 512) * sysv_nblocks(s, stat->size); stat->blksize = s->s_blocksize; diff --git a/init/do_mounts.c b/init/do_mounts.c index 0f6e1d985a3b..b2eee02e0f83 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -325,17 +325,19 @@ static void __init get_fs_names(char *page) static int __init do_mount_root(char *name, char *fs, int flags, void *data) { + struct super_block *s; int err = sys_mount(name, "/root", fs, flags, data); if (err) return err; sys_chdir((const char __user __force *)"/root"); - ROOT_DEV = current->fs->pwd.mnt->mnt_sb->s_dev; + s = current->fs->pwd.dentry->d_sb; + ROOT_DEV = s->s_dev; printk(KERN_INFO "VFS: Mounted root (%s filesystem)%s on device %u:%u.\n", - current->fs->pwd.mnt->mnt_sb->s_type->name, - current->fs->pwd.mnt->mnt_sb->s_flags & MS_RDONLY ? - " readonly" : "", MAJOR(ROOT_DEV), MINOR(ROOT_DEV)); + s->s_type->name, + s->s_flags & MS_RDONLY ? " readonly" : "", + MAJOR(ROOT_DEV), MINOR(ROOT_DEV)); return 0; } diff --git a/kernel/acct.c b/kernel/acct.c index 8cba12429d82..9663eb8058f9 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -315,7 +315,7 @@ void acct_auto_close(struct super_block *sb) spin_lock(&acct_lock); restart: list_for_each_entry(acct, &acct_list, list) - if (acct->file && acct->file->f_path.mnt->mnt_sb == sb) { + if (acct->file && acct->file->f_path.dentry->d_sb == sb) { acct_file_reopen(acct, NULL, NULL); goto restart; } diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 4def4d92aaee..57546cfb18ec 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2507,7 +2507,7 @@ static int selinux_mount(char *dev_name, const struct cred *cred = current_cred(); if (flags & MS_REMOUNT) - return superblock_has_perm(cred, path->mnt->mnt_sb, + return superblock_has_perm(cred, path->dentry->d_sb, FILESYSTEM__REMOUNT, NULL); else return path_has_perm(cred, path, FILE__MOUNTON); diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 7db62b48eb42..e8af5b0ba80f 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -406,7 +406,7 @@ static int smack_sb_statfs(struct dentry *dentry) static int smack_sb_mount(char *dev_name, struct path *path, char *type, unsigned long flags, void *data) { - struct superblock_smack *sbp = path->mnt->mnt_sb->s_security; + struct superblock_smack *sbp = path->dentry->d_sb->s_security; struct smk_audit_info ad; smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); @@ -435,7 +435,7 @@ static int smack_sb_umount(struct vfsmount *mnt, int flags) smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); smk_ad_setfield_u_fs_path(&ad, path); - sbp = mnt->mnt_sb->s_security; + sbp = path.dentry->d_sb->s_security; return smk_curacc(sbp->smk_floor, MAY_WRITE, &ad); } From cdcf116d44e78c7216ba9f8be9af1cdfca7af728 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Dec 2011 10:51:53 -0500 Subject: [PATCH 156/165] switch security_path_chmod() to struct path * Signed-off-by: Al Viro --- fs/open.c | 2 +- include/linux/security.h | 10 +++------- security/apparmor/lsm.c | 7 +++---- security/capability.c | 3 +-- security/security.c | 7 +++---- security/tomoyo/tomoyo.c | 11 ++++------- 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/fs/open.c b/fs/open.c index 2659f596f4c5..77becc041149 100644 --- a/fs/open.c +++ b/fs/open.c @@ -456,7 +456,7 @@ static int chmod_common(struct path *path, umode_t mode) if (error) return error; mutex_lock(&inode->i_mutex); - error = security_path_chmod(path->dentry, path->mnt, mode); + error = security_path_chmod(path, mode); if (error) goto out_unlock; newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); diff --git a/include/linux/security.h b/include/linux/security.h index 535721cc374a..4298d2dbafa3 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1435,8 +1435,7 @@ struct security_operations { struct dentry *new_dentry); int (*path_rename) (struct path *old_dir, struct dentry *old_dentry, struct path *new_dir, struct dentry *new_dentry); - int (*path_chmod) (struct dentry *dentry, struct vfsmount *mnt, - umode_t mode); + int (*path_chmod) (struct path *path, umode_t mode); int (*path_chown) (struct path *path, uid_t uid, gid_t gid); int (*path_chroot) (struct path *path); #endif @@ -2866,8 +2865,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir, struct dentry *new_dentry); int security_path_rename(struct path *old_dir, struct dentry *old_dentry, struct path *new_dir, struct dentry *new_dentry); -int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - umode_t mode); +int security_path_chmod(struct path *path, umode_t mode); int security_path_chown(struct path *path, uid_t uid, gid_t gid); int security_path_chroot(struct path *path); #else /* CONFIG_SECURITY_PATH */ @@ -2919,9 +2917,7 @@ static inline int security_path_rename(struct path *old_dir, return 0; } -static inline int security_path_chmod(struct dentry *dentry, - struct vfsmount *mnt, - umode_t mode) +static inline int security_path_chmod(struct path *path, umode_t mode) { return 0; } diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index c0a399ec1df9..2c0a0ff41399 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -344,13 +344,12 @@ static int apparmor_path_rename(struct path *old_dir, struct dentry *old_dentry, return error; } -static int apparmor_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - umode_t mode) +static int apparmor_path_chmod(struct path *path, umode_t mode) { - if (!mediated_filesystem(dentry->d_inode)) + if (!mediated_filesystem(path->dentry->d_inode)) return 0; - return common_perm_mnt_dentry(OP_CHMOD, mnt, dentry, AA_MAY_CHMOD); + return common_perm_mnt_dentry(OP_CHMOD, path->mnt, path->dentry, AA_MAY_CHMOD); } static int apparmor_path_chown(struct path *path, uid_t uid, gid_t gid) diff --git a/security/capability.c b/security/capability.c index 156816d451ba..3b5883b7179f 100644 --- a/security/capability.c +++ b/security/capability.c @@ -279,8 +279,7 @@ static int cap_path_truncate(struct path *path) return 0; } -static int cap_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - umode_t mode) +static int cap_path_chmod(struct path *path, umode_t mode) { return 0; } diff --git a/security/security.c b/security/security.c index 151152de1a0a..214502c772ab 100644 --- a/security/security.c +++ b/security/security.c @@ -454,12 +454,11 @@ int security_path_truncate(struct path *path) return security_ops->path_truncate(path); } -int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - umode_t mode) +int security_path_chmod(struct path *path, umode_t mode) { - if (unlikely(IS_PRIVATE(dentry->d_inode))) + if (unlikely(IS_PRIVATE(path->dentry->d_inode))) return 0; - return security_ops->path_chmod(dentry, mnt, mode); + return security_ops->path_chmod(path, mode); } int security_path_chown(struct path *path, uid_t uid, gid_t gid) diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c index 75c956a51e75..620d37c159a3 100644 --- a/security/tomoyo/tomoyo.c +++ b/security/tomoyo/tomoyo.c @@ -353,17 +353,14 @@ static int tomoyo_file_ioctl(struct file *file, unsigned int cmd, /** * tomoyo_path_chmod - Target for security_path_chmod(). * - * @dentry: Pointer to "struct dentry". - * @mnt: Pointer to "struct vfsmount". - * @mode: DAC permission mode. + * @path: Pointer to "struct path". + * @mode: DAC permission mode. * * Returns 0 on success, negative value otherwise. */ -static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt, - umode_t mode) +static int tomoyo_path_chmod(struct path *path, umode_t mode) { - struct path path = { mnt, dentry }; - return tomoyo_path_number_perm(TOMOYO_TYPE_CHMOD, &path, + return tomoyo_path_number_perm(TOMOYO_TYPE_CHMOD, path, mode & S_IALLUGO); } From 64132379d509184425672e0dce1ac0a031e3f2a5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Dec 2011 20:51:13 -0500 Subject: [PATCH 157/165] vfs: switch ->show_stats to struct dentry * Signed-off-by: Al Viro --- drivers/staging/pohmelfs/inode.c | 4 ++-- fs/cifs/cifsfs.c | 2 +- fs/nfs/super.c | 14 +++++++------- fs/proc_namespace.c | 11 ++++++----- include/linux/fs.h | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c index 6c12516826ad..91ec29e112bc 100644 --- a/drivers/staging/pohmelfs/inode.c +++ b/drivers/staging/pohmelfs/inode.c @@ -1759,11 +1759,11 @@ err_out_exit: return err; } -static int pohmelfs_show_stats(struct seq_file *m, struct vfsmount *mnt) +static int pohmelfs_show_stats(struct seq_file *m, struct dentry *root) { struct netfs_state *st; struct pohmelfs_ctl *ctl; - struct pohmelfs_sb *psb = POHMELFS_SB(mnt->mnt_sb); + struct pohmelfs_sb *psb = POHMELFS_SB(root->d_sb); struct pohmelfs_config *c; mutex_lock(&psb->state_lock); diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 5bb961c13c4d..0cb89dc6526c 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -488,7 +488,7 @@ static void cifs_umount_begin(struct super_block *sb) } #ifdef CONFIG_CIFS_STATS2 -static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt) +static int cifs_show_stats(struct seq_file *s, struct dentry *root) { /* BB FIXME */ return 0; diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 0e6dd56a9f1e..dd74d3bc2eaa 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -265,7 +265,7 @@ static int nfs_statfs(struct dentry *, struct kstatfs *); static int nfs_show_options(struct seq_file *, struct vfsmount *); static int nfs_show_devname(struct seq_file *, struct vfsmount *); static int nfs_show_path(struct seq_file *, struct vfsmount *); -static int nfs_show_stats(struct seq_file *, struct vfsmount *); +static int nfs_show_stats(struct seq_file *, struct dentry *); static struct dentry *nfs_fs_mount(struct file_system_type *, int, const char *, void *); static struct dentry *nfs_xdev_mount(struct file_system_type *fs_type, @@ -785,10 +785,10 @@ static int nfs_show_path(struct seq_file *m, struct vfsmount *mnt) /* * Present statistical information for this VFS mountpoint */ -static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) +static int nfs_show_stats(struct seq_file *m, struct dentry *root) { int i, cpu; - struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); + struct nfs_server *nfss = NFS_SB(root->d_sb); struct rpc_auth *auth = nfss->client->cl_auth; struct nfs_iostats totals = { }; @@ -798,10 +798,10 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) * Display all mount option settings */ seq_printf(m, "\n\topts:\t"); - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw"); - seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : ""); - seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : ""); - seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : ""); + seq_puts(m, root->d_sb->s_flags & MS_RDONLY ? "ro" : "rw"); + seq_puts(m, root->d_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : ""); + seq_puts(m, root->d_sb->s_flags & MS_NOATIME ? ",noatime" : ""); + seq_puts(m, root->d_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : ""); nfs_show_mount_options(m, nfss, 1); seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ); diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 9dcd9543ca12..61a09a6364ba 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -183,12 +183,13 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) { struct mount *r = real_mount(mnt); struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; + struct super_block *sb = mnt_path.dentry->d_sb; int err = 0; /* device */ - if (mnt->mnt_sb->s_op->show_devname) { + if (sb->s_op->show_devname) { seq_puts(m, "device "); - err = mnt->mnt_sb->s_op->show_devname(m, mnt); + err = sb->s_op->show_devname(m, mnt); } else { if (r->mnt_devname) { seq_puts(m, "device "); @@ -204,13 +205,13 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) /* file system type */ seq_puts(m, "with fstype "); - show_type(m, mnt->mnt_sb); + show_type(m, sb); /* optional statistics */ - if (mnt->mnt_sb->s_op->show_stats) { + if (sb->s_op->show_stats) { seq_putc(m, ' '); if (!err) - err = mnt->mnt_sb->s_op->show_stats(m, mnt); + err = sb->s_op->show_stats(m, mnt_path.dentry); } seq_putc(m, '\n'); diff --git a/include/linux/fs.h b/include/linux/fs.h index 659be7d82617..b2e4b6f639e4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1675,7 +1675,7 @@ struct super_operations { int (*show_options)(struct seq_file *, struct vfsmount *); int (*show_devname)(struct seq_file *, struct vfsmount *); int (*show_path)(struct seq_file *, struct vfsmount *); - int (*show_stats)(struct seq_file *, struct vfsmount *); + int (*show_stats)(struct seq_file *, struct dentry *); #ifdef CONFIG_QUOTA ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); From d861c630e99febe5ce6055290085556c5b714b06 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Dec 2011 21:32:45 -0500 Subject: [PATCH 158/165] vfs: switch ->show_devname() to struct dentry * Signed-off-by: Al Viro --- fs/nfs/super.c | 6 +++--- fs/proc_namespace.c | 17 +++++++++-------- include/linux/fs.h | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index dd74d3bc2eaa..6e6faa17bd38 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -263,7 +263,7 @@ static match_table_t nfs_local_lock_tokens = { static void nfs_umount_begin(struct super_block *); static int nfs_statfs(struct dentry *, struct kstatfs *); static int nfs_show_options(struct seq_file *, struct vfsmount *); -static int nfs_show_devname(struct seq_file *, struct vfsmount *); +static int nfs_show_devname(struct seq_file *, struct dentry *); static int nfs_show_path(struct seq_file *, struct vfsmount *); static int nfs_show_stats(struct seq_file *, struct dentry *); static struct dentry *nfs_fs_mount(struct file_system_type *, @@ -760,14 +760,14 @@ static void show_pnfs(struct seq_file *m, struct nfs_server *server) {} #endif #endif -static int nfs_show_devname(struct seq_file *m, struct vfsmount *mnt) +static int nfs_show_devname(struct seq_file *m, struct dentry *root) { char *page = (char *) __get_free_page(GFP_KERNEL); char *devname, *dummy; int err = 0; if (!page) return -ENOMEM; - devname = nfs_path(&dummy, mnt->mnt_root, page, PAGE_SIZE); + devname = nfs_path(&dummy, root, page, PAGE_SIZE); if (IS_ERR(devname)) err = PTR_ERR(devname); else diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 61a09a6364ba..6d4583ddbeda 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -94,9 +94,10 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt) struct mount *r = real_mount(mnt); int err = 0; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; + struct super_block *sb = mnt_path.dentry->d_sb; - if (mnt->mnt_sb->s_op->show_devname) { - err = mnt->mnt_sb->s_op->show_devname(m, mnt); + if (sb->s_op->show_devname) { + err = sb->s_op->show_devname(m, mnt_path.dentry); if (err) goto out; } else { @@ -105,14 +106,14 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt) seq_putc(m, ' '); seq_path(m, &mnt_path, " \t\n\\"); seq_putc(m, ' '); - show_type(m, mnt->mnt_sb); + show_type(m, sb); seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw"); - err = show_sb_opts(m, mnt->mnt_sb); + err = show_sb_opts(m, sb); if (err) goto out; show_mnt_opts(m, mnt); - if (mnt->mnt_sb->s_op->show_options) - err = mnt->mnt_sb->s_op->show_options(m, mnt); + if (sb->s_op->show_options) + err = sb->s_op->show_options(m, mnt); seq_puts(m, " 0 0\n"); out: return err; @@ -163,7 +164,7 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) show_type(m, sb); seq_putc(m, ' '); if (sb->s_op->show_devname) - err = sb->s_op->show_devname(m, mnt); + err = sb->s_op->show_devname(m, mnt->mnt_root); else mangle(m, r->mnt_devname ? r->mnt_devname : "none"); if (err) @@ -189,7 +190,7 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) /* device */ if (sb->s_op->show_devname) { seq_puts(m, "device "); - err = sb->s_op->show_devname(m, mnt); + err = sb->s_op->show_devname(m, mnt_path.dentry); } else { if (r->mnt_devname) { seq_puts(m, "device "); diff --git a/include/linux/fs.h b/include/linux/fs.h index b2e4b6f639e4..a8dff43d1b9d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1673,7 +1673,7 @@ struct super_operations { void (*umount_begin) (struct super_block *); int (*show_options)(struct seq_file *, struct vfsmount *); - int (*show_devname)(struct seq_file *, struct vfsmount *); + int (*show_devname)(struct seq_file *, struct dentry *); int (*show_path)(struct seq_file *, struct vfsmount *); int (*show_stats)(struct seq_file *, struct dentry *); #ifdef CONFIG_QUOTA From a6322de67b58a00e3a783ad9c87c2a11b2d67b47 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Dec 2011 21:37:57 -0500 Subject: [PATCH 159/165] vfs: switch ->show_path() to struct dentry * Signed-off-by: Al Viro --- fs/nfs/super.c | 4 ++-- fs/proc_namespace.c | 2 +- include/linux/fs.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 6e6faa17bd38..02c693c77ab7 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -264,7 +264,7 @@ static void nfs_umount_begin(struct super_block *); static int nfs_statfs(struct dentry *, struct kstatfs *); static int nfs_show_options(struct seq_file *, struct vfsmount *); static int nfs_show_devname(struct seq_file *, struct dentry *); -static int nfs_show_path(struct seq_file *, struct vfsmount *); +static int nfs_show_path(struct seq_file *, struct dentry *); static int nfs_show_stats(struct seq_file *, struct dentry *); static struct dentry *nfs_fs_mount(struct file_system_type *, int, const char *, void *); @@ -776,7 +776,7 @@ static int nfs_show_devname(struct seq_file *m, struct dentry *root) return err; } -static int nfs_show_path(struct seq_file *m, struct vfsmount *mnt) +static int nfs_show_path(struct seq_file *m, struct dentry *dentry) { seq_puts(m, "/"); return 0; diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 6d4583ddbeda..8f8304b3f98a 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -131,7 +131,7 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id, MAJOR(sb->s_dev), MINOR(sb->s_dev)); if (sb->s_op->show_path) - err = sb->s_op->show_path(m, mnt); + err = sb->s_op->show_path(m, mnt->mnt_root); else seq_dentry(m, mnt->mnt_root, " \t\n\\"); if (err) diff --git a/include/linux/fs.h b/include/linux/fs.h index a8dff43d1b9d..13721b073407 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1674,7 +1674,7 @@ struct super_operations { int (*show_options)(struct seq_file *, struct vfsmount *); int (*show_devname)(struct seq_file *, struct dentry *); - int (*show_path)(struct seq_file *, struct vfsmount *); + int (*show_path)(struct seq_file *, struct dentry *); int (*show_stats)(struct seq_file *, struct dentry *); #ifdef CONFIG_QUOTA ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); From 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Dec 2011 21:32:45 -0500 Subject: [PATCH 160/165] vfs: switch ->show_options() to struct dentry * Signed-off-by: Al Viro --- Documentation/filesystems/Locking | 2 +- Documentation/filesystems/vfs.txt | 2 +- arch/s390/hypfs/inode.c | 4 ++-- drivers/staging/pohmelfs/inode.c | 4 ++-- drivers/usb/core/inode.c | 2 +- fs/adfs/super.c | 4 ++-- fs/autofs4/inode.c | 6 +++--- fs/btrfs/super.c | 4 ++-- fs/ceph/super.c | 6 +++--- fs/cifs/cifsfs.c | 6 +++--- fs/devpts/inode.c | 4 ++-- fs/ecryptfs/super.c | 4 ++-- fs/ext2/super.c | 4 ++-- fs/ext3/super.c | 4 ++-- fs/ext4/super.c | 4 ++-- fs/fat/inode.c | 6 +++--- fs/fuse/inode.c | 10 +++++----- fs/gfs2/super.c | 8 ++++---- fs/hfs/super.c | 4 ++-- fs/hfsplus/hfsplus_fs.h | 2 +- fs/hfsplus/options.c | 4 ++-- fs/hostfs/hostfs_kern.c | 4 ++-- fs/jffs2/super.c | 4 ++-- fs/jfs/super.c | 4 ++-- fs/namespace.c | 4 ++-- fs/ncpfs/inode.c | 6 +++--- fs/nfs/super.c | 6 +++--- fs/nilfs2/super.c | 6 +++--- fs/ntfs/inode.c | 8 ++++---- fs/ntfs/inode.h | 2 +- fs/ocfs2/super.c | 9 ++++----- fs/proc_namespace.c | 4 ++-- fs/ubifs/super.c | 4 ++-- fs/udf/super.c | 6 +++--- fs/ufs/super.c | 4 ++-- fs/xfs/xfs_super.c | 4 ++-- include/linux/fs.h | 4 ++-- kernel/cgroup.c | 4 ++-- mm/shmem.c | 4 ++-- 39 files changed, 90 insertions(+), 91 deletions(-) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 9e9f30b9f46b..4fca82e5276e 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -117,7 +117,7 @@ prototypes: int (*statfs) (struct dentry *, struct kstatfs *); int (*remount_fs) (struct super_block *, int *, char *); void (*umount_begin) (struct super_block *); - int (*show_options)(struct seq_file *, struct vfsmount *); + int (*show_options)(struct seq_file *, struct dentry *); ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 4b9f0d092a79..3d9393b845b8 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -225,7 +225,7 @@ struct super_operations { void (*clear_inode) (struct inode *); void (*umount_begin) (struct super_block *); - int (*show_options)(struct seq_file *, struct vfsmount *); + int (*show_options)(struct seq_file *, struct dentry *); ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 98efd2d6207a..8a2a887478cc 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c @@ -259,9 +259,9 @@ static int hypfs_parse_options(char *options, struct super_block *sb) return 0; } -static int hypfs_show_options(struct seq_file *s, struct vfsmount *mnt) +static int hypfs_show_options(struct seq_file *s, struct dentry *root) { - struct hypfs_sb_info *hypfs_info = mnt->mnt_sb->s_fs_info; + struct hypfs_sb_info *hypfs_info = root->d_sb->s_fs_info; seq_printf(s, ",uid=%u", hypfs_info->uid); seq_printf(s, ",gid=%u", hypfs_info->gid); diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c index 91ec29e112bc..807e3f324113 100644 --- a/drivers/staging/pohmelfs/inode.c +++ b/drivers/staging/pohmelfs/inode.c @@ -1369,9 +1369,9 @@ static int pohmelfs_statfs(struct dentry *dentry, struct kstatfs *buf) return 0; } -static int pohmelfs_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int pohmelfs_show_options(struct seq_file *seq, struct dentry *root) { - struct pohmelfs_sb *psb = POHMELFS_SB(vfs->mnt_sb); + struct pohmelfs_sb *psb = POHMELFS_SB(root->d_sb); seq_printf(seq, ",idx=%u", psb->idx); seq_printf(seq, ",trans_scan_timeout=%u", jiffies_to_msecs(psb->trans_scan_timeout)); diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 2b60af2ce3ba..9e186f3da839 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c @@ -65,7 +65,7 @@ static umode_t devmode = USBFS_DEFAULT_DEVMODE; static umode_t busmode = USBFS_DEFAULT_BUSMODE; static umode_t listmode = USBFS_DEFAULT_LISTMODE; -static int usbfs_show_options(struct seq_file *seq, struct vfsmount *mnt) +static int usbfs_show_options(struct seq_file *seq, struct dentry *root) { if (devuid != 0) seq_printf(seq, ",devuid=%u", devuid); 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) sb->s_fs_info = NULL; } -static int adfs_show_options(struct seq_file *seq, struct vfsmount *mnt) +static int adfs_show_options(struct seq_file *seq, struct dentry *root) { - struct adfs_sb_info *asb = ADFS_SB(mnt->mnt_sb); + struct adfs_sb_info *asb = ADFS_SB(root->d_sb); if (asb->s_uid != 0) seq_printf(seq, ",uid=%u", asb->s_uid); diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index f799efad52a8..2ba44c79d548 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c @@ -70,10 +70,10 @@ out_kill_sb: kill_litter_super(sb); } -static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt) +static int autofs4_show_options(struct seq_file *m, struct dentry *root) { - struct autofs_sb_info *sbi = autofs4_sbi(mnt->mnt_sb); - struct inode *root_inode = mnt->mnt_sb->s_root->d_inode; + struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb); + struct inode *root_inode = root->d_sb->s_root->d_inode; if (!sbi) return 0; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index dc62d3cc68fd..ae488aa1966a 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -661,9 +661,9 @@ int btrfs_sync_fs(struct super_block *sb, int wait) return ret; } -static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) { - struct btrfs_root *root = btrfs_sb(vfs->mnt_sb); + struct btrfs_root *root = btrfs_sb(dentry->d_sb); struct btrfs_fs_info *info = root->fs_info; char *compress_type; 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: /** * ceph_show_options - Show mount options in /proc/mounts * @m: seq_file to write to - * @mnt: mount descriptor + * @root: root of that (sub)tree */ -static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt) +static int ceph_show_options(struct seq_file *m, struct dentry *root) { - struct ceph_fs_client *fsc = ceph_sb_to_client(mnt->mnt_sb); + struct ceph_fs_client *fsc = ceph_sb_to_client(root->d_sb); struct ceph_mount_options *fsopt = fsc->mount_options; struct ceph_options *opt = fsc->client->options; diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 0cb89dc6526c..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) * ones are. */ static int -cifs_show_options(struct seq_file *s, struct vfsmount *m) +cifs_show_options(struct seq_file *s, struct dentry *root) { - struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb); + struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb); struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); struct sockaddr *srcaddr; srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; @@ -430,7 +430,7 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) seq_printf(s, ",cifsacl"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) seq_printf(s, ",dynperm"); - if (m->mnt_sb->s_flags & MS_POSIXACL) + if (root->d_sb->s_flags & MS_POSIXACL) seq_printf(s, ",acl"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) seq_printf(s, ",mfsymlinks"); 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) return err; } -static int devpts_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int devpts_show_options(struct seq_file *seq, struct dentry *root) { - struct pts_fs_info *fsi = DEVPTS_SB(vfs->mnt_sb); + struct pts_fs_info *fsi = DEVPTS_SB(root->d_sb); struct pts_mount_opts *opts = &fsi->mount_opts; if (opts->setuid) diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c index da485f0b4d1e..9df7fd6e0c39 100644 --- a/fs/ecryptfs/super.c +++ b/fs/ecryptfs/super.c @@ -131,9 +131,9 @@ static void ecryptfs_evict_inode(struct inode *inode) * Prints the mount options for a given superblock. * Returns zero; does not fail. */ -static int ecryptfs_show_options(struct seq_file *m, struct vfsmount *mnt) +static int ecryptfs_show_options(struct seq_file *m, struct dentry *root) { - struct super_block *sb = mnt->mnt_sb; + struct super_block *sb = root->d_sb; struct ecryptfs_mount_crypt_stat *mount_crypt_stat = &ecryptfs_superblock_to_private(sb)->mount_crypt_stat; struct ecryptfs_global_auth_tok *walker; diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 67b5e752ec9d..9b403f064ce0 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -210,9 +210,9 @@ static void destroy_inodecache(void) kmem_cache_destroy(ext2_inode_cachep); } -static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int ext2_show_options(struct seq_file *seq, struct dentry *root) { - struct super_block *sb = vfs->mnt_sb; + struct super_block *sb = root->d_sb; struct ext2_sb_info *sbi = EXT2_SB(sb); struct ext2_super_block *es = sbi->s_es; unsigned long def_mount_opts; diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 7e8944ee67c6..3a10b884e1be 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -610,9 +610,9 @@ static char *data_mode_string(unsigned long mode) * - it's set to a non-default value OR * - if the per-sb default is different from the global default */ -static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int ext3_show_options(struct seq_file *seq, struct dentry *root) { - struct super_block *sb = vfs->mnt_sb; + struct super_block *sb = root->d_sb; struct ext3_sb_info *sbi = EXT3_SB(sb); struct ext3_super_block *es = sbi->s_es; unsigned long def_mount_opts; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index b739b210a616..6733b3736b3b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1032,11 +1032,11 @@ static inline void ext4_show_quota_options(struct seq_file *seq, * - it's set to a non-default value OR * - if the per-sb default is different from the global default */ -static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int ext4_show_options(struct seq_file *seq, struct dentry *root) { int def_errors; unsigned long def_mount_opts; - struct super_block *sb = vfs->mnt_sb; + struct super_block *sb = root->d_sb; struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_super_block *es = sbi->s_es; diff --git a/fs/fat/inode.c b/fs/fat/inode.c index ef44e5f98ced..7873797cc76a 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -671,7 +671,7 @@ int fat_sync_inode(struct inode *inode) EXPORT_SYMBOL_GPL(fat_sync_inode); -static int fat_show_options(struct seq_file *m, struct vfsmount *mnt); +static int fat_show_options(struct seq_file *m, struct dentry *root); static const struct super_operations fat_sops = { .alloc_inode = fat_alloc_inode, .destroy_inode = fat_destroy_inode, @@ -810,9 +810,9 @@ static const struct export_operations fat_export_ops = { .get_parent = fat_get_parent, }; -static int fat_show_options(struct seq_file *m, struct vfsmount *mnt) +static int fat_show_options(struct seq_file *m, struct dentry *root) { - struct msdos_sb_info *sbi = MSDOS_SB(mnt->mnt_sb); + struct msdos_sb_info *sbi = MSDOS_SB(root->d_sb); struct fat_mount_options *opts = &sbi->options; int isvfat = opts->isvfat; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 3d3622a1ceac..64cf8d07393e 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -497,9 +497,10 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev) return 1; } -static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt) +static int fuse_show_options(struct seq_file *m, struct dentry *root) { - struct fuse_conn *fc = get_fuse_conn_super(mnt->mnt_sb); + struct super_block *sb = root->d_sb; + struct fuse_conn *fc = get_fuse_conn_super(sb); seq_printf(m, ",user_id=%u", fc->user_id); seq_printf(m, ",group_id=%u", fc->group_id); @@ -509,9 +510,8 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt) seq_puts(m, ",allow_other"); if (fc->max_read != ~0) seq_printf(m, ",max_read=%u", fc->max_read); - if (mnt->mnt_sb->s_bdev && - mnt->mnt_sb->s_blocksize != FUSE_DEFAULT_BLKSIZE) - seq_printf(m, ",blksize=%lu", mnt->mnt_sb->s_blocksize); + if (sb->s_bdev && sb->s_blocksize != FUSE_DEFAULT_BLKSIZE) + seq_printf(m, ",blksize=%lu", sb->s_blocksize); return 0; } diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 9e89d94be003..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) /** * gfs2_show_options - Show mount options for /proc/mounts * @s: seq_file structure - * @mnt: vfsmount + * @root: root of this (sub)tree * * Returns: 0 on success or error code */ -static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) +static int gfs2_show_options(struct seq_file *s, struct dentry *root) { - struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info; + struct gfs2_sbd *sdp = root->d_sb->s_fs_info; struct gfs2_args *args = &sdp->sd_args; int val; - if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir)) + if (is_ancestor(root, sdp->sd_master_dir)) seq_printf(s, ",meta"); if (args->ar_lockproto[0]) seq_printf(s, ",lockproto=%s", args->ar_lockproto); diff --git a/fs/hfs/super.c b/fs/hfs/super.c index 32dc2fbb26d5..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) return 0; } -static int hfs_show_options(struct seq_file *seq, struct vfsmount *mnt) +static int hfs_show_options(struct seq_file *seq, struct dentry *root) { - struct hfs_sb_info *sbi = HFS_SB(mnt->mnt_sb); + struct hfs_sb_info *sbi = HFS_SB(root->d_sb); if (sbi->s_creator != cpu_to_be32(0x3f3f3f3f)) seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator); diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index 3a6c025414e2..21a5b7fc6db4 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h @@ -419,7 +419,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size); int hfsplus_parse_options(char *, struct hfsplus_sb_info *); int hfsplus_parse_options_remount(char *input, int *force); void hfsplus_fill_defaults(struct hfsplus_sb_info *); -int hfsplus_show_options(struct seq_file *, struct vfsmount *); +int hfsplus_show_options(struct seq_file *, struct dentry *); /* super.c */ struct inode *hfsplus_iget(struct super_block *, unsigned long); 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: return 1; } -int hfsplus_show_options(struct seq_file *seq, struct vfsmount *mnt) +int hfsplus_show_options(struct seq_file *seq, struct dentry *root) { - struct hfsplus_sb_info *sbi = HFSPLUS_SB(mnt->mnt_sb); + struct hfsplus_sb_info *sbi = HFSPLUS_SB(root->d_sb); if (sbi->creator != HFSPLUS_DEF_CR_TYPE) seq_printf(seq, ",creator=%.4s", (char *)&sbi->creator); diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index a7340e710a90..e130bd46d671 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -258,9 +258,9 @@ static void hostfs_destroy_inode(struct inode *inode) call_rcu(&inode->i_rcu, hostfs_i_callback); } -static int hostfs_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int hostfs_show_options(struct seq_file *seq, struct dentry *root) { - const char *root_path = vfs->mnt_sb->s_fs_info; + const char *root_path = root->d_sb->s_fs_info; size_t offset = strlen(root_ino) + 1; if (strlen(root_path) > offset) diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 804e1292d63e..8be4925296cf 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -96,9 +96,9 @@ static const char *jffs2_compr_name(unsigned int compr) } } -static int jffs2_show_options(struct seq_file *s, struct vfsmount *mnt) +static int jffs2_show_options(struct seq_file *s, struct dentry *root) { - struct jffs2_sb_info *c = JFFS2_SB_INFO(mnt->mnt_sb); + struct jffs2_sb_info *c = JFFS2_SB_INFO(root->d_sb); struct jffs2_mount_opts *opts = &c->mount_opts; if (opts->override_compr) diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 1b8f4ca29adf..682bca642f38 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -608,9 +608,9 @@ static int jfs_sync_fs(struct super_block *sb, int wait) return 0; } -static int jfs_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int jfs_show_options(struct seq_file *seq, struct dentry *root) { - struct jfs_sb_info *sbi = JFS_SBI(vfs->mnt_sb); + struct jfs_sb_info *sbi = JFS_SBI(root->d_sb); if (sbi->uid != -1) seq_printf(seq, ",uid=%d", sbi->uid); diff --git a/fs/namespace.c b/fs/namespace.c index 773435ca300d..db65e2e4921f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -836,12 +836,12 @@ static inline void mangle(struct seq_file *m, const char *s) * * See also save_mount_options(). */ -int generic_show_options(struct seq_file *m, struct vfsmount *mnt) +int generic_show_options(struct seq_file *m, struct dentry *root) { const char *options; rcu_read_lock(); - options = rcu_dereference(mnt->mnt_sb->s_options); + options = rcu_dereference(root->d_sb->s_options); if (options != NULL && options[0]) { seq_putc(m, ','); diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index f3f07cd392b3..3d1e34f8a68e 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c @@ -44,7 +44,7 @@ static void ncp_evict_inode(struct inode *); static void ncp_put_super(struct super_block *); static int ncp_statfs(struct dentry *, struct kstatfs *); -static int ncp_show_options(struct seq_file *, struct vfsmount *); +static int ncp_show_options(struct seq_file *, struct dentry *); static struct kmem_cache * ncp_inode_cachep; @@ -322,9 +322,9 @@ static void ncp_stop_tasks(struct ncp_server *server) { flush_work_sync(&server->timeout_tq); } -static int ncp_show_options(struct seq_file *seq, struct vfsmount *mnt) +static int ncp_show_options(struct seq_file *seq, struct dentry *root) { - struct ncp_server *server = NCP_SBP(mnt->mnt_sb); + struct ncp_server *server = NCP_SBP(root->d_sb); unsigned int tmp; if (server->m.uid != 0) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 02c693c77ab7..e463967aafb8 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -262,7 +262,7 @@ static match_table_t nfs_local_lock_tokens = { static void nfs_umount_begin(struct super_block *); static int nfs_statfs(struct dentry *, struct kstatfs *); -static int nfs_show_options(struct seq_file *, struct vfsmount *); +static int nfs_show_options(struct seq_file *, struct dentry *); static int nfs_show_devname(struct seq_file *, struct dentry *); static int nfs_show_path(struct seq_file *, struct dentry *); static int nfs_show_stats(struct seq_file *, struct dentry *); @@ -720,9 +720,9 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, /* * Describe the mount options on this VFS mountpoint */ -static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt) +static int nfs_show_options(struct seq_file *m, struct dentry *root) { - struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); + struct nfs_server *nfss = NFS_SB(root->d_sb); nfs_show_mount_options(m, nfss, 0); diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 5356c7169d50..08e3d4f9df18 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -648,11 +648,11 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) return 0; } -static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int nilfs_show_options(struct seq_file *seq, struct dentry *dentry) { - struct super_block *sb = vfs->mnt_sb; + struct super_block *sb = dentry->d_sb; struct the_nilfs *nilfs = sb->s_fs_info; - struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; + struct nilfs_root *root = NILFS_I(dentry->d_inode)->i_root; if (!nilfs_test_opt(nilfs, BARRIER)) seq_puts(seq, ",nobarrier"); diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index fea40bb6fb68..2eaa66652944 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -2300,16 +2300,16 @@ void ntfs_evict_big_inode(struct inode *vi) /** * ntfs_show_options - show mount options in /proc/mounts * @sf: seq_file in which to write our mount options - * @mnt: vfs mount whose mount options to display + * @root: root of the mounted tree whose mount options to display * * Called by the VFS once for each mounted ntfs volume when someone reads * /proc/mounts in order to display the NTFS specific mount options of each - * mount. The mount options of the vfs mount @mnt are written to the seq file + * mount. The mount options of fs specified by @root are written to the seq file * @sf and success is returned. */ -int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt) +int ntfs_show_options(struct seq_file *sf, struct dentry *root) { - ntfs_volume *vol = NTFS_SB(mnt->mnt_sb); + ntfs_volume *vol = NTFS_SB(root->d_sb); int i; 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); extern int ntfs_read_inode_mount(struct inode *vi); -extern int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt); +extern int ntfs_show_options(struct seq_file *sf, struct dentry *root); #ifdef NTFS_RW diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index c05ff25c356c..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, int is_remount); static int ocfs2_check_set_options(struct super_block *sb, struct mount_options *options); -static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt); +static int ocfs2_show_options(struct seq_file *s, struct dentry *root); static void ocfs2_put_super(struct super_block *sb); static int ocfs2_mount_volume(struct super_block *sb); static int ocfs2_remount(struct super_block *sb, int *flags, char *data); @@ -1533,9 +1533,9 @@ bail: return status; } -static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) +static int ocfs2_show_options(struct seq_file *s, struct dentry *root) { - struct ocfs2_super *osb = OCFS2_SB(mnt->mnt_sb); + struct ocfs2_super *osb = OCFS2_SB(root->d_sb); unsigned long opts = osb->s_mount_opt; unsigned int local_alloc_megs; @@ -1567,8 +1567,7 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) if (osb->preferred_slot != OCFS2_INVALID_SLOT) seq_printf(s, ",preferred_slot=%d", osb->preferred_slot); - if (!(mnt->mnt_flags & MNT_NOATIME) && !(mnt->mnt_flags & MNT_RELATIME)) - seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum); + seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum); if (osb->osb_commit_interval) seq_printf(s, ",commit=%u", diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 8f8304b3f98a..12412852d88a 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -113,7 +113,7 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt) goto out; show_mnt_opts(m, mnt); if (sb->s_op->show_options) - err = sb->s_op->show_options(m, mnt); + err = sb->s_op->show_options(m, mnt_path.dentry); seq_puts(m, " 0 0\n"); out: return err; @@ -174,7 +174,7 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) if (err) goto out; if (sb->s_op->show_options) - err = sb->s_op->show_options(m, mnt); + err = sb->s_op->show_options(m, mnt->mnt_root); seq_putc(m, '\n'); out: return err; diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index d93a3fadf53c..63765d58445b 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -419,9 +419,9 @@ static int ubifs_statfs(struct dentry *dentry, struct kstatfs *buf) return 0; } -static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt) +static int ubifs_show_options(struct seq_file *s, struct dentry *root) { - struct ubifs_info *c = mnt->mnt_sb->s_fs_info; + struct ubifs_info *c = root->d_sb->s_fs_info; if (c->mount_opts.unmount_mode == 2) seq_printf(s, ",fast_unmount"); diff --git a/fs/udf/super.c b/fs/udf/super.c index c94fc889a486..0c33225647a0 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -89,7 +89,7 @@ static void udf_open_lvid(struct super_block *); static void udf_close_lvid(struct super_block *); static unsigned int udf_count_free(struct super_block *); static int udf_statfs(struct dentry *, struct kstatfs *); -static int udf_show_options(struct seq_file *, struct vfsmount *); +static int udf_show_options(struct seq_file *, struct dentry *); struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi) { @@ -249,9 +249,9 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count) return 0; } -static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt) +static int udf_show_options(struct seq_file *seq, struct dentry *root) { - struct super_block *sb = mnt->mnt_sb; + struct super_block *sb = root->d_sb; struct udf_sb_info *sbi = UDF_SB(sb); if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT)) diff --git a/fs/ufs/super.c b/fs/ufs/super.c index d6961eb5b774..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) return 0; } -static int ufs_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int ufs_show_options(struct seq_file *seq, struct dentry *root) { - struct ufs_sb_info *sbi = UFS_SB(vfs->mnt_sb); + struct ufs_sb_info *sbi = UFS_SB(root->d_sb); unsigned mval = sbi->s_mount_opt & UFS_MOUNT_UFSTYPE; const struct match_token *tp = tokens; 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( STATIC int xfs_fs_show_options( struct seq_file *m, - struct vfsmount *mnt) + struct dentry *root) { - return -xfs_showargs(XFS_M(mnt->mnt_sb), m); + return -xfs_showargs(XFS_M(root->d_sb), m); } /* diff --git a/include/linux/fs.h b/include/linux/fs.h index 13721b073407..cc1021fd19ef 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1672,7 +1672,7 @@ struct super_operations { int (*remount_fs) (struct super_block *, int *, char *); void (*umount_begin) (struct super_block *); - int (*show_options)(struct seq_file *, struct vfsmount *); + int (*show_options)(struct seq_file *, struct dentry *); int (*show_devname)(struct seq_file *, struct dentry *); int (*show_path)(struct seq_file *, struct dentry *); int (*show_stats)(struct seq_file *, struct dentry *); @@ -2592,7 +2592,7 @@ extern void setattr_copy(struct inode *inode, const struct iattr *attr); extern void file_update_time(struct file *file); -extern int generic_show_options(struct seq_file *m, struct vfsmount *mnt); +extern int generic_show_options(struct seq_file *m, struct dentry *root); extern void save_mount_options(struct super_block *sb, char *options); extern void replace_mount_options(struct super_block *sb, char *options); diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 86ebacfd9431..7cab65f83f1d 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -1038,9 +1038,9 @@ static int rebind_subsystems(struct cgroupfs_root *root, return 0; } -static int cgroup_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int cgroup_show_options(struct seq_file *seq, struct dentry *dentry) { - struct cgroupfs_root *root = vfs->mnt_sb->s_fs_info; + struct cgroupfs_root *root = dentry->d_sb->s_fs_info; struct cgroup_subsys *ss; mutex_lock(&cgroup_mutex); diff --git a/mm/shmem.c b/mm/shmem.c index 86a19efc36fb..feead1943d92 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2118,9 +2118,9 @@ out: return error; } -static int shmem_show_options(struct seq_file *seq, struct vfsmount *vfs) +static int shmem_show_options(struct seq_file *seq, struct dentry *root) { - struct shmem_sb_info *sbinfo = SHMEM_SB(vfs->mnt_sb); + struct shmem_sb_info *sbinfo = SHMEM_SB(root->d_sb); if (sbinfo->max_blocks != shmem_default_max_blocks()) seq_printf(seq, ",size=%luk", From 39f7c4db1d2d9e2e2a90abdf34811783089d217d Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 21 Nov 2011 12:11:30 +0100 Subject: [PATCH 161/165] vfs: keep list of mounts for each superblock Keep track of vfsmounts belonging to a superblock. List is protected by vfsmount_lock. Signed-off-by: Miklos Szeredi Tested-by: Toshiyuki Okajima Signed-off-by: Al Viro --- fs/mount.h | 1 + fs/namespace.c | 7 +++++++ fs/super.c | 2 ++ include/linux/fs.h | 1 + 4 files changed, 11 insertions(+) diff --git a/fs/mount.h b/fs/mount.h index 0921b51e27e2..4ef36d93e5a2 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -29,6 +29,7 @@ struct mount { #endif struct list_head mnt_mounts; /* list of children, anchored here */ struct list_head mnt_child; /* and going through their mnt_child */ + struct list_head mnt_instance; /* mount instance on sb->s_mounts */ const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ struct list_head mnt_list; struct list_head mnt_expire; /* link in fs-specific expiry list */ diff --git a/fs/namespace.c b/fs/namespace.c index db65e2e4921f..145217b088d1 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -671,6 +671,9 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void mnt->mnt.mnt_sb = root->d_sb; mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; + br_write_lock(vfsmount_lock); + list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts); + br_write_unlock(vfsmount_lock); return &mnt->mnt; } EXPORT_SYMBOL_GPL(vfs_kern_mount); @@ -699,6 +702,9 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, mnt->mnt.mnt_root = dget(root); mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; + br_write_lock(vfsmount_lock); + list_add_tail(&mnt->mnt_instance, &sb->s_mounts); + br_write_unlock(vfsmount_lock); if (flag & CL_SLAVE) { list_add(&mnt->mnt_slave, &old->mnt_slave_list); @@ -781,6 +787,7 @@ put_again: acct_auto_close_mnt(&mnt->mnt); goto put_again; } + list_del(&mnt->mnt_instance); br_write_unlock(vfsmount_lock); mntfree(mnt); } diff --git a/fs/super.c b/fs/super.c index 0413f51a9f0f..993ca8f128d6 100644 --- a/fs/super.c +++ b/fs/super.c @@ -142,6 +142,7 @@ static struct super_block *alloc_super(struct file_system_type *type) INIT_LIST_HEAD(&s->s_dentry_lru); INIT_LIST_HEAD(&s->s_inode_lru); spin_lock_init(&s->s_inode_lru_lock); + INIT_LIST_HEAD(&s->s_mounts); init_rwsem(&s->s_umount); mutex_init(&s->s_lock); lockdep_set_class(&s->s_umount, &type->s_umount_key); @@ -200,6 +201,7 @@ static inline void destroy_super(struct super_block *s) free_percpu(s->s_files); #endif security_sb_free(s); + WARN_ON(!list_empty(&s->s_mounts)); kfree(s->s_subtype); kfree(s->s_options); kfree(s); diff --git a/include/linux/fs.h b/include/linux/fs.h index cc1021fd19ef..03385acd71e8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1428,6 +1428,7 @@ struct super_block { #else struct list_head s_files; #endif + struct list_head s_mounts; /* list of mounts; _not_ for fs use */ /* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */ struct list_head s_dentry_lru; /* unused dentry lru */ int s_nr_dentry_unused; /* # of dentry on lru */ From 4ed5e82fe77f4147cf386327c9a63a2dd7eff518 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 21 Nov 2011 12:11:31 +0100 Subject: [PATCH 162/165] vfs: protect remounting superblock read-only Currently remouting superblock read-only is racy in a major way. With the per mount read-only infrastructure it is now possible to prevent most races, which this patch attempts. Before starting the remount read-only, iterate through all mounts belonging to the superblock and if none of them have any pending writes, set sb->s_readonly_remount. This indicates that remount is in progress and no further write requests are allowed. If the remount succeeds set MS_RDONLY and reset s_readonly_remount. If the remounting is unsuccessful just reset s_readonly_remount. This can result in transient EROFS errors, despite the fact the remount failed. Unfortunately hodling off writes is difficult as remount itself may touch the filesystem (e.g. through load_nls()) which would deadlock. A later patch deals with delayed writes due to nlink going to zero. Signed-off-by: Miklos Szeredi Tested-by: Toshiyuki Okajima Signed-off-by: Al Viro --- fs/internal.h | 1 + fs/namespace.c | 40 +++++++++++++++++++++++++++++++++++++++- fs/super.c | 22 ++++++++++++++++++---- include/linux/fs.h | 3 +++ 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index 2523a4029452..9962c59ba280 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -52,6 +52,7 @@ extern int finish_automount(struct vfsmount *, struct path *); extern void mnt_make_longterm(struct vfsmount *); extern void mnt_make_shortterm(struct vfsmount *); +extern int sb_prepare_remount_readonly(struct super_block *); extern void __init mnt_init(void); diff --git a/fs/namespace.c b/fs/namespace.c index 145217b088d1..98ebc78b21ab 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -273,6 +273,15 @@ static unsigned int mnt_get_writers(struct mount *mnt) #endif } +static int mnt_is_readonly(struct vfsmount *mnt) +{ + if (mnt->mnt_sb->s_readonly_remount) + return 1; + /* Order wrt setting s_flags/s_readonly_remount in do_remount() */ + smp_rmb(); + return __mnt_is_readonly(mnt); +} + /* * Most r/o checks on a fs are for operations that take * discrete amounts of time, like a write() or unlink(). @@ -312,7 +321,7 @@ int mnt_want_write(struct vfsmount *m) * MNT_WRITE_HOLD is cleared. */ smp_rmb(); - if (__mnt_is_readonly(m)) { + if (mnt_is_readonly(m)) { mnt_dec_writers(mnt); ret = -EROFS; goto out; @@ -435,6 +444,35 @@ static void __mnt_unmake_readonly(struct mount *mnt) br_write_unlock(vfsmount_lock); } +int sb_prepare_remount_readonly(struct super_block *sb) +{ + struct mount *mnt; + int err = 0; + + br_write_lock(vfsmount_lock); + list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) { + if (!(mnt->mnt.mnt_flags & MNT_READONLY)) { + mnt->mnt.mnt_flags |= MNT_WRITE_HOLD; + smp_mb(); + if (mnt_get_writers(mnt) > 0) { + err = -EBUSY; + break; + } + } + } + if (!err) { + sb->s_readonly_remount = 1; + smp_wmb(); + } + list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) { + if (mnt->mnt.mnt_flags & MNT_WRITE_HOLD) + mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; + } + br_write_unlock(vfsmount_lock); + + return err; +} + static void free_vfsmnt(struct mount *mnt) { kfree(mnt->mnt_devname); diff --git a/fs/super.c b/fs/super.c index 993ca8f128d6..6acc02237e3e 100644 --- a/fs/super.c +++ b/fs/super.c @@ -723,23 +723,33 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) /* If we are remounting RDONLY and current sb is read/write, make sure there are no rw files opened */ if (remount_ro) { - if (force) + if (force) { mark_files_ro(sb); - else if (!fs_may_remount_ro(sb)) - return -EBUSY; + } else { + retval = sb_prepare_remount_readonly(sb); + if (retval) + return retval; + + retval = -EBUSY; + if (!fs_may_remount_ro(sb)) + goto cancel_readonly; + } } if (sb->s_op->remount_fs) { retval = sb->s_op->remount_fs(sb, &flags, data); if (retval) { if (!force) - return retval; + goto cancel_readonly; /* If forced remount, go ahead despite any errors */ WARN(1, "forced remount of a %s fs returned %i\n", sb->s_type->name, retval); } } sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); + /* Needs to be ordered wrt mnt_is_readonly() */ + smp_wmb(); + sb->s_readonly_remount = 0; /* * Some filesystems modify their metadata via some other path than the @@ -752,6 +762,10 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) if (remount_ro && sb->s_bdev) invalidate_bdev(sb->s_bdev); return 0; + +cancel_readonly: + sb->s_readonly_remount = 0; + return retval; } static void do_emergency_remount(struct work_struct *work) diff --git a/include/linux/fs.h b/include/linux/fs.h index 03385acd71e8..7b8a681b1ef4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1482,6 +1482,9 @@ struct super_block { int cleancache_poolid; struct shrinker s_shrink; /* per-sb shrinker handle */ + + /* Being remounted read-only */ + int s_readonly_remount; }; /* superblock cache pruning functions */ From 7ada4db88634429f4da690ad1c4eb73c93085f0c Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 21 Nov 2011 12:11:32 +0100 Subject: [PATCH 163/165] vfs: count unlinked inodes Add a new counter to the superblock that keeps track of unlinked but not yet deleted inodes. Do not WARN_ON if set_nlink is called with zero count, just do a ratelimited printk. This happens on xfs and probably other filesystems after an unclean shutdown when the filesystem reads inodes which already have zero i_nlink. Reported by Christoph Hellwig. Signed-off-by: Miklos Szeredi Tested-by: Toshiyuki Okajima Signed-off-by: Al Viro --- fs/inode.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 61 ++++----------------------------- 2 files changed, 92 insertions(+), 54 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 961355d00e38..87535753ab04 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -26,6 +26,7 @@ #include #include #include /* for inode_has_buffers */ +#include #include "internal.h" /* @@ -242,6 +243,11 @@ void __destroy_inode(struct inode *inode) BUG_ON(inode_has_buffers(inode)); security_inode_free(inode); fsnotify_inode_delete(inode); + if (!inode->i_nlink) { + WARN_ON(atomic_long_read(&inode->i_sb->s_remove_count) == 0); + atomic_long_dec(&inode->i_sb->s_remove_count); + } + #ifdef CONFIG_FS_POSIX_ACL if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED) posix_acl_release(inode->i_acl); @@ -268,6 +274,85 @@ static void destroy_inode(struct inode *inode) call_rcu(&inode->i_rcu, i_callback); } +/** + * drop_nlink - directly drop an inode's link count + * @inode: inode + * + * This is a low-level filesystem helper to replace any + * direct filesystem manipulation of i_nlink. In cases + * where we are attempting to track writes to the + * filesystem, a decrement to zero means an imminent + * write when the file is truncated and actually unlinked + * on the filesystem. + */ +void drop_nlink(struct inode *inode) +{ + WARN_ON(inode->i_nlink == 0); + inode->__i_nlink--; + if (!inode->i_nlink) + atomic_long_inc(&inode->i_sb->s_remove_count); +} +EXPORT_SYMBOL(drop_nlink); + +/** + * clear_nlink - directly zero an inode's link count + * @inode: inode + * + * This is a low-level filesystem helper to replace any + * direct filesystem manipulation of i_nlink. See + * drop_nlink() for why we care about i_nlink hitting zero. + */ +void clear_nlink(struct inode *inode) +{ + if (inode->i_nlink) { + inode->__i_nlink = 0; + atomic_long_inc(&inode->i_sb->s_remove_count); + } +} +EXPORT_SYMBOL(clear_nlink); + +/** + * set_nlink - directly set an inode's link count + * @inode: inode + * @nlink: new nlink (should be non-zero) + * + * This is a low-level filesystem helper to replace any + * direct filesystem manipulation of i_nlink. + */ +void set_nlink(struct inode *inode, unsigned int nlink) +{ + if (!nlink) { + printk_ratelimited(KERN_INFO + "set_nlink() clearing i_nlink on %s inode %li\n", + inode->i_sb->s_type->name, inode->i_ino); + clear_nlink(inode); + } else { + /* Yes, some filesystems do change nlink from zero to one */ + if (inode->i_nlink == 0) + atomic_long_dec(&inode->i_sb->s_remove_count); + + inode->__i_nlink = nlink; + } +} +EXPORT_SYMBOL(set_nlink); + +/** + * inc_nlink - directly increment an inode's link count + * @inode: inode + * + * This is a low-level filesystem helper to replace any + * direct filesystem manipulation of i_nlink. Currently, + * it is only here for parity with dec_nlink(). + */ +void inc_nlink(struct inode *inode) +{ + if (WARN_ON(inode->i_nlink == 0)) + atomic_long_dec(&inode->i_sb->s_remove_count); + + inode->__i_nlink++; +} +EXPORT_SYMBOL(inc_nlink); + void address_space_init_once(struct address_space *mapping) { memset(mapping, 0, sizeof(*mapping)); diff --git a/include/linux/fs.h b/include/linux/fs.h index 7b8a681b1ef4..8ac40921f5ac 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1483,6 +1483,9 @@ struct super_block { struct shrinker s_shrink; /* per-sb shrinker handle */ + /* Number of inodes with nlink == 0 but still referenced */ + atomic_long_t s_remove_count; + /* Being remounted read-only */ int s_readonly_remount; }; @@ -1768,31 +1771,10 @@ static inline void mark_inode_dirty_sync(struct inode *inode) __mark_inode_dirty(inode, I_DIRTY_SYNC); } -/** - * set_nlink - directly set an inode's link count - * @inode: inode - * @nlink: new nlink (should be non-zero) - * - * This is a low-level filesystem helper to replace any - * direct filesystem manipulation of i_nlink. - */ -static inline void set_nlink(struct inode *inode, unsigned int nlink) -{ - inode->__i_nlink = nlink; -} - -/** - * inc_nlink - directly increment an inode's link count - * @inode: inode - * - * This is a low-level filesystem helper to replace any - * direct filesystem manipulation of i_nlink. Currently, - * it is only here for parity with dec_nlink(). - */ -static inline void inc_nlink(struct inode *inode) -{ - inode->__i_nlink++; -} +extern void inc_nlink(struct inode *inode); +extern void drop_nlink(struct inode *inode); +extern void clear_nlink(struct inode *inode); +extern void set_nlink(struct inode *inode, unsigned int nlink); static inline void inode_inc_link_count(struct inode *inode) { @@ -1800,35 +1782,6 @@ static inline void inode_inc_link_count(struct inode *inode) mark_inode_dirty(inode); } -/** - * drop_nlink - directly drop an inode's link count - * @inode: inode - * - * This is a low-level filesystem helper to replace any - * direct filesystem manipulation of i_nlink. In cases - * where we are attempting to track writes to the - * filesystem, a decrement to zero means an imminent - * write when the file is truncated and actually unlinked - * on the filesystem. - */ -static inline void drop_nlink(struct inode *inode) -{ - inode->__i_nlink--; -} - -/** - * clear_nlink - directly zero an inode's link count - * @inode: inode - * - * This is a low-level filesystem helper to replace any - * direct filesystem manipulation of i_nlink. See - * drop_nlink() for why we care about i_nlink hitting zero. - */ -static inline void clear_nlink(struct inode *inode) -{ - inode->__i_nlink = 0; -} - static inline void inode_dec_link_count(struct inode *inode) { drop_nlink(inode); From 8e8b87964bc8dc5c14b6543fc933b7725f07d3ac Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 21 Nov 2011 12:11:33 +0100 Subject: [PATCH 164/165] vfs: prevent remount read-only if pending removes If there are any inodes on the super block that have been unlinked (i_nlink == 0) but have not yet been deleted then prevent the remounting the super block read-only. Reported-by: Toshiyuki Okajima Signed-off-by: Miklos Szeredi Tested-by: Toshiyuki Okajima Signed-off-by: Al Viro --- fs/file_table.c | 23 ----------------------- fs/namespace.c | 7 +++++++ fs/super.c | 4 ---- include/linux/fs.h | 2 -- 4 files changed, 7 insertions(+), 29 deletions(-) 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) #endif -int fs_may_remount_ro(struct super_block *sb) -{ - struct file *file; - /* Check that no files are currently opened for writing. */ - lg_global_lock(files_lglock); - do_file_list_for_each_entry(sb, file) { - struct inode *inode = file->f_path.dentry->d_inode; - - /* File with pending delete? */ - if (inode->i_nlink == 0) - goto too_bad; - - /* Writeable file? */ - if (S_ISREG(inode->i_mode) && (file->f_mode & FMODE_WRITE)) - goto too_bad; - } while_file_list_for_each_entry; - lg_global_unlock(files_lglock); - return 1; /* Tis' cool bro. */ -too_bad: - lg_global_unlock(files_lglock); - return 0; -} - /** * mark_files_ro - mark all files read-only * @sb: superblock in question diff --git a/fs/namespace.c b/fs/namespace.c index 98ebc78b21ab..7e6f2c9dc7c4 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -449,6 +449,10 @@ int sb_prepare_remount_readonly(struct super_block *sb) struct mount *mnt; int err = 0; + /* Racy optimization. Recheck the counter under MNT_WRITE_HOLD */ + if (atomic_long_read(&sb->s_remove_count)) + return -EBUSY; + br_write_lock(vfsmount_lock); list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) { if (!(mnt->mnt.mnt_flags & MNT_READONLY)) { @@ -460,6 +464,9 @@ int sb_prepare_remount_readonly(struct super_block *sb) } } } + if (!err && atomic_long_read(&sb->s_remove_count)) + err = -EBUSY; + if (!err) { sb->s_readonly_remount = 1; smp_wmb(); diff --git a/fs/super.c b/fs/super.c index 6acc02237e3e..de41e1e46f09 100644 --- a/fs/super.c +++ b/fs/super.c @@ -729,10 +729,6 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) retval = sb_prepare_remount_readonly(sb); if (retval) return retval; - - retval = -EBUSY; - if (!fs_may_remount_ro(sb)) - goto cancel_readonly; } } diff --git a/include/linux/fs.h b/include/linux/fs.h index 8ac40921f5ac..7aacf31418fe 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2150,8 +2150,6 @@ extern const struct file_operations read_pipefifo_fops; extern const struct file_operations write_pipefifo_fops; extern const struct file_operations rdwr_pipefifo_fops; -extern int fs_may_remount_ro(struct super_block *); - #ifdef CONFIG_BLOCK /* * return READ, READA, or WRITE From c3aa077648e147783a7a53b409578234647db853 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Wed, 21 Dec 2011 20:17:10 +0100 Subject: [PATCH 165/165] reiserfs: Properly display mount options in /proc/mounts Make reiserfs properly display mount options in /proc/mounts. CC: reiserfs-devel@vger.kernel.org Signed-off-by: Jan Kara Signed-off-by: Al Viro --- fs/reiserfs/bitmap.c | 91 ++++++++++++++++++++++++++ fs/reiserfs/super.c | 116 ++++++++++++++++++++++++++++++--- include/linux/reiserfs_fs.h | 7 +- include/linux/reiserfs_fs_sb.h | 4 +- 4 files changed, 204 insertions(+), 14 deletions(-) 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 @@ #include #include #include +#include #define PREALLOCATION_SIZE 9 @@ -634,6 +635,96 @@ int reiserfs_parse_alloc_options(struct super_block *s, char *options) return 0; } +static void print_sep(struct seq_file *seq, int *first) +{ + if (!*first) + seq_puts(seq, ":"); + else + *first = 0; +} + +void show_alloc_options(struct seq_file *seq, struct super_block *s) +{ + int first = 1; + + if (SB_ALLOC_OPTS(s) == ((1 << _ALLOC_skip_busy) | + (1 << _ALLOC_dirid_groups) | (1 << _ALLOC_packing_groups))) + return; + + seq_puts(seq, ",alloc="); + + if (TEST_OPTION(concentrating_formatted_nodes, s)) { + print_sep(seq, &first); + if (REISERFS_SB(s)->s_alloc_options.border != 10) { + seq_printf(seq, "concentrating_formatted_nodes=%d", + 100 / REISERFS_SB(s)->s_alloc_options.border); + } else + seq_puts(seq, "concentrating_formatted_nodes"); + } + if (TEST_OPTION(displacing_large_files, s)) { + print_sep(seq, &first); + if (REISERFS_SB(s)->s_alloc_options.large_file_size != 16) { + seq_printf(seq, "displacing_large_files=%lu", + REISERFS_SB(s)->s_alloc_options.large_file_size); + } else + seq_puts(seq, "displacing_large_files"); + } + if (TEST_OPTION(displacing_new_packing_localities, s)) { + print_sep(seq, &first); + seq_puts(seq, "displacing_new_packing_localities"); + } + if (TEST_OPTION(old_hashed_relocation, s)) { + print_sep(seq, &first); + seq_puts(seq, "old_hashed_relocation"); + } + if (TEST_OPTION(new_hashed_relocation, s)) { + print_sep(seq, &first); + seq_puts(seq, "new_hashed_relocation"); + } + if (TEST_OPTION(dirid_groups, s)) { + print_sep(seq, &first); + seq_puts(seq, "dirid_groups"); + } + if (TEST_OPTION(oid_groups, s)) { + print_sep(seq, &first); + seq_puts(seq, "oid_groups"); + } + if (TEST_OPTION(packing_groups, s)) { + print_sep(seq, &first); + seq_puts(seq, "packing_groups"); + } + if (TEST_OPTION(hashed_formatted_nodes, s)) { + print_sep(seq, &first); + seq_puts(seq, "hashed_formatted_nodes"); + } + if (TEST_OPTION(skip_busy, s)) { + print_sep(seq, &first); + seq_puts(seq, "skip_busy"); + } + if (TEST_OPTION(hundredth_slices, s)) { + print_sep(seq, &first); + seq_puts(seq, "hundredth_slices"); + } + if (TEST_OPTION(old_way, s)) { + print_sep(seq, &first); + seq_puts(seq, "old_way"); + } + if (TEST_OPTION(displace_based_on_dirid, s)) { + print_sep(seq, &first); + seq_puts(seq, "displace_based_on_dirid"); + } + if (REISERFS_SB(s)->s_alloc_options.preallocmin != 0) { + print_sep(seq, &first); + seq_printf(seq, "preallocmin=%d", + REISERFS_SB(s)->s_alloc_options.preallocmin); + } + if (REISERFS_SB(s)->s_alloc_options.preallocsize != 17) { + print_sep(seq, &first); + seq_printf(seq, "preallocsize=%d", + REISERFS_SB(s)->s_alloc_options.preallocsize); + } +} + static inline void new_hashed_relocation(reiserfs_blocknr_hint_t * hint) { char *hash_in; diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 1abffa451529..19c454e61b79 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -28,6 +28,7 @@ #include #include #include +#include struct file_system_type reiserfs_fs_type; @@ -61,6 +62,7 @@ static int is_any_reiserfs_magic_string(struct reiserfs_super_block *rs) static int reiserfs_remount(struct super_block *s, int *flags, char *data); static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf); +void show_alloc_options(struct seq_file *seq, struct super_block *s); static int reiserfs_sync_fs(struct super_block *s, int wait) { @@ -596,6 +598,82 @@ out: reiserfs_write_unlock_once(inode->i_sb, lock_depth); } +static int reiserfs_show_options(struct seq_file *seq, struct dentry *root) +{ + struct super_block *s = root->d_sb; + struct reiserfs_journal *journal = SB_JOURNAL(s); + long opts = REISERFS_SB(s)->s_mount_opt; + + if (opts & (1 << REISERFS_LARGETAIL)) + seq_puts(seq, ",tails=on"); + else if (!(opts & (1 << REISERFS_SMALLTAIL))) + seq_puts(seq, ",notail"); + /* tails=small is default so we don't show it */ + + if (!(opts & (1 << REISERFS_BARRIER_FLUSH))) + seq_puts(seq, ",barrier=none"); + /* barrier=flush is default so we don't show it */ + + if (opts & (1 << REISERFS_ERROR_CONTINUE)) + seq_puts(seq, ",errors=continue"); + else if (opts & (1 << REISERFS_ERROR_PANIC)) + seq_puts(seq, ",errors=panic"); + /* errors=ro is default so we don't show it */ + + if (opts & (1 << REISERFS_DATA_LOG)) + seq_puts(seq, ",data=journal"); + else if (opts & (1 << REISERFS_DATA_WRITEBACK)) + seq_puts(seq, ",data=writeback"); + /* data=ordered is default so we don't show it */ + + if (opts & (1 << REISERFS_ATTRS)) + seq_puts(seq, ",attrs"); + + if (opts & (1 << REISERFS_XATTRS_USER)) + seq_puts(seq, ",user_xattr"); + + if (opts & (1 << REISERFS_EXPOSE_PRIVROOT)) + seq_puts(seq, ",expose_privroot"); + + if (opts & (1 << REISERFS_POSIXACL)) + seq_puts(seq, ",acl"); + + if (REISERFS_SB(s)->s_jdev) + seq_printf(seq, ",jdev=%s", REISERFS_SB(s)->s_jdev); + + if (journal->j_max_commit_age != journal->j_default_max_commit_age) + seq_printf(seq, ",commit=%d", journal->j_max_commit_age); + +#ifdef CONFIG_QUOTA + if (REISERFS_SB(s)->s_qf_names[USRQUOTA]) + seq_printf(seq, ",usrjquota=%s", REISERFS_SB(s)->s_qf_names[USRQUOTA]); + else if (opts & (1 << REISERFS_USRQUOTA)) + seq_puts(seq, ",usrquota"); + if (REISERFS_SB(s)->s_qf_names[GRPQUOTA]) + seq_printf(seq, ",grpjquota=%s", REISERFS_SB(s)->s_qf_names[GRPQUOTA]); + else if (opts & (1 << REISERFS_GRPQUOTA)) + seq_puts(seq, ",grpquota"); + if (REISERFS_SB(s)->s_jquota_fmt) { + if (REISERFS_SB(s)->s_jquota_fmt == QFMT_VFS_OLD) + seq_puts(seq, ",jqfmt=vfsold"); + else if (REISERFS_SB(s)->s_jquota_fmt == QFMT_VFS_V0) + seq_puts(seq, ",jqfmt=vfsv0"); + } +#endif + + /* Block allocator options */ + if (opts & (1 << REISERFS_NO_BORDER)) + seq_puts(seq, ",block-allocator=noborder"); + if (opts & (1 << REISERFS_NO_UNHASHED_RELOCATION)) + seq_puts(seq, ",block-allocator=no_unhashed_relocation"); + if (opts & (1 << REISERFS_HASHED_RELOCATION)) + seq_puts(seq, ",block-allocator=hashed_relocation"); + if (opts & (1 << REISERFS_TEST4)) + seq_puts(seq, ",block-allocator=test4"); + show_alloc_options(seq, s); + return 0; +} + #ifdef CONFIG_QUOTA static ssize_t reiserfs_quota_write(struct super_block *, int, const char *, size_t, loff_t); @@ -616,7 +694,7 @@ static const struct super_operations reiserfs_sops = { .unfreeze_fs = reiserfs_unfreeze, .statfs = reiserfs_statfs, .remount_fs = reiserfs_remount, - .show_options = generic_show_options, + .show_options = reiserfs_show_options, #ifdef CONFIG_QUOTA .quota_read = reiserfs_quota_read, .quota_write = reiserfs_quota_write, @@ -914,9 +992,9 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin {"jdev",.arg_required = 'j',.values = NULL}, {"nolargeio",.arg_required = 'w',.values = NULL}, {"commit",.arg_required = 'c',.values = NULL}, - {"usrquota",.setmask = 1 << REISERFS_QUOTA}, - {"grpquota",.setmask = 1 << REISERFS_QUOTA}, - {"noquota",.clrmask = 1 << REISERFS_QUOTA}, + {"usrquota",.setmask = 1 << REISERFS_USRQUOTA}, + {"grpquota",.setmask = 1 << REISERFS_GRPQUOTA}, + {"noquota",.clrmask = 1 << REISERFS_USRQUOTA | 1 << REISERFS_GRPQUOTA}, {"errors",.arg_required = 'e',.values = error_actions}, {"usrjquota",.arg_required = 'u' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL}, @@ -1030,12 +1108,19 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin return 0; } strcpy(qf_names[qtype], arg); - *mount_options |= 1 << REISERFS_QUOTA; + if (qtype == USRQUOTA) + *mount_options |= 1 << REISERFS_USRQUOTA; + else + *mount_options |= 1 << REISERFS_GRPQUOTA; } else { if (qf_names[qtype] != REISERFS_SB(s)->s_qf_names[qtype]) kfree(qf_names[qtype]); qf_names[qtype] = NULL; + if (qtype == USRQUOTA) + *mount_options &= ~(1 << REISERFS_USRQUOTA); + else + *mount_options &= ~(1 << REISERFS_GRPQUOTA); } } if (c == 'f') { @@ -1074,9 +1159,10 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin "journaled quota format not specified."); return 0; } - /* This checking is not precise wrt the quota type but for our purposes it is sufficient */ - if (!(*mount_options & (1 << REISERFS_QUOTA)) - && sb_any_quota_loaded(s)) { + if ((!(*mount_options & (1 << REISERFS_USRQUOTA)) && + sb_has_quota_loaded(s, USRQUOTA)) || + (!(*mount_options & (1 << REISERFS_GRPQUOTA)) && + sb_has_quota_loaded(s, GRPQUOTA))) { reiserfs_warning(s, "super-6516", "quota options must " "be present when quota is turned on."); return 0; @@ -1224,7 +1310,8 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) safe_mask |= 1 << REISERFS_ERROR_RO; safe_mask |= 1 << REISERFS_ERROR_CONTINUE; safe_mask |= 1 << REISERFS_ERROR_PANIC; - safe_mask |= 1 << REISERFS_QUOTA; + safe_mask |= 1 << REISERFS_USRQUOTA; + safe_mask |= 1 << REISERFS_GRPQUOTA; /* Update the bitmask, taking care to keep * the bits we're not allowed to change here */ @@ -1671,6 +1758,14 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) &commit_max_age, qf_names, &qfmt) == 0) { goto error; } + if (jdev_name && jdev_name[0]) { + REISERFS_SB(s)->s_jdev = kstrdup(jdev_name, GFP_KERNEL); + if (!REISERFS_SB(s)->s_jdev) { + SWARN(silent, s, "", "Cannot allocate memory for " + "journal device name"); + goto error; + } + } #ifdef CONFIG_QUOTA handle_quota_files(s, qf_names, &qfmt); #endif @@ -2053,8 +2148,9 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, int err; struct inode *inode; struct reiserfs_transaction_handle th; + int opt = type == USRQUOTA ? REISERFS_USRQUOTA : REISERFS_GRPQUOTA; - if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA))) + if (!(REISERFS_SB(sb)->s_mount_opt & (1 << opt))) return -EINVAL; /* Quotafile not on the same filesystem? */ diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h index 26be28fd7b76..2213ddcce20c 100644 --- a/include/linux/reiserfs_fs.h +++ b/include/linux/reiserfs_fs.h @@ -1759,13 +1759,14 @@ struct reiserfs_journal_header { REISERFS_QUOTA_TRANS_BLOCKS(sb))) #ifdef CONFIG_QUOTA +#define REISERFS_QUOTA_OPTS ((1 << REISERFS_USRQUOTA) | (1 << REISERFS_GRPQUOTA)) /* We need to update data and inode (atime) */ -#define REISERFS_QUOTA_TRANS_BLOCKS(s) (REISERFS_SB(s)->s_mount_opt & (1<s_mount_opt & REISERFS_QUOTA_OPTS ? 2 : 0) /* 1 balancing, 1 bitmap, 1 data per write + stat data update */ -#define REISERFS_QUOTA_INIT_BLOCKS(s) (REISERFS_SB(s)->s_mount_opt & (1<s_mount_opt & REISERFS_QUOTA_OPTS ? \ (DQUOT_INIT_ALLOC*(JOURNAL_PER_BALANCE_CNT+2)+DQUOT_INIT_REWRITE+1) : 0) /* same as with INIT */ -#define REISERFS_QUOTA_DEL_BLOCKS(s) (REISERFS_SB(s)->s_mount_opt & (1<s_mount_opt & REISERFS_QUOTA_OPTS ? \ (DQUOT_DEL_ALLOC*(JOURNAL_PER_BALANCE_CNT+2)+DQUOT_DEL_REWRITE+1) : 0) #else #define REISERFS_QUOTA_TRANS_BLOCKS(s) 0 diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h index 52c83b6a758a..8c9e85c64b46 100644 --- a/include/linux/reiserfs_fs_sb.h +++ b/include/linux/reiserfs_fs_sb.h @@ -417,6 +417,7 @@ struct reiserfs_sb_info { char *s_qf_names[MAXQUOTAS]; int s_jquota_fmt; #endif + char *s_jdev; /* Stored jdev for mount option showing */ #ifdef CONFIG_REISERFS_CHECK struct tree_balance *cur_tb; /* @@ -482,7 +483,8 @@ enum reiserfs_mount_options { REISERFS_ERROR_RO, REISERFS_ERROR_CONTINUE, - REISERFS_QUOTA, /* Some quota option specified */ + REISERFS_USRQUOTA, /* User quota option specified */ + REISERFS_GRPQUOTA, /* Group quota option specified */ REISERFS_TEST1, REISERFS_TEST2,