Skip to content

Commit

Permalink
scsi: always assign block layer tags if enabled
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Christoph Hellwig committed Nov 12, 2014
1 parent e2eddf4 commit 2ecb204
Show file tree
Hide file tree
Showing 33 changed files with 86 additions and 168 deletions.
38 changes: 1 addition & 37 deletions Documentation/scsi/scsi_mid_low_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,11 @@ is initialized. The functions below are listed alphabetically and their
names all start with "scsi_".

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

Details:

/**
* scsi_activate_tcq - turn on tag command queueing ("ordered" task attribute)
* @sdev: device to turn on TCQ for
* @depth: queue depth
*
* Returns nothing
*
* Might block: no
*
* Notes: Eventually, it is hoped depth would be the maximum depth
* the device could cope with and the real queue depth
* would be adjustable from 0 to depth.
*
* Defined (inline) in: include/scsi/scsi_tcq.h
**/
void scsi_activate_tcq(struct scsi_device *sdev, int depth)


/**
* scsi_add_device - creates new scsi device (lu) instance
* @shost: pointer to scsi host instance
Expand Down Expand Up @@ -471,9 +451,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device * dev)
*
* Notes: Can be invoked any time on a SCSI device controlled by this
* LLD. [Specifically during and after slave_configure() and prior to
* slave_destroy().] Can safely be invoked from interrupt code. Actual
* queue depth change may be delayed until the next command is being
* processed. See also scsi_activate_tcq() and scsi_deactivate_tcq().
* slave_destroy().] Can safely be invoked from interrupt code.
*
* Defined in: drivers/scsi/scsi.c [see source code for more notes]
*
Expand Down Expand Up @@ -514,20 +492,6 @@ unsigned char *scsi_bios_ptable(struct block_device *dev)
void scsi_block_requests(struct Scsi_Host * shost)


/**
* scsi_deactivate_tcq - turn off tag command queueing
* @sdev: device to turn off TCQ for
* @depth: queue depth (stored in sdev)
*
* Returns nothing
*
* Might block: no
*
* Defined (inline) in: include/scsi/scsi_tcq.h
**/
void scsi_deactivate_tcq(struct scsi_device *sdev, int depth)


/**
* scsi_host_alloc - create a scsi host adapter instance and perform basic
* initialization.
Expand Down
1 change: 1 addition & 0 deletions drivers/message/fusion/mptsas.c
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,7 @@ static struct scsi_host_template mptsas_driver_template = {
.cmd_per_lun = 7,
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = mptscsih_host_attrs,
.use_blk_tags = 1,
};

static int mptsas_get_linkerrors(struct sas_phy *phy)
Expand Down
12 changes: 5 additions & 7 deletions drivers/scsi/53c700.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
tpnt->slave_alloc = NCR_700_slave_alloc;
tpnt->change_queue_depth = NCR_700_change_queue_depth;
tpnt->change_queue_type = NCR_700_change_queue_type;
tpnt->use_blk_tags = 1;

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

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

scsi_set_tag_type(SDp, tag_type);

/* We have a global (per target) flag to track whether TCQ is
* enabled, so we'll be turning it off for the entire target here.
* our tag algorithm will fail if we mix tagged and untagged commands,
Expand All @@ -2106,12 +2104,12 @@ static int NCR_700_change_queue_type(struct scsi_device *SDp, int tag_type)
if (!tag_type) {
/* shift back to the default unqueued number of commands
* (the user can still raise this) */
scsi_deactivate_tcq(SDp, SDp->host->cmd_per_lun);
scsi_adjust_queue_depth(SDp, 0, SDp->host->cmd_per_lun);
hostdata->tag_negotiated &= ~(1 << sdev_id(SDp));
} else {
/* Here, we cleared the negotiation flag above, so this
* will force the driver to renegotiate */
scsi_activate_tcq(SDp, SDp->queue_depth);
scsi_adjust_queue_depth(SDp, tag_type, SDp->queue_depth);
if (change_tag)
NCR_700_set_tag_neg_state(SDp, NCR_700_START_TAG_NEGOTIATION);
}
Expand Down
11 changes: 6 additions & 5 deletions drivers/scsi/aic7xxx/aic79xx_osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ struct scsi_host_template aic79xx_driver_template = {
.slave_configure = ahd_linux_slave_configure,
.target_alloc = ahd_linux_target_alloc,
.target_destroy = ahd_linux_target_destroy,
.use_blk_tags = 1,
};

/******************************** Bus DMA *************************************/
Expand Down Expand Up @@ -1468,12 +1469,12 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev,

switch ((dev->flags & (AHD_DEV_Q_BASIC|AHD_DEV_Q_TAGGED))) {
case AHD_DEV_Q_BASIC:
scsi_set_tag_type(sdev, MSG_SIMPLE_TASK);
scsi_activate_tcq(sdev, dev->openings + dev->active);
scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TASK,
dev->openings + dev->active);
break;
case AHD_DEV_Q_TAGGED:
scsi_set_tag_type(sdev, MSG_ORDERED_TASK);
scsi_activate_tcq(sdev, dev->openings + dev->active);
scsi_adjust_queue_depth(sdev, MSG_ORDERED_TASK,
dev->openings + dev->active);
break;
default:
/*
Expand All @@ -1482,7 +1483,7 @@ ahd_platform_set_tags(struct ahd_softc *ahd, struct scsi_device *sdev,
* serially on the controller/device. This should
* remove some latency.
*/
scsi_deactivate_tcq(sdev, 1);
scsi_adjust_queue_depth(sdev, 0, 1);
break;
}
}
Expand Down
11 changes: 6 additions & 5 deletions drivers/scsi/aic7xxx/aic7xxx_osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ struct scsi_host_template aic7xxx_driver_template = {
.slave_configure = ahc_linux_slave_configure,
.target_alloc = ahc_linux_target_alloc,
.target_destroy = ahc_linux_target_destroy,
.use_blk_tags = 1,
};

/**************************** Tasklet Handler *********************************/
Expand Down Expand Up @@ -1334,12 +1335,12 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
}
switch ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED))) {
case AHC_DEV_Q_BASIC:
scsi_set_tag_type(sdev, MSG_SIMPLE_TAG);
scsi_activate_tcq(sdev, dev->openings + dev->active);
scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TASK,
dev->openings + dev->active);
break;
case AHC_DEV_Q_TAGGED:
scsi_set_tag_type(sdev, MSG_ORDERED_TAG);
scsi_activate_tcq(sdev, dev->openings + dev->active);
scsi_adjust_queue_depth(sdev, MSG_ORDERED_TASK,
dev->openings + dev->active);
break;
default:
/*
Expand All @@ -1348,7 +1349,7 @@ ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
* serially on the controller/device. This should
* remove some latency.
*/
scsi_deactivate_tcq(sdev, 2);
scsi_adjust_queue_depth(sdev, 0, 2);
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/aic94xx/aic94xx_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static struct scsi_host_template aic94xx_sht = {
.eh_bus_reset_handler = sas_eh_bus_reset_handler,
.target_destroy = sas_target_destroy,
.ioctl = sas_ioctl,
.use_blk_tags = 1,
};

static int asd_map_memio(struct asd_ha_struct *asd_ha)
Expand Down
8 changes: 3 additions & 5 deletions drivers/scsi/bfa/bfad_im.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,7 @@ bfad_thread_workq(struct bfad_s *bfad)
static int
bfad_im_slave_configure(struct scsi_device *sdev)
{
if (sdev->tagged_supported)
scsi_activate_tcq(sdev, bfa_lun_queue_depth);
else
scsi_deactivate_tcq(sdev, bfa_lun_queue_depth);

scsi_adjust_queue_depth(sdev, 0, bfa_lun_queue_depth);
return 0;
}

Expand All @@ -804,6 +800,7 @@ struct scsi_host_template bfad_im_scsi_host_template = {
.shost_attrs = bfad_im_host_attrs,
.max_sectors = BFAD_MAX_SECTORS,
.vendor_id = BFA_PCI_VENDOR_ID_BROCADE,
.use_blk_tags = 1,
};

struct scsi_host_template bfad_im_vport_template = {
Expand All @@ -825,6 +822,7 @@ struct scsi_host_template bfad_im_vport_template = {
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = bfad_im_vport_attrs,
.max_sectors = BFAD_MAX_SECTORS,
.use_blk_tags = 1,
};

bfa_status_t
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/bnx2fc/bnx2fc_fcoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -2790,6 +2790,7 @@ static struct scsi_host_template bnx2fc_shost_template = {
.use_clustering = ENABLE_CLUSTERING,
.sg_tablesize = BNX2FC_MAX_BDS_PER_CMD,
.max_sectors = 1024,
.use_blk_tags = 1,
};

static struct libfc_function_template bnx2fc_libfc_fcn_templ = {
Expand Down
8 changes: 3 additions & 5 deletions drivers/scsi/csiostor/csio_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,11 +2241,7 @@ csio_slave_alloc(struct scsi_device *sdev)
static int
csio_slave_configure(struct scsi_device *sdev)
{
if (sdev->tagged_supported)
scsi_activate_tcq(sdev, csio_lun_qdepth);
else
scsi_deactivate_tcq(sdev, csio_lun_qdepth);

scsi_adjust_queue_depth(sdev, 0, csio_lun_qdepth);
return 0;
}

Expand Down Expand Up @@ -2290,6 +2286,7 @@ struct scsi_host_template csio_fcoe_shost_template = {
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = csio_fcoe_lport_attrs,
.max_sectors = CSIO_MAX_SECTOR_SIZE,
.use_blk_tags = 1,
};

struct scsi_host_template csio_fcoe_shost_vport_template = {
Expand All @@ -2309,6 +2306,7 @@ struct scsi_host_template csio_fcoe_shost_vport_template = {
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = csio_fcoe_vport_attrs,
.max_sectors = CSIO_MAX_SECTOR_SIZE,
.use_blk_tags = 1,
};

/*
Expand Down
12 changes: 5 additions & 7 deletions drivers/scsi/esas2r/esas2r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ static struct scsi_host_template driver_template = {
.change_queue_depth = esas2r_change_queue_depth,
.change_queue_type = scsi_change_queue_type,
.max_sectors = 0xFFFF,
.use_blk_tags = 1,
};

int sgl_page_size = 512;
Expand Down Expand Up @@ -1278,13 +1279,10 @@ int esas2r_slave_configure(struct scsi_device *dev)
esas2r_log_dev(ESAS2R_LOG_INFO, &(dev->sdev_gendev),
"esas2r_slave_configure()");

if (dev->tagged_supported) {
scsi_set_tag_type(dev, MSG_SIMPLE_TAG);
scsi_activate_tcq(dev, cmd_per_lun);
} else {
scsi_set_tag_type(dev, 0);
scsi_deactivate_tcq(dev, cmd_per_lun);
}
if (dev->tagged_supported)
scsi_adjust_queue_depth(dev, MSG_SIMPLE_TAG, cmd_per_lun);
else
scsi_adjust_queue_depth(dev, 0, cmd_per_lun);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/scsi/esp_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2419,10 +2419,9 @@ static int esp_slave_configure(struct scsi_device *dev)
queue_depth = dev->host->cmd_per_lun;

if (goal_tags) {
scsi_set_tag_type(dev, MSG_ORDERED_TAG);
scsi_activate_tcq(dev, queue_depth);
scsi_adjust_queue_depth(dev, MSG_ORDERED_TAG, queue_depth);
} else {
scsi_deactivate_tcq(dev, queue_depth);
scsi_adjust_queue_depth(dev, 0, queue_depth);
}
tp->flags |= ESP_TGT_DISCONNECT;

Expand Down Expand Up @@ -2631,6 +2630,7 @@ struct scsi_host_template scsi_esp_template = {
.use_clustering = ENABLE_CLUSTERING,
.max_sectors = 0xffff,
.skip_settle_delay = 1,
.use_blk_tags = 1,
};
EXPORT_SYMBOL(scsi_esp_template);

Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/fcoe/fcoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ static struct scsi_host_template fcoe_shost_template = {
.use_clustering = ENABLE_CLUSTERING,
.sg_tablesize = SG_ALL,
.max_sectors = 0xffff,
.use_blk_tags = 1,
};

/**
Expand Down
3 changes: 2 additions & 1 deletion drivers/scsi/fnic/fnic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static int fnic_slave_alloc(struct scsi_device *sdev)
if (!rport || fc_remote_port_chkready(rport))
return -ENXIO;

scsi_activate_tcq(sdev, fnic_max_qdepth);
scsi_adjust_queue_depth(sdev, 0, fnic_max_qdepth);
return 0;
}

Expand All @@ -121,6 +121,7 @@ static struct scsi_host_template fnic_host_template = {
.sg_tablesize = FNIC_MAX_SG_DESC_CNT,
.max_sectors = 0xffff,
.shost_attrs = fnic_attrs,
.use_blk_tags = 1,
};

static void
Expand Down
11 changes: 6 additions & 5 deletions drivers/scsi/ibmvscsi/ibmvfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2888,11 +2888,11 @@ static int ibmvfc_slave_configure(struct scsi_device *sdev)
if (sdev->type == TYPE_DISK)
sdev->allow_restart = 1;

if (sdev->tagged_supported) {
scsi_set_tag_type(sdev, MSG_SIMPLE_TAG);
scsi_activate_tcq(sdev, sdev->queue_depth);
} else
scsi_deactivate_tcq(sdev, sdev->queue_depth);
if (sdev->tagged_supported)
scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG,
sdev->queue_depth);
else
scsi_adjust_queue_depth(sdev, 0, sdev->queue_depth);
spin_unlock_irqrestore(shost->host_lock, flags);
return 0;
}
Expand Down Expand Up @@ -3108,6 +3108,7 @@ static struct scsi_host_template driver_template = {
.max_sectors = IBMVFC_MAX_SECTORS,
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = ibmvfc_attrs,
.use_blk_tags = 1,
};

/**
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/ipr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6317,6 +6317,7 @@ static struct scsi_host_template driver_template = {
.sdev_attrs = ipr_dev_attrs,
.proc_name = IPR_NAME,
.no_write_same = 1,
.use_blk_tags = 1,
};

/**
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/isci/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static struct scsi_host_template isci_sht = {
.target_destroy = sas_target_destroy,
.ioctl = sas_ioctl,
.shost_attrs = isci_host_attrs,
.use_blk_tags = 1,
};

static struct sas_domain_function_template isci_transport_ops = {
Expand Down
7 changes: 1 addition & 6 deletions drivers/scsi/libfc/fc_fcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2160,12 +2160,7 @@ int fc_slave_alloc(struct scsi_device *sdev)
if (!rport || fc_remote_port_chkready(rport))
return -ENXIO;

if (sdev->tagged_supported)
scsi_activate_tcq(sdev, FC_FCP_DFLT_QUEUE_DEPTH);
else
scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev),
FC_FCP_DFLT_QUEUE_DEPTH);

scsi_adjust_queue_depth(sdev, 0, FC_FCP_DFLT_QUEUE_DEPTH);
return 0;
}
EXPORT_SYMBOL(fc_slave_alloc);
Expand Down
Loading

0 comments on commit 2ecb204

Please sign in to comment.