]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: add error injection for per-AG resv failure
authorGao Xiang <hsiangkao@redhat.com>
Wed, 30 Jun 2021 22:28:38 +0000 (18:28 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 30 Jun 2021 22:28:38 +0000 (18:28 -0400)
Source kernel commit: 2b92faed551173f065ee2a8cf087dc76cf40303b

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>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
io/inject.c
libxfs/xfs_ag_resv.c
libxfs/xfs_errortag.h

index 9a401a1e0096f3b090c29a18731bbf8f04357fad..b8b0977e139e7ae2807ab12c3e4658fa43abd9a8 100644 (file)
@@ -57,6 +57,7 @@ error_tag(char *name)
                { XFS_ERRTAG_BUF_IOERROR,               "buf_ioerror" },
                { XFS_ERRTAG_REDUCE_MAX_IEXTENTS,       "reduce_max_iextents" },
                { XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT,  "bmap_alloc_minlen_extent" },
+               { XFS_ERRTAG_AG_RESV_FAIL,              "ag_resv_fail" },
                { XFS_ERRTAG_MAX,                       NULL }
        };
        int     count;
index 530455a51772d44aac171146138a7100d071f36f..9dc5bf241b428d7de7947f552e0c443af7229cc4 100644 (file)
@@ -210,7 +210,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_);
index 6ca9084b6934effa27a5ad1d7d7ccf42aad42193..a23a52e643ad19a5c665c004b8350385b67ce847 100644 (file)
@@ -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.
 #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_ */