public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Karel Zak <kzak@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-fsdevel@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>,
	Greg KH <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	Linux API <linux-api@vger.kernel.org>,
	linux-man <linux-man@vger.kernel.org>,
	LSM <linux-security-module@vger.kernel.org>,
	Ian Kent <raven@themaw.net>, David Howells <dhowells@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <christian@brauner.io>,
	Amir Goldstein <amir73il@gmail.com>,
	James Bottomley <James.Bottomley@hansenpartnership.com>
Subject: Re: [RFC PATCH] getting misc stats/attributes via xattr API
Date: Wed, 11 May 2022 09:25:52 +1000	[thread overview]
Message-ID: <20220510232552.GD2306852@dread.disaster.area> (raw)
In-Reply-To: <20220510123512.h6jjqgowex6gnjh5@ws.net.home>

On Tue, May 10, 2022 at 02:35:12PM +0200, Karel Zak wrote:
> On Mon, May 09, 2022 at 02:48:15PM +0200, 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.).
> 
> Sounds like David's fsinfo() :-)
> 
> We need an interface where the kernel returns a consistent mount table    
> entry (more syscalls to get more key=value could be a way how to get
> inconsistent data).                                              
> 
> IMHO all the attempts to make a trivial interface will be unsuccessful
> because the mount table is complex (tree) and mixes strings, paths,
> and flags. We will always end with a complex interface or complex
> strings (like the last xatts attempt). There is no 3rd path to go ...
> 
> The best would be simplified fsinfo() where userspace defines
> a request (wanted "keys"), and the kernel fills a buffer with data
> separated by some header metadata struct. In this case, the kernel can
> return strings and structs with binary data.  
> 
> 
> I'd love something like:
> 
> ssize_t sz;
> fsinfo_query query[] = {
>     { .request = FSINFO_MOUNT_PATH },
>     { .request = FSINFO_PROPAGATION },
>     { .request = FSINFO_CHILDREN_IDS },
> };
> 
> sz = fsinfo(dfd, "", AT_EMPTY_PATH,
>                 &query, ARRAY_SIZE(query),
>                 buf, sizeof(buf));
> 
> for (p = buf; p < buf + sz; ) {
> {
>     fsinfo_entry *e = (struct fsinfo_entry) p;
>     char *data = p + sizeof(struct fsinfo_entry);
> 
>     switch(e->request) {
>     case FSINFO_MOUNT_PATH:
>         printf("mountpoint %s\n", data);
>         break;
>     case FSINFO_PROPAGATION:
>         printf("propagation %x\n", (uintptr_t) data);
>         break;
>     case FSINFO_CHILDREN_IDS:
>         fsinfo_child *x = (fsinfo_child *) data;
>         for (i = 0; i < e->count; i++) {
>             printf("child: %d\n", x[i].mnt_id);
>         }
>         break;
>     ...
>     }
> 
>     p += sizeof(struct fsinfo_entry) + e->len;
> }

That's pretty much what a multi-xattr get operation looks like.
It's a bit more more intricate in the setup of the request/return
buffer, but otherwise the structure of the code is the same.

I just don't see why we need special purpose interfaces like this
for key/value information when small tweaks to the existing
generic key/value interfaces can provide exactly the same
functionality....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2022-05-10 23:26 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03 12:23 [RFC PATCH] getting misc stats/attributes via xattr API Miklos Szeredi
2022-05-03 14:39 ` Amir Goldstein
2022-05-03 14:53   ` Greg KH
2022-05-03 15:04     ` Miklos Szeredi
2022-05-03 15:14       ` Amir Goldstein
2022-05-03 16:54       ` Greg KH
2022-05-03 22:43 ` Dave Chinner
2022-05-04  7:18   ` Miklos Szeredi
2022-05-04 14:22     ` Amir Goldstein
2022-05-05 12:30 ` Karel Zak
2022-05-05 13:59   ` Miklos Szeredi
2022-05-05 23:38 ` tytso
2022-05-06  0:06   ` Amir Goldstein
2022-05-07  0:32   ` Dave Chinner
2022-05-09 12:48 ` Christian Brauner
2022-05-09 14:20   ` Amir Goldstein
2022-05-09 15:08     ` Christian Brauner
2022-05-09 17:07       ` Amir Goldstein
2022-05-09 21:42       ` Vivek Goyal
2022-05-10  3:34         ` Ian Kent
2022-05-10  0:55   ` Dave Chinner
2022-05-10 12:40     ` Christian Brauner
2022-05-11  0:42       ` Dave Chinner
2022-05-11  9:16         ` Christian Brauner
2022-05-10 12:45     ` Florian Weimer
2022-05-10 23:04       ` Dave Chinner
2022-05-10  3:49   ` Miklos Szeredi
2022-05-10  4:27     ` Ian Kent
2022-05-10  8:06       ` Miklos Szeredi
2022-05-10  8:07         ` Miklos Szeredi
2022-05-10 11:53     ` Christian Brauner
2022-05-10 13:15       ` Miklos Szeredi
2022-05-10 13:18         ` Miklos Szeredi
2022-05-10 14:19         ` Christian Brauner
2022-05-10 14:41           ` Miklos Szeredi
2022-05-10 15:30             ` Christian Brauner
2022-05-10 15:47               ` Miklos Szeredi
2022-05-10 15:53                 ` Christian Brauner
2022-05-10 12:35   ` Karel Zak
2022-05-10 23:25     ` Dave Chinner [this message]
2022-05-11  8:58       ` Karel Zak
2022-11-14  9:00 ` Abel Wu
2022-11-14 12:35   ` Miklos Szeredi
2022-11-15  3:39     ` Abel Wu
2023-04-15 11:06     ` [LSF/MM TOPIC] fsinfo and mount namespace notifications Amir Goldstein
2023-04-18  8:54       ` Miklos Szeredi
2023-04-18 15:56         ` Amir Goldstein
2023-04-18 18:57           ` Miklos Szeredi
2023-04-19  8:18             ` Amir Goldstein
2023-04-19  8:43               ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220510232552.GD2306852@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=christian@brauner.io \
    --cc=dhowells@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kzak@redhat.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=raven@themaw.net \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox