static struct dstat *dstat_list[2] = {};
static int dstat_curr = 0;
-static struct output human, binary, debug;
+static struct output drvdata, human, binary, debug;
static char *msg_q_name = NULL;
static int msg_q_id = -1, msg_q = -1;
return t_old;
}
+static int blkiomon_dump_drvdata(struct blk_io_trace *bit, void *pdu_buf)
+{
+ if (!drvdata.fn)
+ return 0;
+
+ if (fwrite(bit, sizeof(*bit), 1, drvdata.fp) != 1)
+ goto failed;
+ if (fwrite(pdu_buf, bit->pdu_len, 1, drvdata.fp) != 1)
+ goto failed;
+ if (drvdata.pipe && fflush(drvdata.fp))
+ goto failed;
+ return 0;
+
+failed:
+ fprintf(stderr, "blkiomon: could not write to %s\n", drvdata.fn);
+ fclose(drvdata.fp);
+ drvdata.fn = NULL;
+ return 1;
+}
+
static int blkiomon_do_fifo(void)
{
struct trace *t;
t->sequence = sequence++;
+ /* forward low-level device driver trace to other tool */
+ if (bit->action & BLK_TC_ACT(BLK_TC_DRV_DATA)) {
+ driverdata++;
+ if (blkiomon_dump_drvdata(bit, pdu_buf))
+ break;
+ continue;
+ }
+
if (!(bit->action & BLK_TC_ACT(BLK_TC_ISSUE | BLK_TC_COMPLETE)))
continue;
leftover, match, mismatch, driverdata, sequence);
}
-#define S_OPTS "b:D:h:I:Q:q:m:V"
+#define S_OPTS "b:d:D:h:I:Q:q:m:V"
static char usage_str[] = "\n\nblkiomon " \
"-I <interval> | --interval=<interval>\n" \
"\t-I Sample interval.\n" \
"\t-h Human-readable output file.\n" \
"\t-b Binary output file.\n" \
+ "\t-d Output file for data emitted by low level device driver.\n" \
"\t-D Output file for debugging data.\n" \
"\t-Qqm Output to message queue using given ID for messages.\n" \
"\t-V Print program version.\n\n";
.flag = NULL,
.val = 'b'
},
+ {
+ .name = "dump-lldd",
+ .has_arg = required_argument,
+ .flag = NULL,
+ .val = 'd'
+ },
{
.name = "debug",
.has_arg = required_argument,
case 'b':
binary.fn = optarg;
break;
+ case 'd':
+ drvdata.fn = optarg;
+ break;
case 'D':
debug.fn = optarg;
break;
return 1;
if (blkiomon_open_output(&binary))
return 1;
+ if (blkiomon_open_output(&drvdata))
+ return 1;
if (blkiomon_open_output(&debug))
return 1;
if (blkiomon_open_msg_q())