Skip to content

Commit e36e0c8

Browse files
htejunJames Bottomley
authored andcommitted
[SCSI] 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. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1 parent aedf349 commit e36e0c8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,8 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
14791479
static void scsi_kill_request(struct request *req, request_queue_t *q)
14801480
{
14811481
struct scsi_cmnd *cmd = req->special;
1482+
struct scsi_device *sdev = cmd->device;
1483+
struct Scsi_Host *shost = sdev->host;
14821484

14831485
blkdev_dequeue_request(req);
14841486

@@ -1491,6 +1493,19 @@ static void scsi_kill_request(struct request *req, request_queue_t *q)
14911493
scsi_init_cmd_errh(cmd);
14921494
cmd->result = DID_NO_CONNECT << 16;
14931495
atomic_inc(&cmd->device->iorequest_cnt);
1496+
1497+
/*
1498+
* SCSI request completion path will do scsi_device_unbusy(),
1499+
* bump busy counts. To bump the counters, we need to dance
1500+
* with the locks as normal issue path does.
1501+
*/
1502+
sdev->device_busy++;
1503+
spin_unlock(sdev->request_queue->queue_lock);
1504+
spin_lock(shost->host_lock);
1505+
shost->host_busy++;
1506+
spin_unlock(shost->host_lock);
1507+
spin_lock(sdev->request_queue->queue_lock);
1508+
14941509
__scsi_done(cmd);
14951510
}
14961511

0 commit comments

Comments
 (0)