aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_lib.c
diff options
context:
space:
mode:
authorJens Axboe <jaxboe@fusionio.com>2011-03-10 02:58:35 -0500
committerJens Axboe <jaxboe@fusionio.com>2011-03-10 02:58:35 -0500
commit4c63f5646e405b5010cc9499419060bf2e838f5b (patch)
treedf91ba315032c8ec4aafeb3ab96fdfa7c6c656e1 /drivers/scsi/scsi_lib.c
parentcafb0bfca1a73efd6d8a4a6a6a716e6134b96c24 (diff)
parent69d60eb96ae8a73cf9b79cf28051caf973006011 (diff)
Merge branch 'for-2.6.39/stack-plug' into for-2.6.39/core
Conflicts: block/blk-core.c block/blk-flush.c drivers/md/raid1.c drivers/md/raid10.c drivers/md/raid5.c fs/nilfs2/btnode.c fs/nilfs2/mdt.c Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r--drivers/scsi/scsi_lib.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index fb2bb35c62cb..bf80a4c5a481 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -67,6 +67,13 @@ static struct scsi_host_sg_pool scsi_sg_pools[] = {
67 67
68struct kmem_cache *scsi_sdb_cache; 68struct kmem_cache *scsi_sdb_cache;
69 69
70/*
71 * When to reinvoke queueing after a resource shortage. It's 3 msecs to
72 * not change behaviour from the previous unplug mechanism, experimentation
73 * may prove this needs changing.
74 */
75#define SCSI_QUEUE_DELAY 3
76
70static void scsi_run_queue(struct request_queue *q); 77static void scsi_run_queue(struct request_queue *q);
71 78
72/* 79/*
@@ -149,14 +156,7 @@ static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)
149 /* 156 /*
150 * Requeue this command. It will go before all other commands 157 * Requeue this command. It will go before all other commands
151 * that are already in the queue. 158 * that are already in the queue.
152 * 159 */
153 * NOTE: there is magic here about the way the queue is plugged if
154 * we have no outstanding commands.
155 *
156 * Although we *don't* plug the queue, we call the request
157 * function. The SCSI request function detects the blocked condition
158 * and plugs the queue appropriately.
159 */
160 spin_lock_irqsave(q->queue_lock, flags); 160 spin_lock_irqsave(q->queue_lock, flags);
161 blk_requeue_request(q, cmd->request); 161 blk_requeue_request(q, cmd->request);
162 spin_unlock_irqrestore(q->queue_lock, flags); 162 spin_unlock_irqrestore(q->queue_lock, flags);
@@ -1194,11 +1194,11 @@ int scsi_prep_return(struct request_queue *q, struct request *req, int ret)
1194 case BLKPREP_DEFER: 1194 case BLKPREP_DEFER:
1195 /* 1195 /*
1196 * If we defer, the blk_peek_request() returns NULL, but the 1196 * If we defer, the blk_peek_request() returns NULL, but the
1197 * queue must be restarted, so we plug here if no returning 1197 * queue must be restarted, so we schedule a callback to happen
1198 * command will automatically do that. 1198 * shortly.
1199 */ 1199 */
1200 if (sdev->device_busy == 0) 1200 if (sdev->device_busy == 0)
1201 blk_plug_device(q); 1201 blk_delay_queue(q, SCSI_QUEUE_DELAY);
1202 break; 1202 break;
1203 default: 1203 default:
1204 req->cmd_flags |= REQ_DONTPREP; 1204 req->cmd_flags |= REQ_DONTPREP;
@@ -1237,7 +1237,7 @@ static inline int scsi_dev_queue_ready(struct request_queue *q,
1237 sdev_printk(KERN_INFO, sdev, 1237 sdev_printk(KERN_INFO, sdev,
1238 "unblocking device at zero depth\n")); 1238 "unblocking device at zero depth\n"));
1239 } else { 1239 } else {
1240 blk_plug_device(q); 1240 blk_delay_queue(q, SCSI_QUEUE_DELAY);
1241 return 0; 1241 return 0;
1242 } 1242 }
1243 } 1243 }
@@ -1467,7 +1467,7 @@ static void scsi_request_fn(struct request_queue *q)
1467 * the host is no longer able to accept any more requests. 1467 * the host is no longer able to accept any more requests.
1468 */ 1468 */
1469 shost = sdev->host; 1469 shost = sdev->host;
1470 while (!blk_queue_plugged(q)) { 1470 for (;;) {
1471 int rtn; 1471 int rtn;
1472 /* 1472 /*
1473 * get next queueable request. We do this early to make sure 1473 * get next queueable request. We do this early to make sure
@@ -1546,15 +1546,8 @@ static void scsi_request_fn(struct request_queue *q)
1546 */ 1546 */
1547 rtn = scsi_dispatch_cmd(cmd); 1547 rtn = scsi_dispatch_cmd(cmd);
1548 spin_lock_irq(q->queue_lock); 1548 spin_lock_irq(q->queue_lock);
1549 if(rtn) { 1549 if (rtn)
1550 /* we're refusing the command; because of 1550 goto out_delay;
1551 * the way locks get dropped, we need to
1552 * check here if plugging is required */
1553 if(sdev->device_busy == 0)
1554 blk_plug_device(q);
1555
1556 break;
1557 }
1558 } 1551 }
1559 1552
1560 goto out; 1553 goto out;
@@ -1573,9 +1566,10 @@ static void scsi_request_fn(struct request_queue *q)
1573 spin_lock_irq(q->queue_lock); 1566 spin_lock_irq(q->queue_lock);
1574 blk_requeue_request(q, req); 1567 blk_requeue_request(q, req);
1575 sdev->device_busy--; 1568 sdev->device_busy--;
1576 if(sdev->device_busy == 0) 1569out_delay:
1577 blk_plug_device(q); 1570 if (sdev->device_busy == 0)
1578 out: 1571 blk_delay_queue(q, SCSI_QUEUE_DELAY);
1572out:
1579 /* must be careful here...if we trigger the ->remove() function 1573 /* must be careful here...if we trigger the ->remove() function
1580 * we cannot be holding the q lock */ 1574 * we cannot be holding the q lock */
1581 spin_unlock_irq(q->queue_lock); 1575 spin_unlock_irq(q->queue_lock);