]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
scsi: don't allow setting of queue_depth bigger than can_queue
authorChristoph Hellwig <hch@lst.de>
Thu, 13 Nov 2014 13:27:41 +0000 (14:27 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 24 Nov 2014 13:45:26 +0000 (14:45 +0100)
We won't ever queue more commands than the host allows.  Instead of
letting drivers either reject or ignore this case handle it in
common code.  Note that various driver use internal constant or
variables that are assigned to both shost->can_queue and checked
in ->change_queue_depth - I did remove those checks as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Hannes Reinecke <hare@suse.de>
drivers/infiniband/ulp/srp/ib_srp.c
drivers/scsi/3w-9xxx.c
drivers/scsi/3w-sas.c
drivers/scsi/3w-xxxx.c
drivers/scsi/hpsa.c
drivers/scsi/megaraid/megaraid_mbox.c
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/scsi_sysfs.c
drivers/scsi/vmw_pvscsi.c

index 98a303558930e7a5ccad46ae36803b54801d4b64..8d13a19e04b2d96fda8dce1e32985aa191fb812f 100644 (file)
@@ -2410,14 +2410,8 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
 static int
 srp_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
 {
-       struct Scsi_Host *shost = sdev->host;
-       int max_depth;
-
-       max_depth = shost->can_queue;
        if (!sdev->tagged_supported)
-               max_depth = 1;
-       if (qdepth > max_depth)
-               qdepth = max_depth;
+               qdepth = 1;
        scsi_adjust_queue_depth(sdev, qdepth);
        return sdev->queue_depth;
 }
index 02021f5ca8669c2f36d120784e72e5860519dcb2..1cf37032290a884e3050c4fa57a152efb717f5ec 100644 (file)
@@ -196,8 +196,6 @@ static int twa_change_queue_depth(struct scsi_device *sdev, int queue_depth,
        if (reason != SCSI_QDEPTH_DEFAULT)
                return -EOPNOTSUPP;
 
-       if (queue_depth > TW_Q_LENGTH-2)
-               queue_depth = TW_Q_LENGTH-2;
        scsi_adjust_queue_depth(sdev, queue_depth);
        return queue_depth;
 } /* End twa_change_queue_depth() */
index ac0c2544a47026058059f3d6c077fb851f205aff..547756b7d5bf85caa608aab176b8733bb234f5f0 100644 (file)
@@ -198,8 +198,6 @@ static int twl_change_queue_depth(struct scsi_device *sdev, int queue_depth,
        if (reason != SCSI_QDEPTH_DEFAULT)
                return -EOPNOTSUPP;
 
-       if (queue_depth > TW_Q_LENGTH-2)
-               queue_depth = TW_Q_LENGTH-2;
        scsi_adjust_queue_depth(sdev, queue_depth);
        return queue_depth;
 } /* End twl_change_queue_depth() */
index 1ec9ad92b6c3853fad1699d3944f8aae4d5d1a8e..261a4c1da962819670e90a008b9a852c1b9181bc 100644 (file)
@@ -530,8 +530,6 @@ static int tw_change_queue_depth(struct scsi_device *sdev, int queue_depth,
        if (reason != SCSI_QDEPTH_DEFAULT)
                return -EOPNOTSUPP;
 
-       if (queue_depth > TW_Q_LENGTH-2)
-               queue_depth = TW_Q_LENGTH-2;
        scsi_adjust_queue_depth(sdev, queue_depth);
        return queue_depth;
 } /* End tw_change_queue_depth() */
index 3569f42019426502253809ca067f16106e82046a..617f218e2a16c5ed07e80929886dd1df3728adf0 100644 (file)
@@ -4082,11 +4082,6 @@ static int hpsa_change_queue_depth(struct scsi_device *sdev,
        if (reason != SCSI_QDEPTH_DEFAULT)
                return -ENOTSUPP;
 
-       if (qdepth < 1)
-               qdepth = 1;
-       else
-               if (qdepth > h->nr_cmds)
-                       qdepth = h->nr_cmds;
        scsi_adjust_queue_depth(sdev, qdepth);
        return sdev->queue_depth;
 }
index 6b077d839f2bf4c32de70ea3d98b44c6417edcd8..d56eb9d3d40ca1e8c1f1c8d6620224664669395b 100644 (file)
@@ -347,8 +347,6 @@ static int megaraid_change_queue_depth(struct scsi_device *sdev, int qdepth,
        if (reason != SCSI_QDEPTH_DEFAULT)
                return -EOPNOTSUPP;
 
-       if (qdepth > MBOX_MAX_SCSI_CMDS)
-               qdepth = MBOX_MAX_SCSI_CMDS;
        scsi_adjust_queue_depth(sdev, qdepth);
        return sdev->queue_depth;
 }
index 3ccfbec682d0ed2346ce8c540e0e3aea4900ce71..69a9dd6ae04c6907400effdac7cc39ecaf026a5f 100644 (file)
@@ -2597,8 +2597,6 @@ static int megasas_change_queue_depth(struct scsi_device *sdev,
        if (reason != SCSI_QDEPTH_DEFAULT)
                return -EOPNOTSUPP;
 
-       if (queue_depth > sdev->host->can_queue)
-               queue_depth = sdev->host->can_queue;
        scsi_adjust_queue_depth(sdev, queue_depth);
 
        return queue_depth;
index 35d93b0af82b8163e5e9c1653689903e8814fd7c..bffd5abdcd1febbab4e5b2b3024c33026db29203 100644 (file)
@@ -877,7 +877,7 @@ sdev_store_queue_depth(struct device *dev, struct device_attribute *attr,
 
        depth = simple_strtoul(buf, NULL, 0);
 
-       if (depth < 1)
+       if (depth < 1 || depth > sht->can_queue)
                return -EINVAL;
 
        retval = sht->change_queue_depth(sdev, depth,
index 4a01c0598a2f891e8b12a1f4123cf751432643d7..03ad24be728e9ea68f35abf6a259f96752882927 100644 (file)
@@ -508,20 +508,14 @@ static int pvscsi_change_queue_depth(struct scsi_device *sdev,
                                     int qdepth,
                                     int reason)
 {
-       int max_depth;
-       struct Scsi_Host *shost = sdev->host;
-
        if (reason != SCSI_QDEPTH_DEFAULT)
                /*
                 * We support only changing default.
                 */
                return -EOPNOTSUPP;
 
-       max_depth = shost->can_queue;
        if (!sdev->tagged_supported)
-               max_depth = 1;
-       if (qdepth > max_depth)
-               qdepth = max_depth;
+               qdepth = 1;
        scsi_adjust_queue_depth(sdev, qdepth);
 
        if (sdev->inquiry_len > 7)