]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: add zone reset error injection
authorChristoph Hellwig <hch@lst.de>
Fri, 30 Jan 2026 05:19:24 +0000 (06:19 +0100)
committerCarlos Maiolino <cem@kernel.org>
Fri, 30 Jan 2026 09:41:42 +0000 (10:41 +0100)
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>
fs/xfs/libxfs/xfs_errortag.h
fs/xfs/xfs_zone_gc.c

index b7d98471684bf1d38e94f991b4234017eb968754..6de207fed2d89212f6c86c2043ef49b32fa29f6d 100644 (file)
@@ -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_ */
index 4023448e85d1a64b9e7e5539e3c60bcab2a53dfd..57010218490459d762c2a2d1f2c03f36be122bbc 100644 (file)
@@ -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);