diff options
author | Christoph Hellwig <hch@lst.de> | 2014-11-13 08:27:41 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-11-24 08:45:26 -0500 |
commit | 1e6f2416044c062a56091ebf8d76760956dd5872 (patch) | |
tree | 53b83ab97cc475c37f957bb85167ae8cb2ccd550 | |
parent | c40ecc12cfdb630332198a04e2832ae8218a61f1 (diff) |
scsi: don't allow setting of queue_depth bigger than can_queue
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>
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 8 | ||||
-rw-r--r-- | drivers/scsi/3w-9xxx.c | 2 | ||||
-rw-r--r-- | drivers/scsi/3w-sas.c | 2 | ||||
-rw-r--r-- | drivers/scsi/3w-xxxx.c | 2 | ||||
-rw-r--r-- | drivers/scsi/hpsa.c | 5 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_mbox.c | 2 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas_base.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 2 | ||||
-rw-r--r-- | drivers/scsi/vmw_pvscsi.c | 8 |
9 files changed, 3 insertions, 30 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 98a303558930..8d13a19e04b2 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -2410,14 +2410,8 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | |||
2410 | static int | 2410 | static int |
2411 | srp_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) | 2411 | srp_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) |
2412 | { | 2412 | { |
2413 | struct Scsi_Host *shost = sdev->host; | ||
2414 | int max_depth; | ||
2415 | |||
2416 | max_depth = shost->can_queue; | ||
2417 | if (!sdev->tagged_supported) | 2413 | if (!sdev->tagged_supported) |
2418 | max_depth = 1; | 2414 | qdepth = 1; |
2419 | if (qdepth > max_depth) | ||
2420 | qdepth = max_depth; | ||
2421 | scsi_adjust_queue_depth(sdev, qdepth); | 2415 | scsi_adjust_queue_depth(sdev, qdepth); |
2422 | return sdev->queue_depth; | 2416 | return sdev->queue_depth; |
2423 | } | 2417 | } |
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 02021f5ca866..1cf37032290a 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -196,8 +196,6 @@ static int twa_change_queue_depth(struct scsi_device *sdev, int queue_depth, | |||
196 | if (reason != SCSI_QDEPTH_DEFAULT) | 196 | if (reason != SCSI_QDEPTH_DEFAULT) |
197 | return -EOPNOTSUPP; | 197 | return -EOPNOTSUPP; |
198 | 198 | ||
199 | if (queue_depth > TW_Q_LENGTH-2) | ||
200 | queue_depth = TW_Q_LENGTH-2; | ||
201 | scsi_adjust_queue_depth(sdev, queue_depth); | 199 | scsi_adjust_queue_depth(sdev, queue_depth); |
202 | return queue_depth; | 200 | return queue_depth; |
203 | } /* End twa_change_queue_depth() */ | 201 | } /* End twa_change_queue_depth() */ |
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index ac0c2544a470..547756b7d5bf 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c | |||
@@ -198,8 +198,6 @@ static int twl_change_queue_depth(struct scsi_device *sdev, int queue_depth, | |||
198 | if (reason != SCSI_QDEPTH_DEFAULT) | 198 | if (reason != SCSI_QDEPTH_DEFAULT) |
199 | return -EOPNOTSUPP; | 199 | return -EOPNOTSUPP; |
200 | 200 | ||
201 | if (queue_depth > TW_Q_LENGTH-2) | ||
202 | queue_depth = TW_Q_LENGTH-2; | ||
203 | scsi_adjust_queue_depth(sdev, queue_depth); | 201 | scsi_adjust_queue_depth(sdev, queue_depth); |
204 | return queue_depth; | 202 | return queue_depth; |
205 | } /* End twl_change_queue_depth() */ | 203 | } /* End twl_change_queue_depth() */ |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 1ec9ad92b6c3..261a4c1da962 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -530,8 +530,6 @@ static int tw_change_queue_depth(struct scsi_device *sdev, int queue_depth, | |||
530 | if (reason != SCSI_QDEPTH_DEFAULT) | 530 | if (reason != SCSI_QDEPTH_DEFAULT) |
531 | return -EOPNOTSUPP; | 531 | return -EOPNOTSUPP; |
532 | 532 | ||
533 | if (queue_depth > TW_Q_LENGTH-2) | ||
534 | queue_depth = TW_Q_LENGTH-2; | ||
535 | scsi_adjust_queue_depth(sdev, queue_depth); | 533 | scsi_adjust_queue_depth(sdev, queue_depth); |
536 | return queue_depth; | 534 | return queue_depth; |
537 | } /* End tw_change_queue_depth() */ | 535 | } /* End tw_change_queue_depth() */ |
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 3569f4201942..617f218e2a16 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -4082,11 +4082,6 @@ static int hpsa_change_queue_depth(struct scsi_device *sdev, | |||
4082 | if (reason != SCSI_QDEPTH_DEFAULT) | 4082 | if (reason != SCSI_QDEPTH_DEFAULT) |
4083 | return -ENOTSUPP; | 4083 | return -ENOTSUPP; |
4084 | 4084 | ||
4085 | if (qdepth < 1) | ||
4086 | qdepth = 1; | ||
4087 | else | ||
4088 | if (qdepth > h->nr_cmds) | ||
4089 | qdepth = h->nr_cmds; | ||
4090 | scsi_adjust_queue_depth(sdev, qdepth); | 4085 | scsi_adjust_queue_depth(sdev, qdepth); |
4091 | return sdev->queue_depth; | 4086 | return sdev->queue_depth; |
4092 | } | 4087 | } |
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 6b077d839f2b..d56eb9d3d40c 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
@@ -347,8 +347,6 @@ static int megaraid_change_queue_depth(struct scsi_device *sdev, int qdepth, | |||
347 | if (reason != SCSI_QDEPTH_DEFAULT) | 347 | if (reason != SCSI_QDEPTH_DEFAULT) |
348 | return -EOPNOTSUPP; | 348 | return -EOPNOTSUPP; |
349 | 349 | ||
350 | if (qdepth > MBOX_MAX_SCSI_CMDS) | ||
351 | qdepth = MBOX_MAX_SCSI_CMDS; | ||
352 | scsi_adjust_queue_depth(sdev, qdepth); | 350 | scsi_adjust_queue_depth(sdev, qdepth); |
353 | return sdev->queue_depth; | 351 | return sdev->queue_depth; |
354 | } | 352 | } |
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 3ccfbec682d0..69a9dd6ae04c 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c | |||
@@ -2597,8 +2597,6 @@ static int megasas_change_queue_depth(struct scsi_device *sdev, | |||
2597 | if (reason != SCSI_QDEPTH_DEFAULT) | 2597 | if (reason != SCSI_QDEPTH_DEFAULT) |
2598 | return -EOPNOTSUPP; | 2598 | return -EOPNOTSUPP; |
2599 | 2599 | ||
2600 | if (queue_depth > sdev->host->can_queue) | ||
2601 | queue_depth = sdev->host->can_queue; | ||
2602 | scsi_adjust_queue_depth(sdev, queue_depth); | 2600 | scsi_adjust_queue_depth(sdev, queue_depth); |
2603 | 2601 | ||
2604 | return queue_depth; | 2602 | return queue_depth; |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 35d93b0af82b..bffd5abdcd1f 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -877,7 +877,7 @@ sdev_store_queue_depth(struct device *dev, struct device_attribute *attr, | |||
877 | 877 | ||
878 | depth = simple_strtoul(buf, NULL, 0); | 878 | depth = simple_strtoul(buf, NULL, 0); |
879 | 879 | ||
880 | if (depth < 1) | 880 | if (depth < 1 || depth > sht->can_queue) |
881 | return -EINVAL; | 881 | return -EINVAL; |
882 | 882 | ||
883 | retval = sht->change_queue_depth(sdev, depth, | 883 | retval = sht->change_queue_depth(sdev, depth, |
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 4a01c0598a2f..03ad24be728e 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c | |||
@@ -508,20 +508,14 @@ static int pvscsi_change_queue_depth(struct scsi_device *sdev, | |||
508 | int qdepth, | 508 | int qdepth, |
509 | int reason) | 509 | int reason) |
510 | { | 510 | { |
511 | int max_depth; | ||
512 | struct Scsi_Host *shost = sdev->host; | ||
513 | |||
514 | if (reason != SCSI_QDEPTH_DEFAULT) | 511 | if (reason != SCSI_QDEPTH_DEFAULT) |
515 | /* | 512 | /* |
516 | * We support only changing default. | 513 | * We support only changing default. |
517 | */ | 514 | */ |
518 | return -EOPNOTSUPP; | 515 | return -EOPNOTSUPP; |
519 | 516 | ||
520 | max_depth = shost->can_queue; | ||
521 | if (!sdev->tagged_supported) | 517 | if (!sdev->tagged_supported) |
522 | max_depth = 1; | 518 | qdepth = 1; |
523 | if (qdepth > max_depth) | ||
524 | qdepth = max_depth; | ||
525 | scsi_adjust_queue_depth(sdev, qdepth); | 519 | scsi_adjust_queue_depth(sdev, qdepth); |
526 | 520 | ||
527 | if (sdev->inquiry_len > 7) | 521 | if (sdev->inquiry_len > 7) |