[2/2] block: add more debug data to print_req_err
diff mbox series

Message ID 20190611200210.4819-3-chaitanya.kulkarni@wdc.com
State New
Headers show
Series
  • block: improve print_req_error()
Related show

Commit Message

Chaitanya Kulkarni June 11, 2019, 8:02 p.m. UTC
This patch adds more debug data on the top of the existing
print_req_error() where we enhance the print message with the printing
request operations in string format and other request fields.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 block/blk-core.c | 57 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 3 deletions(-)

Comments

Bart Van Assche June 12, 2019, 3:21 p.m. UTC | #1
On 6/11/19 1:02 PM, Chaitanya Kulkarni wrote:
> +static inline const char *req_op_str(struct request *req)
> +{
> +       char *ret;
> +
> +       switch (req_op(req)) {
> +       case REQ_OP_READ:
> +               ret = "read";
> +               break;
> +       case REQ_OP_WRITE:
> +               ret = "write";
> +               break;
> +       case REQ_OP_FLUSH:
> +               ret = "flush";
> +               break;
> +       case REQ_OP_DISCARD:
> +               ret = "discard";
> +               break;
> +       case REQ_OP_SECURE_ERASE:
> +               ret = "secure_erase";
> +               break;
> +       case REQ_OP_ZONE_RESET:
> +               ret = "zone_reset";
> +               break;
> +       case REQ_OP_WRITE_SAME:
> +               ret = "write_same";
> +               break;
> +       case REQ_OP_WRITE_ZEROES:
> +               ret = "write_zeroes";
> +               break;
> +       case REQ_OP_SCSI_IN:
> +               ret = "scsi_in";
> +               break;
> +       case REQ_OP_SCSI_OUT:
> +               ret = "scsi_out";
> +               break;
> +       case REQ_OP_DRV_IN:
> +               ret = "drv_in";
> +               break;
> +       case REQ_OP_DRV_OUT:
> +               ret = "drv_out";
> +               break;
> +       default:
> +               ret = "unknown";
> +       }
> +
> +       return ret;
> +}
Please use an array instead of a switch/case statement to do this 
conversion. See also blk-mq-debugfs.c for examples.

Please also make show_bio_op(op) in include/trace/events/f2fs.h call the 
above function.

Thanks,

Bart.
Chaitanya Kulkarni June 12, 2019, 4:19 p.m. UTC | #2
Thanks for for the review, I'll send out the V2.

On 6/12/19 8:22 AM, Bart Van Assche wrote:
> On 6/11/19 1:02 PM, Chaitanya Kulkarni wrote:
>> +static inline const char *req_op_str(struct request *req)
>> +{
>> +       char *ret;
>> +
>> +       switch (req_op(req)) {
>> +       case REQ_OP_READ:
>> +               ret = "read";
>> +               break;
>> +       case REQ_OP_WRITE:
>> +               ret = "write";
>> +               break;
>> +       case REQ_OP_FLUSH:
>> +               ret = "flush";
>> +               break;
>> +       case REQ_OP_DISCARD:
>> +               ret = "discard";
>> +               break;
>> +       case REQ_OP_SECURE_ERASE:
>> +               ret = "secure_erase";
>> +               break;
>> +       case REQ_OP_ZONE_RESET:
>> +               ret = "zone_reset";
>> +               break;
>> +       case REQ_OP_WRITE_SAME:
>> +               ret = "write_same";
>> +               break;
>> +       case REQ_OP_WRITE_ZEROES:
>> +               ret = "write_zeroes";
>> +               break;
>> +       case REQ_OP_SCSI_IN:
>> +               ret = "scsi_in";
>> +               break;
>> +       case REQ_OP_SCSI_OUT:
>> +               ret = "scsi_out";
>> +               break;
>> +       case REQ_OP_DRV_IN:
>> +               ret = "drv_in";
>> +               break;
>> +       case REQ_OP_DRV_OUT:
>> +               ret = "drv_out";
>> +               break;
>> +       default:
>> +               ret = "unknown";
>> +       }
>> +
>> +       return ret;
>> +}
> Please use an array instead of a switch/case statement to do this 
> conversion. See also blk-mq-debugfs.c for examples.
>
> Please also make show_bio_op(op) in include/trace/events/f2fs.h call the 
> above function.
>
> Thanks,
>
> Bart.
>

Patch
diff mbox series

diff --git a/block/blk-core.c b/block/blk-core.c
index d1a227cfb72e..659e5ea6f6c9 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -167,6 +167,54 @@  int blk_status_to_errno(blk_status_t status)
 }
 EXPORT_SYMBOL_GPL(blk_status_to_errno);
 
+static inline const char *req_op_str(struct request *req)
+{
+       char *ret;
+
+       switch (req_op(req)) {
+       case REQ_OP_READ:
+               ret = "read";
+               break;
+       case REQ_OP_WRITE:
+               ret = "write";
+               break;
+       case REQ_OP_FLUSH:
+               ret = "flush";
+               break;
+       case REQ_OP_DISCARD:
+               ret = "discard";
+               break;
+       case REQ_OP_SECURE_ERASE:
+               ret = "secure_erase";
+               break;
+       case REQ_OP_ZONE_RESET:
+               ret = "zone_reset";
+               break;
+       case REQ_OP_WRITE_SAME:
+               ret = "write_same";
+               break;
+       case REQ_OP_WRITE_ZEROES:
+               ret = "write_zeroes";
+               break;
+       case REQ_OP_SCSI_IN:
+               ret = "scsi_in";
+               break;
+       case REQ_OP_SCSI_OUT:
+               ret = "scsi_out";
+               break;
+       case REQ_OP_DRV_IN:
+               ret = "drv_in";
+               break;
+       case REQ_OP_DRV_OUT:
+               ret = "drv_out";
+               break;
+       default:
+               ret = "unknown";
+       }
+
+       return ret;
+}
+
 static void print_req_error(struct request *req, blk_status_t status,
 		const char *caller)
 {
@@ -176,11 +224,14 @@  static void print_req_error(struct request *req, blk_status_t status,
 		return;
 
 	printk_ratelimited(KERN_ERR
-		"%s: %s error, dev %s, sector %llu op 0x%x flags 0x%x\n",
+		"%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,
 		req->rq_disk ?  req->rq_disk->disk_name : "?",
-		blk_rq_pos(req), req_op(req),
-		req->cmd_flags & ~REQ_OP_MASK);
+		blk_rq_pos(req), req_op(req), req_op_str(req),
+		req->cmd_flags & ~REQ_OP_MASK,
+		req->nr_phys_segments,
+		IOPRIO_PRIO_CLASS(req->ioprio));
 }
 
 static void req_bio_endio(struct request *rq, struct bio *bio,