support for zoned devices v3
Re: [PATCH 41/45] xfs: support write life time based data placement
In reply to Christoph HellwigQuoted 22 lines · Christoph Hellwig
From: Hans Holmberg <[email protected]>
Add a file write life time data placement allocation scheme that aims to minimize fragmentation and thereby to do two things:
a) separate file data to different zones when possible.
b) colocate file data of similar life times when feasible.To get best results, average file sizes should align with the zone capacity that is reported through the
XFS_IOC_FSGEOMETRYioctl.This improvement in data placement efficiency reduces the number of blocks requiring relocation by GC, and thus decreases overall write amplification. The impact on performance varies depending on how full the file system is.
For RocksDB using leveled compaction, the lifetime hints can improve throughput for overwrite workloads at 80% file system utilization by ~10%, but for lower file system utilization there won't be as much benefit in application performance as there is less need for garbage collection to start with.
Quoted 4 lines
Lifetime hints can be disabled using the nolifetime mount option.
Signed-off-by Hans Holmberg <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>
I appreciate the extra information in the commit message!
--D
Quoted 419 lines
--- fs/xfs/xfs_mount.h | 2 + fs/xfs/xfs_super.c | 15 +++++ fs/xfs/xfs_zone_alloc.c | 130 +++++++++++++++++++++++++++++++++++----- fs/xfs/xfs_zone_gc.c | 4 +- fs/xfs/xfs_zone_priv.h | 9 ++- 5 files changed, 141 insertions(+), 19 deletions(-)fs/xfs/xfs_mount.h +2
-0@@ -373,6 +373,7 @@ typedef struct xfs_mount {#define XFS_FEAT_ZONED (1ULL << 29)/* zoned RT device */ /* Mount features */ +#define XFS_FEAT_NOLIFETIME (1ULL << 47)/* disable lifetime hints */ #define XFS_FEAT_NOATTR2 (1ULL << 48)/* disable attr2 creation */ #define XFS_FEAT_NOALIGN (1ULL << 49)/* ignore alignment */ #define XFS_FEAT_ALLOCSIZE (1ULL << 50)/* user specified allocation size */ @@ -428,6 +429,7 @@ __XFS_HAS_FEAT(large_extent_counts, NREXT64) __XFS_HAS_FEAT(exchange_range, EXCHANGE_RANGE) __XFS_HAS_FEAT(metadir, METADIR) __XFS_HAS_FEAT(zoned, ZONED) +__XFS_HAS_FEAT(nolifetime, NOLIFETIME)static inline bool xfs_has_rtgroups (const struct xfs_mount *mp) {fs/xfs/xfs_super.c +15
-0@@ -111,6 +111,7 @@ enum { Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota, Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce, Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum, Opt_max_open_zones, + Opt_lifetime, Opt_nolifetime, }; static const struct fs_parameter_spec xfs_fs_parameters[] = {@@ -156,6 +157,8 @@ static const struct fs_parameter_spec xfs_fs_parameters[] = {fsparam_flag ("dax" , Opt_dax),fsparam_enum ("dax" , Opt_dax_enum, dax_param_enums),fsparam_u32 ("max_open_zones" , Opt_max_open_zones), +fsparam_flag ("lifetime" , Opt_lifetime), + fsparam_flag("nolifetime", Opt_nolifetime), {} };@@ -184,6 +187,7 @@ xfs_fs_show_options( { XFS_FEAT_LARGE_IOSIZE, ",largeio" }, { XFS_FEAT_DAX_ALWAYS, ",dax=always" }, { XFS_FEAT_DAX_NEVER, ",dax=never" }, + { XFS_FEAT_NOLIFETIME, ",nolifetime" }, { 0, NULL } };struct xfs_mount *mp =XFS_M (root->d_sb);@@ -1091,6 +1095,11 @@ xfs_finish_flags( "max_open_zones mount option only supported on zoned file systems.");return -EINVAL ; } +if (mp->m_features &XFS_FEAT_NOLIFETIME ) { +xfs_warn (mp, +"nolifetime mount option only supported on zoned file systems." ); +return -EINVAL ; + } }return 0 ;@@ -1478,6 +1487,12 @@ xfs_fs_parse_param(case Opt_max_open_zones: parsing_mp->m_max_open_zones = result.uint_32;return 0 ; +case Opt_lifetime: + parsing_mp->m_features &= ~XFS_FEAT_NOLIFETIME ; +return 0 ; +case Opt_nolifetime: + parsing_mp->m_features |=XFS_FEAT_NOLIFETIME ; +return 0 ;default :xfs_warn (parsing_mp,"unknown mount option [%s]." , param->key);return -EINVAL ;fs/xfs/xfs_zone_alloc.c +114
-16@@ -423,6 +423,7 @@ static struct xfs_open_zone *xfs_init_open_zone ( struct xfs_rtgroup *rtg, xfs_rgblock_t write_pointer, + enum rw_hint write_hint, bool is_gc) { struct xfs_open_zone *oz;@@ -433,6 +434,7 @@ xfs_init_open_zone( oz->oz_rtg = rtg; oz->oz_write_pointer = write_pointer; oz->oz_written = write_pointer; + oz->oz_write_hint = write_hint; oz->oz_is_gc = is_gc;/* @@ -452,6 +454,7 @@ xfs_init_open_zone(struct xfs_open_zone *xfs_open_zone (struct xfs_mount *mp, +enum rw_hint write_hint,bool is_gc) {struct xfs_zone_info *zi = mp->m_zone_info;@@ -464,12 +467,13 @@ xfs_open_zone(return NULL ;set_current_state (TASK_RUNNING ); -return xfs_init_open_zone (to_rtg (xg),0 , is_gc); +return xfs_init_open_zone (to_rtg (xg),0 , write_hint, is_gc); }static struct xfs_open_zone *xfs_try_open_zone ( -struct xfs_mount *mp) +struct xfs_mount *mp, +enum rw_hint write_hint) {struct xfs_zone_info *zi = mp->m_zone_info;struct xfs_open_zone *oz;@@ -486,7 +490,7 @@ xfs_try_open_zone(*/ zi->zi_nr_open_zones++;spin_unlock (&zi->zi_open_zones_lock); - oz =xfs_open_zone (mp, false); + oz =xfs_open_zone (mp, write_hint, false);spin_lock (&zi->zi_open_zones_lock);if (!oz) { zi->zi_nr_open_zones--;@@ -509,16 +513,78 @@ xfs_try_open_zone(return oz; } +/* +* For data with short or medium lifetime, try to colocated it into an +* already open zone with a matching temperature. +*/ +static bool +xfs_colocate_eagerly ( +enum rw_hint file_hint) +{ +switch (file_hint) { +case WRITE_LIFE_MEDIUM : +case WRITE_LIFE_SHORT : +case WRITE_LIFE_NONE : +return true; +default : +return false; + } +} + +static bool +xfs_good_hint_match ( +struct xfs_open_zone *oz, +enum rw_hint file_hint) +{ +switch (oz->oz_write_hint) { +case WRITE_LIFE_LONG : +case WRITE_LIFE_EXTREME : +/* colocate long and extreme */ +if (file_hint ==WRITE_LIFE_LONG || + file_hint ==WRITE_LIFE_EXTREME ) +return true; +break ; +case WRITE_LIFE_MEDIUM : +/* colocate medium with medium */ +if (file_hint ==WRITE_LIFE_MEDIUM ) +return true; +break ; +case WRITE_LIFE_SHORT : +case WRITE_LIFE_NONE : +case WRITE_LIFE_NOT_SET : +/* colocate short and none */ +if (file_hint <=WRITE_LIFE_SHORT ) +return true; +break ; + } +return false; +} +static bool xfs_try_use_zone (struct xfs_zone_info *zi, -struct xfs_open_zone *oz) +enum rw_hint file_hint, +struct xfs_open_zone *oz, +bool lowspace) {if (oz->oz_write_pointer ==rtg_blocks (oz->oz_rtg))return false; +if (!lowspace && !xfs_good_hint_match (oz, file_hint)) +return false;if (!atomic_inc_not_zero (&oz->oz_ref))return false; +/* +* If we have a hint set for the data, use that for the zone even if +* some data was written already without any hint set, but don't change +* the temperature after that as that would make little sense without +* tracking per-temperature class written block counts, which is +* probably overkill anyway. +*/ +if (file_hint !=WRITE_LIFE_NOT_SET && + oz->oz_write_hint ==WRITE_LIFE_NOT_SET ) + oz->oz_write_hint = file_hint; +/* * If we couldn't match by inode or life time we just pick the first * zone with enough space above. For that we want the least busy zone @@ -533,14 +599,16 @@ xfs_try_use_zone(static struct xfs_open_zone *xfs_select_open_zone_lru ( -struct xfs_zone_info *zi) +struct xfs_zone_info *zi, +enum rw_hint file_hint, +bool lowspace) {struct xfs_open_zone *oz;lockdep_assert_held (&zi->zi_open_zones_lock);list_for_each_entry (oz, &zi->zi_open_zones, oz_entry) -if (xfs_try_use_zone (zi, oz)) +if (xfs_try_use_zone (zi, file_hint, oz, lowspace))return oz;cond_resched_lock (&zi->zi_open_zones_lock);@@ -549,20 +617,28 @@ xfs_select_open_zone_lru(static struct xfs_open_zone *xfs_select_open_zone_mru ( -struct xfs_zone_info *zi) +struct xfs_zone_info *zi, +enum rw_hint file_hint) {struct xfs_open_zone *oz;lockdep_assert_held (&zi->zi_open_zones_lock);list_for_each_entry_reverse (oz, &zi->zi_open_zones, oz_entry) -if (xfs_try_use_zone (zi, oz)) +if (xfs_try_use_zone (zi, file_hint, oz, false))return oz;cond_resched_lock (&zi->zi_open_zones_lock);return NULL ; } +static inline enum rw_hint xfs_inode_write_hint (struct xfs_inode *ip) +{ +if (xfs_has_nolifetime (ip->i_mount)) +return WRITE_LIFE_NOT_SET ; +return VFS_I (ip)->i_write_hint; +} +/* * Try to pack inodes that are written back after they were closed tight instead * of trying to open new zones for them or spread them to the least recently @@ -586,6 +662,7 @@ static inline bool xfs_zoned_pack_tight(struct xfs_inode *ip)static struct xfs_open_zone *xfs_select_zone_nowait (struct xfs_mount *mp, +enum rw_hint write_hint,bool pack_tight) {struct xfs_zone_info *zi = mp->m_zone_info;@@ -594,20 +671,38 @@ xfs_select_zone_nowait(if (xfs_is_shutdown (mp))return NULL ; +/* +* Try to fill up open zones with matching temperature if available. It +* is better to try to co-locate data when this is favorable, so we can +* activate empty zones when it is statistically better to separate +* data. +*/ spin_lock (&zi->zi_open_zones_lock); -if (pack_tight) - oz =xfs_select_open_zone_mru (zi); +if (xfs_colocate_eagerly (write_hint)) + oz =xfs_select_open_zone_lru (zi, write_hint, false); +else if (pack_tight) + oz =xfs_select_open_zone_mru (zi, write_hint);if (oz) goto out_unlock;/* * See if we can open a new zone and use that. */ - oz =xfs_try_open_zone (mp); + oz =xfs_try_open_zone (mp, write_hint);if (oz) goto out_unlock; - oz =xfs_select_open_zone_lru (zi); +/* +* Try to colocate cold data with other cold data if we failed to open a +* new zone for it. +*/ +if (write_hint !=WRITE_LIFE_NOT_SET && + !xfs_colocate_eagerly (write_hint)) + oz =xfs_select_open_zone_lru (zi, write_hint, false); +if (!oz) + oz =xfs_select_open_zone_lru (zi,WRITE_LIFE_NOT_SET , false); +if (!oz) + oz =xfs_select_open_zone_lru (zi,WRITE_LIFE_NOT_SET , true); out_unlock:spin_unlock (&zi->zi_open_zones_lock);return oz;@@ -616,19 +711,20 @@ xfs_select_zone_nowait(static struct xfs_open_zone *xfs_select_zone (struct xfs_mount *mp, +enum rw_hint write_hint,bool pack_tight) {struct xfs_zone_info *zi = mp->m_zone_info;DEFINE_WAIT (wait);struct xfs_open_zone *oz; - oz =xfs_select_zone_nowait (mp, pack_tight); + oz =xfs_select_zone_nowait (mp, write_hint, pack_tight);if (oz)return oz;for (;;) {prepare_to_wait (&zi->zi_zone_wait, &wait,TASK_UNINTERRUPTIBLE ); - oz =xfs_select_zone_nowait (mp, pack_tight); + oz =xfs_select_zone_nowait (mp, write_hint, pack_tight);if (oz)break ;schedule ();@@ -706,6 +802,7 @@ xfs_zone_alloc_and_submit( {struct xfs_inode *ip =XFS_I (ioend->io_inode);struct xfs_mount *mp = ip->i_mount; +enum rw_hint write_hint =xfs_inode_write_hint (ip);bool pack_tight =xfs_zoned_pack_tight (ip);unsigned int alloc_len;struct iomap_ioend *split;@@ -723,7 +820,7 @@ xfs_zone_alloc_and_submit( *oz =xfs_last_used_zone (ioend);if (!*oz) { select_zone: - *oz =xfs_select_zone (mp, pack_tight); + *oz =xfs_select_zone (mp, write_hint, pack_tight);if (!*oz) goto out_error; }@@ -861,7 +958,8 @@ xfs_init_zone(struct xfs_open_zone *oz;atomic_inc (&rtg_group (rtg)->xg_active_ref); - oz =xfs_init_open_zone (rtg, write_pointer, false); + oz =xfs_init_open_zone (rtg, write_pointer,WRITE_LIFE_NOT_SET , + false);list_add_tail (&oz->oz_entry, &zi->zi_open_zones); zi->zi_nr_open_zones++;fs/xfs/xfs_zone_gc.c +2
-2@@ -547,7 +547,7 @@ xfs_zone_gc_select_target(ASSERT (zi->zi_nr_open_zones <= mp->m_max_open_zones -XFS_OPEN_GC_ZONES ); - oz =xfs_open_zone (mp, true); + oz =xfs_open_zone (mp,WRITE_LIFE_NOT_SET , true);if (oz)trace_xfs_zone_gc_target_opened (oz->oz_rtg);spin_lock (&zi->zi_open_zones_lock);@@ -1117,7 +1117,7 @@ xfs_zone_gc_mount( zi->zi_nr_open_zones == mp->m_max_open_zones) oz =xfs_zone_gc_steal_open (zi); else - oz =xfs_open_zone (mp, true); + oz =xfs_open_zone (mp,WRITE_LIFE_NOT_SET , true);if (!oz) {xfs_warn (mp,"unable to allocate a zone for gc" ); error = -EIO ;fs/xfs/xfs_zone_priv.h +8
-1@@ -26,6 +26,12 @@ struct xfs_open_zone {*/ xfs_rgblock_t oz_written; +/* +* Write hint (data temperature) assigned to this zone, or +* WRITE_LIFE_NOT_SET if none was set. +*/ +enum rw_hint oz_write_hint; +/* * Is this open zone used for garbage collection? There can only be a * single open GC zone, which is pointed to by zi_open_gc_zone in @@ -100,7 +106,8 @@ struct xfs_zone_info { }; -struct xfs_open_zone *xfs_open_zone (struct xfs_mount *mp,bool is_gc); +struct xfs_open_zone *xfs_open_zone (struct xfs_mount *mp, +enum rw_hint write_hint,bool is_gc);int xfs_zone_gc_reset_sync (struct xfs_rtgroup *rtg);bool xfs_zoned_need_gc (struct xfs_mount *mp);Signature · 1 line
2.45.2
PATCH 42/45 xfs: wire up the show_stats super operation
In reply to Christoph HellwigThe show_stats option allows a file system to dump plain text statistic on a per-mount basis into /proc/*/mountstats. Wire up a no-op version which will grow useful information for zoned file systems later.
--- fs/xfs/xfs_super.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/xfs/xfs_super.c +9 -0
@@ -1258,6 +1258,14 @@ xfs_fs_shutdown(xfs_force_shutdown (XFS_M (sb),SHUTDOWN_DEVICE_REMOVED ); } +static int +xfs_fs_show_stats ( +struct seq_file *m, +struct dentry *root) +{ +return 0 ; +} +static const struct super_operations xfs_super_operations = { .alloc_inode = xfs_fs_alloc_inode, .destroy_inode = xfs_fs_destroy_inode,
@@ -1272,6 +1280,7 @@ static const struct super_operations xfs_super_operations = { .nr_cached_objects = xfs_fs_nr_cached_objects, .free_cached_objects = xfs_fs_free_cached_objects, .shutdown = xfs_fs_shutdown, + .show_stats = xfs_fs_show_stats, }; static int
Signature · 1 line
2.45.2
PATCH 43/45 xfs: export zone stats in /proc/*/mountstats
In reply to Christoph HellwigFrom: Hans Holmberg <[email protected]>
Add the per-zone life time hint and the used block distribution for fully written zones, grouping reclaimable zones in fixed-percentage buckets spanning 0..9%, 10..19% and full zones as 100% used as well as a few statistics about the zone allocator and open and reclaimable zones in /proc/*/mountstats.
This gives good insight into data fragmentation and data placement success rate.
--- fs/xfs/Makefile | 1 + fs/xfs/xfs_super.c | 4 ++ fs/xfs/xfs_zone_alloc.h | 1 + fs/xfs/xfs_zone_info.c | 105 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 fs/xfs/xfs_zone_info.c
fs/xfs/Makefile +1 -0
@@ -140,6 +140,7 @@ xfs-$(CONFIG_XFS_QUOTA) += xfs_dquot.o \ xfs-$(CONFIG_XFS_RT) += xfs_rtalloc.o \ xfs_zone_alloc.o \ xfs_zone_gc.o \ + xfs_zone_info.o \ xfs_zone_space_resv.o xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
fs/xfs/xfs_super.c +4 -0
@@ -1263,6 +1263,10 @@ xfs_fs_show_stats(struct seq_file *m, struct dentry *root) { + struct xfs_mount *mp = XFS_M(root->d_sb); + +if (xfs_has_zoned (mp) &&IS_ENABLED (CONFIG_XFS_RT )) +xfs_zoned_show_stats (m, mp);return 0 ; }
fs/xfs/xfs_zone_alloc.h +1 -0
@@ -44,6 +44,7 @@ void xfs_mark_rtg_boundary(struct iomap_ioend *ioend);uint64_t xfs_zoned_default_resblks (struct xfs_mount *mp,enum xfs_free_counter ctr); +void xfs_zoned_show_stats (struct seq_file *m,struct xfs_mount *mp);#ifdef CONFIG_XFS_RT int xfs_mount_zones (struct xfs_mount *mp);
fs/xfs/xfs_zone_info.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH 44/45 xfs: contain more sysfs code in xfs_sysfs.c
In reply to Christoph HellwigExtend the error sysfs initialization helper to include the neighbouring attributes as well.
--- fs/xfs/xfs_mount.c | 29 ++++++----------------------- fs/xfs/xfs_sysfs.c | 35 ++++++++++++++++++++++++++++------- fs/xfs/xfs_sysfs.h | 5 ++--- 3 files changed, 36 insertions(+), 33 deletions(-)
fs/xfs/xfs_mount.c +6 -23
@@ -768,27 +768,15 @@ xfs_mountfs(/* enable fail_at_unmount as default */ mp->m_fail_unmount = true; -super_set_sysfs_name_id (mp->m_super); - - error =xfs_sysfs_init (&mp->m_kobj, &xfs_mp_ktype, -NULL , mp->m_super->s_id); -if (error) - goto out; - - error =xfs_sysfs_init (&mp->m_stats.xs_kobj, &xfs_stats_ktype, - &mp->m_kobj,"stats" ); + error =xfs_mount_sysfs_init (mp);if (error) - goto out_remove_sysfs; + goto out_remove_scrub_stats;xchk_stats_register (mp->m_scrub_stats, mp->m_debugfs); - error =xfs_error_sysfs_init (mp); -if (error) - goto out_remove_scrub_stats; - error =xfs_errortag_init (mp);if (error) - goto out_remove_error_sysfs; + goto out_remove_sysfs; error =xfs_uuid_mount (mp);if (error)
@@ -1151,13 +1139,10 @@ xfs_mountfs(xfs_uuid_unmount (mp); out_remove_errortag:xfs_errortag_del (mp); - out_remove_error_sysfs: -xfs_error_sysfs_del (mp); + out_remove_sysfs: +xfs_mount_sysfs_del (mp); out_remove_scrub_stats:xchk_stats_unregister (mp->m_scrub_stats); -xfs_sysfs_del (&mp->m_stats.xs_kobj); - out_remove_sysfs: -xfs_sysfs_del (&mp->m_kobj); out:return error; }
@@ -1234,10 +1219,8 @@ xfs_unmountfs(xfs_free_rtgroups (mp,0 , mp->m_sb.sb_rgcount);xfs_free_perag_range (mp,0 , mp->m_sb.sb_agcount);xfs_errortag_del (mp); -xfs_error_sysfs_del (mp);xchk_stats_unregister (mp->m_scrub_stats); -xfs_sysfs_del (&mp->m_stats.xs_kobj); -xfs_sysfs_del (&mp->m_kobj); +xfs_mount_sysfs_del (mp); }/*
fs/xfs/xfs_sysfs.c +28 -7
@@ -69,7 +69,7 @@ static struct attribute *xfs_mp_attrs[] = { };ATTRIBUTE_GROUPS (xfs_mp); -const struct kobj_type xfs_mp_ktype = { +static const struct kobj_type xfs_mp_ktype = { .release = xfs_sysfs_release, .sysfs_ops = &xfs_sysfs_ops, .default_groups = xfs_mp_groups,
@@ -702,39 +702,58 @@ xfs_error_sysfs_init_class( }int -xfs_error_sysfs_init ( +xfs_mount_sysfs_init (struct xfs_mount *mp) {int error; +super_set_sysfs_name_id (mp->m_super); + +/* .../xfs/<dev>/ */ + error =xfs_sysfs_init (&mp->m_kobj, &xfs_mp_ktype, +NULL , mp->m_super->s_id); +if (error) +return error; + +/* .../xfs/<dev>/stats/ */ + error =xfs_sysfs_init (&mp->m_stats.xs_kobj, &xfs_stats_ktype, + &mp->m_kobj,"stats" ); +if (error) + goto out_remove_fsdir; +/* .../xfs/<dev>/error/ */ error =xfs_sysfs_init (&mp->m_error_kobj, &xfs_error_ktype, &mp->m_kobj,"error" );if (error) -return error; + goto out_remove_stats_dir; +/* .../xfs/<dev>/error/fail_at_unmount */ error =sysfs_create_file (&mp->m_error_kobj.kobject,ATTR_LIST (fail_at_unmount));if (error) - goto out_error; + goto out_remove_error_dir;/* .../xfs/<dev>/error/metadata/ */ error =xfs_error_sysfs_init_class (mp,XFS_ERR_METADATA ,"metadata" , &mp->m_error_meta_kobj, xfs_error_meta_init);if (error) - goto out_error; + goto out_remove_error_dir;return 0 ; -out_error: +out_remove_error_dir:xfs_sysfs_del (&mp->m_error_kobj); +out_remove_stats_dir: +xfs_sysfs_del (&mp->m_stats.xs_kobj); +out_remove_fsdir: +xfs_sysfs_del (&mp->m_kobj);return error; }void -xfs_error_sysfs_del ( +xfs_mount_sysfs_del (struct xfs_mount *mp) {struct xfs_error_cfg *cfg;
@@ -749,6 +768,8 @@ xfs_error_sysfs_del( }xfs_sysfs_del (&mp->m_error_meta_kobj);xfs_sysfs_del (&mp->m_error_kobj); +xfs_sysfs_del (&mp->m_stats.xs_kobj); +xfs_sysfs_del (&mp->m_kobj); } struct xfs_error_cfg *
fs/xfs/xfs_sysfs.h +2 -3
@@ -7,7 +7,6 @@#ifndef __XFS_SYSFS_H__#define __XFS_SYSFS_H__ -extern const struct kobj_type xfs_mp_ktype;/* xfs_mount */ extern const struct kobj_type xfs_dbg_ktype;/* debug */ extern const struct kobj_type xfs_log_ktype;/* xlog */ extern const struct kobj_type xfs_stats_ktype;/* stats */
@@ -53,7 +52,7 @@ xfs_sysfs_del( wait_for_completion(&kobj->complete); } -int xfs_error_sysfs_init (struct xfs_mount *mp); -void xfs_error_sysfs_del (struct xfs_mount *mp); +int xfs_mount_sysfs_init (struct xfs_mount *mp); +void xfs_mount_sysfs_del (struct xfs_mount *mp);#endif /* __XFS_SYSFS_H__ */
Signature · 1 line
2.45.2
PATCH 45/45 xfs: export max_open_zones in sysfs
In reply to Christoph HellwigAdd 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.
--- fs/xfs/xfs_mount.h | 1 + fs/xfs/xfs_sysfs.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
fs/xfs/xfs_mount.h +1 -0
@@ -287,6 +287,7 @@ typedef struct xfs_mount {#ifdef CONFIG_XFS_ONLINE_SCRUB_STATS struct xchk_stats *m_scrub_stats;#endif +struct xfs_kobj m_zoned_kobj;xfs_agnumber_t m_agfrotor;/* last ag where space found */ atomic_t m_agirotor;/* last ag dir inode alloced */ atomic_t m_rtgrotor;/* last rtgroup rtpicked */
fs/xfs/xfs_sysfs.c +40 -0
@@ -13,6 +13,7 @@#include "xfs_log.h" #include "xfs_log_priv.h" #include "xfs_mount.h" +#include "xfs_zones.h" struct xfs_sysfs_attr {struct attribute attr;
@@ -701,6 +702,34 @@ xfs_error_sysfs_init_class(return error; } +static inline struct xfs_mount *zoned_to_mp (struct kobject *kobj) +{ + return container_of(to_kobj(kobj), struct xfs_mount, m_zoned_kobj); +} + +static ssize_t +max_open_zones_show ( +struct kobject *kobj, +char *buf) +{ +/* only report the open zones available for user data */ +return sysfs_emit (buf,"%u\n" , +zoned_to_mp (kobj)->m_max_open_zones -XFS_OPEN_GC_ZONES ); +} +XFS_SYSFS_ATTR_RO (max_open_zones); + +static struct attribute *xfs_zoned_attrs[] = { +ATTR_LIST (max_open_zones), +NULL , +}; +ATTRIBUTE_GROUPS (xfs_zoned); + +static const struct kobj_type xfs_zoned_ktype = { + .release = xfs_sysfs_release, + .sysfs_ops = &xfs_sysfs_ops, + .default_groups = xfs_zoned_groups, +}; +int xfs_mount_sysfs_init (struct xfs_mount *mp)
@@ -741,6 +770,14 @@ xfs_mount_sysfs_init(if (error) goto out_remove_error_dir; +if (IS_ENABLED (CONFIG_XFS_RT ) &&xfs_has_zoned (mp)) { +/* .../xfs/<dev>/zoned/ */ + error =xfs_sysfs_init (&mp->m_zoned_kobj, &xfs_zoned_ktype, + &mp->m_kobj,"zoned" ); +if (error) + goto out_remove_error_dir; + } +return 0 ; out_remove_error_dir:
@@ -759,6 +796,9 @@ xfs_mount_sysfs_del(struct xfs_error_cfg *cfg;int i, j; +if (IS_ENABLED (CONFIG_XFS_RT ) &&xfs_has_zoned (mp)) +xfs_sysfs_del (&mp->m_zoned_kobj); +for (i =0 ; i <XFS_ERR_CLASS_MAX ; i++) {for (j =0 ; j <XFS_ERR_ERRNO_MAX ; j++) { cfg = &mp->m_error_cfg[i][j];
Signature · 1 line
2.45.2