Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36446
b: refs/heads/master
c: d1ad4ea
h: refs/heads/master
v: v3
  • Loading branch information
Pete Zaitcev authored and Greg Kroah-Hartman committed Sep 27, 2006
1 parent a6d37a0 commit 026df53
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 14acdcd32160767d7f2fa00803d2d764d3e3373a
refs/heads/master: d1ad4ea331e78a5ff90eda7718da31bcbc1a9c38
38 changes: 25 additions & 13 deletions trunk/drivers/block/ub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 026df53

Please sign in to comment.