Skip to content

Commit 2ecb204

Browse files
author
Christoph Hellwig
committed
scsi: always assign block layer tags if enabled
Allow a driver to ask for block layer tags by setting .use_blk_tags in the host template, in which case it will always see a valid value in request->tag, similar to the behavior when using blk-mq. This means even SCSI "untagged" commands will now have a tag, which is especially useful when using a host-wide tag map. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Mike Christie <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]>
1 parent e2eddf4 commit 2ecb204

File tree

33 files changed

+86
-168
lines changed

33 files changed

+86
-168
lines changed

Documentation/scsi/scsi_mid_low_api.txt

+1-37
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,11 @@ is initialized. The functions below are listed alphabetically and their
366366
names all start with "scsi_".
367367

368368
Summary:
369-
scsi_activate_tcq - turn on tag command queueing
370369
scsi_add_device - creates new scsi device (lu) instance
371370
scsi_add_host - perform sysfs registration and set up transport class
372371
scsi_adjust_queue_depth - change the queue depth on a SCSI device
373372
scsi_bios_ptable - return copy of block device's partition table
374373
scsi_block_requests - prevent further commands being queued to given host
375-
scsi_deactivate_tcq - turn off tag command queueing
376374
scsi_host_alloc - return a new scsi_host instance whose refcount==1
377375
scsi_host_get - increments Scsi_Host instance's refcount
378376
scsi_host_put - decrements Scsi_Host instance's refcount (free if 0)
@@ -389,24 +387,6 @@ Summary:
389387

390388
Details:
391389

392-
/**
393-
* scsi_activate_tcq - turn on tag command queueing ("ordered" task attribute)
394-
* @sdev: device to turn on TCQ for
395-
* @depth: queue depth
396-
*
397-
* Returns nothing
398-
*
399-
* Might block: no
400-
*
401-
* Notes: Eventually, it is hoped depth would be the maximum depth
402-
* the device could cope with and the real queue depth
403-
* would be adjustable from 0 to depth.
404-
*
405-
* Defined (inline) in: include/scsi/scsi_tcq.h
406-
**/
407-
void scsi_activate_tcq(struct scsi_device *sdev, int depth)
408-
409-
410390
/**
411391
* scsi_add_device - creates new scsi device (lu) instance
412392
* @shost: pointer to scsi host instance
@@ -471,9 +451,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device * dev)
471451
*
472452
* Notes: Can be invoked any time on a SCSI device controlled by this
473453
* LLD. [Specifically during and after slave_configure() and prior to
474-
* slave_destroy().] Can safely be invoked from interrupt code. Actual
475-
* queue depth change may be delayed until the next command is being
476-
* processed. See also scsi_activate_tcq() and scsi_deactivate_tcq().
454+
* slave_destroy().] Can safely be invoked from interrupt code.
477455
*
478456
* Defined in: drivers/scsi/scsi.c [see source code for more notes]
479457
*
@@ -514,20 +492,6 @@ unsigned char *scsi_bios_ptable(struct block_device *dev)
514492
void scsi_block_requests(struct Scsi_Host * shost)
515493

516494

517-
/**
518-
* scsi_deactivate_tcq - turn off tag command queueing
519-
* @sdev: device to turn off TCQ for
520-
* @depth: queue depth (stored in sdev)
521-
*
522-
* Returns nothing
523-
*
524-
* Might block: no
525-
*
526-
* Defined (inline) in: include/scsi/scsi_tcq.h
527-
**/
528-
void scsi_deactivate_tcq(struct scsi_device *sdev, int depth)
529-
530-
531495
/**
532496
* scsi_host_alloc - create a scsi host adapter instance and perform basic
533497
* initialization.

drivers/message/fusion/mptsas.c

+1
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,7 @@ static struct scsi_host_template mptsas_driver_template = {
19941994
.cmd_per_lun = 7,
19951995
.use_clustering = ENABLE_CLUSTERING,
19961996
.shost_attrs = mptscsih_host_attrs,
1997+
.use_blk_tags = 1,
19971998
};
19981999

19992000
static int mptsas_get_linkerrors(struct sas_phy *phy)

drivers/scsi/53c700.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
327327
tpnt->slave_alloc = NCR_700_slave_alloc;
328328
tpnt->change_queue_depth = NCR_700_change_queue_depth;
329329
tpnt->change_queue_type = NCR_700_change_queue_type;
330+
tpnt->use_blk_tags = 1;
330331

331332
if(tpnt->name == NULL)
332333
tpnt->name = "53c700";
@@ -902,7 +903,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
902903
NCR_700_set_tag_neg_state(SCp->device, NCR_700_FINISHED_TAG_NEGOTIATION);
903904
hostdata->tag_negotiated &= ~(1<<scmd_id(SCp));
904905
SCp->device->tagged_supported = 0;
905-
scsi_deactivate_tcq(SCp->device, host->cmd_per_lun);
906+
scsi_adjust_queue_depth(SCp->device, 0, host->cmd_per_lun);
906907
} else {
907908
shost_printk(KERN_WARNING, host,
908909
"(%d:%d) Unexpected REJECT Message %s\n",
@@ -2049,8 +2050,7 @@ NCR_700_slave_configure(struct scsi_device *SDp)
20492050

20502051
/* to do here: allocate memory; build a queue_full list */
20512052
if(SDp->tagged_supported) {
2052-
scsi_set_tag_type(SDp, MSG_ORDERED_TAG);
2053-
scsi_activate_tcq(SDp, NCR_700_DEFAULT_TAGS);
2053+
scsi_adjust_queue_depth(SDp, MSG_ORDERED_TAG, NCR_700_DEFAULT_TAGS);
20542054
NCR_700_set_tag_neg_state(SDp, NCR_700_START_TAG_NEGOTIATION);
20552055
} else {
20562056
/* initialise to default depth */
@@ -2094,8 +2094,6 @@ static int NCR_700_change_queue_type(struct scsi_device *SDp, int tag_type)
20942094
struct NCR_700_Host_Parameters *hostdata =
20952095
(struct NCR_700_Host_Parameters *)SDp->host->hostdata[0];
20962096

2097-
scsi_set_tag_type(SDp, tag_type);
2098-
20992097
/* We have a global (per target) flag to track whether TCQ is
21002098
* enabled, so we'll be turning it off for the entire target here.
21012099
* our tag algorithm will fail if we mix tagged and untagged commands,
@@ -2106,12 +2104,12 @@ static int NCR_700_change_queue_type(struct scsi_device *SDp, int tag_type)
21062104
if (!tag_type) {
21072105
/* shift back to the default unqueued number of commands
21082106
* (the user can still raise this) */
2109-
scsi_deactivate_tcq(SDp, SDp->host->cmd_per_lun);
2107+
scsi_adjust_queue_depth(SDp, 0, SDp->host->cmd_per_lun);
21102108
hostdata->tag_negotiated &= ~(1 << sdev_id(SDp));
21112109
} else {
21122110
/* Here, we cleared the negotiation flag above, so this
21132111
* will force the driver to renegotiate */
2114-
scsi_activate_tcq(SDp, SDp->queue_depth);
2112+
scsi_adjust_queue_depth(SDp, tag_type, SDp->queue_depth);
21152113
if (change_tag)
21162114
NCR_700_set_tag_neg_state(SDp, NCR_700_START_TAG_NEGOTIATION);
21172115
}

drivers/scsi/aic7xxx/aic79xx_osm.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ struct scsi_host_template aic79xx_driver_template = {
925925
.slave_configure = ahd_linux_slave_configure,
926926
.target_alloc = ahd_linux_target_alloc,
927927
.target_destroy = ahd_linux_target_destroy,
928+
.use_blk_tags = 1,
928929
};
929930

930931
/******************************** Bus DMA *************************************/
@@ -1468,12 +1469,12 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev,
14681469

14691470
switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) {
14701471
case AHD_DEV_Q_BASIC:
1471-
scsi_set_tag_type(sdev, MSG_SIMPLE_TASK);
1472-
scsi_activate_tcq(sdev, dev->openings + dev->active);
1472+
scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TASK,
1473+
dev->openings + dev->active);
14731474
break;
14741475
case AHD_DEV_Q_TAGGED:
1475-
scsi_set_tag_type(sdev, MSG_ORDERED_TASK);
1476-
scsi_activate_tcq(sdev, dev->openings + dev->active);
1476+
scsi_adjust_queue_depth(sdev, MSG_ORDERED_TASK,
1477+
dev->openings + dev->active);
14771478
break;
14781479
default:
14791480
/*
@@ -1482,7 +1483,7 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev,
14821483
* serially on the controller/device. This should
14831484
* remove some latency.
14841485
*/
1485-
scsi_deactivate_tcq(sdev, 1);
1486+
scsi_adjust_queue_depth(sdev, 0, 1);
14861487
break;
14871488
}
14881489
}

drivers/scsi/aic7xxx/aic7xxx_osm.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,7 @@ struct scsi_host_template aic7xxx_driver_template = {
812812
.slave_configure = ahc_linux_slave_configure,
813813
.target_alloc = ahc_linux_target_alloc,
814814
.target_destroy = ahc_linux_target_destroy,
815+
.use_blk_tags = 1,
815816
};
816817

817818
/**************************** Tasklet Handler *********************************/
@@ -1334,12 +1335,12 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
13341335
}
13351336
switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) {
13361337
case AHC_DEV_Q_BASIC:
1337-
scsi_set_tag_type(sdev, MSG_SIMPLE_TAG);
1338-
scsi_activate_tcq(sdev, dev->openings + dev->active);
1338+
scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TASK,
1339+
dev->openings + dev->active);
13391340
break;
13401341
case AHC_DEV_Q_TAGGED:
1341-
scsi_set_tag_type(sdev, MSG_ORDERED_TAG);
1342-
scsi_activate_tcq(sdev, dev->openings + dev->active);
1342+
scsi_adjust_queue_depth(sdev, MSG_ORDERED_TASK,
1343+
dev->openings + dev->active);
13431344
break;
13441345
default:
13451346
/*
@@ -1348,7 +1349,7 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
13481349
* serially on the controller/device. This should
13491350
* remove some latency.
13501351
*/
1351-
scsi_deactivate_tcq(sdev, 2);
1352+
scsi_adjust_queue_depth(sdev, 0, 2);
13521353
break;
13531354
}
13541355
}

drivers/scsi/aic94xx/aic94xx_init.c

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static struct scsi_host_template aic94xx_sht = {
8383
.eh_bus_reset_handler = sas_eh_bus_reset_handler,
8484
.target_destroy = sas_target_destroy,
8585
.ioctl = sas_ioctl,
86+
.use_blk_tags = 1,
8687
};
8788

8889
static int asd_map_memio(struct asd_ha_struct *asd_ha)

drivers/scsi/bfa/bfad_im.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,7 @@ bfad_thread_workq(struct bfad_s *bfad)
776776
static int
777777
bfad_im_slave_configure(struct scsi_device *sdev)
778778
{
779-
if (sdev->tagged_supported)
780-
scsi_activate_tcq(sdev, bfa_lun_queue_depth);
781-
else
782-
scsi_deactivate_tcq(sdev, bfa_lun_queue_depth);
783-
779+
scsi_adjust_queue_depth(sdev, 0, bfa_lun_queue_depth);
784780
return 0;
785781
}
786782

@@ -804,6 +800,7 @@ struct scsi_host_template bfad_im_scsi_host_template = {
804800
.shost_attrs = bfad_im_host_attrs,
805801
.max_sectors = BFAD_MAX_SECTORS,
806802
.vendor_id = BFA_PCI_VENDOR_ID_BROCADE,
803+
.use_blk_tags = 1,
807804
};
808805

809806
struct scsi_host_template bfad_im_vport_template = {
@@ -825,6 +822,7 @@ struct scsi_host_template bfad_im_vport_template = {
825822
.use_clustering = ENABLE_CLUSTERING,
826823
.shost_attrs = bfad_im_vport_attrs,
827824
.max_sectors = BFAD_MAX_SECTORS,
825+
.use_blk_tags = 1,
828826
};
829827

830828
bfa_status_t

drivers/scsi/bnx2fc/bnx2fc_fcoe.c

+1
Original file line numberDiff line numberDiff line change
@@ -2790,6 +2790,7 @@ static struct scsi_host_template bnx2fc_shost_template = {
27902790
.use_clustering = ENABLE_CLUSTERING,
27912791
.sg_tablesize = BNX2FC_MAX_BDS_PER_CMD,
27922792
.max_sectors = 1024,
2793+
.use_blk_tags = 1,
27932794
};
27942795

27952796
static struct libfc_function_template bnx2fc_libfc_fcn_templ = {

drivers/scsi/csiostor/csio_scsi.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -2241,11 +2241,7 @@ csio_slave_alloc(struct scsi_device *sdev)
22412241
static int
22422242
csio_slave_configure(struct scsi_device *sdev)
22432243
{
2244-
if (sdev->tagged_supported)
2245-
scsi_activate_tcq(sdev, csio_lun_qdepth);
2246-
else
2247-
scsi_deactivate_tcq(sdev, csio_lun_qdepth);
2248-
2244+
scsi_adjust_queue_depth(sdev, 0, csio_lun_qdepth);
22492245
return 0;
22502246
}
22512247

@@ -2290,6 +2286,7 @@ struct scsi_host_template csio_fcoe_shost_template = {
22902286
.use_clustering = ENABLE_CLUSTERING,
22912287
.shost_attrs = csio_fcoe_lport_attrs,
22922288
.max_sectors = CSIO_MAX_SECTOR_SIZE,
2289+
.use_blk_tags = 1,
22932290
};
22942291

22952292
struct scsi_host_template csio_fcoe_shost_vport_template = {
@@ -2309,6 +2306,7 @@ struct scsi_host_template csio_fcoe_shost_vport_template = {
23092306
.use_clustering = ENABLE_CLUSTERING,
23102307
.shost_attrs = csio_fcoe_vport_attrs,
23112308
.max_sectors = CSIO_MAX_SECTOR_SIZE,
2309+
.use_blk_tags = 1,
23122310
};
23132311

23142312
/*

drivers/scsi/esas2r/esas2r_main.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ static struct scsi_host_template driver_template = {
260260
.change_queue_depth = esas2r_change_queue_depth,
261261
.change_queue_type = scsi_change_queue_type,
262262
.max_sectors = 0xFFFF,
263+
.use_blk_tags = 1,
263264
};
264265

265266
int sgl_page_size = 512;
@@ -1278,13 +1279,10 @@ int esas2r_slave_configure(struct scsi_device *dev)
12781279
esas2r_log_dev(ESAS2R_LOG_INFO, &(dev->sdev_gendev),
12791280
"esas2r_slave_configure()");
12801281

1281-
if (dev->tagged_supported) {
1282-
scsi_set_tag_type(dev, MSG_SIMPLE_TAG);
1283-
scsi_activate_tcq(dev, cmd_per_lun);
1284-
} else {
1285-
scsi_set_tag_type(dev, 0);
1286-
scsi_deactivate_tcq(dev, cmd_per_lun);
1287-
}
1282+
if (dev->tagged_supported)
1283+
scsi_adjust_queue_depth(dev, MSG_SIMPLE_TAG, cmd_per_lun);
1284+
else
1285+
scsi_adjust_queue_depth(dev, 0, cmd_per_lun);
12881286

12891287
return 0;
12901288
}

drivers/scsi/esp_scsi.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -2419,10 +2419,9 @@ static int esp_slave_configure(struct scsi_device *dev)
24192419
queue_depth = dev->host->cmd_per_lun;
24202420

24212421
if (goal_tags) {
2422-
scsi_set_tag_type(dev, MSG_ORDERED_TAG);
2423-
scsi_activate_tcq(dev, queue_depth);
2422+
scsi_adjust_queue_depth(dev, MSG_ORDERED_TAG, queue_depth);
24242423
} else {
2425-
scsi_deactivate_tcq(dev, queue_depth);
2424+
scsi_adjust_queue_depth(dev, 0, queue_depth);
24262425
}
24272426
tp->flags |= ESP_TGT_DISCONNECT;
24282427

@@ -2631,6 +2630,7 @@ struct scsi_host_template scsi_esp_template = {
26312630
.use_clustering = ENABLE_CLUSTERING,
26322631
.max_sectors = 0xffff,
26332632
.skip_settle_delay = 1,
2633+
.use_blk_tags = 1,
26342634
};
26352635
EXPORT_SYMBOL(scsi_esp_template);
26362636

drivers/scsi/fcoe/fcoe.c

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ static struct scsi_host_template fcoe_shost_template = {
288288
.use_clustering = ENABLE_CLUSTERING,
289289
.sg_tablesize = SG_ALL,
290290
.max_sectors = 0xffff,
291+
.use_blk_tags = 1,
291292
};
292293

293294
/**

drivers/scsi/fnic/fnic_main.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static int fnic_slave_alloc(struct scsi_device *sdev)
100100
if (!rport || fc_remote_port_chkready(rport))
101101
return -ENXIO;
102102

103-
scsi_activate_tcq(sdev, fnic_max_qdepth);
103+
scsi_adjust_queue_depth(sdev, 0, fnic_max_qdepth);
104104
return 0;
105105
}
106106

@@ -121,6 +121,7 @@ static struct scsi_host_template fnic_host_template = {
121121
.sg_tablesize = FNIC_MAX_SG_DESC_CNT,
122122
.max_sectors = 0xffff,
123123
.shost_attrs = fnic_attrs,
124+
.use_blk_tags = 1,
124125
};
125126

126127
static void

drivers/scsi/ibmvscsi/ibmvfc.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -2888,11 +2888,11 @@ static int ibmvfc_slave_configure(struct scsi_device *sdev)
28882888
if (sdev->type == TYPE_DISK)
28892889
sdev->allow_restart = 1;
28902890

2891-
if (sdev->tagged_supported) {
2892-
scsi_set_tag_type(sdev, MSG_SIMPLE_TAG);
2893-
scsi_activate_tcq(sdev, sdev->queue_depth);
2894-
} else
2895-
scsi_deactivate_tcq(sdev, sdev->queue_depth);
2891+
if (sdev->tagged_supported)
2892+
scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG,
2893+
sdev->queue_depth);
2894+
else
2895+
scsi_adjust_queue_depth(sdev, 0, sdev->queue_depth);
28962896
spin_unlock_irqrestore(shost->host_lock, flags);
28972897
return 0;
28982898
}
@@ -3108,6 +3108,7 @@ static struct scsi_host_template driver_template = {
31083108
.max_sectors = IBMVFC_MAX_SECTORS,
31093109
.use_clustering = ENABLE_CLUSTERING,
31103110
.shost_attrs = ibmvfc_attrs,
3111+
.use_blk_tags = 1,
31113112
};
31123113

31133114
/**

drivers/scsi/ipr.c

+1
Original file line numberDiff line numberDiff line change
@@ -6317,6 +6317,7 @@ static struct scsi_host_template driver_template = {
63176317
.sdev_attrs = ipr_dev_attrs,
63186318
.proc_name = IPR_NAME,
63196319
.no_write_same = 1,
6320+
.use_blk_tags = 1,
63206321
};
63216322

63226323
/**

drivers/scsi/isci/init.c

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ static struct scsi_host_template isci_sht = {
172172
.target_destroy = sas_target_destroy,
173173
.ioctl = sas_ioctl,
174174
.shost_attrs = isci_host_attrs,
175+
.use_blk_tags = 1,
175176
};
176177

177178
static struct sas_domain_function_template isci_transport_ops = {

drivers/scsi/libfc/fc_fcp.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -2160,12 +2160,7 @@ int fc_slave_alloc(struct scsi_device *sdev)
21602160
if (!rport || fc_remote_port_chkready(rport))
21612161
return -ENXIO;
21622162

2163-
if (sdev->tagged_supported)
2164-
scsi_activate_tcq(sdev, FC_FCP_DFLT_QUEUE_DEPTH);
2165-
else
2166-
scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev),
2167-
FC_FCP_DFLT_QUEUE_DEPTH);
2168-
2163+
scsi_adjust_queue_depth(sdev, 0, FC_FCP_DFLT_QUEUE_DEPTH);
21692164
return 0;
21702165
}
21712166
EXPORT_SYMBOL(fc_slave_alloc);

0 commit comments

Comments
 (0)