From 392aaa18453fc9d81c6f40b463431761bd5becdf Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 17 Sep 2002 19:00:08 -0700 Subject: [PATCH] partial bio completion notification Make bio->bi_end_io() take bytes_done and actual error as argument. This enables partial completion of bio's, which is important for latency reasons (bio can be huge, for slow media we want page-by-page completions). I think I got most of the bi_end_io() functions out there, but I might have missed a few. For the record, if you don't care about partial completions and just want to be notified when the entire bio completes, add a if (bio->bi_size) return 1; to the top of your bi_end_io(). It should return 0 on completion. bio_endio() will decrement bio->bi_size appropriately, it's recommended for people to go through that. Otherwise they will have to control BIO_UPTODATE and bi_size decrement themselves, there's really no reason to do that. I've deliberately avoided doing any functional changes to any of the end_io functions, as I think that would only make the patch more complex. It's simple right now, but this being i/o paths I prefer (as usual) to be careful and take small steps. The mpage_end_io_read() do-vecs-at-the-time change can come right after this, for instance. --- include/linux/bio.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/bio.h b/include/linux/bio.h index 8113ca45c3d2..e9a0d968d1e2 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -51,7 +51,7 @@ struct bio_vec { }; struct bio; -typedef void (bio_end_io_t) (struct bio *); +typedef int (bio_end_io_t) (struct bio *, unsigned int, int); typedef void (bio_destructor_t) (struct bio *); /* @@ -161,7 +161,7 @@ struct bio { #define BIO_SEG_BOUNDARY(q, b1, b2) \ BIOVEC_SEG_BOUNDARY((q), __BVEC_END((b1)), __BVEC_START((b2))) -#define bio_io_error(bio) bio_endio((bio), 0) +#define bio_io_error(bio, bytes) bio_endio((bio), (bytes), -EIO) /* * drivers should not use the __ version unless they _really_ want to @@ -194,7 +194,7 @@ struct bio { extern struct bio *bio_alloc(int, int); extern void bio_put(struct bio *); -extern void bio_endio(struct bio *, int); +extern int bio_endio(struct bio *, unsigned int, int); struct request_queue; extern inline int bio_phys_segments(struct request_queue *, struct bio *); extern inline int bio_hw_segments(struct request_queue *, struct bio *); -- cgit v1.2.3