From: Jann Horn <jannh@google.com>
To: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
raven@themaw.net, Miklos Szeredi <mszeredi@redhat.com>,
Christian Brauner <christian@brauner.io>,
Linux API <linux-api@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 11/19] afs: Support fsinfo() [ver #16]
Date: Wed, 19 Feb 2020 22:01:47 +0100 [thread overview]
Message-ID: <CAG48ez0fsB_XTmNfE-2tuabH7JHyQdih8bu7Qwu9HGWJXti7tQ@mail.gmail.com> (raw)
In-Reply-To: <158204558110.3299825.5080605285325995873.stgit@warthog.procyon.org.uk>
On Tue, Feb 18, 2020 at 6:07 PM David Howells <dhowells@redhat.com> wrote:
> Add fsinfo support to the AFS filesystem.
[...]
> static const struct super_operations afs_super_ops = {
> .statfs = afs_statfs,
> +#ifdef CONFIG_FSINFO
> + .fsinfo_attributes = afs_fsinfo_attributes,
> +#endif
> + .alloc_inode = afs_alloc_inode,
> + .drop_inode = afs_drop_inode,
> + .destroy_inode = afs_destroy_inode,
> + .free_inode = afs_free_inode,
> + .evict_inode = afs_evict_inode,
> + .show_devname = afs_show_devname,
> + .show_options = afs_show_options,
> +};
> +
> +static const struct super_operations afs_dyn_super_ops = {
> + .statfs = afs_statfs,
> +#ifdef CONFIG_FSINFO
> + .fsinfo_attributes = afs_dyn_fsinfo_attributes,
> +#endif
> .alloc_inode = afs_alloc_inode,
> .drop_inode = afs_drop_inode,
> .destroy_inode = afs_destroy_inode,
[...]
> @@ -432,9 +454,12 @@ static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx)
> sb->s_blocksize_bits = PAGE_SHIFT;
> sb->s_maxbytes = MAX_LFS_FILESIZE;
> sb->s_magic = AFS_FS_MAGIC;
> - sb->s_op = &afs_super_ops;
> - if (!as->dyn_root)
> + if (!as->dyn_root) {
> + sb->s_op = &afs_super_ops;
> sb->s_xattr = afs_xattr_handlers;
> + } else {
> + sb->s_op = &afs_dyn_super_ops;
> + }
Ewww. So basically, having one static set of .fsinfo_attributes is not
sufficiently flexible for everyone, but instead of allowing the
filesystem to dynamically provide a list of supported attributes, you
just duplicate the super_operations? Seems to me like it'd be cleaner
to add a function pointer to the super_operations that can dynamically
fill out the supported fsinfo attributes.
It seems to me like the current API is going to be a dead end if you
ever want to have decent passthrough of these things for e.g. FUSE, or
overlayfs, or VirtFS?
> ret = super_setup_bdi(sb);
> if (ret)
> return ret;
> @@ -444,7 +469,7 @@ static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx)
> if (as->dyn_root) {
> inode = afs_iget_pseudo_dir(sb, true);
> } else {
> - sprintf(sb->s_id, "%llu", as->volume->vid);
> + sprintf(sb->s_id, "%llx", as->volume->vid);
(This is technically a (small) UAPI change for audit logging of AFS
filesystems, right? You may want to note that in the commit message.)
> afs_activate_volume(as->volume);
> iget_data.fid.vid = as->volume->vid;
> iget_data.fid.vnode = 1;
[...]
> +static int afs_fsinfo_get_supports(struct path *path, struct fsinfo_context *ctx)
> +{
> + struct fsinfo_supports *sup = ctx->buffer;
> +
> + sup = ctx->buffer;
Duplicate assignment to "sup".
> + sup->stx_mask = (STATX_TYPE | STATX_MODE |
> + STATX_NLINK |
> + STATX_UID | STATX_GID |
> + STATX_MTIME | STATX_INO |
> + STATX_SIZE);
> + sup->stx_attributes = STATX_ATTR_AUTOMOUNT;
> + return sizeof(*sup);
> +}
[...]
> +static int afs_fsinfo_get_server_address(struct path *path, struct fsinfo_context *ctx)
> +{
> + struct fsinfo_afs_server_address *addr = ctx->buffer;
> + struct afs_server_list *slist;
> + struct afs_super_info *as = AFS_FS_S(path->dentry->d_sb);
> + struct afs_addr_list *alist;
> + struct afs_volume *volume = as->volume;
> + struct afs_server *server;
> + struct afs_net *net = afs_d2net(path->dentry);
> + unsigned int i;
> + int ret = -ENODATA;
> +
> + read_lock(&volume->servers_lock);
> + slist = afs_get_serverlist(volume->servers);
> + read_unlock(&volume->servers_lock);
> +
> + if (ctx->Nth >= slist->nr_servers)
> + goto put_slist;
> + server = slist->servers[ctx->Nth].server;
> +
> + read_lock(&server->fs_lock);
> + alist = afs_get_addrlist(rcu_access_pointer(server->addresses));
Documentation for rcu_access_pointer() says:
* Return the value of the specified RCU-protected pointer, but omit the
* lockdep checks for being in an RCU read-side critical section. This is
* useful when the value of this pointer is accessed, but the pointer is
* not dereferenced, for example, when testing an RCU-protected pointer
* against NULL. Although rcu_access_pointer() may also be used in cases
* where update-side locks prevent the value of the pointer from changing,
* you should instead use rcu_dereference_protected() for this use case.
*
* It is also permissible to use rcu_access_pointer() when read-side
* access to the pointer was removed at least one grace period ago, as
* is the case in the context of the RCU callback that is freeing up
* the data, or after a synchronize_rcu() returns. This can be useful
* when tearing down multi-linked structures after a grace period
* has elapsed.
> + read_unlock(&server->fs_lock);
next prev parent reply other threads:[~2020-02-19 21:02 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 17:04 [PATCH 00/19] VFS: Filesystem information and notifications [ver #16] David Howells
2020-02-18 17:05 ` [PATCH 01/19] vfs: syscall: Add fsinfo() to query filesystem information " David Howells
2020-02-19 16:31 ` Darrick J. Wong
2020-02-19 20:07 ` Jann Horn
2020-02-20 10:34 ` David Howells
2020-02-20 15:48 ` Darrick J. Wong
2020-02-20 11:03 ` David Howells
2020-02-20 14:54 ` Jann Horn
2020-02-20 15:31 ` Darrick J. Wong
2020-02-18 17:05 ` [PATCH 02/19] fsinfo: Add syscalls to other arches " David Howells
2020-02-21 14:51 ` Christian Brauner
2020-02-21 18:10 ` Geert Uytterhoeven
2020-02-18 17:05 ` [PATCH 03/19] fsinfo: Provide a bitmap of supported features " David Howells
2020-02-19 16:37 ` Darrick J. Wong
2020-02-20 12:22 ` David Howells
2020-02-18 17:05 ` [PATCH 04/19] vfs: Add mount change counter " David Howells
2020-02-21 14:48 ` Christian Brauner
2020-02-18 17:05 ` [PATCH 05/19] vfs: Introduce a non-repeating system-unique superblock ID " David Howells
2020-02-19 16:53 ` Darrick J. Wong
2020-02-20 12:45 ` David Howells
2020-02-18 17:05 ` [PATCH 06/19] vfs: Allow fsinfo() to look up a mount object by " David Howells
2020-02-21 15:09 ` Christian Brauner
2020-02-18 17:05 ` [PATCH 07/19] vfs: Allow mount information to be queried by fsinfo() " David Howells
2020-02-18 17:05 ` [PATCH 08/19] vfs: fsinfo sample: Mount listing program " David Howells
2020-02-18 17:06 ` [PATCH 09/19] fsinfo: Allow the mount topology propogation flags to be retrieved " David Howells
2020-02-18 17:06 ` [PATCH 10/19] fsinfo: Add API documentation " David Howells
2020-02-18 17:06 ` [PATCH 11/19] afs: Support fsinfo() " David Howells
2020-02-19 21:01 ` Jann Horn [this message]
2020-02-20 12:58 ` David Howells
2020-02-20 14:58 ` Jann Horn
2020-02-21 13:26 ` David Howells
2020-02-18 17:06 ` [PATCH 12/19] security: Add hooks to rule on setting a superblock or mount watch " David Howells
2020-02-18 17:06 ` [PATCH 13/19] vfs: Add a mount-notification facility " David Howells
2020-02-19 22:40 ` Jann Horn
2020-02-19 22:55 ` Jann Horn
2020-02-21 12:24 ` David Howells
2020-02-21 15:49 ` Jann Horn
2020-02-21 17:06 ` David Howells
2020-02-21 17:36 ` seq_lock and lockdep_is_held() assertions Jann Horn
2020-02-21 18:02 ` John Stultz
2020-02-18 17:06 ` [PATCH 14/19] notifications: sample: Display mount tree change notifications [ver #16] David Howells
2020-02-18 17:06 ` [PATCH 15/19] vfs: Add superblock " David Howells
2020-02-19 23:08 ` Jann Horn
2020-02-21 14:23 ` David Howells
2020-02-21 15:44 ` Jann Horn
2020-02-21 16:33 ` David Howells
2020-02-21 16:41 ` Jann Horn
2020-02-21 17:11 ` David Howells
2020-02-18 17:06 ` [PATCH 16/19] fsinfo: Provide superblock notification counter " David Howells
2020-02-18 17:07 ` [PATCH 17/19] notifications: sample: Display superblock notifications " David Howells
2020-02-18 17:07 ` [PATCH 18/19] ext4: Add example fsinfo information " David Howells
2020-02-19 17:04 ` Darrick J. Wong
2020-02-20 0:53 ` kbuild test robot
2020-02-21 14:43 ` David Howells
2020-02-21 16:26 ` Darrick J. Wong
2020-02-18 17:07 ` [PATCH 19/19] nfs: Add example filesystem " David Howells
2020-02-20 2:13 ` kbuild test robot
2020-02-20 2:20 ` kbuild test robot
2020-02-18 18:12 ` David Howells
2020-02-19 10:23 ` [PATCH 00/19] VFS: Filesystem information and notifications " Stefan Metzmacher
2020-02-19 14:46 ` Christian Brauner
2020-02-19 15:50 ` Darrick J. Wong
2020-02-20 4:42 ` Ian Kent
2020-02-20 9:09 ` Christian Brauner
2020-02-20 11:30 ` Ian Kent
2020-02-19 16:16 ` David Howells
2020-02-21 12:57 ` David Howells
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=CAG48ez0fsB_XTmNfE-2tuabH7JHyQdih8bu7Qwu9HGWJXti7tQ@mail.gmail.com \
--to=jannh@google.com \
--cc=christian@brauner.io \
--cc=dhowells@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=raven@themaw.net \
--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;
as well as URLs for NNTP newsgroup(s).