Commit c607140b authored by Patrick Mansfield's avatar Patrick Mansfield Committed by James Bottomley

[PATCH] 1/7 starved changes - use a list_head for starved queue's

Use a list_head per scsi_host to store a list of scsi request queues
that were "starved" (they were not able to send IO because of per host
limitations).
parent d189d057
...@@ -383,6 +383,7 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template *shost_tp, int xtr_bytes) ...@@ -383,6 +383,7 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template *shost_tp, int xtr_bytes)
scsi_assign_lock(shost, &shost->default_lock); scsi_assign_lock(shost, &shost->default_lock);
INIT_LIST_HEAD(&shost->my_devices); INIT_LIST_HEAD(&shost->my_devices);
INIT_LIST_HEAD(&shost->eh_cmd_q); INIT_LIST_HEAD(&shost->eh_cmd_q);
INIT_LIST_HEAD(&shost->starved_list);
init_waitqueue_head(&shost->host_wait); init_waitqueue_head(&shost->host_wait);
shost->dma_channel = 0xff; shost->dma_channel = 0xff;
......
...@@ -380,6 +380,7 @@ struct Scsi_Host ...@@ -380,6 +380,7 @@ struct Scsi_Host
struct scsi_host_cmd_pool *cmd_pool; struct scsi_host_cmd_pool *cmd_pool;
spinlock_t free_list_lock; spinlock_t free_list_lock;
struct list_head free_list; /* backup store of cmd structs */ struct list_head free_list; /* backup store of cmd structs */
struct list_head starved_list;
spinlock_t default_lock; spinlock_t default_lock;
spinlock_t *host_lock; spinlock_t *host_lock;
...@@ -470,12 +471,6 @@ struct Scsi_Host ...@@ -470,12 +471,6 @@ struct Scsi_Host
*/ */
unsigned reverse_ordering:1; unsigned reverse_ordering:1;
/*
* Indicates that one or more devices on this host were starved, and
* when the device becomes less busy that we need to feed them.
*/
unsigned some_device_starved:1;
/* /*
* Host has rejected a command because it was busy. * Host has rejected a command because it was busy.
*/ */
......
...@@ -555,6 +555,7 @@ struct scsi_device { ...@@ -555,6 +555,7 @@ struct scsi_device {
volatile unsigned short device_busy; /* commands actually active on low-level */ volatile unsigned short device_busy; /* commands actually active on low-level */
spinlock_t list_lock; spinlock_t list_lock;
struct list_head cmd_list; /* queue of in use SCSI Command structures */ struct list_head cmd_list; /* queue of in use SCSI Command structures */
struct list_head starved_entry;
Scsi_Cmnd *current_cmnd; /* currently active command */ Scsi_Cmnd *current_cmnd; /* currently active command */
unsigned short queue_depth; /* How deep of a queue we want */ unsigned short queue_depth; /* How deep of a queue we want */
unsigned short last_queue_full_depth; /* These two are used by */ unsigned short last_queue_full_depth; /* These two are used by */
...@@ -615,8 +616,6 @@ struct scsi_device { ...@@ -615,8 +616,6 @@ struct scsi_device {
* because we did a bus reset. */ * because we did a bus reset. */
unsigned ten:1; /* support ten byte read / write */ unsigned ten:1; /* support ten byte read / write */
unsigned remap:1; /* support remapping */ unsigned remap:1; /* support remapping */
unsigned starved:1; /* unable to process commands because
host busy */
// unsigned sync:1; /* Sync transfer state, managed by host */ // unsigned sync:1; /* Sync transfer state, managed by host */
// unsigned wide:1; /* WIDE transfer state, managed by host */ // unsigned wide:1; /* WIDE transfer state, managed by host */
......
...@@ -356,7 +356,6 @@ static void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd) ...@@ -356,7 +356,6 @@ static void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd)
struct scsi_device *sdev, *sdev2; struct scsi_device *sdev, *sdev2;
struct Scsi_Host *shost; struct Scsi_Host *shost;
unsigned long flags; unsigned long flags;
int all_clear;
ASSERT_LOCK(q->queue_lock, 0); ASSERT_LOCK(q->queue_lock, 0);
...@@ -383,11 +382,6 @@ static void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd) ...@@ -383,11 +382,6 @@ static void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd)
__elv_add_request(q, cmd->request, 0, 0); __elv_add_request(q, cmd->request, 0, 0);
} }
/*
* Just hit the requeue function for the queue.
*/
__blk_run_queue(q);
sdev = q->queuedata; sdev = q->queuedata;
shost = sdev->host; shost = sdev->host;
...@@ -412,31 +406,24 @@ static void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd) ...@@ -412,31 +406,24 @@ static void scsi_queue_next_request(request_queue_t *q, struct scsi_cmnd *cmd)
} }
} }
while (!list_empty(&shost->starved_list) &&
!shost->host_blocked && !shost->host_self_blocked &&
!((shost->can_queue > 0) &&
(shost->host_busy >= shost->can_queue))) {
/* /*
* Now see whether there are other devices on the bus which * As long as shost is accepting commands and we have
* might be starved. If so, hit the request function. If we * starved queues, call __blk_run_queue. scsi_request_fn
* don't find any, then it is safe to reset the flag. If we * drops the queue_lock and can add us back to the
* find any device that it is starved, it isn't safe to reset the * starved_list.
* flag as the queue function releases the lock and thus some */
* other device might have become starved along the way. sdev2 = list_entry(shost->starved_list.next,
*/ struct scsi_device, starved_entry);
all_clear = 1; list_del_init(&sdev2->starved_entry);
if (shost->some_device_starved) { __blk_run_queue(sdev2->request_queue);
list_for_each_entry(sdev, &shost->my_devices, siblings) {
if (shost->can_queue > 0 &&
shost->host_busy >= shost->can_queue)
break;
if (shost->host_blocked || shost->host_self_blocked)
break;
if (sdev->device_blocked || !sdev->starved)
continue;
__blk_run_queue(sdev->request_queue);
all_clear = 0;
} }
if (sdev == NULL && all_clear) __blk_run_queue(q);
shost->some_device_starved = 0;
}
spin_unlock_irqrestore(q->queue_lock, flags); spin_unlock_irqrestore(q->queue_lock, flags);
} }
...@@ -1115,23 +1102,16 @@ static void scsi_request_fn(request_queue_t *q) ...@@ -1115,23 +1102,16 @@ static void scsi_request_fn(request_queue_t *q)
*/ */
if (sdev->device_blocked) if (sdev->device_blocked)
break; break;
if (!list_empty(&sdev->starved_entry))
break;
if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) || if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) ||
shost->host_blocked || shost->host_self_blocked) { shost->host_blocked || shost->host_self_blocked) {
/* list_add_tail(&sdev->starved_entry,
* If we are unable to process any commands at all for &shost->starved_list);
* this device, then we consider it to be starved.
* What this means is that there are no outstanding
* commands for this device and hence we need a
* little help getting it started again
* once the host isn't quite so busy.
*/
if (sdev->device_busy == 0) {
sdev->starved = 1;
shost->some_device_starved = 1;
}
break; break;
} else }
sdev->starved = 0;
/* /*
* If we couldn't find a request that could be queued, then we * If we couldn't find a request that could be queued, then we
......
...@@ -400,6 +400,7 @@ static struct scsi_device *scsi_alloc_sdev(struct Scsi_Host *shost, ...@@ -400,6 +400,7 @@ static struct scsi_device *scsi_alloc_sdev(struct Scsi_Host *shost,
INIT_LIST_HEAD(&sdev->siblings); INIT_LIST_HEAD(&sdev->siblings);
INIT_LIST_HEAD(&sdev->same_target_siblings); INIT_LIST_HEAD(&sdev->same_target_siblings);
INIT_LIST_HEAD(&sdev->cmd_list); INIT_LIST_HEAD(&sdev->cmd_list);
INIT_LIST_HEAD(&sdev->starved_entry);
spin_lock_init(&sdev->list_lock); spin_lock_init(&sdev->list_lock);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment