* [PATCH] xfs: Check for m_errortag initialization in xfs_errortag_test
@ 2017-06-30 13:03 Carlos Maiolino
2017-06-30 16:45 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Carlos Maiolino @ 2017-06-30 13:03 UTC (permalink / raw)
To: linux-xfs
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>
---
fs/xfs/xfs_error.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 26c32bc..2f4feb9 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -233,6 +233,17 @@ xfs_errortag_test(
{
unsigned int randfactor;
+ /*
+ * To be able to use error injection anywhere, we need to ensure error
+ * injection mechanism is already initialized.
+ *
+ * Code paths like I/O completion can be called before the
+ * initialization is complete, but be able to inject errors in such
+ * places is still useful.
+ */
+ if (!mp->m_errortag)
+ return false;
+
ASSERT(error_tag < XFS_ERRTAG_MAX);
randfactor = mp->m_errortag[error_tag];
if (!randfactor || prandom_u32() % randfactor)
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs: Check for m_errortag initialization in xfs_errortag_test
2017-06-30 13:03 [PATCH] xfs: Check for m_errortag initialization in xfs_errortag_test Carlos Maiolino
@ 2017-06-30 16:45 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2017-06-30 16:45 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
On Fri, Jun 30, 2017 at 03:03:01PM +0200, Carlos Maiolino wrote:
> 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>
Ahah, hadn't realized that. Looks good,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/xfs_error.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index 26c32bc..2f4feb9 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -233,6 +233,17 @@ xfs_errortag_test(
> {
> unsigned int randfactor;
>
> + /*
> + * To be able to use error injection anywhere, we need to ensure error
> + * injection mechanism is already initialized.
> + *
> + * Code paths like I/O completion can be called before the
> + * initialization is complete, but be able to inject errors in such
> + * places is still useful.
> + */
> + if (!mp->m_errortag)
> + return false;
> +
> ASSERT(error_tag < XFS_ERRTAG_MAX);
> randfactor = mp->m_errortag[error_tag];
> if (!randfactor || prandom_u32() % randfactor)
> --
> 2.9.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-30 16:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-30 13:03 [PATCH] xfs: Check for m_errortag initialization in xfs_errortag_test Carlos Maiolino
2017-06-30 16:45 ` Darrick J. Wong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.