Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a488e749 authored by Jens Axboe's avatar Jens Axboe
Browse files

scsi: convert to blk_delay_queue()



It was always abuse to reuse the plugging infrastructure for this,
convert it to the (new) real API for delaying queueing a bit. A
default delay of 3 msec is defined, to match the previous
behaviour.

Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
parent 0a41e90b
Loading
Loading
Loading
Loading
+19 −25
Original line number Original line Diff line number Diff line
@@ -67,6 +67,13 @@ static struct scsi_host_sg_pool scsi_sg_pools[] = {


struct kmem_cache *scsi_sdb_cache;
struct kmem_cache *scsi_sdb_cache;


/*
 * When to reinvoke queueing after a resource shortage. It's 3 msecs to
 * not change behaviour from the previous unplug mechanism, experimentation
 * may prove this needs changing.
 */
#define SCSI_QUEUE_DELAY	3

static void scsi_run_queue(struct request_queue *q);
static void scsi_run_queue(struct request_queue *q);


/*
/*
@@ -149,13 +156,6 @@ static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)
	/*
	/*
	 * Requeue this command.  It will go before all other commands
	 * Requeue this command.  It will go before all other commands
	 * that are already in the queue.
	 * that are already in the queue.
	 *
	 * NOTE: there is magic here about the way the queue is plugged if
	 * we have no outstanding commands.
	 * 
	 * Although we *don't* plug the queue, we call the request
	 * function.  The SCSI request function detects the blocked condition
	 * and plugs the queue appropriately.
	 */
	 */
	spin_lock_irqsave(q->queue_lock, flags);
	spin_lock_irqsave(q->queue_lock, flags);
	blk_requeue_request(q, cmd->request);
	blk_requeue_request(q, cmd->request);
@@ -1194,11 +1194,11 @@ int scsi_prep_return(struct request_queue *q, struct request *req, int ret)
	case BLKPREP_DEFER:
	case BLKPREP_DEFER:
		/*
		/*
		 * If we defer, the blk_peek_request() returns NULL, but the
		 * If we defer, the blk_peek_request() returns NULL, but the
		 * queue must be restarted, so we plug here if no returning
		 * queue must be restarted, so we schedule a callback to happen
		 * command will automatically do that.
		 * shortly.
		 */
		 */
		if (sdev->device_busy == 0)
		if (sdev->device_busy == 0)
			blk_plug_device(q);
			blk_delay_queue(q, SCSI_QUEUE_DELAY);
		break;
		break;
	default:
	default:
		req->cmd_flags |= REQ_DONTPREP;
		req->cmd_flags |= REQ_DONTPREP;
@@ -1237,7 +1237,7 @@ static inline int scsi_dev_queue_ready(struct request_queue *q,
				   sdev_printk(KERN_INFO, sdev,
				   sdev_printk(KERN_INFO, sdev,
				   "unblocking device at zero depth\n"));
				   "unblocking device at zero depth\n"));
		} else {
		} else {
			blk_plug_device(q);
			blk_delay_queue(q, SCSI_QUEUE_DELAY);
			return 0;
			return 0;
		}
		}
	}
	}
@@ -1467,7 +1467,7 @@ static void scsi_request_fn(struct request_queue *q)
	 * the host is no longer able to accept any more requests.
	 * the host is no longer able to accept any more requests.
	 */
	 */
	shost = sdev->host;
	shost = sdev->host;
	while (!blk_queue_plugged(q)) {
	for (;;) {
		int rtn;
		int rtn;
		/*
		/*
		 * get next queueable request.  We do this early to make sure
		 * get next queueable request.  We do this early to make sure
@@ -1546,15 +1546,8 @@ static void scsi_request_fn(struct request_queue *q)
		 */
		 */
		rtn = scsi_dispatch_cmd(cmd);
		rtn = scsi_dispatch_cmd(cmd);
		spin_lock_irq(q->queue_lock);
		spin_lock_irq(q->queue_lock);
		if(rtn) {
		if (rtn)
			/* we're refusing the command; because of
			goto out_delay;
			 * the way locks get dropped, we need to 
			 * check here if plugging is required */
			if(sdev->device_busy == 0)
				blk_plug_device(q);

			break;
		}
	}
	}


	goto out;
	goto out;
@@ -1573,8 +1566,9 @@ static void scsi_request_fn(struct request_queue *q)
	spin_lock_irq(q->queue_lock);
	spin_lock_irq(q->queue_lock);
	blk_requeue_request(q, req);
	blk_requeue_request(q, req);
	sdev->device_busy--;
	sdev->device_busy--;
out_delay:
	if (sdev->device_busy == 0)
	if (sdev->device_busy == 0)
		blk_plug_device(q);
		blk_delay_queue(q, SCSI_QUEUE_DELAY);
out:
out:
	/* must be careful here...if we trigger the ->remove() function
	/* must be careful here...if we trigger the ->remove() function
	 * we cannot be holding the q lock */
	 * we cannot be holding the q lock */