From patchwork Fri Apr 3 01:56:08 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: 6153151 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1C53CBF4A6 for ; Fri, 3 Apr 2015 02:00:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2038620379 for ; Fri, 3 Apr 2015 02:00:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1EDCD2035E for ; Fri, 3 Apr 2015 02:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753164AbbDCCAc (ORCPT ); Thu, 2 Apr 2015 22:00:32 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:44984 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbbDCCAa (ORCPT ); Thu, 2 Apr 2015 22:00:30 -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 1YdquM-0002rz-6Q; Thu, 02 Apr 2015 20:00:30 -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 1YdquL-0003Lp-HY; Thu, 02 Apr 2015 20:00:30 -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:08 -0500 Message-Id: <1428026183-14879-4-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: U2FsdGVkX18Yd3nrFFuGZ9pj5dBSqPSGt6pYbHqOeEw= 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; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Linux Containers X-Spam-Relay-Country: X-Spam-Timing: total 322 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 4.1 (1.3%), b_tie_ro: 3.0 (0.9%), parse: 1.06 (0.3%), extract_message_metadata: 15 (4.7%), get_uri_detail_list: 3.0 (0.9%), tests_pri_-1000: 6 (1.7%), tests_pri_-950: 1.29 (0.4%), tests_pri_-900: 1.12 (0.3%), tests_pri_-400: 22 (6.9%), check_bayes: 21 (6.5%), b_tokenize: 7 (2.2%), b_tok_get_all: 7 (2.2%), b_comp_prob: 1.77 (0.5%), b_tok_touch_all: 2.7 (0.8%), b_finish: 0.70 (0.2%), tests_pri_0: 264 (81.8%), tests_pri_500: 4.6 (1.4%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH review 04/19] mnt: In umount_tree reuse mnt_list instead of mnt_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 umount_tree builds a list of mounts that need to be unmounted. Utilize mnt_list for this purpose instead of mnt_hash. This begins to allow keeping a mount on the mnt_hash after it is unmounted, which is necessary for a properly functioning MNT_LOCKED implementation. The fact that mnt_list is an ordinary list makding available list_move is nice bonus. Cc: stable@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- fs/namespace.c | 20 +++++++++++--------- fs/pnode.c | 6 +++--- fs/pnode.h | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index c68d9fc912e7..54cbef129f4a 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1327,23 +1327,25 @@ enum umount_tree_flags { */ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) { - HLIST_HEAD(tmp_list); + LIST_HEAD(tmp_list); struct mount *p; - for (p = mnt; p; p = next_mnt(p, mnt)) { - hlist_del_init_rcu(&p->mnt_hash); - hlist_add_head(&p->mnt_hash, &tmp_list); - } + /* Gather the mounts to umount */ + for (p = mnt; p; p = next_mnt(p, mnt)) + list_move(&p->mnt_list, &tmp_list); - hlist_for_each_entry(p, &tmp_list, mnt_hash) + /* Hide the mounts from lookup_mnt and mnt_mounts */ + list_for_each_entry(p, &tmp_list, mnt_list) { + hlist_del_init_rcu(&p->mnt_hash); list_del_init(&p->mnt_child); + } + /* Add propogated mounts to the tmp_list */ if (how & UMOUNT_PROPAGATE) propagate_umount(&tmp_list); - while (!hlist_empty(&tmp_list)) { - p = hlist_entry(tmp_list.first, struct mount, mnt_hash); - hlist_del_init_rcu(&p->mnt_hash); + while (!list_empty(&tmp_list)) { + p = list_first_entry(&tmp_list, struct mount, mnt_list); list_del_init(&p->mnt_expire); list_del_init(&p->mnt_list); __touch_mnt_namespace(p->mnt_ns); diff --git a/fs/pnode.c b/fs/pnode.c index 260ac8f898a4..bf012af709dd 100644 --- a/fs/pnode.c +++ b/fs/pnode.c @@ -384,7 +384,7 @@ 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); - hlist_add_before_rcu(&child->mnt_hash, &mnt->mnt_hash); + list_move_tail(&child->mnt_list, &mnt->mnt_list); } } } @@ -396,11 +396,11 @@ static void __propagate_umount(struct mount *mnt) * * vfsmount lock must be held for write */ -int propagate_umount(struct hlist_head *list) +int propagate_umount(struct list_head *list) { struct mount *mnt; - hlist_for_each_entry(mnt, list, mnt_hash) + list_for_each_entry(mnt, list, mnt_list) __propagate_umount(mnt); return 0; } diff --git a/fs/pnode.h b/fs/pnode.h index 16afc3d6d2f2..aa6d65df7204 100644 --- a/fs/pnode.h +++ b/fs/pnode.h @@ -40,7 +40,7 @@ static inline void set_mnt_shared(struct mount *mnt) void change_mnt_propagation(struct mount *, int); int propagate_mnt(struct mount *, struct mountpoint *, struct mount *, struct hlist_head *); -int propagate_umount(struct hlist_head *); +int propagate_umount(struct list_head *); int propagate_mount_busy(struct mount *, int); void mnt_release_group_id(struct mount *); int get_dominating_id(struct mount *mnt, const struct path *root);