[PATCH 2/2] vfs: Do not copy_tree() unnecessarily while mounting

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

 



While mounting propagate_mnt() would walk through propagation tree
cloning the mount for every every mount the root propagates to.
Even for mounts which parents are not parents of the directory you're
trying to mount to.

Then before the propagate_mnt() is left it will clean the unneeded
cloned mounts (those which parent root is not parent of your new mount
point).

I think this whole operation is unnecessary and can be avoided by
skipping the copy_tree() if the propagated mount root is not
subdirectory of the directory you're mounting to. Such cloned mount
would be cleaned up later anyway.

Signed-off-by: Lukas Czerner <lczerner@xxxxxxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
---
 fs/pnode.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/pnode.c b/fs/pnode.c
index ab5fa9e..3ebf63d 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -237,22 +237,22 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry,
 
 		source =  get_source(m, prev_dest_mnt, prev_src_mnt, &type);
 
-		if (!(child = copy_tree(source, source->mnt.mnt_root, type))) {
-			ret = -ENOMEM;
-			list_splice(tree_list, tmp_list.prev);
-			goto out;
-		}
-
 		if (is_subdir(dest_dentry, m->mnt.mnt_root)) {
+			if (!(child = copy_tree(source,
+						source->mnt.mnt_root, type))) {
+				ret = -ENOMEM;
+				list_splice(tree_list, tmp_list.prev);
+				goto out;
+			}
+
 			mnt_set_mountpoint(m, dest_dentry, child);
 			list_add_tail(&child->mnt_hash, tree_list);
-		} else {
+		} else
 			/*
 			 * This can happen if the parent mount was bind mounted
 			 * on some subdirectory of a shared/slave mount.
 			 */
-			list_add_tail(&child->mnt_hash, &tmp_list);
-		}
+			continue;
 		prev_dest_mnt = m;
 		prev_src_mnt  = child;
 	}
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux