From patchwork Mon Mar 15 12:07:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 12139083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA43DC43331 for ; Mon, 15 Mar 2021 12:08:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EAF064EEE for ; Mon, 15 Mar 2021 12:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbhCOMIB (ORCPT ); Mon, 15 Mar 2021 08:08:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41064 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbhCOMH4 (ORCPT ); Mon, 15 Mar 2021 08:07:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615810076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EMY/gt5XSciN6cQxAWuIihEs18mKZz1X5H8/RDx4gWM=; b=HgmQ8CUk2HLG+++tkakaRvyhvUDRueQTL6HFrc+1hQ7zRIXVKht9q2dLyJ5Oj/JZhw0Nmj Pc8CUZROw6AOGS1rwdl7r0DZKLx0uXNaMh3BHCqlhJFbN4tVuQNnd4f9NDqOmf6jtAYYfa yCEiYAbYtHhDn+4Gy0W4WM7sbZ2kTCc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-ZF6FC_whPi2H-3mRCduqRw-1; Mon, 15 Mar 2021 08:07:52 -0400 X-MC-Unique: ZF6FC_whPi2H-3mRCduqRw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 12F3993920; Mon, 15 Mar 2021 12:07:51 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-118-152.rdu2.redhat.com [10.10.118.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7C9710190A7; Mon, 15 Mar 2021 12:07:48 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 1/3] vfs: Use an xarray in the mount namespace to handle /proc/mounts list From: David Howells To: Alexander Viro , Miklos Szeredi Cc: Matthew Wilcox , dhowells@redhat.com, Matthew Wilcox , Ian Kent , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 15 Mar 2021 12:07:47 +0000 Message-ID: <161581006790.2850696.15507933486273306779.stgit@warthog.procyon.org.uk> In-Reply-To: <161581005972.2850696.12854461380574304411.stgit@warthog.procyon.org.uk> References: <161581005972.2850696.12854461380574304411.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add an xarray to the mount namespace and use this to perform a mnt_id to mount object mapping for the namespace. Make use of xa_reserve() to perform preallocation before taking the mount_lock. This will allow the set of mount objects in a namespace to be iterated using xarray iteration and without the need to insert and remove fake mounts as bookmarks - which cause issues for other trawlers of the list. As a bonus, if we want to allow it, lseek() can be used to start at a particular mount - though there's no easy way to limit the return to just a single entry or enforce a failure if that mount doesn't exist, but a later one does. Signed-off-by: David Howells cc: Alexander Viro cc: Miklos Szeredi cc: Matthew Wilcox --- fs/mount.h | 2 + fs/namespace.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 0b6e08cf8afb..455f4d293a65 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -4,6 +4,7 @@ #include #include #include +#include struct mnt_namespace { struct ns_common ns; @@ -14,6 +15,7 @@ struct mnt_namespace { * - taking namespace_sem for read AND taking .ns_lock. */ struct list_head list; + struct xarray mounts_by_id; /* List of mounts by mnt_id */ spinlock_t ns_lock; struct user_namespace *user_ns; struct ucounts *ucounts; diff --git a/fs/namespace.c b/fs/namespace.c index 56bb5a5fdc0d..5c9bcaeac4de 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -901,6 +901,57 @@ void mnt_change_mountpoint(struct mount *parent, struct mountpoint *mp, struct m mnt_add_count(old_parent, -1); } +/* + * Reserve slots in the mnt_id-to-mount mapping in a namespace. This gets the + * memory allocation done upfront. + */ +static int reserve_mnt_id_one(struct mount *mnt, struct mnt_namespace *ns) +{ + struct mount *m; + int ret; + + ret = xa_reserve(&ns->mounts_by_id, mnt->mnt_id, GFP_KERNEL); + if (ret < 0) + return ret; + + list_for_each_entry(m, &mnt->mnt_list, mnt_list) { + ret = xa_reserve(&ns->mounts_by_id, m->mnt_id, GFP_KERNEL); + if (ret < 0) + return ret; + } + + return 0; +} + +static int reserve_mnt_id_list(struct hlist_head *tree_list) +{ + struct mount *child; + int ret; + + hlist_for_each_entry(child, tree_list, mnt_hash) { + ret = reserve_mnt_id_one(child, child->mnt_parent->mnt_ns); + if (ret < 0) + return ret; + } + return 0; +} + +static void add_mnt_to_ns(struct mount *m, struct mnt_namespace *ns) +{ + void *x; + + m->mnt_ns = ns; + x = xa_store(&ns->mounts_by_id, m->mnt_id, m, GFP_ATOMIC); + WARN(xa_err(x), "Couldn't store mnt_id %x\n", m->mnt_id); +} + +static void remove_mnt_from_ns(struct mount *mnt) +{ + if (mnt->mnt_ns && mnt->mnt_ns != MNT_NS_INTERNAL) + xa_erase(&mnt->mnt_ns->mounts_by_id, mnt->mnt_id); + mnt->mnt_ns = NULL; +} + /* * vfsmount lock must be held for write */ @@ -914,8 +965,9 @@ static void commit_tree(struct mount *mnt) BUG_ON(parent == mnt); list_add_tail(&head, &mnt->mnt_list); - list_for_each_entry(m, &head, mnt_list) - m->mnt_ns = n; + list_for_each_entry(m, &head, mnt_list) { + add_mnt_to_ns(m, n); + } list_splice(&head, n->list.prev); @@ -1529,7 +1581,7 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) ns->mounts--; __touch_mnt_namespace(ns); } - p->mnt_ns = NULL; + remove_mnt_from_ns(p); if (how & UMOUNT_SYNC) p->mnt.mnt_flags |= MNT_SYNC_UMOUNT; @@ -2144,6 +2196,13 @@ static int attach_recursive_mnt(struct mount *source_mnt, err = count_mounts(ns, source_mnt); if (err) goto out; + + /* Reserve id-to-mount mapping slots in the namespace we're + * going to use. + */ + err = reserve_mnt_id_one(source_mnt, dest_mnt->mnt_ns); + if (err) + goto out; } if (IS_MNT_SHARED(dest_mnt)) { @@ -2151,6 +2210,8 @@ static int attach_recursive_mnt(struct mount *source_mnt, if (err) goto out; err = propagate_mnt(dest_mnt, dest_mp, source_mnt, &tree_list); + if (!err && !moving) + err = reserve_mnt_id_list(&tree_list); lock_mount_hash(); if (err) goto out_cleanup_ids; @@ -3260,6 +3321,7 @@ static void dec_mnt_namespaces(struct ucounts *ucounts) static void free_mnt_ns(struct mnt_namespace *ns) { + WARN_ON(!xa_empty(&ns->mounts_by_id)); if (!is_anon_ns(ns)) ns_free_inum(&ns->ns); dec_mnt_namespaces(ns->ucounts); @@ -3306,6 +3368,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool a INIT_LIST_HEAD(&new_ns->list); init_waitqueue_head(&new_ns->poll); spin_lock_init(&new_ns->ns_lock); + xa_init(&new_ns->mounts_by_id); new_ns->user_ns = get_user_ns(user_ns); new_ns->ucounts = ucounts; return new_ns; @@ -3362,7 +3425,7 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, p = old; q = new; while (p) { - q->mnt_ns = new_ns; + add_mnt_to_ns(q, new_ns); new_ns->mounts++; if (new_fs) { if (&p->mnt == new_fs->root.mnt) { @@ -3404,7 +3467,7 @@ struct dentry *mount_subtree(struct vfsmount *m, const char *name) mntput(m); return ERR_CAST(ns); } - mnt->mnt_ns = ns; + add_mnt_to_ns(mnt, ns); ns->root = mnt; ns->mounts++; list_add(&mnt->mnt_list, &ns->list); @@ -3583,7 +3646,7 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, goto err_path; } mnt = real_mount(newmount.mnt); - mnt->mnt_ns = ns; + add_mnt_to_ns(mnt, ns); ns->root = mnt; ns->mounts = 1; list_add(&mnt->mnt_list, &ns->list); @@ -4193,7 +4256,7 @@ static void __init init_mount_tree(void) if (IS_ERR(ns)) panic("Can't allocate initial namespace"); m = real_mount(mnt); - m->mnt_ns = ns; + add_mnt_to_ns(m, ns); ns->root = m; ns->mounts = 1; list_add(&m->mnt_list, &ns->list); @@ -4270,7 +4333,7 @@ void kern_unmount(struct vfsmount *mnt) { /* release long term mount so mount point can be released */ if (!IS_ERR_OR_NULL(mnt)) { - real_mount(mnt)->mnt_ns = NULL; + remove_mnt_from_ns(real_mount(mnt)); synchronize_rcu(); /* yecchhh... */ mntput(mnt); } @@ -4283,7 +4346,7 @@ void kern_unmount_array(struct vfsmount *mnt[], unsigned int num) for (i = 0; i < num; i++) if (mnt[i]) - real_mount(mnt[i])->mnt_ns = NULL; + remove_mnt_from_ns(real_mount(mnt[i])); synchronize_rcu_expedited(); for (i = 0; i < num; i++) mntput(mnt[i]); From patchwork Mon Mar 15 12:07:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 12139085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CA39C433E0 for ; Mon, 15 Mar 2021 12:09:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 637BC64E41 for ; Mon, 15 Mar 2021 12:09:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbhCOMIe (ORCPT ); Mon, 15 Mar 2021 08:08:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32399 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbhCOMIE (ORCPT ); Mon, 15 Mar 2021 08:08:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615810083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WV8Qo1wCC5wakuqg7LiPHipA4SNifOTUXpzARroenTg=; b=DZgT1SusWwr2XKnCfOxIX1sw7L2XdqxYhDRdN/Qi15MIMgWWO0yLLrnNCV9MsQtTWe0HZ6 rK5qz7MlQ/FCC7bmrJMBrDbdx8dF4t2Cawdn6VkxIXe0S5C1kezI5TTGAXJu276J954VDQ wls4u5EVozC4ndzRhH+R3BPo6RvQxu0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-KJheqZhaMduAdwSih0IuAA-1; Mon, 15 Mar 2021 08:08:00 -0400 X-MC-Unique: KJheqZhaMduAdwSih0IuAA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A95F2100C660; Mon, 15 Mar 2021 12:07:58 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-118-152.rdu2.redhat.com [10.10.118.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E7E919701; Mon, 15 Mar 2021 12:07:56 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 2/3] vfs: Use the mounts_to_id array to do /proc/mounts and co. From: David Howells To: Alexander Viro , Miklos Szeredi Cc: Matthew Wilcox , dhowells@redhat.com, Matthew Wilcox , Ian Kent , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 15 Mar 2021 12:07:56 +0000 Message-ID: <161581007628.2850696.11692651942358302102.stgit@warthog.procyon.org.uk> In-Reply-To: <161581005972.2850696.12854461380574304411.stgit@warthog.procyon.org.uk> References: <161581005972.2850696.12854461380574304411.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Use the mounts_to_id xarray added to the mount namespace to perform iteration over the mounts in a namespace on behalf of /proc/mounts and similar. Since it doesn't trawl a standard list_head, but rather uses xarray, this could be done under the RCU read lock only. To do this, we would need to hide mounts that are in the process of being inserted into the tree by marking them in the xarray itself or using a mount flag. Signed-off-by: David Howells cc: Alexander Viro cc: Miklos Szeredi cc: Matthew Wilcox --- fs/mount.h | 2 +- fs/namespace.c | 40 +++++++++++++++++----------------------- fs/proc_namespace.c | 3 --- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/fs/mount.h b/fs/mount.h index 455f4d293a65..114e7d603995 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -130,7 +130,7 @@ struct proc_mounts { struct mnt_namespace *ns; struct path root; int (*show)(struct seq_file *, struct vfsmount *); - struct mount cursor; + struct xa_state xas; }; extern const struct seq_operations mounts_op; diff --git a/fs/namespace.c b/fs/namespace.c index 5c9bcaeac4de..d19fde0654f7 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1334,6 +1334,7 @@ struct vfsmount *mnt_clone_internal(const struct path *path) } #ifdef CONFIG_PROC_FS +#if 0 static struct mount *mnt_list_next(struct mnt_namespace *ns, struct list_head *p) { @@ -1351,47 +1352,40 @@ static struct mount *mnt_list_next(struct mnt_namespace *ns, return ret; } +#endif /* iterator; we want it to have access to namespace_sem, thus here... */ static void *m_start(struct seq_file *m, loff_t *pos) { - struct proc_mounts *p = m->private; - struct list_head *prev; + struct proc_mounts *state = m->private; + void *entry; down_read(&namespace_sem); - if (!*pos) { - prev = &p->ns->list; - } else { - prev = &p->cursor.mnt_list; + state->xas = (struct xa_state) __XA_STATE(&state->ns->mounts_by_id, *pos, 0, 0); - /* Read after we'd reached the end? */ - if (list_empty(prev)) - return NULL; - } + entry = xas_find(&state->xas, ULONG_MAX); + while (entry && xas_invalid(entry)) + entry = xas_next_entry(&state->xas, ULONG_MAX); - return mnt_list_next(p->ns, prev); + return entry; } static void *m_next(struct seq_file *m, void *v, loff_t *pos) { - struct proc_mounts *p = m->private; + struct proc_mounts *state = m->private; struct mount *mnt = v; + void *entry; + + *pos = mnt->mnt_id + 1; + entry = xas_next_entry(&state->xas, ULONG_MAX); + while (entry && xas_invalid(entry)) + entry = xas_next_entry(&state->xas, ULONG_MAX); - ++*pos; - return mnt_list_next(p->ns, &mnt->mnt_list); + return entry; } static void m_stop(struct seq_file *m, void *v) { - struct proc_mounts *p = m->private; - struct mount *mnt = v; - - lock_ns_list(p->ns); - if (mnt) - list_move_tail(&p->cursor.mnt_list, &mnt->mnt_list); - else - list_del_init(&p->cursor.mnt_list); - unlock_ns_list(p->ns); up_read(&namespace_sem); } diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 392ef5162655..9ae07f1904e6 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -283,8 +283,6 @@ static int mounts_open_common(struct inode *inode, struct file *file, p->ns = ns; p->root = root; p->show = show; - INIT_LIST_HEAD(&p->cursor.mnt_list); - p->cursor.mnt.mnt_flags = MNT_CURSOR; return 0; @@ -301,7 +299,6 @@ static int mounts_release(struct inode *inode, struct file *file) struct seq_file *m = file->private_data; struct proc_mounts *p = m->private; path_put(&p->root); - mnt_cursor_del(p->ns, &p->cursor); put_mnt_ns(p->ns); return seq_release_private(inode, file); } From patchwork Mon Mar 15 12:08:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 12139087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D50DC433E6 for ; Mon, 15 Mar 2021 12:09:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76C0D64E76 for ; Mon, 15 Mar 2021 12:09:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230502AbhCOMIf (ORCPT ); Mon, 15 Mar 2021 08:08:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46817 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230442AbhCOMIJ (ORCPT ); Mon, 15 Mar 2021 08:08:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615810089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gp+7jAw9DBst1BkRwe0IRvUzSqM3k8jkvwLyhio5B5w=; b=fXsa/nrNZanWpdMPnkEZOeO0fgn9I3g1b0Z/yn9JAeM7rl04EOfC3QxFcmt3t7XZt2mBRt Y8p6fZNrPRRE05bMP5QT05xUgx8gq8gOUnJpjCtnx/Z+7s6NyVHA8+Z/7cDcSPy6xRUxz8 WTiNFOt8knKLrfCEMoO7sADOEhHVTj0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-n3CUcFu9Mlm_KZFOd00Gww-1; Mon, 15 Mar 2021 08:08:07 -0400 X-MC-Unique: n3CUcFu9Mlm_KZFOd00Gww-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41D5F93921; Mon, 15 Mar 2021 12:08:06 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-118-152.rdu2.redhat.com [10.10.118.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3FF55C3E6; Mon, 15 Mar 2021 12:08:04 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 3/3] vfs: Remove mount list trawling cursor stuff From: David Howells To: Alexander Viro , Miklos Szeredi Cc: Matthew Wilcox , dhowells@redhat.com, Matthew Wilcox , Ian Kent , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 15 Mar 2021 12:08:03 +0000 Message-ID: <161581008391.2850696.2182919568148594136.stgit@warthog.procyon.org.uk> In-Reply-To: <161581005972.2850696.12854461380574304411.stgit@warthog.procyon.org.uk> References: <161581005972.2850696.12854461380574304411.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove the stuff for trawling a mount namespace's mount list using inserted cursors as bookmarks as this has been replaced with an xarray-based approach. Signed-off-by: David Howells cc: Alexander Viro cc: Miklos Szeredi cc: Matthew Wilcox --- fs/namespace.c | 30 ------------------------------ include/linux/mount.h | 4 +--- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index d19fde0654f7..105a6d882cb4 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -673,11 +673,6 @@ static inline void unlock_ns_list(struct mnt_namespace *ns) spin_unlock(&ns->ns_lock); } -static inline bool mnt_is_cursor(struct mount *mnt) -{ - return mnt->mnt.mnt_flags & MNT_CURSOR; -} - /* * __is_local_mountpoint - Test to see if dentry is a mountpoint in the * current mount namespace. @@ -702,8 +697,6 @@ bool __is_local_mountpoint(struct dentry *dentry) down_read(&namespace_sem); lock_ns_list(ns); list_for_each_entry(mnt, &ns->list, mnt_list) { - if (mnt_is_cursor(mnt)) - continue; is_covered = (mnt->mnt_mountpoint == dentry); if (is_covered) break; @@ -1334,26 +1327,6 @@ struct vfsmount *mnt_clone_internal(const struct path *path) } #ifdef CONFIG_PROC_FS -#if 0 -static struct mount *mnt_list_next(struct mnt_namespace *ns, - struct list_head *p) -{ - struct mount *mnt, *ret = NULL; - - lock_ns_list(ns); - list_for_each_continue(p, &ns->list) { - mnt = list_entry(p, typeof(*mnt), mnt_list); - if (!mnt_is_cursor(mnt)) { - ret = mnt; - break; - } - } - unlock_ns_list(ns); - - return ret; -} -#endif - /* iterator; we want it to have access to namespace_sem, thus here... */ static void *m_start(struct seq_file *m, loff_t *pos) { @@ -4390,9 +4363,6 @@ static bool mnt_already_visible(struct mnt_namespace *ns, struct mount *child; int mnt_flags; - if (mnt_is_cursor(mnt)) - continue; - if (mnt->mnt.mnt_sb->s_type != sb->s_type) continue; diff --git a/include/linux/mount.h b/include/linux/mount.h index 5d92a7e1a742..88027d38833c 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -51,8 +51,7 @@ struct fs_context; #define MNT_ATIME_MASK (MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME ) #define MNT_INTERNAL_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \ - MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED | \ - MNT_CURSOR) + MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED) #define MNT_INTERNAL 0x4000 @@ -66,7 +65,6 @@ struct fs_context; #define MNT_SYNC_UMOUNT 0x2000000 #define MNT_MARKED 0x4000000 #define MNT_UMOUNT 0x8000000 -#define MNT_CURSOR 0x10000000 struct vfsmount { struct dentry *mnt_root; /* root of the mounted tree */