@@ -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,