xfs: add additional zoned sysfs attributes
Subsystems (2)
cover xfs: add additional zoned sysfs attributes
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
Signature · 1 line
2.53.0
PATCH 1/2 xfs: expose the number of free zones in sysfs
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.
--- Documentation/admin-guide/xfs.rst | 4 ++++ fs/xfs/xfs_sysfs.c | 12 ++++++++++++ 2 files changed, 16 insertions(+)
Documentation/admin-guide/xfs.rst +4 -0
@@ -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.
fs/xfs/xfs_sysfs.c +12 -0
@@ -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 ,
Signature · 1 line
2.53.0
Re: [PATCH 1/2] xfs: expose the number of free zones in sysfs
Quoted 9 lines · 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 <[email protected]>
Looks good to me.
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 1/2] xfs: expose the number of free zones in sysfs
In reply to Niklas CasselQuoted 7 lines · 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.
The usual way to expose stats in xfs is through the stats sysfs file. Which requires some parsing, but the usual monitoring tools already have this.
Re: [PATCH 1/2] xfs: expose the number of free zones in sysfs
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · 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:".
Quoted 7 lines
Quoted 3 lines
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.
The usual way to expose stats in xfs is through the stats sysfs file. Which requires some parsing, but the usual monitoring tools already have this.
So we have the following options:
1) /sys/fs/xfs/<dev>/zoned/
2) /sys/fs/xfs/<dev>/stats/stats
3) /sys/kernel/debug/xfs/<dev>/
You say that the usual way to expose stats is through 2) but e.g. nr_open_zones is exposed via 1), introduced in commit 62c89988dc19 ("xfs: expose the number of open zones in sysfs") (You are the author of that commit btw :))
In my mind, nr_open_zones and nr_free_zones is very similar, so I though it was most logical to have them in the same place.
That said, if you prefer 2) or 3) over 1) for exposing nr_free_zones, please tell me which you prefer, and I can send a V2 with that.
Kind regards,
Niklas
Re: [PATCH 1/2] xfs: expose the number of free zones in sysfs
Quoted 4 lines · Niklas Cassel
You say that the usual way to expose stats is through 2) but e.g.
nr_open_zonesis exposed via 1), introduced in commit62c89988dc19("xfs: expose the number of open zones in sysfs") (You are the author of that commit btw :))
nr_open_zones is important for applications as it tells them how many different placement points we can have. nr_free is really just an implementation detail.
Re: [PATCH 1/2] xfs: expose the number of free zones in sysfs
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Niklas Cassel
You say that the usual way to expose stats is through 2) but e.g.
nr_open_zonesis exposed via 1), introduced in commit62c89988dc19("xfs: expose the number of open zones in sysfs") (You are the author of that commit btw :))
nr_open_zonesis important for applications as it tells them how many different placement points we can have.nr_freeis really just an implementation detail.
The commit message for 62c89988dc19 ("xfs: expose the number of open zones in sysfs") motivated the change by saying that nr_open_zones could be used in monitoring or testing software.
Which seemed like the same reason/purpose why I wanted to add nr_free_zones.
Your commit message did not mention that user space software could also use nr_open_zones to calculate the number of different placement points.
Anyway, I can continue with the current (somewhat fragile) way of parsing /proc/<pid>/mountstats. It is just a bit unfortunate that you can't get it for a specific mountpoint only.
The "mountstats" command:
https://man7.org/linux/man-pages/man8/mountstats.8.html
seems to be able to display the mountstats for a specific mountpoint only, but it seems to be for NFS only.
Carlos,
please disregard this series.
Kind regards,
Niklas
Re: [PATCH 1/2] xfs: expose the number of free zones in sysfs
Quoted 15 lines · Niklas Cassel
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Niklas Cassel
You say that the usual way to expose stats is through 2) but e.g.
nr_open_zonesis exposed via 1), introduced in commit62c89988dc19("xfs: expose the number of open zones in sysfs") (You are the author of that commit btw :))
nr_open_zonesis important for applications as it tells them how many different placement points we can have.nr_freeis really just an implementation detail.The commit message for
62c89988dc19("xfs: expose the number of open zones in sysfs") motivated the change by saying thatnr_open_zonescould be used in monitoring or testing software.
Quoted 8 lines
Which seemed like the same reason/purpose why I wanted to add
nr_free_zones.Your commit message did not mention that user space software could also use
nr_open_zonesto calculate the number of different placement points.Anyway, I can continue with the current (somewhat fragile) way of parsing /proc/<pid>/mountstats. It is just a bit unfortunate that you can't get it for a specific mountpoint only.
Fyi. I'm adding some helpers for getting specific xfs mountstats in fstests:
https://lore.kernel.org/fstests/[email protected]/
Quoted 13 lines
The "mountstats" command:
https://man7.org/linux/man-pages/man8/mountstats.8.html
seems to be able to display the mountstats for a specific mountpoint only, but it seems to be for NFS only.Carlos,
please disregard this series.Kind regards,
Niklas
PATCH 2/2 xfs: expose the current zonegc required status in sysfs
In reply to Niklas CasselThe 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.
--- Documentation/admin-guide/xfs.rst | 4 ++++ fs/xfs/xfs_sysfs.c | 11 +++++++++++ 2 files changed, 15 insertions(+)
Documentation/admin-guide/xfs.rst +4 -0
@@ -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.
fs/xfs/xfs_sysfs.c +11 -0
@@ -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);
Signature · 1 line
2.53.0
Re: [PATCH 2/2] xfs: expose the current zonegc required status in sysfs
Quoted 9 lines · 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 <[email protected]>
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 ?
Quoted 44 lines
--- Documentation/admin-guide/xfs.rst | 4 ++++ fs/xfs/xfs_sysfs.c | 11 +++++++++++ 2 files changed, 15 insertions(+)Documentation/admin-guide/xfs.rst +4
-0@@ -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.fs/xfs/xfs_sysfs.c +11
-0@@ -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);
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 2/2] xfs: expose the current zonegc required status in sysfs
Quoted 15 lines · Damien Le Moal
Quoted 9 lines · 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 <[email protected]>As is, I think this is OK, but I wonder if we should not instead call the attribute
zonegc_runningand usexfs_is_zonegc_running()to test theXFS_OPSTATE_ZONEGC_RUNNINGflag for the attribute value ?
Quoted 7 lines
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
Re: [PATCH 2/2] xfs: expose the current zonegc required status in sysfs
In reply to Niklas CasselQuoted 7 lines · 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.
GC needed is a very complex internal condition, and I don't think exposing the current value as a stable ABI is a good idea.
What are you trying to do with this information?
Re: [PATCH 2/2] xfs: expose the current zonegc required status in sysfs
Quoted 11 lines · Christoph Hellwig
Quoted 7 lines · 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.
GC needed is a very complex internal condition, and I don't think exposing the current value as a stable ABI is a good idea.
So we have the following options:
1) /sys/fs/xfs/<dev>/zoned/
2) /sys/fs/xfs/<dev>/stats/stats
3) /sys/kernel/debug/xfs/<dev>/
In my mind, debugfs is usually used for sensitive stuff, however, considering that the information exposed in this patch is exactly the same information as "GC required:" in /proc/<pid>/mountstats, I assume that the sensitive argument is not really applicable here.
Like you say, debugfs can also be used in order to avoid exposing the current value as a stable ABI. However, since the information exposed in this patch is accessed using the exact same function call: xfs_zoned_need_gc() as "GC required:" in /proc/<pid>/mountstats, isn't the current value already exposed as a stable ABI?
Or perhaps I am missing something here, and for some reason, unlike a sysfs attribute, the information exposed in /proc/<pid>/mountstats is not considered a stable ABI ?
That said, if you prefer 2) or 3) over 1) for exposing zonegc_required, please tell me which you prefer, and I can send a V2 with that.
Kind regards,
Niklas
Re: [PATCH 2/2] xfs: expose the current zonegc required status in sysfs
Quoted 7 lines · Niklas Cassel
Or perhaps I am missing something here, and for some reason, unlike a sysfs attribute, the information exposed in /proc/<pid>/mountstats is not considered a stable ABI ?
That said, if you prefer 2) or 3) over 1) for exposing
zonegc_required, please tell me which you prefer, and I can send a V2 with that.
I'd prefer not adding another API for querying this detail. Especially no a fairly heavy weight one.
Quoted 7 lines · Niklas Cassel
Hello all,
This series adds:
/sys/fs/xfs/<dev>/zoned/nr_free_zones
and
/sys/fs/xfs/<dev>/zoned/zonegc_required
Quoted 6 lines
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.
What monitoring tools software are you aiming for?
Carlos Maiolino
maintainerQuoted 8 lines · Christoph Hellwig
Quoted 7 lines · Niklas Cassel
Hello all,
This series adds:
/sys/fs/xfs/<dev>/zoned/nr_free_zones
and
/sys/fs/xfs/<dev>/zoned/zonegc_required
Quoted 8 lines
Quoted 6 lines
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.
What monitoring tools software are you aiming for?
Zonar perhaps?
Quoted 2 lines
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Niklas Cassel
Hello all,
This series adds:
/sys/fs/xfs/<dev>/zoned/nr_free_zones
and
/sys/fs/xfs/<dev>/zoned/zonegc_required
Quoted 8 lines
Quoted 6 lines
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.
What monitoring tools software are you aiming for?
Like Damien said: home made benchmarking scripts that sample these values in order to know when to kick off a new benchmark, such that each benchmark will have as similar starting conditions as possible wrt. GC.
Kind regards,
Niklas