Skip to content

Commit e2d62bf

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: move the guts of XFS_ERRORTAG_DELAY out of line
Mirror what is done for the more common XFS_ERRORTAG_TEST version, and also only look at the error tag value once now that we can easily have a local variable. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent b8862a0 commit e2d62bf

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

fs/xfs/xfs_error.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,27 @@ xfs_errortag_test(
144144
return true;
145145
}
146146

147+
void
148+
xfs_errortag_delay(
149+
struct xfs_mount *mp,
150+
const char *file,
151+
int line,
152+
unsigned int error_tag)
153+
{
154+
unsigned int delay = mp->m_errortag[error_tag];
155+
156+
might_sleep();
157+
158+
if (!delay)
159+
return;
160+
161+
xfs_warn_ratelimited(mp,
162+
"Injecting %ums delay at file %s, line %d, on filesystem \"%s\"",
163+
delay, file, line,
164+
mp->m_super->s_id);
165+
mdelay(delay);
166+
}
167+
147168
int
148169
xfs_errortag_add(
149170
struct xfs_mount *mp,

fs/xfs/xfs_error.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,10 @@ bool xfs_errortag_test(struct xfs_mount *mp, const char *file, int line,
4040
unsigned int error_tag);
4141
#define XFS_TEST_ERROR(mp, tag) \
4242
xfs_errortag_test((mp), __FILE__, __LINE__, (tag))
43-
bool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag);
43+
void xfs_errortag_delay(struct xfs_mount *mp, const char *file, int line,
44+
unsigned int error_tag);
4445
#define XFS_ERRORTAG_DELAY(mp, tag) \
45-
do { \
46-
might_sleep(); \
47-
if (!mp->m_errortag[tag]) \
48-
break; \
49-
xfs_warn_ratelimited((mp), \
50-
"Injecting %ums delay at file %s, line %d, on filesystem \"%s\"", \
51-
(mp)->m_errortag[(tag)], __FILE__, __LINE__, \
52-
(mp)->m_super->s_id); \
53-
mdelay((mp)->m_errortag[(tag)]); \
54-
} while (0)
55-
46+
xfs_errortag_delay((mp), __FILE__, __LINE__, (tag))
5647
int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
5748
int xfs_errortag_clearall(struct xfs_mount *mp);
5849
#else

0 commit comments

Comments
 (0)