Home | History | Annotate | Download | only in blktrace

Lines Matching defs:iop

1439 static int net_sendfile(struct io_info *iop)
1443 ret = sendfile(iop->ofd, iop->ifd, NULL, iop->ready);
1447 } else if (ret < (int)iop->ready) {
1449 ret, iop->ready);
1456 static inline int net_sendfile_data(struct tracer *tp, struct io_info *iop)
1458 struct devpath *dpp = iop->dpp;
1460 if (net_send_header(iop->ofd, tp->cpu, dpp->buts_name, iop->ready))
1462 return net_sendfile(iop);
1465 static int fill_ofname(struct io_info *iop, int cpu)
1469 char *dst = iop->ofn;
1472 len = snprintf(iop->ofn, sizeof(iop->ofn), "%s/", output_dir);
1474 len = snprintf(iop->ofn, sizeof(iop->ofn), "./");
1477 struct cl_conn *nc = iop->nc;
1481 gmtime(&iop->dpp->cl_connect_time));
1484 if (stat(iop->ofn, &sb) < 0) {
1488 iop->ofn, errno, strerror(errno));
1496 if (mkdir(iop->ofn, 0755) < 0 && errno != EEXIST) {
1499 iop->ofn, errno, strerror(errno));
1505 snprintf(iop->ofn + len, sizeof(iop->ofn), "%s.blktrace.%d",
1508 snprintf(iop->ofn + len, sizeof(iop->ofn), "%s.blktrace.%d",
1509 iop->dpp->buts_name, cpu);
1514 static int set_vbuf(struct io_info *iop, int mode, size_t size)
1516 iop->obuf = malloc(size);
1517 if (setvbuf(iop->ofp, iop->obuf, mode, size) < 0) {
1519 iop->dpp->path, (int)size, errno,
1521 free(iop->obuf);
1528 static int iop_open(struct io_info *iop, int cpu)
1530 iop->ofd = -1;
1531 if (fill_ofname(iop, cpu))
1534 iop->ofp = my_fopen(iop->ofn, "w+");
1535 if (iop->ofp == NULL) {
1537 iop->ofn, errno, strerror(errno));
1541 if (set_vbuf(iop, _IOLBF, FILE_VBUF_SIZE)) {
1543 iop->ofn, errno, strerror(errno));
1544 fclose(iop->ofp);
1548 iop->ofd = fileno(iop->ofp);
1552 static void close_iop(struct io_info *iop)
1554 struct mmap_info *mip = &iop->mmap_info;
1560 if (ftruncate(fileno(iop->ofp), mip->fs_size) < 0) {
1563 iop->ofn, errno, strerror(errno));
1567 if (iop->ofp)
1568 fclose(iop->ofp);
1569 if (iop->obuf)
1570 free(iop->obuf);
1576 struct io_info *iop = &tp->ios[--tp->nios];
1578 iop->dpp->drops = get_drops(iop->dpp);
1579 if (iop->ifd >= 0)
1580 close(iop->ifd);
1582 if (iop->ofp)
1583 close_iop(iop);
1584 else if (iop->ofd >= 0) {
1585 struct devpath *dpp = iop->dpp;
1587 net_send_close(iop->ofd, dpp->buts_name, dpp->drops);
1588 net_close_connection(&iop->ofd);
1599 struct io_info *iop;
1609 iop = tp->ios;
1614 iop->dpp = dpp;
1615 iop->ofd = -1;
1616 snprintf(iop->ifn, sizeof(iop->ifn), "%s/block/%s/trace%d",
1619 iop->ifd = my_open(iop->ifn, O_RDONLY | O_NONBLOCK);
1620 if (iop->ifd < 0) {
1622 tp->cpu, iop->ifn, errno, strerror(errno));
1626 init_mmap_info(&iop->mmap_info);
1628 pfd->fd = iop->ifd;
1634 iop->ofd = net_setup_client();
1635 if (iop->ofd < 0)
1637 net_send_open(iop->ofd, tp->cpu, dpp->buts_name);
1639 if (iop_open(iop, tp->cpu))
1650 iop++;
1657 close(iop->ifd); /* tp->nios _not_ bumped */
1667 struct io_info *iop = tp->ios;
1669 for (i = 0; nevs > 0 && i < ndevs; i++, pfd++, iop++) {
1671 mip = &iop->mmap_info;
1673 ret = setup_mmap(iop->ofd, buf_size, mip);
1679 ret = read(iop->ifd, mip->fs_buf + mip->fs_off,
1682 pdc_dr_update(iop->dpp, tp->cpu, ret);
1694 read_err(tp->cpu, iop->ifn);
1711 struct io_info *iop = tp->ios;
1713 for (i = 0; i < ndevs; i++, pfd++, iop++, sp++) {
1715 if (fstat(iop->ifd, &sb) < 0) {
1716 perror(iop->ifn);
1718 } else if (sb.st_size > (off_t)iop->data_queued) {
1719 iop->ready = sb.st_size - iop->data_queued;
1720 iop->data_queued = sb.st_size;
1722 if (!net_sendfile_data(tp, iop)) {
1723 pdc_dr_update(iop->dpp, tp->cpu,
1724 iop->ready);
1745 struct io_info *iop = tp->ios;
1748 for (i = 0; i < ndevs; i++, pfd++, iop++) {
1750 tbp->len = read(iop->ifd, tbp->buf, buf_size);
1752 pdc_dr_update(iop->dpp, tp->cpu, tbp->len);
1753 add_trace_buf(iop->dpp, tp->cpu, &tbp);
1763 read_err(tp->cpu, iop->ifn);
2241 struct io_info *iop;
2243 for (cpu = 0, iop = dpp->ios; cpu < ncpus; cpu++, iop++)
2244 close_iop(iop);
2301 struct io_info *iop;
2320 dpp->ios = calloc(nc->ncpus, sizeof(*iop));
2321 memset(dpp->ios, 0, ndevs * sizeof(*iop));
2323 for (cpu = 0, iop = dpp->ios; cpu < nc->ncpus; cpu++, iop++) {
2324 iop->dpp = dpp;
2325 iop->nc = nc;
2326 init_mmap_info(&iop->mmap_info);
2328 if (iop_open(iop, cpu))
2368 struct io_info *iop = &dpp->ios[bnh->cpu];
2369 struct mmap_info *mip = &iop->mmap_info;
2371 if (setup_mmap(iop->ofd, bnh->len, &iop->mmap_info)) {