Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2497035ybd; Mon, 24 Jun 2019 07:26:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9+fXW8JR72T1jduP2ULXzKvScZzGNu6Kt4vgFUW7W9K4mx6zu9KTSHq3la46VwBW1y1/N X-Received: by 2002:a65:6650:: with SMTP id z16mr8214428pgv.270.1561386409266; 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=hwftyZkg320zJF48iOTmSclnj+7igCb5Bp6k7HLfa2Ljvziu9GKQTlxlgpUKHCwzoB Yjs716vnnoUnEsAEXTKC27GuLDmKsn4YVq6+5nM6WUpgsNOQK6PDM6qhBiKf4OduKRQT RGi4bzL4CSE5G6k9DCMghxcRUhBHmK9Xqtb2zmDzfmRQf1iULOZ0MCCU6kbInI1zBykN hFXEojT5qlUhWEg6bRlwjgD5n6Rpyyg+59onZJKJLRRxePI02JA9lZpxPxCQikZxXcc5 dnpEWUQ3OPLZ2DCub0Ne1c+jhgXnRSay3D/P2rLrBQVAI9goc8uuiUHM8EC+I85/izzA W/oA== 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=2RflXoqZp/ULmXzyX0NU62k87AxVBjgbb/iMACpKAFo=; b=0zZnD/Fo4V04Ra3Jw/xI3B2+73xEZnqVKvgQui0txv6odTcHg5C0y25vWMASVpotar mOZF+Wo1WiyRPBbaS0FG00ZdLWAeARqbAWfTJ2/9dvbBHyMcpmY1LBmg0mbcdStVSJdD yKmNrEA+HwzPOOdHnPgPuva/I1tdLCkyWbeiSM+avkLl1xgqNF6CipPzGzfMwVWAPfRR 77PaLO5l9NzVLTmPcc6vzYBYOC5Y9R+lGkhqlW8diY/GmwmKeXryNrKDegS6Ua72tthw 2c5mw1MBJH0eLPmnrQ8Jy1LJh7b8oj9PyVpsIK3v1DiarK21XGjuvQBE9XhQGDeqZwKR Uvpg== 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 g145si10541686pfb.173.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 S1729257AbfFXOKv (ORCPT + 99 others); Mon, 24 Jun 2019 10:10:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53648 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727301AbfFXOKv (ORCPT ); Mon, 24 Jun 2019 10:10:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6104881F35; Mon, 24 Jun 2019 14:10:50 +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 ED8011001DEF; Mon, 24 Jun 2019 14:10:48 +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 13/25] hugetlbfs: Add support for fsinfo() [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:43 +0100 Message-ID: <156138544306.25627.17156844240352443841.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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 24 Jun 2019 14:10:50 +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(). Signed-off-by: David Howells --- fs/hugetlbfs/inode.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 1dcc57189382..62d5d5dec447 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -958,6 +959,59 @@ static int hugetlbfs_show_options(struct seq_file *m, struct dentry *root) return 0; } +#ifdef CONFIG_FSINFO +static int hugetlbfs_fsinfo(struct path *path, struct fsinfo_kparams *params) +{ + struct dentry *dentry = path->dentry; + struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry->d_sb); + struct hugepage_subpool *spool = sbinfo->spool; + unsigned long hpage_size = huge_page_size(sbinfo->hstate); + unsigned hpage_shift = huge_page_shift(sbinfo->hstate); + char mod; + + switch (params->request) { + case FSINFO_ATTR_PARAMETERS: + fsinfo_note_sb_params(params, dentry->d_sb->s_flags); + if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID)) + fsinfo_note_paramf(params, "uid", "%u", + from_kuid_munged(&init_user_ns, + sbinfo->uid)); + + if (!gid_eq(sbinfo->gid, GLOBAL_ROOT_GID)) + fsinfo_note_paramf(params, "gid", "%u", + from_kgid_munged(&init_user_ns, + sbinfo->gid)); + + if (spool && spool->max_hpages != -1) + fsinfo_note_paramf(params, "size", "%llu", + (unsigned long long)spool->max_hpages << hpage_shift); + + if (spool && spool->min_hpages != -1) + fsinfo_note_paramf(params, "min_size", "%llu", + (unsigned long long)spool->min_hpages << hpage_shift); + + hpage_size /= 1024; + mod = 'K'; + if (hpage_size >= 1024) { + hpage_size /= 1024; + mod = 'M'; + } + fsinfo_note_paramf(params, "pagesize", "%lu%c", hpage_size, mod); + + if (sbinfo->mode != 0755) + fsinfo_note_paramf(params, "mode", "%o", sbinfo->mode); + + if (sbinfo->max_inodes != -1) + fsinfo_note_paramf(params, "nr_inodes", "%lu", + sbinfo->max_inodes); + return params->usage; + + default: + return generic_fsinfo(path, params); + } +} +#endif /* CONFIG_FSINFO */ + static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf) { struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry->d_sb); @@ -1116,6 +1170,9 @@ static const struct super_operations hugetlbfs_ops = { .statfs = hugetlbfs_statfs, .put_super = hugetlbfs_put_super, .show_options = hugetlbfs_show_options, +#ifdef CONFIG_FSINFO + .fsinfo = hugetlbfs_fsinfo, +#endif }; /*