scsi: core: Add new flag BLIST_IGN_MEDIA_CHANGE
authorMartin Kepplinger <martin.kepplinger@puri.sm>
Sun, 4 Jul 2021 07:54:01 +0000 (09:54 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 22 Jul 2021 03:43:48 +0000 (23:43 -0400)
Add a new flag for devices that erroneously establish MEDIUM MAY HAVE
CHANGED unit attentions. Drivers can set this flag to make the SCSI
layer ignore media change events during resume.

[mkp: add "ignore" and add corresponding flag to struct scsi_device]

Link: https://lore.kernel.org/r/20210704075403.147114-2-martin.kepplinger@puri.sm
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_scan.c
include/scsi/scsi_device.h
include/scsi/scsi_devinfo.h

index b059bf2b61d4eb58ce285edf190dd72bc634321f..3faedf4970ec6f02aaf41c6911884788e522b426 100644 (file)
@@ -973,6 +973,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
        if (*bflags & BLIST_UNMAP_LIMIT_WS)
                sdev->unmap_limit_for_ws = 1;
 
+       if (*bflags & BLIST_IGN_MEDIA_CHANGE)
+               sdev->ignore_media_change = 1;
+
        sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
 
        if (*bflags & BLIST_TRY_VPD_PAGES)
index ac6ab16abee76aacdf46c240f7415570961da6bd..d1de21f799f476543c1be254d2e44497ed37c04a 100644 (file)
@@ -205,6 +205,7 @@ struct scsi_device {
        unsigned unmap_limit_for_ws:1;  /* Use the UNMAP limit for WRITE SAME */
        unsigned rpm_autosuspend:1;     /* Enable runtime autosuspend at device
                                         * creation time */
+       unsigned ignore_media_change:1; /* Ignore MEDIA CHANGE on resume */
 
        bool offline_already;           /* Device offline message logged */
 
index 3fdb322d4c4bbeaba31fc0ac0a5a912d924637f6..5d14adae21c78903188052187076eeec9644188a 100644 (file)
@@ -28,7 +28,8 @@
 #define BLIST_LARGELUN         ((__force blist_flags_t)(1ULL << 9))
 /* override additional length field */
 #define BLIST_INQUIRY_36       ((__force blist_flags_t)(1ULL << 10))
-#define __BLIST_UNUSED_11      ((__force blist_flags_t)(1ULL << 11))
+/* ignore MEDIA CHANGE unit attention after resuming from runtime suspend */
+#define BLIST_IGN_MEDIA_CHANGE ((__force blist_flags_t)(1ULL << 11))
 /* do not do automatic start on add */
 #define BLIST_NOSTARTONADD     ((__force blist_flags_t)(1ULL << 12))
 #define __BLIST_UNUSED_13      ((__force blist_flags_t)(1ULL << 13))
@@ -73,8 +74,7 @@
 #define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \
                               (__force blist_flags_t) \
                               ((__force __u64)__BLIST_LAST_USED - 1ULL)))
-#define __BLIST_UNUSED_MASK (__BLIST_UNUSED_11 | \
-                            __BLIST_UNUSED_13 | \
+#define __BLIST_UNUSED_MASK (__BLIST_UNUSED_13 | \
                             __BLIST_UNUSED_14 | \
                             __BLIST_UNUSED_15 | \
                             __BLIST_UNUSED_16 | \