scsi-misc-2.5 software enqueue when can_queue is reached
PATCH 1/1 scsi-misc-2.5 software enqueue when can_queue is reached
James,
I've made changes to the original patch based on the comments received. Can you push this through or comment? Thanks.
Patch is based on scsi-misc-2.5.
This patch puts scsi_cmnds on to a pending list if the can_queue limit is reached, or host_blocked is set.
drivers/scsi/hosts.c +62 -8
@@ -383,6 +383,7 @@scsi_assign_lock (shost, &shost->default_lock);INIT_LIST_HEAD (&shost->my_devices);INIT_LIST_HEAD (&shost->eh_cmd_q); +INIT_LIST_HEAD (&shost->pending_cmd);init_waitqueue_head (&shost->host_wait); shost->dma_channel =0xff ;
@@ -613,19 +614,72 @@spin_unlock_irqrestore (shost->host_lock, flags); } +void scsi_host_send_pending (struct Scsi_Host *shost) +{ +struct scsi_cmnd *scmd; +unsigned long flags; + +spin_lock_irqsave (shost->host_lock, flags); +while (!shost->host_self_blocked && + !list_empty (&shost->pending_cmd)) { +/* +* list_for_each_safe is not safe here, since after the +* unlock someone else can remove the scmd after the one +* we are pulling off the list. +*/ + scmd = list_entry(shost->pending_cmd.next, struct scsi_cmnd, + pending_cmd); +list_del_init (&scmd->pending_cmd); +SCSI_LOG_MLQUEUE (3 , +printk ("%s: removed from pending cmd: 0x%lx\n" , + __FUNCTION__, scmd->serial_number)); +spin_unlock_irqrestore (shost->host_lock, flags); +if (scsi_dispatch_cmd (scmd,0 )) +/* +* Device hit host_blocked, or (race case) +* can_queue limit was reached. +*/ + goto unlocked; +spin_lock_irqsave (shost->host_lock, flags); + } +spin_unlock_irqrestore (shost->host_lock, flags); +unlocked: +} +void scsi_host_busy_dec_and_test (struct Scsi_Host *shost,Scsi_Device *sdev) {unsigned long flags; +struct scsi_cmnd *scmd;spin_lock_irqsave (shost->host_lock, flags); +/* +* If broken adapters are ever fixed or go away (at least qlogicfc +* and qlogicisp): +* +* WARN_ON(shost->host_busy > shost->can_queue); +*/ shost->host_busy--; sdev->device_busy--; -if (shost->in_recovery && shost->host_failed && - (shost->host_busy == shost->host_failed)) - { -up (shost->eh_wait); -SCSI_LOG_ERROR_RECOVERY (5 ,printk ("Waking error handler" -" thread\n" )); - } -spin_unlock_irqrestore (shost->host_lock, flags); +if (shost->in_recovery) { +if (shost->host_failed && (shost->host_busy == shost->host_failed)) { +up (shost->eh_wait); +SCSI_LOG_ERROR_RECOVERY (5 ,printk ("Waking error handler" +" thread\n" )); + } +spin_unlock_irqrestore (shost->host_lock, flags); + }else if (!list_empty (&shost->pending_cmd) && + !shost->host_blocked && !shost->host_self_blocked) { +/* +* Send one pending command. +*/ + scmd = list_entry(shost->pending_cmd.next, struct scsi_cmnd, + pending_cmd); +list_del_init (&scmd->pending_cmd); +SCSI_LOG_MLQUEUE (3 , +printk ("%s: removed from pending cmd: 0x%lx\n" , + __FUNCTION__, scmd->serial_number)); +spin_unlock_irqrestore (shost->host_lock, flags); +scsi_dispatch_cmd (scmd,0 ); + }else +spin_unlock_irqrestore (shost->host_lock, flags); }
drivers/scsi/hosts.h +2 -10
@@ -380,6 +380,7 @@struct scsi_host_cmd_pool *cmd_pool;spinlock_t free_list_lock;struct list_head free_list;/* backup store of cmd structs */ +struct list_head pending_cmd;/* head of list */ spinlock_t default_lock;spinlock_t *host_lock;
@@ -471,12 +472,6 @@ 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. */ unsigned int host_blocked;
@@ -580,12 +575,9 @@extern struct Scsi_Host *scsi_host_hn_get (unsigned short );extern void scsi_host_put (struct Scsi_Host *);extern void scsi_host_init (void ); - -/* -* host_busy inc/dec/test functions -*/ extern void scsi_host_busy_inc (struct Scsi_Host *,Scsi_Device *);extern void scsi_host_busy_dec_and_test (struct Scsi_Host *,Scsi_Device *); +extern void scsi_host_send_pending (struct Scsi_Host *shost);/** * scsi_find_device - find a device given the host
drivers/scsi/scsi.c +42 -27
132 lines not on this page · raw message
drivers/scsi/scsi.h +5 -4
@@ -444,7 +444,7 @@/* * Prototypes for functions in scsi.c */ -extern int scsi_dispatch_cmd (Scsi_Cmnd * SCpnt); +extern int scsi_dispatch_cmd (Scsi_Cmnd * SCpnt,int resend);extern int scsi_setup_command_freelist (struct Scsi_Host *shost);extern void scsi_destroy_command_freelist (struct Scsi_Host *shost);extern struct scsi_cmnd *scsi_get_command (struct scsi_device *dev,int flags);
@@ -634,8 +634,6 @@* because we did a bus reset. */ unsigned ten:1; /* support ten byte read / write */ 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 wide:1; /* WIDE transfer state, managed by host */
@@ -727,7 +725,9 @@struct scsi_cmnd *reset_chain;struct list_head list;/* scsi_cmnd participates in queue lists */ - +struct list_head pending_cmd;/* for use with host->pending_cmd, this +* could be shared with eh_entry. +*/ struct list_head eh_entry;/* entry for the host eh_cmd_q */ int eh_state;/* Used for state tracking in error handlr */ int eh_eflags;/* Used by error handlr */
@@ -854,6 +854,7 @@#define SCSI_MLQUEUE_HOST_BUSY 0x1055#define SCSI_MLQUEUE_DEVICE_BUSY 0x1056#define SCSI_MLQUEUE_EH_RETRY 0x1057 +#define SCSI_MLQUEUE_PENDING 0x1058/* * old style reset request from external source
drivers/scsi/scsi_error.c +42 -9
83 lines not on this page · raw message
drivers/scsi/scsi_lib.c +29 -56
144 lines not on this page · raw message
-- Patrick Mansfield