* [PATCH 1/6] xfs: remove xfs_errortag_get
2025-09-15 13:30 cleanup error tags Christoph Hellwig
@ 2025-09-15 13:30 ` Christoph Hellwig
2025-09-15 18:54 ` Darrick J. Wong
2025-09-15 13:30 ` [PATCH 2/6] xfs: remove xfs_errortag_set Christoph Hellwig
` (4 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2025-09-15 13:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
xfs_errortag_get is only called by xfs_errortag_attr_show, which does not
need to validate the error tag, because it can only be called on valid
error tags that had a sysfs attribute registered.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_error.c | 16 ++--------------
fs/xfs/xfs_error.h | 1 -
2 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index dbd87e137694..45a43e47ce92 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -118,10 +118,9 @@ xfs_errortag_attr_show(
char *buf)
{
struct xfs_mount *mp = to_mp(kobject);
- struct xfs_errortag_attr *xfs_attr = to_attr(attr);
+ unsigned int error_tag = to_attr(attr)->tag;
- return snprintf(buf, PAGE_SIZE, "%u\n",
- xfs_errortag_get(mp, xfs_attr->tag));
+ return snprintf(buf, PAGE_SIZE, "%u\n", mp->m_errortag[error_tag]);
}
static const struct sysfs_ops xfs_errortag_sysfs_ops = {
@@ -326,17 +325,6 @@ xfs_errortag_test(
return true;
}
-int
-xfs_errortag_get(
- struct xfs_mount *mp,
- unsigned int error_tag)
-{
- if (!xfs_errortag_valid(error_tag))
- return -EINVAL;
-
- return mp->m_errortag[error_tag];
-}
-
int
xfs_errortag_set(
struct xfs_mount *mp,
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 0b9c5ba8a598..3aeb03001acf 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -58,7 +58,6 @@ bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
mdelay((mp)->m_errortag[(tag)]); \
} while (0)
-extern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag);
extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag,
unsigned int tag_value);
extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 1/6] xfs: remove xfs_errortag_get
2025-09-15 13:30 ` [PATCH 1/6] xfs: remove xfs_errortag_get Christoph Hellwig
@ 2025-09-15 18:54 ` Darrick J. Wong
0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2025-09-15 18:54 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Carlos Maiolino, linux-xfs
On Mon, Sep 15, 2025 at 06:30:37AM -0700, Christoph Hellwig wrote:
> xfs_errortag_get is only called by xfs_errortag_attr_show, which does not
> need to validate the error tag, because it can only be called on valid
> error tags that had a sysfs attribute registered.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Makes sense,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_error.c | 16 ++--------------
> fs/xfs/xfs_error.h | 1 -
> 2 files changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index dbd87e137694..45a43e47ce92 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -118,10 +118,9 @@ xfs_errortag_attr_show(
> char *buf)
> {
> struct xfs_mount *mp = to_mp(kobject);
> - struct xfs_errortag_attr *xfs_attr = to_attr(attr);
> + unsigned int error_tag = to_attr(attr)->tag;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n",
> - xfs_errortag_get(mp, xfs_attr->tag));
> + return snprintf(buf, PAGE_SIZE, "%u\n", mp->m_errortag[error_tag]);
> }
>
> static const struct sysfs_ops xfs_errortag_sysfs_ops = {
> @@ -326,17 +325,6 @@ xfs_errortag_test(
> return true;
> }
>
> -int
> -xfs_errortag_get(
> - struct xfs_mount *mp,
> - unsigned int error_tag)
> -{
> - if (!xfs_errortag_valid(error_tag))
> - return -EINVAL;
> -
> - return mp->m_errortag[error_tag];
> -}
> -
> int
> xfs_errortag_set(
> struct xfs_mount *mp,
> diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> index 0b9c5ba8a598..3aeb03001acf 100644
> --- a/fs/xfs/xfs_error.h
> +++ b/fs/xfs/xfs_error.h
> @@ -58,7 +58,6 @@ bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
> mdelay((mp)->m_errortag[(tag)]); \
> } while (0)
>
> -extern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag);
> extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag,
> unsigned int tag_value);
> extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
> --
> 2.47.2
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/6] xfs: remove xfs_errortag_set
2025-09-15 13:30 cleanup error tags Christoph Hellwig
2025-09-15 13:30 ` [PATCH 1/6] xfs: remove xfs_errortag_get Christoph Hellwig
@ 2025-09-15 13:30 ` Christoph Hellwig
2025-09-15 18:54 ` Darrick J. Wong
2025-09-15 13:30 ` [PATCH 3/6] xfs: remove the expr argument to XFS_TEST_ERROR Christoph Hellwig
` (3 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2025-09-15 13:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
xfs_errortag_set is only called by xfs_errortag_attr_store, , which does
not need to validate the error tag, because it can only be called on
valid error tags that had a sysfs attribute registered.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_error.c | 29 ++++++-----------------------
fs/xfs/xfs_error.h | 3 ---
2 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 45a43e47ce92..fac35ff3da65 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -93,21 +93,18 @@ xfs_errortag_attr_store(
size_t count)
{
struct xfs_mount *mp = to_mp(kobject);
- struct xfs_errortag_attr *xfs_attr = to_attr(attr);
+ unsigned int error_tag = to_attr(attr)->tag;
int ret;
- unsigned int val;
if (strcmp(buf, "default") == 0) {
- val = xfs_errortag_random_default[xfs_attr->tag];
+ mp->m_errortag[error_tag] =
+ xfs_errortag_random_default[error_tag];
} else {
- ret = kstrtouint(buf, 0, &val);
+ ret = kstrtouint(buf, 0, &mp->m_errortag[error_tag]);
if (ret)
return ret;
}
- ret = xfs_errortag_set(mp, xfs_attr->tag, val);
- if (ret)
- return ret;
return count;
}
@@ -325,19 +322,6 @@ xfs_errortag_test(
return true;
}
-int
-xfs_errortag_set(
- struct xfs_mount *mp,
- unsigned int error_tag,
- unsigned int tag_value)
-{
- if (!xfs_errortag_valid(error_tag))
- return -EINVAL;
-
- mp->m_errortag[error_tag] = tag_value;
- return 0;
-}
-
int
xfs_errortag_add(
struct xfs_mount *mp,
@@ -347,9 +331,8 @@ xfs_errortag_add(
if (!xfs_errortag_valid(error_tag))
return -EINVAL;
-
- return xfs_errortag_set(mp, error_tag,
- xfs_errortag_random_default[error_tag]);
+ mp->m_errortag[error_tag] = xfs_errortag_random_default[error_tag];
+ return 0;
}
int
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 3aeb03001acf..fd60a008f9d2 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -58,8 +58,6 @@ bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
mdelay((mp)->m_errortag[(tag)]); \
} while (0)
-extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag,
- unsigned int tag_value);
extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
extern int xfs_errortag_clearall(struct xfs_mount *mp);
#else
@@ -67,7 +65,6 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
#define xfs_errortag_del(mp)
#define XFS_TEST_ERROR(expr, mp, tag) (expr)
#define XFS_ERRORTAG_DELAY(mp, tag) ((void)0)
-#define xfs_errortag_set(mp, tag, val) (ENOSYS)
#define xfs_errortag_add(mp, tag) (ENOSYS)
#define xfs_errortag_clearall(mp) (ENOSYS)
#endif /* DEBUG */
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 2/6] xfs: remove xfs_errortag_set
2025-09-15 13:30 ` [PATCH 2/6] xfs: remove xfs_errortag_set Christoph Hellwig
@ 2025-09-15 18:54 ` Darrick J. Wong
0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2025-09-15 18:54 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Carlos Maiolino, linux-xfs
On Mon, Sep 15, 2025 at 06:30:38AM -0700, Christoph Hellwig wrote:
> xfs_errortag_set is only called by xfs_errortag_attr_store, , which does
> not need to validate the error tag, because it can only be called on
> valid error tags that had a sysfs attribute registered.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Makes sense too
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_error.c | 29 ++++++-----------------------
> fs/xfs/xfs_error.h | 3 ---
> 2 files changed, 6 insertions(+), 26 deletions(-)
>
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index 45a43e47ce92..fac35ff3da65 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -93,21 +93,18 @@ xfs_errortag_attr_store(
> size_t count)
> {
> struct xfs_mount *mp = to_mp(kobject);
> - struct xfs_errortag_attr *xfs_attr = to_attr(attr);
> + unsigned int error_tag = to_attr(attr)->tag;
> int ret;
> - unsigned int val;
>
> if (strcmp(buf, "default") == 0) {
> - val = xfs_errortag_random_default[xfs_attr->tag];
> + mp->m_errortag[error_tag] =
> + xfs_errortag_random_default[error_tag];
> } else {
> - ret = kstrtouint(buf, 0, &val);
> + ret = kstrtouint(buf, 0, &mp->m_errortag[error_tag]);
> if (ret)
> return ret;
> }
>
> - ret = xfs_errortag_set(mp, xfs_attr->tag, val);
> - if (ret)
> - return ret;
> return count;
> }
>
> @@ -325,19 +322,6 @@ xfs_errortag_test(
> return true;
> }
>
> -int
> -xfs_errortag_set(
> - struct xfs_mount *mp,
> - unsigned int error_tag,
> - unsigned int tag_value)
> -{
> - if (!xfs_errortag_valid(error_tag))
> - return -EINVAL;
> -
> - mp->m_errortag[error_tag] = tag_value;
> - return 0;
> -}
> -
> int
> xfs_errortag_add(
> struct xfs_mount *mp,
> @@ -347,9 +331,8 @@ xfs_errortag_add(
>
> if (!xfs_errortag_valid(error_tag))
> return -EINVAL;
> -
> - return xfs_errortag_set(mp, error_tag,
> - xfs_errortag_random_default[error_tag]);
> + mp->m_errortag[error_tag] = xfs_errortag_random_default[error_tag];
> + return 0;
> }
>
> int
> diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> index 3aeb03001acf..fd60a008f9d2 100644
> --- a/fs/xfs/xfs_error.h
> +++ b/fs/xfs/xfs_error.h
> @@ -58,8 +58,6 @@ bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
> mdelay((mp)->m_errortag[(tag)]); \
> } while (0)
>
> -extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag,
> - unsigned int tag_value);
> extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
> extern int xfs_errortag_clearall(struct xfs_mount *mp);
> #else
> @@ -67,7 +65,6 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
> #define xfs_errortag_del(mp)
> #define XFS_TEST_ERROR(expr, mp, tag) (expr)
> #define XFS_ERRORTAG_DELAY(mp, tag) ((void)0)
> -#define xfs_errortag_set(mp, tag, val) (ENOSYS)
> #define xfs_errortag_add(mp, tag) (ENOSYS)
> #define xfs_errortag_clearall(mp) (ENOSYS)
> #endif /* DEBUG */
> --
> 2.47.2
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/6] xfs: remove the expr argument to XFS_TEST_ERROR
2025-09-15 13:30 cleanup error tags Christoph Hellwig
2025-09-15 13:30 ` [PATCH 1/6] xfs: remove xfs_errortag_get Christoph Hellwig
2025-09-15 13:30 ` [PATCH 2/6] xfs: remove xfs_errortag_set Christoph Hellwig
@ 2025-09-15 13:30 ` Christoph Hellwig
2025-09-15 18:55 ` Darrick J. Wong
2025-09-15 13:30 ` [PATCH 4/6] xfs: remove pointless externs in xfs_error.h Christoph Hellwig
` (2 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2025-09-15 13:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Don't pass expr to XFS_TEST_ERROR. Most calls pass a constant false,
and the places that do pass an expression become cleaner by moving it
out.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_ag_resv.c | 7 +++----
fs/xfs/libxfs/xfs_alloc.c | 5 ++---
fs/xfs/libxfs/xfs_attr_leaf.c | 2 +-
fs/xfs/libxfs/xfs_bmap.c | 17 ++++++++---------
fs/xfs/libxfs/xfs_btree.c | 2 +-
fs/xfs/libxfs/xfs_da_btree.c | 2 +-
fs/xfs/libxfs/xfs_dir2.c | 2 +-
fs/xfs/libxfs/xfs_exchmaps.c | 4 ++--
fs/xfs/libxfs/xfs_ialloc.c | 2 +-
fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
fs/xfs/libxfs/xfs_inode_fork.c | 3 +--
fs/xfs/libxfs/xfs_metafile.c | 2 +-
fs/xfs/libxfs/xfs_refcount.c | 7 +++----
fs/xfs/libxfs/xfs_rmap.c | 2 +-
fs/xfs/libxfs/xfs_rtbitmap.c | 2 +-
fs/xfs/scrub/cow_repair.c | 4 ++--
fs/xfs/scrub/repair.c | 2 +-
fs/xfs/xfs_attr_item.c | 2 +-
fs/xfs/xfs_buf.c | 4 ++--
fs/xfs/xfs_error.c | 5 ++---
fs/xfs/xfs_error.h | 10 +++++-----
fs/xfs/xfs_inode.c | 28 +++++++++++++---------------
fs/xfs/xfs_iomap.c | 4 ++--
fs/xfs/xfs_log.c | 8 ++++----
fs/xfs/xfs_trans_ail.c | 2 +-
25 files changed, 62 insertions(+), 70 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index fb79215a509d..8ac8230c3d3c 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -92,9 +92,8 @@ xfs_ag_resv_critical(
trace_xfs_ag_resv_critical(pag, type, avail);
/* Critically low if less than 10% or max btree height remains. */
- return XFS_TEST_ERROR(avail < orig / 10 ||
- avail < mp->m_agbtree_maxlevels,
- mp, XFS_ERRTAG_AG_RESV_CRITICAL);
+ return avail < orig / 10 || avail < mp->m_agbtree_maxlevels ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_AG_RESV_CRITICAL);
}
/*
@@ -203,7 +202,7 @@ __xfs_ag_resv_init(
return -EINVAL;
}
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_AG_RESV_FAIL))
error = -ENOSPC;
else
error = xfs_dec_fdblocks(mp, hidden_space, true);
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 000cc7f4a3ce..ad381c73abc4 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -3321,7 +3321,7 @@ xfs_agf_read_verify(
xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else {
fa = xfs_agf_verify(bp);
- if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
+ if (fa || XFS_TEST_ERROR(mp, XFS_ERRTAG_ALLOC_READ_AGF))
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
}
@@ -4019,8 +4019,7 @@ __xfs_free_extent(
ASSERT(len != 0);
ASSERT(type != XFS_AG_RESV_AGFL);
- if (XFS_TEST_ERROR(false, mp,
- XFS_ERRTAG_FREE_EXTENT))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_FREE_EXTENT))
return -EIO;
error = xfs_free_extent_fix_freelist(tp, pag, &agbp);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index fddb55605e0c..8508c845b27e 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -1225,7 +1225,7 @@ xfs_attr3_leaf_to_node(
trace_xfs_attr_leaf_to_node(args);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
error = -EIO;
goto out;
}
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index d954f9b8071f..17edc24d4bb0 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3662,8 +3662,7 @@ xfs_bmap_btalloc(
/* Trim the allocation back to the maximum an AG can fit. */
args.maxlen = min(ap->length, mp->m_ag_max_usable);
- if (unlikely(XFS_TEST_ERROR(false, mp,
- XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
+ if (unlikely(XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
error = xfs_bmap_exact_minlen_extent_alloc(ap, &args);
else if ((ap->datatype & XFS_ALLOC_USERDATA) &&
xfs_inode_is_filestream(ap->ip))
@@ -3849,7 +3848,7 @@ xfs_bmapi_read(
}
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -4200,7 +4199,7 @@ xfs_bmapi_write(
(XFS_BMAPI_PREALLOC | XFS_BMAPI_ZERO));
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -4545,7 +4544,7 @@ xfs_bmapi_remap(
(XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC));
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5679,7 +5678,7 @@ xfs_bmap_collapse_extents(
int logflags = 0;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5795,7 +5794,7 @@ xfs_bmap_insert_extents(
int logflags = 0;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5900,7 +5899,7 @@ xfs_bmap_split_extent(
int i = 0;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -6065,7 +6064,7 @@ xfs_bmap_finish_one(
trace_xfs_bmap_deferred(bi);
- if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE))
+ if (XFS_TEST_ERROR(tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE))
return -EIO;
switch (bi->bi_type) {
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index a61211d253f1..dbe9df8c3300 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -306,7 +306,7 @@ xfs_btree_check_block(
fa = __xfs_btree_check_block(cur, block, level, bp);
if (XFS_IS_CORRUPT(mp, fa != NULL) ||
- XFS_TEST_ERROR(false, mp, xfs_btree_block_errtag(cur))) {
+ XFS_TEST_ERROR(mp, xfs_btree_block_errtag(cur))) {
if (bp)
trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_btree_mark_sick(cur);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 723a0643b838..90f7fc219fcc 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -565,7 +565,7 @@ xfs_da3_split(
trace_xfs_da_split(state->args);
- if (XFS_TEST_ERROR(false, state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
+ if (XFS_TEST_ERROR(state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
return -EIO;
/*
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 1775abcfa04d..82a338458a51 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -223,7 +223,7 @@ xfs_dir_ino_validate(
bool ino_ok = xfs_verify_dir_ino(mp, ino);
if (XFS_IS_CORRUPT(mp, !ino_ok) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_DIR_INO_VALIDATE)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_DIR_INO_VALIDATE)) {
xfs_warn(mp, "Invalid inode number 0x%Lx",
(unsigned long long) ino);
return -EFSCORRUPTED;
diff --git a/fs/xfs/libxfs/xfs_exchmaps.c b/fs/xfs/libxfs/xfs_exchmaps.c
index 3f1d6a98c118..932ee4619e9e 100644
--- a/fs/xfs/libxfs/xfs_exchmaps.c
+++ b/fs/xfs/libxfs/xfs_exchmaps.c
@@ -616,7 +616,7 @@ xfs_exchmaps_finish_one(
return error;
}
- if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
+ if (XFS_TEST_ERROR(tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
return -EIO;
/* If we still have work to do, ask for a new transaction. */
@@ -882,7 +882,7 @@ xmi_ensure_delta_nextents(
&new_nextents))
return -EFBIG;
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
new_nextents > 10)
return -EFBIG;
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 750111634d9f..ca57a4e5ced9 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2706,7 +2706,7 @@ xfs_agi_read_verify(
xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else {
fa = xfs_agi_verify(bp);
- if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
+ if (fa || XFS_TEST_ERROR(mp, XFS_ERRTAG_IALLOC_READ_AGI))
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
}
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index aa13fc00afd7..b1812b2c3cce 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -61,8 +61,8 @@ xfs_inode_buf_verify(
di_ok = xfs_verify_magic16(bp, dip->di_magic) &&
xfs_dinode_good_version(mp, dip->di_version) &&
xfs_verify_agino_or_null(bp->b_pag, unlinked_ino);
- if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
- XFS_ERRTAG_ITOBP_INOTOBP))) {
+ if (unlikely(!di_ok ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_ITOBP_INOTOBP))) {
if (readahead) {
bp->b_flags &= ~XBF_DONE;
xfs_buf_ioerror(bp, -EIO);
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 4f99b90add55..1772d82f2d68 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -756,8 +756,7 @@ xfs_iext_count_extend(
if (nr_exts < ifp->if_nextents)
return -EFBIG;
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
- nr_exts > 10)
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) && nr_exts > 10)
return -EFBIG;
if (nr_exts > xfs_iext_max_nextents(has_large, whichfork)) {
diff --git a/fs/xfs/libxfs/xfs_metafile.c b/fs/xfs/libxfs/xfs_metafile.c
index 225923e463c4..b02e3d6c0868 100644
--- a/fs/xfs/libxfs/xfs_metafile.c
+++ b/fs/xfs/libxfs/xfs_metafile.c
@@ -121,7 +121,7 @@ xfs_metafile_resv_critical(
div_u64(mp->m_metafile_resv_target, 10)))
return true;
- return XFS_TEST_ERROR(false, mp, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
+ return XFS_TEST_ERROR(mp, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
}
/* Allocate a block from the metadata file's reservation. */
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 897784037483..2484dc9f6d7e 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1113,8 +1113,7 @@ xfs_refcount_still_have_space(
* refcount continue update "error" has been injected.
*/
if (cur->bc_refc.nr_ops > 2 &&
- XFS_TEST_ERROR(false, cur->bc_mp,
- XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE))
+ XFS_TEST_ERROR(cur->bc_mp, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE))
return false;
if (cur->bc_refc.nr_ops == 0)
@@ -1398,7 +1397,7 @@ xfs_refcount_finish_one(
trace_xfs_refcount_deferred(mp, ri);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
return -EIO;
/*
@@ -1511,7 +1510,7 @@ xfs_rtrefcount_finish_one(
trace_xfs_refcount_deferred(mp, ri);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
return -EIO;
/*
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index 3cdf50563fec..83e0488ff773 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -2690,7 +2690,7 @@ xfs_rmap_finish_one(
trace_xfs_rmap_deferred(mp, ri);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_RMAP_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_RMAP_FINISH_ONE))
return -EIO;
/*
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 5057536e586c..618061d898d4 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -1067,7 +1067,7 @@ xfs_rtfree_extent(
ASSERT(rbmip->i_itemp != NULL);
xfs_assert_ilocked(rbmip, XFS_ILOCK_EXCL);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_FREE_EXTENT))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_FREE_EXTENT))
return -EIO;
error = xfs_rtcheck_alloc_range(&args, start, len);
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index 38a246b8bf11..b2a83801412e 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -300,7 +300,7 @@ xrep_cow_find_bad(
* on the debugging knob, replace everything in the CoW fork.
*/
if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
- XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
+ XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
if (error)
@@ -385,7 +385,7 @@ xrep_cow_find_bad_rt(
* CoW fork and then scan for staging extents in the refcountbt.
*/
if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
- XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
+ XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
if (error)
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index d00c18954a26..efd5a7ccdf62 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -1110,7 +1110,7 @@ xrep_will_attempt(
return true;
/* Let debug users force us into the repair routines. */
- if (XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
+ if (XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
return true;
/* Metadata is corrupt or failed cross-referencing. */
diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
index 5eef3bc30bda..c3a593319bee 100644
--- a/fs/xfs/xfs_attr_item.c
+++ b/fs/xfs/xfs_attr_item.c
@@ -491,7 +491,7 @@ xfs_attr_finish_item(
/* Reset trans after EAGAIN cycle since the transaction is new */
args->trans = tp;
- if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) {
+ if (XFS_TEST_ERROR(args->dp->i_mount, XFS_ERRTAG_LARP)) {
error = -EIO;
goto out;
}
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index f9ef3b2a332a..8360e77b3215 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1299,7 +1299,7 @@ xfs_buf_bio_end_io(
if (bio->bi_status)
xfs_buf_ioerror(bp, blk_status_to_errno(bio->bi_status));
else if ((bp->b_flags & XBF_WRITE) && (bp->b_flags & XBF_ASYNC) &&
- XFS_TEST_ERROR(false, bp->b_mount, XFS_ERRTAG_BUF_IOERROR))
+ XFS_TEST_ERROR(bp->b_mount, XFS_ERRTAG_BUF_IOERROR))
xfs_buf_ioerror(bp, -EIO);
if (bp->b_flags & XBF_ASYNC) {
@@ -2084,7 +2084,7 @@ void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
* This allows userspace to disrupt buffer caching for debug/testing
* purposes.
*/
- if (XFS_TEST_ERROR(false, bp->b_mount, XFS_ERRTAG_BUF_LRU_REF))
+ if (XFS_TEST_ERROR(bp->b_mount, XFS_ERRTAG_BUF_LRU_REF))
lru_ref = 0;
atomic_set(&bp->b_lru_ref, lru_ref);
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index fac35ff3da65..44dd8aba0097 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -291,7 +291,6 @@ xfs_errortag_enabled(
bool
xfs_errortag_test(
struct xfs_mount *mp,
- const char *expression,
const char *file,
int line,
unsigned int error_tag)
@@ -317,8 +316,8 @@ xfs_errortag_test(
return false;
xfs_warn_ratelimited(mp,
-"Injecting error (%s) at file %s, line %d, on filesystem \"%s\"",
- expression, file, line, mp->m_super->s_id);
+"Injecting error at file %s, line %d, on filesystem \"%s\"",
+ file, line, mp->m_super->s_id);
return true;
}
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index fd60a008f9d2..8429c1ee86e7 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -41,10 +41,10 @@ extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
#ifdef DEBUG
extern int xfs_errortag_init(struct xfs_mount *mp);
extern void xfs_errortag_del(struct xfs_mount *mp);
-extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression,
- const char *file, int line, unsigned int error_tag);
-#define XFS_TEST_ERROR(expr, mp, tag) \
- ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag)))
+bool xfs_errortag_test(struct xfs_mount *mp, const char *file, int line,
+ unsigned int error_tag);
+#define XFS_TEST_ERROR(mp, tag) \
+ xfs_errortag_test((mp), __FILE__, __LINE__, (tag))
bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
#define XFS_ERRORTAG_DELAY(mp, tag) \
do { \
@@ -63,7 +63,7 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
#else
#define xfs_errortag_init(mp) (0)
#define xfs_errortag_del(mp)
-#define XFS_TEST_ERROR(expr, mp, tag) (expr)
+#define XFS_TEST_ERROR(mp, tag) (false)
#define XFS_ERRORTAG_DELAY(mp, tag) ((void)0)
#define xfs_errortag_add(mp, tag) (ENOSYS)
#define xfs_errortag_clearall(mp) (ENOSYS)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 9c39251961a3..5940faefe522 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2377,8 +2377,8 @@ xfs_iflush(
* error handling as the caller will shutdown and fail the buffer.
*/
error = -EFSCORRUPTED;
- if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC),
- mp, XFS_ERRTAG_IFLUSH_1)) {
+ if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC) ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_1)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad inode %llu magic number 0x%x, ptr "PTR_FMT,
__func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip);
@@ -2394,29 +2394,27 @@ xfs_iflush(
goto flush_out;
}
} else if (S_ISREG(VFS_I(ip)->i_mode)) {
- if (XFS_TEST_ERROR(
- ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
- ip->i_df.if_format != XFS_DINODE_FMT_BTREE,
- mp, XFS_ERRTAG_IFLUSH_3)) {
+ if ((ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
+ ip->i_df.if_format != XFS_DINODE_FMT_BTREE) ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_3)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad regular inode %llu, ptr "PTR_FMT,
__func__, ip->i_ino, ip);
goto flush_out;
}
} else if (S_ISDIR(VFS_I(ip)->i_mode)) {
- if (XFS_TEST_ERROR(
- ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
- ip->i_df.if_format != XFS_DINODE_FMT_BTREE &&
- ip->i_df.if_format != XFS_DINODE_FMT_LOCAL,
- mp, XFS_ERRTAG_IFLUSH_4)) {
+ if ((ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
+ ip->i_df.if_format != XFS_DINODE_FMT_BTREE &&
+ ip->i_df.if_format != XFS_DINODE_FMT_LOCAL) ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_4)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad directory inode %llu, ptr "PTR_FMT,
__func__, ip->i_ino, ip);
goto flush_out;
}
}
- if (XFS_TEST_ERROR(ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af) >
- ip->i_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
+ if (ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af) >
+ ip->i_nblocks || XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_5)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: detected corrupt incore inode %llu, "
"total extents = %llu nblocks = %lld, ptr "PTR_FMT,
@@ -2425,8 +2423,8 @@ xfs_iflush(
ip->i_nblocks, ip);
goto flush_out;
}
- if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize,
- mp, XFS_ERRTAG_IFLUSH_6)) {
+ if (ip->i_forkoff > mp->m_sb.sb_inodesize ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_6)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: bad inode %llu, forkoff 0x%x, ptr "PTR_FMT,
__func__, ip->i_ino, ip->i_forkoff, ip);
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 2a74f2957341..2570d0a66047 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1554,7 +1554,7 @@ xfs_zoned_buffered_write_iomap_begin(
return error;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, XFS_DATA_FORK);
error = -EFSCORRUPTED;
goto out_unlock;
@@ -1728,7 +1728,7 @@ xfs_buffered_write_iomap_begin(
return error;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, XFS_DATA_FORK);
error = -EFSCORRUPTED;
goto out_unlock;
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index c8a57e21a1d3..6e6442b0543c 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -969,8 +969,8 @@ xfs_log_unmount_write(
* counters will be recalculated. Refer to xlog_check_unmount_rec for
* more details.
*/
- if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
- XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
+ if (xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS) ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
xfs_alert(mp, "%s: will fix summary counters at next mount",
__func__);
return;
@@ -1240,7 +1240,7 @@ xlog_ioend_work(
/*
* Race to shutdown the filesystem if we see an error.
*/
- if (XFS_TEST_ERROR(error, log->l_mp, XFS_ERRTAG_IODONE_IOERR)) {
+ if (error || XFS_TEST_ERROR(log->l_mp, XFS_ERRTAG_IODONE_IOERR)) {
xfs_alert(log->l_mp, "log I/O error %d", error);
xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR);
}
@@ -1827,7 +1827,7 @@ xlog_sync(
* detects the bad CRC and attempts to recover.
*/
#ifdef DEBUG
- if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) {
+ if (XFS_TEST_ERROR(log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) {
iclog->ic_header.h_crc &= cpu_to_le32(0xAAAAAAAA);
iclog->ic_fail_crc = true;
xfs_warn(log->l_mp,
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 67c328d23e4a..38983c6777df 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -374,7 +374,7 @@ xfsaild_push_item(
* If log item pinning is enabled, skip the push and track the item as
* pinned. This can help induce head-behind-tail conditions.
*/
- if (XFS_TEST_ERROR(false, ailp->ail_log->l_mp, XFS_ERRTAG_LOG_ITEM_PIN))
+ if (XFS_TEST_ERROR(ailp->ail_log->l_mp, XFS_ERRTAG_LOG_ITEM_PIN))
return XFS_ITEM_PINNED;
/*
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 3/6] xfs: remove the expr argument to XFS_TEST_ERROR
2025-09-15 13:30 ` [PATCH 3/6] xfs: remove the expr argument to XFS_TEST_ERROR Christoph Hellwig
@ 2025-09-15 18:55 ` Darrick J. Wong
0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2025-09-15 18:55 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Carlos Maiolino, linux-xfs
On Mon, Sep 15, 2025 at 06:30:39AM -0700, Christoph Hellwig wrote:
> Don't pass expr to XFS_TEST_ERROR. Most calls pass a constant false,
> and the places that do pass an expression become cleaner by moving it
> out.
Yeah, that expr argument has always struck me as kind of pointless.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/libxfs/xfs_ag_resv.c | 7 +++----
> fs/xfs/libxfs/xfs_alloc.c | 5 ++---
> fs/xfs/libxfs/xfs_attr_leaf.c | 2 +-
> fs/xfs/libxfs/xfs_bmap.c | 17 ++++++++---------
> fs/xfs/libxfs/xfs_btree.c | 2 +-
> fs/xfs/libxfs/xfs_da_btree.c | 2 +-
> fs/xfs/libxfs/xfs_dir2.c | 2 +-
> fs/xfs/libxfs/xfs_exchmaps.c | 4 ++--
> fs/xfs/libxfs/xfs_ialloc.c | 2 +-
> fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
> fs/xfs/libxfs/xfs_inode_fork.c | 3 +--
> fs/xfs/libxfs/xfs_metafile.c | 2 +-
> fs/xfs/libxfs/xfs_refcount.c | 7 +++----
> fs/xfs/libxfs/xfs_rmap.c | 2 +-
> fs/xfs/libxfs/xfs_rtbitmap.c | 2 +-
> fs/xfs/scrub/cow_repair.c | 4 ++--
> fs/xfs/scrub/repair.c | 2 +-
> fs/xfs/xfs_attr_item.c | 2 +-
> fs/xfs/xfs_buf.c | 4 ++--
> fs/xfs/xfs_error.c | 5 ++---
> fs/xfs/xfs_error.h | 10 +++++-----
> fs/xfs/xfs_inode.c | 28 +++++++++++++---------------
> fs/xfs/xfs_iomap.c | 4 ++--
> fs/xfs/xfs_log.c | 8 ++++----
> fs/xfs/xfs_trans_ail.c | 2 +-
> 25 files changed, 62 insertions(+), 70 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
> index fb79215a509d..8ac8230c3d3c 100644
> --- a/fs/xfs/libxfs/xfs_ag_resv.c
> +++ b/fs/xfs/libxfs/xfs_ag_resv.c
> @@ -92,9 +92,8 @@ xfs_ag_resv_critical(
> trace_xfs_ag_resv_critical(pag, type, avail);
>
> /* Critically low if less than 10% or max btree height remains. */
> - return XFS_TEST_ERROR(avail < orig / 10 ||
> - avail < mp->m_agbtree_maxlevels,
> - mp, XFS_ERRTAG_AG_RESV_CRITICAL);
> + return avail < orig / 10 || avail < mp->m_agbtree_maxlevels ||
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_AG_RESV_CRITICAL);
> }
>
> /*
> @@ -203,7 +202,7 @@ __xfs_ag_resv_init(
> return -EINVAL;
> }
>
> - if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL))
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_AG_RESV_FAIL))
> error = -ENOSPC;
> else
> error = xfs_dec_fdblocks(mp, hidden_space, true);
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index 000cc7f4a3ce..ad381c73abc4 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -3321,7 +3321,7 @@ xfs_agf_read_verify(
> xfs_verifier_error(bp, -EFSBADCRC, __this_address);
> else {
> fa = xfs_agf_verify(bp);
> - if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
> + if (fa || XFS_TEST_ERROR(mp, XFS_ERRTAG_ALLOC_READ_AGF))
> xfs_verifier_error(bp, -EFSCORRUPTED, fa);
> }
> }
> @@ -4019,8 +4019,7 @@ __xfs_free_extent(
> ASSERT(len != 0);
> ASSERT(type != XFS_AG_RESV_AGFL);
>
> - if (XFS_TEST_ERROR(false, mp,
> - XFS_ERRTAG_FREE_EXTENT))
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_FREE_EXTENT))
> return -EIO;
>
> error = xfs_free_extent_fix_freelist(tp, pag, &agbp);
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index fddb55605e0c..8508c845b27e 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -1225,7 +1225,7 @@ xfs_attr3_leaf_to_node(
>
> trace_xfs_attr_leaf_to_node(args);
>
> - if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
> error = -EIO;
> goto out;
> }
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index d954f9b8071f..17edc24d4bb0 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -3662,8 +3662,7 @@ xfs_bmap_btalloc(
> /* Trim the allocation back to the maximum an AG can fit. */
> args.maxlen = min(ap->length, mp->m_ag_max_usable);
>
> - if (unlikely(XFS_TEST_ERROR(false, mp,
> - XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
> + if (unlikely(XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
> error = xfs_bmap_exact_minlen_extent_alloc(ap, &args);
> else if ((ap->datatype & XFS_ALLOC_USERDATA) &&
> xfs_inode_is_filestream(ap->ip))
> @@ -3849,7 +3848,7 @@ xfs_bmapi_read(
> }
>
> if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
> xfs_bmap_mark_sick(ip, whichfork);
> return -EFSCORRUPTED;
> }
> @@ -4200,7 +4199,7 @@ xfs_bmapi_write(
> (XFS_BMAPI_PREALLOC | XFS_BMAPI_ZERO));
>
> if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
> xfs_bmap_mark_sick(ip, whichfork);
> return -EFSCORRUPTED;
> }
> @@ -4545,7 +4544,7 @@ xfs_bmapi_remap(
> (XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC));
>
> if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
> xfs_bmap_mark_sick(ip, whichfork);
> return -EFSCORRUPTED;
> }
> @@ -5679,7 +5678,7 @@ xfs_bmap_collapse_extents(
> int logflags = 0;
>
> if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
> xfs_bmap_mark_sick(ip, whichfork);
> return -EFSCORRUPTED;
> }
> @@ -5795,7 +5794,7 @@ xfs_bmap_insert_extents(
> int logflags = 0;
>
> if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
> xfs_bmap_mark_sick(ip, whichfork);
> return -EFSCORRUPTED;
> }
> @@ -5900,7 +5899,7 @@ xfs_bmap_split_extent(
> int i = 0;
>
> if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
> xfs_bmap_mark_sick(ip, whichfork);
> return -EFSCORRUPTED;
> }
> @@ -6065,7 +6064,7 @@ xfs_bmap_finish_one(
>
> trace_xfs_bmap_deferred(bi);
>
> - if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE))
> + if (XFS_TEST_ERROR(tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE))
> return -EIO;
>
> switch (bi->bi_type) {
> diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
> index a61211d253f1..dbe9df8c3300 100644
> --- a/fs/xfs/libxfs/xfs_btree.c
> +++ b/fs/xfs/libxfs/xfs_btree.c
> @@ -306,7 +306,7 @@ xfs_btree_check_block(
>
> fa = __xfs_btree_check_block(cur, block, level, bp);
> if (XFS_IS_CORRUPT(mp, fa != NULL) ||
> - XFS_TEST_ERROR(false, mp, xfs_btree_block_errtag(cur))) {
> + XFS_TEST_ERROR(mp, xfs_btree_block_errtag(cur))) {
> if (bp)
> trace_xfs_btree_corrupt(bp, _RET_IP_);
> xfs_btree_mark_sick(cur);
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 723a0643b838..90f7fc219fcc 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -565,7 +565,7 @@ xfs_da3_split(
>
> trace_xfs_da_split(state->args);
>
> - if (XFS_TEST_ERROR(false, state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
> + if (XFS_TEST_ERROR(state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
> return -EIO;
>
> /*
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 1775abcfa04d..82a338458a51 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -223,7 +223,7 @@ xfs_dir_ino_validate(
> bool ino_ok = xfs_verify_dir_ino(mp, ino);
>
> if (XFS_IS_CORRUPT(mp, !ino_ok) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_DIR_INO_VALIDATE)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_DIR_INO_VALIDATE)) {
> xfs_warn(mp, "Invalid inode number 0x%Lx",
> (unsigned long long) ino);
> return -EFSCORRUPTED;
> diff --git a/fs/xfs/libxfs/xfs_exchmaps.c b/fs/xfs/libxfs/xfs_exchmaps.c
> index 3f1d6a98c118..932ee4619e9e 100644
> --- a/fs/xfs/libxfs/xfs_exchmaps.c
> +++ b/fs/xfs/libxfs/xfs_exchmaps.c
> @@ -616,7 +616,7 @@ xfs_exchmaps_finish_one(
> return error;
> }
>
> - if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
> + if (XFS_TEST_ERROR(tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
> return -EIO;
>
> /* If we still have work to do, ask for a new transaction. */
> @@ -882,7 +882,7 @@ xmi_ensure_delta_nextents(
> &new_nextents))
> return -EFBIG;
>
> - if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
> new_nextents > 10)
> return -EFBIG;
>
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index 750111634d9f..ca57a4e5ced9 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -2706,7 +2706,7 @@ xfs_agi_read_verify(
> xfs_verifier_error(bp, -EFSBADCRC, __this_address);
> else {
> fa = xfs_agi_verify(bp);
> - if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
> + if (fa || XFS_TEST_ERROR(mp, XFS_ERRTAG_IALLOC_READ_AGI))
> xfs_verifier_error(bp, -EFSCORRUPTED, fa);
> }
> }
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index aa13fc00afd7..b1812b2c3cce 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -61,8 +61,8 @@ xfs_inode_buf_verify(
> di_ok = xfs_verify_magic16(bp, dip->di_magic) &&
> xfs_dinode_good_version(mp, dip->di_version) &&
> xfs_verify_agino_or_null(bp->b_pag, unlinked_ino);
> - if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
> - XFS_ERRTAG_ITOBP_INOTOBP))) {
> + if (unlikely(!di_ok ||
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_ITOBP_INOTOBP))) {
> if (readahead) {
> bp->b_flags &= ~XBF_DONE;
> xfs_buf_ioerror(bp, -EIO);
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index 4f99b90add55..1772d82f2d68 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -756,8 +756,7 @@ xfs_iext_count_extend(
> if (nr_exts < ifp->if_nextents)
> return -EFBIG;
>
> - if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
> - nr_exts > 10)
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) && nr_exts > 10)
> return -EFBIG;
>
> if (nr_exts > xfs_iext_max_nextents(has_large, whichfork)) {
> diff --git a/fs/xfs/libxfs/xfs_metafile.c b/fs/xfs/libxfs/xfs_metafile.c
> index 225923e463c4..b02e3d6c0868 100644
> --- a/fs/xfs/libxfs/xfs_metafile.c
> +++ b/fs/xfs/libxfs/xfs_metafile.c
> @@ -121,7 +121,7 @@ xfs_metafile_resv_critical(
> div_u64(mp->m_metafile_resv_target, 10)))
> return true;
>
> - return XFS_TEST_ERROR(false, mp, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
> + return XFS_TEST_ERROR(mp, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
> }
>
> /* Allocate a block from the metadata file's reservation. */
> diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
> index 897784037483..2484dc9f6d7e 100644
> --- a/fs/xfs/libxfs/xfs_refcount.c
> +++ b/fs/xfs/libxfs/xfs_refcount.c
> @@ -1113,8 +1113,7 @@ xfs_refcount_still_have_space(
> * refcount continue update "error" has been injected.
> */
> if (cur->bc_refc.nr_ops > 2 &&
> - XFS_TEST_ERROR(false, cur->bc_mp,
> - XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE))
> + XFS_TEST_ERROR(cur->bc_mp, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE))
> return false;
>
> if (cur->bc_refc.nr_ops == 0)
> @@ -1398,7 +1397,7 @@ xfs_refcount_finish_one(
>
> trace_xfs_refcount_deferred(mp, ri);
>
> - if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
> return -EIO;
>
> /*
> @@ -1511,7 +1510,7 @@ xfs_rtrefcount_finish_one(
>
> trace_xfs_refcount_deferred(mp, ri);
>
> - if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
> return -EIO;
>
> /*
> diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
> index 3cdf50563fec..83e0488ff773 100644
> --- a/fs/xfs/libxfs/xfs_rmap.c
> +++ b/fs/xfs/libxfs/xfs_rmap.c
> @@ -2690,7 +2690,7 @@ xfs_rmap_finish_one(
>
> trace_xfs_rmap_deferred(mp, ri);
>
> - if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_RMAP_FINISH_ONE))
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_RMAP_FINISH_ONE))
> return -EIO;
>
> /*
> diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
> index 5057536e586c..618061d898d4 100644
> --- a/fs/xfs/libxfs/xfs_rtbitmap.c
> +++ b/fs/xfs/libxfs/xfs_rtbitmap.c
> @@ -1067,7 +1067,7 @@ xfs_rtfree_extent(
> ASSERT(rbmip->i_itemp != NULL);
> xfs_assert_ilocked(rbmip, XFS_ILOCK_EXCL);
>
> - if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_FREE_EXTENT))
> + if (XFS_TEST_ERROR(mp, XFS_ERRTAG_FREE_EXTENT))
> return -EIO;
>
> error = xfs_rtcheck_alloc_range(&args, start, len);
> diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
> index 38a246b8bf11..b2a83801412e 100644
> --- a/fs/xfs/scrub/cow_repair.c
> +++ b/fs/xfs/scrub/cow_repair.c
> @@ -300,7 +300,7 @@ xrep_cow_find_bad(
> * on the debugging knob, replace everything in the CoW fork.
> */
> if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
> - XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
> + XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
> error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
> xc->irec.br_blockcount);
> if (error)
> @@ -385,7 +385,7 @@ xrep_cow_find_bad_rt(
> * CoW fork and then scan for staging extents in the refcountbt.
> */
> if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
> - XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
> + XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
> error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
> xc->irec.br_blockcount);
> if (error)
> diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
> index d00c18954a26..efd5a7ccdf62 100644
> --- a/fs/xfs/scrub/repair.c
> +++ b/fs/xfs/scrub/repair.c
> @@ -1110,7 +1110,7 @@ xrep_will_attempt(
> return true;
>
> /* Let debug users force us into the repair routines. */
> - if (XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
> + if (XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
> return true;
>
> /* Metadata is corrupt or failed cross-referencing. */
> diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
> index 5eef3bc30bda..c3a593319bee 100644
> --- a/fs/xfs/xfs_attr_item.c
> +++ b/fs/xfs/xfs_attr_item.c
> @@ -491,7 +491,7 @@ xfs_attr_finish_item(
> /* Reset trans after EAGAIN cycle since the transaction is new */
> args->trans = tp;
>
> - if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) {
> + if (XFS_TEST_ERROR(args->dp->i_mount, XFS_ERRTAG_LARP)) {
> error = -EIO;
> goto out;
> }
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index f9ef3b2a332a..8360e77b3215 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -1299,7 +1299,7 @@ xfs_buf_bio_end_io(
> if (bio->bi_status)
> xfs_buf_ioerror(bp, blk_status_to_errno(bio->bi_status));
> else if ((bp->b_flags & XBF_WRITE) && (bp->b_flags & XBF_ASYNC) &&
> - XFS_TEST_ERROR(false, bp->b_mount, XFS_ERRTAG_BUF_IOERROR))
> + XFS_TEST_ERROR(bp->b_mount, XFS_ERRTAG_BUF_IOERROR))
> xfs_buf_ioerror(bp, -EIO);
>
> if (bp->b_flags & XBF_ASYNC) {
> @@ -2084,7 +2084,7 @@ void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
> * This allows userspace to disrupt buffer caching for debug/testing
> * purposes.
> */
> - if (XFS_TEST_ERROR(false, bp->b_mount, XFS_ERRTAG_BUF_LRU_REF))
> + if (XFS_TEST_ERROR(bp->b_mount, XFS_ERRTAG_BUF_LRU_REF))
> lru_ref = 0;
>
> atomic_set(&bp->b_lru_ref, lru_ref);
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index fac35ff3da65..44dd8aba0097 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -291,7 +291,6 @@ xfs_errortag_enabled(
> bool
> xfs_errortag_test(
> struct xfs_mount *mp,
> - const char *expression,
> const char *file,
> int line,
> unsigned int error_tag)
> @@ -317,8 +316,8 @@ xfs_errortag_test(
> return false;
>
> xfs_warn_ratelimited(mp,
> -"Injecting error (%s) at file %s, line %d, on filesystem \"%s\"",
> - expression, file, line, mp->m_super->s_id);
> +"Injecting error at file %s, line %d, on filesystem \"%s\"",
> + file, line, mp->m_super->s_id);
> return true;
> }
>
> diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> index fd60a008f9d2..8429c1ee86e7 100644
> --- a/fs/xfs/xfs_error.h
> +++ b/fs/xfs/xfs_error.h
> @@ -41,10 +41,10 @@ extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
> #ifdef DEBUG
> extern int xfs_errortag_init(struct xfs_mount *mp);
> extern void xfs_errortag_del(struct xfs_mount *mp);
> -extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression,
> - const char *file, int line, unsigned int error_tag);
> -#define XFS_TEST_ERROR(expr, mp, tag) \
> - ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag)))
> +bool xfs_errortag_test(struct xfs_mount *mp, const char *file, int line,
> + unsigned int error_tag);
> +#define XFS_TEST_ERROR(mp, tag) \
> + xfs_errortag_test((mp), __FILE__, __LINE__, (tag))
> bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
> #define XFS_ERRORTAG_DELAY(mp, tag) \
> do { \
> @@ -63,7 +63,7 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
> #else
> #define xfs_errortag_init(mp) (0)
> #define xfs_errortag_del(mp)
> -#define XFS_TEST_ERROR(expr, mp, tag) (expr)
> +#define XFS_TEST_ERROR(mp, tag) (false)
> #define XFS_ERRORTAG_DELAY(mp, tag) ((void)0)
> #define xfs_errortag_add(mp, tag) (ENOSYS)
> #define xfs_errortag_clearall(mp) (ENOSYS)
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 9c39251961a3..5940faefe522 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -2377,8 +2377,8 @@ xfs_iflush(
> * error handling as the caller will shutdown and fail the buffer.
> */
> error = -EFSCORRUPTED;
> - if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC),
> - mp, XFS_ERRTAG_IFLUSH_1)) {
> + if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC) ||
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_1)) {
> xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
> "%s: Bad inode %llu magic number 0x%x, ptr "PTR_FMT,
> __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip);
> @@ -2394,29 +2394,27 @@ xfs_iflush(
> goto flush_out;
> }
> } else if (S_ISREG(VFS_I(ip)->i_mode)) {
> - if (XFS_TEST_ERROR(
> - ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
> - ip->i_df.if_format != XFS_DINODE_FMT_BTREE,
> - mp, XFS_ERRTAG_IFLUSH_3)) {
> + if ((ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
> + ip->i_df.if_format != XFS_DINODE_FMT_BTREE) ||
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_3)) {
> xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
> "%s: Bad regular inode %llu, ptr "PTR_FMT,
> __func__, ip->i_ino, ip);
> goto flush_out;
> }
> } else if (S_ISDIR(VFS_I(ip)->i_mode)) {
> - if (XFS_TEST_ERROR(
> - ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
> - ip->i_df.if_format != XFS_DINODE_FMT_BTREE &&
> - ip->i_df.if_format != XFS_DINODE_FMT_LOCAL,
> - mp, XFS_ERRTAG_IFLUSH_4)) {
> + if ((ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
> + ip->i_df.if_format != XFS_DINODE_FMT_BTREE &&
> + ip->i_df.if_format != XFS_DINODE_FMT_LOCAL) ||
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_4)) {
> xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
> "%s: Bad directory inode %llu, ptr "PTR_FMT,
> __func__, ip->i_ino, ip);
> goto flush_out;
> }
> }
> - if (XFS_TEST_ERROR(ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af) >
> - ip->i_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
> + if (ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af) >
> + ip->i_nblocks || XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_5)) {
> xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
> "%s: detected corrupt incore inode %llu, "
> "total extents = %llu nblocks = %lld, ptr "PTR_FMT,
> @@ -2425,8 +2423,8 @@ xfs_iflush(
> ip->i_nblocks, ip);
> goto flush_out;
> }
> - if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize,
> - mp, XFS_ERRTAG_IFLUSH_6)) {
> + if (ip->i_forkoff > mp->m_sb.sb_inodesize ||
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_6)) {
> xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
> "%s: bad inode %llu, forkoff 0x%x, ptr "PTR_FMT,
> __func__, ip->i_ino, ip->i_forkoff, ip);
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 2a74f2957341..2570d0a66047 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -1554,7 +1554,7 @@ xfs_zoned_buffered_write_iomap_begin(
> return error;
>
> if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
> xfs_bmap_mark_sick(ip, XFS_DATA_FORK);
> error = -EFSCORRUPTED;
> goto out_unlock;
> @@ -1728,7 +1728,7 @@ xfs_buffered_write_iomap_begin(
> return error;
>
> if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
> - XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
> xfs_bmap_mark_sick(ip, XFS_DATA_FORK);
> error = -EFSCORRUPTED;
> goto out_unlock;
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index c8a57e21a1d3..6e6442b0543c 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -969,8 +969,8 @@ xfs_log_unmount_write(
> * counters will be recalculated. Refer to xlog_check_unmount_rec for
> * more details.
> */
> - if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
> - XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
> + if (xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS) ||
> + XFS_TEST_ERROR(mp, XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
> xfs_alert(mp, "%s: will fix summary counters at next mount",
> __func__);
> return;
> @@ -1240,7 +1240,7 @@ xlog_ioend_work(
> /*
> * Race to shutdown the filesystem if we see an error.
> */
> - if (XFS_TEST_ERROR(error, log->l_mp, XFS_ERRTAG_IODONE_IOERR)) {
> + if (error || XFS_TEST_ERROR(log->l_mp, XFS_ERRTAG_IODONE_IOERR)) {
> xfs_alert(log->l_mp, "log I/O error %d", error);
> xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR);
> }
> @@ -1827,7 +1827,7 @@ xlog_sync(
> * detects the bad CRC and attempts to recover.
> */
> #ifdef DEBUG
> - if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) {
> + if (XFS_TEST_ERROR(log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) {
> iclog->ic_header.h_crc &= cpu_to_le32(0xAAAAAAAA);
> iclog->ic_fail_crc = true;
> xfs_warn(log->l_mp,
> diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
> index 67c328d23e4a..38983c6777df 100644
> --- a/fs/xfs/xfs_trans_ail.c
> +++ b/fs/xfs/xfs_trans_ail.c
> @@ -374,7 +374,7 @@ xfsaild_push_item(
> * If log item pinning is enabled, skip the push and track the item as
> * pinned. This can help induce head-behind-tail conditions.
> */
> - if (XFS_TEST_ERROR(false, ailp->ail_log->l_mp, XFS_ERRTAG_LOG_ITEM_PIN))
> + if (XFS_TEST_ERROR(ailp->ail_log->l_mp, XFS_ERRTAG_LOG_ITEM_PIN))
> return XFS_ITEM_PINNED;
>
> /*
> --
> 2.47.2
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/6] xfs: remove pointless externs in xfs_error.h
2025-09-15 13:30 cleanup error tags Christoph Hellwig
` (2 preceding siblings ...)
2025-09-15 13:30 ` [PATCH 3/6] xfs: remove the expr argument to XFS_TEST_ERROR Christoph Hellwig
@ 2025-09-15 13:30 ` Christoph Hellwig
2025-09-15 18:55 ` Darrick J. Wong
2025-09-15 13:30 ` [PATCH 5/6] xfs: centralize error tag definitions Christoph Hellwig
2025-09-15 13:30 ` [PATCH 6/6] xfs: constify xfs_errortag_random_default Christoph Hellwig
5 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2025-09-15 13:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_error.h | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 8429c1ee86e7..fe6a71bbe9cd 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -8,22 +8,17 @@
struct xfs_mount;
-extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
- const char *filename, int linenum,
- xfs_failaddr_t failaddr);
-extern void xfs_corruption_error(const char *tag, int level,
- struct xfs_mount *mp, const void *buf, size_t bufsize,
- const char *filename, int linenum,
- xfs_failaddr_t failaddr);
+void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
+ const char *filename, int linenum, xfs_failaddr_t failaddr);
+void xfs_corruption_error(const char *tag, int level, struct xfs_mount *mp,
+ const void *buf, size_t bufsize, const char *filename,
+ int linenum, xfs_failaddr_t failaddr);
void xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa);
-extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
- const char *name, const void *buf, size_t bufsz,
- xfs_failaddr_t failaddr);
-extern void xfs_verifier_error(struct xfs_buf *bp, int error,
- xfs_failaddr_t failaddr);
-extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
- const char *name, const void *buf, size_t bufsz,
- xfs_failaddr_t failaddr);
+void xfs_buf_verifier_error(struct xfs_buf *bp, int error, const char *name,
+ const void *buf, size_t bufsz, xfs_failaddr_t failaddr);
+void xfs_verifier_error(struct xfs_buf *bp, int error, xfs_failaddr_t failaddr);
+void xfs_inode_verifier_error(struct xfs_inode *ip, int error, const char *name,
+ const void *buf, size_t bufsz, xfs_failaddr_t failaddr);
#define XFS_ERROR_REPORT(e, lvl, mp) \
xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
@@ -39,8 +34,8 @@ extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
#define XFS_CORRUPTION_DUMP_LEN (128)
#ifdef DEBUG
-extern int xfs_errortag_init(struct xfs_mount *mp);
-extern void xfs_errortag_del(struct xfs_mount *mp);
+int xfs_errortag_init(struct xfs_mount *mp);
+void xfs_errortag_del(struct xfs_mount *mp);
bool xfs_errortag_test(struct xfs_mount *mp, const char *file, int line,
unsigned int error_tag);
#define XFS_TEST_ERROR(mp, tag) \
@@ -58,8 +53,8 @@ bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
mdelay((mp)->m_errortag[(tag)]); \
} while (0)
-extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
-extern int xfs_errortag_clearall(struct xfs_mount *mp);
+int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
+int xfs_errortag_clearall(struct xfs_mount *mp);
#else
#define xfs_errortag_init(mp) (0)
#define xfs_errortag_del(mp)
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 4/6] xfs: remove pointless externs in xfs_error.h
2025-09-15 13:30 ` [PATCH 4/6] xfs: remove pointless externs in xfs_error.h Christoph Hellwig
@ 2025-09-15 18:55 ` Darrick J. Wong
0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2025-09-15 18:55 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Carlos Maiolino, linux-xfs
On Mon, Sep 15, 2025 at 06:30:40AM -0700, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_error.h | 33 ++++++++++++++-------------------
> 1 file changed, 14 insertions(+), 19 deletions(-)
>
> diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> index 8429c1ee86e7..fe6a71bbe9cd 100644
> --- a/fs/xfs/xfs_error.h
> +++ b/fs/xfs/xfs_error.h
> @@ -8,22 +8,17 @@
>
> struct xfs_mount;
>
> -extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
> - const char *filename, int linenum,
> - xfs_failaddr_t failaddr);
> -extern void xfs_corruption_error(const char *tag, int level,
> - struct xfs_mount *mp, const void *buf, size_t bufsize,
> - const char *filename, int linenum,
> - xfs_failaddr_t failaddr);
> +void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
> + const char *filename, int linenum, xfs_failaddr_t failaddr);
> +void xfs_corruption_error(const char *tag, int level, struct xfs_mount *mp,
> + const void *buf, size_t bufsize, const char *filename,
> + int linenum, xfs_failaddr_t failaddr);
> void xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa);
> -extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
> - const char *name, const void *buf, size_t bufsz,
> - xfs_failaddr_t failaddr);
> -extern void xfs_verifier_error(struct xfs_buf *bp, int error,
> - xfs_failaddr_t failaddr);
> -extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
> - const char *name, const void *buf, size_t bufsz,
> - xfs_failaddr_t failaddr);
> +void xfs_buf_verifier_error(struct xfs_buf *bp, int error, const char *name,
> + const void *buf, size_t bufsz, xfs_failaddr_t failaddr);
> +void xfs_verifier_error(struct xfs_buf *bp, int error, xfs_failaddr_t failaddr);
> +void xfs_inode_verifier_error(struct xfs_inode *ip, int error, const char *name,
> + const void *buf, size_t bufsz, xfs_failaddr_t failaddr);
>
> #define XFS_ERROR_REPORT(e, lvl, mp) \
> xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
> @@ -39,8 +34,8 @@ extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
> #define XFS_CORRUPTION_DUMP_LEN (128)
>
> #ifdef DEBUG
> -extern int xfs_errortag_init(struct xfs_mount *mp);
> -extern void xfs_errortag_del(struct xfs_mount *mp);
> +int xfs_errortag_init(struct xfs_mount *mp);
> +void xfs_errortag_del(struct xfs_mount *mp);
> bool xfs_errortag_test(struct xfs_mount *mp, const char *file, int line,
> unsigned int error_tag);
> #define XFS_TEST_ERROR(mp, tag) \
> @@ -58,8 +53,8 @@ bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
> mdelay((mp)->m_errortag[(tag)]); \
> } while (0)
>
> -extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
> -extern int xfs_errortag_clearall(struct xfs_mount *mp);
> +int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
> +int xfs_errortag_clearall(struct xfs_mount *mp);
> #else
> #define xfs_errortag_init(mp) (0)
> #define xfs_errortag_del(mp)
> --
> 2.47.2
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/6] xfs: centralize error tag definitions
2025-09-15 13:30 cleanup error tags Christoph Hellwig
` (3 preceding siblings ...)
2025-09-15 13:30 ` [PATCH 4/6] xfs: remove pointless externs in xfs_error.h Christoph Hellwig
@ 2025-09-15 13:30 ` Christoph Hellwig
2025-09-15 19:10 ` Darrick J. Wong
2025-09-15 13:30 ` [PATCH 6/6] xfs: constify xfs_errortag_random_default Christoph Hellwig
5 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2025-09-15 13:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Right now 5 places in the kernel and one in xfsprogs need to be updated
for each new error tag. Add a bit of macro magic so that only the
error tag definition and a single table, which reside next to each
other, need to be updated.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_errortag.h | 94 ++++++++++----------
fs/xfs/xfs_error.c | 166 +++++------------------------------
2 files changed, 69 insertions(+), 191 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h
index a53c5d40e084..115b556f2238 100644
--- a/fs/xfs/libxfs/xfs_errortag.h
+++ b/fs/xfs/libxfs/xfs_errortag.h
@@ -4,7 +4,7 @@
* Copyright (C) 2017 Oracle.
* All Rights Reserved.
*/
-#ifndef __XFS_ERRORTAG_H_
+#if !defined(__XFS_ERRORTAG_H_) || defined(XFS_ERRTAG)
#define __XFS_ERRORTAG_H_
/*
@@ -71,49 +71,53 @@
* Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
*/
#define XFS_RANDOM_DEFAULT 100
-#define XFS_RANDOM_IFLUSH_1 XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IFLUSH_2 XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IFLUSH_3 XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IFLUSH_4 XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IFLUSH_5 XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IFLUSH_6 XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_DA_READ_BUF XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_BTREE_CHECK_LBLOCK (XFS_RANDOM_DEFAULT/4)
-#define XFS_RANDOM_BTREE_CHECK_SBLOCK XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_ALLOC_READ_AGF XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IALLOC_READ_AGI XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_ITOBP_INOTOBP XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IUNLINK XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IUNLINK_REMOVE XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_DIR_INO_VALIDATE XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_BULKSTAT_READ_CHUNK XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_IODONE_IOERR (XFS_RANDOM_DEFAULT/10)
-#define XFS_RANDOM_STRATREAD_IOERR (XFS_RANDOM_DEFAULT/10)
-#define XFS_RANDOM_STRATCMPL_IOERR (XFS_RANDOM_DEFAULT/10)
-#define XFS_RANDOM_DIOWRITE_IOERR (XFS_RANDOM_DEFAULT/10)
-#define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT
-#define XFS_RANDOM_FREE_EXTENT 1
-#define XFS_RANDOM_RMAP_FINISH_ONE 1
-#define XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE 1
-#define XFS_RANDOM_REFCOUNT_FINISH_ONE 1
-#define XFS_RANDOM_BMAP_FINISH_ONE 1
-#define XFS_RANDOM_AG_RESV_CRITICAL 4
-#define XFS_RANDOM_LOG_BAD_CRC 1
-#define XFS_RANDOM_LOG_ITEM_PIN 1
-#define XFS_RANDOM_BUF_LRU_REF 2
-#define XFS_RANDOM_FORCE_SCRUB_REPAIR 1
-#define XFS_RANDOM_FORCE_SUMMARY_RECALC 1
-#define XFS_RANDOM_IUNLINK_FALLBACK (XFS_RANDOM_DEFAULT/10)
-#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
-#define XFS_RANDOM_LARP 1
-#define XFS_RANDOM_DA_LEAF_SPLIT 1
-#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
-#define XFS_RANDOM_METAFILE_RESV_CRITICAL 4
+
+#define XFS_ERRTAGS \
+XFS_ERRTAG(NOERROR, noerror, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IFLUSH_1, iflush1, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IFLUSH_2, iflush2, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IFLUSH_3, iflush3, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IFLUSH_4, iflush4, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IFLUSH_5, iflush5, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IFLUSH_6, iflush6, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(DA_READ_BUF, dareadbuf, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(BTREE_CHECK_LBLOCK, btree_chk_lblk, XFS_RANDOM_DEFAULT/4) \
+XFS_ERRTAG(BTREE_CHECK_SBLOCK, btree_chk_sblk, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(ALLOC_READ_AGF, readagf, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IALLOC_READ_AGI, readagi, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(ITOBP_INOTOBP, itobp, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IUNLINK, iunlink, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IUNLINK_REMOVE, iunlinkrm, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(DIR_INO_VALIDATE, dirinovalid, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(BULKSTAT_READ_CHUNK, bulkstat, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(IODONE_IOERR, logiodone, XFS_RANDOM_DEFAULT/10) \
+XFS_ERRTAG(STRATREAD_IOERR, stratread, XFS_RANDOM_DEFAULT/10) \
+XFS_ERRTAG(STRATCMPL_IOERR, stratcmpl, XFS_RANDOM_DEFAULT/10) \
+XFS_ERRTAG(DIOWRITE_IOERR, diowrite, XFS_RANDOM_DEFAULT/10) \
+XFS_ERRTAG(BMAPIFORMAT, bmapifmt, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(FREE_EXTENT, free_extent, 1) \
+XFS_ERRTAG(RMAP_FINISH_ONE, rmap_finish_one, 1) \
+XFS_ERRTAG(REFCOUNT_CONTINUE_UPDATE, \
+ refcount_continue_update, 1) \
+XFS_ERRTAG(REFCOUNT_FINISH_ONE, refcount_finish_one, 1) \
+XFS_ERRTAG(BMAP_FINISH_ONE, bmap_finish_one, 1) \
+XFS_ERRTAG(AG_RESV_CRITICAL, ag_resv_critical, 4) \
+XFS_ERRTAG(LOG_BAD_CRC, log_bad_crc, 1) \
+XFS_ERRTAG(LOG_ITEM_PIN, log_item_pin, 1) \
+XFS_ERRTAG(BUF_LRU_REF, buf_lru_ref, 2) \
+XFS_ERRTAG(FORCE_SCRUB_REPAIR, force_repair, 1) \
+XFS_ERRTAG(FORCE_SUMMARY_RECALC, bad_summary, 1) \
+XFS_ERRTAG(IUNLINK_FALLBACK, iunlink_fallback, XFS_RANDOM_DEFAULT/10) \
+XFS_ERRTAG(BUF_IOERROR, buf_ioerror, XFS_RANDOM_DEFAULT) \
+XFS_ERRTAG(REDUCE_MAX_IEXTENTS, reduce_max_iextents, 1) \
+XFS_ERRTAG(BMAP_ALLOC_MINLEN_EXTENT, bmap_alloc_minlen_extent, 1) \
+XFS_ERRTAG(AG_RESV_FAIL, ag_resv_fail, 1) \
+XFS_ERRTAG(LARP, larp, 1) \
+XFS_ERRTAG(DA_LEAF_SPLIT, da_leaf_split, 1) \
+XFS_ERRTAG(ATTR_LEAF_TO_NODE, attr_leaf_to_node, 1) \
+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) \
#endif /* __XFS_ERRORTAG_H_ */
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 44dd8aba0097..ac895cd2bc0a 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -10,61 +10,17 @@
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
-#include "xfs_errortag.h"
#include "xfs_error.h"
#include "xfs_sysfs.h"
#include "xfs_inode.h"
#ifdef DEBUG
-static unsigned int xfs_errortag_random_default[] = {
- XFS_RANDOM_DEFAULT,
- XFS_RANDOM_IFLUSH_1,
- XFS_RANDOM_IFLUSH_2,
- XFS_RANDOM_IFLUSH_3,
- XFS_RANDOM_IFLUSH_4,
- XFS_RANDOM_IFLUSH_5,
- XFS_RANDOM_IFLUSH_6,
- XFS_RANDOM_DA_READ_BUF,
- XFS_RANDOM_BTREE_CHECK_LBLOCK,
- XFS_RANDOM_BTREE_CHECK_SBLOCK,
- XFS_RANDOM_ALLOC_READ_AGF,
- XFS_RANDOM_IALLOC_READ_AGI,
- XFS_RANDOM_ITOBP_INOTOBP,
- XFS_RANDOM_IUNLINK,
- XFS_RANDOM_IUNLINK_REMOVE,
- XFS_RANDOM_DIR_INO_VALIDATE,
- XFS_RANDOM_BULKSTAT_READ_CHUNK,
- XFS_RANDOM_IODONE_IOERR,
- XFS_RANDOM_STRATREAD_IOERR,
- XFS_RANDOM_STRATCMPL_IOERR,
- XFS_RANDOM_DIOWRITE_IOERR,
- XFS_RANDOM_BMAPIFORMAT,
- XFS_RANDOM_FREE_EXTENT,
- XFS_RANDOM_RMAP_FINISH_ONE,
- XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE,
- XFS_RANDOM_REFCOUNT_FINISH_ONE,
- XFS_RANDOM_BMAP_FINISH_ONE,
- XFS_RANDOM_AG_RESV_CRITICAL,
- 0, /* XFS_RANDOM_DROP_WRITES has been removed */
- XFS_RANDOM_LOG_BAD_CRC,
- XFS_RANDOM_LOG_ITEM_PIN,
- XFS_RANDOM_BUF_LRU_REF,
- XFS_RANDOM_FORCE_SCRUB_REPAIR,
- XFS_RANDOM_FORCE_SUMMARY_RECALC,
- XFS_RANDOM_IUNLINK_FALLBACK,
- XFS_RANDOM_BUF_IOERROR,
- XFS_RANDOM_REDUCE_MAX_IEXTENTS,
- XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT,
- XFS_RANDOM_AG_RESV_FAIL,
- XFS_RANDOM_LARP,
- XFS_RANDOM_DA_LEAF_SPLIT,
- XFS_RANDOM_ATTR_LEAF_TO_NODE,
- XFS_RANDOM_WB_DELAY_MS,
- XFS_RANDOM_WRITE_DELAY_MS,
- XFS_RANDOM_EXCHMAPS_FINISH_ONE,
- XFS_RANDOM_METAFILE_RESV_CRITICAL,
-};
+#define XFS_ERRTAG(_tag, _name, _default) \
+ [XFS_ERRTAG_##_tag] = (_default),
+#include "xfs_errortag.h"
+static unsigned int xfs_errortag_random_default[] = { XFS_ERRTAGS };
+#undef XFS_ERRTAG
struct xfs_errortag_attr {
struct attribute attr;
@@ -125,110 +81,28 @@ static const struct sysfs_ops xfs_errortag_sysfs_ops = {
.store = xfs_errortag_attr_store,
};
-#define XFS_ERRORTAG_ATTR_RW(_name, _tag) \
+#define XFS_ERRTAG(_tag, _name, _default) \
static struct xfs_errortag_attr xfs_errortag_attr_##_name = { \
.attr = {.name = __stringify(_name), \
.mode = VERIFY_OCTAL_PERMISSIONS(S_IWUSR | S_IRUGO) }, \
- .tag = (_tag), \
-}
-
-#define XFS_ERRORTAG_ATTR_LIST(_name) &xfs_errortag_attr_##_name.attr
-
-XFS_ERRORTAG_ATTR_RW(noerror, XFS_ERRTAG_NOERROR);
-XFS_ERRORTAG_ATTR_RW(iflush1, XFS_ERRTAG_IFLUSH_1);
-XFS_ERRORTAG_ATTR_RW(iflush2, XFS_ERRTAG_IFLUSH_2);
-XFS_ERRORTAG_ATTR_RW(iflush3, XFS_ERRTAG_IFLUSH_3);
-XFS_ERRORTAG_ATTR_RW(iflush4, XFS_ERRTAG_IFLUSH_4);
-XFS_ERRORTAG_ATTR_RW(iflush5, XFS_ERRTAG_IFLUSH_5);
-XFS_ERRORTAG_ATTR_RW(iflush6, XFS_ERRTAG_IFLUSH_6);
-XFS_ERRORTAG_ATTR_RW(dareadbuf, XFS_ERRTAG_DA_READ_BUF);
-XFS_ERRORTAG_ATTR_RW(btree_chk_lblk, XFS_ERRTAG_BTREE_CHECK_LBLOCK);
-XFS_ERRORTAG_ATTR_RW(btree_chk_sblk, XFS_ERRTAG_BTREE_CHECK_SBLOCK);
-XFS_ERRORTAG_ATTR_RW(readagf, XFS_ERRTAG_ALLOC_READ_AGF);
-XFS_ERRORTAG_ATTR_RW(readagi, XFS_ERRTAG_IALLOC_READ_AGI);
-XFS_ERRORTAG_ATTR_RW(itobp, XFS_ERRTAG_ITOBP_INOTOBP);
-XFS_ERRORTAG_ATTR_RW(iunlink, XFS_ERRTAG_IUNLINK);
-XFS_ERRORTAG_ATTR_RW(iunlinkrm, XFS_ERRTAG_IUNLINK_REMOVE);
-XFS_ERRORTAG_ATTR_RW(dirinovalid, XFS_ERRTAG_DIR_INO_VALIDATE);
-XFS_ERRORTAG_ATTR_RW(bulkstat, XFS_ERRTAG_BULKSTAT_READ_CHUNK);
-XFS_ERRORTAG_ATTR_RW(logiodone, XFS_ERRTAG_IODONE_IOERR);
-XFS_ERRORTAG_ATTR_RW(stratread, XFS_ERRTAG_STRATREAD_IOERR);
-XFS_ERRORTAG_ATTR_RW(stratcmpl, XFS_ERRTAG_STRATCMPL_IOERR);
-XFS_ERRORTAG_ATTR_RW(diowrite, XFS_ERRTAG_DIOWRITE_IOERR);
-XFS_ERRORTAG_ATTR_RW(bmapifmt, XFS_ERRTAG_BMAPIFORMAT);
-XFS_ERRORTAG_ATTR_RW(free_extent, XFS_ERRTAG_FREE_EXTENT);
-XFS_ERRORTAG_ATTR_RW(rmap_finish_one, XFS_ERRTAG_RMAP_FINISH_ONE);
-XFS_ERRORTAG_ATTR_RW(refcount_continue_update, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE);
-XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE);
-XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE);
-XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
-XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC);
-XFS_ERRORTAG_ATTR_RW(log_item_pin, XFS_ERRTAG_LOG_ITEM_PIN);
-XFS_ERRORTAG_ATTR_RW(buf_lru_ref, XFS_ERRTAG_BUF_LRU_REF);
-XFS_ERRORTAG_ATTR_RW(force_repair, XFS_ERRTAG_FORCE_SCRUB_REPAIR);
-XFS_ERRORTAG_ATTR_RW(bad_summary, XFS_ERRTAG_FORCE_SUMMARY_RECALC);
-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);
-XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP);
-XFS_ERRORTAG_ATTR_RW(da_leaf_split, XFS_ERRTAG_DA_LEAF_SPLIT);
-XFS_ERRORTAG_ATTR_RW(attr_leaf_to_node, XFS_ERRTAG_ATTR_LEAF_TO_NODE);
-XFS_ERRORTAG_ATTR_RW(wb_delay_ms, XFS_ERRTAG_WB_DELAY_MS);
-XFS_ERRORTAG_ATTR_RW(write_delay_ms, XFS_ERRTAG_WRITE_DELAY_MS);
-XFS_ERRORTAG_ATTR_RW(exchmaps_finish_one, XFS_ERRTAG_EXCHMAPS_FINISH_ONE);
-XFS_ERRORTAG_ATTR_RW(metafile_resv_crit, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
+ .tag = XFS_ERRTAG_##_tag, \
+};
+#include "xfs_errortag.h"
+XFS_ERRTAGS
+#undef XFS_ERRTAG
+#define XFS_ERRTAG(_tag, _name, _default) \
+ &xfs_errortag_attr_##_name.attr,
+#include "xfs_errortag.h"
static struct attribute *xfs_errortag_attrs[] = {
- XFS_ERRORTAG_ATTR_LIST(noerror),
- XFS_ERRORTAG_ATTR_LIST(iflush1),
- XFS_ERRORTAG_ATTR_LIST(iflush2),
- XFS_ERRORTAG_ATTR_LIST(iflush3),
- XFS_ERRORTAG_ATTR_LIST(iflush4),
- XFS_ERRORTAG_ATTR_LIST(iflush5),
- XFS_ERRORTAG_ATTR_LIST(iflush6),
- XFS_ERRORTAG_ATTR_LIST(dareadbuf),
- XFS_ERRORTAG_ATTR_LIST(btree_chk_lblk),
- XFS_ERRORTAG_ATTR_LIST(btree_chk_sblk),
- XFS_ERRORTAG_ATTR_LIST(readagf),
- XFS_ERRORTAG_ATTR_LIST(readagi),
- XFS_ERRORTAG_ATTR_LIST(itobp),
- XFS_ERRORTAG_ATTR_LIST(iunlink),
- XFS_ERRORTAG_ATTR_LIST(iunlinkrm),
- XFS_ERRORTAG_ATTR_LIST(dirinovalid),
- XFS_ERRORTAG_ATTR_LIST(bulkstat),
- XFS_ERRORTAG_ATTR_LIST(logiodone),
- XFS_ERRORTAG_ATTR_LIST(stratread),
- XFS_ERRORTAG_ATTR_LIST(stratcmpl),
- XFS_ERRORTAG_ATTR_LIST(diowrite),
- XFS_ERRORTAG_ATTR_LIST(bmapifmt),
- XFS_ERRORTAG_ATTR_LIST(free_extent),
- XFS_ERRORTAG_ATTR_LIST(rmap_finish_one),
- XFS_ERRORTAG_ATTR_LIST(refcount_continue_update),
- XFS_ERRORTAG_ATTR_LIST(refcount_finish_one),
- XFS_ERRORTAG_ATTR_LIST(bmap_finish_one),
- XFS_ERRORTAG_ATTR_LIST(ag_resv_critical),
- XFS_ERRORTAG_ATTR_LIST(log_bad_crc),
- XFS_ERRORTAG_ATTR_LIST(log_item_pin),
- XFS_ERRORTAG_ATTR_LIST(buf_lru_ref),
- XFS_ERRORTAG_ATTR_LIST(force_repair),
- XFS_ERRORTAG_ATTR_LIST(bad_summary),
- XFS_ERRORTAG_ATTR_LIST(iunlink_fallback),
- 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),
- XFS_ERRORTAG_ATTR_LIST(larp),
- XFS_ERRORTAG_ATTR_LIST(da_leaf_split),
- XFS_ERRORTAG_ATTR_LIST(attr_leaf_to_node),
- XFS_ERRORTAG_ATTR_LIST(wb_delay_ms),
- XFS_ERRORTAG_ATTR_LIST(write_delay_ms),
- XFS_ERRORTAG_ATTR_LIST(exchmaps_finish_one),
- XFS_ERRORTAG_ATTR_LIST(metafile_resv_crit),
- NULL,
+ XFS_ERRTAGS
+ NULL
};
ATTRIBUTE_GROUPS(xfs_errortag);
+#undef XFS_ERRTAG
+
+/* -1 because XFS_ERRTAG_DROP_WRITES got removed, + 1 for NULL termination */
+static_assert(ARRAY_SIZE(xfs_errortag_attrs) == XFS_ERRTAG_MAX);
static const struct kobj_type xfs_errortag_ktype = {
.release = xfs_sysfs_release,
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 5/6] xfs: centralize error tag definitions
2025-09-15 13:30 ` [PATCH 5/6] xfs: centralize error tag definitions Christoph Hellwig
@ 2025-09-15 19:10 ` Darrick J. Wong
2025-09-15 20:53 ` Christoph Hellwig
0 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2025-09-15 19:10 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Carlos Maiolino, linux-xfs
On Mon, Sep 15, 2025 at 06:30:41AM -0700, Christoph Hellwig wrote:
> Right now 5 places in the kernel and one in xfsprogs need to be updated
> for each new error tag. Add a bit of macro magic so that only the
> error tag definition and a single table, which reside next to each
> other, need to be updated.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/libxfs/xfs_errortag.h | 94 ++++++++++----------
> fs/xfs/xfs_error.c | 166 +++++------------------------------
> 2 files changed, 69 insertions(+), 191 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h
> index a53c5d40e084..115b556f2238 100644
> --- a/fs/xfs/libxfs/xfs_errortag.h
> +++ b/fs/xfs/libxfs/xfs_errortag.h
> @@ -4,7 +4,7 @@
> * Copyright (C) 2017 Oracle.
> * All Rights Reserved.
> */
> -#ifndef __XFS_ERRORTAG_H_
> +#if !defined(__XFS_ERRORTAG_H_) || defined(XFS_ERRTAG)
Hrmm. So now xfs_errortag.h has two uses: one where we just #include
it without defining XFS_ERRTAG, and we get the XFS_ERRTAG_* values?
and I guess a broken XFS_ERRTAGS that isn't fully defined?
And then you're allowed to #include it again, provided you enclose that
inside a #define XFS_ERRTAG and a user of an XFS_ERRTAGS symbol, in
which case it actually spits out a usable XFS_ERRTAGS?
That could be documented better.
"There are two ways to use this header file. The first way is to
#include it bare, which will define all the XFS_ERRTAG_* error injection
knobs for use with the XFS_TEST_ERROR macro. The second way is to
enclose the #include with a #define for an XFS_ERRTAG macro, in which
case the header will define an XFS_ERRTAGS macro that expands to one
XFS_ERRTAG use for each defined error injection knob."
I like the removal of the boilerplate code all over the place.
--D
> #define __XFS_ERRORTAG_H_
>
> /*
> @@ -71,49 +71,53 @@
> * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
> */
> #define XFS_RANDOM_DEFAULT 100
> -#define XFS_RANDOM_IFLUSH_1 XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IFLUSH_2 XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IFLUSH_3 XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IFLUSH_4 XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IFLUSH_5 XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IFLUSH_6 XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_DA_READ_BUF XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_BTREE_CHECK_LBLOCK (XFS_RANDOM_DEFAULT/4)
> -#define XFS_RANDOM_BTREE_CHECK_SBLOCK XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_ALLOC_READ_AGF XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IALLOC_READ_AGI XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_ITOBP_INOTOBP XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IUNLINK XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IUNLINK_REMOVE XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_DIR_INO_VALIDATE XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_BULKSTAT_READ_CHUNK XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_IODONE_IOERR (XFS_RANDOM_DEFAULT/10)
> -#define XFS_RANDOM_STRATREAD_IOERR (XFS_RANDOM_DEFAULT/10)
> -#define XFS_RANDOM_STRATCMPL_IOERR (XFS_RANDOM_DEFAULT/10)
> -#define XFS_RANDOM_DIOWRITE_IOERR (XFS_RANDOM_DEFAULT/10)
> -#define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT
> -#define XFS_RANDOM_FREE_EXTENT 1
> -#define XFS_RANDOM_RMAP_FINISH_ONE 1
> -#define XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE 1
> -#define XFS_RANDOM_REFCOUNT_FINISH_ONE 1
> -#define XFS_RANDOM_BMAP_FINISH_ONE 1
> -#define XFS_RANDOM_AG_RESV_CRITICAL 4
> -#define XFS_RANDOM_LOG_BAD_CRC 1
> -#define XFS_RANDOM_LOG_ITEM_PIN 1
> -#define XFS_RANDOM_BUF_LRU_REF 2
> -#define XFS_RANDOM_FORCE_SCRUB_REPAIR 1
> -#define XFS_RANDOM_FORCE_SUMMARY_RECALC 1
> -#define XFS_RANDOM_IUNLINK_FALLBACK (XFS_RANDOM_DEFAULT/10)
> -#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
> -#define XFS_RANDOM_LARP 1
> -#define XFS_RANDOM_DA_LEAF_SPLIT 1
> -#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
> -#define XFS_RANDOM_METAFILE_RESV_CRITICAL 4
> +
> +#define XFS_ERRTAGS \
Do you need to #undef XFS_ERRTAGS here to prevent the W=XXX build and/or
static tools from whining about redefined macros?
Also sorta wondering if for cleanliness this ought to be:
#ifdef XFS_ERRTAG
# define XFS_ERRTAGS \
<giant table>
#endif /* XFS_ERRTAG */
To avoid cluttering up the macro namespace if the file #include'ing
xfs_errortag.h didn't define XFS_ERRTAG and doesn't actually want the
ERRTAGS expansion?
--D
> +XFS_ERRTAG(NOERROR, noerror, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IFLUSH_1, iflush1, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IFLUSH_2, iflush2, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IFLUSH_3, iflush3, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IFLUSH_4, iflush4, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IFLUSH_5, iflush5, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IFLUSH_6, iflush6, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(DA_READ_BUF, dareadbuf, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(BTREE_CHECK_LBLOCK, btree_chk_lblk, XFS_RANDOM_DEFAULT/4) \
> +XFS_ERRTAG(BTREE_CHECK_SBLOCK, btree_chk_sblk, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(ALLOC_READ_AGF, readagf, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IALLOC_READ_AGI, readagi, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(ITOBP_INOTOBP, itobp, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IUNLINK, iunlink, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IUNLINK_REMOVE, iunlinkrm, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(DIR_INO_VALIDATE, dirinovalid, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(BULKSTAT_READ_CHUNK, bulkstat, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(IODONE_IOERR, logiodone, XFS_RANDOM_DEFAULT/10) \
> +XFS_ERRTAG(STRATREAD_IOERR, stratread, XFS_RANDOM_DEFAULT/10) \
> +XFS_ERRTAG(STRATCMPL_IOERR, stratcmpl, XFS_RANDOM_DEFAULT/10) \
> +XFS_ERRTAG(DIOWRITE_IOERR, diowrite, XFS_RANDOM_DEFAULT/10) \
> +XFS_ERRTAG(BMAPIFORMAT, bmapifmt, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(FREE_EXTENT, free_extent, 1) \
> +XFS_ERRTAG(RMAP_FINISH_ONE, rmap_finish_one, 1) \
> +XFS_ERRTAG(REFCOUNT_CONTINUE_UPDATE, \
> + refcount_continue_update, 1) \
> +XFS_ERRTAG(REFCOUNT_FINISH_ONE, refcount_finish_one, 1) \
> +XFS_ERRTAG(BMAP_FINISH_ONE, bmap_finish_one, 1) \
> +XFS_ERRTAG(AG_RESV_CRITICAL, ag_resv_critical, 4) \
> +XFS_ERRTAG(LOG_BAD_CRC, log_bad_crc, 1) \
> +XFS_ERRTAG(LOG_ITEM_PIN, log_item_pin, 1) \
> +XFS_ERRTAG(BUF_LRU_REF, buf_lru_ref, 2) \
> +XFS_ERRTAG(FORCE_SCRUB_REPAIR, force_repair, 1) \
> +XFS_ERRTAG(FORCE_SUMMARY_RECALC, bad_summary, 1) \
> +XFS_ERRTAG(IUNLINK_FALLBACK, iunlink_fallback, XFS_RANDOM_DEFAULT/10) \
> +XFS_ERRTAG(BUF_IOERROR, buf_ioerror, XFS_RANDOM_DEFAULT) \
> +XFS_ERRTAG(REDUCE_MAX_IEXTENTS, reduce_max_iextents, 1) \
> +XFS_ERRTAG(BMAP_ALLOC_MINLEN_EXTENT, bmap_alloc_minlen_extent, 1) \
> +XFS_ERRTAG(AG_RESV_FAIL, ag_resv_fail, 1) \
> +XFS_ERRTAG(LARP, larp, 1) \
> +XFS_ERRTAG(DA_LEAF_SPLIT, da_leaf_split, 1) \
> +XFS_ERRTAG(ATTR_LEAF_TO_NODE, attr_leaf_to_node, 1) \
> +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) \
>
> #endif /* __XFS_ERRORTAG_H_ */
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index 44dd8aba0097..ac895cd2bc0a 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -10,61 +10,17 @@
> #include "xfs_log_format.h"
> #include "xfs_trans_resv.h"
> #include "xfs_mount.h"
> -#include "xfs_errortag.h"
> #include "xfs_error.h"
> #include "xfs_sysfs.h"
> #include "xfs_inode.h"
>
> #ifdef DEBUG
>
> -static unsigned int xfs_errortag_random_default[] = {
> - XFS_RANDOM_DEFAULT,
> - XFS_RANDOM_IFLUSH_1,
> - XFS_RANDOM_IFLUSH_2,
> - XFS_RANDOM_IFLUSH_3,
> - XFS_RANDOM_IFLUSH_4,
> - XFS_RANDOM_IFLUSH_5,
> - XFS_RANDOM_IFLUSH_6,
> - XFS_RANDOM_DA_READ_BUF,
> - XFS_RANDOM_BTREE_CHECK_LBLOCK,
> - XFS_RANDOM_BTREE_CHECK_SBLOCK,
> - XFS_RANDOM_ALLOC_READ_AGF,
> - XFS_RANDOM_IALLOC_READ_AGI,
> - XFS_RANDOM_ITOBP_INOTOBP,
> - XFS_RANDOM_IUNLINK,
> - XFS_RANDOM_IUNLINK_REMOVE,
> - XFS_RANDOM_DIR_INO_VALIDATE,
> - XFS_RANDOM_BULKSTAT_READ_CHUNK,
> - XFS_RANDOM_IODONE_IOERR,
> - XFS_RANDOM_STRATREAD_IOERR,
> - XFS_RANDOM_STRATCMPL_IOERR,
> - XFS_RANDOM_DIOWRITE_IOERR,
> - XFS_RANDOM_BMAPIFORMAT,
> - XFS_RANDOM_FREE_EXTENT,
> - XFS_RANDOM_RMAP_FINISH_ONE,
> - XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE,
> - XFS_RANDOM_REFCOUNT_FINISH_ONE,
> - XFS_RANDOM_BMAP_FINISH_ONE,
> - XFS_RANDOM_AG_RESV_CRITICAL,
> - 0, /* XFS_RANDOM_DROP_WRITES has been removed */
> - XFS_RANDOM_LOG_BAD_CRC,
> - XFS_RANDOM_LOG_ITEM_PIN,
> - XFS_RANDOM_BUF_LRU_REF,
> - XFS_RANDOM_FORCE_SCRUB_REPAIR,
> - XFS_RANDOM_FORCE_SUMMARY_RECALC,
> - XFS_RANDOM_IUNLINK_FALLBACK,
> - XFS_RANDOM_BUF_IOERROR,
> - XFS_RANDOM_REDUCE_MAX_IEXTENTS,
> - XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT,
> - XFS_RANDOM_AG_RESV_FAIL,
> - XFS_RANDOM_LARP,
> - XFS_RANDOM_DA_LEAF_SPLIT,
> - XFS_RANDOM_ATTR_LEAF_TO_NODE,
> - XFS_RANDOM_WB_DELAY_MS,
> - XFS_RANDOM_WRITE_DELAY_MS,
> - XFS_RANDOM_EXCHMAPS_FINISH_ONE,
> - XFS_RANDOM_METAFILE_RESV_CRITICAL,
> -};
> +#define XFS_ERRTAG(_tag, _name, _default) \
> + [XFS_ERRTAG_##_tag] = (_default),
> +#include "xfs_errortag.h"
> +static unsigned int xfs_errortag_random_default[] = { XFS_ERRTAGS };
> +#undef XFS_ERRTAG
>
> struct xfs_errortag_attr {
> struct attribute attr;
> @@ -125,110 +81,28 @@ static const struct sysfs_ops xfs_errortag_sysfs_ops = {
> .store = xfs_errortag_attr_store,
> };
>
> -#define XFS_ERRORTAG_ATTR_RW(_name, _tag) \
> +#define XFS_ERRTAG(_tag, _name, _default) \
> static struct xfs_errortag_attr xfs_errortag_attr_##_name = { \
> .attr = {.name = __stringify(_name), \
> .mode = VERIFY_OCTAL_PERMISSIONS(S_IWUSR | S_IRUGO) }, \
> - .tag = (_tag), \
> -}
> -
> -#define XFS_ERRORTAG_ATTR_LIST(_name) &xfs_errortag_attr_##_name.attr
> -
> -XFS_ERRORTAG_ATTR_RW(noerror, XFS_ERRTAG_NOERROR);
> -XFS_ERRORTAG_ATTR_RW(iflush1, XFS_ERRTAG_IFLUSH_1);
> -XFS_ERRORTAG_ATTR_RW(iflush2, XFS_ERRTAG_IFLUSH_2);
> -XFS_ERRORTAG_ATTR_RW(iflush3, XFS_ERRTAG_IFLUSH_3);
> -XFS_ERRORTAG_ATTR_RW(iflush4, XFS_ERRTAG_IFLUSH_4);
> -XFS_ERRORTAG_ATTR_RW(iflush5, XFS_ERRTAG_IFLUSH_5);
> -XFS_ERRORTAG_ATTR_RW(iflush6, XFS_ERRTAG_IFLUSH_6);
> -XFS_ERRORTAG_ATTR_RW(dareadbuf, XFS_ERRTAG_DA_READ_BUF);
> -XFS_ERRORTAG_ATTR_RW(btree_chk_lblk, XFS_ERRTAG_BTREE_CHECK_LBLOCK);
> -XFS_ERRORTAG_ATTR_RW(btree_chk_sblk, XFS_ERRTAG_BTREE_CHECK_SBLOCK);
> -XFS_ERRORTAG_ATTR_RW(readagf, XFS_ERRTAG_ALLOC_READ_AGF);
> -XFS_ERRORTAG_ATTR_RW(readagi, XFS_ERRTAG_IALLOC_READ_AGI);
> -XFS_ERRORTAG_ATTR_RW(itobp, XFS_ERRTAG_ITOBP_INOTOBP);
> -XFS_ERRORTAG_ATTR_RW(iunlink, XFS_ERRTAG_IUNLINK);
> -XFS_ERRORTAG_ATTR_RW(iunlinkrm, XFS_ERRTAG_IUNLINK_REMOVE);
> -XFS_ERRORTAG_ATTR_RW(dirinovalid, XFS_ERRTAG_DIR_INO_VALIDATE);
> -XFS_ERRORTAG_ATTR_RW(bulkstat, XFS_ERRTAG_BULKSTAT_READ_CHUNK);
> -XFS_ERRORTAG_ATTR_RW(logiodone, XFS_ERRTAG_IODONE_IOERR);
> -XFS_ERRORTAG_ATTR_RW(stratread, XFS_ERRTAG_STRATREAD_IOERR);
> -XFS_ERRORTAG_ATTR_RW(stratcmpl, XFS_ERRTAG_STRATCMPL_IOERR);
> -XFS_ERRORTAG_ATTR_RW(diowrite, XFS_ERRTAG_DIOWRITE_IOERR);
> -XFS_ERRORTAG_ATTR_RW(bmapifmt, XFS_ERRTAG_BMAPIFORMAT);
> -XFS_ERRORTAG_ATTR_RW(free_extent, XFS_ERRTAG_FREE_EXTENT);
> -XFS_ERRORTAG_ATTR_RW(rmap_finish_one, XFS_ERRTAG_RMAP_FINISH_ONE);
> -XFS_ERRORTAG_ATTR_RW(refcount_continue_update, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE);
> -XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE);
> -XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE);
> -XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL);
> -XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC);
> -XFS_ERRORTAG_ATTR_RW(log_item_pin, XFS_ERRTAG_LOG_ITEM_PIN);
> -XFS_ERRORTAG_ATTR_RW(buf_lru_ref, XFS_ERRTAG_BUF_LRU_REF);
> -XFS_ERRORTAG_ATTR_RW(force_repair, XFS_ERRTAG_FORCE_SCRUB_REPAIR);
> -XFS_ERRORTAG_ATTR_RW(bad_summary, XFS_ERRTAG_FORCE_SUMMARY_RECALC);
> -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);
> -XFS_ERRORTAG_ATTR_RW(larp, XFS_ERRTAG_LARP);
> -XFS_ERRORTAG_ATTR_RW(da_leaf_split, XFS_ERRTAG_DA_LEAF_SPLIT);
> -XFS_ERRORTAG_ATTR_RW(attr_leaf_to_node, XFS_ERRTAG_ATTR_LEAF_TO_NODE);
> -XFS_ERRORTAG_ATTR_RW(wb_delay_ms, XFS_ERRTAG_WB_DELAY_MS);
> -XFS_ERRORTAG_ATTR_RW(write_delay_ms, XFS_ERRTAG_WRITE_DELAY_MS);
> -XFS_ERRORTAG_ATTR_RW(exchmaps_finish_one, XFS_ERRTAG_EXCHMAPS_FINISH_ONE);
> -XFS_ERRORTAG_ATTR_RW(metafile_resv_crit, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
> + .tag = XFS_ERRTAG_##_tag, \
> +};
> +#include "xfs_errortag.h"
> +XFS_ERRTAGS
> +#undef XFS_ERRTAG
>
> +#define XFS_ERRTAG(_tag, _name, _default) \
> + &xfs_errortag_attr_##_name.attr,
> +#include "xfs_errortag.h"
> static struct attribute *xfs_errortag_attrs[] = {
> - XFS_ERRORTAG_ATTR_LIST(noerror),
> - XFS_ERRORTAG_ATTR_LIST(iflush1),
> - XFS_ERRORTAG_ATTR_LIST(iflush2),
> - XFS_ERRORTAG_ATTR_LIST(iflush3),
> - XFS_ERRORTAG_ATTR_LIST(iflush4),
> - XFS_ERRORTAG_ATTR_LIST(iflush5),
> - XFS_ERRORTAG_ATTR_LIST(iflush6),
> - XFS_ERRORTAG_ATTR_LIST(dareadbuf),
> - XFS_ERRORTAG_ATTR_LIST(btree_chk_lblk),
> - XFS_ERRORTAG_ATTR_LIST(btree_chk_sblk),
> - XFS_ERRORTAG_ATTR_LIST(readagf),
> - XFS_ERRORTAG_ATTR_LIST(readagi),
> - XFS_ERRORTAG_ATTR_LIST(itobp),
> - XFS_ERRORTAG_ATTR_LIST(iunlink),
> - XFS_ERRORTAG_ATTR_LIST(iunlinkrm),
> - XFS_ERRORTAG_ATTR_LIST(dirinovalid),
> - XFS_ERRORTAG_ATTR_LIST(bulkstat),
> - XFS_ERRORTAG_ATTR_LIST(logiodone),
> - XFS_ERRORTAG_ATTR_LIST(stratread),
> - XFS_ERRORTAG_ATTR_LIST(stratcmpl),
> - XFS_ERRORTAG_ATTR_LIST(diowrite),
> - XFS_ERRORTAG_ATTR_LIST(bmapifmt),
> - XFS_ERRORTAG_ATTR_LIST(free_extent),
> - XFS_ERRORTAG_ATTR_LIST(rmap_finish_one),
> - XFS_ERRORTAG_ATTR_LIST(refcount_continue_update),
> - XFS_ERRORTAG_ATTR_LIST(refcount_finish_one),
> - XFS_ERRORTAG_ATTR_LIST(bmap_finish_one),
> - XFS_ERRORTAG_ATTR_LIST(ag_resv_critical),
> - XFS_ERRORTAG_ATTR_LIST(log_bad_crc),
> - XFS_ERRORTAG_ATTR_LIST(log_item_pin),
> - XFS_ERRORTAG_ATTR_LIST(buf_lru_ref),
> - XFS_ERRORTAG_ATTR_LIST(force_repair),
> - XFS_ERRORTAG_ATTR_LIST(bad_summary),
> - XFS_ERRORTAG_ATTR_LIST(iunlink_fallback),
> - 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),
> - XFS_ERRORTAG_ATTR_LIST(larp),
> - XFS_ERRORTAG_ATTR_LIST(da_leaf_split),
> - XFS_ERRORTAG_ATTR_LIST(attr_leaf_to_node),
> - XFS_ERRORTAG_ATTR_LIST(wb_delay_ms),
> - XFS_ERRORTAG_ATTR_LIST(write_delay_ms),
> - XFS_ERRORTAG_ATTR_LIST(exchmaps_finish_one),
> - XFS_ERRORTAG_ATTR_LIST(metafile_resv_crit),
> - NULL,
> + XFS_ERRTAGS
> + NULL
> };
> ATTRIBUTE_GROUPS(xfs_errortag);
> +#undef XFS_ERRTAG
> +
> +/* -1 because XFS_ERRTAG_DROP_WRITES got removed, + 1 for NULL termination */
> +static_assert(ARRAY_SIZE(xfs_errortag_attrs) == XFS_ERRTAG_MAX);
>
> static const struct kobj_type xfs_errortag_ktype = {
> .release = xfs_sysfs_release,
> --
> 2.47.2
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 5/6] xfs: centralize error tag definitions
2025-09-15 19:10 ` Darrick J. Wong
@ 2025-09-15 20:53 ` Christoph Hellwig
2025-09-15 23:37 ` Darrick J. Wong
0 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2025-09-15 20:53 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Christoph Hellwig, Carlos Maiolino, linux-xfs
On Mon, Sep 15, 2025 at 12:10:01PM -0700, Darrick J. Wong wrote:
> > -#ifndef __XFS_ERRORTAG_H_
> > +#if !defined(__XFS_ERRORTAG_H_) || defined(XFS_ERRTAG)
>
> Hrmm. So now xfs_errortag.h has two uses: one where we just #include
> it without defining XFS_ERRTAG, and we get the XFS_ERRTAG_* values?
Yes.
> and I guess a broken XFS_ERRTAGS that isn't fully defined?
Yes. I wouldn't call it broken, just not usable :)
> And then you're allowed to #include it again, provided you enclose that
> inside a #define XFS_ERRTAG and a user of an XFS_ERRTAGS symbol, in
> which case it actually spits out a usable XFS_ERRTAGS?
Yes.
> That could be documented better.
>
> "There are two ways to use this header file. The first way is to
> #include it bare, which will define all the XFS_ERRTAG_* error injection
> knobs for use with the XFS_TEST_ERROR macro. The second way is to
> enclose the #include with a #define for an XFS_ERRTAG macro, in which
> case the header will define an XFS_ERRTAGS macro that expands to one
> XFS_ERRTAG use for each defined error injection knob."
I can add that.
> > +
> > +#define XFS_ERRTAGS \
>
> Do you need to #undef XFS_ERRTAGS here to prevent the W=XXX build and/or
> static tools from whining about redefined macros?
XFS_ERRTAGS is redefined identically, which is allowed. And we can't
undef it here, because we use the definition in the .c files. We could
undef it after using it, but that feels a bit pointless.
>
> Also sorta wondering if for cleanliness this ought to be:
>
> #ifdef XFS_ERRTAG
> # define XFS_ERRTAGS \
> <giant table>
> #endif /* XFS_ERRTAG */
>
> To avoid cluttering up the macro namespace if the file #include'ing
> xfs_errortag.h didn't define XFS_ERRTAG and doesn't actually want the
> ERRTAGS expansion?
That does sound doable, let me give it a try.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/6] xfs: centralize error tag definitions
2025-09-15 20:53 ` Christoph Hellwig
@ 2025-09-15 23:37 ` Darrick J. Wong
0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2025-09-15 23:37 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Carlos Maiolino, linux-xfs
On Mon, Sep 15, 2025 at 10:53:27PM +0200, Christoph Hellwig wrote:
> On Mon, Sep 15, 2025 at 12:10:01PM -0700, Darrick J. Wong wrote:
> > > -#ifndef __XFS_ERRORTAG_H_
> > > +#if !defined(__XFS_ERRORTAG_H_) || defined(XFS_ERRTAG)
> >
> > Hrmm. So now xfs_errortag.h has two uses: one where we just #include
> > it without defining XFS_ERRTAG, and we get the XFS_ERRTAG_* values?
>
> Yes.
>
> > and I guess a broken XFS_ERRTAGS that isn't fully defined?
>
> Yes. I wouldn't call it broken, just not usable :)
Heh. :)
> > And then you're allowed to #include it again, provided you enclose that
> > inside a #define XFS_ERRTAG and a user of an XFS_ERRTAGS symbol, in
> > which case it actually spits out a usable XFS_ERRTAGS?
>
> Yes.
>
> > That could be documented better.
> >
> > "There are two ways to use this header file. The first way is to
> > #include it bare, which will define all the XFS_ERRTAG_* error injection
> > knobs for use with the XFS_TEST_ERROR macro. The second way is to
> > enclose the #include with a #define for an XFS_ERRTAG macro, in which
> > case the header will define an XFS_ERRTAGS macro that expands to one
> > XFS_ERRTAG use for each defined error injection knob."
>
> I can add that.
>
> > > +
> > > +#define XFS_ERRTAGS \
> >
> > Do you need to #undef XFS_ERRTAGS here to prevent the W=XXX build and/or
> > static tools from whining about redefined macros?
>
> XFS_ERRTAGS is redefined identically, which is allowed. And we can't
> undef it here, because we use the definition in the .c files. We could
> undef it after using it, but that feels a bit pointless.
Sorry, I should have spelled out what I meant explicitly:
#ifdef XFS_ERRTAG
# undef XFS_ERRTAGS
# define XFS_ERRTAGS \
<giant blob of error knobs>
#endif /* XFS_ERRTAG */
You undefine XFS_ERRAGS *before* redefining it, just to make it clear to
anyone reading the .h file that the exact definition of XFS_ERRTAGS in a
.c file can be fluid.
--D
> >
> > Also sorta wondering if for cleanliness this ought to be:
> >
> > #ifdef XFS_ERRTAG
> > # define XFS_ERRTAGS \
> > <giant table>
> > #endif /* XFS_ERRTAG */
> >
> > To avoid cluttering up the macro namespace if the file #include'ing
> > xfs_errortag.h didn't define XFS_ERRTAG and doesn't actually want the
> > ERRTAGS expansion?
>
> That does sound doable, let me give it a try.
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/6] xfs: constify xfs_errortag_random_default
2025-09-15 13:30 cleanup error tags Christoph Hellwig
` (4 preceding siblings ...)
2025-09-15 13:30 ` [PATCH 5/6] xfs: centralize error tag definitions Christoph Hellwig
@ 2025-09-15 13:30 ` Christoph Hellwig
2025-09-15 19:10 ` Darrick J. Wong
5 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2025-09-15 13:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
This table is never modified, so mark it const.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_error.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index ac895cd2bc0a..39830b252ac8 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -19,7 +19,7 @@
#define XFS_ERRTAG(_tag, _name, _default) \
[XFS_ERRTAG_##_tag] = (_default),
#include "xfs_errortag.h"
-static unsigned int xfs_errortag_random_default[] = { XFS_ERRTAGS };
+static const unsigned int xfs_errortag_random_default[] = { XFS_ERRTAGS };
#undef XFS_ERRTAG
struct xfs_errortag_attr {
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 6/6] xfs: constify xfs_errortag_random_default
2025-09-15 13:30 ` [PATCH 6/6] xfs: constify xfs_errortag_random_default Christoph Hellwig
@ 2025-09-15 19:10 ` Darrick J. Wong
0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2025-09-15 19:10 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Carlos Maiolino, linux-xfs
On Mon, Sep 15, 2025 at 06:30:42AM -0700, Christoph Hellwig wrote:
> This table is never modified, so mark it const.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Woot.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_error.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index ac895cd2bc0a..39830b252ac8 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -19,7 +19,7 @@
> #define XFS_ERRTAG(_tag, _name, _default) \
> [XFS_ERRTAG_##_tag] = (_default),
> #include "xfs_errortag.h"
> -static unsigned int xfs_errortag_random_default[] = { XFS_ERRTAGS };
> +static const unsigned int xfs_errortag_random_default[] = { XFS_ERRTAGS };
> #undef XFS_ERRTAG
>
> struct xfs_errortag_attr {
> --
> 2.47.2
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/6] xfs: remove the expr argument to XFS_TEST_ERROR
2025-09-16 16:28 cleanup error tags v2 Christoph Hellwig
@ 2025-09-16 16:28 ` Christoph Hellwig
0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2025-09-16 16:28 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs, Darrick J. Wong
Don't pass expr to XFS_TEST_ERROR. Most calls pass a constant false,
and the places that do pass an expression become cleaner by moving it
out.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/xfs/libxfs/xfs_ag_resv.c | 7 +++----
fs/xfs/libxfs/xfs_alloc.c | 5 ++---
fs/xfs/libxfs/xfs_attr_leaf.c | 2 +-
fs/xfs/libxfs/xfs_bmap.c | 17 ++++++++---------
fs/xfs/libxfs/xfs_btree.c | 2 +-
fs/xfs/libxfs/xfs_da_btree.c | 2 +-
fs/xfs/libxfs/xfs_dir2.c | 2 +-
fs/xfs/libxfs/xfs_exchmaps.c | 4 ++--
fs/xfs/libxfs/xfs_ialloc.c | 2 +-
fs/xfs/libxfs/xfs_inode_buf.c | 4 ++--
fs/xfs/libxfs/xfs_inode_fork.c | 3 +--
fs/xfs/libxfs/xfs_metafile.c | 2 +-
fs/xfs/libxfs/xfs_refcount.c | 7 +++----
fs/xfs/libxfs/xfs_rmap.c | 2 +-
fs/xfs/libxfs/xfs_rtbitmap.c | 2 +-
fs/xfs/scrub/cow_repair.c | 4 ++--
fs/xfs/scrub/repair.c | 2 +-
fs/xfs/xfs_attr_item.c | 2 +-
fs/xfs/xfs_buf.c | 4 ++--
fs/xfs/xfs_error.c | 5 ++---
fs/xfs/xfs_error.h | 10 +++++-----
fs/xfs/xfs_inode.c | 28 +++++++++++++---------------
fs/xfs/xfs_iomap.c | 4 ++--
fs/xfs/xfs_log.c | 8 ++++----
fs/xfs/xfs_trans_ail.c | 2 +-
25 files changed, 62 insertions(+), 70 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index fb79215a509d..8ac8230c3d3c 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -92,9 +92,8 @@ xfs_ag_resv_critical(
trace_xfs_ag_resv_critical(pag, type, avail);
/* Critically low if less than 10% or max btree height remains. */
- return XFS_TEST_ERROR(avail < orig / 10 ||
- avail < mp->m_agbtree_maxlevels,
- mp, XFS_ERRTAG_AG_RESV_CRITICAL);
+ return avail < orig / 10 || avail < mp->m_agbtree_maxlevels ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_AG_RESV_CRITICAL);
}
/*
@@ -203,7 +202,7 @@ __xfs_ag_resv_init(
return -EINVAL;
}
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_AG_RESV_FAIL))
error = -ENOSPC;
else
error = xfs_dec_fdblocks(mp, hidden_space, true);
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 000cc7f4a3ce..ad381c73abc4 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -3321,7 +3321,7 @@ xfs_agf_read_verify(
xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else {
fa = xfs_agf_verify(bp);
- if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
+ if (fa || XFS_TEST_ERROR(mp, XFS_ERRTAG_ALLOC_READ_AGF))
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
}
@@ -4019,8 +4019,7 @@ __xfs_free_extent(
ASSERT(len != 0);
ASSERT(type != XFS_AG_RESV_AGFL);
- if (XFS_TEST_ERROR(false, mp,
- XFS_ERRTAG_FREE_EXTENT))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_FREE_EXTENT))
return -EIO;
error = xfs_free_extent_fix_freelist(tp, pag, &agbp);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index fddb55605e0c..8508c845b27e 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -1225,7 +1225,7 @@ xfs_attr3_leaf_to_node(
trace_xfs_attr_leaf_to_node(args);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
error = -EIO;
goto out;
}
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index d954f9b8071f..17edc24d4bb0 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3662,8 +3662,7 @@ xfs_bmap_btalloc(
/* Trim the allocation back to the maximum an AG can fit. */
args.maxlen = min(ap->length, mp->m_ag_max_usable);
- if (unlikely(XFS_TEST_ERROR(false, mp,
- XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
+ if (unlikely(XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
error = xfs_bmap_exact_minlen_extent_alloc(ap, &args);
else if ((ap->datatype & XFS_ALLOC_USERDATA) &&
xfs_inode_is_filestream(ap->ip))
@@ -3849,7 +3848,7 @@ xfs_bmapi_read(
}
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -4200,7 +4199,7 @@ xfs_bmapi_write(
(XFS_BMAPI_PREALLOC | XFS_BMAPI_ZERO));
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -4545,7 +4544,7 @@ xfs_bmapi_remap(
(XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC));
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5679,7 +5678,7 @@ xfs_bmap_collapse_extents(
int logflags = 0;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5795,7 +5794,7 @@ xfs_bmap_insert_extents(
int logflags = 0;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5900,7 +5899,7 @@ xfs_bmap_split_extent(
int i = 0;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -6065,7 +6064,7 @@ xfs_bmap_finish_one(
trace_xfs_bmap_deferred(bi);
- if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE))
+ if (XFS_TEST_ERROR(tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE))
return -EIO;
switch (bi->bi_type) {
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index a61211d253f1..dbe9df8c3300 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -306,7 +306,7 @@ xfs_btree_check_block(
fa = __xfs_btree_check_block(cur, block, level, bp);
if (XFS_IS_CORRUPT(mp, fa != NULL) ||
- XFS_TEST_ERROR(false, mp, xfs_btree_block_errtag(cur))) {
+ XFS_TEST_ERROR(mp, xfs_btree_block_errtag(cur))) {
if (bp)
trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_btree_mark_sick(cur);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 723a0643b838..90f7fc219fcc 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -565,7 +565,7 @@ xfs_da3_split(
trace_xfs_da_split(state->args);
- if (XFS_TEST_ERROR(false, state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
+ if (XFS_TEST_ERROR(state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
return -EIO;
/*
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 1775abcfa04d..82a338458a51 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -223,7 +223,7 @@ xfs_dir_ino_validate(
bool ino_ok = xfs_verify_dir_ino(mp, ino);
if (XFS_IS_CORRUPT(mp, !ino_ok) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_DIR_INO_VALIDATE)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_DIR_INO_VALIDATE)) {
xfs_warn(mp, "Invalid inode number 0x%Lx",
(unsigned long long) ino);
return -EFSCORRUPTED;
diff --git a/fs/xfs/libxfs/xfs_exchmaps.c b/fs/xfs/libxfs/xfs_exchmaps.c
index 3f1d6a98c118..932ee4619e9e 100644
--- a/fs/xfs/libxfs/xfs_exchmaps.c
+++ b/fs/xfs/libxfs/xfs_exchmaps.c
@@ -616,7 +616,7 @@ xfs_exchmaps_finish_one(
return error;
}
- if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
+ if (XFS_TEST_ERROR(tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
return -EIO;
/* If we still have work to do, ask for a new transaction. */
@@ -882,7 +882,7 @@ xmi_ensure_delta_nextents(
&new_nextents))
return -EFBIG;
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
new_nextents > 10)
return -EFBIG;
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 750111634d9f..ca57a4e5ced9 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2706,7 +2706,7 @@ xfs_agi_read_verify(
xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else {
fa = xfs_agi_verify(bp);
- if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
+ if (fa || XFS_TEST_ERROR(mp, XFS_ERRTAG_IALLOC_READ_AGI))
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
}
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index aa13fc00afd7..b1812b2c3cce 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -61,8 +61,8 @@ xfs_inode_buf_verify(
di_ok = xfs_verify_magic16(bp, dip->di_magic) &&
xfs_dinode_good_version(mp, dip->di_version) &&
xfs_verify_agino_or_null(bp->b_pag, unlinked_ino);
- if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
- XFS_ERRTAG_ITOBP_INOTOBP))) {
+ if (unlikely(!di_ok ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_ITOBP_INOTOBP))) {
if (readahead) {
bp->b_flags &= ~XBF_DONE;
xfs_buf_ioerror(bp, -EIO);
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 4f99b90add55..1772d82f2d68 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -756,8 +756,7 @@ xfs_iext_count_extend(
if (nr_exts < ifp->if_nextents)
return -EFBIG;
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
- nr_exts > 10)
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) && nr_exts > 10)
return -EFBIG;
if (nr_exts > xfs_iext_max_nextents(has_large, whichfork)) {
diff --git a/fs/xfs/libxfs/xfs_metafile.c b/fs/xfs/libxfs/xfs_metafile.c
index 225923e463c4..b02e3d6c0868 100644
--- a/fs/xfs/libxfs/xfs_metafile.c
+++ b/fs/xfs/libxfs/xfs_metafile.c
@@ -121,7 +121,7 @@ xfs_metafile_resv_critical(
div_u64(mp->m_metafile_resv_target, 10)))
return true;
- return XFS_TEST_ERROR(false, mp, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
+ return XFS_TEST_ERROR(mp, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
}
/* Allocate a block from the metadata file's reservation. */
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 897784037483..2484dc9f6d7e 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1113,8 +1113,7 @@ xfs_refcount_still_have_space(
* refcount continue update "error" has been injected.
*/
if (cur->bc_refc.nr_ops > 2 &&
- XFS_TEST_ERROR(false, cur->bc_mp,
- XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE))
+ XFS_TEST_ERROR(cur->bc_mp, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE))
return false;
if (cur->bc_refc.nr_ops == 0)
@@ -1398,7 +1397,7 @@ xfs_refcount_finish_one(
trace_xfs_refcount_deferred(mp, ri);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
return -EIO;
/*
@@ -1511,7 +1510,7 @@ xfs_rtrefcount_finish_one(
trace_xfs_refcount_deferred(mp, ri);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
return -EIO;
/*
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index 3cdf50563fec..83e0488ff773 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -2690,7 +2690,7 @@ xfs_rmap_finish_one(
trace_xfs_rmap_deferred(mp, ri);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_RMAP_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_RMAP_FINISH_ONE))
return -EIO;
/*
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 5057536e586c..618061d898d4 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -1067,7 +1067,7 @@ xfs_rtfree_extent(
ASSERT(rbmip->i_itemp != NULL);
xfs_assert_ilocked(rbmip, XFS_ILOCK_EXCL);
- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_FREE_EXTENT))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_FREE_EXTENT))
return -EIO;
error = xfs_rtcheck_alloc_range(&args, start, len);
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index 38a246b8bf11..b2a83801412e 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -300,7 +300,7 @@ xrep_cow_find_bad(
* on the debugging knob, replace everything in the CoW fork.
*/
if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
- XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
+ XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
if (error)
@@ -385,7 +385,7 @@ xrep_cow_find_bad_rt(
* CoW fork and then scan for staging extents in the refcountbt.
*/
if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
- XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
+ XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
if (error)
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index d00c18954a26..efd5a7ccdf62 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -1110,7 +1110,7 @@ xrep_will_attempt(
return true;
/* Let debug users force us into the repair routines. */
- if (XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
+ if (XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
return true;
/* Metadata is corrupt or failed cross-referencing. */
diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
index 5eef3bc30bda..c3a593319bee 100644
--- a/fs/xfs/xfs_attr_item.c
+++ b/fs/xfs/xfs_attr_item.c
@@ -491,7 +491,7 @@ xfs_attr_finish_item(
/* Reset trans after EAGAIN cycle since the transaction is new */
args->trans = tp;
- if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) {
+ if (XFS_TEST_ERROR(args->dp->i_mount, XFS_ERRTAG_LARP)) {
error = -EIO;
goto out;
}
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index f9ef3b2a332a..8360e77b3215 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1299,7 +1299,7 @@ xfs_buf_bio_end_io(
if (bio->bi_status)
xfs_buf_ioerror(bp, blk_status_to_errno(bio->bi_status));
else if ((bp->b_flags & XBF_WRITE) && (bp->b_flags & XBF_ASYNC) &&
- XFS_TEST_ERROR(false, bp->b_mount, XFS_ERRTAG_BUF_IOERROR))
+ XFS_TEST_ERROR(bp->b_mount, XFS_ERRTAG_BUF_IOERROR))
xfs_buf_ioerror(bp, -EIO);
if (bp->b_flags & XBF_ASYNC) {
@@ -2084,7 +2084,7 @@ void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
* This allows userspace to disrupt buffer caching for debug/testing
* purposes.
*/
- if (XFS_TEST_ERROR(false, bp->b_mount, XFS_ERRTAG_BUF_LRU_REF))
+ if (XFS_TEST_ERROR(bp->b_mount, XFS_ERRTAG_BUF_LRU_REF))
lru_ref = 0;
atomic_set(&bp->b_lru_ref, lru_ref);
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index fac35ff3da65..44dd8aba0097 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -291,7 +291,6 @@ xfs_errortag_enabled(
bool
xfs_errortag_test(
struct xfs_mount *mp,
- const char *expression,
const char *file,
int line,
unsigned int error_tag)
@@ -317,8 +316,8 @@ xfs_errortag_test(
return false;
xfs_warn_ratelimited(mp,
-"Injecting error (%s) at file %s, line %d, on filesystem \"%s\"",
- expression, file, line, mp->m_super->s_id);
+"Injecting error at file %s, line %d, on filesystem \"%s\"",
+ file, line, mp->m_super->s_id);
return true;
}
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index fd60a008f9d2..8429c1ee86e7 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -41,10 +41,10 @@ extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
#ifdef DEBUG
extern int xfs_errortag_init(struct xfs_mount *mp);
extern void xfs_errortag_del(struct xfs_mount *mp);
-extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression,
- const char *file, int line, unsigned int error_tag);
-#define XFS_TEST_ERROR(expr, mp, tag) \
- ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag)))
+bool xfs_errortag_test(struct xfs_mount *mp, const char *file, int line,
+ unsigned int error_tag);
+#define XFS_TEST_ERROR(mp, tag) \
+ xfs_errortag_test((mp), __FILE__, __LINE__, (tag))
bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
#define XFS_ERRORTAG_DELAY(mp, tag) \
do { \
@@ -63,7 +63,7 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp);
#else
#define xfs_errortag_init(mp) (0)
#define xfs_errortag_del(mp)
-#define XFS_TEST_ERROR(expr, mp, tag) (expr)
+#define XFS_TEST_ERROR(mp, tag) (false)
#define XFS_ERRORTAG_DELAY(mp, tag) ((void)0)
#define xfs_errortag_add(mp, tag) (ENOSYS)
#define xfs_errortag_clearall(mp) (ENOSYS)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 9c39251961a3..5940faefe522 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2377,8 +2377,8 @@ xfs_iflush(
* error handling as the caller will shutdown and fail the buffer.
*/
error = -EFSCORRUPTED;
- if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC),
- mp, XFS_ERRTAG_IFLUSH_1)) {
+ if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC) ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_1)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad inode %llu magic number 0x%x, ptr "PTR_FMT,
__func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip);
@@ -2394,29 +2394,27 @@ xfs_iflush(
goto flush_out;
}
} else if (S_ISREG(VFS_I(ip)->i_mode)) {
- if (XFS_TEST_ERROR(
- ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
- ip->i_df.if_format != XFS_DINODE_FMT_BTREE,
- mp, XFS_ERRTAG_IFLUSH_3)) {
+ if ((ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
+ ip->i_df.if_format != XFS_DINODE_FMT_BTREE) ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_3)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad regular inode %llu, ptr "PTR_FMT,
__func__, ip->i_ino, ip);
goto flush_out;
}
} else if (S_ISDIR(VFS_I(ip)->i_mode)) {
- if (XFS_TEST_ERROR(
- ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
- ip->i_df.if_format != XFS_DINODE_FMT_BTREE &&
- ip->i_df.if_format != XFS_DINODE_FMT_LOCAL,
- mp, XFS_ERRTAG_IFLUSH_4)) {
+ if ((ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS &&
+ ip->i_df.if_format != XFS_DINODE_FMT_BTREE &&
+ ip->i_df.if_format != XFS_DINODE_FMT_LOCAL) ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_4)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad directory inode %llu, ptr "PTR_FMT,
__func__, ip->i_ino, ip);
goto flush_out;
}
}
- if (XFS_TEST_ERROR(ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af) >
- ip->i_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
+ if (ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af) >
+ ip->i_nblocks || XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_5)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: detected corrupt incore inode %llu, "
"total extents = %llu nblocks = %lld, ptr "PTR_FMT,
@@ -2425,8 +2423,8 @@ xfs_iflush(
ip->i_nblocks, ip);
goto flush_out;
}
- if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize,
- mp, XFS_ERRTAG_IFLUSH_6)) {
+ if (ip->i_forkoff > mp->m_sb.sb_inodesize ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_6)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: bad inode %llu, forkoff 0x%x, ptr "PTR_FMT,
__func__, ip->i_ino, ip->i_forkoff, ip);
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 2a74f2957341..2570d0a66047 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1554,7 +1554,7 @@ xfs_zoned_buffered_write_iomap_begin(
return error;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, XFS_DATA_FORK);
error = -EFSCORRUPTED;
goto out_unlock;
@@ -1728,7 +1728,7 @@ xfs_buffered_write_iomap_begin(
return error;
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, XFS_DATA_FORK);
error = -EFSCORRUPTED;
goto out_unlock;
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index c8a57e21a1d3..6e6442b0543c 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -969,8 +969,8 @@ xfs_log_unmount_write(
* counters will be recalculated. Refer to xlog_check_unmount_rec for
* more details.
*/
- if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
- XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
+ if (xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS) ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
xfs_alert(mp, "%s: will fix summary counters at next mount",
__func__);
return;
@@ -1240,7 +1240,7 @@ xlog_ioend_work(
/*
* Race to shutdown the filesystem if we see an error.
*/
- if (XFS_TEST_ERROR(error, log->l_mp, XFS_ERRTAG_IODONE_IOERR)) {
+ if (error || XFS_TEST_ERROR(log->l_mp, XFS_ERRTAG_IODONE_IOERR)) {
xfs_alert(log->l_mp, "log I/O error %d", error);
xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR);
}
@@ -1827,7 +1827,7 @@ xlog_sync(
* detects the bad CRC and attempts to recover.
*/
#ifdef DEBUG
- if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) {
+ if (XFS_TEST_ERROR(log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) {
iclog->ic_header.h_crc &= cpu_to_le32(0xAAAAAAAA);
iclog->ic_fail_crc = true;
xfs_warn(log->l_mp,
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 67c328d23e4a..38983c6777df 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -374,7 +374,7 @@ xfsaild_push_item(
* If log item pinning is enabled, skip the push and track the item as
* pinned. This can help induce head-behind-tail conditions.
*/
- if (XFS_TEST_ERROR(false, ailp->ail_log->l_mp, XFS_ERRTAG_LOG_ITEM_PIN))
+ if (XFS_TEST_ERROR(ailp->ail_log->l_mp, XFS_ERRTAG_LOG_ITEM_PIN))
return XFS_ITEM_PINNED;
/*
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread