linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: viro@zeniv.linux.org.uk
Cc: torvalds@linux-foundation.org, dhowells@redhat.com,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 35/38] afs: Add fsinfo support [ver #10]
Date: Fri, 27 Jul 2018 18:35:16 +0100	[thread overview]
Message-ID: <153271291695.9458.8521989831386567633.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <153271267980.9458.7640156373438016898.stgit@warthog.procyon.org.uk>

Add fsinfo support to the AFS filesystem.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/afs/super.c |  133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)

diff --git a/fs/afs/super.c b/fs/afs/super.c
index 55f11477ade6..852526f17e4a 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -26,6 +26,7 @@
 #include <linux/sched.h>
 #include <linux/nsproxy.h>
 #include <linux/magic.h>
+#include <linux/fsinfo.h>
 #include <net/net_namespace.h>
 #include "internal.h"
 
@@ -34,6 +35,7 @@ static void afs_kill_super(struct super_block *sb);
 static struct inode *afs_alloc_inode(struct super_block *sb);
 static void afs_destroy_inode(struct inode *inode);
 static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
+static int afs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params);
 static int afs_show_devname(struct seq_file *m, struct dentry *root);
 static int afs_show_options(struct seq_file *m, struct dentry *root);
 static int afs_init_fs_context(struct fs_context *fc, struct dentry *reference);
@@ -53,6 +55,7 @@ int afs_net_id;
 
 static const struct super_operations afs_super_ops = {
 	.statfs		= afs_statfs,
+	.get_fsinfo	= afs_get_fsinfo,
 	.alloc_inode	= afs_alloc_inode,
 	.drop_inode	= afs_drop_inode,
 	.destroy_inode	= afs_destroy_inode,
@@ -771,3 +774,133 @@ static int afs_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 	return ret;
 }
+
+/*
+ * Get filesystem information.
+ */
+static int afs_get_fsinfo(struct dentry *dentry, struct fsinfo_kparams *params)
+{
+	struct fsinfo_timestamp_info *tsinfo;
+	struct fsinfo_server_address *addr;
+	struct fsinfo_capabilities *caps;
+	struct fsinfo_supports *sup;
+	struct afs_server_list *slist;
+	struct afs_super_info *as = AFS_FS_S(dentry->d_sb);
+	struct afs_addr_list *alist;
+	struct afs_server *server;
+	struct afs_volume *volume = as->volume;
+	struct afs_cell *cell = as->cell;
+	struct afs_net *net = afs_d2net(dentry);
+	bool dyn_root = as->dyn_root;
+	int ret;
+
+	switch (params->request) {
+	case fsinfo_attr_timestamp_info:
+		tsinfo = params->buffer;
+		tsinfo->minimum_timestamp = 0;
+		tsinfo->maximum_timestamp = UINT_MAX;
+		tsinfo->mtime_gran_mantissa = 1;
+		tsinfo->mtime_gran_exponent = 0;
+		return sizeof(*tsinfo);
+
+	case fsinfo_attr_supports:
+		sup = params->buffer;
+		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);
+
+	case fsinfo_attr_capabilities:
+		caps = params->buffer;
+		if (dyn_root) {
+			fsinfo_set_cap(caps, fsinfo_cap_is_automounter_fs);
+			fsinfo_set_cap(caps, fsinfo_cap_automounts);
+		} else {
+			fsinfo_set_cap(caps, fsinfo_cap_is_network_fs);
+			fsinfo_set_cap(caps, fsinfo_cap_automounts);
+			fsinfo_set_cap(caps, fsinfo_cap_adv_locks);
+			fsinfo_set_cap(caps, fsinfo_cap_uids);
+			fsinfo_set_cap(caps, fsinfo_cap_gids);
+			fsinfo_set_cap(caps, fsinfo_cap_volume_id);
+			fsinfo_set_cap(caps, fsinfo_cap_volume_name);
+			fsinfo_set_cap(caps, fsinfo_cap_cell_name);
+			fsinfo_set_cap(caps, fsinfo_cap_iver_mono_incr);
+			fsinfo_set_cap(caps, fsinfo_cap_symlinks);
+			fsinfo_set_cap(caps, fsinfo_cap_hard_links_1dir);
+			fsinfo_set_cap(caps, fsinfo_cap_has_mtime);
+		}
+		return sizeof(*caps);
+
+	case fsinfo_attr_volume_name:
+		if (dyn_root)
+			return -EOPNOTSUPP;
+		if (params->buffer)
+			memcpy(params->buffer, volume->name, volume->name_len);
+		return volume->name_len;
+
+	case fsinfo_attr_cell_name:
+		if (dyn_root)
+			return -EOPNOTSUPP;
+		if (params->buffer)
+			memcpy(params->buffer, cell->name, cell->name_len);
+		return cell->name_len;
+
+	case fsinfo_attr_server_name:
+		if (dyn_root)
+			return -EOPNOTSUPP;
+		read_lock(&volume->servers_lock);
+		slist = afs_get_serverlist(volume->servers);
+		read_unlock(&volume->servers_lock);
+
+		if (params->Nth < slist->nr_servers) {
+			server = slist->servers[params->Nth].server;
+			if (params->buffer)
+				ret = sprintf(params->buffer, "%pU", &server->uuid);
+			else
+				ret = 16 * 2 + 4;
+		} else {
+			ret = -ENODATA;
+		}
+
+		afs_put_serverlist(net, slist);
+		return ret;
+
+	case fsinfo_attr_server_address:
+		addr = params->buffer;
+		if (dyn_root)
+			return -EOPNOTSUPP;
+		read_lock(&volume->servers_lock);
+		slist = afs_get_serverlist(volume->servers);
+		read_unlock(&volume->servers_lock);
+
+		ret = -ENODATA;
+		if (params->Nth >= slist->nr_servers)
+			goto put_slist;
+		server = slist->servers[params->Nth].server;
+
+		read_lock(&server->fs_lock);
+		alist = afs_get_addrlist(rcu_access_pointer(server->addresses));
+		read_unlock(&server->fs_lock);
+		if (!alist)
+			goto put_slist;
+
+		if (params->Mth >= alist->nr_addrs)
+			goto put_alist;
+
+		memcpy(addr, &alist->addrs[params->Mth],
+		       sizeof(struct sockaddr_rxrpc));
+		ret = sizeof(*addr);
+
+	put_alist:
+		afs_put_addrlist(alist);
+	put_slist:
+		afs_put_serverlist(net, slist);
+		return ret;
+
+	default:
+		return generic_fsinfo(dentry, params);
+	}
+}

  parent reply	other threads:[~2018-07-27 18:58 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 17:31 [PATCH 00/38] VFS: Introduce filesystem context [ver #10] David Howells
2018-07-27 17:31 ` [PATCH 01/38] vfs: syscall: Add open_tree(2) to reference or clone a mount " David Howells
2018-07-27 17:31 ` [PATCH 02/38] vfs: syscall: Add move_mount(2) to move mounts around " David Howells
2018-07-27 17:31 ` [PATCH 03/38] teach move_mount(2) to work with OPEN_TREE_CLONE " David Howells
2018-07-27 17:31 ` [PATCH 04/38] vfs: Suppress MS_* flag defs within the kernel unless explicitly enabled " David Howells
2018-07-27 17:31 ` [PATCH 05/38] vfs: Introduce the basic header for the new mount API's filesystem context " David Howells
2018-07-27 17:32 ` [PATCH 06/38] vfs: Introduce logging functions " David Howells
2018-07-27 17:32 ` [PATCH 07/38] vfs: Add configuration parser helpers " David Howells
2018-07-27 17:32 ` [PATCH 08/38] vfs: Add LSM hooks for the new mount API " David Howells
2018-07-27 17:32 ` [PATCH 09/38] selinux: Implement the new mount API LSM hooks " David Howells
2018-07-27 17:32 ` [PATCH 10/38] smack: Implement filesystem context security " David Howells
2018-07-27 17:32 ` [PATCH 11/38] apparmor: Implement security hooks for the new mount API " David Howells
2018-07-27 17:32 ` [PATCH 12/38] vfs: Pass key and value into LSM and FS and provide a helper parser " David Howells
2018-07-27 17:32 ` [PATCH 13/38] tomoyo: Implement security hooks for the new mount API " David Howells
2018-07-28  2:29   ` Tetsuo Handa
2018-07-30 10:49   ` David Howells
2018-07-27 17:32 ` [PATCH 14/38] vfs: Separate changing mount flags full remount " David Howells
2018-07-27 17:33 ` [PATCH 15/38] vfs: Implement a filesystem superblock creation/configuration context " David Howells
2018-07-27 17:33 ` [PATCH 16/38] vfs: Remove unused code after filesystem context changes " David Howells
2018-07-27 17:33 ` [PATCH 17/38] procfs: Move proc_fill_super() to fs/proc/root.c " David Howells
2018-07-27 17:33 ` [PATCH 18/38] proc: Add fs_context support to procfs " David Howells
2018-07-27 17:33 ` [PATCH 19/38] ipc: Convert mqueue fs to fs_context " David Howells
2018-07-27 17:33 ` [PATCH 20/38] cpuset: Use " David Howells
2018-07-27 17:33 ` [PATCH 21/38] kernfs, sysfs, cgroup, intel_rdt: Support " David Howells
2018-07-27 17:33 ` [PATCH 22/38] hugetlbfs: Convert to " David Howells
2018-07-27 17:33 ` [PATCH 23/38] vfs: Remove kern_mount_data() " David Howells
2018-07-27 17:34 ` [PATCH 24/38] vfs: Provide documentation for new mount API " David Howells
2018-07-27 17:34 ` [PATCH 25/38] Make anon_inodes unconditional " David Howells
2018-07-27 20:04   ` Randy Dunlap
2018-07-30 10:52   ` David Howells
2018-07-27 17:34 ` [PATCH 26/38] vfs: syscall: Add fsopen() to prepare for superblock creation " David Howells
2018-07-27 17:34 ` [PATCH 27/38] vfs: Implement logging through fs_context " David Howells
2018-07-27 17:34 ` [PATCH 28/38] vfs: Add some logging to the core users of the fs_context log " David Howells
2018-07-27 17:34 ` [PATCH 29/38] vfs: syscall: Add fsconfig() for configuring and managing a context " David Howells
2018-07-27 19:42   ` Andy Lutomirski
2018-07-27 21:51   ` David Howells
2018-07-27 21:57     ` Andy Lutomirski
2018-07-27 22:27     ` David Howells
2018-07-27 22:32   ` Jann Horn
2018-07-29  8:50   ` David Howells
2018-07-29 11:14     ` Jann Horn
2018-07-30 12:32     ` David Howells
2018-07-27 17:34 ` [PATCH 30/38] vfs: syscall: Add fsmount() to create a mount for a superblock " David Howells
2018-07-27 19:27   ` Andy Lutomirski
2018-07-27 19:43     ` Andy Lutomirski
2018-07-27 22:09     ` David Howells
2018-07-27 22:06   ` David Howells
2018-07-27 17:34 ` [PATCH 31/38] vfs: syscall: Add fspick() to select a superblock for reconfiguration " David Howells
2018-07-27 17:34 ` [PATCH 32/38] afs: Add fs_context support " David Howells
2018-07-27 17:35 ` [PATCH 33/38] afs: Use fs_context to pass parameters over automount " David Howells
2018-07-27 17:35 ` [PATCH 34/38] vfs: syscall: Add fsinfo() to query filesystem information " David Howells
2018-07-27 19:35   ` Andy Lutomirski
2018-07-27 22:12   ` David Howells
2018-07-27 23:14   ` Jann Horn
2018-07-27 23:49   ` David Howells
2018-07-28  0:14     ` Anton Altaparmakov
2018-07-27 23:51   ` David Howells
2018-07-27 23:58     ` Jann Horn
2018-07-28  0:08     ` David Howells
2018-07-30 14:48   ` David Howells
2018-07-31  4:16   ` Al Viro
2018-07-31 12:39   ` David Howells
2018-07-31 13:20   ` David Howells
2018-07-31 23:49   ` Darrick J. Wong
2018-08-01  1:07   ` David Howells
2018-07-27 17:35 ` David Howells [this message]
2018-07-27 17:35 ` [PATCH 36/38] vfs: Add a sample program for the new mount API " David Howells
2018-07-29 11:37   ` Pavel Machek
2018-07-30 12:23   ` David Howells
2018-07-30 14:31     ` Pavel Machek
2018-07-30 18:08       ` Matthew Wilcox
2018-07-30 18:16         ` Pavel Machek
2018-07-30 18:18         ` Linus Torvalds
2018-07-30 18:38           ` Matthew Wilcox
2018-07-30 18:59             ` Linus Torvalds
2018-07-30 19:49               ` Matthew Wilcox
2018-07-30 21:02                 ` Theodore Y. Ts'o
2018-07-30 21:23                   ` Pavel Machek
2018-07-30 23:58                   ` Matthew Wilcox
2018-07-31  0:58                     ` Theodore Y. Ts'o
2018-07-31  9:40                       ` Pavel Machek
2018-07-31 10:11                       ` David Howells
2018-07-31 11:34                         ` Pavel Machek
2018-07-31 12:07                           ` Matthew Wilcox
2018-07-31 12:28                             ` Pavel Machek
2018-07-31 13:33                               ` Al Viro
2018-07-31 13:00                             ` David Howells
2018-07-31 19:39                               ` Pavel Machek
2018-07-31 21:00                               ` David Howells
2018-07-31 21:21                                 ` Linus Torvalds
2018-07-31 21:38                                 ` David Howells
2018-07-30 20:47               ` Pavel Machek
2018-07-30 15:33     ` David Howells
2018-07-30 17:30       ` Pavel Machek
2018-07-30 17:54         ` Linus Torvalds
2018-07-30 18:16           ` Pavel Machek
2018-07-27 17:35 ` [PATCH 37/38] vfs: Allow fsinfo() to query what's in an fs_context " David Howells
2018-07-27 17:35 ` [PATCH 38/38] vfs: Allow fsinfo() to be used to query an fs parameter description " 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=153271291695.9458.8521989831386567633.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --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).