Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp68505pxa; Tue, 18 Aug 2020 16:11:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEzR+CGgl1Ec3XoymPF/ympcOOMiDtVjBTEfHZsbr+aUvzjmqxILDSi3DH6m0ZWkPkkEAp X-Received: by 2002:a50:8f44:: with SMTP id 62mr22793207edy.3.1597792276951; Tue, 18 Aug 2020 16:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597792276; cv=none; d=google.com; s=arc-20160816; b=0pKqovekBjIgCUaPXsnEp4bCHMB8O4LHDvdPcJnC/UI0K4Jv3pee5nydpdgCgkYWZE TWgeKa7B2gIThmRzonJBD4Ya+Mj2e85Qif0NJ4PBukktCcom3xVUh1FfD0/9tv/pHXRj grt5Lz8W03v3GOOOuU9w8PDuyaK+lzZqYVstY+zg78pyXwET0r8DZZxZqWcDNWd0nnMm 5OcBFavDPoRHKlLCH4A6lBIuoQzM1xMyURxwZCeaCoZfNtbjDmOK5K9SGrGVycJBLhI2 jeqmXe/G/XhDBk6oErLzyAA77fa4QttR7NG52NC0DzWlQu+MrZOh1SqGWIuP6BVVa43a VT2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=44jjlz9gHZ8bxkxJCT+KFdrq1JkP5ys9BBa+Qk39NAU=; b=TuYIFh6TmaAp1BHDZXy5sZPpS6r+bPIbvdrfyKQ/AMV9BTECsTzXheMMdNd2KGk2sv BSwPUWwWceQWzL49kXprAWkdbyZBQSNznbls7F38PO3pcpzdhdeaP2S/v+TvoX/+mbce 0IgNlL7BjVdufjAp47YxmZGmL9ddSaGG57Cs0iowfxIEl4AGAU0qMLhlAFOQExB6p/ZN RvP6r+Co0pHhe7IVWw0CC57GPBKshn5ukg00XCkzhYY6mAi15ueRlP9ecMeEP3rkR+Oz PijwgcxRsNzdYzOJXRXYHaleWCt5tKPDkKVru1lxVjab4jBX6iU+IRlg9i64hw/fNjA8 WfLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=KmKfogzw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si13750816eju.316.2020.08.18.16.10.52; Tue, 18 Aug 2020 16:11:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=KmKfogzw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbgHRUxd (ORCPT + 99 others); Tue, 18 Aug 2020 16:53:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbgHRUxc (ORCPT ); Tue, 18 Aug 2020 16:53:32 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6089C061343 for ; Tue, 18 Aug 2020 13:53:31 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id f26so22961141ljc.8 for ; Tue, 18 Aug 2020 13:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=44jjlz9gHZ8bxkxJCT+KFdrq1JkP5ys9BBa+Qk39NAU=; b=KmKfogzwUujvQb/F0JA/vopaWbvFysSlsxJrpItNo5RKDQ8MIZrythcEa0jhqcR97h 6k/jvzQGWfMSCchn3FxL3xWMnBP2o1wmrl8y6sRimpA8Bh+iDfzxbjypP5Ke/mhWrexJ Ac+8fu9qUv1fiSsbJIE2/XWj5iLbyNhOIcPwQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=44jjlz9gHZ8bxkxJCT+KFdrq1JkP5ys9BBa+Qk39NAU=; b=XLkT+dkBX7MvTCzjO/GToOzmtt+k64Jh3Mw7yyYXVGEN2RlT6oX4APynEQbxtvhiQf ax0XhSvKBNOcOncFGmlQmbh0+K7Grh818/NhgZLRTtqbhStTUF/Bq0VKgsvUN/wpNKkf lR6MemYYDsB0jNqQoGtDrZrFpZD8H8FjzkL5OmgQdvmZAzGWL30XuIdCP+flmQHV9HTq rzBjkwp09IKaXMq+M5NvVm8PgH7MMQUP78W72TdCtF2XRMIGRnVFwpWpnqJ4FGcazu52 JFfVrT+OeGJYoWikE9wNUS2uJevjS904E1E4Yk/CpYxG/q7OTPNhrL+Mb+32Dl8k1c8t M5gA== X-Gm-Message-State: AOAM532WNyXmbLBgaOBfHA2OhgFOmbmqI71KadPRQqH+H0Q8Mn0aXc1V CFfUc/Z0we/pAq3Dsvpz4hjZT5X/12QliA== X-Received: by 2002:a2e:9ed4:: with SMTP id h20mr10663202ljk.82.1597784009868; Tue, 18 Aug 2020 13:53:29 -0700 (PDT) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com. [209.85.208.181]) by smtp.gmail.com with ESMTPSA id f12sm6212072ljn.14.2020.08.18.13.53.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Aug 2020 13:53:28 -0700 (PDT) Received: by mail-lj1-f181.google.com with SMTP id v12so22968442ljc.10 for ; Tue, 18 Aug 2020 13:53:27 -0700 (PDT) X-Received: by 2002:a2e:b008:: with SMTP id y8mr9400093ljk.421.1597784007533; Tue, 18 Aug 2020 13:53:27 -0700 (PDT) MIME-Version: 1.0 References: <1842689.1596468469@warthog.procyon.org.uk> <1845353.1596469795@warthog.procyon.org.uk> <20200811135419.GA1263716@miu.piliscsaba.redhat.com> <52483.1597190733@warthog.procyon.org.uk> <066f9aaf-ee97-46db-022f-5d007f9e6edb@redhat.com> <94f907f0-996e-0456-db8a-7823e2ef3d3f@redhat.com> In-Reply-To: From: Linus Torvalds Date: Tue, 18 Aug 2020 13:53:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: file metadata via fs API To: Miklos Szeredi Cc: Steven Whitehouse , David Howells , linux-fsdevel , Al Viro , Karel Zak , Jeff Layton , Miklos Szeredi , Nicolas Dichtel , Christian Brauner , Lennart Poettering , Linux API , Ian Kent , LSM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 18, 2020 at 1:18 PM Miklos Szeredi wrote: > > So why mix a binary structure into it? Would it not make more sense > to make it text only? .. because for basic and standard stuff, the binary structure just makes sense and is easier for everybody. When I want to get the size of a file, I do "stat()" on it, and get the size from st.st_size. That's convenient, and there's no reason _not_ to do it. Returning the size as an ASCII string would be completely pointless and annoying as hell. So binary formats have their places. But those places are for standard and well-understood fields that are commonly accessed and do not have any free-form or wild components to them that needs to be marshalled into some binary format. Whenever you have free-form data, just use ASCII. It's what "mount" already uses, for chrissake. We pass in mount options as ASCII for a good reason. Basically, I think a rough rule of thumb can and should be: - stuff that the VFS knows about natively and fully is clearly pretty mount-agnostic and generic, and can be represented in whatever extended "struct statfs_x" directly. - anything that is variable-format and per-fs should be expressed in the ASCII buffer Look at our fancy new fs_context - that's pretty much what it does even inside the kernel. Sure, we have "binary" fields there for core basic information ("struct dentry *root", but also things like flags with MNT_NOSUID), but the configuration stuff is ASCII that the filesystem can parse itself. Exactly because some things are very much specific to some filesystems, not generic things. So we fundamentally already have a mix of "standard FS data" and "filesystem-specific options", and it's already basically split that way: binary flag fields for the generic stuff, and ASCII text for the odd options. Again: binary data isn't wrong when it's a fixed structure that didn't need some odd massaging or marshalling or parsing. Just a simple fixed structure. That is _the_ most common kernel interface, used for almost everything. Sometimes we have arrays of them, but most of the time it's a single struct pointer. But binary data very much is wrong the moment you think you need to have a parser to read it, or a marshaller to write it. Just use ASCII. I really would prefer for the free-form data to have a lot of commonalities with the /proc/mounts line. Not because that's a wonderful format, but because there are very very few truly wonderful formats out there, and in the absense of "wonderful", I'd much prefer "familiar" and "able to use common helpers" (hopefully both on the kernel side and the user side).. Linus