summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-07-02 13:37:43 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2020-07-02 13:38:37 -0400
commitbb3a4b8263a99e78be6ee64b8ff181e8abc15ecf (patch)
treefcf828e41790897af2ea8a2d6252d00c0b073375
parentf385d13bf8510277eedcc24de4a6a3c3bf8f334b (diff)
block: Add blk_status_to_str()
If we're going to the trouble of having these nice error strings, let's make them available. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--block/blk-core.c13
-rw-r--r--include/linux/blkdev.h1
2 files changed, 10 insertions, 4 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 9bfaee050c82..60a1a2907abf 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -210,18 +210,23 @@ int blk_status_to_errno(blk_status_t status)
}
EXPORT_SYMBOL_GPL(blk_status_to_errno);
-static void print_req_error(struct request *req, blk_status_t status,
- const char *caller)
+const char *blk_status_to_str(blk_status_t status)
{
int idx = (__force int)status;
if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
- return;
+ return "(invalid error)";
+ return blk_errors[idx].name;
+}
+EXPORT_SYMBOL_GPL(blk_status_to_str);
+static void print_req_error(struct request *req, blk_status_t status,
+ const char *caller)
+{
printk_ratelimited(KERN_ERR
"%s: %s error, dev %s, sector %llu op 0x%x:(%s) flags 0x%x "
"phys_seg %u prio class %u\n",
- caller, blk_errors[idx].name,
+ caller, blk_status_to_str(status),
req->rq_disk ? req->rq_disk->disk_name : "?",
blk_rq_pos(req), req_op(req), blk_op_str(req_op(req)),
req->cmd_flags & ~REQ_OP_MASK,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 32868fbedc9e..2979f9082a98 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -889,6 +889,7 @@ extern const char *blk_op_str(unsigned int op);
int blk_status_to_errno(blk_status_t status);
blk_status_t errno_to_blk_status(int errno);
+const char *blk_status_to_str(blk_status_t status);
int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin);