Commit f79d5fda authored by Akinobu Mita's avatar Akinobu Mita Committed by Christoph Hellwig

nvme: enable to inject errors into admin commands

This enables to inject errors into the commands submitted to the admin
queue.

It is useful to test error handling in the controller initialization.

	# echo 100 > /sys/kernel/debug/nvme0/fault_inject/probability
	# echo 1 > /sys/kernel/debug/nvme0/fault_inject/times
	# echo 10 > /sys/kernel/debug/nvme0/fault_inject/space
	# nvme reset /dev/nvme0
	# dmesg
	...
	nvme nvme0: Could not set queue count (16385)
	nvme nvme0: IO queues not created
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: default avatarMinwoo Im <minwoo.im.dev@gmail.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent a3646451
...@@ -3722,6 +3722,7 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl); ...@@ -3722,6 +3722,7 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);
void nvme_uninit_ctrl(struct nvme_ctrl *ctrl) void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
{ {
nvme_fault_inject_fini(&ctrl->fault_inject);
dev_pm_qos_hide_latency_tolerance(ctrl->device); dev_pm_qos_hide_latency_tolerance(ctrl->device);
cdev_device_del(&ctrl->cdev, ctrl->device); cdev_device_del(&ctrl->cdev, ctrl->device);
} }
...@@ -3817,6 +3818,8 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, ...@@ -3817,6 +3818,8 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
dev_pm_qos_update_user_latency_tolerance(ctrl->device, dev_pm_qos_update_user_latency_tolerance(ctrl->device,
min(default_ps_max_latency_us, (unsigned long)S32_MAX)); min(default_ps_max_latency_us, (unsigned long)S32_MAX));
nvme_fault_inject_init(&ctrl->fault_inject, dev_name(ctrl->device));
return 0; return 0;
out_free_name: out_free_name:
kfree_const(ctrl->device->kobj.name); kfree_const(ctrl->device->kobj.name);
......
...@@ -60,9 +60,6 @@ void nvme_should_fail(struct request *req) ...@@ -60,9 +60,6 @@ void nvme_should_fail(struct request *req)
struct nvme_fault_inject *fault_inject = NULL; struct nvme_fault_inject *fault_inject = NULL;
u16 status; u16 status;
/*
* make sure this request is coming from a valid namespace
*/
if (disk) { if (disk) {
struct nvme_ns *ns = disk->private_data; struct nvme_ns *ns = disk->private_data;
...@@ -70,6 +67,8 @@ void nvme_should_fail(struct request *req) ...@@ -70,6 +67,8 @@ void nvme_should_fail(struct request *req)
fault_inject = &ns->fault_inject; fault_inject = &ns->fault_inject;
else else
WARN_ONCE(1, "No namespace found for request\n"); WARN_ONCE(1, "No namespace found for request\n");
} else {
fault_inject = &nvme_req(req)->ctrl->fault_inject;
} }
if (fault_inject && should_fail(&fault_inject->attr, 1)) { if (fault_inject && should_fail(&fault_inject->attr, 1)) {
......
...@@ -256,6 +256,8 @@ struct nvme_ctrl { ...@@ -256,6 +256,8 @@ struct nvme_ctrl {
struct page *discard_page; struct page *discard_page;
unsigned long discard_page_busy; unsigned long discard_page_busy;
struct nvme_fault_inject fault_inject;
}; };
enum nvme_iopolicy { enum nvme_iopolicy {
......
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