[RFC PATCH 8/10] vfs: shared subtree aware namespaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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(+)

Index: 2.6.13.sharedsubtree/fs/namespace.c
===================================================================
--- 2.6.13.sharedsubtree.orig/fs/namespace.c
+++ 2.6.13.sharedsubtree/fs/namespace.c
@@ -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);
 }
Index: 2.6.13.sharedsubtree/fs/pnode.c
===================================================================
--- 2.6.13.sharedsubtree.orig/fs/pnode.c
+++ 2.6.13.sharedsubtree/fs/pnode.c
@@ -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);
Index: 2.6.13.sharedsubtree/include/linux/pnode.h
===================================================================
--- 2.6.13.sharedsubtree.orig/include/linux/pnode.h
+++ 2.6.13.sharedsubtree/include/linux/pnode.h
@@ -62,6 +62,7 @@ int propagate_commit_mount(struct vfsmou
 int 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 */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux