stats and error injection for zoned GC v2
Subsystems (2)
Hi all,
this series adds error injection for zoned resets and zoned GC stats. My initial use is for a test case that verifies zone reset error handling, but that stats should also be very useful for monitoring tools like PCP and benchmarking.
As part of the error injection work I've also added a mount option to enable error ibjection at mount time so that it can exercise the mount code as well and cleaned up various other bits of the error injection code.
Changes since v1:
- improve the errortag mount option documentation
- rename the defer_log stat to match all the others
- rename xs_gc_write_bytes to xs_gc_bytes and correctly track it
Diffstat:
Documentation/admin-guide/xfs.rst | 8 ++ fs/xfs/libxfs/xfs_defer.c | 2 fs/xfs/libxfs/xfs_errortag.h | 8 +- fs/xfs/xfs_error.c | 142 +++++++++++++++++++++----------------- fs/xfs/xfs_error.h | 23 ++---- fs/xfs/xfs_stats.c | 12 ++- fs/xfs/xfs_stats.h | 8 +- fs/xfs/xfs_super.c | 20 +++++ fs/xfs/xfs_zone_gc.c | 72 ++++++++++++------- 9 files changed, 186 insertions(+), 109 deletions(-)
PATCH 1/11 xfs: fix the errno sign for the xfs_errortag_{add,clearall} stubs
All errno values should be negative in the kernel.
--- fs/xfs/xfs_error.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_error.h +2 -2
@@ -60,8 +60,8 @@ int xfs_errortag_clearall(struct xfs_mount *mp);#define xfs_errortag_del (mp)#define XFS_TEST_ERROR (mp, tag) (false)#define XFS_ERRORTAG_DELAY (mp, tag) ((void)0) -#define xfs_errortag_add (mp, tag) (ENOSYS) -#define xfs_errortag_clearall (mp) (ENOSYS) +#define xfs_errortag_add (mp, tag) (-ENOSYS) +#define xfs_errortag_clearall (mp) (-ENOSYS)#endif /* DEBUG */ /*
Signature · 1 line
2.47.3
PATCH 2/11 xfs: allocate m_errortag early
In reply to Christoph HellwigEnsure the mount structure always has a valid m_errortag for debug builds. This removes the NULL checking from the runtime code, and prepares for allowing to set errortags from mount.
--- fs/xfs/xfs_error.c | 26 +------------------------- fs/xfs/xfs_super.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 25 deletions(-)
fs/xfs/xfs_error.c +1 -25
@@ -114,18 +114,8 @@ intxfs_errortag_init ( struct xfs_mount *mp) { -int ret; - - mp->m_errortag =kzalloc (sizeof (unsigned int ) *XFS_ERRTAG_MAX , -GFP_KERNEL | __GFP_RETRY_MAYFAIL); -if (!mp->m_errortag) -return -ENOMEM ; - - ret =xfs_sysfs_init (&mp->m_errortag_kobj, &xfs_errortag_ktype, +return xfs_sysfs_init (&mp->m_errortag_kobj, &xfs_errortag_ktype, &mp->m_kobj,"errortag" ); -if (ret) -kfree (mp->m_errortag); -return ret; }void
@@ -133,7 +123,6 @@ xfs_errortag_del( struct xfs_mount *mp) {xfs_sysfs_del (&mp->m_errortag_kobj); -kfree (mp->m_errortag); } static bool
@@ -154,8 +143,6 @@ xfs_errortag_enabled( struct xfs_mount *mp, unsigned int tag) { -if (!mp->m_errortag) -return false;if (!xfs_errortag_valid (tag))return false;
@@ -171,17 +158,6 @@ xfs_errortag_test( {unsigned int randfactor; -/* -* To be able to use error injection anywhere, we need to ensure error -* injection mechanism is already initialized. -* -* Code paths like I/O completion can be called before the -* initialization is complete, but be able to inject errors in such -* places is still useful. -*/ -if (!mp->m_errortag) -return false; -if (!xfs_errortag_valid (error_tag))return false;
fs/xfs/xfs_super.c +12 -0
@@ -40,6 +40,7 @@#include "xfs_defer.h" #include "xfs_attr_item.h" #include "xfs_xattr.h" +#include "xfs_errortag.h" #include "xfs_iunlink_item.h" #include "xfs_dahash_test.h" #include "xfs_rtbitmap.h"
@@ -822,6 +823,9 @@ xfs_mount_free(debugfs_remove (mp->m_debugfs);kfree (mp->m_rtname);kfree (mp->m_logname); +#ifdef DEBUG +kfree (mp->m_errortag); +#endif kfree (mp); }
@@ -2254,6 +2258,14 @@ xfs_init_fs_context( mp =kzalloc (sizeof (struct xfs_mount ),GFP_KERNEL );if (!mp)return -ENOMEM ; +#ifdef DEBUG + mp->m_errortag =kcalloc (XFS_ERRTAG_MAX ,sizeof (*mp->m_errortag), +GFP_KERNEL ); +if (!mp->m_errortag) { +kfree (mp); +return -ENOMEM ; + } +#endif spin_lock_init (&mp->m_sb_lock);for (i =0 ; i <XG_TYPE_MAX ; i++)
Signature · 1 line
2.47.3
PATCH 3/11 xfs: don't validate error tags in the I/O path
In reply to Christoph HellwigWe can trust XFS developers enough to not pass random stuff to XFS_ERROR_TEST/DELAY. Open code the validity check in xfs_errortag_add, which is the only place that receives unvalidated error tag values from user space, and drop the now pointless xfs_errortag_enabled helper.
--- fs/xfs/libxfs/xfs_errortag.h | 2 +- fs/xfs/xfs_error.c | 38 ++++++++++-------------------------- fs/xfs/xfs_error.h | 2 +- 3 files changed, 12 insertions(+), 30 deletions(-)
fs/xfs/libxfs/xfs_errortag.h +1 -1
@@ -53,7 +53,7 @@* Drop-writes support removed because write error handling cannot trash * pre-existing delalloc extents in any useful way anymore. We retain the * definition so that we can reject it as an invalid value in -* xfs_errortag_valid(). +* xfs_errortag_add(). */ #define XFS_ERRTAG_DROP_WRITES 28#define XFS_ERRTAG_LOG_BAD_CRC 29
fs/xfs/xfs_error.c +10 -28
@@ -125,30 +125,6 @@ xfs_errortag_del(xfs_sysfs_del (&mp->m_errortag_kobj); } -static bool -xfs_errortag_valid ( -unsigned int error_tag) -{ -if (error_tag >=XFS_ERRTAG_MAX ) -return false; - -/* Error out removed injection types */ -if (error_tag ==XFS_ERRTAG_DROP_WRITES ) -return false; -return true; -} - -bool -xfs_errortag_enabled ( -struct xfs_mount *mp, -unsigned int tag) -{ -if (!xfs_errortag_valid (tag)) -return false; - -return mp->m_errortag[tag] !=0 ; -} - bool xfs_errortag_test( struct xfs_mount *mp,
@@ -158,9 +134,6 @@ xfs_errortag_test( {unsigned int randfactor; -if (!xfs_errortag_valid (error_tag)) -return false; - randfactor = mp->m_errortag[error_tag];if (!randfactor ||get_random_u32_below (randfactor))return false;
@@ -178,8 +151,17 @@ xfs_errortag_add( {BUILD_BUG_ON (ARRAY_SIZE (xfs_errortag_random_default) !=XFS_ERRTAG_MAX ); -if (!xfs_errortag_valid (error_tag)) +if (error_tag >=XFS_ERRTAG_MAX ) +return -EINVAL ; + +/* Error out removed injection types */ +switch (error_tag) { +case XFS_ERRTAG_DROP_WRITES :return -EINVAL ; +default : +break ; + } + mp->m_errortag[error_tag] = xfs_errortag_random_default[error_tag];return 0 ; }
fs/xfs/xfs_error.h +1 -1
@@ -44,7 +44,7 @@ bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);#define XFS_ERRORTAG_DELAY (mp, tag) \ do { \ might_sleep(); \ - if (!xfs_errortag_enabled((mp), (tag))) \ + if (!mp->m_errortag[tag]) \ break; \ xfs_warn_ratelimited((mp), \ "Injecting %ums delay at file %s, line %d, on filesystem \"%s\"", \
Signature · 1 line
2.47.3
PATCH 4/11 xfs: move the guts of XFS_ERRORTAG_DELAY out of line
In reply to Christoph HellwigMirror what is done for the more common XFS_ERRORTAG_TEST version, and also only look at the error tag value once now that we can easily have a local variable.
--- fs/xfs/xfs_error.c | 21 +++++++++++++++++++++ fs/xfs/xfs_error.h | 15 +++------------ 2 files changed, 24 insertions(+), 12 deletions(-)
fs/xfs/xfs_error.c +21 -0
@@ -144,6 +144,27 @@ xfs_errortag_test(return true; } +void +xfs_errortag_delay ( +struct xfs_mount *mp, +const char *file, +int line, +unsigned int error_tag) +{ +unsigned int delay = mp->m_errortag[error_tag]; + +might_sleep (); + +if (!delay) +return ; + +xfs_warn_ratelimited (mp, +"Injecting %ums delay at file %s, line %d, on filesystem \"%s\"" , + delay, file, line, + mp->m_super->s_id); +mdelay (delay); +} + int xfs_errortag_add( struct xfs_mount *mp,
fs/xfs/xfs_error.h +3 -12
@@ -40,19 +40,10 @@ bool xfs_errortag_test(struct xfs_mount *mp, const char *file, int line, unsigned int error_tag);#define XFS_TEST_ERROR (mp, tag) \ xfs_errortag_test((mp), __FILE__, __LINE__, (tag)) -bool xfs_errortag_enabled (struct xfs_mount *mp,unsigned int tag); +void xfs_errortag_delay (struct xfs_mount *mp,const char *file,int line, +unsigned int error_tag);#define XFS_ERRORTAG_DELAY (mp, tag) \ - do { \ - might_sleep(); \ - if (!mp->m_errortag[tag]) \ - break; \ - xfs_warn_ratelimited((mp), \ -"Injecting %ums delay at file %s, line %d, on filesystem \"%s\"", \ - (mp)->m_errortag[(tag)], __FILE__, __LINE__, \ - (mp)->m_super->s_id); \ - mdelay((mp)->m_errortag[(tag)]); \ - } while (0) - + xfs_errortag_delay((mp), __FILE__, __LINE__, (tag))int xfs_errortag_add (struct xfs_mount *mp,unsigned int error_tag);int xfs_errortag_clearall (struct xfs_mount *mp);#else
Signature · 1 line
2.47.3
PATCH 5/11 xfs: use WRITE_ONCE/READ_ONCE for m_errortag
In reply to Christoph HellwigThere is no synchronization for updating m_errortag, which is fine as it's just a debug tool. It would still be nice to fully avoid the theoretical case of torn values, so use WRITE_ONCE and READ_ONCE to access the members.
--- fs/xfs/xfs_error.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
fs/xfs/xfs_error.c +14 -9
@@ -50,17 +50,18 @@ xfs_errortag_attr_store( {struct xfs_mount *mp =to_mp (kobject);unsigned int error_tag =to_attr (attr)->tag; +unsigned int val;int ret;if (strcmp (buf,"default" ) ==0 ) { - mp->m_errortag[error_tag] = - xfs_errortag_random_default[error_tag]; + val = xfs_errortag_random_default[error_tag]; }else { - ret =kstrtouint (buf,0 , &mp->m_errortag[error_tag]); + ret =kstrtouint (buf,0 , &val);if (ret)return ret; } +WRITE_ONCE (mp->m_errortag[error_tag], val);return count; }
@@ -71,9 +72,9 @@ xfs_errortag_attr_show( char *buf) {struct xfs_mount *mp =to_mp (kobject); -unsigned int error_tag =to_attr (attr)->tag; -return snprintf (buf,PAGE_SIZE ,"%u\n" , mp->m_errortag[error_tag]); +return snprintf (buf,PAGE_SIZE ,"%u\n" , +READ_ONCE (mp->m_errortag[to_attr (attr)->tag])); }static const struct sysfs_ops xfs_errortag_sysfs_ops = {
@@ -134,7 +135,7 @@ xfs_errortag_test( {unsigned int randfactor; - randfactor = mp->m_errortag[error_tag]; + randfactor =READ_ONCE (mp->m_errortag[error_tag]);if (!randfactor ||get_random_u32_below (randfactor))return false;
@@ -151,7 +152,7 @@ xfs_errortag_delay(int line, unsigned int error_tag) { - unsigned int delay = mp->m_errortag[error_tag]; + unsigned int delay = READ_ONCE(mp->m_errortag[error_tag]);might_sleep ();
@@ -183,7 +184,8 @@ xfs_errortag_add(break ; } - mp->m_errortag[error_tag] = xfs_errortag_random_default[error_tag]; +WRITE_ONCE (mp->m_errortag[error_tag], + xfs_errortag_random_default[error_tag]);return 0 ; }
@@ -191,7 +193,10 @@ intxfs_errortag_clearall ( struct xfs_mount *mp) { -memset (mp->m_errortag,0 ,sizeof (unsigned int ) *XFS_ERRTAG_MAX ); +unsigned int i; + +for (i =0 ; i <XFS_ERRTAG_MAX ; i++) +WRITE_ONCE (mp->m_errortag[i],0 );return 0 ; }#endif /* DEBUG */
Signature · 1 line
2.47.3
PATCH 6/11 xfs: allow setting errortags at mount time
In reply to Christoph HellwigAdd an errortag mount option that enables an errortag with the default injection frequency. This allows injecting errors into the mount process instead of just on live file systems, and thus test mount error handling.
--- Documentation/admin-guide/xfs.rst | 8 +++++++ fs/xfs/xfs_error.c | 36 +++++++++++++++++++++++++++++++ fs/xfs/xfs_error.h | 4 ++++ fs/xfs/xfs_super.c | 8 ++++++- 4 files changed, 55 insertions(+), 1 deletion(-)
Documentation/admin-guide/xfs.rst +8 -0
@@ -215,6 +215,14 @@ When mounting an XFS filesystem, the following options are accepted. inconsistent namespace presentation during or after a failover event. + errortag=tagname + When specified, enables the error inject tag named "tagname" with the + default frequency. Can be specified multiple times to enable multiple + errortags. Specifying this option on remount will reset the error tag + to the default value if it was set to any other value before. + This option is only supported when CONFIG_XFS_DEBUG is enabled, and + will not be reflected in /proc/self/mounts. + Deprecation of V4 Format ========================
fs/xfs/xfs_error.c +36 -0
@@ -22,6 +22,12 @@static const unsigned int xfs_errortag_random_default[] = {XFS_ERRTAGS };#undef XFS_ERRTAG +#define XFS_ERRTAG (_tag, _name, _default) \ + [XFS_ERRTAG_##_tag] = __stringify(_name), +#include "xfs_errortag.h" +static const char *xfs_errortag_names[] = {XFS_ERRTAGS }; +#undef XFS_ERRTAG +struct xfs_errortag_attr {struct attribute attr;unsigned int tag;
@@ -189,6 +195,36 @@ xfs_errortag_add(return 0 ; } +int +xfs_errortag_add_name ( +struct xfs_mount *mp, +const char *tag_name) +{ +unsigned int i; + +for (i =0 ; i <XFS_ERRTAG_MAX ; i++) { +if (xfs_errortag_names[i] && + !strcmp (xfs_errortag_names[i], tag_name)) +return xfs_errortag_add (mp, i); + } + +return -EINVAL ; +} + +void +xfs_errortag_copy ( +struct xfs_mount *dst_mp, +struct xfs_mount *src_mp) +{ +unsigned int val, i; + +for (i =0 ; i <XFS_ERRTAG_MAX ; i++) { + val =READ_ONCE (src_mp->m_errortag[i]); +if (val) +WRITE_ONCE (dst_mp->m_errortag[i], val); + } +} +int xfs_errortag_clearall (struct xfs_mount *mp)
fs/xfs/xfs_error.h +4 -0
@@ -45,6 +45,8 @@ void xfs_errortag_delay(struct xfs_mount *mp, const char *file, int line,#define XFS_ERRORTAG_DELAY (mp, tag) \ xfs_errortag_delay((mp), __FILE__, __LINE__, (tag))int xfs_errortag_add (struct xfs_mount *mp,unsigned int error_tag); +int xfs_errortag_add_name (struct xfs_mount *mp,const char *tag_name); +void xfs_errortag_copy (struct xfs_mount *dst_mp,struct xfs_mount *src_mp);int xfs_errortag_clearall (struct xfs_mount *mp);#else #define xfs_errortag_init (mp) (0)
@@ -52,6 +54,8 @@ int xfs_errortag_clearall(struct xfs_mount *mp);#define XFS_TEST_ERROR (mp, tag) (false)#define XFS_ERRORTAG_DELAY (mp, tag) ((void)0)#define xfs_errortag_add (mp, tag) (-ENOSYS) +#define xfs_errortag_copy (dst_mp, src_mp) ((void)0) +#define xfs_errortag_add_name (mp, tag_name) (-ENOSYS)#define xfs_errortag_clearall (mp) (-ENOSYS)#endif /* DEBUG */
fs/xfs/xfs_super.c +7 -1
@@ -40,6 +40,7 @@#include "xfs_defer.h" #include "xfs_attr_item.h" #include "xfs_xattr.h" +#include "xfs_error.h" #include "xfs_errortag.h" #include "xfs_iunlink_item.h" #include "xfs_dahash_test.h"
@@ -112,7 +113,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, Opt_max_atomic_write, + Opt_lifetime, Opt_nolifetime, Opt_max_atomic_write, Opt_errortag, };#define fsparam_dead (NAME ) \
@@ -171,6 +172,7 @@ static const struct fs_parameter_spec xfs_fs_parameters[] = {fsparam_flag ("lifetime" , Opt_lifetime),fsparam_flag ("nolifetime" , Opt_nolifetime),fsparam_string ("max_atomic_write" , Opt_max_atomic_write), + fsparam_string("errortag", Opt_errortag), {} };
@@ -1581,6 +1583,8 @@ xfs_fs_parse_param(return -EINVAL ; }return 0 ; +case Opt_errortag: +return xfs_errortag_add_name (parsing_mp, param->string);default :xfs_warn (parsing_mp,"unknown mount option [%s]." , param->key);return -EINVAL ;
@@ -2172,6 +2176,8 @@ xfs_fs_reconfigure(if (error)return error; +xfs_errortag_copy (mp, new_mp); +/* Validate new max_atomic_write option before making other changes */ if (mp->m_awu_max_bytes != new_mp->m_awu_max_bytes) { error = xfs_set_max_atomic_write_opt(mp,
Signature · 1 line
2.47.3
PATCH 7/11 xfs: don't mark all discard issued by zoned GC as sync
In reply to Christoph HellwigDiscard are not usually sync when issued from zoned garbage collection, so drop the REQ_SYNC flag.
--- fs/xfs/xfs_zone_gc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/xfs_zone_gc.c +2 -1
@@ -905,7 +905,8 @@ xfs_zone_gc_prepare_reset(if (!bdev_zone_is_seq (bio->bi_bdev, bio->bi_iter.bi_sector)) {if (!bdev_max_discard_sectors (bio->bi_bdev))return false; - bio->bi_opf =REQ_OP_DISCARD |REQ_SYNC ; + bio->bi_opf &= ~REQ_OP_ZONE_RESET ; + bio->bi_opf |=REQ_OP_DISCARD ; bio->bi_iter.bi_size =XFS_FSB_TO_B (rtg_mount (rtg),rtg_blocks (rtg)); }
Signature · 1 line
2.47.3
PATCH 8/11 xfs: refactor zone reset handling
In reply to Christoph HellwigInclude the actual bio submission in the common zone reset handler to share more code and prepare for adding error injection for zone reset.
Note the I plan to refactor the block layer submit_bio_wait and bio_await_chain code in the next merge window to remove some of the code duplication added here.
--- fs/xfs/xfs_zone_gc.c | 49 +++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-)
fs/xfs/xfs_zone_gc.c +28 -21
@@ -893,40 +893,55 @@ xfs_zone_gc_finish_reset(bio_put (&chunk->bio); } -static bool -xfs_zone_gc_prepare_reset ( -struct bio *bio, -struct xfs_rtgroup *rtg) +static void +xfs_submit_zone_reset_bio ( +struct xfs_rtgroup *rtg, +struct bio *bio) {trace_xfs_zone_reset (rtg);ASSERT (rtg_rmap (rtg)->i_used_blocks ==0 ); bio->bi_iter.bi_sector =xfs_gbno_to_daddr (&rtg->rtg_group,0 );if (!bdev_zone_is_seq (bio->bi_bdev, bio->bi_iter.bi_sector)) { -if (!bdev_max_discard_sectors (bio->bi_bdev)) -return false; +/* +* Also use the bio to drive the state machine when neither +* zone reset nor discard is supported to keep things simple. +*/ +if (!bdev_max_discard_sectors (bio->bi_bdev)) { +bio_endio (bio); +return ; + } bio->bi_opf &= ~REQ_OP_ZONE_RESET ; bio->bi_opf |=REQ_OP_DISCARD ; bio->bi_iter.bi_size =XFS_FSB_TO_B (rtg_mount (rtg),rtg_blocks (rtg)); } -return true; +submit_bio (bio); +} + +static void xfs_bio_wait_endio (struct bio *bio) +{ +complete (bio->bi_private); }int xfs_zone_gc_reset_sync (struct xfs_rtgroup *rtg) { -int error =0 ; +DECLARE_COMPLETION_ONSTACK (done);struct bio bio; +int error;bio_init (&bio,rtg_mount (rtg)->m_rtdev_targp->bt_bdev,NULL ,0 , -REQ_OP_ZONE_RESET ); -if (xfs_zone_gc_prepare_reset (&bio, rtg)) - error =submit_bio_wait (&bio); -bio_uninit (&bio); +REQ_OP_ZONE_RESET |REQ_SYNC ); + bio.bi_private = &done; + bio.bi_end_io = xfs_bio_wait_endio; +xfs_submit_zone_reset_bio (rtg, &bio); +wait_for_completion_io (&done); + error =blk_status_to_errno (bio.bi_status); +bio_uninit (&bio);return error; }
@@ -961,15 +976,7 @@ xfs_zone_gc_reset_zones( chunk->data = data;WRITE_ONCE (chunk->state,XFS_GC_BIO_NEW );list_add_tail (&chunk->entry, &data->resetting); - -/* -* Also use the bio to drive the state machine when neither -* zone reset nor discard is supported to keep things simple. -*/ -if (xfs_zone_gc_prepare_reset (bio, rtg)) -submit_bio (bio); -else -bio_endio (bio); +xfs_submit_zone_reset_bio (rtg, bio); }while (next); }
Signature · 1 line
2.47.3
PATCH 9/11 xfs: add zone reset error injection
In reply to Christoph HellwigAdd a new errortag to test that zone reset errors are handled correctly.
--- fs/xfs/libxfs/xfs_errortag.h | 6 ++++-- fs/xfs/xfs_zone_gc.c | 13 +++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_errortag.h +4 -2
@@ -74,7 +74,8 @@#define XFS_ERRTAG_EXCHMAPS_FINISH_ONE 44#define XFS_ERRTAG_METAFILE_RESV_CRITICAL 45#define XFS_ERRTAG_FORCE_ZERO_RANGE 46 -#define XFS_ERRTAG_MAX 47 +#define XFS_ERRTAG_ZONE_RESET 47 +#define XFS_ERRTAG_MAX 48/* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
@@ -135,7 +136,8 @@ XFS_ERRTAG(WB_DELAY_MS, wb_delay_ms, 3000) \ XFS_ERRTAG(WRITE_DELAY_MS, write_delay_ms, 3000) \ XFS_ERRTAG(EXCHMAPS_FINISH_ONE, exchmaps_finish_one, 1) \ XFS_ERRTAG(METAFILE_RESV_CRITICAL, metafile_resv_crit, 4) \ -XFS_ERRTAG(FORCE_ZERO_RANGE, force_zero_range, 4) +XFS_ERRTAG(FORCE_ZERO_RANGE, force_zero_range, 4) \ +XFS_ERRTAG(ZONE_RESET, zone_reset, 1)#endif /* XFS_ERRTAG */ #endif /* __XFS_ERRORTAG_H_ */
fs/xfs/xfs_zone_gc.c +11 -2
@@ -16,6 +16,8 @@#include "xfs_rmap.h" #include "xfs_rtbitmap.h" #include "xfs_rtrmap_btree.h" +#include "xfs_errortag.h" +#include "xfs_error.h" #include "xfs_zone_alloc.h" #include "xfs_zone_priv.h" #include "xfs_zones.h"
@@ -898,9 +900,17 @@ xfs_submit_zone_reset_bio(struct xfs_rtgroup *rtg, struct bio *bio) { + struct xfs_mount *mp = rtg_mount(rtg); +trace_xfs_zone_reset (rtg);ASSERT (rtg_rmap (rtg)->i_used_blocks ==0 ); + +if (XFS_TEST_ERROR (mp,XFS_ERRTAG_ZONE_RESET )) { +bio_io_error (bio); +return ; + } + bio->bi_iter.bi_sector =xfs_gbno_to_daddr (&rtg->rtg_group,0 );if (!bdev_zone_is_seq (bio->bi_bdev, bio->bi_iter.bi_sector)) {/*
@@ -913,8 +923,7 @@ xfs_submit_zone_reset_bio( } bio->bi_opf &= ~REQ_OP_ZONE_RESET ; bio->bi_opf |=REQ_OP_DISCARD ; - bio->bi_iter.bi_size = -XFS_FSB_TO_B (rtg_mount (rtg),rtg_blocks (rtg)); + bio->bi_iter.bi_size =XFS_FSB_TO_B (mp,rtg_blocks (rtg)); }submit_bio (bio);
Signature · 1 line
2.47.3
PATCH 10/11 xfs: give the defer_relog stat a xs_ prefix
In reply to Christoph HellwigMake this counter naming consistent with all the others.
--- fs/xfs/libxfs/xfs_defer.c | 2 +- fs/xfs/xfs_stats.c | 6 +++--- fs/xfs/xfs_stats.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_defer.c +1 -1
@@ -565,7 +565,7 @@ xfs_defer_relog(continue ;trace_xfs_defer_relog_intent ((*tpp)->t_mountp, dfp); -XFS_STATS_INC ((*tpp)->t_mountp, defer_relog); +XFS_STATS_INC ((*tpp)->t_mountp, xs_defer_relog);xfs_defer_relog_intent (*tpp, dfp); }
fs/xfs/xfs_stats.c +3 -3
@@ -23,7 +23,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)uint64_t xs_xstrat_bytes =0 ;uint64_t xs_write_bytes =0 ;uint64_t xs_read_bytes =0 ; -uint64_t defer_relog =0 ; +uint64_t xs_defer_relog =0 ; static const struct xstats_entry { char *desc;
@@ -76,13 +76,13 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) xs_xstrat_bytes +=per_cpu_ptr (stats, i)->s.xs_xstrat_bytes; xs_write_bytes +=per_cpu_ptr (stats, i)->s.xs_write_bytes; xs_read_bytes +=per_cpu_ptr (stats, i)->s.xs_read_bytes; - defer_relog +=per_cpu_ptr (stats, i)->s.defer_relog; + xs_defer_relog +=per_cpu_ptr (stats, i)->s.xs_defer_relog; } len +=scnprintf (buf + len,PATH_MAX -len,"xpc %llu %llu %llu\n" , xs_xstrat_bytes, xs_write_bytes, xs_read_bytes); len +=scnprintf (buf + len,PATH_MAX -len,"defer_relog %llu\n" , - defer_relog); + xs_defer_relog); len +=scnprintf (buf + len,PATH_MAX -len,"debug %u\n" , #if defined(DEBUG) 1);
fs/xfs/xfs_stats.h +1 -1
@@ -142,7 +142,7 @@ struct __xfsstats {uint64_t xs_xstrat_bytes;uint64_t xs_write_bytes;uint64_t xs_read_bytes; -uint64_t defer_relog; +uint64_t xs_defer_relog; };#define xfsstats_offset (f) (offsetof(struct __xfsstats, f)/sizeof(uint32_t))
Signature · 1 line
2.47.3
Re: [PATCH 10/11] xfs: give the defer_relog stat a xs_ prefix
Quoted 3 lines · Christoph Hellwig
Make this counter naming consistent with all the others.
Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 11/11 xfs: add sysfs stats for zoned GC
In reply to Christoph HellwigAdd counters of read, write and zone_reset operations as well as GC written bytes to sysfs. This way they can be easily used for monitoring tools and test cases.
--- fs/xfs/xfs_stats.c | 6 +++++- fs/xfs/xfs_stats.h | 6 ++++++ fs/xfs/xfs_zone_gc.c | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-)
fs/xfs/xfs_stats.c +5 -1
@@ -24,6 +24,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)uint64_t xs_write_bytes =0 ;uint64_t xs_read_bytes =0 ;uint64_t xs_defer_relog =0 ; +uint64_t xs_gc_bytes =0 ; static const struct xstats_entry { char *desc;
@@ -57,7 +58,8 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) { "rtrmapbt_mem", xfsstats_offset(xs_rtrefcbt_2) }, { "rtrefcntbt", xfsstats_offset(xs_qm_dqreclaims)},/* we print both series of quota information together */ - { "qm", xfsstats_offset(xs_xstrat_bytes)}, + { "qm", xfsstats_offset(xs_gc_read_calls)}, + { "zoned", xfsstats_offset(__pad1)}, };/* Loop over all stats groups */
@@ -77,6 +79,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) xs_write_bytes +=per_cpu_ptr (stats, i)->s.xs_write_bytes; xs_read_bytes +=per_cpu_ptr (stats, i)->s.xs_read_bytes; xs_defer_relog +=per_cpu_ptr (stats, i)->s.xs_defer_relog; + xs_gc_bytes +=per_cpu_ptr (stats, i)->s.xs_gc_bytes; } len += scnprintf(buf + len, PATH_MAX-len, "xpc %llu %llu %llu\n",
@@ -89,6 +92,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)#else 0);#endif + len +=scnprintf (buf + len,PATH_MAX -len,"gc xpc %llu\n" , xs_gc_bytes);return len; }
fs/xfs/xfs_stats.h +6 -0
@@ -138,11 +138,17 @@ struct __xfsstats {uint32_t xs_qm_dqwants;uint32_t xs_qm_dquot;uint32_t xs_qm_dquot_unused; +/* Zone GC counters */ +uint32_t xs_gc_read_calls; +uint32_t xs_gc_write_calls; +uint32_t xs_gc_zone_reset_calls; +uint32_t __pad1;/* Extra precision counters */ uint64_t xs_xstrat_bytes;uint64_t xs_write_bytes;uint64_t xs_read_bytes;uint64_t xs_defer_relog; +uint64_t xs_gc_bytes; };#define xfsstats_offset (f) (offsetof(struct __xfsstats, f)/sizeof(uint32_t))
fs/xfs/xfs_zone_gc.c +7 -0
@@ -712,6 +712,8 @@ xfs_zone_gc_start_chunk( data->scratch_head = (data->scratch_head + len) % data->scratch_size; data->scratch_available -= len; +XFS_STATS_INC (mp, xs_gc_read_calls); +WRITE_ONCE (chunk->state,XFS_GC_BIO_NEW );list_add_tail (&chunk->entry, &data->reading);xfs_zone_gc_iter_advance (iter, irec.rm_blockcount);
@@ -815,6 +817,9 @@ xfs_zone_gc_write_chunk(return ; } +XFS_STATS_INC (mp, xs_gc_write_calls); +XFS_STATS_ADD (mp, xs_gc_bytes, chunk->len); +WRITE_ONCE (chunk->state,XFS_GC_BIO_NEW );list_move_tail (&chunk->entry, &data->writing);
@@ -911,6 +916,8 @@ xfs_submit_zone_reset_bio(return ; } +XFS_STATS_INC (mp, xs_gc_zone_reset_calls); + bio->bi_iter.bi_sector =xfs_gbno_to_daddr (&rtg->rtg_group,0 );if (!bdev_zone_is_seq (bio->bi_bdev, bio->bi_iter.bi_sector)) {/*
Signature · 1 line
2.47.3
Re: [PATCH 11/11] xfs: add sysfs stats for zoned GC
Quoted 97 lines · Christoph Hellwig
Add counters of read, write and
zone_resetoperations as well as GC written bytes to sysfs. This way they can be easily used for monitoring tools and test cases.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Carlos Maiolino <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>--- fs/xfs/xfs_stats.c | 6 +++++- fs/xfs/xfs_stats.h | 6 ++++++ fs/xfs/xfs_zone_gc.c | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-)fs/xfs/xfs_stats.c +5
-1@@ -24,6 +24,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)uint64_t xs_write_bytes =0 ;uint64_t xs_read_bytes =0 ;uint64_t xs_defer_relog =0 ; +uint64_t xs_gc_bytes =0 ; static const struct xstats_entry { char *desc;@@ -57,7 +58,8 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) { "rtrmapbt_mem", xfsstats_offset(xs_rtrefcbt_2) }, { "rtrefcntbt", xfsstats_offset(xs_qm_dqreclaims)},/* we print both series of quota information together */ - { "qm", xfsstats_offset(xs_xstrat_bytes)}, + { "qm", xfsstats_offset(xs_gc_read_calls)}, + { "zoned", xfsstats_offset(__pad1)}, };/* Loop over all stats groups */ @@ -77,6 +79,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) xs_write_bytes +=per_cpu_ptr (stats, i)->s.xs_write_bytes; xs_read_bytes +=per_cpu_ptr (stats, i)->s.xs_read_bytes; xs_defer_relog +=per_cpu_ptr (stats, i)->s.xs_defer_relog; + xs_gc_bytes +=per_cpu_ptr (stats, i)->s.xs_gc_bytes; } len += scnprintf(buf + len, PATH_MAX-len, "xpc %llu %llu %llu\n",@@ -89,6 +92,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf)#else 0);#endif + len +=scnprintf (buf + len,PATH_MAX -len,"gc xpc %llu\n" , xs_gc_bytes);return len; }fs/xfs/xfs_stats.h +6
-0@@ -138,11 +138,17 @@ struct __xfsstats {uint32_t xs_qm_dqwants;uint32_t xs_qm_dquot;uint32_t xs_qm_dquot_unused; +/* Zone GC counters */ +uint32_t xs_gc_read_calls; +uint32_t xs_gc_write_calls; +uint32_t xs_gc_zone_reset_calls; +uint32_t __pad1;/* Extra precision counters */ uint64_t xs_xstrat_bytes;uint64_t xs_write_bytes;uint64_t xs_read_bytes;uint64_t xs_defer_relog; +uint64_t xs_gc_bytes; };#define xfsstats_offset (f) (offsetof(struct __xfsstats, f)/sizeof(uint32_t))fs/xfs/xfs_zone_gc.c +5
-0@@ -712,6 +712,8 @@ xfs_zone_gc_start_chunk( data->scratch_head = (data->scratch_head + len) % data->scratch_size; data->scratch_available -= len; +XFS_STATS_INC (mp, xs_gc_read_calls); +WRITE_ONCE (chunk->state,XFS_GC_BIO_NEW );list_add_tail (&chunk->entry, &data->reading);xfs_zone_gc_iter_advance (iter, irec.rm_blockcount);@@ -815,6 +817,9 @@ xfs_zone_gc_write_chunk(return ; } +XFS_STATS_INC (mp, xs_gc_write_calls); +XFS_STATS_ADD (mp, xs_gc_bytes, chunk->len); +WRITE_ONCE (chunk->state,XFS_GC_BIO_NEW );list_move_tail (&chunk->entry, &data->writing);
fs/xfs/xfs_zone_gc.c xfs_submit_zone_reset_bio( · line 923
Quoted 8 lines
fs/xfs/xfs_zone_gc.c +2
-0@@ -911,6 +916,8 @@ xfs_submit_zone_reset_bio(return ; } +XFS_STATS_INC (mp, xs_gc_zone_reset_calls); + bio->bi_iter.bi_sector =xfs_gbno_to_daddr (&rtg->rtg_group,0 );if (!bdev_zone_is_seq (bio->bi_bdev, bio->bi_iter.bi_sector)) {/*
Looks good,
Quoted 11 lines · Christoph Hellwig
this series adds error injection for zoned resets and zoned GC stats. My initial use is for a test case that verifies zone reset error handling, but that stats should also be very useful for monitoring tools like PCP and benchmarking.
As part of the error injection work I've also added a mount option to enable error ibjection at mount time so that it can exercise the mount code as well and cleaned up various other bits of the error injection code.
[...]
Applied to for-next, thanks!
[01/11] xfs: fix the errno sign for the xfs_errortag_{add,clearall} stubs
commit: 9a228d141536a91bf9e48a21b37ebb0f8eea8273
[02/11] xfs: allocate m_errortag early
commit: 394969e2f9d11427ce493e171949958122dc11ee
[03/11] xfs: don't validate error tags in the I/O path
commit: b8862a09d8256a9037293f1da3b4617b21de26f1
[04/11] xfs: move the guts of XFS_ERRORTAG_DELAY out of line
commit: e2d62bfd99b6b79d7c5a4c543c2d84049f01f24f
[05/11] xfs: use WRITE_ONCE/READ_ONCE for m_errortag
commit: 4d8f42466a3ba2342b876822ff0582a49e174c9b
[06/11] xfs: allow setting errortags at mount time
commit: 2d263debd7f1df2091efb4c06eda02ab04b68562
[07/11] xfs: don't mark all discard issued by zoned GC as sync
commit: 32ae9b893a1dc341274ffabd3cdcc63134f36060
[08/11] xfs: refactor zone reset handling
commit: 06873dbd940dea955b30efb0b59212f1c858f6d9
[09/11] xfs: add zone reset error injection
commit: 41374ae69ec3a910950d3888f444f80678c6f308
[10/11] xfs: give the defer_relog stat a xs_ prefix
commit: edf6078212c366459d3c70833290579b200128b1
[11/11] xfs: add sysfs stats for zoned GC
commit: e33839b514a8af27ba03f9f2a414d154aa980320Best regards,
Signature · 1 line
Carlos Maiolino <[email protected]>