]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: expose the number of open zones in sysfs
authorChristoph Hellwig <hch@lst.de>
Tue, 31 Mar 2026 15:27:30 +0000 (17:27 +0200)
committerCarlos Maiolino <cem@kernel.org>
Tue, 7 Apr 2026 11:28:47 +0000 (13:28 +0200)
Add a sysfs attribute for the current number of open zones so that it
can be trivially read from userspace in monitoring or testing software.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Documentation/admin-guide/xfs.rst
fs/xfs/xfs_sysfs.c

index 746ea60eed3fa841583d61b438207bb4109745d9..acdd4b65964c058647a7b383d8c2c778777a538e 100644 (file)
@@ -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_open_zones                        (Min:  0  Default:  Varies  Max:  UINTMAX)
+       This read-only attribute exposes the current number of open zones
+       used by the file system.
+
   zonegc_low_space             (Min:  0  Default:  0  Max:  100)
        Define a percentage for how much of the unused space that GC should keep
        available for writing. A high value will reclaim more of the space
index 4527119b29619fb8059734aa3e921b24defc1e29..676777064c2d76dece120cf9f1f9275c6c477979 100644 (file)
@@ -13,6 +13,7 @@
 #include "xfs_log.h"
 #include "xfs_log_priv.h"
 #include "xfs_mount.h"
+#include "xfs_zone_priv.h"
 #include "xfs_zones.h"
 #include "xfs_zone_alloc.h"
 
@@ -719,6 +720,17 @@ max_open_zones_show(
 }
 XFS_SYSFS_ATTR_RO(max_open_zones);
 
+static ssize_t
+nr_open_zones_show(
+       struct kobject          *kobj,
+       char                    *buf)
+{
+       struct xfs_zone_info    *zi = zoned_to_mp(kobj)->m_zone_info;
+
+       return sysfs_emit(buf, "%u\n", READ_ONCE(zi->zi_nr_open_zones));
+}
+XFS_SYSFS_ATTR_RO(nr_open_zones);
+
 static ssize_t
 zonegc_low_space_store(
        struct kobject          *kobj,
@@ -756,6 +768,7 @@ XFS_SYSFS_ATTR_RW(zonegc_low_space);
 
 static struct attribute *xfs_zoned_attrs[] = {
        ATTR_LIST(max_open_zones),
+       ATTR_LIST(nr_open_zones),
        ATTR_LIST(zonegc_low_space),
        NULL,
 };