Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 117704
b: refs/heads/master
c: 6c5121b
h: refs/heads/master
v: v3
  • Loading branch information
Kiyoshi Ueda authored and James Bottomley committed Oct 23, 2008
1 parent 7f0e516 commit 02a6178
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d11251709f31d49c8167a619d4475fdf6cd7f73
refs/heads/master: 6c5121b78ba5c70a9990e2af6cb4d6bbffe0d4d8
32 changes: 32 additions & 0 deletions trunk/drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,37 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
return 1;
}

/*
* Busy state exporting function for request stacking drivers.
*
* For efficiency, no lock is taken to check the busy state of
* shost/starget/sdev, since the returned value is not guaranteed and
* may be changed after request stacking drivers call the function,
* regardless of taking lock or not.
*
* When scsi can't dispatch I/Os anymore and needs to kill I/Os
* (e.g. !sdev), scsi needs to return 'not busy'.
* Otherwise, request stacking drivers may hold requests forever.
*/
static int scsi_lld_busy(struct request_queue *q)
{
struct scsi_device *sdev = q->queuedata;
struct Scsi_Host *shost;
struct scsi_target *starget;

if (!sdev)
return 0;

shost = sdev->host;
starget = scsi_target(sdev);

if (scsi_host_in_recovery(shost) || scsi_host_is_busy(shost) ||
scsi_target_is_busy(starget) || scsi_device_is_busy(sdev))
return 1;

return 0;
}

/*
* Kill a request for a dead device
*/
Expand Down Expand Up @@ -1767,6 +1798,7 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
blk_queue_prep_rq(q, scsi_prep_fn);
blk_queue_softirq_done(q, scsi_softirq_done);
blk_queue_rq_timed_out(q, scsi_times_out);
blk_queue_lld_busy(q, scsi_lld_busy);
return q;
}

Expand Down

0 comments on commit 02a6178

Please sign in to comment.