vfs: shared subtree aware namespaces
RFC PATCH 8/10 vfs: shared subtree aware namespaces
Patch that help setup the correct propagation for the mounts under the new cloned namespace.
Signed by Ram Pai ([email protected])
fs/namespace.c | 14 ++++++++++++++ fs/pnode.c | 17 +++++++++++++++++ include/linux/pnode.h | 1 + 3 files changed, 32 insertions(+)
fs/namespace.c +14 -0
@@ -1572,11 +1572,22 @@ int copy_namespace(int flags, struct tas* fs_struct, so tsk->fs->lock is not needed. */ p = namespace->root; q = new_ns->root;while (p) { +if (IS_MNT_UNCLONABLE (p)) { + p =skip_mnt_tree (p); + p =next_mnt (p, namespace->root); +continue ; + } q->mnt_namespace = new_ns; +/* +* release the reference to q->mnt_master +* held in clone_mnt() +*/ +mntput (q->mnt_master); +copy_propagation (p, q);if (fs) {if (p == fs->rootmnt) { rootmnt = p; fs->rootmnt =mntget (q); }
@@ -1949,14 +1960,17 @@ void __init mnt_init(unsigned long mempa }void __put_namespace (struct namespace *namespace) {struct vfsmount *root = namespace->root; +struct vfsmount *mnt; namespace->root =NULL ;spin_unlock (&vfsmount_lock);down_write (&namespace_sem);spin_lock (&vfsmount_lock); +list_for_each_entry (mnt, &namespace->list, mnt_list) +do_make_private (mnt);umount_tree (root);spin_unlock (&vfsmount_lock);up_write (&namespace_sem);kfree (namespace); }
fs/pnode.c +17 -0
@@ -175,10 +175,27 @@ void pnode_slave_mount(struct vfsmount * first->mnt_master = second->mnt_master;list_add (&first->mnt_slave, &second->mnt_slave);spin_unlock (&vfspnode_lock); } +/* +* set up the same propagation for mount @new as +* that of mount @old' +*/ +void copy_propagation (struct vfsmount *old,struct vfsmount *new) +{ +spin_lock (&vfspnode_lock); + new->mnt_master =NULL ; +if (IS_MNT_SHARED (old)) +list_add_tail (&new->mnt_share, &old->mnt_share); +else if (IS_MNT_SLAVE (old)) { +list_add_tail (&new->mnt_slave, &old->mnt_slave); + new->mnt_master = old->mnt_master; + } +spin_unlock (&vfspnode_lock); +} +static int check_peer (struct vfsmount *start,struct vfsmount *orig) {struct vfsmount *m = start; do { m = next_shared(m);
include/linux/pnode.h +1 -0
@@ -62,6 +62,7 @@ int propagate_commit_mount(struct vfsmouint propagate_abort_mount (struct vfsmount *);int propagate_prepare_mount (struct vfsmount *,struct dentry *,struct vfsmount *);int propagate_umount (struct vfsmount *);int propagate_mount_busy (struct vfsmount *,int ); +void copy_propagation (struct vfsmount *,struct vfsmount *);#endif /* _LINUX_PNODE_H */
Quoted 2 lines · Ram
Patch that help setup the correct propagation for the mounts under the new cloned namespace.
_definitely_ should go earlier in the series.