aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-06-03 03:38:04 -0400
committerJens Axboe <axboe@fb.com>2017-06-09 11:27:32 -0400
commit2a842acab109f40f0d7d10b38e9ca88390628996 (patch)
treebdfc7a47fe655c2ea7a5f74127015d7a502042f0 /include/linux/blkdev.h
parent1be5690984588953e759af0a4c6ddac182a1806c (diff)
block: introduce new block status code type
Currently we use nornal Linux errno values in the block layer, and while we accept any error a few have overloaded magic meanings. This patch instead introduces a new blk_status_t value that holds block layer specific status codes and explicitly explains their meaning. Helpers to convert from and to the previous special meanings are provided for now, but I suspect we want to get rid of them in the long run - those drivers that have a errno input (e.g. networking) usually get errnos that don't know about the special block layer overloads, and similarly returning them to userspace will usually return somethings that strictly speaking isn't correct for file system operations, but that's left as an exercise for later. For now the set of errors is a very limited set that closely corresponds to the previous overloaded errno values, but there is some low hanging fruite to improve it. blk_status_t (ab)uses the sparse __bitwise annotations to allow for sparse typechecking, so that we can easily catch places passing the wrong values. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 019f18c65098..2a8871638453 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -55,7 +55,7 @@ struct blk_stat_callback;
55 */ 55 */
56#define BLKCG_MAX_POLS 3 56#define BLKCG_MAX_POLS 3
57 57
58typedef void (rq_end_io_fn)(struct request *, int); 58typedef void (rq_end_io_fn)(struct request *, blk_status_t);
59 59
60#define BLK_RL_SYNCFULL (1U << 0) 60#define BLK_RL_SYNCFULL (1U << 0)
61#define BLK_RL_ASYNCFULL (1U << 1) 61#define BLK_RL_ASYNCFULL (1U << 1)
@@ -940,7 +940,7 @@ extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
940 int (*bio_ctr)(struct bio *, struct bio *, void *), 940 int (*bio_ctr)(struct bio *, struct bio *, void *),
941 void *data); 941 void *data);
942extern void blk_rq_unprep_clone(struct request *rq); 942extern void blk_rq_unprep_clone(struct request *rq);
943extern int blk_insert_cloned_request(struct request_queue *q, 943extern blk_status_t blk_insert_cloned_request(struct request_queue *q,
944 struct request *rq); 944 struct request *rq);
945extern int blk_rq_append_bio(struct request *rq, struct bio *bio); 945extern int blk_rq_append_bio(struct request *rq, struct bio *bio);
946extern void blk_delay_queue(struct request_queue *, unsigned long); 946extern void blk_delay_queue(struct request_queue *, unsigned long);
@@ -980,6 +980,9 @@ extern void blk_execute_rq(struct request_queue *, struct gendisk *,
980extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, 980extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
981 struct request *, int, rq_end_io_fn *); 981 struct request *, int, rq_end_io_fn *);
982 982
983int blk_status_to_errno(blk_status_t status);
984blk_status_t errno_to_blk_status(int errno);
985
983bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie); 986bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie);
984 987
985static inline struct request_queue *bdev_get_queue(struct block_device *bdev) 988static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
@@ -1112,16 +1115,16 @@ extern struct request *blk_fetch_request(struct request_queue *q);
1112 * blk_end_request() for parts of the original function. 1115 * blk_end_request() for parts of the original function.
1113 * This prevents code duplication in drivers. 1116 * This prevents code duplication in drivers.
1114 */ 1117 */
1115extern bool blk_update_request(struct request *rq, int error, 1118extern bool blk_update_request(struct request *rq, blk_status_t error,
1116 unsigned int nr_bytes); 1119 unsigned int nr_bytes);
1117extern void blk_finish_request(struct request *rq, int error); 1120extern void blk_finish_request(struct request *rq, blk_status_t error);
1118extern bool blk_end_request(struct request *rq, int error, 1121extern bool blk_end_request(struct request *rq, blk_status_t error,
1119 unsigned int nr_bytes); 1122 unsigned int nr_bytes);
1120extern void blk_end_request_all(struct request *rq, int error); 1123extern void blk_end_request_all(struct request *rq, blk_status_t error);
1121extern bool __blk_end_request(struct request *rq, int error, 1124extern bool __blk_end_request(struct request *rq, blk_status_t error,
1122 unsigned int nr_bytes); 1125 unsigned int nr_bytes);
1123extern void __blk_end_request_all(struct request *rq, int error); 1126extern void __blk_end_request_all(struct request *rq, blk_status_t error);
1124extern bool __blk_end_request_cur(struct request *rq, int error); 1127extern bool __blk_end_request_cur(struct request *rq, blk_status_t error);
1125 1128
1126extern void blk_complete_request(struct request *); 1129extern void blk_complete_request(struct request *);
1127extern void __blk_complete_request(struct request *); 1130extern void __blk_complete_request(struct request *);