Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 20 Jan 2017 19:47:18 +0000 (11:47 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 20 Jan 2017 19:47:18 +0000 (11:47 -0800)
Pull SCSI fixes from James Bottomley:
 "This is a set of 12 fixes including the mpt3sas one that was causing
  hangs on ATA passthrough.

  The others are a couple of zoned block device fixes, a SAS device
  detection bug which lead to SATA drives not being matched to bays, two
  qla2xxx MSI fixes, a qla2xxx req for rsp confusion caused by cut and
  paste, and a few other minor fixes"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: mpt3sas: fix hang on ata passthrough commands
  scsi: lpfc: Set elsiocb contexts to NULL after freeing it
  scsi: sd: Ignore zoned field for host-managed devices
  scsi: sd: Fix wrong DPOFUA disable in sd_read_cache_type
  scsi: bfa: fix wrongly initialized variable in bfad_im_bsg_els_ct_request()
  scsi: ses: Fix SAS device detection in enclosure
  scsi: libfc: Fix variable name in fc_set_wwpn
  scsi: lpfc: avoid double free of resource identifiers
  scsi: qla2xxx: remove irq_affinity_notifier
  scsi: qla2xxx: fix MSI-X vector affinity
  scsi: qla2xxx: Fix apparent cut-n-paste error.
  scsi: qla2xxx: Get mutex lock before checking optrom_state

1  2 
drivers/scsi/sd.c

diff --combined drivers/scsi/sd.c
@@@ -836,6 -836,7 +836,6 @@@ static int sd_setup_write_same_cmnd(str
        struct bio *bio = rq->bio;
        sector_t sector = blk_rq_pos(rq);
        unsigned int nr_sectors = blk_rq_sectors(rq);
 -      unsigned int nr_bytes = blk_rq_bytes(rq);
        int ret;
  
        if (sdkp->device->no_write_same)
  
        cmd->transfersize = sdp->sector_size;
        cmd->allowed = SD_MAX_RETRIES;
 -
 -      /*
 -       * For WRITE_SAME the data transferred in the DATA IN buffer is
 -       * different from the amount of data actually written to the target.
 -       *
 -       * We set up __data_len to the amount of data transferred from the
 -       * DATA IN buffer so that blk_rq_map_sg set up the proper S/G list
 -       * to transfer a single sector of data first, but then reset it to
 -       * the amount of data to be written right after so that the I/O path
 -       * knows how much to actually write.
 -       */
 -      rq->__data_len = sdp->sector_size;
 -      ret = scsi_init_io(cmd);
 -      rq->__data_len = nr_bytes;
 -      return ret;
 +      return scsi_init_io(cmd);
  }
  
  static int sd_setup_flush_cmnd(struct scsi_cmnd *cmd)
@@@ -2585,7 -2600,8 +2585,8 @@@ sd_read_cache_type(struct scsi_disk *sd
                if (sdp->broken_fua) {
                        sd_first_printk(KERN_NOTICE, sdkp, "Disabling FUA\n");
                        sdkp->DPOFUA = 0;
-               } else if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) {
+               } else if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw &&
+                          !sdkp->device->use_16_for_rw) {
                        sd_first_printk(KERN_NOTICE, sdkp,
                                  "Uses READ/WRITE(6), disabling FUA\n");
                        sdkp->DPOFUA = 0;
@@@ -2768,13 -2784,21 +2769,21 @@@ static void sd_read_block_characteristi
                queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);
        }
  
-       sdkp->zoned = (buffer[8] >> 4) & 3;
-       if (sdkp->zoned == 1)
-               q->limits.zoned = BLK_ZONED_HA;
-       else if (sdkp->device->type == TYPE_ZBC)
+       if (sdkp->device->type == TYPE_ZBC) {
+               /* Host-managed */
                q->limits.zoned = BLK_ZONED_HM;
-       else
-               q->limits.zoned = BLK_ZONED_NONE;
+       } else {
+               sdkp->zoned = (buffer[8] >> 4) & 3;
+               if (sdkp->zoned == 1)
+                       /* Host-aware */
+                       q->limits.zoned = BLK_ZONED_HA;
+               else
+                       /*
+                        * Treat drive-managed devices as
+                        * regular block devices.
+                        */
+                       q->limits.zoned = BLK_ZONED_NONE;
+       }
        if (blk_queue_is_zoned(q) && sdkp->first_scan)
                sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n",
                      q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware");