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 <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -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)
|
if (ret)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
@@ -1855,7 +1855,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mnt_want_write(file->f_path.mnt);
|
err = mnt_want_write_file(file);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@@ -1987,7 +1987,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
|
|||||||
if (btrfs_root_readonly(root))
|
if (btrfs_root_readonly(root))
|
||||||
return -EROFS;
|
return -EROFS;
|
||||||
|
|
||||||
ret = mnt_want_write(file->f_path.mnt);
|
ret = mnt_want_write_file(file);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -2195,7 +2195,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
|
|||||||
if (btrfs_root_readonly(root))
|
if (btrfs_root_readonly(root))
|
||||||
return -EROFS;
|
return -EROFS;
|
||||||
|
|
||||||
ret = mnt_want_write(file->f_path.mnt);
|
ret = mnt_want_write_file(file);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -2549,7 +2549,7 @@ static long btrfs_ioctl_trans_start(struct file *file)
|
|||||||
if (btrfs_root_readonly(root))
|
if (btrfs_root_readonly(root))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = mnt_want_write(file->f_path.mnt);
|
ret = mnt_want_write_file(file);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||||||
case EXT2_IOC_SETFLAGS: {
|
case EXT2_IOC_SETFLAGS: {
|
||||||
unsigned int oldflags;
|
unsigned int oldflags;
|
||||||
|
|
||||||
ret = mnt_want_write(filp->f_path.mnt);
|
ret = mnt_want_write_file(filp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ setflags_out:
|
|||||||
case EXT2_IOC_SETVERSION:
|
case EXT2_IOC_SETVERSION:
|
||||||
if (!inode_owner_or_capable(inode))
|
if (!inode_owner_or_capable(inode))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
ret = mnt_want_write(filp->f_path.mnt);
|
ret = mnt_want_write_file(filp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if (get_user(inode->i_generation, (int __user *) arg)) {
|
if (get_user(inode->i_generation, (int __user *) arg)) {
|
||||||
@@ -121,7 +121,7 @@ setflags_out:
|
|||||||
if (get_user(rsv_window_size, (int __user *)arg))
|
if (get_user(rsv_window_size, (int __user *)arg))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
ret = mnt_want_write(filp->f_path.mnt);
|
ret = mnt_want_write_file(filp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||||||
if (get_user(flags, (int __user *) arg))
|
if (get_user(flags, (int __user *) arg))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ flags_out:
|
|||||||
if (!inode_owner_or_capable(inode))
|
if (!inode_owner_or_capable(inode))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
if (get_user(generation, (int __user *) arg)) {
|
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))
|
if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ setrsvsz_out:
|
|||||||
if (!capable(CAP_SYS_RESOURCE))
|
if (!capable(CAP_SYS_RESOURCE))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ group_extend_out:
|
|||||||
if (!capable(CAP_SYS_RESOURCE))
|
if (!capable(CAP_SYS_RESOURCE))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||||||
if (get_user(flags, (int __user *) arg))
|
if (get_user(flags, (int __user *) arg))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ flags_out:
|
|||||||
if (!inode_owner_or_capable(inode))
|
if (!inode_owner_or_capable(inode))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
if (get_user(generation, (int __user *) arg)) {
|
if (get_user(generation, (int __user *) arg)) {
|
||||||
@@ -192,7 +192,7 @@ setversion_out:
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ setversion_out:
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
goto mext_out;
|
goto mext_out;
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ mext_out:
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ mext_out:
|
|||||||
if (!inode_owner_or_capable(inode))
|
if (!inode_owner_or_capable(inode))
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
/*
|
/*
|
||||||
@@ -323,7 +323,7 @@ mext_out:
|
|||||||
if (!inode_owner_or_capable(inode))
|
if (!inode_owner_or_capable(inode))
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
err = ext4_alloc_da_blocks(inode);
|
err = ext4_alloc_da_blocks(inode);
|
||||||
|
@@ -44,7 +44,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
err = mnt_want_write(file->f_path.mnt);
|
err = mnt_want_write_file(file);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_unlock_inode;
|
goto out_unlock_inode;
|
||||||
|
|
||||||
|
@@ -223,7 +223,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
|
|||||||
int error;
|
int error;
|
||||||
u32 new_flags, flags;
|
u32 new_flags, flags;
|
||||||
|
|
||||||
error = mnt_want_write(filp->f_path.mnt);
|
error = mnt_want_write_file(filp);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
|
|||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
err = mnt_want_write(file->f_path.mnt);
|
err = mnt_want_write_file(file);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||||||
unsigned int oldflags;
|
unsigned int oldflags;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@@ -147,7 +147,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
|
|||||||
status = -EEXIST;
|
status = -EEXIST;
|
||||||
if (dentry->d_inode)
|
if (dentry->d_inode)
|
||||||
goto out_put;
|
goto out_put;
|
||||||
status = mnt_want_write(rec_file->f_path.mnt);
|
status = mnt_want_write_file(rec_file);
|
||||||
if (status)
|
if (status)
|
||||||
goto out_put;
|
goto out_put;
|
||||||
status = vfs_mkdir(dir->d_inode, dentry, S_IRWXU);
|
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)
|
if (!rec_file || !clp->cl_firststate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
status = mnt_want_write(rec_file->f_path.mnt);
|
status = mnt_want_write_file(rec_file);
|
||||||
if (status)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
clp->cl_firststate = 0;
|
clp->cl_firststate = 0;
|
||||||
@@ -311,7 +311,7 @@ nfsd4_recdir_purge_old(void) {
|
|||||||
|
|
||||||
if (!rec_file)
|
if (!rec_file)
|
||||||
return;
|
return;
|
||||||
status = mnt_want_write(rec_file->f_path.mnt);
|
status = mnt_want_write_file(rec_file);
|
||||||
if (status)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
status = nfsd4_list_rec_dir(purge_old);
|
status = nfsd4_list_rec_dir(purge_old);
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
|
#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
#include <linux/compat.h> /* compat_ptr() */
|
#include <linux/compat.h> /* compat_ptr() */
|
||||||
#include <linux/mount.h> /* mnt_want_write(), mnt_drop_write() */
|
#include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write() */
|
||||||
#include <linux/buffer_head.h>
|
#include <linux/buffer_head.h>
|
||||||
#include <linux/nilfs2_fs.h>
|
#include <linux/nilfs2_fs.h>
|
||||||
#include "nilfs.h"
|
#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))
|
if (get_user(flags, (int __user *)argp))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
ret = mnt_want_write(filp->f_path.mnt);
|
ret = mnt_want_write_file(filp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
|
|||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
ret = mnt_want_write(filp->f_path.mnt);
|
ret = mnt_want_write_file(filp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp,
|
|||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
ret = mnt_want_write(filp->f_path.mnt);
|
ret = mnt_want_write_file(filp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -591,7 +591,7 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
|
|||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
ret = mnt_want_write(filp->f_path.mnt);
|
ret = mnt_want_write_file(filp);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -710,7 +710,7 @@ static int nilfs_ioctl_resize(struct inode *inode, struct file *filp,
|
|||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = mnt_want_write(filp->f_path.mnt);
|
ret = mnt_want_write_file(filp);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@@ -906,7 +906,7 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||||||
if (get_user(flags, (int __user *) arg))
|
if (get_user(flags, (int __user *) arg))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
status = mnt_want_write(filp->f_path.mnt);
|
status = mnt_want_write_file(filp);
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
status = ocfs2_set_inode_attr(inode, flags,
|
status = ocfs2_set_inode_attr(inode, flags,
|
||||||
|
@@ -1059,7 +1059,7 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
|
|||||||
struct ocfs2_move_extents range;
|
struct ocfs2_move_extents range;
|
||||||
struct ocfs2_move_extents_context *context = NULL;
|
struct ocfs2_move_extents_context *context = NULL;
|
||||||
|
|
||||||
status = mnt_want_write(filp->f_path.mnt);
|
status = mnt_want_write_file(filp);
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
@@ -55,7 +55,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ setflags_out:
|
|||||||
err = -EPERM;
|
err = -EPERM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
err = mnt_want_write(filp->f_path.mnt);
|
err = mnt_want_write_file(filp);
|
||||||
if (err)
|
if (err)
|
||||||
break;
|
break;
|
||||||
if (get_user(inode->i_generation, (int __user *)arg)) {
|
if (get_user(inode->i_generation, (int __user *)arg)) {
|
||||||
|
@@ -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
|
* Make sure the file-system is read-write and make sure it
|
||||||
* will not become read-only while we are changing the flags.
|
* 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)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags);
|
dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags);
|
||||||
|
@@ -559,7 +559,7 @@ xfs_attrmulti_by_handle(
|
|||||||
ops[i].am_flags);
|
ops[i].am_flags);
|
||||||
break;
|
break;
|
||||||
case ATTR_OP_SET:
|
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)
|
if (ops[i].am_error)
|
||||||
break;
|
break;
|
||||||
ops[i].am_error = xfs_attrmulti_attr_set(
|
ops[i].am_error = xfs_attrmulti_attr_set(
|
||||||
@@ -569,7 +569,7 @@ xfs_attrmulti_by_handle(
|
|||||||
mnt_drop_write(parfilp->f_path.mnt);
|
mnt_drop_write(parfilp->f_path.mnt);
|
||||||
break;
|
break;
|
||||||
case ATTR_OP_REMOVE:
|
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)
|
if (ops[i].am_error)
|
||||||
break;
|
break;
|
||||||
ops[i].am_error = xfs_attrmulti_attr_remove(
|
ops[i].am_error = xfs_attrmulti_attr_remove(
|
||||||
|
@@ -454,7 +454,7 @@ xfs_compat_attrmulti_by_handle(
|
|||||||
&ops[i].am_length, ops[i].am_flags);
|
&ops[i].am_length, ops[i].am_flags);
|
||||||
break;
|
break;
|
||||||
case ATTR_OP_SET:
|
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)
|
if (ops[i].am_error)
|
||||||
break;
|
break;
|
||||||
ops[i].am_error = xfs_attrmulti_attr_set(
|
ops[i].am_error = xfs_attrmulti_attr_set(
|
||||||
@@ -464,7 +464,7 @@ xfs_compat_attrmulti_by_handle(
|
|||||||
mnt_drop_write(parfilp->f_path.mnt);
|
mnt_drop_write(parfilp->f_path.mnt);
|
||||||
break;
|
break;
|
||||||
case ATTR_OP_REMOVE:
|
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)
|
if (ops[i].am_error)
|
||||||
break;
|
break;
|
||||||
ops[i].am_error = xfs_attrmulti_attr_remove(
|
ops[i].am_error = xfs_attrmulti_attr_remove(
|
||||||
|
Reference in New Issue
Block a user