diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
commit | 185a257f2f73bcd89050ad02da5bedbc28fc43fa (patch) | |
tree | 5e32586114534ed3f2165614cba3d578f5d87307 /drivers/block/ub.c | |
parent | 3f1a9aaeffd8d1cbc5ab9776c45cbd66af1c9699 (diff) | |
parent | a77c64c1a641950626181b4857abb701d8f38ccc (diff) |
Merge branch 'master' into gfs2
Diffstat (limited to 'drivers/block/ub.c')
-rw-r--r-- | drivers/block/ub.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index d62b49fbf10..45a8f402b07 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -358,7 +358,7 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, struct ub_scsi_cmd *cmd, struct ub_request *urq); static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); -static void ub_end_rq(struct request *rq, int uptodate); +static void ub_end_rq(struct request *rq, unsigned int status); static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, struct ub_request *urq, struct ub_scsi_cmd *cmd); static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd); @@ -639,9 +639,15 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) struct ub_request *urq; int n_elem; - if (atomic_read(&sc->poison) || lun->changed) { + if (atomic_read(&sc->poison)) { + blkdev_dequeue_request(rq); + ub_end_rq(rq, DID_NO_CONNECT << 16); + return 0; + } + + if (lun->changed && !blk_pc_request(rq)) { blkdev_dequeue_request(rq); - ub_end_rq(rq, 0); + ub_end_rq(rq, SAM_STAT_CHECK_CONDITION); return 0; } @@ -693,7 +699,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) drop: ub_put_cmd(lun, cmd); - ub_end_rq(rq, 0); + ub_end_rq(rq, DID_ERROR << 16); return 0; } @@ -761,47 +767,53 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) struct ub_lun *lun = cmd->lun; struct ub_request *urq = cmd->back; struct request *rq; - int uptodate; + unsigned int scsi_status; rq = urq->rq; if (cmd->error == 0) { - uptodate = 1; - if (blk_pc_request(rq)) { if (cmd->act_len >= rq->data_len) rq->data_len = 0; else rq->data_len -= cmd->act_len; } + scsi_status = 0; } else { - uptodate = 0; - if (blk_pc_request(rq)) { /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE); rq->sense_len = UB_SENSE_SIZE; if (sc->top_sense[0] != 0) - rq->errors = SAM_STAT_CHECK_CONDITION; + scsi_status = SAM_STAT_CHECK_CONDITION; else - rq->errors = DID_ERROR << 16; + scsi_status = DID_ERROR << 16; } else { if (cmd->error == -EIO) { if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0) return; } + scsi_status = SAM_STAT_CHECK_CONDITION; } } urq->rq = NULL; ub_put_cmd(lun, cmd); - ub_end_rq(rq, uptodate); + ub_end_rq(rq, scsi_status); blk_start_queue(lun->disk->queue); } -static void ub_end_rq(struct request *rq, int uptodate) +static void ub_end_rq(struct request *rq, unsigned int scsi_status) { + int uptodate; + + if (scsi_status == 0) { + uptodate = 1; + } else { + uptodate = 0; + rq->errors = scsi_status; + } end_that_request_first(rq, uptodate, rq->hard_nr_sectors); end_that_request_last(rq, uptodate); } |