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 1/2] xfs: expose the number of free zones in sysfs
Date: Mon, 20 Apr 2026 15:50:13 +0200	[thread overview]
Message-ID: <20260420135011.624587-5-cassel@kernel.org> (raw)
In-Reply-To: <20260420135011.624587-4-cassel@kernel.org>

The number of free zones is currently available in /proc/<pid>/mountstats
(which contains stats for all mounted zoned XFS filesystems), under
"free zones:".

Add a sysfs attribute /sys/fs/xfs/<dev>/zoned/nr_free_zones 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                | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/Documentation/admin-guide/xfs.rst b/Documentation/admin-guide/xfs.rst
index acdd4b65964c0..be0d3f5e8b4c4 100644
--- a/Documentation/admin-guide/xfs.rst
+++ b/Documentation/admin-guide/xfs.rst
@@ -550,6 +550,10 @@ For zoned file systems, the following attributes are exposed in:
 	is limited by the capabilities of the backing zoned device, file system
 	size and the max_open_zones mount option.
 
+  nr_free_zones			(Min:  0  Default:  Varies  Max:  INTMAX)
+	This read-only attribute exposes the current number of free zones
+	available to the file system.
+
   nr_open_zones			(Min:  0  Default:  Varies  Max:  UINTMAX)
 	This read-only attribute exposes the current number of open zones
 	used by the file system.
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 676777064c2d7..312bae4cf70fd 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -720,6 +720,17 @@ max_open_zones_show(
 }
 XFS_SYSFS_ATTR_RO(max_open_zones);
 
+static ssize_t
+nr_free_zones_show(
+	struct kobject		*kobj,
+	char			*buf)
+{
+	struct xfs_zone_info	*zi = zoned_to_mp(kobj)->m_zone_info;
+
+	return sysfs_emit(buf, "%d\n", atomic_read(&zi->zi_nr_free_zones));
+}
+XFS_SYSFS_ATTR_RO(nr_free_zones);
+
 static ssize_t
 nr_open_zones_show(
 	struct kobject		*kobj,
@@ -768,6 +779,7 @@ XFS_SYSFS_ATTR_RW(zonegc_low_space);
 
 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),
 	NULL,
-- 
2.53.0


  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 ` Niklas Cassel [this message]
2026-04-20 15:39   ` [PATCH 1/2] xfs: expose the number of free zones in sysfs Damien Le Moal
2026-04-20 13:50 ` [PATCH 2/2] xfs: expose the current zonegc required status " Niklas Cassel
2026-04-20 15:47   ` 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-5-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