Commit 2b92faed authored by Gao Xiang's avatar Gao Xiang Committed by Darrick J. Wong
Browse files

xfs: add error injection for per-AG resv failure



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: default avatarGao Xiang <hsiangkao@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent fb2fc172
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -211,6 +211,10 @@ __xfs_ag_resv_init(
		ASSERT(0);
		return -EINVAL;
	}

	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,
+3 −1
Original line number Diff line number Diff line
@@ -58,7 +58,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.
@@ -101,5 +102,6 @@
#define XFS_RANDOM_BUF_IOERROR				XFS_RANDOM_DEFAULT
#define XFS_RANDOM_REDUCE_MAX_IEXTENTS			1
#define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT		1
#define XFS_RANDOM_AG_RESV_FAIL				1

#endif /* __XFS_ERRORTAG_H_ */
+3 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ static unsigned int xfs_errortag_random_default[] = {
	XFS_RANDOM_BUF_IOERROR,
	XFS_RANDOM_REDUCE_MAX_IEXTENTS,
	XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT,
	XFS_RANDOM_AG_RESV_FAIL,
};

struct xfs_errortag_attr {
@@ -168,6 +169,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 +210,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,
};