Skip to content

Commit 19190f5

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "This is quite a bumper crop of fixes: three from Arnd correcting various build issues in some configurations, a lock recursion in qla2xxx. Two potentially exploitable issues in hpsa and mvsas, a potential null deref in st, a revert of a bdi registration fix that turned out to cause even more problems, a set of fixes to allow people who only defined MPT2SAS to still work after the mpt2/mpt3sas merger and a couple of fixes for issues turned up by the hyper-v storvsc driver" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: mpt3sas: fix Kconfig dependency problem for mpt2sas back compatibility Revert "scsi: Fix a bdi reregistration race" mpt3sas: Add dummy Kconfig option for backwards compatibility Fix a memory leak in scsi_host_dev_release() block/sd: Fix device-imposed transfer length limits scsi_debug: fix prevent_allow+verify regressions MAINTAINERS: Add myself as co-maintainer of the SCSI subsystem. sd: Make discard granularity match logical block size when LBPRZ=1 scsi: hpsa: select CONFIG_SCSI_SAS_ATTR scsi: advansys needs ISA dma api for ISA support scsi_sysfs: protect against double execution of __scsi_remove_device() st: fix potential null pointer dereference. scsi: report 'INQUIRY result too short' once per host advansys: fix big-endian builds qla2xxx: Fix rwlock recursion hpsa: logical vs bitwise AND typo mvsas: don't allow negative timeouts mpt3sas: Fix use sas_is_tlr_enabled API before enabling MPI2_SCSIIO_CONTROL_TLR_ON flag
2 parents a2dbb7b + be9e2f7 commit 19190f5

File tree

19 files changed

+129
-70
lines changed

19 files changed

+129
-70
lines changed

MAINTAINERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9427,8 +9427,10 @@ F: include/scsi/sg.h
94279427

94289428
SCSI SUBSYSTEM
94299429
M: "James E.J. Bottomley" <JBottomley@odin.com>
9430-
L: linux-scsi@vger.kernel.org
94319430
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git
9431+
M: "Martin K. Petersen" <martin.petersen@oracle.com>
9432+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
9433+
L: linux-scsi@vger.kernel.org
94329434
S: Maintained
94339435
F: drivers/scsi/
94349436
F: include/scsi/

block/blk-settings.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ void blk_set_default_limits(struct queue_limits *lim)
9191
lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
9292
lim->virt_boundary_mask = 0;
9393
lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
94-
lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
94+
lim->max_sectors = lim->max_dev_sectors = lim->max_hw_sectors =
95+
BLK_SAFE_MAX_SECTORS;
9596
lim->chunk_sectors = 0;
9697
lim->max_write_same_sectors = 0;
9798
lim->max_discard_sectors = 0;
@@ -127,6 +128,7 @@ void blk_set_stacking_limits(struct queue_limits *lim)
127128
lim->max_hw_sectors = UINT_MAX;
128129
lim->max_segment_size = UINT_MAX;
129130
lim->max_sectors = UINT_MAX;
131+
lim->max_dev_sectors = UINT_MAX;
130132
lim->max_write_same_sectors = UINT_MAX;
131133
}
132134
EXPORT_SYMBOL(blk_set_stacking_limits);
@@ -214,8 +216,8 @@ void blk_queue_bounce_limit(struct request_queue *q, u64 max_addr)
214216
EXPORT_SYMBOL(blk_queue_bounce_limit);
215217

216218
/**
217-
* blk_limits_max_hw_sectors - set hard and soft limit of max sectors for request
218-
* @limits: the queue limits
219+
* blk_queue_max_hw_sectors - set max sectors for a request for this queue
220+
* @q: the request queue for the device
219221
* @max_hw_sectors: max hardware sectors in the usual 512b unit
220222
*
221223
* Description:
@@ -224,36 +226,29 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
224226
* the device driver based upon the capabilities of the I/O
225227
* controller.
226228
*
229+
* max_dev_sectors is a hard limit imposed by the storage device for
230+
* READ/WRITE requests. It is set by the disk driver.
231+
*
227232
* max_sectors is a soft limit imposed by the block layer for
228233
* filesystem type requests. This value can be overridden on a
229234
* per-device basis in /sys/block/<device>/queue/max_sectors_kb.
230235
* The soft limit can not exceed max_hw_sectors.
231236
**/
232-
void blk_limits_max_hw_sectors(struct queue_limits *limits, unsigned int max_hw_sectors)
237+
void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)
233238
{
239+
struct queue_limits *limits = &q->limits;
240+
unsigned int max_sectors;
241+
234242
if ((max_hw_sectors << 9) < PAGE_CACHE_SIZE) {
235243
max_hw_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
236244
printk(KERN_INFO "%s: set to minimum %d\n",
237245
__func__, max_hw_sectors);
238246
}
239247

240248
limits->max_hw_sectors = max_hw_sectors;
241-
limits->max_sectors = min_t(unsigned int, max_hw_sectors,
242-
BLK_DEF_MAX_SECTORS);
243-
}
244-
EXPORT_SYMBOL(blk_limits_max_hw_sectors);
245-
246-
/**
247-
* blk_queue_max_hw_sectors - set max sectors for a request for this queue
248-
* @q: the request queue for the device
249-
* @max_hw_sectors: max hardware sectors in the usual 512b unit
250-
*
251-
* Description:
252-
* See description for blk_limits_max_hw_sectors().
253-
**/
254-
void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)
255-
{
256-
blk_limits_max_hw_sectors(&q->limits, max_hw_sectors);
249+
max_sectors = min_not_zero(max_hw_sectors, limits->max_dev_sectors);
250+
max_sectors = min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS);
251+
limits->max_sectors = max_sectors;
257252
}
258253
EXPORT_SYMBOL(blk_queue_max_hw_sectors);
259254

@@ -527,6 +522,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
527522

528523
t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
529524
t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
525+
t->max_dev_sectors = min_not_zero(t->max_dev_sectors, b->max_dev_sectors);
530526
t->max_write_same_sectors = min(t->max_write_same_sectors,
531527
b->max_write_same_sectors);
532528
t->bounce_pfn = min_not_zero(t->bounce_pfn, b->bounce_pfn);

block/blk-sysfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
205205
if (ret < 0)
206206
return ret;
207207

208+
max_hw_sectors_kb = min_not_zero(max_hw_sectors_kb, (unsigned long)
209+
q->limits.max_dev_sectors >> 1);
210+
208211
if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
209212
return -EINVAL;
210213

drivers/scsi/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ config SCSI_HPSA
364364
tristate "HP Smart Array SCSI driver"
365365
depends on PCI && SCSI
366366
select CHECK_SIGNATURE
367+
select SCSI_SAS_ATTRS
367368
help
368369
This driver supports HP Smart Array Controllers (circa 2009).
369370
It is a SCSI alternative to the cciss driver, which is a block
@@ -499,6 +500,7 @@ config SCSI_ADVANSYS
499500
tristate "AdvanSys SCSI support"
500501
depends on SCSI
501502
depends on ISA || EISA || PCI
503+
depends on ISA_DMA_API || !ISA
502504
help
503505
This is a driver for all SCSI host adapters manufactured by
504506
AdvanSys. It is documented in the kernel source in

drivers/scsi/advansys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7803,7 +7803,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
78037803
return ASC_BUSY;
78047804
}
78057805
scsiqp->sense_addr = cpu_to_le32(sense_addr);
7806-
scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
7806+
scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
78077807

78087808
/* Build ADV_SCSI_REQ_Q */
78097809

drivers/scsi/hosts.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,17 @@ static void scsi_host_dev_release(struct device *dev)
333333
kfree(queuedata);
334334
}
335335

336+
if (shost->shost_state == SHOST_CREATED) {
337+
/*
338+
* Free the shost_dev device name here if scsi_host_alloc()
339+
* and scsi_host_put() have been called but neither
340+
* scsi_host_add() nor scsi_host_remove() has been called.
341+
* This avoids that the memory allocated for the shost_dev
342+
* name is leaked.
343+
*/
344+
kfree(dev_name(&shost->shost_dev));
345+
}
346+
336347
scsi_destroy_command_freelist(shost);
337348
if (shost_use_blk_mq(shost)) {
338349
if (shost->tag_set.tags)

drivers/scsi/hpsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8671,7 +8671,7 @@ static void hpsa_disable_rld_caching(struct ctlr_info *h)
86718671
if ((rc != 0) || (c->err_info->CommandStatus != 0))
86728672
goto errout;
86738673

8674-
if (*options && HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
8674+
if (*options & HPSA_DIAG_OPTS_DISABLE_RLD_CACHING)
86758675
goto out;
86768676

86778677
errout:

drivers/scsi/mpt3sas/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,12 @@ config SCSI_MPT3SAS_MAX_SGE
7171
MAX_PHYS_SEGMENTS in most kernels. However in SuSE kernels this
7272
can be 256. However, it may decreased down to 16. Decreasing this
7373
parameter will reduce memory requirements on a per controller instance.
74+
75+
config SCSI_MPT2SAS
76+
tristate "Legacy MPT2SAS config option"
77+
default n
78+
select SCSI_MPT3SAS
79+
depends on PCI && SCSI
80+
---help---
81+
Dummy config option for backwards compatiblity: configure the MPT3SAS
82+
driver instead.

drivers/scsi/mpt3sas/mpt3sas_scsih.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3905,8 +3905,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
39053905
* We do not expose raid functionality to upper layer for warpdrive.
39063906
*/
39073907
if (!ioc->is_warpdrive && !scsih_is_raid(&scmd->device->sdev_gendev)
3908-
&& (sas_device_priv_data->flags & MPT_DEVICE_TLR_ON) &&
3909-
scmd->cmd_len != 32)
3908+
&& sas_is_tlr_enabled(scmd->device) && scmd->cmd_len != 32)
39103909
mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON;
39113910

39123911
smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd);

drivers/scsi/mvsas/mv_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,15 +758,15 @@ mvs_store_interrupt_coalescing(struct device *cdev,
758758
struct device_attribute *attr,
759759
const char *buffer, size_t size)
760760
{
761-
int val = 0;
761+
unsigned int val = 0;
762762
struct mvs_info *mvi = NULL;
763763
struct Scsi_Host *shost = class_to_shost(cdev);
764764
struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
765765
u8 i, core_nr;
766766
if (buffer == NULL)
767767
return size;
768768

769-
if (sscanf(buffer, "%d", &val) != 1)
769+
if (sscanf(buffer, "%u", &val) != 1)
770770
return -EINVAL;
771771

772772
if (val >= 0x10000) {

drivers/scsi/qla2xxx/qla_nx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ qla82xx_pci_get_crb_addr_2M(struct qla_hw_data *ha, ulong off_in,
433433
if (off_in < QLA82XX_PCI_CRBSPACE)
434434
return -1;
435435

436-
*off_out = (void __iomem *)(off_in - QLA82XX_PCI_CRBSPACE);
436+
off_in -= QLA82XX_PCI_CRBSPACE;
437437

438438
/* Try direct map */
439439
m = &crb_128M_2M_map[CRB_BLK(off_in)].sub_block[CRB_SUBBLK(off_in)];
@@ -443,6 +443,7 @@ qla82xx_pci_get_crb_addr_2M(struct qla_hw_data *ha, ulong off_in,
443443
return 0;
444444
}
445445
/* Not in direct map, use crb window */
446+
*off_out = (void __iomem *)off_in;
446447
return 1;
447448
}
448449

drivers/scsi/scsi_debug.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,9 @@ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEMENT + 1] = {
465465
0} },
466466
{0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* MAINT OUT */
467467
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
468-
{0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* VERIFY */
469-
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
468+
{0, 0x2f, 0, F_D_OUT_MAYBE | FF_DIRECT_IO, NULL, NULL, /* VERIFY(10) */
469+
{10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7,
470+
0, 0, 0, 0, 0, 0} },
470471
{1, 0x7f, 0x9, F_SA_HIGH | F_D_IN | FF_DIRECT_IO, resp_read_dt0,
471472
vl_iarr, {32, 0xc7, 0, 0, 0, 0, 0x1f, 0x18, 0x0, 0x9, 0xfe, 0,
472473
0xff, 0xff, 0xff, 0xff} },/* VARIABLE LENGTH, READ(32) */
@@ -477,8 +478,8 @@ static const struct opcode_info_t opcode_info_arr[SDEB_I_LAST_ELEMENT + 1] = {
477478
{10, 0x13, 0xff, 0xff, 0, 0, 0, 0xff, 0xff, 0xc7, 0, 0, 0, 0, 0,
478479
0} },
479480
/* 20 */
480-
{0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* ALLOW REMOVAL */
481-
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
481+
{0, 0x1e, 0, 0, NULL, NULL, /* ALLOW REMOVAL */
482+
{6, 0, 0, 0, 0x3, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
482483
{0, 0x1, 0, 0, resp_start_stop, NULL, /* REWIND ?? */
483484
{6, 0x1, 0, 0, 0, 0xc7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
484485
{0, 0, 0, F_INV_OP | FF_RESPOND, NULL, NULL, /* ATA_PT */

drivers/scsi/scsi_scan.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
701701
* strings.
702702
*/
703703
if (sdev->inquiry_len < 36) {
704-
sdev_printk(KERN_INFO, sdev,
705-
"scsi scan: INQUIRY result too short (%d),"
706-
" using 36\n", sdev->inquiry_len);
704+
if (!sdev->host->short_inquiry) {
705+
shost_printk(KERN_INFO, sdev->host,
706+
"scsi scan: INQUIRY result too short (%d),"
707+
" using 36\n", sdev->inquiry_len);
708+
sdev->host->short_inquiry = 1;
709+
}
707710
sdev->inquiry_len = 36;
708711
}
709712

drivers/scsi/scsi_sysfs.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,14 @@ void __scsi_remove_device(struct scsi_device *sdev)
11021102
{
11031103
struct device *dev = &sdev->sdev_gendev;
11041104

1105+
/*
1106+
* This cleanup path is not reentrant and while it is impossible
1107+
* to get a new reference with scsi_device_get() someone can still
1108+
* hold a previously acquired one.
1109+
*/
1110+
if (sdev->sdev_state == SDEV_DEL)
1111+
return;
1112+
11051113
if (sdev->is_visible) {
11061114
if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
11071115
return;
@@ -1110,7 +1118,9 @@ void __scsi_remove_device(struct scsi_device *sdev)
11101118
device_unregister(&sdev->sdev_dev);
11111119
transport_remove_device(dev);
11121120
scsi_dh_remove_device(sdev);
1113-
}
1121+
device_del(dev);
1122+
} else
1123+
put_device(&sdev->sdev_dev);
11141124

11151125
/*
11161126
* Stop accepting new requests and wait until all queuecommand() and
@@ -1121,16 +1131,6 @@ void __scsi_remove_device(struct scsi_device *sdev)
11211131
blk_cleanup_queue(sdev->request_queue);
11221132
cancel_work_sync(&sdev->requeue_work);
11231133

1124-
/*
1125-
* Remove the device after blk_cleanup_queue() has been called such
1126-
* a possible bdi_register() call with the same name occurs after
1127-
* blk_cleanup_queue() has called bdi_destroy().
1128-
*/
1129-
if (sdev->is_visible)
1130-
device_del(dev);
1131-
else
1132-
put_device(&sdev->sdev_dev);
1133-
11341134
if (sdev->host->hostt->slave_destroy)
11351135
sdev->host->hostt->slave_destroy(sdev);
11361136
transport_destroy_device(dev);

0 commit comments

Comments
 (0)