public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Carlos Maiolino <cem@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>,
	Damien Le Moal <dlemoal@kernel.org>,
	Hans Holmberg <hans.holmberg@wdc.com>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	linux-xfs@vger.kernel.org, Niklas Cassel <cassel@kernel.org>
Subject: [PATCH 2/2] xfs: expose the current zonegc required status in sysfs
Date: Mon, 20 Apr 2026 15:50:14 +0200	[thread overview]
Message-ID: <20260420135011.624587-6-cassel@kernel.org> (raw)
In-Reply-To: <20260420135011.624587-4-cassel@kernel.org>

The current zonegc required status is currently available in
/proc/<pid>/mountstats (which contains stats for all mounted zoned XFS
filesystems), under "RT GC required:".

Add a sysfs attribute /sys/fs/xfs/<dev>/zoned/zonegc_required for the same.
This makes it trivial for monitoring software to read the value, for a
specific filesystem, without any complex parsing.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
 Documentation/admin-guide/xfs.rst |  4 ++++
 fs/xfs/xfs_sysfs.c                | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/Documentation/admin-guide/xfs.rst b/Documentation/admin-guide/xfs.rst
index be0d3f5e8b4c4..87ead41aa86c4 100644
--- a/Documentation/admin-guide/xfs.rst
+++ b/Documentation/admin-guide/xfs.rst
@@ -565,3 +565,7 @@ For zoned file systems, the following attributes are exposed in:
 	bursts at the cost of increased write amplification.  Regardless
 	of this value, garbage collection will always aim to free a minimum
 	amount of blocks to keep max_open_zones open for data placement purposes.
+
+  zonegc_required		(Min:  0  Default:  Varies  Max:  1)
+	This read-only attribute exposes if GC is currently required by the file
+	system.
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 312bae4cf70fd..1e1ee020df001 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -777,11 +777,22 @@ zonegc_low_space_show(
 }
 XFS_SYSFS_ATTR_RW(zonegc_low_space);
 
+static ssize_t
+zonegc_required_show(
+	struct kobject		*kobj,
+	char			*buf)
+{
+	return sysfs_emit(buf, "%d\n",
+			xfs_zoned_need_gc(zoned_to_mp(kobj)));
+}
+XFS_SYSFS_ATTR_RO(zonegc_required);
+
 static struct attribute *xfs_zoned_attrs[] = {
 	ATTR_LIST(max_open_zones),
 	ATTR_LIST(nr_free_zones),
 	ATTR_LIST(nr_open_zones),
 	ATTR_LIST(zonegc_low_space),
+	ATTR_LIST(zonegc_required),
 	NULL,
 };
 ATTRIBUTE_GROUPS(xfs_zoned);
-- 
2.53.0


  parent reply	other threads:[~2026-04-20 13:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 13:50 [PATCH 0/2] xfs: add additional zoned sysfs attributes Niklas Cassel
2026-04-20 13:50 ` [PATCH 1/2] xfs: expose the number of free zones in sysfs Niklas Cassel
2026-04-20 15:39   ` Damien Le Moal
2026-04-20 13:50 ` Niklas Cassel [this message]
2026-04-20 15:47   ` [PATCH 2/2] xfs: expose the current zonegc required status " Damien Le Moal
2026-04-20 16:09     ` Niklas Cassel

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=20260420135011.624587-6-cassel@kernel.org \
    --to=cassel@kernel.org \
    --cc=cem@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=hans.holmberg@wdc.com \
    --cc=hch@lst.de \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-xfs@vger.kernel.org \
    /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