Skip to content

Commit

Permalink
vfs: mnt_drop_write_file()
Browse files Browse the repository at this point in the history
new helper (wrapper around mnt_drop_write()) to be used in pair with
mnt_want_write_file().

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jan 4, 2012
1 parent 8c9379e commit 2a79f17
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 48 deletions.
12 changes: 6 additions & 6 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions fs/ext2/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions fs/ext3/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
14 changes: 7 additions & 7 deletions fs/ext4/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

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

Expand Down
2 changes: 1 addition & 1 deletion fs/fat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/hfsplus/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fs/ncpfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions fs/nfsd/nfs4recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions fs/nilfs2/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/move_extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions fs/reiserfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fs/ubifs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit 2a79f17

Please sign in to comment.