From: Wenchao Hao <haowenchao2@xxxxxxxxxx> Add new param lun_eh to control if enable LUN based error handler, since virtio_scsi did not define other further reset callbacks, it is not necessary to fallback to further recover any more, so set the LUN error handler with fallback set to 0. Signed-off-by: Wenchao Hao <haowenchao2@xxxxxxxxxx> --- drivers/scsi/virtio_scsi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 21ce3e940192..99276ad0e441 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -28,6 +28,7 @@ #include <scsi/scsi_cmnd.h> #include <scsi/scsi_tcq.h> #include <scsi/scsi_devinfo.h> +#include <scsi/scsi_eh.h> #include <linux/seqlock.h> #include "sd.h" @@ -41,6 +42,10 @@ module_param(virtscsi_poll_queues, uint, 0644); MODULE_PARM_DESC(virtscsi_poll_queues, "The number of dedicated virtqueues for polling I/O"); +static bool lun_eh; +module_param(lun_eh, bool, 0444); +MODULE_PARM_DESC(lun_eh, "LUN based error handle (def=0)"); + /* Command queue element */ struct virtio_scsi_cmd { struct scsi_cmnd *sc; @@ -682,9 +687,18 @@ static int virtscsi_device_alloc(struct scsi_device *sdevice) */ sdevice->sdev_bflags = BLIST_TRY_VPD_PAGES; + if (lun_eh) + return scsi_device_setup_eh(sdevice, 0); + return 0; } +static void virtscsi_device_destroy(struct scsi_device *sdevice) +{ + if (lun_eh) + return scsi_device_clear_eh(sdevice); +} + /** * virtscsi_change_queue_depth() - Change a virtscsi target's queue depth @@ -801,7 +815,7 @@ static const struct scsi_host_template virtscsi_host_template = { .eh_device_reset_handler = virtscsi_device_reset, .eh_timed_out = virtscsi_eh_timed_out, .sdev_init = virtscsi_device_alloc, - + .sdev_destroy = virtscsi_device_destroy, .dma_boundary = UINT_MAX, .map_queues = virtscsi_map_queues, .track_queue_depth = 1, -- 2.33.0