diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/DAC960.c | 11 | ||||
-rw-r--r-- | drivers/block/cciss.c | 25 | ||||
-rw-r--r-- | drivers/block/cpqarray.c | 36 | ||||
-rw-r--r-- | drivers/block/floppy.c | 16 | ||||
-rw-r--r-- | drivers/block/nbd.c | 8 | ||||
-rw-r--r-- | drivers/block/ps3disk.c | 12 | ||||
-rw-r--r-- | drivers/block/sunvdc.c | 11 | ||||
-rw-r--r-- | drivers/block/sx8.c | 58 | ||||
-rw-r--r-- | drivers/block/ub.c | 10 | ||||
-rw-r--r-- | drivers/block/viodasd.c | 15 | ||||
-rw-r--r-- | drivers/block/xen-blkfront.c | 10 | ||||
-rw-r--r-- | drivers/block/xsysace.c | 5 |
12 files changed, 74 insertions, 143 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 9030c373ce67..cd03473f3547 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
@@ -3455,19 +3455,12 @@ static inline bool DAC960_ProcessCompletedRequest(DAC960_Command_T *Command, | |||
3455 | bool SuccessfulIO) | 3455 | bool SuccessfulIO) |
3456 | { | 3456 | { |
3457 | struct request *Request = Command->Request; | 3457 | struct request *Request = Command->Request; |
3458 | int UpToDate; | 3458 | int Error = SuccessfulIO ? 0 : -EIO; |
3459 | |||
3460 | UpToDate = 0; | ||
3461 | if (SuccessfulIO) | ||
3462 | UpToDate = 1; | ||
3463 | 3459 | ||
3464 | pci_unmap_sg(Command->Controller->PCIDevice, Command->cmd_sglist, | 3460 | pci_unmap_sg(Command->Controller->PCIDevice, Command->cmd_sglist, |
3465 | Command->SegmentCount, Command->DmaDirection); | 3461 | Command->SegmentCount, Command->DmaDirection); |
3466 | 3462 | ||
3467 | if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) { | 3463 | if (!__blk_end_request(Request, Error, Command->BlockCount << 9)) { |
3468 | add_disk_randomness(Request->rq_disk); | ||
3469 | end_that_request_last(Request, UpToDate); | ||
3470 | |||
3471 | if (Command->Completion) { | 3464 | if (Command->Completion) { |
3472 | complete(Command->Completion); | 3465 | complete(Command->Completion); |
3473 | Command->Completion = NULL; | 3466 | Command->Completion = NULL; |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 509b6490413b..ef50068def88 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -1187,17 +1187,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, | |||
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | static inline void complete_buffers(struct bio *bio, int status) | ||
1191 | { | ||
1192 | while (bio) { | ||
1193 | struct bio *xbh = bio->bi_next; | ||
1194 | |||
1195 | bio->bi_next = NULL; | ||
1196 | bio_endio(bio, status ? 0 : -EIO); | ||
1197 | bio = xbh; | ||
1198 | } | ||
1199 | } | ||
1200 | |||
1201 | static void cciss_check_queues(ctlr_info_t *h) | 1190 | static void cciss_check_queues(ctlr_info_t *h) |
1202 | { | 1191 | { |
1203 | int start_queue = h->next_to_run; | 1192 | int start_queue = h->next_to_run; |
@@ -1263,21 +1252,14 @@ static void cciss_softirq_done(struct request *rq) | |||
1263 | pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); | 1252 | pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); |
1264 | } | 1253 | } |
1265 | 1254 | ||
1266 | complete_buffers(rq->bio, (rq->errors == 0)); | ||
1267 | |||
1268 | if (blk_fs_request(rq)) { | ||
1269 | const int rw = rq_data_dir(rq); | ||
1270 | |||
1271 | disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors); | ||
1272 | } | ||
1273 | |||
1274 | #ifdef CCISS_DEBUG | 1255 | #ifdef CCISS_DEBUG |
1275 | printk("Done with %p\n", rq); | 1256 | printk("Done with %p\n", rq); |
1276 | #endif /* CCISS_DEBUG */ | 1257 | #endif /* CCISS_DEBUG */ |
1277 | 1258 | ||
1278 | add_disk_randomness(rq->rq_disk); | 1259 | if (blk_end_request(rq, (rq->errors == 0) ? 0 : -EIO, blk_rq_bytes(rq))) |
1260 | BUG(); | ||
1261 | |||
1279 | spin_lock_irqsave(&h->lock, flags); | 1262 | spin_lock_irqsave(&h->lock, flags); |
1280 | end_that_request_last(rq, (rq->errors == 0)); | ||
1281 | cmd_free(h, cmd, 1); | 1263 | cmd_free(h, cmd, 1); |
1282 | cciss_check_queues(h); | 1264 | cciss_check_queues(h); |
1283 | spin_unlock_irqrestore(&h->lock, flags); | 1265 | spin_unlock_irqrestore(&h->lock, flags); |
@@ -2544,7 +2526,6 @@ after_error_processing: | |||
2544 | } | 2526 | } |
2545 | cmd->rq->data_len = 0; | 2527 | cmd->rq->data_len = 0; |
2546 | cmd->rq->completion_data = cmd; | 2528 | cmd->rq->completion_data = cmd; |
2547 | blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE); | ||
2548 | blk_complete_request(cmd->rq); | 2529 | blk_complete_request(cmd->rq); |
2549 | } | 2530 | } |
2550 | 2531 | ||
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index c8132d958795..69199185ff4b 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -167,7 +167,6 @@ static void start_io(ctlr_info_t *h); | |||
167 | 167 | ||
168 | static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c); | 168 | static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c); |
169 | static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c); | 169 | static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c); |
170 | static inline void complete_buffers(struct bio *bio, int ok); | ||
171 | static inline void complete_command(cmdlist_t *cmd, int timeout); | 170 | static inline void complete_command(cmdlist_t *cmd, int timeout); |
172 | 171 | ||
173 | static irqreturn_t do_ida_intr(int irq, void *dev_id); | 172 | static irqreturn_t do_ida_intr(int irq, void *dev_id); |
@@ -980,26 +979,13 @@ static void start_io(ctlr_info_t *h) | |||
980 | } | 979 | } |
981 | } | 980 | } |
982 | 981 | ||
983 | static inline void complete_buffers(struct bio *bio, int ok) | ||
984 | { | ||
985 | struct bio *xbh; | ||
986 | |||
987 | while (bio) { | ||
988 | xbh = bio->bi_next; | ||
989 | bio->bi_next = NULL; | ||
990 | |||
991 | bio_endio(bio, ok ? 0 : -EIO); | ||
992 | |||
993 | bio = xbh; | ||
994 | } | ||
995 | } | ||
996 | /* | 982 | /* |
997 | * Mark all buffers that cmd was responsible for | 983 | * Mark all buffers that cmd was responsible for |
998 | */ | 984 | */ |
999 | static inline void complete_command(cmdlist_t *cmd, int timeout) | 985 | static inline void complete_command(cmdlist_t *cmd, int timeout) |
1000 | { | 986 | { |
1001 | struct request *rq = cmd->rq; | 987 | struct request *rq = cmd->rq; |
1002 | int ok=1; | 988 | int error = 0; |
1003 | int i, ddir; | 989 | int i, ddir; |
1004 | 990 | ||
1005 | if (cmd->req.hdr.rcode & RCODE_NONFATAL && | 991 | if (cmd->req.hdr.rcode & RCODE_NONFATAL && |
@@ -1011,16 +997,17 @@ static inline void complete_command(cmdlist_t *cmd, int timeout) | |||
1011 | if (cmd->req.hdr.rcode & RCODE_FATAL) { | 997 | if (cmd->req.hdr.rcode & RCODE_FATAL) { |
1012 | printk(KERN_WARNING "Fatal error on ida/c%dd%d\n", | 998 | printk(KERN_WARNING "Fatal error on ida/c%dd%d\n", |
1013 | cmd->ctlr, cmd->hdr.unit); | 999 | cmd->ctlr, cmd->hdr.unit); |
1014 | ok = 0; | 1000 | error = -EIO; |
1015 | } | 1001 | } |
1016 | if (cmd->req.hdr.rcode & RCODE_INVREQ) { | 1002 | if (cmd->req.hdr.rcode & RCODE_INVREQ) { |
1017 | printk(KERN_WARNING "Invalid request on ida/c%dd%d = (cmd=%x sect=%d cnt=%d sg=%d ret=%x)\n", | 1003 | printk(KERN_WARNING "Invalid request on ida/c%dd%d = (cmd=%x sect=%d cnt=%d sg=%d ret=%x)\n", |
1018 | cmd->ctlr, cmd->hdr.unit, cmd->req.hdr.cmd, | 1004 | cmd->ctlr, cmd->hdr.unit, cmd->req.hdr.cmd, |
1019 | cmd->req.hdr.blk, cmd->req.hdr.blk_cnt, | 1005 | cmd->req.hdr.blk, cmd->req.hdr.blk_cnt, |
1020 | cmd->req.hdr.sg_cnt, cmd->req.hdr.rcode); | 1006 | cmd->req.hdr.sg_cnt, cmd->req.hdr.rcode); |
1021 | ok = 0; | 1007 | error = -EIO; |
1022 | } | 1008 | } |
1023 | if (timeout) ok = 0; | 1009 | if (timeout) |
1010 | error = -EIO; | ||
1024 | /* unmap the DMA mapping for all the scatter gather elements */ | 1011 | /* unmap the DMA mapping for all the scatter gather elements */ |
1025 | if (cmd->req.hdr.cmd == IDA_READ) | 1012 | if (cmd->req.hdr.cmd == IDA_READ) |
1026 | ddir = PCI_DMA_FROMDEVICE; | 1013 | ddir = PCI_DMA_FROMDEVICE; |
@@ -1030,18 +1017,9 @@ static inline void complete_command(cmdlist_t *cmd, int timeout) | |||
1030 | pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr, | 1017 | pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr, |
1031 | cmd->req.sg[i].size, ddir); | 1018 | cmd->req.sg[i].size, ddir); |
1032 | 1019 | ||
1033 | complete_buffers(rq->bio, ok); | ||
1034 | |||
1035 | if (blk_fs_request(rq)) { | ||
1036 | const int rw = rq_data_dir(rq); | ||
1037 | |||
1038 | disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors); | ||
1039 | } | ||
1040 | |||
1041 | add_disk_randomness(rq->rq_disk); | ||
1042 | |||
1043 | DBGPX(printk("Done with %p\n", rq);); | 1020 | DBGPX(printk("Done with %p\n", rq);); |
1044 | end_that_request_last(rq, ok ? 1 : -EIO); | 1021 | if (__blk_end_request(rq, error, blk_rq_bytes(rq))) |
1022 | BUG(); | ||
1045 | } | 1023 | } |
1046 | 1024 | ||
1047 | /* | 1025 | /* |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 639ed14bb08d..32c79a55511b 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -2287,21 +2287,19 @@ static int do_format(int drive, struct format_descr *tmp_format_req) | |||
2287 | * ============================= | 2287 | * ============================= |
2288 | */ | 2288 | */ |
2289 | 2289 | ||
2290 | static void floppy_end_request(struct request *req, int uptodate) | 2290 | static void floppy_end_request(struct request *req, int error) |
2291 | { | 2291 | { |
2292 | unsigned int nr_sectors = current_count_sectors; | 2292 | unsigned int nr_sectors = current_count_sectors; |
2293 | unsigned int drive = (unsigned long)req->rq_disk->private_data; | ||
2293 | 2294 | ||
2294 | /* current_count_sectors can be zero if transfer failed */ | 2295 | /* current_count_sectors can be zero if transfer failed */ |
2295 | if (!uptodate) | 2296 | if (error) |
2296 | nr_sectors = req->current_nr_sectors; | 2297 | nr_sectors = req->current_nr_sectors; |
2297 | if (end_that_request_first(req, uptodate, nr_sectors)) | 2298 | if (__blk_end_request(req, error, nr_sectors << 9)) |
2298 | return; | 2299 | return; |
2299 | add_disk_randomness(req->rq_disk); | ||
2300 | floppy_off((long)req->rq_disk->private_data); | ||
2301 | blkdev_dequeue_request(req); | ||
2302 | end_that_request_last(req, uptodate); | ||
2303 | 2300 | ||
2304 | /* We're done with the request */ | 2301 | /* We're done with the request */ |
2302 | floppy_off(drive); | ||
2305 | current_req = NULL; | 2303 | current_req = NULL; |
2306 | } | 2304 | } |
2307 | 2305 | ||
@@ -2332,7 +2330,7 @@ static void request_done(int uptodate) | |||
2332 | 2330 | ||
2333 | /* unlock chained buffers */ | 2331 | /* unlock chained buffers */ |
2334 | spin_lock_irqsave(q->queue_lock, flags); | 2332 | spin_lock_irqsave(q->queue_lock, flags); |
2335 | floppy_end_request(req, 1); | 2333 | floppy_end_request(req, 0); |
2336 | spin_unlock_irqrestore(q->queue_lock, flags); | 2334 | spin_unlock_irqrestore(q->queue_lock, flags); |
2337 | } else { | 2335 | } else { |
2338 | if (rq_data_dir(req) == WRITE) { | 2336 | if (rq_data_dir(req) == WRITE) { |
@@ -2346,7 +2344,7 @@ static void request_done(int uptodate) | |||
2346 | DRWE->last_error_generation = DRS->generation; | 2344 | DRWE->last_error_generation = DRS->generation; |
2347 | } | 2345 | } |
2348 | spin_lock_irqsave(q->queue_lock, flags); | 2346 | spin_lock_irqsave(q->queue_lock, flags); |
2349 | floppy_end_request(req, 0); | 2347 | floppy_end_request(req, -EIO); |
2350 | spin_unlock_irqrestore(q->queue_lock, flags); | 2348 | spin_unlock_irqrestore(q->queue_lock, flags); |
2351 | } | 2349 | } |
2352 | } | 2350 | } |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index ba9b17e507e0..ae3106045ee5 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -100,17 +100,15 @@ static const char *nbdcmd_to_ascii(int cmd) | |||
100 | 100 | ||
101 | static void nbd_end_request(struct request *req) | 101 | static void nbd_end_request(struct request *req) |
102 | { | 102 | { |
103 | int uptodate = (req->errors == 0) ? 1 : 0; | 103 | int error = req->errors ? -EIO : 0; |
104 | struct request_queue *q = req->q; | 104 | struct request_queue *q = req->q; |
105 | unsigned long flags; | 105 | unsigned long flags; |
106 | 106 | ||
107 | dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->disk_name, | 107 | dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->disk_name, |
108 | req, uptodate? "done": "failed"); | 108 | req, error ? "failed" : "done"); |
109 | 109 | ||
110 | spin_lock_irqsave(q->queue_lock, flags); | 110 | spin_lock_irqsave(q->queue_lock, flags); |
111 | if (!end_that_request_first(req, uptodate, req->nr_sectors)) { | 111 | __blk_end_request(req, error, req->nr_sectors << 9); |
112 | end_that_request_last(req, uptodate); | ||
113 | } | ||
114 | spin_unlock_irqrestore(q->queue_lock, flags); | 112 | spin_unlock_irqrestore(q->queue_lock, flags); |
115 | } | 113 | } |
116 | 114 | ||
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index e354bfc070e1..7483f947f0e9 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c | |||
@@ -229,7 +229,7 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data) | |||
229 | struct ps3_storage_device *dev = data; | 229 | struct ps3_storage_device *dev = data; |
230 | struct ps3disk_private *priv; | 230 | struct ps3disk_private *priv; |
231 | struct request *req; | 231 | struct request *req; |
232 | int res, read, uptodate; | 232 | int res, read, error; |
233 | u64 tag, status; | 233 | u64 tag, status; |
234 | unsigned long num_sectors; | 234 | unsigned long num_sectors; |
235 | const char *op; | 235 | const char *op; |
@@ -270,21 +270,17 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data) | |||
270 | if (status) { | 270 | if (status) { |
271 | dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__, | 271 | dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__, |
272 | __LINE__, op, status); | 272 | __LINE__, op, status); |
273 | uptodate = 0; | 273 | error = -EIO; |
274 | } else { | 274 | } else { |
275 | dev_dbg(&dev->sbd.core, "%s:%u: %s completed\n", __func__, | 275 | dev_dbg(&dev->sbd.core, "%s:%u: %s completed\n", __func__, |
276 | __LINE__, op); | 276 | __LINE__, op); |
277 | uptodate = 1; | 277 | error = 0; |
278 | if (read) | 278 | if (read) |
279 | ps3disk_scatter_gather(dev, req, 0); | 279 | ps3disk_scatter_gather(dev, req, 0); |
280 | } | 280 | } |
281 | 281 | ||
282 | spin_lock(&priv->lock); | 282 | spin_lock(&priv->lock); |
283 | if (!end_that_request_first(req, uptodate, num_sectors)) { | 283 | __blk_end_request(req, error, num_sectors << 9); |
284 | add_disk_randomness(req->rq_disk); | ||
285 | blkdev_dequeue_request(req); | ||
286 | end_that_request_last(req, uptodate); | ||
287 | } | ||
288 | priv->req = NULL; | 284 | priv->req = NULL; |
289 | ps3disk_do_request(dev, priv->queue); | 285 | ps3disk_do_request(dev, priv->queue); |
290 | spin_unlock(&priv->lock); | 286 | spin_unlock(&priv->lock); |
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index fac4c6cd04f7..66e30155b0ab 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c | |||
@@ -212,12 +212,9 @@ static void vdc_end_special(struct vdc_port *port, struct vio_disk_desc *desc) | |||
212 | vdc_finish(&port->vio, -err, WAITING_FOR_GEN_CMD); | 212 | vdc_finish(&port->vio, -err, WAITING_FOR_GEN_CMD); |
213 | } | 213 | } |
214 | 214 | ||
215 | static void vdc_end_request(struct request *req, int uptodate, int num_sectors) | 215 | static void vdc_end_request(struct request *req, int error, int num_sectors) |
216 | { | 216 | { |
217 | if (end_that_request_first(req, uptodate, num_sectors)) | 217 | __blk_end_request(req, error, num_sectors << 9); |
218 | return; | ||
219 | add_disk_randomness(req->rq_disk); | ||
220 | end_that_request_last(req, uptodate); | ||
221 | } | 218 | } |
222 | 219 | ||
223 | static void vdc_end_one(struct vdc_port *port, struct vio_dring_state *dr, | 220 | static void vdc_end_one(struct vdc_port *port, struct vio_dring_state *dr, |
@@ -242,7 +239,7 @@ static void vdc_end_one(struct vdc_port *port, struct vio_dring_state *dr, | |||
242 | 239 | ||
243 | rqe->req = NULL; | 240 | rqe->req = NULL; |
244 | 241 | ||
245 | vdc_end_request(req, !desc->status, desc->size >> 9); | 242 | vdc_end_request(req, (desc->status ? -EIO : 0), desc->size >> 9); |
246 | 243 | ||
247 | if (blk_queue_stopped(port->disk->queue)) | 244 | if (blk_queue_stopped(port->disk->queue)) |
248 | blk_start_queue(port->disk->queue); | 245 | blk_start_queue(port->disk->queue); |
@@ -456,7 +453,7 @@ static void do_vdc_request(struct request_queue *q) | |||
456 | 453 | ||
457 | blkdev_dequeue_request(req); | 454 | blkdev_dequeue_request(req); |
458 | if (__send_request(req) < 0) | 455 | if (__send_request(req) < 0) |
459 | vdc_end_request(req, 0, req->hard_nr_sectors); | 456 | vdc_end_request(req, -EIO, req->hard_nr_sectors); |
460 | } | 457 | } |
461 | } | 458 | } |
462 | 459 | ||
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index 52dc5e131718..cd5674b63faf 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c | |||
@@ -744,16 +744,14 @@ static unsigned int carm_fill_get_fw_ver(struct carm_host *host, | |||
744 | 744 | ||
745 | static inline void carm_end_request_queued(struct carm_host *host, | 745 | static inline void carm_end_request_queued(struct carm_host *host, |
746 | struct carm_request *crq, | 746 | struct carm_request *crq, |
747 | int uptodate) | 747 | int error) |
748 | { | 748 | { |
749 | struct request *req = crq->rq; | 749 | struct request *req = crq->rq; |
750 | int rc; | 750 | int rc; |
751 | 751 | ||
752 | rc = end_that_request_first(req, uptodate, req->hard_nr_sectors); | 752 | rc = __blk_end_request(req, error, blk_rq_bytes(req)); |
753 | assert(rc == 0); | 753 | assert(rc == 0); |
754 | 754 | ||
755 | end_that_request_last(req, uptodate); | ||
756 | |||
757 | rc = carm_put_request(host, crq); | 755 | rc = carm_put_request(host, crq); |
758 | assert(rc == 0); | 756 | assert(rc == 0); |
759 | } | 757 | } |
@@ -793,9 +791,9 @@ static inline void carm_round_robin(struct carm_host *host) | |||
793 | } | 791 | } |
794 | 792 | ||
795 | static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq, | 793 | static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq, |
796 | int is_ok) | 794 | int error) |
797 | { | 795 | { |
798 | carm_end_request_queued(host, crq, is_ok); | 796 | carm_end_request_queued(host, crq, error); |
799 | if (max_queue == 1) | 797 | if (max_queue == 1) |
800 | carm_round_robin(host); | 798 | carm_round_robin(host); |
801 | else if ((host->n_msgs <= CARM_MSG_LOW_WATER) && | 799 | else if ((host->n_msgs <= CARM_MSG_LOW_WATER) && |
@@ -873,14 +871,14 @@ queue_one_request: | |||
873 | sg = &crq->sg[0]; | 871 | sg = &crq->sg[0]; |
874 | n_elem = blk_rq_map_sg(q, rq, sg); | 872 | n_elem = blk_rq_map_sg(q, rq, sg); |
875 | if (n_elem <= 0) { | 873 | if (n_elem <= 0) { |
876 | carm_end_rq(host, crq, 0); | 874 | carm_end_rq(host, crq, -EIO); |
877 | return; /* request with no s/g entries? */ | 875 | return; /* request with no s/g entries? */ |
878 | } | 876 | } |
879 | 877 | ||
880 | /* map scatterlist to PCI bus addresses */ | 878 | /* map scatterlist to PCI bus addresses */ |
881 | n_elem = pci_map_sg(host->pdev, sg, n_elem, pci_dir); | 879 | n_elem = pci_map_sg(host->pdev, sg, n_elem, pci_dir); |
882 | if (n_elem <= 0) { | 880 | if (n_elem <= 0) { |
883 | carm_end_rq(host, crq, 0); | 881 | carm_end_rq(host, crq, -EIO); |
884 | return; /* request with no s/g entries? */ | 882 | return; /* request with no s/g entries? */ |
885 | } | 883 | } |
886 | crq->n_elem = n_elem; | 884 | crq->n_elem = n_elem; |
@@ -941,7 +939,7 @@ queue_one_request: | |||
941 | 939 | ||
942 | static void carm_handle_array_info(struct carm_host *host, | 940 | static void carm_handle_array_info(struct carm_host *host, |
943 | struct carm_request *crq, u8 *mem, | 941 | struct carm_request *crq, u8 *mem, |
944 | int is_ok) | 942 | int error) |
945 | { | 943 | { |
946 | struct carm_port *port; | 944 | struct carm_port *port; |
947 | u8 *msg_data = mem + sizeof(struct carm_array_info); | 945 | u8 *msg_data = mem + sizeof(struct carm_array_info); |
@@ -952,9 +950,9 @@ static void carm_handle_array_info(struct carm_host *host, | |||
952 | 950 | ||
953 | DPRINTK("ENTER\n"); | 951 | DPRINTK("ENTER\n"); |
954 | 952 | ||
955 | carm_end_rq(host, crq, is_ok); | 953 | carm_end_rq(host, crq, error); |
956 | 954 | ||
957 | if (!is_ok) | 955 | if (error) |
958 | goto out; | 956 | goto out; |
959 | if (le32_to_cpu(desc->array_status) & ARRAY_NO_EXIST) | 957 | if (le32_to_cpu(desc->array_status) & ARRAY_NO_EXIST) |
960 | goto out; | 958 | goto out; |
@@ -1001,7 +999,7 @@ out: | |||
1001 | 999 | ||
1002 | static void carm_handle_scan_chan(struct carm_host *host, | 1000 | static void carm_handle_scan_chan(struct carm_host *host, |
1003 | struct carm_request *crq, u8 *mem, | 1001 | struct carm_request *crq, u8 *mem, |
1004 | int is_ok) | 1002 | int error) |
1005 | { | 1003 | { |
1006 | u8 *msg_data = mem + IOC_SCAN_CHAN_OFFSET; | 1004 | u8 *msg_data = mem + IOC_SCAN_CHAN_OFFSET; |
1007 | unsigned int i, dev_count = 0; | 1005 | unsigned int i, dev_count = 0; |
@@ -1009,9 +1007,9 @@ static void carm_handle_scan_chan(struct carm_host *host, | |||
1009 | 1007 | ||
1010 | DPRINTK("ENTER\n"); | 1008 | DPRINTK("ENTER\n"); |
1011 | 1009 | ||
1012 | carm_end_rq(host, crq, is_ok); | 1010 | carm_end_rq(host, crq, error); |
1013 | 1011 | ||
1014 | if (!is_ok) { | 1012 | if (error) { |
1015 | new_state = HST_ERROR; | 1013 | new_state = HST_ERROR; |
1016 | goto out; | 1014 | goto out; |
1017 | } | 1015 | } |
@@ -1033,23 +1031,23 @@ out: | |||
1033 | } | 1031 | } |
1034 | 1032 | ||
1035 | static void carm_handle_generic(struct carm_host *host, | 1033 | static void carm_handle_generic(struct carm_host *host, |
1036 | struct carm_request *crq, int is_ok, | 1034 | struct carm_request *crq, int error, |
1037 | int cur_state, int next_state) | 1035 | int cur_state, int next_state) |
1038 | { | 1036 | { |
1039 | DPRINTK("ENTER\n"); | 1037 | DPRINTK("ENTER\n"); |
1040 | 1038 | ||
1041 | carm_end_rq(host, crq, is_ok); | 1039 | carm_end_rq(host, crq, error); |
1042 | 1040 | ||
1043 | assert(host->state == cur_state); | 1041 | assert(host->state == cur_state); |
1044 | if (is_ok) | 1042 | if (error) |
1045 | host->state = next_state; | ||
1046 | else | ||
1047 | host->state = HST_ERROR; | 1043 | host->state = HST_ERROR; |
1044 | else | ||
1045 | host->state = next_state; | ||
1048 | schedule_work(&host->fsm_task); | 1046 | schedule_work(&host->fsm_task); |
1049 | } | 1047 | } |
1050 | 1048 | ||
1051 | static inline void carm_handle_rw(struct carm_host *host, | 1049 | static inline void carm_handle_rw(struct carm_host *host, |
1052 | struct carm_request *crq, int is_ok) | 1050 | struct carm_request *crq, int error) |
1053 | { | 1051 | { |
1054 | int pci_dir; | 1052 | int pci_dir; |
1055 | 1053 | ||
@@ -1062,7 +1060,7 @@ static inline void carm_handle_rw(struct carm_host *host, | |||
1062 | 1060 | ||
1063 | pci_unmap_sg(host->pdev, &crq->sg[0], crq->n_elem, pci_dir); | 1061 | pci_unmap_sg(host->pdev, &crq->sg[0], crq->n_elem, pci_dir); |
1064 | 1062 | ||
1065 | carm_end_rq(host, crq, is_ok); | 1063 | carm_end_rq(host, crq, error); |
1066 | } | 1064 | } |
1067 | 1065 | ||
1068 | static inline void carm_handle_resp(struct carm_host *host, | 1066 | static inline void carm_handle_resp(struct carm_host *host, |
@@ -1071,7 +1069,7 @@ static inline void carm_handle_resp(struct carm_host *host, | |||
1071 | u32 handle = le32_to_cpu(ret_handle_le); | 1069 | u32 handle = le32_to_cpu(ret_handle_le); |
1072 | unsigned int msg_idx; | 1070 | unsigned int msg_idx; |
1073 | struct carm_request *crq; | 1071 | struct carm_request *crq; |
1074 | int is_ok = (status == RMSG_OK); | 1072 | int error = (status == RMSG_OK) ? 0 : -EIO; |
1075 | u8 *mem; | 1073 | u8 *mem; |
1076 | 1074 | ||
1077 | VPRINTK("ENTER, handle == 0x%x\n", handle); | 1075 | VPRINTK("ENTER, handle == 0x%x\n", handle); |
@@ -1090,7 +1088,7 @@ static inline void carm_handle_resp(struct carm_host *host, | |||
1090 | /* fast path */ | 1088 | /* fast path */ |
1091 | if (likely(crq->msg_type == CARM_MSG_READ || | 1089 | if (likely(crq->msg_type == CARM_MSG_READ || |
1092 | crq->msg_type == CARM_MSG_WRITE)) { | 1090 | crq->msg_type == CARM_MSG_WRITE)) { |
1093 | carm_handle_rw(host, crq, is_ok); | 1091 | carm_handle_rw(host, crq, error); |
1094 | return; | 1092 | return; |
1095 | } | 1093 | } |
1096 | 1094 | ||
@@ -1100,7 +1098,7 @@ static inline void carm_handle_resp(struct carm_host *host, | |||
1100 | case CARM_MSG_IOCTL: { | 1098 | case CARM_MSG_IOCTL: { |
1101 | switch (crq->msg_subtype) { | 1099 | switch (crq->msg_subtype) { |
1102 | case CARM_IOC_SCAN_CHAN: | 1100 | case CARM_IOC_SCAN_CHAN: |
1103 | carm_handle_scan_chan(host, crq, mem, is_ok); | 1101 | carm_handle_scan_chan(host, crq, mem, error); |
1104 | break; | 1102 | break; |
1105 | default: | 1103 | default: |
1106 | /* unknown / invalid response */ | 1104 | /* unknown / invalid response */ |
@@ -1112,21 +1110,21 @@ static inline void carm_handle_resp(struct carm_host *host, | |||
1112 | case CARM_MSG_MISC: { | 1110 | case CARM_MSG_MISC: { |
1113 | switch (crq->msg_subtype) { | 1111 | switch (crq->msg_subtype) { |
1114 | case MISC_ALLOC_MEM: | 1112 | case MISC_ALLOC_MEM: |
1115 | carm_handle_generic(host, crq, is_ok, | 1113 | carm_handle_generic(host, crq, error, |
1116 | HST_ALLOC_BUF, HST_SYNC_TIME); | 1114 | HST_ALLOC_BUF, HST_SYNC_TIME); |
1117 | break; | 1115 | break; |
1118 | case MISC_SET_TIME: | 1116 | case MISC_SET_TIME: |
1119 | carm_handle_generic(host, crq, is_ok, | 1117 | carm_handle_generic(host, crq, error, |
1120 | HST_SYNC_TIME, HST_GET_FW_VER); | 1118 | HST_SYNC_TIME, HST_GET_FW_VER); |
1121 | break; | 1119 | break; |
1122 | case MISC_GET_FW_VER: { | 1120 | case MISC_GET_FW_VER: { |
1123 | struct carm_fw_ver *ver = (struct carm_fw_ver *) | 1121 | struct carm_fw_ver *ver = (struct carm_fw_ver *) |
1124 | mem + sizeof(struct carm_msg_get_fw_ver); | 1122 | mem + sizeof(struct carm_msg_get_fw_ver); |
1125 | if (is_ok) { | 1123 | if (!error) { |
1126 | host->fw_ver = le32_to_cpu(ver->version); | 1124 | host->fw_ver = le32_to_cpu(ver->version); |
1127 | host->flags |= (ver->features & FL_FW_VER_MASK); | 1125 | host->flags |= (ver->features & FL_FW_VER_MASK); |
1128 | } | 1126 | } |
1129 | carm_handle_generic(host, crq, is_ok, | 1127 | carm_handle_generic(host, crq, error, |
1130 | HST_GET_FW_VER, HST_PORT_SCAN); | 1128 | HST_GET_FW_VER, HST_PORT_SCAN); |
1131 | break; | 1129 | break; |
1132 | } | 1130 | } |
@@ -1140,7 +1138,7 @@ static inline void carm_handle_resp(struct carm_host *host, | |||
1140 | case CARM_MSG_ARRAY: { | 1138 | case CARM_MSG_ARRAY: { |
1141 | switch (crq->msg_subtype) { | 1139 | switch (crq->msg_subtype) { |
1142 | case CARM_ARRAY_INFO: | 1140 | case CARM_ARRAY_INFO: |
1143 | carm_handle_array_info(host, crq, mem, is_ok); | 1141 | carm_handle_array_info(host, crq, mem, error); |
1144 | break; | 1142 | break; |
1145 | default: | 1143 | default: |
1146 | /* unknown / invalid response */ | 1144 | /* unknown / invalid response */ |
@@ -1159,7 +1157,7 @@ static inline void carm_handle_resp(struct carm_host *host, | |||
1159 | err_out: | 1157 | err_out: |
1160 | printk(KERN_WARNING DRV_NAME "(%s): BUG: unhandled message type %d/%d\n", | 1158 | printk(KERN_WARNING DRV_NAME "(%s): BUG: unhandled message type %d/%d\n", |
1161 | pci_name(host->pdev), crq->msg_type, crq->msg_subtype); | 1159 | pci_name(host->pdev), crq->msg_type, crq->msg_subtype); |
1162 | carm_end_rq(host, crq, 0); | 1160 | carm_end_rq(host, crq, -EIO); |
1163 | } | 1161 | } |
1164 | 1162 | ||
1165 | static inline void carm_handle_responses(struct carm_host *host) | 1163 | static inline void carm_handle_responses(struct carm_host *host) |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 08e909dc7944..c6179d6ac6e4 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -808,16 +808,16 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
808 | 808 | ||
809 | static void ub_end_rq(struct request *rq, unsigned int scsi_status) | 809 | static void ub_end_rq(struct request *rq, unsigned int scsi_status) |
810 | { | 810 | { |
811 | int uptodate; | 811 | int error; |
812 | 812 | ||
813 | if (scsi_status == 0) { | 813 | if (scsi_status == 0) { |
814 | uptodate = 1; | 814 | error = 0; |
815 | } else { | 815 | } else { |
816 | uptodate = 0; | 816 | error = -EIO; |
817 | rq->errors = scsi_status; | 817 | rq->errors = scsi_status; |
818 | } | 818 | } |
819 | end_that_request_first(rq, uptodate, rq->hard_nr_sectors); | 819 | if (__blk_end_request(rq, error, blk_rq_bytes(rq))) |
820 | end_that_request_last(rq, uptodate); | 820 | BUG(); |
821 | } | 821 | } |
822 | 822 | ||
823 | static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, | 823 | static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, |
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index ab5d404faa11..9e61fca46117 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c | |||
@@ -229,13 +229,10 @@ static struct block_device_operations viodasd_fops = { | |||
229 | /* | 229 | /* |
230 | * End a request | 230 | * End a request |
231 | */ | 231 | */ |
232 | static void viodasd_end_request(struct request *req, int uptodate, | 232 | static void viodasd_end_request(struct request *req, int error, |
233 | int num_sectors) | 233 | int num_sectors) |
234 | { | 234 | { |
235 | if (end_that_request_first(req, uptodate, num_sectors)) | 235 | __blk_end_request(req, error, num_sectors << 9); |
236 | return; | ||
237 | add_disk_randomness(req->rq_disk); | ||
238 | end_that_request_last(req, uptodate); | ||
239 | } | 236 | } |
240 | 237 | ||
241 | /* | 238 | /* |
@@ -374,12 +371,12 @@ static void do_viodasd_request(struct request_queue *q) | |||
374 | blkdev_dequeue_request(req); | 371 | blkdev_dequeue_request(req); |
375 | /* check that request contains a valid command */ | 372 | /* check that request contains a valid command */ |
376 | if (!blk_fs_request(req)) { | 373 | if (!blk_fs_request(req)) { |
377 | viodasd_end_request(req, 0, req->hard_nr_sectors); | 374 | viodasd_end_request(req, -EIO, req->hard_nr_sectors); |
378 | continue; | 375 | continue; |
379 | } | 376 | } |
380 | /* Try sending the request */ | 377 | /* Try sending the request */ |
381 | if (send_request(req) != 0) | 378 | if (send_request(req) != 0) |
382 | viodasd_end_request(req, 0, req->hard_nr_sectors); | 379 | viodasd_end_request(req, -EIO, req->hard_nr_sectors); |
383 | } | 380 | } |
384 | } | 381 | } |
385 | 382 | ||
@@ -591,7 +588,7 @@ static int viodasd_handle_read_write(struct vioblocklpevent *bevent) | |||
591 | num_req_outstanding--; | 588 | num_req_outstanding--; |
592 | spin_unlock_irqrestore(&viodasd_spinlock, irq_flags); | 589 | spin_unlock_irqrestore(&viodasd_spinlock, irq_flags); |
593 | 590 | ||
594 | error = event->xRc != HvLpEvent_Rc_Good; | 591 | error = (event->xRc == HvLpEvent_Rc_Good) ? 0 : -EIO; |
595 | if (error) { | 592 | if (error) { |
596 | const struct vio_error_entry *err; | 593 | const struct vio_error_entry *err; |
597 | err = vio_lookup_rc(viodasd_err_table, bevent->sub_result); | 594 | err = vio_lookup_rc(viodasd_err_table, bevent->sub_result); |
@@ -601,7 +598,7 @@ static int viodasd_handle_read_write(struct vioblocklpevent *bevent) | |||
601 | } | 598 | } |
602 | qlock = req->q->queue_lock; | 599 | qlock = req->q->queue_lock; |
603 | spin_lock_irqsave(qlock, irq_flags); | 600 | spin_lock_irqsave(qlock, irq_flags); |
604 | viodasd_end_request(req, !error, num_sect); | 601 | viodasd_end_request(req, error, num_sect); |
605 | spin_unlock_irqrestore(qlock, irq_flags); | 602 | spin_unlock_irqrestore(qlock, irq_flags); |
606 | 603 | ||
607 | /* Finally, try to get more requests off of this device's queue */ | 604 | /* Finally, try to get more requests off of this device's queue */ |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 2bdebcb3ff16..8afce67c0aa5 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -452,7 +452,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) | |||
452 | RING_IDX i, rp; | 452 | RING_IDX i, rp; |
453 | unsigned long flags; | 453 | unsigned long flags; |
454 | struct blkfront_info *info = (struct blkfront_info *)dev_id; | 454 | struct blkfront_info *info = (struct blkfront_info *)dev_id; |
455 | int uptodate; | 455 | int error; |
456 | 456 | ||
457 | spin_lock_irqsave(&blkif_io_lock, flags); | 457 | spin_lock_irqsave(&blkif_io_lock, flags); |
458 | 458 | ||
@@ -477,13 +477,13 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) | |||
477 | 477 | ||
478 | add_id_to_freelist(info, id); | 478 | add_id_to_freelist(info, id); |
479 | 479 | ||
480 | uptodate = (bret->status == BLKIF_RSP_OKAY); | 480 | error = (bret->status == BLKIF_RSP_OKAY) ? 0 : -EIO; |
481 | switch (bret->operation) { | 481 | switch (bret->operation) { |
482 | case BLKIF_OP_WRITE_BARRIER: | 482 | case BLKIF_OP_WRITE_BARRIER: |
483 | if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { | 483 | if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { |
484 | printk(KERN_WARNING "blkfront: %s: write barrier op failed\n", | 484 | printk(KERN_WARNING "blkfront: %s: write barrier op failed\n", |
485 | info->gd->disk_name); | 485 | info->gd->disk_name); |
486 | uptodate = -EOPNOTSUPP; | 486 | error = -EOPNOTSUPP; |
487 | info->feature_barrier = 0; | 487 | info->feature_barrier = 0; |
488 | xlvbd_barrier(info); | 488 | xlvbd_barrier(info); |
489 | } | 489 | } |
@@ -494,10 +494,8 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) | |||
494 | dev_dbg(&info->xbdev->dev, "Bad return from blkdev data " | 494 | dev_dbg(&info->xbdev->dev, "Bad return from blkdev data " |
495 | "request: %x\n", bret->status); | 495 | "request: %x\n", bret->status); |
496 | 496 | ||
497 | ret = end_that_request_first(req, uptodate, | 497 | ret = __blk_end_request(req, error, blk_rq_bytes(req)); |
498 | req->hard_nr_sectors); | ||
499 | BUG_ON(ret); | 498 | BUG_ON(ret); |
500 | end_that_request_last(req, uptodate); | ||
501 | break; | 499 | break; |
502 | default: | 500 | default: |
503 | BUG(); | 501 | BUG(); |
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index 82effce97c51..2c81465fd60c 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c | |||
@@ -703,7 +703,7 @@ static void ace_fsm_dostate(struct ace_device *ace) | |||
703 | 703 | ||
704 | /* bio finished; is there another one? */ | 704 | /* bio finished; is there another one? */ |
705 | i = ace->req->current_nr_sectors; | 705 | i = ace->req->current_nr_sectors; |
706 | if (end_that_request_first(ace->req, 1, i)) { | 706 | if (__blk_end_request(ace->req, 0, i)) { |
707 | /* dev_dbg(ace->dev, "next block; h=%li c=%i\n", | 707 | /* dev_dbg(ace->dev, "next block; h=%li c=%i\n", |
708 | * ace->req->hard_nr_sectors, | 708 | * ace->req->hard_nr_sectors, |
709 | * ace->req->current_nr_sectors); | 709 | * ace->req->current_nr_sectors); |
@@ -718,9 +718,6 @@ static void ace_fsm_dostate(struct ace_device *ace) | |||
718 | break; | 718 | break; |
719 | 719 | ||
720 | case ACE_FSM_STATE_REQ_COMPLETE: | 720 | case ACE_FSM_STATE_REQ_COMPLETE: |
721 | /* Complete the block request */ | ||
722 | blkdev_dequeue_request(ace->req); | ||
723 | end_that_request_last(ace->req, 1); | ||
724 | ace->req = NULL; | 721 | ace->req = NULL; |
725 | 722 | ||
726 | /* Finished request; go to idle state */ | 723 | /* Finished request; go to idle state */ |