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 <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2011-12-09 08:06:57 -05:00
parent 8c9379e972
commit 2a79f17e4a
22 changed files with 55 additions and 48 deletions

View File

@ -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 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
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 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
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;
}

View File

@ -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 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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:

View File

@ -110,7 +110,7 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
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 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
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 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (err == 0)
err = err2;
group_add_out:
mnt_drop_write(filp->f_path.mnt);
mnt_drop_write_file(filp);
return err;
}
case FITRIM: {

View File

@ -134,7 +134,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
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 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
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 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
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 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (err)
return err;
err = ext4_alloc_da_blocks(inode);
mnt_drop_write(filp->f_path.mnt);
mnt_drop_write_file(filp);
return err;
}

View File

@ -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:

View File

@ -285,7 +285,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
out:
gfs2_glock_dq_uninit(&gh);
out_drop_write:
mnt_drop_write(filp->f_path.mnt);
mnt_drop_write_file(filp);
return error;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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:

View File

@ -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;

View File

@ -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;
}

View File

@ -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"

View File

@ -27,7 +27,7 @@
#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
#include <linux/vmalloc.h>
#include <linux/compat.h> /* compat_ptr() */
#include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write() */
#include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write_file() */
#include <linux/buffer_head.h>
#include <linux/nilfs2_fs.h>
#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 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
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;
}

View File

@ -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:

View File

@ -1145,7 +1145,7 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
kfree(context);
mnt_drop_write(filp->f_path.mnt);
mnt_drop_write_file(filp);
return status;
}

View File

@ -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:

View File

@ -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 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);