Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp313478pxb; Wed, 23 Mar 2022 19:10:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqe+XOz01PrP82CmJ2oHXHVfXyem1AyFQxc5a0Q2xVs8Zu8/sFPw9wrTDiBa2kWWYW28QM X-Received: by 2002:a17:903:1c2:b0:154:5edf:56d3 with SMTP id e2-20020a17090301c200b001545edf56d3mr3349091plh.10.1648087841268; Wed, 23 Mar 2022 19:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648087841; cv=none; d=google.com; s=arc-20160816; b=SdG1uQMueKeuf0X4j30olmb93FkV4IYhQc73M0jmqIdoYy+vZmb8tGBI3WZuo0MIcG RAYeQERkp1Ww34jDFFg+9y0ApTk86nGs7mJAUugbO992m643RRVHLJvg5I/4bCS6CnY2 hMde/E3uPtkPoaoN18lIbaOCEVPODa2oWYIbfI2sGYpNPHgtmVpRX7Dc+bjLNkxS91Nq 1psUX++eHRgWdggS4chhrzhtxigmryFBlQDZC+gSk/WZEAP0W9DbHm9Yj9Kq/HVKsyQx xwwwF5n5Qoy7P35mRTyBADCkwsHdPVxlftAL434e2HDatF4bZAlyJrNed9/U9NwDGDY0 +uJw== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=v67yEHZF+mWrcVVVzQnTLeOFxfVlSQsXaIHjbMmzPxs=; b=x8HuAvig6U25YMqTjJJmek+Sie0Dhl6dOGoABTjX3mZoBoM11wUF3GQndj92C/mff2 +2ZwOn2YGovViMySzG0N646yp8V8E6CETlJPK11YN9wde7d4P5O+D/xWNNcVWsX0gh1I nGAx4w5RyjAAuYZtfqXZxffwApD3UhVFhw+7o7qEuGSn3sn0wI6BK3i8IndIoG4GWwTR ymS6fo+2ZdVmEVJhItNchgWnJCd9Wh14G2ftX9O5eUnj41ikJ0PzpkloPFoHpqZRXK/+ 1QrC6xC5hEdjcc3kZksP3Fl77IvNfYdRhF3YGfyEd3xedxK48FfQmNQvcgmrp97+82V6 Xvyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=fxDxhCBc; 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 t2-20020a170902b20200b00153b2d16406si18314531plr.14.2022.03.23.19.10.27; Wed, 23 Mar 2022 19:10:41 -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; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=fxDxhCBc; 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 S1345456AbiCWXSp (ORCPT + 99 others); Wed, 23 Mar 2022 19:18:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345447AbiCWXSm (ORCPT ); Wed, 23 Mar 2022 19:18:42 -0400 Received: from sonic315-27.consmr.mail.ne1.yahoo.com (sonic315-27.consmr.mail.ne1.yahoo.com [66.163.190.153]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D211790CE0 for ; Wed, 23 Mar 2022 16:17:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1648077430; bh=v67yEHZF+mWrcVVVzQnTLeOFxfVlSQsXaIHjbMmzPxs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=fxDxhCBcj+dJ9rOPsrfQhpR6/Wz1mNFTDfWRs0YRzO2PLESHajaFYw4fMVqGzApiKbWraCn4SHEhlSe5c+HJwApksHob1lFVM+tP7D0/MB2jQSf+QN6Hqz2CkNrflSYPmP6UIemIRohY+XAj73JqB7GB9zh6PE6zGm4E+cqp3Jqq0uyUoSZERN3H2x3qb+AXV0TFul1ch1yf55HhsY5+PufoAgZhmoRIg41a31AigqxpEhdh1HK0uDqxf0TROBKeb6Ze7PDWqrMuan952LJiqJjJ5kP8TpCNDjZ2qyqeWIZLKwNdCN2pW5ymvlT+wCU/FFIszlfv4QcxDRIMcRMz0Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1648077430; bh=N356eMqQgGrIXhRu8EunIkwCAUoK4yb9Y2saHGeSS/x=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=hyZY6HP2zIE3582RMch80fwwA7NRVkWkvskGEqaBGzclP6VM2aRyyPiPSKoInK+ph3aAJag8EoWmTMIr9PjuBYo64Fse7aBcWswrnoST/xgfFcDJOc+quXlJ7fBs8bwkPOSJ8Tagf8OfqSFlgqmW1zznoNF3Np6GI1Qqlfmxr36wM3kIiDUIz/jRBCsJRbl68i2oGmbzHy9pacJE5/EecOL9VWXlLMzCmWWp3hWHrivN91S6H8zmyJAZasCZXs2y/7aCisTfMEQvG+Q2YtqYHntCZSJtqylxGMYXu2mPlh1ovWFyN/hzcJoXnpLuayi4GFSngphUvhBkYukQF68SEw== X-YMail-OSG: fkJNkBQVM1l88LWsGms_c8LwxfW_dlrT2KOLkWK7fRq3v1qO0awvH4jtBTht2IL n94dwBPyBRR7cZ9BggbmCeQ1T5kvv0vnTP0uc_JsSH5dnQKO4WIf7aZqTDO37UIc6xdMEppYwRI4 _2TI2z6UpuAmm.j_NKn70hH5cQlx7NPcSheHYflrU5tGFyFh0GTnozfL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ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Wed, 23 Mar 2022 23:17:10 +0000 Received: by kubenode506.mail-prod1.omega.ne1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 31ba72db2f688872efa408a84de88f92; Wed, 23 Mar 2022 23:17:04 +0000 (UTC) Message-ID: <4080a088-8d4a-9631-3374-ded001d35c58@schaufler-ca.com> Date: Wed, 23 Mar 2022 16:17:03 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [RFC PATCH] getvalues(2) prototype Content-Language: en-US To: Dave Chinner , Miklos Szeredi Cc: 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 , Ian Kent , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , James Bottomley , Casey Schaufler References: <20220322192712.709170-1-mszeredi@redhat.com> <20220323225843.GI1609613@dread.disaster.area> From: Casey Schaufler In-Reply-To: <20220323225843.GI1609613@dread.disaster.area> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.19987 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 3/23/2022 3:58 PM, Dave Chinner wrote: > On Tue, Mar 22, 2022 at 08:27:12PM +0100, Miklos Szeredi wrote: >> Add a new userspace API that allows getting multiple short values in a >> single syscall. >> >> This would be useful for the following reasons: >> >> - Calling open/read/close for many small files is inefficient. E.g. on my >> desktop invoking lsof(1) results in ~60k open + read + close calls under >> /proc and 90% of those are 128 bytes or less. > How does doing the open/read/close in a single syscall make this any > more efficient? All it saves is the overhead of a couple of > syscalls, it doesn't reduce any of the setup or teardown overhead > needed to read the data itself.... > >> - 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/ > >> - Some attributes are cheap to generate, some are expensive. Allowing >> userspace to select which ones it needs should allow optimizing queries. >> >> - Adding an ascii namespace should allow easy extension and self >> description. >> >> - The values can be text or binary, whichever is fits best. >> >> The interface definition is: >> >> struct name_val { >> const char *name; /* in */ >> struct iovec value_in; /* in */ >> struct iovec value_out; /* out */ >> uint32_t error; /* out */ >> uint32_t reserved; >> }; > Ahhh, XFS_IOC_ATTRMULTI_BY_HANDLE reborn. This is how xfsdump gets > and sets attributes efficiently when dumping and restoring files - > it's an interface that allows batches of xattr operations to be run > on a file in a single syscall. > > 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. > > Then we just get named xattrs in batches from an open fd. > >> int getvalues(int dfd, const char *path, struct name_val *vec, size_t num, >> unsigned int flags); >> >> @dfd and @path are used to lookup object $ORIGIN. @vec contains @num >> name/value descriptors. @flags contains lookup flags for @path. >> >> The syscall returns the number of values filled or an error. >> >> A single name/value descriptor has the following fields: >> >> @name describes the object whose value is to be returned. E.g. >> >> 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. There is a significant and vocal set of people who dislike xattrs passionately. I often hear them whinging whenever someone proposes using them. I think that your suggestion has all the advantages of the getvalues(2) interface while also addressing its shortcomings. If we could get it past the anti-xattr crowd we might have something. You could even provide getvalues() on top of it. > > 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? > > Cheers, > > Dave. >