Re: 答复: [PATCH v5 1/2] scsi: sd: mark disk dead on surprise host removal to avoid I/O hang
From: Bart Van Assche
Date: Tue Oct 13 2026 - 15:29:35 EST
On 10/12/26 7:14 PM, 胡连勤 wrote:
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.cWhy is a new member variable introduced in struct Scsi_Host instead of
index 064c7fc8e368..3a5a0cac2b78 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -930,6 +930,9 @@ static void quiesce_and_remove_host(struct us_data *us)
if (us->pusb_dev->state == USB_STATE_NOTATTACHED) {
set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
wake_up(&us->delay_wait);
+
+ /* Device is physically gone, cannot handle I/O */
+ set_bit(SHOST_SURPRISE_REMOVAL, &host->flags);
}
e.g. changing the state of all SCSI devices that are associated with the
host to SDEV_OFFLINE?
Thanks,
Bart.