On Tue, Nov 29, 2022 at 12:34:53PM +1100, Dave Chinner wrote: > On Mon, Nov 28, 2022 at 05:21:18PM -0800, Darrick J. Wong wrote: > > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > > > Add a new error injection knob so that we can arbitrarily slow down > > writeback to test for race conditions and aberrant reclaim behavior if > > the writeback mechanisms are slow to issue writeback. This will enable > > functional testing for the ifork sequence counters introduced in commit > > 745b3f76d1c8 ("xfs: maintain a sequence count for inode fork > > manipulations"). > > > > Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> > > --- > > v2: this time with tracepoints > > --- > ..... > > > @@ -267,6 +270,14 @@ xfs_errortag_valid( > > return true; > > } > > > > +bool > > +xfs_errortag_enabled( > > + struct xfs_mount *mp, > > + unsigned int tag) > > +{ > > + return mp->m_errortag && mp->m_errortag[tag] != 0; > > +} > > Perhaps consider using the new xfs_errortag_valid() helper? i.e. > > { > if (!mp->errortag) > return false; > if (!xfs_errortag_valid(tag)) > return false; > return mp->m_errortag[tag] != 0; Fixed. > } > > > + > > bool > > xfs_errortag_test( > > struct xfs_mount *mp, > > diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h > > index 5191e9145e55..936d0c52d6af 100644 > > --- a/fs/xfs/xfs_error.h > > +++ b/fs/xfs/xfs_error.h > > @@ -45,6 +45,17 @@ extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression, > > const char *file, int line, unsigned int error_tag); > > #define XFS_TEST_ERROR(expr, mp, tag) \ > > ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag))) > > +bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag); > > +#define XFS_ERRORTAG_DELAY(mp, tag) \ > > + do { \ > > + if (!xfs_errortag_enabled((mp), (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) > > Putting a might_sleep() in this macro might be a good idea - that > will catch delays being added inside spin lock contexts... Done. Thanks for the review! --D > Other than that, it looks fine. > > Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx> > > -- > Dave Chinner > david@xxxxxxxxxxxxx