Message ID | 20210302024816.2525095-6-hsiangkao@redhat.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xfs: support shrinking free space in the last AG | expand |
On Tue, Mar 02, 2021 at 10:48:16AM +0800, Gao Xiang wrote: > per-AG resv failure after fixing up freespace is hard to test in an > effective way, so directly add an error injection path to observe > such error handling path works as expected. > > Signed-off-by: Gao Xiang <hsiangkao@redhat.com> > --- > fs/xfs/libxfs/xfs_ag_resv.c | 6 +++++- > fs/xfs/libxfs/xfs_errortag.h | 4 +++- > fs/xfs/xfs_error.c | 2 ++ > 3 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c > index fdfe6dc0d307..6c5f8d10589c 100644 > --- a/fs/xfs/libxfs/xfs_ag_resv.c > +++ b/fs/xfs/libxfs/xfs_ag_resv.c > @@ -211,7 +211,11 @@ __xfs_ag_resv_init( > ASSERT(0); > return -EINVAL; > } > - error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true); > + > + if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL)) > + error = -ENOSPC; > + else > + error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true); > if (error) { > trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno, > error, _RET_IP_); > diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h > index 6ca9084b6934..b433ef735217 100644 > --- a/fs/xfs/libxfs/xfs_errortag.h > +++ b/fs/xfs/libxfs/xfs_errortag.h > @@ -40,6 +40,7 @@ > #define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25 > #define XFS_ERRTAG_BMAP_FINISH_ONE 26 > #define XFS_ERRTAG_AG_RESV_CRITICAL 27 > + Extra space? > /* > * DEBUG mode instrumentation to test and/or trigger delayed allocation > * block killing in the event of failed writes. When enabled, all > @@ -58,7 +59,8 @@ > #define XFS_ERRTAG_BUF_IOERROR 35 > #define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36 > #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37 > -#define XFS_ERRTAG_MAX 38 > +#define XFS_ERRTAG_AG_RESV_FAIL 38 > +#define XFS_ERRTAG_MAX 39 > > /* > * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. This needs to define XFS_RANDOM_AG_RESV_FAIL and put it in xfs_errortag_random_default in xfs_error.c to avoid running off the end of the array. Also... that _default array /really/ needs to have a BUILD_BUG_ON somewhere to scream loudly if it isn't XFS_ERRTAG_MAX elements long. --D > diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c > index 185b4915b7bf..5192a7063d95 100644 > --- a/fs/xfs/xfs_error.c > +++ b/fs/xfs/xfs_error.c > @@ -168,6 +168,7 @@ XFS_ERRORTAG_ATTR_RW(iunlink_fallback, XFS_ERRTAG_IUNLINK_FALLBACK); > XFS_ERRORTAG_ATTR_RW(buf_ioerror, XFS_ERRTAG_BUF_IOERROR); > XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS); > XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT); > +XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); > > static struct attribute *xfs_errortag_attrs[] = { > XFS_ERRORTAG_ATTR_LIST(noerror), > @@ -208,6 +209,7 @@ static struct attribute *xfs_errortag_attrs[] = { > XFS_ERRORTAG_ATTR_LIST(buf_ioerror), > XFS_ERRORTAG_ATTR_LIST(reduce_max_iextents), > XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent), > + XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), > NULL, > }; > > -- > 2.27.0 >
Hi Darrick, On Wed, Mar 03, 2021 at 10:30:42AM -0800, Darrick J. Wong wrote: > On Tue, Mar 02, 2021 at 10:48:16AM +0800, Gao Xiang wrote: > > per-AG resv failure after fixing up freespace is hard to test in an > > effective way, so directly add an error injection path to observe > > such error handling path works as expected. > > > > Signed-off-by: Gao Xiang <hsiangkao@redhat.com> > > --- > > fs/xfs/libxfs/xfs_ag_resv.c | 6 +++++- > > fs/xfs/libxfs/xfs_errortag.h | 4 +++- > > fs/xfs/xfs_error.c | 2 ++ > > 3 files changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c > > index fdfe6dc0d307..6c5f8d10589c 100644 > > --- a/fs/xfs/libxfs/xfs_ag_resv.c > > +++ b/fs/xfs/libxfs/xfs_ag_resv.c > > @@ -211,7 +211,11 @@ __xfs_ag_resv_init( > > ASSERT(0); > > return -EINVAL; > > } > > - error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true); > > + > > + if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL)) > > + error = -ENOSPC; > > + else > > + error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true); > > if (error) { > > trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno, > > error, _RET_IP_); > > diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h > > index 6ca9084b6934..b433ef735217 100644 > > --- a/fs/xfs/libxfs/xfs_errortag.h > > +++ b/fs/xfs/libxfs/xfs_errortag.h > > @@ -40,6 +40,7 @@ > > #define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25 > > #define XFS_ERRTAG_BMAP_FINISH_ONE 26 > > #define XFS_ERRTAG_AG_RESV_CRITICAL 27 > > + > > Extra space? > > > /* > > * DEBUG mode instrumentation to test and/or trigger delayed allocation > > * block killing in the event of failed writes. When enabled, all > > @@ -58,7 +59,8 @@ > > #define XFS_ERRTAG_BUF_IOERROR 35 > > #define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36 > > #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37 > > -#define XFS_ERRTAG_MAX 38 > > +#define XFS_ERRTAG_AG_RESV_FAIL 38 > > +#define XFS_ERRTAG_MAX 39 > > > > /* > > * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. > > This needs to define XFS_RANDOM_AG_RESV_FAIL and put it in > xfs_errortag_random_default in xfs_error.c to avoid running off the end > of the array. > > Also... that _default array /really/ needs to have a BUILD_BUG_ON > somewhere to scream loudly if it isn't XFS_ERRTAG_MAX elements long. I've sent out v7.1 of this patch attached to this version, https://lore.kernel.org/linux-xfs/20210303000202.2671220-1-hsiangkao@redhat.com/ Yes, I received a 0day CI report of this, would you mind take a look at the fix above instead? Thanks, Ga oXiang > > --D > > > diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c > > index 185b4915b7bf..5192a7063d95 100644 > > --- a/fs/xfs/xfs_error.c > > +++ b/fs/xfs/xfs_error.c > > @@ -168,6 +168,7 @@ XFS_ERRORTAG_ATTR_RW(iunlink_fallback, XFS_ERRTAG_IUNLINK_FALLBACK); > > XFS_ERRORTAG_ATTR_RW(buf_ioerror, XFS_ERRTAG_BUF_IOERROR); > > XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS); > > XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT); > > +XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); > > > > static struct attribute *xfs_errortag_attrs[] = { > > XFS_ERRORTAG_ATTR_LIST(noerror), > > @@ -208,6 +209,7 @@ static struct attribute *xfs_errortag_attrs[] = { > > XFS_ERRORTAG_ATTR_LIST(buf_ioerror), > > XFS_ERRORTAG_ATTR_LIST(reduce_max_iextents), > > XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent), > > + XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), > > NULL, > > }; > > > > -- > > 2.27.0 > > >
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c index fdfe6dc0d307..6c5f8d10589c 100644 --- a/fs/xfs/libxfs/xfs_ag_resv.c +++ b/fs/xfs/libxfs/xfs_ag_resv.c @@ -211,7 +211,11 @@ __xfs_ag_resv_init( ASSERT(0); return -EINVAL; } - error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true); + + if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL)) + error = -ENOSPC; + else + error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true); if (error) { trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno, error, _RET_IP_); diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h index 6ca9084b6934..b433ef735217 100644 --- a/fs/xfs/libxfs/xfs_errortag.h +++ b/fs/xfs/libxfs/xfs_errortag.h @@ -40,6 +40,7 @@ #define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25 #define XFS_ERRTAG_BMAP_FINISH_ONE 26 #define XFS_ERRTAG_AG_RESV_CRITICAL 27 + /* * DEBUG mode instrumentation to test and/or trigger delayed allocation * block killing in the event of failed writes. When enabled, all @@ -58,7 +59,8 @@ #define XFS_ERRTAG_BUF_IOERROR 35 #define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36 #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37 -#define XFS_ERRTAG_MAX 38 +#define XFS_ERRTAG_AG_RESV_FAIL 38 +#define XFS_ERRTAG_MAX 39 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 185b4915b7bf..5192a7063d95 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -168,6 +168,7 @@ XFS_ERRORTAG_ATTR_RW(iunlink_fallback, XFS_ERRTAG_IUNLINK_FALLBACK); XFS_ERRORTAG_ATTR_RW(buf_ioerror, XFS_ERRTAG_BUF_IOERROR); XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS); XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT); +XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL); static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(noerror), @@ -208,6 +209,7 @@ static struct attribute *xfs_errortag_attrs[] = { XFS_ERRORTAG_ATTR_LIST(buf_ioerror), XFS_ERRORTAG_ATTR_LIST(reduce_max_iextents), XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent), + XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), NULL, };
per-AG resv failure after fixing up freespace is hard to test in an effective way, so directly add an error injection path to observe such error handling path works as expected. Signed-off-by: Gao Xiang <hsiangkao@redhat.com> --- fs/xfs/libxfs/xfs_ag_resv.c | 6 +++++- fs/xfs/libxfs/xfs_errortag.h | 4 +++- fs/xfs/xfs_error.c | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-)