Skip to content

Commit

Permalink
scsi: avoid ->change_queue_depth indirection for queue full tracking
Browse files Browse the repository at this point in the history
All drivers use the implementation for ramping the queue up and down, so
instead of overloading the change_queue_depth method call the
implementation diretly if the driver opts into it by setting the
track_queue_depth flag in the host template.

Note that a few drivers validated the new queue depth in their
change_queue_depth method, but as we never go over the queue depth
set during slave_configure or the sysfs file this isn't nessecary
and can safely be removed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Venkatesh Srinivas <venkateshs@google.com>
  • Loading branch information
Christoph Hellwig committed Nov 24, 2014
1 parent 89dac7b commit c40ecc1
Show file tree
Hide file tree
Showing 30 changed files with 73 additions and 244 deletions.
1 change: 1 addition & 0 deletions drivers/infiniband/ulp/iser/iscsi_iser.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ static struct scsi_host_template iscsi_iser_sht = {
.use_clustering = DISABLE_CLUSTERING,
.proc_name = "iscsi_iser",
.this_id = -1,
.track_queue_depth = 1,
};

static struct iscsi_transport iscsi_iser_transport = {
Expand Down
20 changes: 8 additions & 12 deletions drivers/infiniband/ulp/srp/ib_srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,7 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
* srp_change_queue_depth - setting device queue depth
* @sdev: scsi device struct
* @qdepth: requested queue depth
* @reason: SCSI_QDEPTH_DEFAULT/SCSI_QDEPTH_QFULL/SCSI_QDEPTH_RAMP_UP
* @reason: SCSI_QDEPTH_DEFAULT
* (see include/scsi/scsi_host.h for definition)
*
* Returns queue depth.
Expand All @@ -2412,18 +2412,13 @@ srp_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
{
struct Scsi_Host *shost = sdev->host;
int max_depth;
if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP) {
max_depth = shost->can_queue;
if (!sdev->tagged_supported)
max_depth = 1;
if (qdepth > max_depth)
qdepth = max_depth;
scsi_adjust_queue_depth(sdev, qdepth);
} else if (reason == SCSI_QDEPTH_QFULL)
scsi_track_queue_full(sdev, qdepth);
else
return -EOPNOTSUPP;

max_depth = shost->can_queue;
if (!sdev->tagged_supported)
max_depth = 1;
if (qdepth > max_depth)
qdepth = max_depth;
scsi_adjust_queue_depth(sdev, qdepth);
return sdev->queue_depth;
}

Expand Down Expand Up @@ -2766,6 +2761,7 @@ static struct scsi_host_template srp_template = {
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = srp_host_attrs,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

static int srp_sdev_count(struct Scsi_Host *host)
Expand Down
15 changes: 2 additions & 13 deletions drivers/s390/scsi/zfcp_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,7 @@ MODULE_PARM_DESC(allow_lun_scan, "For NPIV, scan and attach all storage LUNs");
static int zfcp_scsi_change_queue_depth(struct scsi_device *sdev, int depth,
int reason)
{
switch (reason) {
case SCSI_QDEPTH_DEFAULT:
scsi_adjust_queue_depth(sdev, depth);
break;
case SCSI_QDEPTH_QFULL:
scsi_track_queue_full(sdev, depth);
break;
case SCSI_QDEPTH_RAMP_UP:
scsi_adjust_queue_depth(sdev, depth);
break;
default:
return -EOPNOTSUPP;
}
scsi_adjust_queue_depth(sdev, depth);
return sdev->queue_depth;
}

Expand Down Expand Up @@ -320,6 +308,7 @@ static struct scsi_host_template zfcp_scsi_host_template = {
.use_clustering = 1,
.shost_attrs = zfcp_sysfs_shost_attrs,
.sdev_attrs = zfcp_sysfs_sdev_attrs,
.track_queue_depth = 1,
};

/**
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 @@ -84,6 +84,7 @@ static struct scsi_host_template aic94xx_sht = {
.target_destroy = sas_target_destroy,
.ioctl = sas_ioctl,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

static int asd_map_memio(struct asd_ha_struct *asd_ha)
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/be2iscsi/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ static struct scsi_host_template beiscsi_sht = {
.cmd_per_lun = BEISCSI_CMD_PER_LUN,
.use_clustering = ENABLE_CLUSTERING,
.vendor_id = SCSI_NL_VID_TYPE_PCI | BE_VENDOR_ID,

.track_queue_depth = 1,
};

static struct scsi_transport_template *beiscsi_scsi_transport;
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 @@ -2792,6 +2792,7 @@ static struct scsi_host_template bnx2fc_shost_template = {
.sg_tablesize = BNX2FC_MAX_BDS_PER_CMD,
.max_sectors = 1024,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

static struct libfc_function_template bnx2fc_libfc_fcn_templ = {
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/bnx2i/bnx2i_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,7 @@ static struct scsi_host_template bnx2i_host_template = {
.use_clustering = ENABLE_CLUSTERING,
.sg_tablesize = ISCSI_MAX_BDS_PER_CMD,
.shost_attrs = bnx2i_dev_attributes,
.track_queue_depth = 1,
};

struct iscsi_transport bnx2i_iscsi_transport = {
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static struct scsi_host_template cxgb3i_host_template = {
.target_alloc = iscsi_target_alloc,
.use_clustering = DISABLE_CLUSTERING,
.this_id = -1,
.track_queue_depth = 1,
};

static struct iscsi_transport cxgb3i_iscsi_transport = {
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ static struct scsi_host_template cxgb4i_host_template = {
.target_alloc = iscsi_target_alloc,
.use_clustering = DISABLE_CLUSTERING,
.this_id = -1,
.track_queue_depth = 1,
};

static struct iscsi_transport cxgb4i_iscsi_transport = {
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 @@ -289,6 +289,7 @@ static struct scsi_host_template fcoe_shost_template = {
.sg_tablesize = SG_ALL,
.max_sectors = 0xffff,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

/**
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/fnic/fnic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ static struct scsi_host_template fnic_host_template = {
.max_sectors = 0xffff,
.shost_attrs = fnic_attrs,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

static void
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/ibmvscsi/ibmvfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3103,6 +3103,7 @@ static struct scsi_host_template driver_template = {
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = ibmvfc_attrs,
.use_blk_tags = 1,
.track_queue_depth = 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 @@ -173,6 +173,7 @@ static struct scsi_host_template isci_sht = {
.ioctl = sas_ioctl,
.shost_attrs = isci_host_attrs,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

static struct sas_domain_function_template isci_transport_ops = {
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/iscsi_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ static struct scsi_host_template iscsi_sw_tcp_sht = {
.target_alloc = iscsi_target_alloc,
.proc_name = "iscsi_tcp",
.this_id = -1,
.track_queue_depth = 1,
};

static struct iscsi_transport iscsi_sw_tcp_transport = {
Expand Down
14 changes: 1 addition & 13 deletions drivers/scsi/libfc/fc_fcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2173,19 +2173,7 @@ EXPORT_SYMBOL(fc_slave_alloc);
*/
int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
{
switch (reason) {
case SCSI_QDEPTH_DEFAULT:
scsi_adjust_queue_depth(sdev, qdepth);
break;
case SCSI_QDEPTH_QFULL:
scsi_track_queue_full(sdev, qdepth);
break;
case SCSI_QDEPTH_RAMP_UP:
scsi_adjust_queue_depth(sdev, qdepth);
break;
default:
return -EOPNOTSUPP;
}
scsi_adjust_queue_depth(sdev, qdepth);
return sdev->queue_depth;
}
EXPORT_SYMBOL(fc_change_queue_depth);
Expand Down
14 changes: 1 addition & 13 deletions drivers/scsi/libiscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1773,19 +1773,7 @@ EXPORT_SYMBOL_GPL(iscsi_queuecommand);

int iscsi_change_queue_depth(struct scsi_device *sdev, int depth, int reason)
{
switch (reason) {
case SCSI_QDEPTH_DEFAULT:
scsi_adjust_queue_depth(sdev, depth);
break;
case SCSI_QDEPTH_QFULL:
scsi_track_queue_full(sdev, depth);
break;
case SCSI_QDEPTH_RAMP_UP:
scsi_adjust_queue_depth(sdev, depth);
break;
default:
return -EOPNOTSUPP;
}
scsi_adjust_queue_depth(sdev, depth);
return sdev->queue_depth;
}
EXPORT_SYMBOL_GPL(iscsi_change_queue_depth);
Expand Down
17 changes: 3 additions & 14 deletions drivers/scsi/libsas/sas_scsi_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,20 +961,9 @@ int sas_change_queue_depth(struct scsi_device *sdev, int depth, int reason)
return __ata_change_queue_depth(dev->sata_dev.ap, sdev, depth,
reason);

switch (reason) {
case SCSI_QDEPTH_DEFAULT:
case SCSI_QDEPTH_RAMP_UP:
if (!sdev->tagged_supported)
depth = 1;
scsi_adjust_queue_depth(sdev, depth);
break;
case SCSI_QDEPTH_QFULL:
scsi_track_queue_full(sdev, depth);
break;
default:
return -EOPNOTSUPP;
}

if (!sdev->tagged_supported)
depth = 1;
scsi_adjust_queue_depth(sdev, depth);
return depth;
}

Expand Down
23 changes: 3 additions & 20 deletions drivers/scsi/lpfc/lpfc_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,26 +255,7 @@ lpfc_update_stats(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
static int
lpfc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
{
struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;

switch (reason) {
case SCSI_QDEPTH_DEFAULT:
/* change request from sysfs, fall through */
case SCSI_QDEPTH_RAMP_UP:
scsi_adjust_queue_depth(sdev, qdepth);
break;
case SCSI_QDEPTH_QFULL:
if (scsi_track_queue_full(sdev, qdepth) == 0)
return sdev->queue_depth;

lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
"0711 detected queue full - lun queue "
"depth adjusted to %d.\n", sdev->queue_depth);
break;
default:
return -EOPNOTSUPP;
}

scsi_adjust_queue_depth(sdev, qdepth);
return sdev->queue_depth;
}

Expand Down Expand Up @@ -5918,6 +5899,7 @@ struct scsi_host_template lpfc_template = {
.change_queue_depth = lpfc_change_queue_depth,
.change_queue_type = scsi_change_queue_type,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

struct scsi_host_template lpfc_vport_template = {
Expand All @@ -5942,4 +5924,5 @@ struct scsi_host_template lpfc_vport_template = {
.change_queue_depth = lpfc_change_queue_depth,
.change_queue_type = scsi_change_queue_type,
.use_blk_tags = 1,
.track_queue_depth = 1,
};
10 changes: 3 additions & 7 deletions drivers/scsi/mpt2sas/mpt2sas_scsih.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,20 +1229,15 @@ _scsih_adjust_queue_depth(struct scsi_device *sdev, int qdepth)
* _scsih_change_queue_depth - setting device queue depth
* @sdev: scsi device struct
* @qdepth: requested queue depth
* @reason: SCSI_QDEPTH_DEFAULT/SCSI_QDEPTH_QFULL/SCSI_QDEPTH_RAMP_UP
* @reason: SCSI_QDEPTH_DEFAULT
* (see include/scsi/scsi_host.h for definition)
*
* Returns queue depth.
*/
static int
_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
{
if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP)
_scsih_adjust_queue_depth(sdev, qdepth);
else if (reason == SCSI_QDEPTH_QFULL)
scsi_track_queue_full(sdev, qdepth);
else
return -EOPNOTSUPP;
_scsih_adjust_queue_depth(sdev, qdepth);

if (sdev->inquiry_len > 7)
sdev_printk(KERN_INFO, sdev, "qdepth(%d), tagged(%d), "
Expand Down Expand Up @@ -7637,6 +7632,7 @@ static struct scsi_host_template scsih_driver_template = {
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = mpt2sas_host_attrs,
.sdev_attrs = mpt2sas_dev_attrs,
.track_queue_depth = 1,
};

/**
Expand Down
10 changes: 3 additions & 7 deletions drivers/scsi/mpt3sas/mpt3sas_scsih.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,20 +1097,15 @@ _scsih_adjust_queue_depth(struct scsi_device *sdev, int qdepth)
* _scsih_change_queue_depth - setting device queue depth
* @sdev: scsi device struct
* @qdepth: requested queue depth
* @reason: SCSI_QDEPTH_DEFAULT/SCSI_QDEPTH_QFULL/SCSI_QDEPTH_RAMP_UP
* @reason: SCSI_QDEPTH_DEFAULT
* (see include/scsi/scsi_host.h for definition)
*
* Returns queue depth.
*/
static int
_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
{
if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP)
_scsih_adjust_queue_depth(sdev, qdepth);
else if (reason == SCSI_QDEPTH_QFULL)
scsi_track_queue_full(sdev, qdepth);
else
return -EOPNOTSUPP;
_scsih_adjust_queue_depth(sdev, qdepth);

if (sdev->inquiry_len > 7)
sdev_printk(KERN_INFO, sdev, "qdepth(%d), tagged(%d), " \
Expand Down Expand Up @@ -7266,6 +7261,7 @@ static struct scsi_host_template scsih_driver_template = {
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = mpt3sas_host_attrs,
.sdev_attrs = mpt3sas_dev_attrs,
.track_queue_depth = 1,
};

/**
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/mvsas/mv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static struct scsi_host_template mvs_sht = {
.ioctl = sas_ioctl,
.shost_attrs = mvst_host_attrs,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

static struct sas_domain_function_template mvs_transport_ops = {
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/pm8001/pm8001_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static struct scsi_host_template pm8001_sht = {
.ioctl = sas_ioctl,
.shost_attrs = pm8001_host_attrs,
.use_blk_tags = 1,
.track_queue_depth = 1,
};

/**
Expand Down
Loading

0 comments on commit c40ecc1

Please sign in to comment.