diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-06-11 16:06:46 +0200 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-06-12 10:40:35 -0600 |
| commit | d39a63ead381c7ee93cd938ea2d759c17343b522 (patch) | |
| tree | 2f8f773e3c73e531a7958f21776acd61fe02711c | |
| parent | ce351560b714403acfdeed86ef96675d229da837 (diff) | |
block: add a str_to_blk_op helper
Add a helper to find the REQ_OP_XYZ constant from the "XYZ" string.
This will be used for the error injection debugfs interface.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Md Haris Iqbal <haris.iqbal@linux.dev>
Link: https://patch.msgid.link/20260611140703.2401204-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
| -rw-r--r-- | block/blk-core.c | 10 | ||||
| -rw-r--r-- | block/blk.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 842b5c6f2fb4..beaab7a71fba 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -132,6 +132,16 @@ inline const char *blk_op_str(enum req_op op) } EXPORT_SYMBOL_GPL(blk_op_str); +enum req_op str_to_blk_op(const char *op) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(blk_op_name); i++) + if (blk_op_name[i] && !strcmp(blk_op_name[i], op)) + return (enum req_op)i; + return REQ_OP_LAST; +} + #define ENT(_tag, _errno, _desc) \ [BLK_STS_##_tag] = { \ .errno = _errno, \ diff --git a/block/blk.h b/block/blk.h index 3ab2cdd6ed12..507ab34a6e90 100644 --- a/block/blk.h +++ b/block/blk.h @@ -53,6 +53,7 @@ void blk_free_flush_queue(struct blk_flush_queue *q); const char *blk_status_to_str(blk_status_t status); const char *blk_status_to_tag(blk_status_t status); blk_status_t tag_to_blk_status(const char *tag); +enum req_op str_to_blk_op(const char *op); bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic); bool blk_queue_start_drain(struct request_queue *q); |
