aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Maiolino <cmaiolino@redhat.com>2017-06-30 12:46:07 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2017-07-02 00:08:47 -0400
commitd04c241c669209667dd8f44335591246e601139a (patch)
tree932d6e33012a971a1b726da229164d9bb7c7da09
parent50e0bdbe9f48f98bb02eac7030d682f4716884ae (diff)
xfs: Check for m_errortag initialization in xfs_errortag_test
While adding error injection into IO completion, I notice the lack of initialization check in xfs_errortag_test(), make the error injection mechanism unable to be used there. IO completion is executed a few times before the error injection mechanism is initialized, so to be safer, make xfs_errortag_test() check if the errortag is properly initialized. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r--fs/xfs/xfs_error.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 26c32bc5cd34..2f4feb959bfb 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -233,6 +233,17 @@ xfs_errortag_test(
233{ 233{
234 unsigned int randfactor; 234 unsigned int randfactor;
235 235
236 /*
237 * To be able to use error injection anywhere, we need to ensure error
238 * injection mechanism is already initialized.
239 *
240 * Code paths like I/O completion can be called before the
241 * initialization is complete, but be able to inject errors in such
242 * places is still useful.
243 */
244 if (!mp->m_errortag)
245 return false;
246
236 ASSERT(error_tag < XFS_ERRTAG_MAX); 247 ASSERT(error_tag < XFS_ERRTAG_MAX);
237 randfactor = mp->m_errortag[error_tag]; 248 randfactor = mp->m_errortag[error_tag];
238 if (!randfactor || prandom_u32() % randfactor) 249 if (!randfactor || prandom_u32() % randfactor)