Skip to content

Commit be9e2f7

Browse files
James BottomleyJames Bottomley
authored andcommitted
Merge branch 'mkp-fixes' into fixes
2 parents e619e6c + 3ddda3e commit be9e2f7

File tree

19 files changed

+126
-59
lines changed

19 files changed

+126
-59
lines changed

MAINTAINERS

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

94129412
SCSI SUBSYSTEM
94139413
M: "James E.J. Bottomley" <JBottomley@odin.com>
9414-
L: linux-scsi@vger.kernel.org
94159414
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git
9415+
M: "Martin K. Petersen" <martin.petersen@oracle.com>
9416+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
9417+
L: linux-scsi@vger.kernel.org
94169418
S: Maintained
94179419
F: drivers/scsi/
94189420
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: 8 additions & 0 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;

drivers/scsi/sd.c

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -638,11 +638,24 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
638638
unsigned int max_blocks = 0;
639639

640640
q->limits.discard_zeroes_data = 0;
641-
q->limits.discard_alignment = sdkp->unmap_alignment *
642-
logical_block_size;
643-
q->limits.discard_granularity =
644-
max(sdkp->physical_block_size,
645-
sdkp->unmap_granularity * logical_block_size);
641+
642+
/*
643+
* When LBPRZ is reported, discard alignment and granularity
644+
* must be fixed to the logical block size. Otherwise the block
645+
* layer will drop misaligned portions of the request which can
646+
* lead to data corruption. If LBPRZ is not set, we honor the
647+
* device preference.
648+
*/
649+
if (sdkp->lbprz) {
650+
q->limits.discard_alignment = 0;
651+
q->limits.discard_granularity = 1;
652+
} else {
653+
q->limits.discard_alignment = sdkp->unmap_alignment *
654+
logical_block_size;
655+
q->limits.discard_granularity =
656+
max(sdkp->physical_block_size,
657+
sdkp->unmap_granularity * logical_block_size);
658+
}
646659

647660
sdkp->provisioning_mode = mode;
648661

@@ -2321,11 +2334,8 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
23212334
}
23222335
}
23232336

2324-
if (sdkp->capacity > 0xffffffff) {
2337+
if (sdkp->capacity > 0xffffffff)
23252338
sdp->use_16_for_rw = 1;
2326-
sdkp->max_xfer_blocks = SD_MAX_XFER_BLOCKS;
2327-
} else
2328-
sdkp->max_xfer_blocks = SD_DEF_XFER_BLOCKS;
23292339

23302340
/* Rescale capacity to 512-byte units */
23312341
if (sector_size == 4096)
@@ -2642,22 +2652,18 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
26422652
{
26432653
unsigned int sector_sz = sdkp->device->sector_size;
26442654
const int vpd_len = 64;
2645-
u32 max_xfer_length;
26462655
unsigned char *buffer = kmalloc(vpd_len, GFP_KERNEL);
26472656

26482657
if (!buffer ||
26492658
/* Block Limits VPD */
26502659
scsi_get_vpd_page(sdkp->device, 0xb0, buffer, vpd_len))
26512660
goto out;
26522661

2653-
max_xfer_length = get_unaligned_be32(&buffer[8]);
2654-
if (max_xfer_length)
2655-
sdkp->max_xfer_blocks = max_xfer_length;
2656-
26572662
blk_queue_io_min(sdkp->disk->queue,
26582663
get_unaligned_be16(&buffer[6]) * sector_sz);
2659-
blk_queue_io_opt(sdkp->disk->queue,
2660-
get_unaligned_be32(&buffer[12]) * sector_sz);
2664+
2665+
sdkp->max_xfer_blocks = get_unaligned_be32(&buffer[8]);
2666+
sdkp->opt_xfer_blocks = get_unaligned_be32(&buffer[12]);
26612667

26622668
if (buffer[3] == 0x3c) {
26632669
unsigned int lba_count, desc_count;
@@ -2806,6 +2812,11 @@ static int sd_try_extended_inquiry(struct scsi_device *sdp)
28062812
return 0;
28072813
}
28082814

2815+
static inline u32 logical_to_sectors(struct scsi_device *sdev, u32 blocks)
2816+
{
2817+
return blocks << (ilog2(sdev->sector_size) - 9);
2818+
}
2819+
28092820
/**
28102821
* sd_revalidate_disk - called the first time a new disk is seen,
28112822
* performs disk spin up, read_capacity, etc.
@@ -2815,8 +2826,9 @@ static int sd_revalidate_disk(struct gendisk *disk)
28152826
{
28162827
struct scsi_disk *sdkp = scsi_disk(disk);
28172828
struct scsi_device *sdp = sdkp->device;
2829+
struct request_queue *q = sdkp->disk->queue;
28182830
unsigned char *buffer;
2819-
unsigned int max_xfer;
2831+
unsigned int dev_max, rw_max;
28202832

28212833
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
28222834
"sd_revalidate_disk\n"));
@@ -2864,11 +2876,26 @@ static int sd_revalidate_disk(struct gendisk *disk)
28642876
*/
28652877
sd_set_flush_flag(sdkp);
28662878

2867-
max_xfer = sdkp->max_xfer_blocks;
2868-
max_xfer <<= ilog2(sdp->sector_size) - 9;
2879+
/* Initial block count limit based on CDB TRANSFER LENGTH field size. */
2880+
dev_max = sdp->use_16_for_rw ? SD_MAX_XFER_BLOCKS : SD_DEF_XFER_BLOCKS;
2881+
2882+
/* Some devices report a maximum block count for READ/WRITE requests. */
2883+
dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks);
2884+
q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max);
2885+
2886+
/*
2887+
* Use the device's preferred I/O size for reads and writes
2888+
* unless the reported value is unreasonably large (or garbage).
2889+
*/
2890+
if (sdkp->opt_xfer_blocks && sdkp->opt_xfer_blocks <= dev_max &&
2891+
sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS)
2892+
rw_max = q->limits.io_opt =
2893+
logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
2894+
else
2895+
rw_max = BLK_DEF_MAX_SECTORS;
28692896

2870-
sdkp->disk->queue->limits.max_sectors =
2871-
min_not_zero(queue_max_hw_sectors(sdkp->disk->queue), max_xfer);
2897+
/* Combine with controller limits */
2898+
q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));
28722899

28732900
set_capacity(disk, sdkp->capacity);
28742901
sd_config_write_same(sdkp);

0 commit comments

Comments
 (0)