Skip to content
Snippets Groups Projects
  1. Nov 06, 2018
    • Arnd Bergmann's avatar
      scsi: myrs: avoid stack overflow warning · 77409c4c
      Arnd Bergmann authored
      
      Putting a 1024 byte data structure on the stack is generally a bad idea.
      On 32-bit systems, it also triggers a compile-time warning when building
      with -Og:
      
      drivers/scsi/myrs.c: In function 'myrs_get_ctlr_info':
      drivers/scsi/myrs.c:212:1: error: the frame size of 1028 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
      
      We only really need three members of the structure, so just read them
      manually here instead of copying the entire structure.
      
      Fixes: 77266186 ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      77409c4c
    • Arnd Bergmann's avatar
      scsi: lpfc: fix remoteport access · f8d29432
      Arnd Bergmann authored
      
      The addition of a spinlock in lpfc_debugfs_nodelist_data() introduced
      a bug that lets us not skip NULL pointers correctly, as noticed by
      gcc-8:
      
      drivers/scsi/lpfc/lpfc_debugfs.c: In function 'lpfc_debugfs_nodelist_data.constprop':
      drivers/scsi/lpfc/lpfc_debugfs.c:728:13: error: 'nrport' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         if (nrport->port_role & FC_PORT_ROLE_NVME_INITIATOR)
      
      This changes the logic back to what it was, while keeping the added
      spinlock.
      
      Fixes: 9e210178 ("scsi: lpfc: Synchronize access to remoteport via rport")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      f8d29432
    • Arnd Bergmann's avatar
      scsi: myrb: fix sprintf buffer overflow warning · f8f4adc1
      Arnd Bergmann authored
      
      gcc warns that the 12 byte fw_version field might not be long enough to
      contain the generated firmware name string:
      
      drivers/scsi/myrb.c: In function 'myrb_get_hba_config':
      drivers/scsi/myrb.c:1052:38: error: '%02d' directive writing between 2 and 3 bytes into a region of size between 2 and 5 [-Werror=format-overflow=]
        sprintf(cb->fw_version, "%d.%02d-%c-%02d",
                                            ^~~~
      drivers/scsi/myrb.c:1052:26: note: directive argument in the range [0, 255]
        sprintf(cb->fw_version, "%d.%02d-%c-%02d",
                                ^~~~~~~~~~~~~~~~~
      drivers/scsi/myrb.c:1052:2: note: 'sprintf' output between 10 and 14 bytes into a destination of size 12
        sprintf(cb->fw_version, "%d.%02d-%c-%02d",
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         enquiry2->fw.major_version,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
         enquiry2->fw.minor_version,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
         enquiry2->fw.firmware_type,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
         enquiry2->fw.turn_id);
         ~~~~~~~~~~~~~~~~~~~~~
      
      I have not checked whether there are appropriate range checks before the
      sprintf, but there is a range check after it that will bail out in case
      of out of range version numbers. This means we can simply use snprintf()
      instead of sprintf() to limit the output buffer size, and it will work
      correctly.
      
      Fixes: 081ff398 ("scsi: myrb: Add Mylex RAID controller (block interface)")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      f8f4adc1
  2. Nov 01, 2018
  3. Oct 25, 2018
    • Damien Le Moal's avatar
      block: Introduce blk_revalidate_disk_zones() · bf505456
      Damien Le Moal authored
      
      Drivers exposing zoned block devices have to initialize and maintain
      correctness (i.e. revalidate) of the device zone bitmaps attached to
      the device request queue (seq_zones_bitmap and seq_zones_wlock).
      
      To simplify coding this, introduce a generic helper function
      blk_revalidate_disk_zones() suitable for most (and likely all) cases.
      This new function always update the seq_zones_bitmap and seq_zones_wlock
      bitmaps as well as the queue nr_zones field when called for a disk
      using a request based queue. For a disk using a BIO based queue, only
      the number of zones is updated since these queues do not have
      schedulers and so do not need the zone bitmaps.
      
      With this change, the zone bitmap initialization code in sd_zbc.c can be
      replaced with a call to this function in sd_zbc_read_zones(), which is
      called from the disk revalidate block operation method.
      
      A call to blk_revalidate_disk_zones() is also added to the null_blk
      driver for devices created with the zoned mode enabled.
      
      Finally, to ensure that zoned devices created with dm-linear or
      dm-flakey expose the correct number of zones through sysfs, a call to
      blk_revalidate_disk_zones() is added to dm_table_set_restrictions().
      
      The zone bitmaps allocated and initialized with
      blk_revalidate_disk_zones() are freed automatically from
      __blk_release_queue() using the block internal function
      blk_queue_free_zone_bitmaps().
      
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Reviewed-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      bf505456
    • Christoph Hellwig's avatar
      block: add a report_zones method · e76239a3
      Christoph Hellwig authored
      
      Dispatching a report zones command through the request queue is a major
      pain due to the command reply payload rewriting necessary. Given that
      blkdev_report_zones() is executing everything synchronously, implement
      report zones as a block device file operation instead, allowing major
      simplification of the code in many places.
      
      sd, null-blk, dm-linear and dm-flakey being the only block device
      drivers supporting exposing zoned block devices, these drivers are
      modified to provide the device side implementation of the
      report_zones() block device file operation.
      
      For device mappers, a new report_zones() target type operation is
      defined so that the upper block layer calls blkdev_report_zones() can
      be propagated down to the underlying devices of the dm targets.
      Implementation for this new operation is added to the dm-linear and
      dm-flakey targets.
      
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      [Damien]
      * Changed method block_device argument to gendisk
      * Various bug fixes and improvements
      * Added support for null_blk, dm-linear and dm-flakey.
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Reviewed-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      e76239a3
    • Damien Le Moal's avatar
      scsi: sd_zbc: Fix sd_zbc_check_zones() error checks · 5f832a39
      Damien Le Moal authored
      
      The unsigned 32 bits overflow check for the zone size value is already
      done within sd_zbc_check_zones() with the test:
      
      } else if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
      
      so there is no need to check again for an out of range value in
      sd_zbc_read_zones(). Simplify the code and fix sd_zbc_check_zones()
      error return to -EFBIG instead of -ENODEV if the zone size is too large.
      Change the return type of sd_zbc_check_zones() to an int for the error
      code and return the zone size (zone_blocks) through a u32 pointer to
      avoid overflowing the signed 32 return value.
      
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Acked-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      5f832a39
    • Damien Le Moal's avatar
      scsi: sd_zbc: Reduce boot device scan and revalidate time · d2e428e4
      Damien Le Moal authored
      
      Handling checks of ZBC device capacity using the max_lba field of the
      REPORT ZONES command reply for disks with rc_basis == 0 can be done
      using the same report zones command reply used to check the "same"
      field.
      
      Avoid executing a report zones command solely to check the disk capacity
      by merging sd_zbc_check_capacity() into sd_zbc_check_zone_size() and
      renaming that function to sd_zbc_check_zones(). This removes a costly
      execution of a full report zones command and so reduces device scan
      duration at boot time as well as the duration of disk revalidate calls.
      
      Furthermore, setting the partial report bit in the REPORT ZONES command
      cdb can significantly reduce this command execution time as the device
      does not have to count and report the total number of zones that could
      be reported assuming a large enough reply buffer. A non-partial zone
      report is necessary only for the first execution of report zones used to
      check the same field value (to ensure that this value applies to all
      zones of the disk). All other calls to sd_zbc_report_zones() can use a
      partial report to reduce execution time.
      
      Using a 14 TB ZBC disk, these simple changes reduce device scan time at
      boot from about 3.5s down to about 900ms. Disk revalidate times are also
      reduced from about 450ms down to 230ms.
      
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Acked-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      d2e428e4
    • Damien Le Moal's avatar
      scsi: sd_zbc: Rearrange code · 7f9d35d2
      Damien Le Moal authored
      
      Move the urswrz check out of sd_zbc_read_zones() and into
      sd_zbc_read_zoned_characteristics() where that value is obtained (read
      from the disk zoned characteristics VPD page). Since this function now
      does more than simply reading the VPD page, rename it to
      sd_zbc_check_zoned_characteristics().
      Also fix the error message displayed when reading that VPD page fails.
      
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
      Acked-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      7f9d35d2
  4. Oct 24, 2018
  5. Oct 19, 2018
  6. Oct 18, 2018
Loading