Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1399624pxb; Thu, 24 Mar 2022 19:49:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMOTCIUeq0fh/2WsUVusyW/oORQEAvzOpxfqVJpOaPdH35WS7KGJ/G025MqVqTywHX46hV X-Received: by 2002:a17:907:1ca8:b0:6df:f192:cf4a with SMTP id nb40-20020a1709071ca800b006dff192cf4amr9266524ejc.620.1648176565972; Thu, 24 Mar 2022 19:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648176565; cv=none; d=google.com; s=arc-20160816; b=b1boQYx8gZnGV4ONC5rA2BU5LfFUvquGoq4xPGQRuR7EVNFilef8wFZU7ctVQAo0pW 8jZkNNQUamDX9vZW6CbVA4fZI7vYuWD2E9tiBJ+TOww56eWkl1YQ5h7Pbbvxd9XkVZLo gCP5/A57N9Ldv3irPB8V34Ak2VowKl+IDq06wlCMetjpW8xqyYIWpD/Fo8aW3j47TW1F tB8fQYoy7MEysc9TixQ3dp2kbtAuMqRUvoSe7Bv4G2Hp3Bxk9V6s/IOaofR4O1M2sTX+ LZnyN+EzZL2eDYY96NiMUOEsV0M31RjoTtJ06NPnSa+AKwC92XMZKgixkdP4qQkP4/BB h0WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=BiBottBy3SS4meXngiki/2gP1NEzkpmEetCppWfjwwk=; b=urjFXz96+Tw57Vo5NT6jRkEg8jySaCuu9oiVZFwSBA/XRF4q8v1TS7GfgxH3bvMpGi 3ANF0V6i0setbNekROawiZ1XDOiKPNxcEoiZ9fOemOLzRGcMZWXwkx1BMeCqzYHBg3CJ v1Moyu7k5kF+u/R4P0TsZjgrjysZvsWgiZmdrFx7XSEEkBEYcCxrXIdsAxTDPm70HJum MJklQ2BV4yMUmurgl7etzR7dbca1tNycqDd1HlWUB0cQHGvnVHA7bneXIjFs7RsRpJyN y2Ik7zUdfVMD4PlgF+G64SNL1RzVushs8yWHHFugw5zFQ0/gW9UkvMrjMlv7R7DtG3dj j6Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a170906380500b006e02fed871esi1208850ejc.418.2022.03.24.19.49.01; Thu, 24 Mar 2022 19:49:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353404AbiCXUdI (ORCPT + 99 others); Thu, 24 Mar 2022 16:33:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353411AbiCXUc5 (ORCPT ); Thu, 24 Mar 2022 16:32:57 -0400 Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8DD2FB6E70; Thu, 24 Mar 2022 13:31:23 -0700 (PDT) Received: from dread.disaster.area (pa49-186-150-27.pa.vic.optusnet.com.au [49.186.150.27]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 2ABDA533EAB; Fri, 25 Mar 2022 07:31:18 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1nXU72-009RUP-Ov; Fri, 25 Mar 2022 07:31:16 +1100 Date: Fri, 25 Mar 2022 07:31:16 +1100 From: Dave Chinner To: Miklos Szeredi Cc: Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Linux API , linux-man , LSM , Karel Zak , Ian Kent , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , James Bottomley Subject: Re: [RFC PATCH] getvalues(2) prototype Message-ID: <20220324203116.GJ1609613@dread.disaster.area> References: <20220322192712.709170-1-mszeredi@redhat.com> <20220323225843.GI1609613@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=VuxAv86n c=1 sm=1 tr=0 ts=623cd519 a=sPqof0Mm7fxWrhYUF33ZaQ==:117 a=sPqof0Mm7fxWrhYUF33ZaQ==:17 a=kj9zAlcOel0A:10 a=o8Y5sQTvuykA:10 a=7-415B0cAAAA:8 a=GumQ9EM2AAAA:8 a=PLAR8crxhtdwIOoicKgA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 24, 2022 at 09:57:26AM +0100, Miklos Szeredi wrote: > On Wed, 23 Mar 2022 at 23:58, Dave Chinner wrote: > > > > On Tue, Mar 22, 2022 at 08:27:12PM +0100, Miklos Szeredi wrote: > > > > - Interfaces for getting various attributes and statistics are fragmented. > > > For files we have basic stat, statx, extended attributes, file attributes > > > (for which there are two overlapping ioctl interfaces). For mounts and > > > superblocks we have stat*fs as well as /proc/$PID/{mountinfo,mountstats}. > > > The latter also has the problem on not allowing queries on a specific > > > mount. > > > > https://xkcd.com/927/ > > Haha! > > > I've said in the past when discussing things like statx() that maybe > > everything should be addressable via the xattr namespace and > > set/queried via xattr names regardless of how the filesystem stores > > the data. The VFS/filesystem simply translates the name to the > > storage location of the information. It might be held in xattrs, but > > it could just be a flag bit in an inode field. > > Right, that would definitely make sense for inode attributes. > > What about other objects' attributes, statistics? Remember this > started out as a way to replace /proc/self/mountinfo with something > that can query individual mount. For individual mount info, why do we even need to query something in /proc? I mean, every open file in the mount has access to the mount and the underlying superblock, so why not just make the query namespace accessable from any open fd on that mount? e.g. /proc/self/mountinfo tells you where the mounts are, then you can just open(O_PATH) the mount point you want the info from and retrieve the relevant xattrs from that fd. The information itself does not need to be in /proc, nor only accessible from /proc, nor be limited to proc infrastructure, nor be constrained by proc's arbitrary "one value per file" presentation.... Indeed, we don't have to centralise all the information in one place - all we need is to have a well defined, consistent method for indexing that information and all the shenanigans for accessing common stuff can be wrapped up in a common userspace library (similar to how iterating the mount table is generic C library functionality). > > > mnt - list of mount parameters > > > mnt:mountpoint - the mountpoint of the mount of $ORIGIN > > > mntns - list of mount ID's reachable from the current root > > > mntns:21:parentid - parent ID of the mount with ID of 21 > > > xattr:security.selinux - the security.selinux extended attribute > > > data:foo/bar - the data contained in file $ORIGIN/foo/bar > > > > How are these different from just declaring new xattr namespaces for > > these things. e.g. open any file and list the xattrs in the > > xattr:mount.mnt namespace to get the list of mount parameters for > > that mount. > > Okay. > > > Why do we need a new "xattr in everything but name" interface when > > we could just extend the one we've already got and formalise a new, > > cleaner version of xattr batch APIs that have been around for 20-odd > > years already? > > Seems to make sense. But...will listxattr list everyting recursively? > I guess that won't work, better just list traditional xattrs, > otherwise we'll likely get regressions, *nod* > and anyway the point of a > hierarchical namespace is to be able to list nodes on each level. We > can use getxattr() for this purpose, just like getvalues() does in the > above example. Yup, and like Casey suggests, you could implement a generic getvalues()-like user library on top of it so users don't even need to know where and how the values are located or retrieved. The other advantage of an xattr interface is that is also provides a symmetrical API for -changing- values. No need for some special configfs or configfd thingy for setting parameters - just change the value of the parameter or mount option with a simple setxattr call. That retains the simplicity of proc and sysfs attributes in that you can change them just by writing a new value to the file.... Cheers, Dave. -- Dave Chinner david@fromorbit.com