Skip to content

Commit 9c47791

Browse files
author
Christoph Hellwig
committed
xfs: export max_open_zones in sysfs
Add a zoned group with an attribute for the maximum number of open zones. This allows querying the open zones for data placement tests, or also for placement aware applications that are in control of the entire file system. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
1 parent 243f40d commit 9c47791

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

fs/xfs/xfs_mount.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ typedef struct xfs_mount {
287287
#ifdef CONFIG_XFS_ONLINE_SCRUB_STATS
288288
struct xchk_stats *m_scrub_stats;
289289
#endif
290+
struct xfs_kobj m_zoned_kobj;
290291
xfs_agnumber_t m_agfrotor; /* last ag where space found */
291292
atomic_t m_agirotor; /* last ag dir inode alloced */
292293
atomic_t m_rtgrotor; /* last rtgroup rtpicked */

fs/xfs/xfs_sysfs.c

Lines changed: 40 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_zones.h"
1617

1718
struct xfs_sysfs_attr {
1819
struct attribute attr;
@@ -701,6 +702,34 @@ xfs_error_sysfs_init_class(
701702
return error;
702703
}
703704

705+
static inline struct xfs_mount *zoned_to_mp(struct kobject *kobj)
706+
{
707+
return container_of(to_kobj(kobj), struct xfs_mount, m_zoned_kobj);
708+
}
709+
710+
static ssize_t
711+
max_open_zones_show(
712+
struct kobject *kobj,
713+
char *buf)
714+
{
715+
/* only report the open zones available for user data */
716+
return sysfs_emit(buf, "%u\n",
717+
zoned_to_mp(kobj)->m_max_open_zones - XFS_OPEN_GC_ZONES);
718+
}
719+
XFS_SYSFS_ATTR_RO(max_open_zones);
720+
721+
static struct attribute *xfs_zoned_attrs[] = {
722+
ATTR_LIST(max_open_zones),
723+
NULL,
724+
};
725+
ATTRIBUTE_GROUPS(xfs_zoned);
726+
727+
static const struct kobj_type xfs_zoned_ktype = {
728+
.release = xfs_sysfs_release,
729+
.sysfs_ops = &xfs_sysfs_ops,
730+
.default_groups = xfs_zoned_groups,
731+
};
732+
704733
int
705734
xfs_mount_sysfs_init(
706735
struct xfs_mount *mp)
@@ -741,6 +770,14 @@ xfs_mount_sysfs_init(
741770
if (error)
742771
goto out_remove_error_dir;
743772

773+
if (IS_ENABLED(CONFIG_XFS_RT) && xfs_has_zoned(mp)) {
774+
/* .../xfs/<dev>/zoned/ */
775+
error = xfs_sysfs_init(&mp->m_zoned_kobj, &xfs_zoned_ktype,
776+
&mp->m_kobj, "zoned");
777+
if (error)
778+
goto out_remove_error_dir;
779+
}
780+
744781
return 0;
745782

746783
out_remove_error_dir:
@@ -759,6 +796,9 @@ xfs_mount_sysfs_del(
759796
struct xfs_error_cfg *cfg;
760797
int i, j;
761798

799+
if (IS_ENABLED(CONFIG_XFS_RT) && xfs_has_zoned(mp))
800+
xfs_sysfs_del(&mp->m_zoned_kobj);
801+
762802
for (i = 0; i < XFS_ERR_CLASS_MAX; i++) {
763803
for (j = 0; j < XFS_ERR_ERRNO_MAX; j++) {
764804
cfg = &mp->m_error_cfg[i][j];

0 commit comments

Comments
 (0)