scsi: avoid ->change_queue_depth indirection for queue full tracking
authorChristoph Hellwig <hch@lst.de>
Thu, 13 Nov 2014 13:25:11 +0000 (14:25 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 24 Nov 2014 13:45:12 +0000 (14:45 +0100)
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>
30 files changed:
drivers/infiniband/ulp/iser/iscsi_iser.c
drivers/infiniband/ulp/srp/ib_srp.c
drivers/s390/scsi/zfcp_scsi.c
drivers/scsi/aic94xx/aic94xx_init.c
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
drivers/scsi/bnx2i/bnx2i_iscsi.c
drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
drivers/scsi/fcoe/fcoe.c
drivers/scsi/fnic/fnic_main.c
drivers/scsi/ibmvscsi/ibmvfc.c
drivers/scsi/isci/init.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/libfc/fc_fcp.c
drivers/scsi/libiscsi.c
drivers/scsi/libsas/sas_scsi_host.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/mpt2sas/mpt2sas_scsih.c
drivers/scsi/mpt3sas/mpt3sas_scsih.c
drivers/scsi/mvsas/mv_init.c
drivers/scsi/pm8001/pm8001_init.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/scsi_debug.c
drivers/scsi/scsi_error.c
drivers/scsi/ufs/ufshcd.c
drivers/scsi/virtio_scsi.c
drivers/target/loopback/tcm_loop.c
include/scsi/scsi_host.h

index f42ab14105ac61f9b29e75ae2178b7aa199df6d1..812a2891de586bd045e26383513535df00e2dfa2 100644 (file)
@@ -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 = {
index 57b5ff1bbcb6597452d8bf99b8ee7bf247cc1d4e..98a303558930e7a5ccad46ae36803b54801d4b64 100644 (file)
@@ -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.
@@ -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;
 }
 
@@ -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)
index b5dfa51f396f1c041d84affdf3255c1c3c88dbf4..179bf3d8af6cbd0465b4f6ba8c4a442a79e59715 100644 (file)
@@ -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;
 }
 
@@ -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,
 };
 
 /**
index 579dc2f460c4753a54f2bd3883d0301d24045080..a64cf932d03dcefcc9b8a1545e9d2523fd2e2424 100644 (file)
@@ -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)
index 30d74a06b9935c5ec760ce3f7f6788a7600d5a33..d9b999a3416fe0a10a09a329a409da9e6801c6f8 100644 (file)
@@ -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;
index 2262c75f45d86e40e5c584d147d24cb5ce68f4c0..cc537972f3eafcd446c10164e6482e83550fb31b 100644 (file)
@@ -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 = {
index 7a36388822aab7241baab2bbe0c751ce1526a384..9de1c20bb0f8cb8ad78702ff7d8f65b4dc24a5ef 100644 (file)
@@ -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 = {
index 49692a1ac44a59cc6a46d6a75bd2a25eca2b355c..99ea67dcdd2ae76f48b8162f64209b59a71eea0e 100644 (file)
@@ -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 = {
index 81bb3bd7909d711e2131f50a037bffc47cf70e8c..af86e8f57b842c0703d6f88679e65fff2c31a5c4 100644 (file)
@@ -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 = {
index a3eeb6842499e7b92ebd6ba22110d4bad6feb9d9..97229860398f6dbfc45f3db5c1848bd51ecf6b00 100644 (file)
@@ -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,
 };
 
 /**
index 1e5706ed9a40ddd2198931fa332e0855e603ee05..86b496c8633dbabc095cb667dc1542cd104bfa2a 100644 (file)
@@ -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
index 147b80e07b00fa9d1b434378afebde61540f3384..381449d5be766abc6e05018c7c4ac50398c1d035 100644 (file)
@@ -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,
 };
 
 /**
index 897562056018c04ad1a0f86c0ac8606b7afb43e8..a81e546595ddf410d893b99fc2108b2282fc26ae 100644 (file)
@@ -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  = {
index 427af0f24b0f2bdde43e39cdf3334518f89d2b8e..a575d845b66702b0e5fa12c104645d0f686354cc 100644 (file)
@@ -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 = {
index bf954ee050f8929d04a694622c7190a6768146d4..0d2d024e77c5e1f12b6793d6385d148aa3f6f71a 100644 (file)
@@ -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);
index d521624dedfb54e97cc28941075542c8f6fb95c9..79e977484ad521bd160fea25aba2f20622571bc9 100644 (file)
@@ -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);
index 89e8b687a6793371994979bcd04c4a6d2ffe1cd7..914e411651378a3fd54aec9cd373550bf6ba46a8 100644 (file)
@@ -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;
 }
 
index 80351fff1a0718288137101dd83d9db7b077b2f0..522854920369fde0364027da36462fc0949eb911 100644 (file)
@@ -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;
 }
 
@@ -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 = {
@@ -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,
 };
index 42fef914d441f4d85ccf302af12f327cf1d5fd3c..b006e1e9fcb8c0a94f83e4be9473b96a182e294a 100644 (file)
@@ -1229,7 +1229,7 @@ _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.
@@ -1237,12 +1237,7 @@ _scsih_adjust_queue_depth(struct scsi_device *sdev, int qdepth)
 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), "
@@ -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,
 };
 
 /**
index b23c2e7588e5b5f73eb7bed7caa0fb9ab7c7a063..568dcaed36cb8ad95f42870a0fd84e44156f7ca4 100644 (file)
@@ -1097,7 +1097,7 @@ _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.
@@ -1105,12 +1105,7 @@ _scsih_adjust_queue_depth(struct scsi_device *sdev, int qdepth)
 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), " \
@@ -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,
 };
 
 /**
index d3c1fa5e76fb3f13f29fefb1cf379d89b820e531..ac7c030784091264e73280675b73fbdf64965973 100644 (file)
@@ -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 = {
index 3ff759a3b74d15754f71ee66c56fc22bdecfecf7..19ae6cab5e44d8909bc6bf93d6ec5d8978dd0cb8 100644 (file)
@@ -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,
 };
 
 /**
index 33166ebec7d8367225eb9c9b9305f63141918308..20049b176b64d5e73c3a54d76e81959e8789171d 100644 (file)
@@ -270,6 +270,7 @@ struct scsi_host_template qla2xxx_driver_template = {
 
        .supported_mode         = MODE_INITIATOR,
        .use_blk_tags           = 1,
+       .track_queue_depth      = 1,
 };
 
 static struct scsi_transport_template *qla2xxx_transport_template = NULL;
@@ -1415,55 +1416,10 @@ qla2xxx_slave_destroy(struct scsi_device *sdev)
        sdev->hostdata = NULL;
 }
 
-static void qla2x00_handle_queue_full(struct scsi_device *sdev, int qdepth)
-{
-       fc_port_t *fcport = (struct fc_port *) sdev->hostdata;
-
-       if (!scsi_track_queue_full(sdev, qdepth))
-               return;
-
-       ql_dbg(ql_dbg_io, fcport->vha, 0x3029,
-           "Queue depth adjusted-down to %d for nexus=%ld:%d:%llu.\n",
-           sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun);
-}
-
-static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth)
-{
-       fc_port_t *fcport = sdev->hostdata;
-       struct scsi_qla_host *vha = fcport->vha;
-       struct req_que *req = NULL;
-
-       req = vha->req;
-       if (!req)
-               return;
-
-       if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth)
-               return;
-
-       scsi_adjust_queue_depth(sdev, qdepth);
-
-       ql_dbg(ql_dbg_io, vha, 0x302a,
-           "Queue depth adjusted-up to %d for nexus=%ld:%d:%llu.\n",
-           sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun);
-}
-
 static int
 qla2x00_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:
-               qla2x00_handle_queue_full(sdev, qdepth);
-               break;
-       case SCSI_QDEPTH_RAMP_UP:
-               qla2x00_adjust_sdev_qdepth_up(sdev, qdepth);
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-
+       scsi_adjust_queue_depth(sdev, qdepth);
        return sdev->queue_depth;
 }
 
index f8724f2e0158d5fca31949593d9a0df86aafada7..2bfde373ea2bf4096c5e4d782044f7e9df8f8e63 100644 (file)
@@ -164,8 +164,6 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd);
 static int qla4xxx_slave_alloc(struct scsi_device *device);
 static umode_t qla4_attr_is_visible(int param_type, int param);
 static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type);
-static int qla4xxx_change_queue_depth(struct scsi_device *sdev, int qdepth,
-                                     int reason);
 
 /*
  * iSCSI Flash DDB sysfs entry points
@@ -203,7 +201,7 @@ static struct scsi_host_template qla4xxx_driver_template = {
        .eh_timed_out           = qla4xxx_eh_cmd_timed_out,
 
        .slave_alloc            = qla4xxx_slave_alloc,
-       .change_queue_depth     = qla4xxx_change_queue_depth,
+       .change_queue_depth     = iscsi_change_queue_depth,
 
        .this_id                = -1,
        .cmd_per_lun            = 3,
@@ -9065,15 +9063,6 @@ static int qla4xxx_slave_alloc(struct scsi_device *sdev)
        return 0;
 }
 
-static int qla4xxx_change_queue_depth(struct scsi_device *sdev, int qdepth,
-                                     int reason)
-{
-       if (!ql4xqfulltracking)
-               return -EOPNOTSUPP;
-
-       return iscsi_change_queue_depth(sdev, qdepth, reason);
-}
-
 /**
  * qla4xxx_del_from_active_array - returns an active srb
  * @ha: Pointer to host adapter structure.
@@ -9873,6 +9862,9 @@ static int __init qla4xxx_module_init(void)
 {
        int ret;
 
+       if (ql4xqfulltracking)
+               qla4xxx_driver_template.track_queue_depth = 1;
+
        /* Allocate cache for SRBs. */
        srb_cachep = kmem_cache_create("qla4xxx_srbs", sizeof(struct srb), 0,
                                       SLAB_HWCACHE_ALIGN, NULL);
index fce393f3e7e05883676aaae0a7f72f488636f26b..84cf82e0782d98a77ddea374d1b170412ba48e59 100644 (file)
@@ -4472,7 +4472,6 @@ static int
 sdebug_change_qdepth(struct scsi_device *sdev, int qdepth, int reason)
 {
        int num_in_q = 0;
-       int bad = 0;
        unsigned long iflags;
        struct sdebug_dev_info *devip;
 
@@ -4484,43 +4483,18 @@ sdebug_change_qdepth(struct scsi_device *sdev, int qdepth, int reason)
        }
        num_in_q = atomic_read(&devip->num_in_q);
        spin_unlock_irqrestore(&queued_arr_lock, iflags);
-       if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP) {
-               if (qdepth < 1)
-                       qdepth = 1;
-               /* allow to exceed max host queued_arr elements for testing */
-               if (qdepth > SCSI_DEBUG_CANQUEUE + 10)
-                       qdepth = SCSI_DEBUG_CANQUEUE + 10;
-               scsi_adjust_queue_depth(sdev, qdepth);
-       } else if (reason == SCSI_QDEPTH_QFULL)
-               scsi_track_queue_full(sdev, qdepth);
-       else
-               bad = 1;
-       if (bad)
-               sdev_printk(KERN_WARNING, sdev,
-                           "%s: unknown reason=0x%x\n", __func__, reason);
+
+       if (qdepth < 1)
+               qdepth = 1;
+       /* allow to exceed max host queued_arr elements for testing */
+       if (qdepth > SCSI_DEBUG_CANQUEUE + 10)
+               qdepth = SCSI_DEBUG_CANQUEUE + 10;
+       scsi_adjust_queue_depth(sdev, qdepth);
+
        if (SCSI_DEBUG_OPT_Q_NOISE & scsi_debug_opts) {
-               if (SCSI_QDEPTH_QFULL == reason)
-                       sdev_printk(KERN_INFO, sdev,
-                           "%s: -> %d, num_in_q=%d, reason: queue full\n",
-                                   __func__, qdepth, num_in_q);
-               else {
-                       const char *cp;
-
-                       switch (reason) {
-                       case SCSI_QDEPTH_DEFAULT:
-                               cp = "default (sysfs ?)";
-                               break;
-                       case SCSI_QDEPTH_RAMP_UP:
-                               cp = "ramp up";
-                               break;
-                       default:
-                               cp = "unknown";
-                               break;
-                       }
-                       sdev_printk(KERN_INFO, sdev,
-                                   "%s: qdepth=%d, num_in_q=%d, reason: %s\n",
-                                   __func__, qdepth, num_in_q, cp);
-               }
+               sdev_printk(KERN_INFO, sdev,
+                           "%s: qdepth=%d, num_in_q=%d\n",
+                           __func__, qdepth, num_in_q);
        }
        return sdev->queue_depth;
 }
@@ -4576,6 +4550,7 @@ static struct scsi_host_template sdebug_driver_template = {
        .max_sectors =          -1U,
        .use_clustering =       DISABLE_CLUSTERING,
        .module =               THIS_MODULE,
+       .track_queue_depth =    1,
 };
 
 static int sdebug_driver_probe(struct device * dev)
index a6f6b9222b515577ba7619f912043ed09653d63f..2d0f5155ee518238fb5a53c78d61f662dcc202f8 100644 (file)
@@ -610,7 +610,7 @@ static void scsi_handle_queue_ramp_up(struct scsi_device *sdev)
        struct scsi_host_template *sht = sdev->host->hostt;
        struct scsi_device *tmp_sdev;
 
-       if (!sht->change_queue_depth ||
+       if (!sht->track_queue_depth ||
            sdev->queue_depth >= sdev->max_queue_depth)
                return;
 
@@ -631,12 +631,8 @@ static void scsi_handle_queue_ramp_up(struct scsi_device *sdev)
                    tmp_sdev->id != sdev->id ||
                    tmp_sdev->queue_depth == sdev->max_queue_depth)
                        continue;
-               /*
-                * call back into LLD to increase queue_depth by one
-                * with ramp up reason code.
-                */
-               sht->change_queue_depth(tmp_sdev, tmp_sdev->queue_depth + 1,
-                                       SCSI_QDEPTH_RAMP_UP);
+
+               scsi_adjust_queue_depth(tmp_sdev, tmp_sdev->queue_depth + 1);
                sdev->last_queue_ramp_up = jiffies;
        }
 }
@@ -646,7 +642,7 @@ static void scsi_handle_queue_full(struct scsi_device *sdev)
        struct scsi_host_template *sht = sdev->host->hostt;
        struct scsi_device *tmp_sdev;
 
-       if (!sht->change_queue_depth)
+       if (!sht->track_queue_depth)
                return;
 
        shost_for_each_device(tmp_sdev, sdev->host) {
@@ -658,8 +654,7 @@ static void scsi_handle_queue_full(struct scsi_device *sdev)
                 * the device when we got the queue full so we start
                 * from the highest possible value and work our way down.
                 */
-               sht->change_queue_depth(tmp_sdev, tmp_sdev->queue_depth - 1,
-                                       SCSI_QDEPTH_QFULL);
+               scsi_track_queue_full(tmp_sdev, tmp_sdev->queue_depth - 1);
        }
 }
 
index 362b818ad827df6786f1a4c186c3e699e3a5e52b..e96ab253e3e5bd2618954b26b70a719e5603db08 100644 (file)
@@ -2800,18 +2800,7 @@ static int ufshcd_change_queue_depth(struct scsi_device *sdev,
        if (depth > hba->nutrs)
                depth = hba->nutrs;
 
-       switch (reason) {
-       case SCSI_QDEPTH_DEFAULT:
-       case SCSI_QDEPTH_RAMP_UP:
-               scsi_adjust_queue_depth(sdev, depth);
-               break;
-       case SCSI_QDEPTH_QFULL:
-               scsi_track_queue_full(sdev, depth);
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-
+       scsi_adjust_queue_depth(sdev, depth);
        return depth;
 }
 
@@ -4231,6 +4220,7 @@ static struct scsi_host_template ufshcd_driver_template = {
        .can_queue              = UFSHCD_CAN_QUEUE,
        .max_host_blocked       = 1,
        .use_blk_tags           = 1,
+       .track_queue_depth      = 1,
 };
 
 static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
index 8e40347da0a8eb9c36374193ea997674344697d5..0f7e4c7ff8c2d6a19efa0c640f9bcb3a4cdec1c3 100644 (file)
@@ -691,18 +691,7 @@ static int virtscsi_change_queue_depth(struct scsi_device *sdev,
        struct Scsi_Host *shost = sdev->host;
        int max_depth = shost->cmd_per_lun;
 
-       switch (reason) {
-       case SCSI_QDEPTH_QFULL: /* Drop qdepth in response to BUSY state */
-               scsi_track_queue_full(sdev, qdepth);
-               break;
-       case SCSI_QDEPTH_RAMP_UP: /* Raise qdepth after BUSY state resolved */
-       case SCSI_QDEPTH_DEFAULT: /* Manual change via sysfs */
-               scsi_adjust_queue_depth(sdev, min(max_depth, qdepth));
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-
+       scsi_adjust_queue_depth(sdev, min(max_depth, qdepth));
        return sdev->queue_depth;
 }
 
@@ -770,6 +759,7 @@ static struct scsi_host_template virtscsi_host_template_single = {
        .use_clustering = ENABLE_CLUSTERING,
        .target_alloc = virtscsi_target_alloc,
        .target_destroy = virtscsi_target_destroy,
+       .track_queue_depth = 1,
 };
 
 static struct scsi_host_template virtscsi_host_template_multi = {
@@ -788,6 +778,7 @@ static struct scsi_host_template virtscsi_host_template_multi = {
        .use_clustering = ENABLE_CLUSTERING,
        .target_alloc = virtscsi_target_alloc,
        .target_destroy = virtscsi_target_destroy,
+       .track_queue_depth = 1,
 };
 
 #define virtscsi_config_get(vdev, fld) \
index 0ed96644ec944e3afb22ce8cc52a83141849b20d..670b75a62243c59fc9129b4f1f119fd0d584202a 100644 (file)
@@ -119,19 +119,7 @@ static int tcm_loop_change_queue_depth(
        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;
 }
 
@@ -423,6 +411,7 @@ static struct scsi_host_template tcm_loop_driver_template = {
        .slave_alloc            = tcm_loop_slave_alloc,
        .module                 = THIS_MODULE,
        .use_blk_tags           = 1,
+       .track_queue_depth      = 1,
 };
 
 static int tcm_loop_driver_probe(struct device *dev)
index 61a81bf77e287746df4c7359d9ae24cb2eed7c44..a0b13a5cd25e91aa1c08c45241a368f1728ccd7e 100644 (file)
@@ -48,8 +48,6 @@ struct blk_queue_tags;
 
 enum {
        SCSI_QDEPTH_DEFAULT,    /* default requested change, e.g. from sysfs */
-       SCSI_QDEPTH_QFULL,      /* scsi-ml requested due to queue full */
-       SCSI_QDEPTH_RAMP_UP,    /* scsi-ml requested due to threshold event */
 };
 
 struct scsi_host_template {
@@ -426,6 +424,11 @@ struct scsi_host_template {
         */
        unsigned use_blk_tags:1;
 
+       /*
+        * Track QUEUE_FULL events and reduce queue depth on demand.
+        */
+       unsigned track_queue_depth:1;
+
        /*
         * This specifies the mode that a LLD supports.
         */