Skip to content

Commit 62c8998

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: expose the number of open zones in sysfs
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>
1 parent 1d0d9e9 commit 62c8998

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Documentation/admin-guide/xfs.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ For zoned file systems, the following attributes are exposed in:
550550
is limited by the capabilities of the backing zoned device, file system
551551
size and the max_open_zones mount option.
552552

553+
nr_open_zones (Min: 0 Default: Varies Max: UINTMAX)
554+
This read-only attribute exposes the current number of open zones
555+
used by the file system.
556+
553557
zonegc_low_space (Min: 0 Default: 0 Max: 100)
554558
Define a percentage for how much of the unused space that GC should keep
555559
available for writing. A high value will reclaim more of the space

fs/xfs/xfs_sysfs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "xfs_log.h"
1414
#include "xfs_log_priv.h"
1515
#include "xfs_mount.h"
16+
#include "xfs_zone_priv.h"
1617
#include "xfs_zones.h"
1718
#include "xfs_zone_alloc.h"
1819

@@ -719,6 +720,17 @@ max_open_zones_show(
719720
}
720721
XFS_SYSFS_ATTR_RO(max_open_zones);
721722

723+
static ssize_t
724+
nr_open_zones_show(
725+
struct kobject *kobj,
726+
char *buf)
727+
{
728+
struct xfs_zone_info *zi = zoned_to_mp(kobj)->m_zone_info;
729+
730+
return sysfs_emit(buf, "%u\n", READ_ONCE(zi->zi_nr_open_zones));
731+
}
732+
XFS_SYSFS_ATTR_RO(nr_open_zones);
733+
722734
static ssize_t
723735
zonegc_low_space_store(
724736
struct kobject *kobj,
@@ -756,6 +768,7 @@ XFS_SYSFS_ATTR_RW(zonegc_low_space);
756768

757769
static struct attribute *xfs_zoned_attrs[] = {
758770
ATTR_LIST(max_open_zones),
771+
ATTR_LIST(nr_open_zones),
759772
ATTR_LIST(zonegc_low_space),
760773
NULL,
761774
};

0 commit comments

Comments
 (0)