From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A349AC433F5 for ; Sat, 26 Mar 2022 04:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231177AbiCZEVT (ORCPT ); Sat, 26 Mar 2022 00:21:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbiCZEVP (ORCPT ); Sat, 26 Mar 2022 00:21:15 -0400 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2197723F3F9; Fri, 25 Mar 2022 21:19:38 -0700 (PDT) Received: from cwcc.thunk.org (pool-108-7-220-252.bstnma.fios.verizon.net [108.7.220.252]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 22Q4JAos018812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 26 Mar 2022 00:19:11 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id D60DD15C0038; Sat, 26 Mar 2022 00:19:10 -0400 (EDT) Date: Sat, 26 Mar 2022 00:19:10 -0400 From: "Theodore Ts'o" To: Karel Zak Cc: Greg KH , Miklos Szeredi , Christian Brauner , Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Linux API , linux-man , LSM , Ian Kent , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , James Bottomley Subject: Re: [RFC PATCH] getvalues(2) prototype Message-ID: References: <20220322192712.709170-1-mszeredi@redhat.com> <20220323114215.pfrxy2b6vsvqig6a@wittgenstein> <20220325084646.7g6oto2ce3vou54x@ws.net.home> <20220325092553.rncxqrjslv6e4c7v@ws.net.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220325092553.rncxqrjslv6e4c7v@ws.net.home> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 25, 2022 at 10:25:53AM +0100, Karel Zak wrote: > > Right, the speed of ps(1) or lsof(1) is not important. IMHO the current > discussion about getvalues() goes in wrong direction :-) > > I guess the primary motivation is not to replace open+read+close, but > provide to userspace something usable to get information from mount > table, because the current /proc/#/mountinfo and notification by > poll() is horrible. I think that's because the getvalues(2) prototype *only* optimizes away open+read+close, and doesn't do a *thing* with respect to /proc//mountinfo. > Don't forget that the previous attempt was fsinfo() from David Howells > (unfortunately, it was too complex and rejected by Linus). fsinfo() tried to do a lot more than solving the /proc//mountinfo problem; perhaps that was the cause of the complexity. Ignoring the notification problem (which I suspect we could solve with an extension of fsnotify), if the goal is to find a cleaner way to fetch information about a process's mount namespace and the mounts in that namespace, why not trying to export that information via sysfs? Information about devices are just as complex, after all. We could make mount namespaces to be their own first class object, so there would be an entry in /proc/ which returns the mount namespace id used by a particular process. Similarly, let each mounted file system be its own first class object. Information about each mount namespace would be in /sys/mnt_ns, and information about each mounted file system would be in /sys/superblock. Then in /sys/mnt_ns there would be a directory for each (superblock, mountpoint) pair. Given how quickly programs like lsof can open tens of thousands of small files, and typically there are't that many mounted file systems in a particular mount namespace, performance really shouldn't be a problem. If it works well enough for other kernel objects that are accessed via sysfs, and fsinfo() is way to complex, why don't we try a pattern which has worked and is "native" to Linux? - Ted