Commit 596444e7 authored by Bart Van Assche's avatar Bart Van Assche Committed by Jens Axboe

null_blk: Add support for init_hctx() fault injection

This makes it possible to test the error path in blk_mq_realloc_hw_ctxs()
and also several error paths in null_blk.
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Cc: Johannes Thumshirn <jth@kernel.org>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 9b03b713
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION #ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION
static DECLARE_FAULT_ATTR(null_timeout_attr); static DECLARE_FAULT_ATTR(null_timeout_attr);
static DECLARE_FAULT_ATTR(null_requeue_attr); static DECLARE_FAULT_ATTR(null_requeue_attr);
static DECLARE_FAULT_ATTR(null_init_hctx_attr);
#endif #endif
static inline u64 mb_per_tick(int mbps) static inline u64 mb_per_tick(int mbps)
...@@ -101,6 +102,9 @@ module_param_string(timeout, g_timeout_str, sizeof(g_timeout_str), 0444); ...@@ -101,6 +102,9 @@ module_param_string(timeout, g_timeout_str, sizeof(g_timeout_str), 0444);
static char g_requeue_str[80]; static char g_requeue_str[80];
module_param_string(requeue, g_requeue_str, sizeof(g_requeue_str), 0444); module_param_string(requeue, g_requeue_str, sizeof(g_requeue_str), 0444);
static char g_init_hctx_str[80];
module_param_string(init_hctx, g_init_hctx_str, sizeof(g_init_hctx_str), 0444);
#endif #endif
static int g_queue_mode = NULL_Q_MQ; static int g_queue_mode = NULL_Q_MQ;
...@@ -1451,6 +1455,11 @@ static int null_init_hctx(struct blk_mq_hw_ctx *hctx, void *driver_data, ...@@ -1451,6 +1455,11 @@ static int null_init_hctx(struct blk_mq_hw_ctx *hctx, void *driver_data,
struct nullb *nullb = hctx->queue->queuedata; struct nullb *nullb = hctx->queue->queuedata;
struct nullb_queue *nq; struct nullb_queue *nq;
#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION
if (g_init_hctx_str[0] && should_fail(&null_init_hctx_attr, 1))
return -EFAULT;
#endif
nq = &nullb->queues[hctx_idx]; nq = &nullb->queues[hctx_idx];
hctx->driver_data = nq; hctx->driver_data = nq;
null_init_queue(nullb, nq); null_init_queue(nullb, nq);
...@@ -1683,6 +1692,8 @@ static bool null_setup_fault(void) ...@@ -1683,6 +1692,8 @@ static bool null_setup_fault(void)
return false; return false;
if (!__null_setup_fault(&null_requeue_attr, g_requeue_str)) if (!__null_setup_fault(&null_requeue_attr, g_requeue_str))
return false; return false;
if (!__null_setup_fault(&null_init_hctx_attr, g_init_hctx_str))
return false;
#endif #endif
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment