Moved starting of tracing after tracers are going
authorAlan D. Brunelle <alan.brunelle@hp.com>
Wed, 11 Feb 2009 21:16:12 +0000 (16:16 -0500)
committerAlan D. Brunelle <alan.brunelle@hp.com>
Wed, 11 Feb 2009 21:16:12 +0000 (16:16 -0500)
Hold off BLKTRACESTART to threads are ready to consume tracers.

blktrace.c

index 00ce0459f3ecdbbb2d708d9b7020223b485f1538..d27ab0578c3aa170157eaf6ab84cc85d161c5a98 100644 (file)
@@ -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");