[SCSI] scsi_lib: don't decrement busy counters when inserting commands
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Fri, 2 Jan 2009 16:42:21 +0000 (10:42 -0600)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Mon, 5 Jan 2009 14:54:11 +0000 (08:54 -0600)
commit4f5299ac4e3a03d5c596c00d726fa932c600609d
treeab303d64c6df361fff4531801eaaedd9c473ea42
parenta234b1103f7df35eacb1de7a9d15a636046e263b
[SCSI] scsi_lib: don't decrement busy counters when inserting commands

A bug was introduced by

commit b60af5b0adf0da24c673598c8d3fb4d4189a15ce
Author: Alan Stern <stern@rowland.harvard.edu>
Date:   Mon Nov 3 15:56:47 2008 -0500

    [SCSI] simplify scsi_io_completion()

because the simplification uses scsi_queue_insert().  The problem with
this function is that it expects to be called from the completion path
while the command is still outstanding, so it decrements the device
and host busy counts to do the requeue.  The problem is that
scsi_io_completion() is a path executed well after these counts have
*already* been decremented, leading to a double decrement if the
command goes down any error path leading to ACTION_DELAYED_RETRY.

The fix is to allow a private function __scsi_queue_insert() with a
flag to say whether the busy counters should be decremented.  This is
made static to scsi_lib.c to discourage other use.

Reported-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/scsi_lib.c