From: Alan D. Brunelle Date: Wed, 11 Feb 2009 21:16:12 +0000 (-0500) Subject: Moved starting of tracing after tracers are going X-Git-Tag: blktrace-1.0.1~26 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=3b552a2d1ff8ecccbbb82668f73d1cb134fca1e9;p=blktrace.git Moved starting of tracing after tracers are going Hold off BLKTRACESTART to threads are ready to consume tracers. --- diff --git a/blktrace.c b/blktrace.c index 00ce045..d27ab05 100644 --- a/blktrace.c +++ b/blktrace.c @@ -933,19 +933,29 @@ static void setup_buts(void) if (ioctl(dpp->fd, BLKTRACESETUP, &buts) < 0) { fprintf(stderr, "BLKTRACESETUP(2) %s failed: %d/%s\n", dpp->path, errno, strerror(errno)); - continue; - } else if (ioctl(dpp->fd, BLKTRACESTART) < 0) { + } + else { + dpp->ncpus = ncpus; + dpp->buts_name = strdup(buts.name); + if (dpp->stats) + free(dpp->stats); + dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats)); + memset(dpp->stats, 0, dpp->ncpus * sizeof(*dpp->stats)); + } + } +} + +static void start_buts(void) +{ + struct list_head *p; + + __list_for_each(p, &devpaths) { + struct devpath *dpp = list_entry(p, struct devpath, head); + + if (ioctl(dpp->fd, BLKTRACESTART) < 0) { fprintf(stderr, "BLKTRACESTART %s failed: %d/%s\n", dpp->path, errno, strerror(errno)); - continue; } - - dpp->ncpus = ncpus; - dpp->buts_name = strdup(buts.name); - if (dpp->stats) - free(dpp->stats); - dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats)); - memset(dpp->stats, 0, dpp->ncpus * sizeof(*dpp->stats)); } } @@ -2557,6 +2567,8 @@ int main(int argc, char *argv[]) pthread_cond_broadcast(&ub_cond); pthread_mutex_unlock(&ub_mutex); + start_buts(); + if (net_mode == Net_client) printf("blktrace: connected!\n");