vfs: mnt_drop_write_file()
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 9 Dec 2011 13:06:57 +0000 (08:06 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 4 Jan 2012 03:52:40 +0000 (22:52 -0500)
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>
22 files changed:
fs/btrfs/ioctl.c
fs/ext2/ioctl.c
fs/ext3/ioctl.c
fs/ext4/ioctl.c
fs/fat/file.c
fs/gfs2/file.c
fs/hfsplus/ioctl.c
fs/inode.c
fs/jfs/ioctl.c
fs/namespace.c
fs/ncpfs/ioctl.c
fs/nfsd/nfs4recover.c
fs/nilfs2/ioctl.c
fs/ocfs2/ioctl.c
fs/ocfs2/move_extents.c
fs/open.c
fs/reiserfs/ioctl.c
fs/ubifs/ioctl.c
fs/xattr.c
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_ioctl32.c
include/linux/mount.h

index 20dd8f3b6c7204e432a91463f8c175620acff084..5441ff1480fdbbd9ce9fe4c9caa6fc0c62392a3c 100644 (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 @@ 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;
 }
 
index 61a3f9661728730f5ed91c89e5f98b3dfb72ffdd..1089f760c8470f25c0cac5744c880de9377775d5 100644 (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 @@ 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:
index a02863a080d339529ec4cffa4098cade1afc7bfd..8e37c41a071b31e90756f9b0762e37a2ac362065 100644 (file)
@@ -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: {
index 9a49760b554d7645e4d630788677a9dbfc4d31b7..d37b3bb2a3b8748b79f3c0e02ab4c17909c5f189 100644 (file)
@@ -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;
        }
 
index 50746a1a07891ecdcbaa4e9abfa566d6451bc65f..d81d01a99b2ccc9c85a84a5882c17b6c29861081 100644 (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:
index 28fc6e3855f3585b3bf90ba78f9af4953fbc9add..b8927d4f3bf20a662b14a766ae6a84a1a70e32cd 100644 (file)
@@ -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;
 }
 
index 31d3fe576429b2692e71c9a6d867329197b29eac..f66c7655b3f7f0d74234f2f70ab7cb4302bb078c 100644 (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;
 }
index ee4e66b998f40d170b1822db68875df73d445db6..4fda5ee855187d5a015b808fd83b9881bf4427a7 100644 (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);
 
index 73d9eaa91c0590373322654afb5a27b40da8387b..f19d1e04a374b39e9dc97779f9539d5598f032dd 100644 (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:
index 7a8f949cec1baeb1e6bab2ecee8400a4d43cbcad..86b4f6406470f9b6eb6e09c9bfe077179edda24e 100644 (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;
index 790e92a9ec63b661172b13af0615541c7fce06d8..6958adfaff084e71fa66a1f7e10a00ad82fd8f60 100644 (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;
 }
index a9aa2f161262abf780f51dcdd67bd396d1273b85..80a0be9ed008a6db484d81303379d0a599c5dad7 100644 (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"
index b7697d1ccd613774f4a6cd3dc790491ff20ad53e..886649627c3d68d568914ee3d88983cbebcf08a5 100644 (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 @@ 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;
 }
index 892ace253f9725bf59e9d11742284157a5928ecc..a6fda3c188aa84a85af41aa42b0b64feac31b410 100644 (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:
index 1d3bf83f8b8528cc22143399d17eafd58db845fd..b1e3fce72ea4767bf795c692e98faacebc42797c 100644 (file)
@@ -1145,7 +1145,7 @@ out:
 
        kfree(context);
 
-       mnt_drop_write(filp->f_path.mnt);
+       mnt_drop_write_file(filp);
 
        return status;
 }
index 22c41b543f2dfc00ce74665e4fdf24db1d8321ac..4ef8d868a44802fa29a0c03eaf57f461acbe9478 100644 (file)
--- 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:
index 0b94d7b2b11f0be6565811ba360461eff84441c7..950e3d1b5c9e563d4dd0fc13c6dfc7ea5ba3a85c 100644 (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 @@ 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;
index e52c84598feb3662734fad100e376b345d92c289..1a7e2d8bdbe92c7145c23c9d82382bcc157b12b2 100644 (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;
        }
 
index 67583de8218cf54213379f586926824f30da5350..82f43376c7cdff1b9acd2b74e31c8e331fb5c307 100644 (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;
index b436e17c753e0d65b125c0cc1cbcaeb2ced2746a..76f3ca5cfc361f962fa40a72243a525f191a618f 100644 (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;
index dd4ba1d4c5826e02a57876d3ab40c0f93bb700a1..f9ccb7b7c043bc0d9524fae8f3afa59975bf32ce 100644 (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;
index 65c1bb0138368b3ea0c7a6a5bf05f2b4bb24354e..00f5c4f2160b26ac018c8be432a4fbebdd92a23d 100644 (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);