Skip to content

Commit 693a1e8

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: core: Use the atomic queue limits API in scsi_add_lun()
Switch scsi_add_lun() to use the atomic queue limits API to update the max_hw_sectors for devices with quirks. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20240409143748.980206-10-hch@lst.de Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 67144d3 commit 693a1e8

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

drivers/scsi/scsi_scan.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
874874
static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
875875
blist_flags_t *bflags, int async)
876876
{
877+
struct queue_limits lim;
877878
int ret;
878879

879880
/*
@@ -1004,19 +1005,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
10041005
if (*bflags & BLIST_SELECT_NO_ATN)
10051006
sdev->select_no_atn = 1;
10061007

1007-
/*
1008-
* Maximum 512 sector transfer length
1009-
* broken RA4x00 Compaq Disk Array
1010-
*/
1011-
if (*bflags & BLIST_MAX_512)
1012-
blk_queue_max_hw_sectors(sdev->request_queue, 512);
1013-
/*
1014-
* Max 1024 sector transfer length for targets that report incorrect
1015-
* max/optimal lengths and relied on the old block layer safe default
1016-
*/
1017-
else if (*bflags & BLIST_MAX_1024)
1018-
blk_queue_max_hw_sectors(sdev->request_queue, 1024);
1019-
10201008
/*
10211009
* Some devices may not want to have a start command automatically
10221010
* issued when a device is added.
@@ -1077,6 +1065,20 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
10771065

10781066
transport_configure_device(&sdev->sdev_gendev);
10791067

1068+
/*
1069+
* No need to freeze the queue as it isn't reachable to anyone else yet.
1070+
*/
1071+
lim = queue_limits_start_update(sdev->request_queue);
1072+
if (*bflags & BLIST_MAX_512)
1073+
lim.max_hw_sectors = 512;
1074+
else if (*bflags & BLIST_MAX_1024)
1075+
lim.max_hw_sectors = 1024;
1076+
ret = queue_limits_commit_update(sdev->request_queue, &lim);
1077+
if (ret) {
1078+
sdev_printk(KERN_ERR, sdev, "failed to apply queue limits.\n");
1079+
return SCSI_SCAN_NO_RESPONSE;
1080+
}
1081+
10801082
if (sdev->host->hostt->slave_configure) {
10811083
ret = sdev->host->hostt->slave_configure(sdev);
10821084
if (ret) {

0 commit comments

Comments
 (0)