SCSI fixes for 4.6-rc2
James Bottomley
maintainerThis is a set of 8 fixes. Two are trivial gcc-6 updates (brace additions and unused variable removal). There's a couple of cxlflash regressions, a correction for sd being overly chatty on revalidation (causing excess log increases). A VPD issue which could crash USB devices because they seem very intolerant to VPD inquiries, an ALUA deadlock fix and a mpt3sas buffer overrun fix.
The patch is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes
The short changelog is:
Arnd Bergmann (1):
aacraid: add missing curly braces
Bart Van Assche (2):
scsi_dh_alua: Fix a recently introduced deadlock
scsi: Declare local symbols static
Calvin Owens (1):
mpt3sas: Don't overreach ioc->reply_post[] during initialization
Hannes Reinecke (1):
scsi: Do not attach VPD to devices that don't support it
Manoj N. Kumar (2):
cxlflash: Move to exponential back-off when cmd_room is not available
cxlflash: Fix regression issue with re-ordering patch
Martin K. Petersen (1):
sd: Fix excessive capacity printing on devices with blocks bigger than 512 bytes
And the diffstat
drivers/scsi/aacraid/linit.c | 3 +- drivers/scsi/cxlflash/main.c | 138 ++++++++++++++++++++--------- drivers/scsi/cxlflash/main.h | 5 +- drivers/scsi/device_handler/scsi_dh_alua.c | 4 +- drivers/scsi/mpt3sas/mpt3sas_base.c | 33 ++++--- drivers/scsi/scsi.c | 3 +- drivers/scsi/scsi_sysfs.c | 8 +- drivers/scsi/sd.c | 47 ++-------- drivers/scsi/sd.h | 7 +- include/scsi/scsi_device.h | 25 ++++++ 10 files changed, 164 insertions(+), 109 deletions(-)
With full diff below.
James
---
drivers/scsi/aacraid/linit.c +2 -1
@@ -452,10 +452,11 @@ static int aac_slave_configure(struct scsi_device *sdev)else if (depth <2 ) depth =2 ;scsi_change_queue_depth (sdev, depth); - }else + }else {scsi_change_queue_depth (sdev,1 ); sdev->tagged_supported =1 ; + }return 0 ; }
drivers/scsi/cxlflash/main.c +95 -43
241 lines not on this page · raw message
drivers/scsi/cxlflash/main.h +2 -3
@@ -79,12 +79,11 @@#define WWPN_BUF_LEN (WWPN_LEN + 1)enum undo_level { -RELEASE_CONTEXT =0 , +UNDO_NOOP =0 ,FREE_IRQ ,UNMAP_ONE ,UNMAP_TWO , -UNMAP_THREE , -UNDO_START +UNMAP_THREE };struct dev_dependent_vals {
drivers/scsi/device_handler/scsi_dh_alua.c +2 -2
@@ -1112,9 +1112,9 @@ static void alua_bus_detach(struct scsi_device *sdev) h->sdev =NULL ;spin_unlock (&h->pg_lock);if (pg) { -spin_lock (&pg->lock); +spin_lock_irq (&pg->lock);list_del_rcu (&h->node); -spin_unlock (&pg->lock); +spin_unlock_irq (&pg->lock);kref_put (&pg->kref, release_port_group); } sdev->handler_data =NULL ;
drivers/scsi/mpt3sas/mpt3sas_base.c +16 -17
@@ -5030,7 +5030,7 @@ _base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, int sleep_flag,static int _base_make_ioc_operational (struct MPT3SAS_ADAPTER *ioc,int sleep_flag) { -int r, i; +int r, i, index;unsigned long flags;u32 reply_address;u16 smid;
@@ -5039,8 +5039,7 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)struct _event_ack_list *delayed_event_ack, *delayed_event_ack_next;u8 hide_flag;struct adapter_reply_queue *reply_q; -long reply_post_free; -u32 reply_post_free_sz, index =0 ; +Mpi2ReplyDescriptorsUnion_t *reply_post_free_contig;dinitprintk (ioc,pr_info (MPT3SAS_FMT "%s\n" , ioc->name, __func__));
@@ -5124,27 +5123,27 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)_base_assign_reply_queues (ioc);/* initialize Reply Post Free Queue */ - reply_post_free_sz = ioc->reply_post_queue_depth * -sizeof (Mpi2DefaultReplyDescriptor_t); - reply_post_free = (long )ioc->reply_post[index].reply_post_free; + index =0 ; + reply_post_free_contig = ioc->reply_post[0 ].reply_post_free;list_for_each_entry (reply_q, &ioc->reply_queue_list, list) { +/* +* If RDPQ is enabled, switch to the next allocation. +* Otherwise advance within the contiguous region. +*/ +if (ioc->rdpq_array_enable) { + reply_q->reply_post_free = + ioc->reply_post[index++].reply_post_free; + }else { + reply_q->reply_post_free = reply_post_free_contig; + reply_post_free_contig += ioc->reply_post_queue_depth; + } + reply_q->reply_post_host_index =0 ; - reply_q->reply_post_free = (Mpi2ReplyDescriptorsUnion_t *) - reply_post_free;for (i =0 ; i < ioc->reply_post_queue_depth; i++) reply_q->reply_post_free[i].Words =cpu_to_le64 (ULLONG_MAX );if (!_base_is_controller_msix_enabled (ioc)) goto skip_init_reply_post_free_queue; -/* -* If RDPQ is enabled, switch to the next allocation. -* Otherwise advance within the contiguous region. -*/ -if (ioc->rdpq_array_enable) - reply_post_free = (long ) - ioc->reply_post[++index].reply_post_free; -else - reply_post_free += reply_post_free_sz; } skip_init_reply_post_free_queue:
drivers/scsi/scsi.c +2 -1
@@ -784,8 +784,9 @@ void scsi_attach_vpd(struct scsi_device *sdev)int pg83_supported =0 ;unsigned char __rcu *vpd_buf, *orig_vpd_buf =NULL ; -if (sdev->skip_vpd_pages) +if (!scsi_device_supports_vpd (sdev))return ; + retry_pg0: vpd_buf =kmalloc (vpd_len,GFP_KERNEL );if (!vpd_buf)
drivers/scsi/scsi_sysfs.c +5 -3
@@ -81,6 +81,7 @@ const char *scsi_host_state_name(enum scsi_host_state state)return name; } +#ifdef CONFIG_SCSI_DH static const struct { unsigned char value; char *name;
@@ -94,7 +95,7 @@ static const struct { { SCSI_ACCESS_STATE_TRANSITIONING, "transitioning" }, }; -const char *scsi_access_state_name (unsigned char state) +static const char *scsi_access_state_name (unsigned char state) {int i;char *name =NULL ;
@@ -107,6 +108,7 @@ const char *scsi_access_state_name(unsigned char state) }return name; } +#endif static int check_set (unsigned long long *val,char *src) {
@@ -226,7 +228,7 @@ show_shost_state(struct device *dev, struct device_attribute *attr, char *buf) }/* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */ -struct device_attribute dev_attr_hstate = +static struct device_attribute dev_attr_hstate =__ATTR (state,S_IRUGO |S_IWUSR , show_shost_state, store_shost_state); static ssize_t
@@ -401,7 +403,7 @@ static struct attribute *scsi_sysfs_shost_attrs[] = { NULL }; -struct attribute_group scsi_shost_attr_group = { +static struct attribute_group scsi_shost_attr_group = { .attrs = scsi_sysfs_shost_attrs, };
drivers/scsi/sd.c +9 -38
83 lines not on this page · raw message
drivers/scsi/sd.h +6 -1
@@ -65,7 +65,7 @@ struct scsi_disk {struct device dev;struct gendisk *disk;atomic_t openers; -sector_t capacity;/* size in 512-byte sectors */ +sector_t capacity;/* size in logical blocks */ u32 max_xfer_blocks;u32 opt_xfer_blocks;u32 max_ws_blocks;
@@ -146,6 +146,11 @@ static inline int scsi_medium_access_command(struct scsi_cmnd *scmd)return 0 ; } +static inline sector_t logical_to_sectors (struct scsi_device *sdev,sector_t blocks) +{ +return blocks << (ilog2 (sdev->sector_size) -9 ); +} +/* * A DIF-capable target device can be formatted with different * protection schemes. Currently 0 through 3 are defined:
include/scsi/scsi_device.h +25 -0
@@ -516,6 +516,31 @@ static inline int scsi_device_tpgs(struct scsi_device *sdev)return sdev->inquiry ? (sdev->inquiry[5 ] >>4 ) &0x3 :0 ; } +/** +* scsi_device_supports_vpd - test if a device supports VPD pages +* @sdev: the &struct scsi_device to test +* +* If the 'try_vpd_pages' flag is set it takes precedence. +* Otherwise we will assume VPD pages are supported if the +* SCSI level is at least SPC-3 and 'skip_vpd_pages' is not set. +*/ +static inline int scsi_device_supports_vpd (struct scsi_device *sdev) +{ +/* Attempt VPD inquiry if the device blacklist explicitly calls +* for it. +*/ +if (sdev->try_vpd_pages) +return 1 ; +/* +* Although VPD inquiries can go to SCSI-2 type devices, +* some USB ones crash on receiving them, and the pages +* we currently ask for are for SPC-3 and beyond +*/ +if (sdev->scsi_level >SCSI_SPC_2 && !sdev->skip_vpd_pages) +return 1 ; +return 0 ; +} +#define MODULE_ALIAS_SCSI_DEVICE (type) \ MODULE_ALIAS("scsi:t-" __stringify(type) "*")#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"