add detailed error values to block layer
Subsystems (2)
RFC PATCH 1/2 add detailed error values to block layer
01-ec-core.patch defines new block error values, and modifies the request completion functions. Right now they just convert the uptodate status to an error value.
diffstat
drivers/block/ll_rw_blk.c | 25 +++++++++++++------------ fs/bio.c | 8 ++++---- include/linux/bio.h | 2 +- include/linux/blkdev.h | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 17 deletions(-)
Mike Chrisite
drivers/block/ll_rw_blk.c +13 -12
@@ -2597,10 +2597,10 @@ void blk_recalc_rq_sectors(struct reques } } -static int __end_that_request_first (struct request *req,int uptodate, +static int __end_that_request_first (struct request *req,int error,int nr_bytes) { -int total_bytes, bio_nbytes, error =0 , next_idx =0 ; +int total_bytes, bio_nbytes, next_idx =0 ;struct bio *bio;/*
@@ -2610,13 +2610,10 @@ static int __end_that_request_first(struif (!blk_pc_request (req)) req->errors =0 ; -if (!uptodate) { - error = -EIO ; -if (blk_fs_request (req) && !(req->flags &REQ_QUIET )) -printk ("end_request: I/O error, dev %s, sector %llu\n" , - req->rq_disk ? req->rq_disk->disk_name :"?" , - (unsigned long long )req->sector); - } +if (error &&blk_fs_request (req) && !(req->flags &REQ_QUIET )) +printk ("end_request: I/O error num %d, dev %s, sector %llu\n" , + error, req->rq_disk ? req->rq_disk->disk_name :"?" , + (unsigned long long )req->sector); total_bytes = bio_nbytes =0 ;while ((bio = req->bio)) {
@@ -2707,7 +2704,8 @@ static int __end_that_request_first(stru**/ int end_that_request_first (struct request *req,int uptodate,int nr_sectors) { -return __end_that_request_first (req, uptodate, nr_sectors <<9 ); +int err = uptodate ?BLK_SUCCESS :BLK_ERR ; +return __end_that_request_first (req, err, nr_sectors <<9 ); }EXPORT_SYMBOL (end_that_request_first);
@@ -2729,7 +2727,8 @@ EXPORT_SYMBOL(end_that_request_first);**/ int end_that_request_chunk (struct request *req,int uptodate,int nr_bytes) { -return __end_that_request_first (req, uptodate, nr_bytes); +int err = uptodate ?BLK_SUCCESS :BLK_ERR ; +return __end_that_request_first (req, err, nr_bytes); }EXPORT_SYMBOL (end_that_request_chunk);
@@ -2767,7 +2766,9 @@ EXPORT_SYMBOL(end_that_request_last);void end_request (struct request *req,int uptodate) { -if (!end_that_request_first (req, uptodate, req->hard_cur_sectors)) { +int err = uptodate ?BLK_SUCCESS :BLK_ERR ; + +if (!end_that_request_first (req, err, req->hard_cur_sectors)) {add_disk_randomness (req->rq_disk);blkdev_dequeue_request (req);end_that_request_last (req);
fs/bio.c +4 -4
@@ -664,10 +664,10 @@ void bio_check_pages_dirty(struct bio *b* bio_endio() will end I/O on @bytes_done number of bytes. This may be * just a partial part of the bio, or it may be the whole bio. bio_endio() * is the preferred way to end I/O on a bio, it takes care of decrementing -* bi_size and clearing BIO_UPTODATE on error. @error is 0 on success, and -* and one of the established -Exxxx (-EIO, for instance) error values in -* case something went wrong. Noone should call bi_end_io() directly on -* a bio unless they own it and thus know that it has an end_io function. +* bi_size and clearing BIO_UPTODATE on error. @error is one of the +* established BLK_xxx error values defined in blkdev.h. Noone should +* call bi_end_io() directly on a bio unless they own it and thus know +* that it has an end_io function. **/ void bio_endio (struct bio *bio,unsigned int bytes_done,int error) {
include/linux/bio.h +1 -1
@@ -174,7 +174,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, bytes) bio_endio((bio), (bytes), -EIO) +#define bio_io_error (bio, bytes) bio_endio((bio), (bytes), BLK_ERR)/* * drivers should not use the __ version unless they _really_ want to
include/linux/blkdev.h +16 -0
@@ -527,6 +527,22 @@ static inline request_queue_t *bdev_get_ }/* +* Error values that users of end_that_request_first/chunk, +* end_request and bio_endio should use to indicate IO +* completion status. +*/ +enum { +BLK_SUCCESS , +BLK_ERR ,/* Generic error like -EIO */ +BLK_FATAL_DEV ,/* Fatal driver error */ +BLK_FATAL_TRNSPT ,/* Fatal transport error */ +BLK_FATAL_DRV ,/* Fatal driver error */ +BLK_RETRY_DEV ,/* Device error, I/O may be retried */ +BLK_RETRY_TRNSPT ,/* Transport error, I/O may retried */ +BLK_RETRY_DRV ,/* Driver error, I/O may be retried */ +}; + +/* * end_request() and friends. Must be called with the request queue spinlock * acquired. All functions called within end_request() _must_be_ atomic. *
Hi!
include/linux/blkdev.h static inline request_queue_t *bdev_get_ · line 537
Quoted 4 lines
include/linux/blkdev.h +4
-0+enum { +BLK_SUCCESS , +BLK_ERR ,/* Generic error like -EIO */ +BLK_FATAL_DEV ,/* Fatal driver error */
perhaps this should be fatal *device* error?
Quoted 11 lines
include/linux/blkdev.h +8
-0+BLK_FATAL_TRNSPT ,/* Fatal transport error */ +BLK_FATAL_DRV ,/* Fatal driver error */ +BLK_RETRY_DEV ,/* Device error, I/O may be retried */ +BLK_RETRY_TRNSPT ,/* Transport error, I/O may retried */ + BLK_RETRY_DRV, /* Driver error, I/O may be retried */ +}; + +/* * end_request() and friends. Must be called with the request queue spinlock * acquired. All functions called within end_request() _must_be_ atomic. *
Signature · 2 lines
When do you have a heart between your knees? [Johanka's followup: and *two* hearts?]
Quoted 10 lines · Pavel Machek
Hi!
include/linux/blkdev.h static inline request_queue_t *bdev_get_ · line 537
Quoted 4 lines
include/linux/blkdev.h +4
-0+enum { +BLK_SUCCESS , +BLK_ERR ,/* Generic error like -EIO */ +BLK_FATAL_DEV ,/* Fatal driver error */ perhaps this should be fatal *device* error?
Hi,
Your right thanks.
Mike Christie