All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-block@vger.kernel.org
Cc: axboe@kernel.dk, damien.lemoal@wdc.com,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [PATCH V3 1/3] block: add a zone condition debug helper
Date: Tue, 24 Mar 2020 19:16:27 -0700	[thread overview]
Message-ID: <20200325021629.15103-2-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20200325021629.15103-1-chaitanya.kulkarni@wdc.com>

Add a helper to stringify the zone conditions. We use this helper in the
next patch to track zone conditions in tracepoints.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 block/blk-zoned.c      | 32 ++++++++++++++++++++++++++++++++
 include/linux/blkdev.h |  3 +++
 2 files changed, 35 insertions(+)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 6b442ae96499..f87956e0dcaf 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -20,6 +20,38 @@
 
 #include "blk.h"
 
+#define ZONE_COND_NAME(name) [BLK_ZONE_COND_##name] = #name
+static const char *const zone_cond_name[] = {
+	ZONE_COND_NAME(NOT_WP),
+	ZONE_COND_NAME(EMPTY),
+	ZONE_COND_NAME(IMP_OPEN),
+	ZONE_COND_NAME(EXP_OPEN),
+	ZONE_COND_NAME(CLOSED),
+	ZONE_COND_NAME(READONLY),
+	ZONE_COND_NAME(FULL),
+	ZONE_COND_NAME(OFFLINE),
+};
+#undef ZONE_COND_NAME
+
+/**
+ * blk_zone_cond_str - Return string XXX in BLK_ZONE_COND_XXX.
+ * @zone_cond: BLK_ZONE_COND_XXX.
+ *
+ * Description: Centralize block layer function to convert BLK_ZONE_COND_XXX
+ * into string format. Useful in the debugging and tracing zone conditions. For
+ * invalid BLK_ZONE_COND_XXX it returns string "UNKNOWN".
+ */
+const char *blk_zone_cond_str(enum blk_zone_cond zone_cond)
+{
+	static const char *zone_cond_str = "UNKNOWN";
+
+	if (zone_cond < ARRAY_SIZE(zone_cond_name) && zone_cond_name[zone_cond])
+		zone_cond_str = zone_cond_name[zone_cond];
+
+	return zone_cond_str;
+}
+EXPORT_SYMBOL_GPL(blk_zone_cond_str);
+
 static inline sector_t blk_zone_start(struct request_queue *q,
 				      sector_t sector)
 {
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 53a1325efbc3..0070f26b9579 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -887,6 +887,9 @@ extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
 /* Helper to convert REQ_OP_XXX to its string format XXX */
 extern const char *blk_op_str(unsigned int op);
 
+/* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
+extern const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
+
 int blk_status_to_errno(blk_status_t status);
 blk_status_t errno_to_blk_status(int errno);
 
-- 
2.22.0


  reply	other threads:[~2020-03-25  3:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25  2:16 [PATCH V3 0/3] null_blk: add tracepoints for zoned mode Chaitanya Kulkarni
2020-03-25  2:16 ` Chaitanya Kulkarni [this message]
2020-03-25  3:27   ` [PATCH V3 1/3] block: add a zone condition debug helper Damien Le Moal
2020-03-25  4:31     ` Chaitanya Kulkarni
2020-03-25  5:20       ` Damien Le Moal
2020-03-25  2:16 ` [PATCH V3 2/3] null_blk: add tracepoint helpers for zoned mode Chaitanya Kulkarni
2020-03-25  3:28   ` Damien Le Moal
2020-03-25  2:16 ` [PATCH V3 3/3] null_blk: add trace in null_blk_zoned.c Chaitanya Kulkarni
2020-03-27  3:12 ` [PATCH V3 0/3] null_blk: add tracepoints for zoned mode Chaitanya Kulkarni
2020-03-27 15:35   ` Jens Axboe
2020-03-27 16:05     ` Damien Le Moal
2020-03-27 16:25       ` Jens Axboe
2020-03-27 19:35     ` Chaitanya Kulkarni
2020-03-27 19:39       ` 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=20200325021629.15103-2-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=linux-block@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.