Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2497034ybd; Mon, 24 Jun 2019 07:26:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB0xndcUQQvhdBoGEMFlQ7eagBH4PPBlXrvs5C+txahFSsCiOZjKy5BuXfN/05X73LhwVj X-Received: by 2002:a17:90a:9a8d:: with SMTP id e13mr25528559pjp.77.1561386409311; Mon, 24 Jun 2019 07:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561386409; cv=none; d=google.com; s=arc-20160816; b=HcLPYxpKvB3HRaLn8a4THEAULgiBScyXGwGsnx3Zt/tJuyGialgyN9Ff6TAxi8ACef aXKkfmB3JRsvWXX7u/juHF7l7majC37WnbqnV3zwpMdDxXDknI9TGTC+p1ykdONlLaHK SD+exbcNDf2rO342wc3oStXA5HsTO4ixmItuPcmNQkbMWGAbYQg0mhyTDFj+9RQynsTT rYo3kteMyPaVbbGCehayfuhkkjzj1A7B/XhPhNBNonUoxAvVdmHiB0AQofF1CnfHUh8b jscvWL2CKoZ/7UJtDeWgQ97d7CRQurjXD8QeBY+iajYl57Yvl4jGjcdokZSPBvhpgj0o yuuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization; bh=H41vi7ZZ9OeyyQfRQSleLhfjckS9kTceipL68TkTZyU=; b=sezGeXyIc3Vdnj3qvwkPAXohAIPe5Ex4GO5mnbYS5S5RbXt6xh7KXhsNpfviUQaOVG NmPF04XtQdPkwbp5lwr4TCpCt0tLZhjsu8JSvQfC3l04H1hWn+qQ6RRYYVirEL2svV0f 6FG+3vvM2V2KVdHzLligjJxKqzMbewW5fuvzGH6J2nib3XSluRg7g4c6mmHEJ8GVx7Ks sYG/IYF8IacNENjaSbOHSwd/OlnnE8p0jkr/NSd7FP9HO3MpaX94QLRTpxInhQPb22Fd y6gDYMADGML7W4Q49kxTysO11LlcedHsJq9oEHM+rljpARuk572rXOgOHr8PW0xu1SGa yYug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e21si10514201pgh.571.2019.06.24.07.26.33; Mon, 24 Jun 2019 07:26:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728940AbfFXOLA (ORCPT + 99 others); Mon, 24 Jun 2019 10:11:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43294 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726453AbfFXOLA (ORCPT ); Mon, 24 Jun 2019 10:11:00 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A9A95307D850; Mon, 24 Jun 2019 14:10:59 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-57.rdu2.redhat.com [10.10.120.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 095955D9C5; Mon, 24 Jun 2019 14:10:57 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 14/25] kernfs, cgroup: Add fsinfo support [ver #14] From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, raven@themaw.net, mszeredi@redhat.com, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 24 Jun 2019 15:10:55 +0100 Message-ID: <156138545561.25627.9159521670900500766.stgit@warthog.procyon.org.uk> In-Reply-To: <156138532485.25627.7459410522109581052.stgit@warthog.procyon.org.uk> References: <156138532485.25627.7459410522109581052.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 24 Jun 2019 14:10:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for fsinfo() to kernfs and cgroup. Signed-off-by: David Howells --- fs/kernfs/mount.c | 20 ++++++++++++++++++++ include/linux/kernfs.h | 4 ++++ kernel/cgroup/cgroup-v1.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ kernel/cgroup/cgroup.c | 19 +++++++++++++++++++ 4 files changed, 87 insertions(+) diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index 9a4646eecb71..f40d467d274b 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "kernfs-internal.h" @@ -45,6 +46,22 @@ static int kernfs_sop_show_path(struct seq_file *sf, struct dentry *dentry) return 0; } +#ifdef CONFIG_FSINFO +static int kernfs_sop_fsinfo(struct path *path, struct fsinfo_kparams *params) +{ + struct kernfs_root *root = kernfs_root(kernfs_dentry_node(path->dentry)); + struct kernfs_syscall_ops *scops = root->syscall_ops; + int ret; + + if (scops && scops->fsinfo) { + ret = scops->fsinfo(root, params); + if (ret != -EAGAIN) + return ret; + } + return generic_fsinfo(path, params); +} +#endif + const struct super_operations kernfs_sops = { .statfs = simple_statfs, .drop_inode = generic_delete_inode, @@ -52,6 +69,9 @@ const struct super_operations kernfs_sops = { .show_options = kernfs_sop_show_options, .show_path = kernfs_sop_show_path, +#ifdef CONFIG_FSINFO + .fsinfo = kernfs_sop_fsinfo, +#endif }; /* diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 2bf477f86eb1..d01ec4dc2db1 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -27,6 +27,7 @@ struct super_block; struct file_system_type; struct poll_table_struct; struct fs_context; +struct fsinfo_kparams; struct kernfs_fs_context; struct kernfs_open_node; @@ -171,6 +172,9 @@ struct kernfs_node { */ struct kernfs_syscall_ops { int (*show_options)(struct seq_file *sf, struct kernfs_root *root); +#ifdef CONFIG_FSINFO + int (*fsinfo)(struct kernfs_root *root, struct fsinfo_kparams *params); +#endif int (*mkdir)(struct kernfs_node *parent, const char *name, umode_t mode); diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index 68ca5de7ec27..c8a85dfcac87 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -921,6 +922,46 @@ const struct fs_parameter_description cgroup1_fs_parameters = { .specs = cgroup1_param_specs, }; +#ifdef CONFIG_FSINFO +static int cgroup1_fsinfo(struct kernfs_root *kf_root, struct fsinfo_kparams *params) +{ + struct cgroup_root *root = cgroup_root_from_kf(kf_root); + struct cgroup_subsys *ss; + int ssid; + + switch (params->request) { + case FSINFO_ATTR_PARAMETERS: + if (root->name[0]) + fsinfo_note_param(params, "name", root->name); + + if (test_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->cgrp.flags)) + fsinfo_note_param(params, "clone_children", NULL); + if (root->flags & CGRP_ROOT_CPUSET_V2_MODE) + fsinfo_note_param(params, "noprefix", NULL); + if (root->flags & CGRP_ROOT_NOPREFIX) + fsinfo_note_param(params, "noprefix", NULL); + if (root->flags & CGRP_ROOT_XATTR) + fsinfo_note_param(params, "xattr", NULL); + + spin_lock(&release_agent_path_lock); + if (root->release_agent_path[0]) + fsinfo_note_param(params, "release_agent", + root->release_agent_path); + spin_unlock(&release_agent_path_lock); + + + for_each_subsys(ss, ssid) { + if (root->subsys_mask & (1 << ssid)) + fsinfo_note_param(params, ss->legacy_name, NULL); + } + return params->usage; + + default: + return -EAGAIN; /* Tell kernfs to call generic_fsinfo() */ + } +} +#endif /* CONFIG_FSINFO */ + int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param) { struct cgroup_fs_context *ctx = cgroup_fc2context(fc); @@ -1114,6 +1155,9 @@ int cgroup1_reconfigure(struct fs_context *fc) struct kernfs_syscall_ops cgroup1_kf_syscall_ops = { .rename = cgroup1_rename, .show_options = cgroup1_show_options, +#ifdef CONFIG_FSINFO + .fsinfo = cgroup1_fsinfo, +#endif .mkdir = cgroup_mkdir, .rmdir = cgroup_rmdir, .show_path = cgroup_show_path, diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 4a0eb465d17e..7e32570905e9 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -1858,6 +1859,21 @@ static int cgroup_show_options(struct seq_file *seq, struct kernfs_root *kf_root return 0; } +#ifdef CONFIG_FSINFO +static int cgroup_fsinfo(struct kernfs_root *kf_root, struct fsinfo_kparams *params) +{ + switch (params->request) { + case FSINFO_ATTR_PARAMETERS: + if (cgrp_dfl_root.flags & CGRP_ROOT_NS_DELEGATE) + fsinfo_note_param(params, "nsdelegate", NULL); + return params->usage; + + default: + return -EAGAIN; /* Tell kernfs to call generic_fsinfo() */ + } +} +#endif /* CONFIG_FSINFO */ + static int cgroup_reconfigure(struct fs_context *fc) { struct cgroup_fs_context *ctx = cgroup_fc2context(fc); @@ -5550,6 +5566,9 @@ int cgroup_rmdir(struct kernfs_node *kn) static struct kernfs_syscall_ops cgroup_kf_syscall_ops = { .show_options = cgroup_show_options, +#ifdef CONFIG_FSINFO + .fsinfo = cgroup_fsinfo, +#endif .mkdir = cgroup_mkdir, .rmdir = cgroup_rmdir, .show_path = cgroup_show_path,