diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 873c920eb0cf063d6ded139155eb1dd4d2c8a50e..021e25a0e5cf750285b62c8e191ae805b90d2c37 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3809,9 +3809,13 @@ static int sd_probe(struct device *dev) static int sd_remove(struct device *dev) { struct scsi_disk *sdkp = dev_get_drvdata(dev); + struct scsi_device *sdev = sdkp->device; scsi_autopm_get_device(sdkp->device); + if (sdev->host->hostt->mark_dead && sdev->host->hostt->mark_dead(sdev->host)) + blk_mark_disk_dead(sdkp->disk); + device_del(&sdkp->disk_dev); del_gendisk(sdkp->disk); if (!sdkp->suspended) diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 12cf9940e5b6759167f9ae7450df8af92a85c63a..2a62d85b7f2a36278f8f296c928eabd1eef469a0 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -496,6 +496,16 @@ static int bus_reset(struct scsi_cmnd *srb) return result < 0 ? FAILED : SUCCESS; } +static bool device_dead(struct Scsi_Host *shost) +{ + struct us_data *us = host_to_us(shost); + + if (us->pusb_dev->state < USB_STATE_CONFIGURED) + return true; + + return false; +} + /* * Report a driver-initiated device reset to the SCSI layer. * Calling this for a SCSI-initiated reset is unnecessary but harmless. @@ -634,7 +644,7 @@ static const struct scsi_host_template usb_stor_host_template = { .eh_abort_handler = command_abort, .eh_device_reset_handler = device_reset, .eh_bus_reset_handler = bus_reset, - + .mark_dead = device_dead, /* queue commands only, only one command per LUN */ .can_queue = 1, diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index f794cb39cc3130d334f7073194c5b1d863b97e00..09873f6af9cbebdc2aaa54c91dea634a2d1d5402 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -805,6 +805,15 @@ static int uas_eh_device_reset_handler(struct scsi_cmnd *cmnd) return SUCCESS; } +static bool uas_device_dead(struct Scsi_Host *shost) +{ + struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; + + if (devinfo->udev->state < USB_STATE_CONFIGURED) + return true; + return false; +} + static int uas_target_alloc(struct scsi_target *starget) { struct uas_dev_info *devinfo = (struct uas_dev_info *) @@ -904,6 +913,7 @@ static const struct scsi_host_template uas_host_template = { .module = THIS_MODULE, .name = "uas", .queuecommand = uas_queuecommand, + .mark_dead = uas_device_dead, .target_alloc = uas_target_alloc, .slave_alloc = uas_slave_alloc, .slave_configure = uas_slave_configure, diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 9232930d73c43ffc37caa82e6c53efaf923cf96f..8c35a34da632750a4a7066e47b51ddd054304c5d 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -154,7 +154,7 @@ struct scsi_host_template { int (* eh_target_reset_handler)(struct scsi_cmnd *); int (* eh_bus_reset_handler)(struct scsi_cmnd *); int (* eh_host_reset_handler)(struct scsi_cmnd *); - + bool (*mark_dead)(struct Scsi_Host *); /* * Before the mid layer attempts to scan for a new device where none * currently exists, it will call this entry in your driver. Should