[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <348596f8-e88b-2e8b-96e2-20caaf5c9d7b@themaw.net>
Date: Sat, 30 Sep 2023 09:16:11 +0800
From: Ian Kent <raven@...maw.net>
To: Miklos Szeredi <miklos@...redi.hu>
Cc: Miklos Szeredi <mszeredi@...hat.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-api@...r.kernel.org, linux-man@...r.kernel.org,
linux-security-module@...r.kernel.org, Karel Zak <kzak@...hat.com>,
David Howells <dhowells@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>,
Christian Brauner <christian@...uner.io>,
Amir Goldstein <amir73il@...il.com>,
Matthew House <mattlloydhouse@...il.com>,
Florian Weimer <fweimer@...hat.com>,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v3 3/4] add statmount(2) syscall
On 29/9/23 17:10, Miklos Szeredi wrote:
> On Fri, 29 Sept 2023 at 02:42, Ian Kent <raven@...maw.net> wrote:
>> On 28/9/23 21:01, Miklos Szeredi wrote:
>>> +static struct vfsmount *lookup_mnt_in_ns(u64 id, struct mnt_namespace *ns)
>>> +{
>>> + struct mount *mnt;
>>> + struct vfsmount *res = NULL;
>>> +
>>> + lock_ns_list(ns);
>>> + list_for_each_entry(mnt, &ns->list, mnt_list) {
>>> + if (!mnt_is_cursor(mnt) && id == mnt->mnt_id_unique) {
>>> + res = &mnt->mnt;
>>> + break;
>>> + }
>>> + }
>>> + unlock_ns_list(ns);
>>> + return res;
>>> +}
>> Seems like we might need to consider making (struct mnt_namespace)->list
>>
>> a hashed list.
> Yes, linear search needs to go. A hash table is probably the easiest solution.
>
> But I'd also consider replacing ns->list with an rbtree. Not as
> trivial as adding a system hash table and probably also slightly
> slower, but it would have some advantages:
>
> - most space efficient (no overhead of hash buckets)
>
> - cursor can go away (f_pos can just contain last ID)
I guess that would be ok.
Avoiding the cursor is a big plus.
An rbtree is used in kernfs and its readdir function is rather painful so
I wonder what the implications might be for other enumeration needs.
Ian
Powered by blists - more mailing lists