From: Lukas Czerner <lczerner@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, mbroz@redhat.com,
Lukas Czerner <lczerner@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH 2/2] vfs: Do not copy_tree() unnecessarily while mounting
Date: Fri, 25 May 2012 17:29:36 +0200 [thread overview]
Message-ID: <1337959776-16564-2-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1337959776-16564-1-git-send-email-lczerner@redhat.com>
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@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
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
next prev parent reply other threads:[~2012-05-25 15:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-25 15:29 [PATCH 1/2] vfs: Do not allow mnt_longterm to go negative Lukas Czerner
2012-05-25 15:29 ` Lukas Czerner [this message]
2012-05-29 10:56 ` Lukáš Czerner
2012-05-30 2:01 ` Al Viro
2012-05-30 3:40 ` Al Viro
2012-06-09 4:54 ` Al Viro
2012-06-11 10:00 ` Lukáš Czerner
2012-05-29 10:57 ` [PATCH v2] " Lukas Czerner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337959776-16564-2-git-send-email-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbroz@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).