From: Kent Overstreet <kent.overstreet@gmail.com>
To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
axboe@kernel.dk
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Subject: [PATCH 2/2] block: Add blk_status_to_str()
Date: Mon, 19 Oct 2020 15:02:41 -0400 [thread overview]
Message-ID: <20201019190241.2910492-2-kent.overstreet@gmail.com> (raw)
In-Reply-To: <20201019190241.2910492-1-kent.overstreet@gmail.com>
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>
---
block/blk-core.c | 13 +++++++++----
include/linux/blkdev.h | 1 +
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 10c08ac506..d68f24a7ee 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -213,18 +213,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 868e11face..d9e3b7b017 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -936,6 +936,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);
--
2.28.0
next prev parent reply other threads:[~2020-10-19 19:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 19:02 [PATCH 1/2] block: Add some exports for bcachefs Kent Overstreet
2020-10-19 19:02 ` Kent Overstreet [this message]
2020-10-19 20:11 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201019190241.2910492-2-kent.overstreet@gmail.com \
--to=kent.overstreet@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®