* [PATCH 0/2] xfs: add additional zoned sysfs attributes @ 2026-04-20 13:50 Niklas Cassel 2026-04-20 13:50 ` [PATCH 1/2] xfs: expose the number of free zones in sysfs Niklas Cassel 2026-04-20 13:50 ` [PATCH 2/2] xfs: expose the current zonegc required status " Niklas Cassel 0 siblings, 2 replies; 6+ messages in thread From: Niklas Cassel @ 2026-04-20 13:50 UTC (permalink / raw) To: Carlos Maiolino Cc: Christoph Hellwig, Damien Le Moal, Hans Holmberg, Johannes Thumshirn, linux-xfs, Niklas Cassel Hello all, This series adds: /sys/fs/xfs/<dev>/zoned/nr_free_zones and /sys/fs/xfs/<dev>/zoned/zonegc_required These values are already available in /proc/<pid>/mountstats, however, mountstats will unconditionally print the stats for all mounted zoned XFS filesystems. Making the same information in /sys/fs/xfs/<dev>/zoned/ makes it easier for monitoring tools software to read the values for a specific filesystem. Kind regards, Niklas Niklas Cassel (2): xfs: expose the number of free zones in sysfs xfs: expose the current zonegc required status in sysfs Documentation/admin-guide/xfs.rst | 8 ++++++++ fs/xfs/xfs_sysfs.c | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) base-commit: 2ffc6900d5c3a7cd59becda2aa67581d9bd3858e -- 2.53.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] xfs: expose the number of free zones in sysfs 2026-04-20 13:50 [PATCH 0/2] xfs: add additional zoned sysfs attributes Niklas Cassel @ 2026-04-20 13:50 ` Niklas Cassel 2026-04-20 15:39 ` Damien Le Moal 2026-04-20 13:50 ` [PATCH 2/2] xfs: expose the current zonegc required status " Niklas Cassel 1 sibling, 1 reply; 6+ messages in thread From: Niklas Cassel @ 2026-04-20 13:50 UTC (permalink / raw) To: Carlos Maiolino Cc: Christoph Hellwig, Damien Le Moal, Hans Holmberg, Johannes Thumshirn, linux-xfs, Niklas Cassel 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] xfs: expose the number of free zones in sysfs 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 0 siblings, 0 replies; 6+ messages in thread From: Damien Le Moal @ 2026-04-20 15:39 UTC (permalink / raw) To: Niklas Cassel, Carlos Maiolino Cc: Christoph Hellwig, Hans Holmberg, Johannes Thumshirn, linux-xfs On 2026/04/20 15:50, Niklas Cassel wrote: > 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> Looks good to me. Reviewed-by: Damien Le Moal <dlemoal@kernel.org> -- Damien Le Moal Western Digital Research ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] xfs: expose the current zonegc required status in sysfs 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 13:50 ` Niklas Cassel 2026-04-20 15:47 ` Damien Le Moal 1 sibling, 1 reply; 6+ messages in thread From: Niklas Cassel @ 2026-04-20 13:50 UTC (permalink / raw) To: Carlos Maiolino Cc: Christoph Hellwig, Damien Le Moal, Hans Holmberg, Johannes Thumshirn, linux-xfs, Niklas Cassel 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] xfs: expose the current zonegc required status in sysfs 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 0 siblings, 1 reply; 6+ messages in thread From: Damien Le Moal @ 2026-04-20 15:47 UTC (permalink / raw) To: Niklas Cassel, Carlos Maiolino Cc: Christoph Hellwig, Hans Holmberg, Johannes Thumshirn, linux-xfs On 2026/04/20 15:50, Niklas Cassel wrote: > 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> As is, I think this is OK, but I wonder if we should not instead call the attribute zonegc_running and use xfs_is_zonegc_running() to test the XFS_OPSTATE_ZONEGC_RUNNING flag for the attribute value ? The reasoning here is that the GC thread also does zone reset for zones with all blocks invalidated, and in such case we may start the GC thread even when xfs_zoned_need_gc() is false. And I think it is more interesting to see if the GC thread is running, so doing IOs. Thoughts ? > --- > 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); -- Damien Le Moal Western Digital Research ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] xfs: expose the current zonegc required status in sysfs 2026-04-20 15:47 ` Damien Le Moal @ 2026-04-20 16:09 ` Niklas Cassel 0 siblings, 0 replies; 6+ messages in thread From: Niklas Cassel @ 2026-04-20 16:09 UTC (permalink / raw) To: Damien Le Moal Cc: Carlos Maiolino, Christoph Hellwig, Hans Holmberg, Johannes Thumshirn, linux-xfs On Mon, Apr 20, 2026 at 05:47:55PM +0200, Damien Le Moal wrote: > On 2026/04/20 15:50, Niklas Cassel wrote: > > 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> > > As is, I think this is OK, but I wonder if we should not instead call the > attribute zonegc_running and use xfs_is_zonegc_running() to test the > XFS_OPSTATE_ZONEGC_RUNNING flag for the attribute value ? > > The reasoning here is that the GC thread also does zone reset for zones with all > blocks invalidated, and in such case we may start the GC thread even when > xfs_zoned_need_gc() is false. > > And I think it is more interesting to see if the GC thread is running, so doing IOs. > > Thoughts ? I did originally create two patches: This patch, which does exactly like "RT GC required:" in /proc/<pid>/mountstats (which also calls xfs_zoned_need_gc()). Another patch that added another sysfs attribute: /sys/fs/xfs/<dev>/zoned/zonegc_running which like you said, calls xfs_is_zonegc_running(zoned_to_mp(kobj))). However, I couldn't come up with a good argument for adding two new sysfs attributes that are more or less the same thing, therefore I chose the attribute which is equivalent to what we already expose via mountstats. If you think it is a good idea to have both, then I could just dig up my patch from the git reflog, and sent it as well. However, I think if we add such "GC running" attribute, then for consistency, shouldn't we add the same also to mountstats? BTW.. didn't you think about moving the zone resets out from the GC thread? If we ever do submit such a patch, then the two attributes would always have the same value. So perhaps we should hold off with adding two attributes until we know for sure if we will move the zone resets out from the GC thread or not? Kind regards, Niklas ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-04-20 16:09 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox