Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp233620rdb; Sat, 30 Sep 2023 02:18:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsUVkCdIS0Uow8HeHNBLYBxSe74Gn9AMq0SywBjYt5V1tkNZhVzKgHu2iiDFI5Relkglxn X-Received: by 2002:a17:90a:15c9:b0:26d:2d77:da7b with SMTP id w9-20020a17090a15c900b0026d2d77da7bmr6046997pjd.6.1696065482430; Sat, 30 Sep 2023 02:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696065482; cv=none; d=google.com; s=arc-20160816; b=TBUcGIf9rRj/lyBPBoRbQupUiLBxrd8F+VofPV3iUofOAbXty+x+nUe68dS3D+sQFQ ju9NIGPa4p9qOByRh9IT8Fuf+QuAZgqsTm73Oh8pOiVvKyrkZTTpSFn534qX2hSlCtz6 ERgnpR8zL6Ul8w0qLBPhSfAVhYCs4V0diep+B2NV/V694JAVvBg8GiEbhp1KeK0eYs0y YjH03vOedbWm1oo7TOoiK7SifZWW//cUY9HkYwQk8dLDRn/+5156uXE4Jr3eyeCOVGVY K0nw/ekkjkneHG5EKr50cIoylMebEeN9jxeJzWM4P7I8NyMf9AM+sjezvHgx+N10OHZ8 m6UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:feedback-id:dkim-signature:dkim-signature; bh=fFeBd2wnRQFZEpz+r8VxUNSi+h4AN2LcJPK4S1aXKis=; fh=JCzGNGudGVUYoetNum5Y/E9UGIl+c+tDFp5DMydl7NA=; b=qcj0vHoRAt7eCJl+U/5PdNz+ktu2x680Eyw3qzRyBCHXtwGAoJ+lpqCEfeouREdPYm flww5QNx59XHXWOxbQfGU0V3h9e6WuwoZrZq2HZxP2yO2uRO2i3F0iRQO3xLH5EMzBrL FeXNE78leYPg+Kb8NzomhBtH9medZ+A9TowDjzGhPJSMvFr/NXBpk6uYf66BT7Dj15Rs 6M1F3O1WxktWtQhxRSESDm7ZI2BVyNz/jcP7rd6xoM5F86MLOMiZQsIWxap5FZq3/q2E hfy/08UL/ixT9gsCQfdJHMO/8H12fXoVFWBODdbJ8fM9Gh2oUb1sDQ9UpEwfh2xy4XEC eqIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=AsuR5BNr; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MCPogdCT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id q5-20020a17090a178500b0027771ba9056si3225587pja.133.2023.09.30.02.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 02:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=AsuR5BNr; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MCPogdCT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3D606811AD9E; Fri, 29 Sep 2023 18:17:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233897AbjI3BQb (ORCPT + 99 others); Fri, 29 Sep 2023 21:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjI3BQa (ORCPT ); Fri, 29 Sep 2023 21:16:30 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0831F3; Fri, 29 Sep 2023 18:16:27 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 763C13200916; Fri, 29 Sep 2023 21:16:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 29 Sep 2023 21:16:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1696036581; x=1696122981; bh=fFeBd2wnRQFZEpz+r8VxUNSi+h4AN2LcJPK 4S1aXKis=; b=AsuR5BNr/3Zccy/Xb5uNgfZgXpVBovOZBwhYBQ0E4yfaaq7CpZh /ZQv/TbE0C6nViX/Qp/767ob3XI3jDp5fgYGH8kTpkTagAAjs9gVTpjdmtsKfsbM iop9rnxJsmUcFDBehPEvfSOO+7nAbOboC8ZPdwHIkrd07YZiVY7zuOkvbfYKAocI P3N0+NCCIBBgaNwcm4UQX7FyJxoo4ML+dmI3bXOkXI2ML+sqZ9tTjQEjJVPnXfTx AMoN59No0cz303+JEs9rjyOp4oTRmYj//EGMTHdBK4fAUSQ/M8U2NGQ1HCysUoV4 BbPMZhG7Qn9NYI5QOJhA1zKppl7F4uluoQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1696036581; x=1696122981; bh=fFeBd2wnRQFZEpz+r8VxUNSi+h4AN2LcJPK 4S1aXKis=; b=MCPogdCTKEpWqzyxwXUoXwfpyQJygkdIURvYLbVFhBo218HKEjf 46mRPT8AH0p/CC32x0nIVVSbFNni23E0H3vQ+Ot6kSkWANtJr6jEtQAuUqYgtLcV zF3DGMUXDxFBYmbc6NCkFD0m44M+lQmqeyC4OONy01owuyCm88YMvx/v3k+5wWgm lJ3SFBfiF2ZfG9iZizW5/P7d9wqytHEIkCiiytYTvmV5BJdhLvv3TkevTZysgoHo EjzWUhlDBT6GZf6yqku6erzlBru/OPCNrsf6LZDnEV2TrEhcEZcFOQ+Yq18HhVxI bxZiGfCErYvgxcYUuHWbBQYU0j9qyNYf5sA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrtdehgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe euhfeuieeijeeuveekgfeitdethefguddtleffhfelfeelhfduuedvfefhgefhheenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Sep 2023 21:16:14 -0400 (EDT) Message-ID: <348596f8-e88b-2e8b-96e2-20caaf5c9d7b@themaw.net> Date: Sat, 30 Sep 2023 09:16:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 3/4] add statmount(2) syscall To: Miklos Szeredi Cc: Miklos Szeredi , 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 , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , Matthew House , Florian Weimer , Arnd Bergmann References: <20230928130147.564503-1-mszeredi@redhat.com> <20230928130147.564503-4-mszeredi@redhat.com> <5787bac5-b368-485a-f906-44e7049d4b8f@themaw.net> Content-Language: en-US From: Ian Kent In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 29 Sep 2023 18:17:26 -0700 (PDT) On 29/9/23 17:10, Miklos Szeredi wrote: > On Fri, 29 Sept 2023 at 02:42, Ian Kent 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