Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5873397iob; Tue, 10 May 2022 05:50:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4kQYkoErpJ7iJmeA83bDiw1BcPo7RLqrdL1MUFfeLeK3fN2mupRAsb+o5Jq89WyV9qzwk X-Received: by 2002:a05:6a00:1881:b0:50e:1a:f452 with SMTP id x1-20020a056a00188100b0050e001af452mr20678839pfh.75.1652187019467; Tue, 10 May 2022 05:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652187019; cv=none; d=google.com; s=arc-20160816; b=VIdzTKuFXyL4P51yyVA549NbwdoPotgpvREyq9c7zZmqM1K1P/PTJdrr07EDIa/78a SvaD0+fjjC40sriR2LXNgUrPhOIrjtZEmB1FLEqHnErjNh4WUsRlsHRlWEltiUMgz1/w MWCZyxI6CgXCEMVWE231Oqyv7q7fsaf6bK3MW/pexXQds3ulTKd/aoejGNNqTMWqK+0G m7WMCt4PvPjS5y2WSbYmmgKwMyJ/jU7pBPZc4i9In+vSpNLekqIFoZtkJaDA6JZFUsWW 13mVUsdscZVzupwkZJaG5MrkSWi/3l6BKEvcQeehi9Xw+26ouDJLODMWF17wy65t88q3 xpVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=csH2b0yln8VJjIPZKUY8Qo0Oj23Oo4VsNy+UnhWpwO0=; b=aeIuxpTqOTdO04RQ15k1LABJNx/vgZFIoMKdeCsFagvEBVUW/GqkMKnZPelEHKcmyk rJ6K3pyz4q8EUaveVR62ZMQXGYlbnSTbjpdzgt5XhVstJHCniHBbbi08993QCWfyu3GZ a4eN85GojcpeUBVm+NsR+H6cqnCX28Q4Fw/KXSrqmyGyMLyA/eEsBQMkLJYKLP797k7a 3Rb3AoNNgfKkFV+oe9lwC2rcg03Rl97+0+O+e0/8w1MVArAXEnKSBLwzHzqXw/A00JqA 6XHNlugatGCA9QgT/hPrRv87YQqS7D4zw0CirTD72rsRnkMOROXad1qMefl7u1ix3zzo yjKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=oYECvY6q; 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 l18-20020a637012000000b003c63c00260bsi3475193pgc.868.2022.05.10.05.50.02; Tue, 10 May 2022 05:50:19 -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=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=oYECvY6q; 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 S233330AbiEJDxd (ORCPT + 99 others); Mon, 9 May 2022 23:53:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232210AbiEJDxQ (ORCPT ); Mon, 9 May 2022 23:53:16 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B8893ED33 for ; Mon, 9 May 2022 20:49:18 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id p4so18490718edx.0 for ; Mon, 09 May 2022 20:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=csH2b0yln8VJjIPZKUY8Qo0Oj23Oo4VsNy+UnhWpwO0=; b=oYECvY6qXcMfackrkGXaEF2Uh8uHzvWghh2G/m/tPRNi9b9hcdKAzXapnkBfurvbuY cQk/LXQg4Z0ssHXJbTax12Vpmb8NOErMzH+BaeZdW79uWkpm8VtbWCTuTP6+XBtrszqm My2e+l5cAmZyvF0loTH1IJeyRjko0Bh2atekA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=csH2b0yln8VJjIPZKUY8Qo0Oj23Oo4VsNy+UnhWpwO0=; b=XsfWnVgTn4snQdirKqo/MBsWp2Qu/kftX9d1mHyevDS5ffQyJxj2BP9sqRItH90iPd QpjS6RK1LS8ZUHnG9Z9hV8P/+hh9LFpqzXcq+CNwzdGKaXqP4Iyak6DEOmV4PMyGiv2Q HfN3S//sFx1mwcGW/6PoEMncgwf6YXiELRIKsX8QQenh3s0hA+tVEzbb2Oqxi2Pb9sYE l7CfBfduQ4TGR97bxeopNZoJMqYKuUj6STSTbyl/uvSkq2qVZbaVpr3iZUDWebcsK4H8 Dn6IlBjfLEY4Mfs2S1GiD7hpU8pRIB5keS3sUxOddrISi6VnZ8iomxsMSsNn2vb0SGP8 hG4Q== X-Gm-Message-State: AOAM531Ngjnb4Re1IBkmNosLu3FG4GzzcyGVEWCMwn3rCtBTWrvGgVCs Prt8nsc7ghsNDLOZpVKZIfgfd/EUH+iA9Ie/q4AFSNdY4zspzpJF X-Received: by 2002:a05:6402:5ca:b0:423:f330:f574 with SMTP id n10-20020a05640205ca00b00423f330f574mr20595539edx.116.1652154556554; Mon, 09 May 2022 20:49:16 -0700 (PDT) MIME-Version: 1.0 References: <20220509124815.vb7d2xj5idhb2wq6@wittgenstein> In-Reply-To: <20220509124815.vb7d2xj5idhb2wq6@wittgenstein> From: Miklos Szeredi Date: Tue, 10 May 2022 05:49:04 +0200 Message-ID: Subject: Re: [RFC PATCH] getting misc stats/attributes via xattr API To: Christian Brauner Cc: linux-fsdevel@vger.kernel.org, Dave Chinner , "Theodore Ts'o" , Karel Zak , Greg KH , linux-kernel@vger.kernel.org, Linux API , linux-man , LSM , Ian Kent , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , James Bottomley Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 Mon, 9 May 2022 at 14:48, Christian Brauner wrote: > One comment about this. We really need to have this interface support > giving us mount options like "relatime" back in numeric form (I assume > this will be possible.). It is royally annoying having to maintain a > mapping table in userspace just to do: > > relatime -> MS_RELATIME/MOUNT_ATTR_RELATIME > ro -> MS_RDONLY/MOUNT_ATTR_RDONLY > > A library shouldn't be required to use this interface. Conservative > low-level software that keeps its shared library dependencies minimal > will need to be able to use that interface without having to go to an > external library that transforms text-based output to binary form (Which > I'm very sure will need to happen if we go with a text-based > interface.). Agreed. > This pattern of requesting the size first by passing empty arguments, > then allocating the buffer and then passing down that buffer to > retrieve that value is really annoying to use and error prone (I do > of course understand why it exists.). > > For real xattrs it's not that bad because we can assume that these > values don't change often and so the race window between > getxattr(GET_SIZE) and getxattr(GET_VALUES) often doesn't matter. But > fwiw, the post > pre check doesn't exist for no reason; we do indeed > hit that race. That code is wrong. Changing xattr size is explicitly documented in the man page as a non-error condition: If size is specified as zero, these calls return the current size of the named extended attribute (and leave value unchanged). This can be used to determine the size of the buffer that should be supplied in a subsequent call. (But, bear in mind that there is a possibility that the attribute value may change between the two calls, so that it is still necessary to check the return status from the second call.) > > In addition, it is costly having to call getxattr() twice. Again, for > retrieving xattrs it often doesn't matter because it's not a super > common operation but for mount and other info it might matter. You don't *have* to retrieve the size, it's perfectly valid to e.g. start with a fixed buffer size and double the size until the result fits. > * Would it be possible to support binary output with this interface? > I really think users would love to have an interfact where they can > get a struct with binary info back. I think that's bad taste. fsinfo(2) had the same issue. As well as mount(2) which still interprets the last argument as a binary blob in certain cases (nfs is one I know of). > Especially for some information at least. I'd really love to have a > way go get a struct mount_info or whatever back that gives me all the > details about a mount encompassed in a single struct. If we want that, then can do a new syscall with that specific struct as an argument. > Callers like systemd will have to parse text and will end up > converting everything from text into binary anyway; especially for > mount information. So giving them an option for this out of the box > would be quite good. What exactly are the attributes that systemd requires? > Interfaces like statx aim to be as fast as possible because we exptect > them to be called quite often. Retrieving mount info is quite costly > and is done quite often as well. Maybe not for all software but for a > lot of low-level software. Especially when starting services in > systemd a lot of mount parsing happens similar when starting > containers in runtimes. Was there ever a test patch for systemd using fsinfo(2)? I think not. Until systemd people start to reengineer the mount handing to allow for retrieving a single mount instead of the complete mount table we will never know where the performance bottleneck lies. > > * If we decide to go forward with this interface - and I think I > mentioned this in the lsfmm session - could we please at least add a > new system call? It really feels wrong to retrieve mount and other > information through the xattr interfaces. They aren't really xattrs. I'd argue with that statement. These are most definitely attributes. As for being extended, we'd just extended the xattr interface... Naming aside... imagine that read(2) has always been used to retrieve disk data, would you say that reading data from proc feels wrong? And in hindsight, would a new syscall for the purpose make any sense? Thanks, Miklos