diff options
author | weiping zhang <zhangweiping@didichuxing.com> | 2018-01-15 23:53:42 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-01-24 08:40:52 -0700 |
commit | e63098f39398bde67be9b64a49deece1c60614df (patch) | |
tree | f120ac537bcbedc3d5b942f6d48f627145cb12af | |
parent | 519fd9a5d08d85f3d9cb4192d624fe8351e40232 (diff) | |
download | blktrace-e63098f39398bde67be9b64a49deece1c60614df.tar.gz |
blktrace: don't stop tracer if not setup trace successfully
if we run blktrace on same device twice, the second time will failed
to ioctl(BLKTRACESETUP), then it will call __stop_tracer, which lead
the first blktrace failed to access debugfs entries. So this patch add
a check to handle this case, to avoid stop tracer uncondionally.
Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | blktrace.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -112,6 +112,7 @@ struct devpath { struct cl_host *ch; u32 cl_id; time_t cl_connect_time; + int setup_done; /* ioctl BLKTRACESETUP done */ struct io_info *ios; }; @@ -1083,6 +1084,7 @@ static int setup_buts(void) if (ioctl(dpp->fd, BLKTRACESETUP, &buts) >= 0) { dpp->ncpus = max_cpus; dpp->buts_name = strdup(buts.name); + dpp->setup_done = 1; if (dpp->stats) free(dpp->stats); dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats)); @@ -1285,7 +1287,8 @@ static void rel_devpaths(void) struct devpath *dpp = list_entry(p, struct devpath, head); list_del(&dpp->head); - __stop_trace(dpp->fd); + if (dpp->setup_done) + __stop_trace(dpp->fd); close(dpp->fd); if (dpp->heads) |