block: cleanup tracing
authorChristoph Hellwig <hch@lst.de>
Fri, 27 Jan 2017 08:35:54 +0000 (09:35 +0100)
committerJens Axboe <axboe@fb.com>
Fri, 27 Jan 2017 22:08:35 +0000 (15:08 -0700)
A couple tweaks to the tracing code:

 - trace the request size for all requests
 - trace request sector and nr_sectors only for fs requests, enforced by
   helpers
 - drop SCSI CDB tracing - we have SCSI tracing for this and are going
   to me the CDB out of the generic struct request soon.

With this the tracing code stops to know about BLOCK_PC requests entirely,
it's just FS vs passthrough requests now, where the latter includes any
driver-private requests.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
include/linux/blktrace_api.h
include/trace/events/block.h
kernel/trace/blktrace.c

index e417f080219a68a90e2b0f795dc8e47c002cc58a..a143a67a6f331736d1ac8aafb61e82095d525f48 100644 (file)
@@ -110,16 +110,16 @@ struct compat_blk_user_trace_setup {
 
 #endif
 
-#if defined(CONFIG_EVENT_TRACING) && defined(CONFIG_BLOCK)
+extern void blk_fill_rwbs(char *rwbs, unsigned int op, int bytes);
 
-static inline int blk_cmd_buf_len(struct request *rq)
+static inline sector_t blk_rq_trace_sector(struct request *rq)
 {
-       return (rq->cmd_type == REQ_TYPE_BLOCK_PC) ? rq->cmd_len * 3 : 1;
+       return (rq->cmd_type != REQ_TYPE_FS) ? 0 : blk_rq_pos(rq);
 }
 
-extern void blk_dump_cmd(char *buf, struct request *rq);
-extern void blk_fill_rwbs(char *rwbs, unsigned int op, int bytes);
-
-#endif /* CONFIG_EVENT_TRACING && CONFIG_BLOCK */
+static inline unsigned int blk_rq_trace_nr_sectors(struct request *rq)
+{
+       return (rq->cmd_type != REQ_TYPE_FS) ? 0 : blk_rq_sectors(rq);
+}
 
 #endif
index 3e02e3a2541373748ebc9a55f76f707c7f322349..a88ed13446ff88e200ed642db63badf4c9a4b680 100644 (file)
@@ -73,19 +73,17 @@ DECLARE_EVENT_CLASS(block_rq_with_error,
                __field(  unsigned int, nr_sector               )
                __field(  int,          errors                  )
                __array(  char,         rwbs,   RWBS_LEN        )
-               __dynamic_array( char,  cmd,    blk_cmd_buf_len(rq)     )
+               __dynamic_array( char,  cmd,    1               )
        ),
 
        TP_fast_assign(
                __entry->dev       = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
-               __entry->sector    = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
-                                       0 : blk_rq_pos(rq);
-               __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
-                                       0 : blk_rq_sectors(rq);
+               __entry->sector    = blk_rq_trace_sector(rq);
+               __entry->nr_sector = blk_rq_trace_nr_sectors(rq);
                __entry->errors    = rq->errors;
 
                blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
-               blk_dump_cmd(__get_str(cmd), rq);
+               __get_str(cmd)[0] = '\0';
        ),
 
        TP_printk("%d,%d %s (%s) %llu + %u [%d]",
@@ -153,7 +151,7 @@ TRACE_EVENT(block_rq_complete,
                __field(  unsigned int, nr_sector               )
                __field(  int,          errors                  )
                __array(  char,         rwbs,   RWBS_LEN        )
-               __dynamic_array( char,  cmd,    blk_cmd_buf_len(rq)     )
+               __dynamic_array( char,  cmd,    1               )
        ),
 
        TP_fast_assign(
@@ -163,7 +161,7 @@ TRACE_EVENT(block_rq_complete,
                __entry->errors    = rq->errors;
 
                blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, nr_bytes);
-               blk_dump_cmd(__get_str(cmd), rq);
+               __get_str(cmd)[0] = '\0';
        ),
 
        TP_printk("%d,%d %s (%s) %llu + %u [%d]",
@@ -186,20 +184,17 @@ DECLARE_EVENT_CLASS(block_rq,
                __field(  unsigned int, bytes                   )
                __array(  char,         rwbs,   RWBS_LEN        )
                __array(  char,         comm,   TASK_COMM_LEN   )
-               __dynamic_array( char,  cmd,    blk_cmd_buf_len(rq)     )
+               __dynamic_array( char,  cmd,    1               )
        ),
 
        TP_fast_assign(
                __entry->dev       = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
-               __entry->sector    = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
-                                       0 : blk_rq_pos(rq);
-               __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
-                                       0 : blk_rq_sectors(rq);
-               __entry->bytes     = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
-                                       blk_rq_bytes(rq) : 0;
+               __entry->sector    = blk_rq_trace_sector(rq);
+               __entry->nr_sector = blk_rq_trace_nr_sectors(rq);
+               __entry->bytes     = blk_rq_bytes(rq);
 
                blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
-               blk_dump_cmd(__get_str(cmd), rq);
+               __get_str(cmd)[0] = '\0';
                memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
        ),
 
index 95cecbf67f5ca0903d582b0ed45ef4b409fa3c99..512b34703ac3ac82b5b6bbf7f7bc624cc6dc21c5 100644 (file)
@@ -712,15 +712,13 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
        if (likely(!bt))
                return;
 
-       if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
+       if (rq->cmd_type != REQ_TYPE_FS)
                what |= BLK_TC_ACT(BLK_TC_PC);
-               __blk_add_trace(bt, 0, nr_bytes, req_op(rq), rq->cmd_flags,
-                               what, rq->errors, rq->cmd_len, rq->cmd);
-       } else  {
+       else
                what |= BLK_TC_ACT(BLK_TC_FS);
-               __blk_add_trace(bt, blk_rq_pos(rq), nr_bytes, req_op(rq),
-                               rq->cmd_flags, what, rq->errors, 0, NULL);
-       }
+
+       __blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes, req_op(rq),
+                       rq->cmd_flags, what, rq->errors, 0, NULL);
 }
 
 static void blk_add_trace_rq_abort(void *ignore,
@@ -972,11 +970,7 @@ void blk_add_driver_data(struct request_queue *q,
        if (likely(!bt))
                return;
 
-       if (rq->cmd_type == REQ_TYPE_BLOCK_PC)
-               __blk_add_trace(bt, 0, blk_rq_bytes(rq), 0, 0,
-                               BLK_TA_DRV_DATA, rq->errors, len, data);
-       else
-               __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), 0, 0,
+       __blk_add_trace(bt, blk_rq_trace_sector(rq), blk_rq_bytes(rq), 0, 0,
                                BLK_TA_DRV_DATA, rq->errors, len, data);
 }
 EXPORT_SYMBOL_GPL(blk_add_driver_data);
@@ -1752,31 +1746,6 @@ void blk_trace_remove_sysfs(struct device *dev)
 
 #ifdef CONFIG_EVENT_TRACING
 
-void blk_dump_cmd(char *buf, struct request *rq)
-{
-       int i, end;
-       int len = rq->cmd_len;
-       unsigned char *cmd = rq->cmd;
-
-       if (rq->cmd_type != REQ_TYPE_BLOCK_PC) {
-               buf[0] = '\0';
-               return;
-       }
-
-       for (end = len - 1; end >= 0; end--)
-               if (cmd[end])
-                       break;
-       end++;
-
-       for (i = 0; i < len; i++) {
-               buf += sprintf(buf, "%s%02x", i == 0 ? "" : " ", cmd[i]);
-               if (i == end && end != len - 1) {
-                       sprintf(buf, " ..");
-                       break;
-               }
-       }
-}
-
 void blk_fill_rwbs(char *rwbs, unsigned int op, int bytes)
 {
        int i = 0;