From patchwork Fri Apr 3 01:56:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Eric W. Biederman" X-Patchwork-Id: 6153171 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2FF709F2EC for ; Fri, 3 Apr 2015 02:00:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4651020379 for ; Fri, 3 Apr 2015 02:00:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52BA62035E for ; Fri, 3 Apr 2015 02:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753310AbbDCCAg (ORCPT ); Thu, 2 Apr 2015 22:00:36 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:45017 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbbDCCAf (ORCPT ); Thu, 2 Apr 2015 22:00:35 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1YdquQ-0002sq-PV; Thu, 02 Apr 2015 20:00:34 -0600 Received: from 70-59-163-10.omah.qwest.net ([70.59.163.10] helo=x220.int.ebiederm.org) by in01.mta.xmission.com with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1YdquQ-0003Lp-7f; Thu, 02 Apr 2015 20:00:34 -0600 From: "Eric W. Biederman" To: Linux Containers Cc: , "Serge E. Hallyn" , Andy Lutomirski , Richard Weinberger , Andrey Vagin , Al Viro , Jann Horn , Willy Tarreau , Omar Sandoval Date: Thu, 2 Apr 2015 20:56:10 -0500 Message-Id: <1428026183-14879-6-git-send-email-ebiederm@xmission.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: <87a8yqou41.fsf_-_@x220.int.ebiederm.org> References: <87a8yqou41.fsf_-_@x220.int.ebiederm.org> X-XM-AID: U2FsdGVkX19nLjI2tVo0dP3HMOw5YNrl+J0Ps4HIjcU= X-SA-Exim-Connect-IP: 70.59.163.10 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-DCC: XMission; sa05 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Linux Containers X-Spam-Relay-Country: X-Spam-Timing: total 218 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 3.1 (1.4%), b_tie_ro: 2.3 (1.1%), parse: 0.59 (0.3%), extract_message_metadata: 10 (4.4%), get_uri_detail_list: 1.37 (0.6%), tests_pri_-1000: 4.7 (2.2%), tests_pri_-950: 1.00 (0.5%), tests_pri_-900: 0.84 (0.4%), tests_pri_-400: 18 (8.2%), check_bayes: 17 (7.8%), b_tokenize: 5 (2.4%), b_tok_get_all: 6 (2.7%), b_comp_prob: 1.34 (0.6%), b_tok_touch_all: 2.7 (1.2%), b_finish: 0.63 (0.3%), tests_pri_0: 174 (80.0%), tests_pri_500: 3.4 (1.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH review 06/19] mnt: Delay removal from the mount hash. X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - Modify __lookup_mnt_hash_last to ignore mounts that have MNT_UMOUNTED set. - Don't remove mounts from the mount hash table in propogate_umount - Don't remove mounts from the mount hash table in umount_tree before the entire list of mounts to be umounted is selected. - Remove mounts from the mount hash table as the last thing that happens in the case where a mount has a parent in umount_tree. Mounts without parents are not hashed (by definition). This paves the way for delaying removal from the mount hash table even farther and fixing the MNT_LOCKED vs MNT_DETACH issue. Cc: stable@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- fs/namespace.c | 13 ++++++++----- fs/pnode.c | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index d1708147eb45..083e3401a808 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -632,14 +632,17 @@ struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry) */ struct mount *__lookup_mnt_last(struct vfsmount *mnt, struct dentry *dentry) { - struct mount *p, *res; - res = p = __lookup_mnt(mnt, dentry); + struct mount *p, *res = NULL; + p = __lookup_mnt(mnt, dentry); if (!p) goto out; + if (!(p->mnt.mnt_flags & MNT_UMOUNT)) + res = p; hlist_for_each_entry_continue(p, mnt_hash) { if (&p->mnt_parent->mnt != mnt || p->mnt_mountpoint != dentry) break; - res = p; + if (!(p->mnt.mnt_flags & MNT_UMOUNT)) + res = p; } out: return res; @@ -1336,9 +1339,8 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) list_move(&p->mnt_list, &tmp_list); } - /* Hide the mounts from lookup_mnt and mnt_mounts */ + /* Hide the mounts from mnt_mounts */ list_for_each_entry(p, &tmp_list, mnt_list) { - hlist_del_init_rcu(&p->mnt_hash); list_del_init(&p->mnt_child); } @@ -1365,6 +1367,7 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) p->mnt_mountpoint = p->mnt.mnt_root; p->mnt_parent = p; p->mnt_mp = NULL; + hlist_del_init_rcu(&p->mnt_hash); } change_mnt_propagation(p, MS_PRIVATE); } diff --git a/fs/pnode.c b/fs/pnode.c index ac3aa0d43b90..c27ae38ee250 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -383,7 +383,6 @@ static void __propagate_umount(struct mount *mnt) */ if (child && list_empty(&child->mnt_mounts)) { list_del_init(&child->mnt_child); - hlist_del_init_rcu(&child->mnt_hash); child->mnt.mnt_flags |= MNT_UMOUNT; list_move_tail(&child->mnt_list, &mnt->mnt_list); }