aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/scsi_lib.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 69da4cb5cb13..a643353584b5 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -295,7 +295,8 @@ void scsi_device_unbusy(struct scsi_device *sdev)
295 unsigned long flags; 295 unsigned long flags;
296 296
297 atomic_dec(&shost->host_busy); 297 atomic_dec(&shost->host_busy);
298 atomic_dec(&starget->target_busy); 298 if (starget->can_queue > 0)
299 atomic_dec(&starget->target_busy);
299 300
300 if (unlikely(scsi_host_in_recovery(shost) && 301 if (unlikely(scsi_host_in_recovery(shost) &&
301 (shost->host_failed || shost->host_eh_scheduled))) { 302 (shost->host_failed || shost->host_eh_scheduled))) {
@@ -364,11 +365,12 @@ static inline bool scsi_device_is_busy(struct scsi_device *sdev)
364 365
365static inline bool scsi_target_is_busy(struct scsi_target *starget) 366static inline bool scsi_target_is_busy(struct scsi_target *starget)
366{ 367{
367 if (starget->can_queue > 0 && 368 if (starget->can_queue > 0) {
368 atomic_read(&starget->target_busy) >= starget->can_queue) 369 if (atomic_read(&starget->target_busy) >= starget->can_queue)
369 return true; 370 return true;
370 if (atomic_read(&starget->target_blocked) > 0) 371 if (atomic_read(&starget->target_blocked) > 0)
371 return true; 372 return true;
373 }
372 return false; 374 return false;
373} 375}
374 376
@@ -1309,6 +1311,9 @@ static inline int scsi_target_queue_ready(struct Scsi_Host *shost,
1309 spin_unlock_irq(shost->host_lock); 1311 spin_unlock_irq(shost->host_lock);
1310 } 1312 }
1311 1313
1314 if (starget->can_queue <= 0)
1315 return 1;
1316
1312 busy = atomic_inc_return(&starget->target_busy) - 1; 1317 busy = atomic_inc_return(&starget->target_busy) - 1;
1313 if (atomic_read(&starget->target_blocked) > 0) { 1318 if (atomic_read(&starget->target_blocked) > 0) {
1314 if (busy) 1319 if (busy)
@@ -1324,7 +1329,7 @@ static inline int scsi_target_queue_ready(struct Scsi_Host *shost,
1324 "unblocking target at zero depth\n")); 1329 "unblocking target at zero depth\n"));
1325 } 1330 }
1326 1331
1327 if (starget->can_queue > 0 && busy >= starget->can_queue) 1332 if (busy >= starget->can_queue)
1328 goto starved; 1333 goto starved;
1329 1334
1330 return 1; 1335 return 1;
@@ -1334,7 +1339,8 @@ starved:
1334 list_move_tail(&sdev->starved_entry, &shost->starved_list); 1339 list_move_tail(&sdev->starved_entry, &shost->starved_list);
1335 spin_unlock_irq(shost->host_lock); 1340 spin_unlock_irq(shost->host_lock);
1336out_dec: 1341out_dec:
1337 atomic_dec(&starget->target_busy); 1342 if (starget->can_queue > 0)
1343 atomic_dec(&starget->target_busy);
1338 return 0; 1344 return 0;
1339} 1345}
1340 1346
@@ -1455,7 +1461,8 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
1455 */ 1461 */
1456 atomic_inc(&sdev->device_busy); 1462 atomic_inc(&sdev->device_busy);
1457 atomic_inc(&shost->host_busy); 1463 atomic_inc(&shost->host_busy);
1458 atomic_inc(&starget->target_busy); 1464 if (starget->can_queue > 0)
1465 atomic_inc(&starget->target_busy);
1459 1466
1460 blk_complete_request(req); 1467 blk_complete_request(req);
1461} 1468}
@@ -1624,7 +1631,8 @@ static void scsi_request_fn(struct request_queue *q)
1624 return; 1631 return;
1625 1632
1626 host_not_ready: 1633 host_not_ready:
1627 atomic_dec(&scsi_target(sdev)->target_busy); 1634 if (scsi_target(sdev)->can_queue > 0)
1635 atomic_dec(&scsi_target(sdev)->target_busy);
1628 not_ready: 1636 not_ready:
1629 /* 1637 /*
1630 * lock q, handle tag, requeue req, and decrement device_busy. We 1638 * lock q, handle tag, requeue req, and decrement device_busy. We