mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
automount wart removal
Calling conventions of ->d_automount() made saner (flagday change) vfs_submount() is gone - its sole remaining user (trace_automount) had been switched to saner primitives. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQqUNBr3gm4hGXdBJlZ7Krx/gZQ6wUCaDoRWQAKCRBZ7Krx/gZQ 6wxMAQCzuMc2GiGBMXzeK4SGA7d5rsK71unf+zczOd8NvbTImQEAs1Cu3u3bF3pq EmHQWFTKBpBf+RHsLSoDHwUA+9THowM= =GXLi -----END PGP SIGNATURE----- Merge tag 'pull-automount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs Pull automount updates from Al Viro: "Automount wart removal A bunch of odd boilerplate gone from instances - the reason for those was the need to protect the yet-to-be-attched mount from mark_mounts_for_expiry() deciding to take it out. But that's easy to detect and take care of in mark_mounts_for_expiry() itself; no need to have every instance simulate mount being busy by grabbing an extra reference to it, with finish_automount() undoing that once it attaches that mount. Should've done it that way from the very beginning... This is a flagday change, thankfully there are very few instances. vfs_submount() is gone - its sole remaining user (trace_automount) had been switched to saner primitives" * tag 'pull-automount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: kill vfs_submount() saner calling conventions for ->d_automount()
This commit is contained in:
commit
0f70f5b08a
|
@ -1243,3 +1243,9 @@ arguments in the opposite order but is otherwise identical.
|
|||
|
||||
Using try_lookup_noperm() will require linux/namei.h to be included.
|
||||
|
||||
---
|
||||
|
||||
**mandatory**
|
||||
|
||||
Calling conventions for ->d_automount() have changed; we should *not* grab
|
||||
an extra reference to new mount - it should be returned with refcount 1.
|
||||
|
|
|
@ -1390,9 +1390,7 @@ defined:
|
|||
|
||||
If a vfsmount is returned, the caller will attempt to mount it
|
||||
on the mountpoint and will remove the vfsmount from its
|
||||
expiration list in the case of failure. The vfsmount should be
|
||||
returned with 2 refs on it to prevent automatic expiration - the
|
||||
caller will clean up the additional ref.
|
||||
expiration list in the case of failure.
|
||||
|
||||
This function is only used if DCACHE_NEED_AUTOMOUNT is set on
|
||||
the dentry. This is set by __d_instantiate() if S_AUTOMOUNT is
|
||||
|
|
|
@ -189,7 +189,6 @@ struct vfsmount *afs_d_automount(struct path *path)
|
|||
if (IS_ERR(newmnt))
|
||||
return newmnt;
|
||||
|
||||
mntget(newmnt); /* prevent immediate expiration */
|
||||
mnt_set_expiry(newmnt, &afs_vfsmounts);
|
||||
queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer,
|
||||
afs_mntpt_expiry_timeout * HZ);
|
||||
|
|
|
@ -319,9 +319,6 @@ static struct vfsmount *fuse_dentry_automount(struct path *path)
|
|||
|
||||
/* Create the submount */
|
||||
mnt = fc_mount(fsc);
|
||||
if (!IS_ERR(mnt))
|
||||
mntget(mnt);
|
||||
|
||||
put_fs_context(fsc);
|
||||
return mnt;
|
||||
}
|
||||
|
|
|
@ -1326,21 +1326,6 @@ struct vfsmount *vfs_kern_mount(struct file_system_type *type,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(vfs_kern_mount);
|
||||
|
||||
struct vfsmount *
|
||||
vfs_submount(const struct dentry *mountpoint, struct file_system_type *type,
|
||||
const char *name, void *data)
|
||||
{
|
||||
/* Until it is worked out how to pass the user namespace
|
||||
* through from the parent mount to the submount don't support
|
||||
* unprivileged mounts with submounts.
|
||||
*/
|
||||
if (mountpoint->d_sb->s_user_ns != &init_user_ns)
|
||||
return ERR_PTR(-EPERM);
|
||||
|
||||
return vfs_kern_mount(type, SB_SUBMOUNT, name, data);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vfs_submount);
|
||||
|
||||
static struct mount *clone_mnt(struct mount *old, struct dentry *root,
|
||||
int flag)
|
||||
{
|
||||
|
@ -3889,10 +3874,6 @@ int finish_automount(struct vfsmount *m, const struct path *path)
|
|||
return PTR_ERR(m);
|
||||
|
||||
mnt = real_mount(m);
|
||||
/* The new mount record should have at least 2 refs to prevent it being
|
||||
* expired before we get a chance to add it
|
||||
*/
|
||||
BUG_ON(mnt_get_count(mnt) < 2);
|
||||
|
||||
if (m->mnt_sb == path->mnt->mnt_sb &&
|
||||
m->mnt_root == dentry) {
|
||||
|
@ -3925,7 +3906,6 @@ int finish_automount(struct vfsmount *m, const struct path *path)
|
|||
unlock_mount(mp);
|
||||
if (unlikely(err))
|
||||
goto discard;
|
||||
mntput(m);
|
||||
return 0;
|
||||
|
||||
discard_locked:
|
||||
|
@ -3939,7 +3919,6 @@ discard:
|
|||
namespace_unlock();
|
||||
}
|
||||
mntput(m);
|
||||
mntput(m);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -3976,11 +3955,14 @@ void mark_mounts_for_expiry(struct list_head *mounts)
|
|||
|
||||
/* extract from the expiration list every vfsmount that matches the
|
||||
* following criteria:
|
||||
* - already mounted
|
||||
* - only referenced by its parent vfsmount
|
||||
* - still marked for expiry (marked on the last call here; marks are
|
||||
* cleared by mntput())
|
||||
*/
|
||||
list_for_each_entry_safe(mnt, next, mounts, mnt_expire) {
|
||||
if (!is_mounted(&mnt->mnt))
|
||||
continue;
|
||||
if (!xchg(&mnt->mnt_expiry_mark, 1) ||
|
||||
propagate_mount_busy(mnt, 1))
|
||||
continue;
|
||||
|
|
|
@ -195,7 +195,6 @@ struct vfsmount *nfs_d_automount(struct path *path)
|
|||
if (IS_ERR(mnt))
|
||||
goto out_fc;
|
||||
|
||||
mntget(mnt); /* prevent immediate expiration */
|
||||
if (timeout <= 0)
|
||||
goto out_fc;
|
||||
|
||||
|
|
|
@ -283,7 +283,6 @@ struct vfsmount *cifs_d_automount(struct path *path)
|
|||
return newmnt;
|
||||
}
|
||||
|
||||
mntget(newmnt); /* prevent immediate expiration */
|
||||
mnt_set_expiry(newmnt, &cifs_automount_list);
|
||||
schedule_delayed_work(&cifs_automount_task,
|
||||
cifs_mountpoint_expiry_timeout);
|
||||
|
|
|
@ -824,13 +824,6 @@ struct super_block *sget(struct file_system_type *type,
|
|||
struct super_block *old;
|
||||
int err;
|
||||
|
||||
/* We don't yet pass the user namespace of the parent
|
||||
* mount through to here so always use &init_user_ns
|
||||
* until that changes.
|
||||
*/
|
||||
if (flags & SB_SUBMOUNT)
|
||||
user_ns = &init_user_ns;
|
||||
|
||||
retry:
|
||||
spin_lock(&sb_lock);
|
||||
if (test) {
|
||||
|
@ -850,7 +843,7 @@ retry:
|
|||
}
|
||||
if (!s) {
|
||||
spin_unlock(&sb_lock);
|
||||
s = alloc_super(type, (flags & ~SB_SUBMOUNT), user_ns);
|
||||
s = alloc_super(type, flags, user_ns);
|
||||
if (!s)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
goto retry;
|
||||
|
|
|
@ -1250,7 +1250,6 @@ extern int send_sigurg(struct file *file);
|
|||
/* These sb flags are internal to the kernel */
|
||||
#define SB_DEAD BIT(21)
|
||||
#define SB_DYING BIT(24)
|
||||
#define SB_SUBMOUNT BIT(26)
|
||||
#define SB_FORCE BIT(27)
|
||||
#define SB_NOSEC BIT(28)
|
||||
#define SB_BORN BIT(29)
|
||||
|
|
|
@ -101,9 +101,6 @@ extern struct vfsmount *vfs_create_mount(struct fs_context *fc);
|
|||
extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
|
||||
int flags, const char *name,
|
||||
void *data);
|
||||
extern struct vfsmount *vfs_submount(const struct dentry *mountpoint,
|
||||
struct file_system_type *type,
|
||||
const char *name, void *data);
|
||||
|
||||
extern void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list);
|
||||
extern void mark_mounts_for_expiry(struct list_head *mounts);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include <linux/workqueue.h>
|
||||
#include <linux/sort.h>
|
||||
#include <linux/io.h> /* vmap_page_range() */
|
||||
#include <linux/fs_context.h>
|
||||
|
||||
#include <asm/setup.h> /* COMMAND_LINE_SIZE */
|
||||
|
||||
|
@ -10241,6 +10242,8 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
|
|||
{
|
||||
struct vfsmount *mnt;
|
||||
struct file_system_type *type;
|
||||
struct fs_context *fc;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* To maintain backward compatibility for tools that mount
|
||||
|
@ -10250,12 +10253,20 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
|
|||
type = get_fs_type("tracefs");
|
||||
if (!type)
|
||||
return NULL;
|
||||
mnt = vfs_submount(mntpt, type, "tracefs", NULL);
|
||||
put_filesystem(type);
|
||||
if (IS_ERR(mnt))
|
||||
return NULL;
|
||||
mntget(mnt);
|
||||
|
||||
fc = fs_context_for_submount(type, mntpt);
|
||||
put_filesystem(type);
|
||||
if (IS_ERR(fc))
|
||||
return ERR_CAST(fc);
|
||||
|
||||
ret = vfs_parse_fs_string(fc, "source",
|
||||
"tracefs", strlen("tracefs"));
|
||||
if (!ret)
|
||||
mnt = fc_mount(fc);
|
||||
else
|
||||
mnt = ERR_PTR(ret);
|
||||
|
||||
put_fs_context(fc);
|
||||
return mnt;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user