Skip to content

Commit d39a63e

Browse files
Christoph Hellwigaxboe
authored andcommitted
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>
1 parent ce35156 commit d39a63e

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

block/blk-core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ inline const char *blk_op_str(enum req_op op)
132132
}
133133
EXPORT_SYMBOL_GPL(blk_op_str);
134134

135+
enum req_op str_to_blk_op(const char *op)
136+
{
137+
int i;
138+
139+
for (i = 0; i < ARRAY_SIZE(blk_op_name); i++)
140+
if (blk_op_name[i] && !strcmp(blk_op_name[i], op))
141+
return (enum req_op)i;
142+
return REQ_OP_LAST;
143+
}
144+
135145
#define ENT(_tag, _errno, _desc) \
136146
[BLK_STS_##_tag] = { \
137147
.errno = _errno, \

block/blk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void blk_free_flush_queue(struct blk_flush_queue *q);
5353
const char *blk_status_to_str(blk_status_t status);
5454
const char *blk_status_to_tag(blk_status_t status);
5555
blk_status_t tag_to_blk_status(const char *tag);
56+
enum req_op str_to_blk_op(const char *op);
5657

5758
bool __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic);
5859
bool blk_queue_start_drain(struct request_queue *q);

0 commit comments

Comments
 (0)