]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: add error injection to test file mapping exchange recovery
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:22:35 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:00:59 +0000 (17:00 -0700)
Source kernel commit: 5fd022ec7d420dfca1eaaf997923a5d4dd0dcf62

Add an errortag so that we can test recovery of exchmaps log items.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
io/inject.c
libxfs/xfs_errortag.h
libxfs/xfs_exchmaps.c

index 6ef1fc8d2f4bc2d657dab19a58d08f88107e22e3..4aeb6da326b4fd166c8276c8a73e612842e52779 100644 (file)
@@ -63,6 +63,7 @@ error_tag(char *name)
                { XFS_ERRTAG_ATTR_LEAF_TO_NODE,         "attr_leaf_to_node" },
                { XFS_ERRTAG_WB_DELAY_MS,               "wb_delay_ms" },
                { XFS_ERRTAG_WRITE_DELAY_MS,            "write_delay_ms" },
+               { XFS_ERRTAG_EXCHMAPS_FINISH_ONE,       "exchmaps_finish_one" },
                { XFS_ERRTAG_MAX,                       NULL }
        };
        int     count;
index 01a9e86b303790f82d7fce5525ef40085a4b2bb2..7002d7676a7884dc185877b7fe7a293f9446a3f4 100644 (file)
@@ -63,7 +63,8 @@
 #define XFS_ERRTAG_ATTR_LEAF_TO_NODE                   41
 #define XFS_ERRTAG_WB_DELAY_MS                         42
 #define XFS_ERRTAG_WRITE_DELAY_MS                      43
-#define XFS_ERRTAG_MAX                                 44
+#define XFS_ERRTAG_EXCHMAPS_FINISH_ONE                 44
+#define XFS_ERRTAG_MAX                                 45
 
 /*
  * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
 #define XFS_RANDOM_ATTR_LEAF_TO_NODE                   1
 #define XFS_RANDOM_WB_DELAY_MS                         3000
 #define XFS_RANDOM_WRITE_DELAY_MS                      3000
+#define XFS_RANDOM_EXCHMAPS_FINISH_ONE                 1
 
 #endif /* __XFS_ERRORTAG_H_ */
index b2c35032d85c12397dd73ffbfa2631eb7df49708..ef30d0b27752b04f48c493918ca1eecf3c447f0c 100644 (file)
@@ -434,6 +434,9 @@ xfs_exchmaps_finish_one(
                        return error;
        }
 
+       if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
+               return -EIO;
+
        /* If we still have work to do, ask for a new transaction. */
        if (xmi_has_more_exchange_work(xmi) || xmi_has_postop_work(xmi)) {
                trace_xfs_exchmaps_defer(tp->t_mountp, xmi);