Skip to content

Commit 41374ae

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: add zone reset error injection
Add a new errortag to test that zone reset errors are handled correctly. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 06873db commit 41374ae

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

fs/xfs/libxfs/xfs_errortag.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
#define XFS_ERRTAG_EXCHMAPS_FINISH_ONE 44
7575
#define XFS_ERRTAG_METAFILE_RESV_CRITICAL 45
7676
#define XFS_ERRTAG_FORCE_ZERO_RANGE 46
77-
#define XFS_ERRTAG_MAX 47
77+
#define XFS_ERRTAG_ZONE_RESET 47
78+
#define XFS_ERRTAG_MAX 48
7879

7980
/*
8081
* 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) \
135136
XFS_ERRTAG(WRITE_DELAY_MS, write_delay_ms, 3000) \
136137
XFS_ERRTAG(EXCHMAPS_FINISH_ONE, exchmaps_finish_one, 1) \
137138
XFS_ERRTAG(METAFILE_RESV_CRITICAL, metafile_resv_crit, 4) \
138-
XFS_ERRTAG(FORCE_ZERO_RANGE, force_zero_range, 4)
139+
XFS_ERRTAG(FORCE_ZERO_RANGE, force_zero_range, 4) \
140+
XFS_ERRTAG(ZONE_RESET, zone_reset, 1)
139141
#endif /* XFS_ERRTAG */
140142

141143
#endif /* __XFS_ERRORTAG_H_ */

fs/xfs/xfs_zone_gc.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "xfs_rmap.h"
1717
#include "xfs_rtbitmap.h"
1818
#include "xfs_rtrmap_btree.h"
19+
#include "xfs_errortag.h"
20+
#include "xfs_error.h"
1921
#include "xfs_zone_alloc.h"
2022
#include "xfs_zone_priv.h"
2123
#include "xfs_zones.h"
@@ -898,9 +900,17 @@ xfs_submit_zone_reset_bio(
898900
struct xfs_rtgroup *rtg,
899901
struct bio *bio)
900902
{
903+
struct xfs_mount *mp = rtg_mount(rtg);
904+
901905
trace_xfs_zone_reset(rtg);
902906

903907
ASSERT(rtg_rmap(rtg)->i_used_blocks == 0);
908+
909+
if (XFS_TEST_ERROR(mp, XFS_ERRTAG_ZONE_RESET)) {
910+
bio_io_error(bio);
911+
return;
912+
}
913+
904914
bio->bi_iter.bi_sector = xfs_gbno_to_daddr(&rtg->rtg_group, 0);
905915
if (!bdev_zone_is_seq(bio->bi_bdev, bio->bi_iter.bi_sector)) {
906916
/*
@@ -913,8 +923,7 @@ xfs_submit_zone_reset_bio(
913923
}
914924
bio->bi_opf &= ~REQ_OP_ZONE_RESET;
915925
bio->bi_opf |= REQ_OP_DISCARD;
916-
bio->bi_iter.bi_size =
917-
XFS_FSB_TO_B(rtg_mount(rtg), rtg_blocks(rtg));
926+
bio->bi_iter.bi_size = XFS_FSB_TO_B(mp, rtg_blocks(rtg));
918927
}
919928

920929
submit_bio(bio);

0 commit comments

Comments
 (0)