* [PATCH 0/2] Rename and export some vfs helpers
@ 2023-09-08 13:28 Amir Goldstein
2023-09-08 13:28 ` [PATCH 1/2] fs: rename __mnt_{want,drop}_write*() helpers Amir Goldstein
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Amir Goldstein @ 2023-09-08 13:28 UTC (permalink / raw)
To: Christian Brauner
Cc: Miklos Szeredi, Jan Kara, Christoph Hellwig, Al Viro,
linux-fsdevel
Christian,
This is the rename that you proposed, for the helpers needed by
overlayfs.
I could stage this in the overlayfs tree for 6.7, but it has a bit
of conflict potential, so maybe best if you stage this in vfs tree.
Perhaps on a topic branch that is expected to be a little more steady
than 'vfs.misc', so that I can base overlayfs-next on it?
Thanks,
Amir.
Amir Goldstein (2):
fs: rename __mnt_{want,drop}_write*() helpers
fs: export mnt_{get,put}_write_access() to modules
fs/inode.c | 8 ++++----
fs/internal.h | 12 ++++++------
fs/namespace.c | 36 +++++++++++++++++++-----------------
fs/open.c | 2 +-
include/linux/mount.h | 4 ++--
kernel/acct.c | 4 ++--
6 files changed, 34 insertions(+), 32 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] fs: rename __mnt_{want,drop}_write*() helpers
2023-09-08 13:28 [PATCH 0/2] Rename and export some vfs helpers Amir Goldstein
@ 2023-09-08 13:28 ` Amir Goldstein
2023-09-08 13:29 ` [PATCH 2/2] fs: export mnt_{get,put}_write_access() to modules Amir Goldstein
2023-09-11 13:09 ` [PATCH 0/2] Rename and export some vfs helpers Christian Brauner
2 siblings, 0 replies; 4+ messages in thread
From: Amir Goldstein @ 2023-09-08 13:28 UTC (permalink / raw)
To: Christian Brauner
Cc: Miklos Szeredi, Jan Kara, Christoph Hellwig, Al Viro,
linux-fsdevel
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>
---
fs/inode.c | 8 ++++----
fs/internal.h | 12 ++++++------
fs/namespace.c | 34 +++++++++++++++++-----------------
fs/open.c | 2 +-
include/linux/mount.h | 4 ++--
kernel/acct.c | 4 ++--
6 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 35fd688168c5..7febdc9fd1a9 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2006,7 +2006,7 @@ void touch_atime(const struct path *path)
if (!sb_start_write_trylock(inode->i_sb))
return;
- if (__mnt_want_write(mnt) != 0)
+ if (mnt_get_write_access(mnt) != 0)
goto skip_update;
/*
* 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.
*/
inode_update_time(inode, S_ATIME);
- __mnt_drop_write(mnt);
+ mnt_put_write_access(mnt);
skip_update:
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);
/* 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);
- __mnt_drop_write_file(file);
+ mnt_put_write_access_file(file);
}
return ret;
diff --git a/fs/internal.h b/fs/internal.h
index d64ae03998cc..8260c738980c 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -73,8 +73,8 @@ extern int sb_prepare_remount_readonly(struct super_block *);
extern void __init mnt_init(void);
-extern int __mnt_want_write_file(struct file *);
-extern void __mnt_drop_write_file(struct file *);
+int mnt_get_write_access_file(struct file *file);
+void mnt_put_write_access_file(struct file *file);
extern void dissolve_on_fput(struct vfsmount *);
extern bool may_mount(void);
@@ -101,7 +101,7 @@ static inline void put_file_access(struct file *file)
i_readcount_dec(file->f_inode);
} else if (file->f_mode & FMODE_WRITER) {
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
* cleared, it will see s_readonly_remount set.
* For RW->RO transition, the barrier pairs with the barrier in
- * __mnt_want_write() before the mnt_is_readonly() check. The barrier
- * makes sure if __mnt_want_write() sees MNT_WRITE_HOLD already
- * cleared, it will see s_readonly_remount set.
+ * mnt_get_write_access() before the mnt_is_readonly() check.
+ * The barrier makes sure if mnt_get_write_access() sees MNT_WRITE_HOLD
+ * already cleared, it will see s_readonly_remount set.
*/
smp_wmb();
}
diff --git a/fs/namespace.c b/fs/namespace.c
index e157efc54023..3fe7c0484e6a 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -330,16 +330,16 @@ static int mnt_is_readonly(struct vfsmount *mnt)
* 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
*
* 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
* 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.
*/
-int __mnt_want_write(struct vfsmount *m)
+int mnt_get_write_access(struct vfsmount *m)
{
struct mount *mnt = real_mount(m);
int ret = 0;
@@ -401,7 +401,7 @@ int mnt_want_write(struct vfsmount *m)
int ret;
sb_start_write(m->mnt_sb);
- ret = __mnt_want_write(m);
+ ret = mnt_get_write_access(m);
if (ret)
sb_end_write(m->mnt_sb);
return ret;
@@ -409,15 +409,15 @@ int mnt_want_write(struct vfsmount *m)
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
*
- * 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)
* 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) {
/*
@@ -428,7 +428,7 @@ int __mnt_want_write_file(struct file *file)
return -EROFS;
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;
sb_start_write(file_inode(file)->i_sb);
- ret = __mnt_want_write_file(file);
+ ret = mnt_get_write_access_file(file);
if (ret)
sb_end_write(file_inode(file)->i_sb);
return ret;
@@ -453,14 +453,14 @@ int mnt_want_write_file(struct file *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
*
* Tells the low-level filesystem that we are done
* 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();
mnt_dec_writers(real_mount(mnt));
@@ -477,20 +477,20 @@ 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);
}
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))
- __mnt_drop_write(file->f_path.mnt);
+ mnt_put_write_access(file->f_path.mnt);
}
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);
}
EXPORT_SYMBOL(mnt_drop_write_file);
diff --git a/fs/open.c b/fs/open.c
index 98f6601fbac6..a65ce47810cf 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -895,7 +895,7 @@ static int do_dentry_open(struct file *f,
error = get_write_access(inode);
if (unlikely(error))
goto cleanup_file;
- error = __mnt_want_write(f->f_path.mnt);
+ error = mnt_get_write_access(f->f_path.mnt);
if (unlikely(error)) {
put_write_access(inode);
goto cleanup_file;
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 4f40b40306d0..ac3dd2876197 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -92,8 +92,8 @@ extern bool __mnt_is_readonly(struct vfsmount *mnt);
extern bool mnt_may_suid(struct vfsmount *mnt);
extern struct vfsmount *clone_private_mount(const struct path *path);
-extern int __mnt_want_write(struct vfsmount *);
-extern void __mnt_drop_write(struct vfsmount *);
+int mnt_get_write_access(struct vfsmount *mnt);
+void mnt_put_write_access(struct vfsmount *mnt);
extern struct vfsmount *fc_mount(struct fs_context *fc);
extern struct vfsmount *vfs_create_mount(struct fs_context *fc);
diff --git a/kernel/acct.c b/kernel/acct.c
index 1a9f929fe629..986c8214dabf 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -246,7 +246,7 @@ static int acct_on(struct filename *pathname)
filp_close(file, NULL);
return PTR_ERR(internal);
}
- err = __mnt_want_write(internal);
+ err = mnt_get_write_access(internal);
if (err) {
mntput(internal);
kfree(acct);
@@ -271,7 +271,7 @@ static int acct_on(struct filename *pathname)
old = xchg(&ns->bacct, &acct->pin);
mutex_unlock(&acct->lock);
pin_kill(old);
- __mnt_drop_write(mnt);
+ mnt_put_write_access(mnt);
mntput(mnt);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] fs: export mnt_{get,put}_write_access() to modules
2023-09-08 13:28 [PATCH 0/2] Rename and export some vfs helpers Amir Goldstein
2023-09-08 13:28 ` [PATCH 1/2] fs: rename __mnt_{want,drop}_write*() helpers Amir Goldstein
@ 2023-09-08 13:29 ` Amir Goldstein
2023-09-11 13:09 ` [PATCH 0/2] Rename and export some vfs helpers Christian Brauner
2 siblings, 0 replies; 4+ messages in thread
From: Amir Goldstein @ 2023-09-08 13:29 UTC (permalink / raw)
To: Christian Brauner
Cc: Miklos Szeredi, Jan Kara, Christoph Hellwig, Al Viro,
linux-fsdevel
Overlayfs is going to use those to get write access on the upper mount
during entire copy up without taking freeze protection on upper sb for
the entire copy up.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/namespace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/namespace.c b/fs/namespace.c
index 3fe7c0484e6a..9e0ea73f2ff9 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -386,6 +386,7 @@ int mnt_get_write_access(struct vfsmount *m)
return ret;
}
+EXPORT_SYMBOL_GPL(mnt_get_write_access);
/**
* mnt_want_write - get write access to a mount
@@ -466,6 +467,7 @@ void mnt_put_write_access(struct vfsmount *mnt)
mnt_dec_writers(real_mount(mnt));
preempt_enable();
}
+EXPORT_SYMBOL_GPL(mnt_put_write_access);
/**
* mnt_drop_write - give up write access to a mount
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Rename and export some vfs helpers
2023-09-08 13:28 [PATCH 0/2] Rename and export some vfs helpers Amir Goldstein
2023-09-08 13:28 ` [PATCH 1/2] fs: rename __mnt_{want,drop}_write*() helpers Amir Goldstein
2023-09-08 13:29 ` [PATCH 2/2] fs: export mnt_{get,put}_write_access() to modules Amir Goldstein
@ 2023-09-11 13:09 ` Christian Brauner
2 siblings, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2023-09-11 13:09 UTC (permalink / raw)
To: Amir Goldstein
Cc: Christian Brauner, Miklos Szeredi, Jan Kara, Christoph Hellwig,
Al Viro, linux-fsdevel
On Fri, 08 Sep 2023 16:28:58 +0300, Amir Goldstein wrote:
> Christian,
>
> This is the rename that you proposed, for the helpers needed by
> overlayfs.
>
> I could stage this in the overlayfs tree for 6.7, but it has a bit
> of conflict potential, so maybe best if you stage this in vfs tree.
>
> [...]
Applied to a branch that's expected to stay stable on v6.6-rc1. I have
no strong feelings about these exports so if someone does, please yell.
---
Applied to the vfs.mount.write branch of the vfs/vfs.git tree.
Patches in the vfs.mount.write branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.mount.write
[1/2] fs: rename __mnt_{want,drop}_write*() helpers
https://git.kernel.org/vfs/vfs/c/3e15dcf77b23
[2/2] fs: export mnt_{get,put}_write_access() to modules
https://git.kernel.org/vfs/vfs/c/ddf9e2ff67a9
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-11 21:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08 13:28 [PATCH 0/2] Rename and export some vfs helpers Amir Goldstein
2023-09-08 13:28 ` [PATCH 1/2] fs: rename __mnt_{want,drop}_write*() helpers Amir Goldstein
2023-09-08 13:29 ` [PATCH 2/2] fs: export mnt_{get,put}_write_access() to modules Amir Goldstein
2023-09-11 13:09 ` [PATCH 0/2] Rename and export some vfs helpers Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).