On 6/13/19 7:16 AM, Chaitanya Kulkarni wrote:
+#define REQ_OP_NAME(name) [REQ_OP_##name] = #name +static const char *const op_name[] = { + REQ_OP_NAME(READ), + REQ_OP_NAME(WRITE), + REQ_OP_NAME(FLUSH), + REQ_OP_NAME(DISCARD), + REQ_OP_NAME(SECURE_ERASE), + REQ_OP_NAME(ZONE_RESET), + REQ_OP_NAME(WRITE_SAME), + REQ_OP_NAME(WRITE_ZEROES), + REQ_OP_NAME(SCSI_IN), + REQ_OP_NAME(SCSI_OUT), + REQ_OP_NAME(DRV_IN), + REQ_OP_NAME(DRV_OUT), +}; + +static inline const char *op_str(int op) +{ + const char *op_str = "REQ_OP_UNKNOWN"; + + if (op < ARRAY_SIZE(op_name) && op_name[op]) + op_str = op_name[op]; + + return op_str; +}
If this patch gets applied there will be three copies in the upstream code that convert a REQ_OP_* constant into a string: one in blk-core.c, one in blk-mq-debugfs.c and one in include/trace/events/f2fs.h. Is it possible to avoid that duplication and have only one function that does the number-to-string conversion?
Bart.