Skip to contentSkip to conversation

SCSI: fix scsi_kill_request() busy count handling

PATCH In review Tejun Heo 2 participants 2 messages Apr 11, 2006

Subsystems (2)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 SCSI: fix scsi_kill_request() busy count handling

scsi_kill_request() completes requests via normal SCSI completion path which decrements busy counts; however, requests which get passed to scsi_kill_request() aren't holding busy counts and scsi_kill_request() don't increment them before invoking completion path resulting in incorrect busy counts. Bump up busy counts before invoking completion path.

---

 drivers/scsi/scsi_lib.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

a12bf362489393691d147f93fbe1aa5d5a3a513d

drivers/scsi/scsi_lib.c +15 -0
index 8f010a3..7b0f9a3 100644
@@ -1479,6 +1479,8 @@ static inline int scsi_host_queue_ready(
 static void scsi_kill_request(struct request *req, request_queue_t *q)
 {
 	struct scsi_cmnd *cmd = req->special;
+	struct scsi_device *sdev = cmd->device;
+	struct Scsi_Host *shost = sdev->host;
 
 	blkdev_dequeue_request(req);
 
@@ -1491,6 +1493,19 @@ static void scsi_kill_request(struct req
 	scsi_init_cmd_errh(cmd);
 	cmd->result = DID_NO_CONNECT << 16;
 	atomic_inc(&cmd->device->iorequest_cnt);
+
+	/*
+	 * SCSI request completion path will do scsi_device_unbusy(),
+	 * bump busy counts.  To bump the counters, we need to dance
+	 * with the locks as normal issue path does.
+	 */
+	sdev->device_busy++;
+	spin_unlock(sdev->request_queue->queue_lock);
+	spin_lock(shost->host_lock);
+	shost->host_busy++;
+	spin_unlock(shost->host_lock);
+	spin_lock(sdev->request_queue->queue_lock);
+
 	__scsi_done(cmd);
 }
 
Signature · 1 line
1.2.4
#1 lore raw
Quoted 8 lines · Tejun Heo

scsi_kill_request() completes requests via normal SCSI completion path which decrements busy counts; however, requests which get passed to scsi_kill_request() aren't holding busy counts and scsi_kill_request() don't increment them before invoking completion path resulting in incorrect busy counts. Bump up busy counts before invoking completion path.

ACK.

As with the other two SCSI core patches, we're blocked on linux-scsi people.

Same response as the other two: if nobody complains, and nobody merges into scsi-misc-2.6 in a sane amount of time, I'll push it into libata.

Jeff