fs: rename __mnt_{want,drop}_write*() helpers

Before exporting these helpers to modules, make their names more
meaningful.

The names mnt_{get,put)_write_access*() were chosen, because they rhyme
with the inode {get,put)_write_access() helpers, which have a very close
meaning for the inode object.

Suggested-by: Christian Brauner <brauner@kernel.org>
Link: https://lore.kernel.org/r/20230817-anfechtbar-ruhelosigkeit-8c6cca8443fc@brauner/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Message-Id: <20230908132900.2983519-2-amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Amir Goldstein 2023-09-08 16:28:59 +03:00 committed by Christian Brauner
parent 0bb80ecc33
commit 3e15dcf77b
No known key found for this signature in database
GPG key ID: 91C61BC06578DCA2
6 changed files with 32 additions and 32 deletions

View file

@ -2006,7 +2006,7 @@ void touch_atime(const struct path *path)
if (!sb_start_write_trylock(inode->i_sb)) if (!sb_start_write_trylock(inode->i_sb))
return; return;
if (__mnt_want_write(mnt) != 0) if (mnt_get_write_access(mnt) != 0)
goto skip_update; goto skip_update;
/* /*
* File systems can error out when updating inodes if they need to * File systems can error out when updating inodes if they need to
@ -2018,7 +2018,7 @@ void touch_atime(const struct path *path)
* of the fs read only, e.g. subvolumes in Btrfs. * of the fs read only, e.g. subvolumes in Btrfs.
*/ */
inode_update_time(inode, S_ATIME); inode_update_time(inode, S_ATIME);
__mnt_drop_write(mnt); mnt_put_write_access(mnt);
skip_update: skip_update:
sb_end_write(inode->i_sb); sb_end_write(inode->i_sb);
} }
@ -2173,9 +2173,9 @@ static int __file_update_time(struct file *file, int sync_mode)
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
/* try to update time settings */ /* try to update time settings */
if (!__mnt_want_write_file(file)) { if (!mnt_get_write_access_file(file)) {
ret = inode_update_time(inode, sync_mode); ret = inode_update_time(inode, sync_mode);
__mnt_drop_write_file(file); mnt_put_write_access_file(file);
} }
return ret; return ret;

View file

@ -73,8 +73,8 @@ extern int sb_prepare_remount_readonly(struct super_block *);
extern void __init mnt_init(void); extern void __init mnt_init(void);
extern int __mnt_want_write_file(struct file *); int mnt_get_write_access_file(struct file *file);
extern void __mnt_drop_write_file(struct file *); void mnt_put_write_access_file(struct file *file);
extern void dissolve_on_fput(struct vfsmount *); extern void dissolve_on_fput(struct vfsmount *);
extern bool may_mount(void); extern bool may_mount(void);
@ -101,7 +101,7 @@ static inline void put_file_access(struct file *file)
i_readcount_dec(file->f_inode); i_readcount_dec(file->f_inode);
} else if (file->f_mode & FMODE_WRITER) { } else if (file->f_mode & FMODE_WRITER) {
put_write_access(file->f_inode); put_write_access(file->f_inode);
__mnt_drop_write(file->f_path.mnt); mnt_put_write_access(file->f_path.mnt);
} }
} }
@ -130,9 +130,9 @@ static inline void sb_start_ro_state_change(struct super_block *sb)
* mnt_is_readonly() making sure if mnt_is_readonly() sees SB_RDONLY * mnt_is_readonly() making sure if mnt_is_readonly() sees SB_RDONLY
* cleared, it will see s_readonly_remount set. * cleared, it will see s_readonly_remount set.
* For RW->RO transition, the barrier pairs with the barrier in * For RW->RO transition, the barrier pairs with the barrier in
* __mnt_want_write() before the mnt_is_readonly() check. The barrier * mnt_get_write_access() before the mnt_is_readonly() check.
* makes sure if __mnt_want_write() sees MNT_WRITE_HOLD already * The barrier makes sure if mnt_get_write_access() sees MNT_WRITE_HOLD
* cleared, it will see s_readonly_remount set. * already cleared, it will see s_readonly_remount set.
*/ */
smp_wmb(); smp_wmb();
} }

View file

@ -330,16 +330,16 @@ static int mnt_is_readonly(struct vfsmount *mnt)
* can determine when writes are able to occur to a filesystem. * can determine when writes are able to occur to a filesystem.
*/ */
/** /**
* __mnt_want_write - get write access to a mount without freeze protection * mnt_get_write_access - get write access to a mount without freeze protection
* @m: 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 * This tells the low-level filesystem that a write is about to be performed to
* it, and makes sure that writes are allowed (mnt it read-write) before * it, and makes sure that writes are allowed (mnt it read-write) before
* returning success. This operation does not protect against filesystem being * returning success. This operation does not protect against filesystem being
* frozen. When the write operation is finished, __mnt_drop_write() must be * frozen. When the write operation is finished, mnt_put_write_access() must be
* called. This is effectively a refcount. * called. This is effectively a refcount.
*/ */
int __mnt_want_write(struct vfsmount *m) int mnt_get_write_access(struct vfsmount *m)
{ {
struct mount *mnt = real_mount(m); struct mount *mnt = real_mount(m);
int ret = 0; int ret = 0;
@ -401,7 +401,7 @@ int mnt_want_write(struct vfsmount *m)
int ret; int ret;
sb_start_write(m->mnt_sb); sb_start_write(m->mnt_sb);
ret = __mnt_want_write(m); ret = mnt_get_write_access(m);
if (ret) if (ret)
sb_end_write(m->mnt_sb); sb_end_write(m->mnt_sb);
return ret; return ret;
@ -409,15 +409,15 @@ int mnt_want_write(struct vfsmount *m)
EXPORT_SYMBOL_GPL(mnt_want_write); EXPORT_SYMBOL_GPL(mnt_want_write);
/** /**
* __mnt_want_write_file - get write access to a file's mount * mnt_get_write_access_file - get write access to a file's mount
* @file: the file who's mount on which to take a write * @file: the file who's mount on which to take a write
* *
* This is like __mnt_want_write, but if the file is already open for writing it * This is like mnt_get_write_access, but if @file is already open for write it
* skips incrementing mnt_writers (since the open file already has a reference) * skips incrementing mnt_writers (since the open file already has a reference)
* and instead only does the check for emergency r/o remounts. This must be * and instead only does the check for emergency r/o remounts. This must be
* paired with __mnt_drop_write_file. * paired with mnt_put_write_access_file.
*/ */
int __mnt_want_write_file(struct file *file) int mnt_get_write_access_file(struct file *file)
{ {
if (file->f_mode & FMODE_WRITER) { if (file->f_mode & FMODE_WRITER) {
/* /*
@ -428,7 +428,7 @@ int __mnt_want_write_file(struct file *file)
return -EROFS; return -EROFS;
return 0; return 0;
} }
return __mnt_want_write(file->f_path.mnt); return mnt_get_write_access(file->f_path.mnt);
} }
/** /**
@ -445,7 +445,7 @@ int mnt_want_write_file(struct file *file)
int ret; int ret;
sb_start_write(file_inode(file)->i_sb); sb_start_write(file_inode(file)->i_sb);
ret = __mnt_want_write_file(file); ret = mnt_get_write_access_file(file);
if (ret) if (ret)
sb_end_write(file_inode(file)->i_sb); sb_end_write(file_inode(file)->i_sb);
return ret; return ret;
@ -453,14 +453,14 @@ int mnt_want_write_file(struct file *file)
EXPORT_SYMBOL_GPL(mnt_want_write_file); EXPORT_SYMBOL_GPL(mnt_want_write_file);
/** /**
* __mnt_drop_write - give up write access to a mount * mnt_put_write_access - give up write access to a mount
* @mnt: the mount on which to give up write access * @mnt: the mount on which to give up write access
* *
* Tells the low-level filesystem that we are done * Tells the low-level filesystem that we are done
* performing writes to it. Must be matched with * performing writes to it. Must be matched with
* __mnt_want_write() call above. * mnt_get_write_access() call above.
*/ */
void __mnt_drop_write(struct vfsmount *mnt) void mnt_put_write_access(struct vfsmount *mnt)
{ {
preempt_disable(); preempt_disable();
mnt_dec_writers(real_mount(mnt)); mnt_dec_writers(real_mount(mnt));
@ -477,20 +477,20 @@ void __mnt_drop_write(struct vfsmount *mnt)
*/ */
void mnt_drop_write(struct vfsmount *mnt) void mnt_drop_write(struct vfsmount *mnt)
{ {
__mnt_drop_write(mnt); mnt_put_write_access(mnt);
sb_end_write(mnt->mnt_sb); sb_end_write(mnt->mnt_sb);
} }
EXPORT_SYMBOL_GPL(mnt_drop_write); EXPORT_SYMBOL_GPL(mnt_drop_write);
void __mnt_drop_write_file(struct file *file) void mnt_put_write_access_file(struct file *file)
{ {
if (!(file->f_mode & FMODE_WRITER)) if (!(file->f_mode & FMODE_WRITER))
__mnt_drop_write(file->f_path.mnt); mnt_put_write_access(file->f_path.mnt);
} }
void mnt_drop_write_file(struct file *file) void mnt_drop_write_file(struct file *file)
{ {
__mnt_drop_write_file(file); mnt_put_write_access_file(file);
sb_end_write(file_inode(file)->i_sb); sb_end_write(file_inode(file)->i_sb);
} }
EXPORT_SYMBOL(mnt_drop_write_file); EXPORT_SYMBOL(mnt_drop_write_file);

View file

@ -895,7 +895,7 @@ static int do_dentry_open(struct file *f,
error = get_write_access(inode); error = get_write_access(inode);
if (unlikely(error)) if (unlikely(error))
goto cleanup_file; goto cleanup_file;
error = __mnt_want_write(f->f_path.mnt); error = mnt_get_write_access(f->f_path.mnt);
if (unlikely(error)) { if (unlikely(error)) {
put_write_access(inode); put_write_access(inode);
goto cleanup_file; goto cleanup_file;

View file

@ -92,8 +92,8 @@ extern bool __mnt_is_readonly(struct vfsmount *mnt);
extern bool mnt_may_suid(struct vfsmount *mnt); extern bool mnt_may_suid(struct vfsmount *mnt);
extern struct vfsmount *clone_private_mount(const struct path *path); extern struct vfsmount *clone_private_mount(const struct path *path);
extern int __mnt_want_write(struct vfsmount *); int mnt_get_write_access(struct vfsmount *mnt);
extern void __mnt_drop_write(struct vfsmount *); void mnt_put_write_access(struct vfsmount *mnt);
extern struct vfsmount *fc_mount(struct fs_context *fc); extern struct vfsmount *fc_mount(struct fs_context *fc);
extern struct vfsmount *vfs_create_mount(struct fs_context *fc); extern struct vfsmount *vfs_create_mount(struct fs_context *fc);

View file

@ -246,7 +246,7 @@ static int acct_on(struct filename *pathname)
filp_close(file, NULL); filp_close(file, NULL);
return PTR_ERR(internal); return PTR_ERR(internal);
} }
err = __mnt_want_write(internal); err = mnt_get_write_access(internal);
if (err) { if (err) {
mntput(internal); mntput(internal);
kfree(acct); kfree(acct);
@ -271,7 +271,7 @@ static int acct_on(struct filename *pathname)
old = xchg(&ns->bacct, &acct->pin); old = xchg(&ns->bacct, &acct->pin);
mutex_unlock(&acct->lock); mutex_unlock(&acct->lock);
pin_kill(old); pin_kill(old);
__mnt_drop_write(mnt); mnt_put_write_access(mnt);
mntput(mnt); mntput(mnt);
return 0; return 0;
} }