History

[BLOCK] add @uptodate to end_that_request_last() and @error to rq_end_io_fn()

add @uptodate argument to end_that_request_last() and @error to rq_end_io_fn(). there's no generic way to pass error code to request completion function, making generic error handling of non-fs request difficult (rq->errors is driver-specific and each driver uses it differently). this patch adds @uptodate to end_that_request_last() and @error to rq_end_io_fn(). for fs requests, this doesn't really matter, so just using the same uptodate argument used in the last call to end_that_request_first() should suffice. imho, this can also help the generic command-carrying request jens is working on.

Tejun Heo committed 20 years ago

Commit 8ffdc651 parent 641000921 files · +42 −34Browse files

Unified · Split

21 files
  1. block/elevator.c +1 −1
  2. block/ll_rw_blk.c +15 −7
  3. drivers/block/DAC960.c +1 −1
  4. drivers/block/cciss.c +1 −1
  5. drivers/block/cpqarray.c +1 −1
  6. drivers/block/floppy.c +1 −1
  7. drivers/block/nbd.c +1 −1
  8. drivers/block/sx8.c +1 −1
  9. drivers/block/ub.c +1 −1
  10. drivers/block/viodasd.c +1 −1
  11. drivers/cdrom/cdu31a.c +1 −1
  12. drivers/ide/ide-cd.c +2 −2
  13. drivers/ide/ide-io.c +3 −3
  14. drivers/message/i2o/i2o_block.c +1 −1
  15. drivers/mmc/mmc_block.c +2 −2
  16. drivers/s390/block/dasd.c +1 −1
  17. drivers/s390/char/tape_block.c +1 −1
  18. drivers/scsi/ide-scsi.c +2 −2
  19. drivers/scsi/scsi_lib.c +1 −1
  20. drivers/scsi/sd.c +1 −1
  21. include/linux/blkdev.h +3 −3
block/elevator.c+1−1
@@ -498,7 +498,7 @@ struct request *elv_next_request(request_queue_t *q) · 497 unmodified lines
498498 blkdev_dequeue_request(rq);
499499 rq->flags |= REQ_QUIET;
500500 end_that_request_chunk(rq, 0, nr_bytes);
501− end_that_request_last(rq);
501+ end_that_request_last(rq, 0);
502502 } else {
503503 printk(KERN_ERR "%s: bad return=%d\n", __FUNCTION__,
504504 ret);
block/ll_rw_blk.c+15−7
@@ -344,7 +344,7 @@ EXPORT_SYMBOL(blk_queue_issue_flush_fn); · 343 unmodified lines
344344 /*
345345 * Cache flushing for ordered writes handling
346346 */
347−static void blk_pre_flush_end_io(struct request *flush_rq)
347+static void blk_pre_flush_end_io(struct request *flush_rq, int error)
348348 {
349349 struct request *rq = flush_rq->end_io_data;
350350 request_queue_t *q = rq->q;
@@ -362,7 +362,7 @@ static void blk_pre_flush_end_io(struct request *flush_rq) · 11 unmodified lines
362362 }
363363 }
364364
365−static void blk_post_flush_end_io(struct request *flush_rq)
365+static void blk_post_flush_end_io(struct request *flush_rq, int error)
366366 {
367367 struct request *rq = flush_rq->end_io_data;
368368 request_queue_t *q = rq->q;
@@ -2317,7 +2317,7 @@ EXPORT_SYMBOL(blk_rq_map_kern); · 1948 unmodified lines
23172317 */
23182318 void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk,
23192319 struct request *rq, int at_head,
2320− void (*done)(struct request *))
2320+ rq_end_io_fn *done)
23212321 {
23222322 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
23232323
@@ -2521,7 +2521,7 @@ EXPORT_SYMBOL(blk_put_request); · 197 unmodified lines
25212521 * blk_end_sync_rq - executes a completion event on a request
25222522 * @rq: request to complete
25232523 */
2524−void blk_end_sync_rq(struct request *rq)
2524+void blk_end_sync_rq(struct request *rq, int error)
25252525 {
25262526 struct completion *waiting = rq->waiting;
25272527
@@ -3183,9 +3183,17 @@ EXPORT_SYMBOL(end_that_request_chunk); · 655 unmodified lines
31833183 /*
31843184 * queue lock must be held
31853185 */
3186−void end_that_request_last(struct request *req)
3186+void end_that_request_last(struct request *req, int uptodate)
31873187 {
31883188 struct gendisk *disk = req->rq_disk;
3189+ int error;
3190+
3191+ /*
3192+ * extend uptodate bool to allow < 0 value to be direct io error
3193+ */
3194+ error = 0;
3195+ if (end_io_error(uptodate))
3196+ error = !uptodate ? -EIO : uptodate;
31893197
31903198 if (unlikely(laptop_mode) && blk_fs_request(req))
31913199 laptop_io_completion();
@@ -3200,7 +3208,7 @@ void end_that_request_last(struct request *req) · 8 unmodified lines
32003208 disk->in_flight--;
32013209 }
32023210 if (req->end_io)
3203− req->end_io(req);
3211+ req->end_io(req, error);
32043212 else
32053213 __blk_put_request(req->q, req);
32063214 }
@@ -3212,7 +3220,7 @@ void end_request(struct request *req, int uptodate) · 5 unmodified lines
32123220 if (!end_that_request_first(req, uptodate, req->hard_cur_sectors)) {
32133221 add_disk_randomness(req->rq_disk);
32143222 blkdev_dequeue_request(req);
3215− end_that_request_last(req);
3223+ end_that_request_last(req, uptodate);
32163224 }
32173225 }
32183226
drivers/block/DAC960.c+1−1
@@ -3471,7 +3471,7 @@ static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command, · 3470 unmodified lines
34713471
34723472 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) {
34733473
3474− end_that_request_last(Request);
3474+ end_that_request_last(Request, UpToDate);
34753475
34763476 if (Command->Completion) {
34773477 complete(Command->Completion);
drivers/block/cciss.c+1−1
@@ -2310,7 +2310,7 @@ static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd, · 2309 unmodified lines
23102310 printk("Done with %p\n", cmd->rq);
23112311 #endif /* CCISS_DEBUG */
23122312
2313− end_that_request_last(cmd->rq);
2313+ end_that_request_last(cmd->rq, status ? 1 : -EIO);
23142314 cmd_free(h,cmd,1);
23152315 }
23162316
drivers/block/cpqarray.c+1−1
@@ -1036,7 +1036,7 @@ static inline void complete_command(cmdlist_t *cmd, int timeout) · 1035 unmodified lines
10361036 complete_buffers(cmd->rq->bio, ok);
10371037
10381038 DBGPX(printk("Done with %p\n", cmd->rq););
1039− end_that_request_last(cmd->rq);
1039+ end_that_request_last(cmd->rq, ok ? 1 : -EIO);
10401040 }
10411041
10421042 /*
drivers/block/floppy.c+1−1
@@ -2301,7 +2301,7 @@ static void floppy_end_request(struct request *req, int uptodate) · 2300 unmodified lines
23012301 add_disk_randomness(req->rq_disk);
23022302 floppy_off((long)req->rq_disk->private_data);
23032303 blkdev_dequeue_request(req);
2304− end_that_request_last(req);
2304+ end_that_request_last(req, uptodate);
23052305
23062306 /* We're done with the request */
23072307 current_req = NULL;
drivers/block/nbd.c+1−1
@@ -136,7 +136,7 @@ static void nbd_end_request(struct request *req) · 135 unmodified lines
136136
137137 spin_lock_irqsave(q->queue_lock, flags);
138138 if (!end_that_request_first(req, uptodate, req->nr_sectors)) {
139− end_that_request_last(req);
139+ end_that_request_last(req, uptodate);
140140 }
141141 spin_unlock_irqrestore(q->queue_lock, flags);
142142 }
drivers/block/sx8.c+1−1
@@ -770,7 +770,7 @@ static inline void carm_end_request_queued(struct carm_host *host, · 769 unmodified lines
770770 rc = end_that_request_first(req, uptodate, req->hard_nr_sectors);
771771 assert(rc == 0);
772772
773− end_that_request_last(req);
773+ end_that_request_last(req, uptodate);
774774
775775 rc = carm_put_request(host, crq);
776776 assert(rc == 0);
drivers/block/ub.c+1−1
@@ -951,7 +951,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) · 950 unmodified lines
951951 static void ub_end_rq(struct request *rq, int uptodate)
952952 {
953953 end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
954− end_that_request_last(rq);
954+ end_that_request_last(rq, uptodate);
955955 }
956956
957957 static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
drivers/block/viodasd.c+1−1
@@ -305,7 +305,7 @@ static void viodasd_end_request(struct request *req, int uptodate, · 304 unmodified lines
305305 if (end_that_request_first(req, uptodate, num_sectors))
306306 return;
307307 add_disk_randomness(req->rq_disk);
308− end_that_request_last(req);
308+ end_that_request_last(req, uptodate);
309309 }
310310
311311 /*
drivers/cdrom/cdu31a.c+1−1
@@ -1402,7 +1402,7 @@ static void do_cdu31a_request(request_queue_t * q) · 1401 unmodified lines
14021402 if (!end_that_request_first(req, 1, nblock)) {
14031403 spin_lock_irq(q->queue_lock);
14041404 blkdev_dequeue_request(req);
1405− end_that_request_last(req);
1405+ end_that_request_last(req, 1);
14061406 spin_unlock_irq(q->queue_lock);
14071407 }
14081408 continue;
drivers/ide/ide-cd.c+2−2
@@ -614,7 +614,7 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate) · 613 unmodified lines
614614 */
615615 spin_lock_irqsave(&ide_lock, flags);
616616 end_that_request_chunk(failed, 0, failed->data_len);
617− end_that_request_last(failed);
617+ end_that_request_last(failed, 0);
618618 spin_unlock_irqrestore(&ide_lock, flags);
619619 }
620620
@@ -1735,7 +1735,7 @@ end_request: · 1114 unmodified lines
17351735
17361736 spin_lock_irqsave(&ide_lock, flags);
17371737 blkdev_dequeue_request(rq);
1738− end_that_request_last(rq);
1738+ end_that_request_last(rq, 1);
17391739 HWGROUP(drive)->rq = NULL;
17401740 spin_unlock_irqrestore(&ide_lock, flags);
17411741 return ide_stopped;
drivers/ide/ide-io.c+3−3
@@ -89,7 +89,7 @@ int __ide_end_request(ide_drive_t *drive, struct request *rq, int uptodate, · 88 unmodified lines
8989
9090 blkdev_dequeue_request(rq);
9191 HWGROUP(drive)->rq = NULL;
92− end_that_request_last(rq);
92+ end_that_request_last(rq, uptodate);
9393 ret = 0;
9494 }
9595 return ret;
@@ -247,7 +247,7 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq) · 151 unmodified lines
247247 }
248248 blkdev_dequeue_request(rq);
249249 HWGROUP(drive)->rq = NULL;
250− end_that_request_last(rq);
250+ end_that_request_last(rq, 1);
251251 spin_unlock_irqrestore(&ide_lock, flags);
252252 }
253253
@@ -379,7 +379,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) · 125 unmodified lines
379379 blkdev_dequeue_request(rq);
380380 HWGROUP(drive)->rq = NULL;
381381 rq->errors = err;
382− end_that_request_last(rq);
382+ end_that_request_last(rq, !rq->errors);
383383 spin_unlock_irqrestore(&ide_lock, flags);
384384 }
385385
drivers/message/i2o/i2o_block.c+1−1
@@ -466,7 +466,7 @@ static void i2o_block_end_request(struct request *req, int uptodate, · 465 unmodified lines
466466
467467 spin_lock_irqsave(q->queue_lock, flags);
468468
469− end_that_request_last(req);
469+ end_that_request_last(req, uptodate);
470470
471471 if (likely(dev)) {
472472 dev->open_queue_depth--;
drivers/mmc/mmc_block.c+2−2
@@ -263,7 +263,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) · 262 unmodified lines
263263 */
264264 add_disk_randomness(req->rq_disk);
265265 blkdev_dequeue_request(req);
266− end_that_request_last(req);
266+ end_that_request_last(req, 1);
267267 }
268268 spin_unlock_irq(&md->lock);
269269 } while (ret);
@@ -289,7 +289,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) · 19 unmodified lines
289289
290290 add_disk_randomness(req->rq_disk);
291291 blkdev_dequeue_request(req);
292− end_that_request_last(req);
292+ end_that_request_last(req, 0);
293293 spin_unlock_irq(&md->lock);
294294
295295 return 0;
drivers/s390/block/dasd.c+1−1
@@ -1035,7 +1035,7 @@ dasd_end_request(struct request *req, int uptodate) · 1034 unmodified lines
10351035 if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
10361036 BUG();
10371037 add_disk_randomness(req->rq_disk);
1038− end_that_request_last(req);
1038+ end_that_request_last(req, uptodate);
10391039 }
10401040
10411041 /*
drivers/s390/char/tape_block.c+1−1
@@ -78,7 +78,7 @@ tapeblock_end_request(struct request *req, int uptodate) · 77 unmodified lines
7878 {
7979 if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
8080 BUG();
81− end_that_request_last(req);
81+ end_that_request_last(req, uptodate);
8282 }
8383
8484 static void
drivers/scsi/ide-scsi.c+2−2
@@ -1046,7 +1046,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd) · 1045 unmodified lines
10461046
10471047 /* kill current request */
10481048 blkdev_dequeue_request(req);
1049− end_that_request_last(req);
1049+ end_that_request_last(req, 0);
10501050 if (req->flags & REQ_SENSE)
10511051 kfree(scsi->pc->buffer);
10521052 kfree(scsi->pc);
@@ -1056,7 +1056,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd) · 3 unmodified lines
10561056 /* now nuke the drive queue */
10571057 while ((req = elv_next_request(drive->queue))) {
10581058 blkdev_dequeue_request(req);
1059− end_that_request_last(req);
1059+ end_that_request_last(req, 0);
10601060 }
10611061
10621062 HWGROUP(drive)->rq = NULL;
drivers/scsi/scsi_lib.c+1−1
@@ -791,7 +791,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, · 790 unmodified lines
791791 spin_lock_irqsave(q->queue_lock, flags);
792792 if (blk_rq_tagged(req))
793793 blk_queue_end_tag(q, req);
794− end_that_request_last(req);
794+ end_that_request_last(req, uptodate);
795795 spin_unlock_irqrestore(q->queue_lock, flags);
796796
797797 /*
drivers/scsi/sd.c+1−1
@@ -748,7 +748,7 @@ static void sd_end_flush(request_queue_t *q, struct request *flush_rq) · 747 unmodified lines
748748 * force journal abort of barriers
749749 */
750750 end_that_request_first(rq, -EOPNOTSUPP, rq->hard_nr_sectors);
751− end_that_request_last(rq);
751+ end_that_request_last(rq, -EOPNOTSUPP);
752752 }
753753 }
754754
include/linux/blkdev.h+3−3
@@ -102,7 +102,7 @@ void copy_io_context(struct io_context **pdst, struct io_context **psrc); · 101 unmodified lines
102102 void swap_io_context(struct io_context **ioc1, struct io_context **ioc2);
103103
104104 struct request;
105−typedef void (rq_end_io_fn)(struct request *);
105+typedef void (rq_end_io_fn)(struct request *, int);
106106
107107 struct request_list {
108108 int count[2];
@@ -560,7 +560,7 @@ extern void register_disk(struct gendisk *dev); · 451 unmodified lines
560560 extern void generic_make_request(struct bio *bio);
561561 extern void blk_put_request(struct request *);
562562 extern void __blk_put_request(request_queue_t *, struct request *);
563−extern void blk_end_sync_rq(struct request *rq);
563+extern void blk_end_sync_rq(struct request *rq, int error);
564564 extern void blk_attempt_remerge(request_queue_t *, struct request *);
565565 extern struct request *blk_get_request(request_queue_t *, int, gfp_t);
566566 extern void blk_insert_request(request_queue_t *, struct request *, int, void *);
@@ -614,7 +614,7 @@ static inline void blk_run_address_space(struct address_space *mapping) · 47 unmodified lines
614614 */
615615 extern int end_that_request_first(struct request *, int, int);
616616 extern int end_that_request_chunk(struct request *, int, int);
617−extern void end_that_request_last(struct request *);
617+extern void end_that_request_last(struct request *, int);
618618 extern void end_request(struct request *req, int uptodate);
619619
620620 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t