first cut at fixing unable to requeue with no outstanding commands
PATCH 1/1 first cut at fixing unable to requeue with no outstanding commands
The attached represents an attempt to break the scsi mid-layer of the assumption that any device can queue at least one command.
What essentially happens if the host rejects a command with no other outstanding commands, it does a very crude countdown (basically counts the number of cycles through the scsi request function) until the device gets enabled again when the count reaches zero. I think the iteration in the request function is better than a fixed timer because it makes the system more responsive to I/O pressure (and also, it's easier to code).
I've tested this by making a SCSI driver artificially reject commands with none outstanding (and run it on my root device). A value of seven seems to cause a delay of between half and five seconds before the host starts up again (depending on the I/O load).
If this approach looks acceptable, I plan the following enhancements
1. Make device_busy count down in the same fashion
2. give ->queuecommand() a two value return (one for blocking the entire host and another for just blocking the device).
3. Make the countdown tuneable from the host template.
James
===== hosts.c 1.9 vs edited =====
hosts.c renamed from drivers/scsi/hosts.c +1 -1
@@ -210,7 +210,7 @@ retval->eh_notify =NULL ;/* Who we notify when we exit. */ - retval->host_blocked = FALSE; + retval->host_blocked =0 ; retval->host_self_blocked = FALSE;#ifdef DEBUG
===== hosts.h 1.12 vs edited =====
hosts.h renamed from drivers/scsi/hosts.h +13 -5
@@ -395,11 +395,6 @@ unsigned use_blk_tcq:1;/* -* Host has rejected a command because it was busy. -*/ - unsigned host_blocked:1; - -/* * Host has requested that no further requests come through for the * time being. */
@@ -417,6 +412,19 @@*/ unsigned some_device_starved:1; +/* +* Host has rejected a command because it was busy. +*/ +unsigned int host_blocked; + +/* +* Initial value for the blocking. If the queue is empty, host_blocked +* counts down in the request_fn until it restarts host operations as +* zero is reached. +* +* FIXME: This should probably be a value in the template */ +#define SCSI_START_HOST_BLOCKED 7 +void (*select_queue_depths)(struct Scsi_Host *,Scsi_Device *);/*
===== scsi.c 1.36 vs edited =====
scsi.c renamed from drivers/scsi/scsi.c +2 -2
@@ -643,7 +643,7 @@return 0 ; } } - host->host_blocked = TRUE; + host->host_blocked =SCSI_START_HOST_BLOCKED ; }else {if (cmd->device->device_busy ==0 ) {if (scsi_retry_command (cmd) ==0 ) {
@@ -1443,7 +1443,7 @@* for both the queue full condition on a device, and for a * host full condition on the host. */ - host->host_blocked = FALSE; + host->host_blocked =0 ; device->device_blocked = FALSE;/*
===== scsi_lib.c 1.30 vs edited =====
scsi_lib.c renamed from drivers/scsi/scsi_lib.c +10 -0
@@ -754,6 +754,16 @@if (SHpnt->in_recovery ||blk_queue_plugged (q))return ; +if (SHpnt->host_busy ==0 && SHpnt->host_blocked) { +/* unblock after host_blocked iterates to zero */ +if (--SHpnt->host_blocked ==0 ) { +printk ("scsi%d unblocking host at zero depth\n" , SHpnt->host_no); + }else { +blk_plug_device (q); +break ; + } + } +/* * If the device cannot accept another request, then quit. */
scsi_lib.c line 766
Quoted 10 lines · James Bottomley [[email protected]] wrote:
scsi_lib.c renamed from drivers/scsi/scsi_lib.c +10
-0+if (SHpnt->host_busy ==0 && SHpnt->host_blocked) { +/* unblock after host_blocked iterates to zero */ +if (--SHpnt->host_blocked ==0 ) { +printk ("scsi%d unblocking host at zero depth\n" , SHpnt->host_no); + }else { +blk_plug_device (q); +break ; + } + } +
Are we guaranteed that blk_run_queues will be called for all types of I/O?
-andmike
--
Michael Anderson
[email protected]