]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mpt2sas: Fix secure erase premature termination
authorAndrey Grodzovsky <andrey2805@gmail.com>
Thu, 17 Nov 2016 01:15:08 +0000 (20:15 -0500)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Feb 2017 10:03:20 +0000 (11:03 +0100)
Problem:
This is a work around for a bug with LSI Fusion MPT SAS2 when
pefroming secure erase. Due to the very long time the operation
takes commands issued during the erase will time out and will trigger
execution of abort hook. Even though the abort hook is called for
the specific command which timed out this leads to entire device halt
(scsi_state terminated) and premature termination of the secured erase.

Fix:
Set device state to busy while erase in progress to reject any incoming
commands until the erase is done. The device is blocked any way during
this time and cannot execute any other command.
More data and logs can be found here -
https://drive.google.com/file/d/0B9ocOHYHbbS1Q3VMdkkzeWFkTjg/view

P.S
This is a backport from the same fix for mpt3sas driver intended
for pre-4.4 stable trees.

Signed-off-by: Andrey Grodzovsky <andrey2805@gmail.com>
Cc: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: PDL-MPT-FUSIONLINUX <MPT-FusionLinux.pdl@broadcom.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/scsi/mpt2sas/mpt2sas_scsih.c

index fe76185cd79ad478eeb5fe90ea0f55aacbefb4b6..64caa5ce3237cb25a1c80292a7ef2d65c31bf488 100644 (file)
@@ -3926,6 +3926,11 @@ _scsih_setup_direct_io(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
        }
 }
 
+static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
+{
+       return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
+}
+
 /**
  * _scsih_qcmd - main scsi request entry point
  * @scmd: pointer to scsi command object
@@ -3948,6 +3953,13 @@ _scsih_qcmd_lck(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
        u32 mpi_control;
        u16 smid;
 
+       /**
+       * Lock the device for any subsequent command until
+       * command is done.
+       */
+       if (ata_12_16_cmd(scmd))
+               scsi_internal_device_block(scmd->device);
+
        scmd->scsi_done = done;
        sas_device_priv_data = scmd->device->hostdata;
        if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
@@ -4454,6 +4466,9 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
        if (scmd == NULL)
                return 1;
 
+       if (ata_12_16_cmd(scmd))
+               scsi_internal_device_unblock(scmd->device, SDEV_RUNNING);
+
        mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
 
        if (mpi_reply == NULL) {