mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Kent <raven@themaw.net>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Miklos Szeredi <mszeredi@redhat.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-api@vger.kernel.org, linux-man@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	Karel Zak <kzak@redhat.com>, David Howells <dhowells@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <christian@brauner.io>,
	Amir Goldstein <amir73il@gmail.com>,
	Matthew House <mattlloydhouse@gmail.com>,
	Florian Weimer <fweimer@redhat.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v3 3/4] add statmount(2) syscall
Date: Sat, 30 Sep 2023 09:16:11 +0800	[thread overview]
Message-ID: <348596f8-e88b-2e8b-96e2-20caaf5c9d7b@themaw.net> (raw)
In-Reply-To: <CAJfpegt80_Tyto3QyD48V_yzHSghqg8AC_OPHEMPkDjEYCcisQ@mail.gmail.com>

On 29/9/23 17:10, Miklos Szeredi wrote:
> On Fri, 29 Sept 2023 at 02:42, Ian Kent <raven@themaw.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


  reply	other threads:[~2023-09-30  1:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 13:01 [PATCH v3 0/4] querying mount attributes Miklos Szeredi
2023-09-28 13:01 ` [PATCH v3 1/4] add unique mount ID Miklos Szeredi
2023-10-05 15:52   ` Miklos Szeredi
2023-10-06 11:44     ` Amir Goldstein
2023-10-06 12:48       ` Miklos Szeredi
2023-09-28 13:01 ` [PATCH v3 2/4] namespace: extract show_path() helper Miklos Szeredi
2023-09-28 13:01 ` [PATCH v3 3/4] add statmount(2) syscall Miklos Szeredi
2023-09-29  0:42   ` Ian Kent
2023-09-29  9:10     ` Miklos Szeredi
2023-09-30  1:16       ` Ian Kent [this message]
2023-10-04 19:26   ` Paul Moore
2023-09-28 13:01 ` [PATCH v3 4/4] add listmount(2) syscall Miklos Szeredi
2023-10-04 19:37   ` Paul Moore
2023-10-05  4:01     ` Miklos Szeredi
2023-10-05  4:23       ` Ian Kent
2023-10-05 15:47         ` Miklos Szeredi
2023-10-06  0:27           ` Ian Kent
2023-10-13  2:39             ` Ian Kent
2023-10-24 13:57               ` Miklos Szeredi
2023-10-06  2:56           ` Paul Moore
2023-10-06  8:53             ` Miklos Szeredi
2023-10-06 23:07               ` Paul Moore

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=348596f8-e88b-2e8b-96e2-20caaf5c9d7b@themaw.net \
    --to=raven@themaw.net \
    --cc=amir73il@gmail.com \
    --cc=arnd@arndb.de \
    --cc=christian@brauner.io \
    --cc=dhowells@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=kzak@redhat.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mattlloydhouse@gmail.com \
    --cc=miklos@szeredi.hu \
    --cc=mszeredi@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --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

all inboxes | Powered by JetHome®