qapi.c (caa9cbd566877b34e9abcc04d936116fc5e0ab28) qapi.c (52eb76f4b1ac040208275665b03da1fbee99c539)
1/*
2 * Block layer qmp and info dump related functions
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 519 unchanged lines hidden (view full) ---

528static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
529{
530 BlockAcctStats *stats = blk_get_stats(blk);
531 BlockAcctTimedStats *ts = NULL;
532 BlockLatencyHistogram *hgram;
533
534 ds->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ];
535 ds->wr_bytes = stats->nr_bytes[BLOCK_ACCT_WRITE];
1/*
2 * Block layer qmp and info dump related functions
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 519 unchanged lines hidden (view full) ---

528static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
529{
530 BlockAcctStats *stats = blk_get_stats(blk);
531 BlockAcctTimedStats *ts = NULL;
532 BlockLatencyHistogram *hgram;
533
534 ds->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ];
535 ds->wr_bytes = stats->nr_bytes[BLOCK_ACCT_WRITE];
536 ds->zone_append_bytes = stats->nr_bytes[BLOCK_ACCT_ZONE_APPEND];
536 ds->unmap_bytes = stats->nr_bytes[BLOCK_ACCT_UNMAP];
537 ds->rd_operations = stats->nr_ops[BLOCK_ACCT_READ];
538 ds->wr_operations = stats->nr_ops[BLOCK_ACCT_WRITE];
537 ds->unmap_bytes = stats->nr_bytes[BLOCK_ACCT_UNMAP];
538 ds->rd_operations = stats->nr_ops[BLOCK_ACCT_READ];
539 ds->wr_operations = stats->nr_ops[BLOCK_ACCT_WRITE];
540 ds->zone_append_operations = stats->nr_ops[BLOCK_ACCT_ZONE_APPEND];
539 ds->unmap_operations = stats->nr_ops[BLOCK_ACCT_UNMAP];
540
541 ds->failed_rd_operations = stats->failed_ops[BLOCK_ACCT_READ];
542 ds->failed_wr_operations = stats->failed_ops[BLOCK_ACCT_WRITE];
541 ds->unmap_operations = stats->nr_ops[BLOCK_ACCT_UNMAP];
542
543 ds->failed_rd_operations = stats->failed_ops[BLOCK_ACCT_READ];
544 ds->failed_wr_operations = stats->failed_ops[BLOCK_ACCT_WRITE];
545 ds->failed_zone_append_operations =
546 stats->failed_ops[BLOCK_ACCT_ZONE_APPEND];
543 ds->failed_flush_operations = stats->failed_ops[BLOCK_ACCT_FLUSH];
544 ds->failed_unmap_operations = stats->failed_ops[BLOCK_ACCT_UNMAP];
545
546 ds->invalid_rd_operations = stats->invalid_ops[BLOCK_ACCT_READ];
547 ds->invalid_wr_operations = stats->invalid_ops[BLOCK_ACCT_WRITE];
547 ds->failed_flush_operations = stats->failed_ops[BLOCK_ACCT_FLUSH];
548 ds->failed_unmap_operations = stats->failed_ops[BLOCK_ACCT_UNMAP];
549
550 ds->invalid_rd_operations = stats->invalid_ops[BLOCK_ACCT_READ];
551 ds->invalid_wr_operations = stats->invalid_ops[BLOCK_ACCT_WRITE];
552 ds->invalid_zone_append_operations =
553 stats->invalid_ops[BLOCK_ACCT_ZONE_APPEND];
548 ds->invalid_flush_operations =
549 stats->invalid_ops[BLOCK_ACCT_FLUSH];
550 ds->invalid_unmap_operations = stats->invalid_ops[BLOCK_ACCT_UNMAP];
551
552 ds->rd_merged = stats->merged[BLOCK_ACCT_READ];
553 ds->wr_merged = stats->merged[BLOCK_ACCT_WRITE];
554 ds->invalid_flush_operations =
555 stats->invalid_ops[BLOCK_ACCT_FLUSH];
556 ds->invalid_unmap_operations = stats->invalid_ops[BLOCK_ACCT_UNMAP];
557
558 ds->rd_merged = stats->merged[BLOCK_ACCT_READ];
559 ds->wr_merged = stats->merged[BLOCK_ACCT_WRITE];
560 ds->zone_append_merged = stats->merged[BLOCK_ACCT_ZONE_APPEND];
554 ds->unmap_merged = stats->merged[BLOCK_ACCT_UNMAP];
555 ds->flush_operations = stats->nr_ops[BLOCK_ACCT_FLUSH];
556 ds->wr_total_time_ns = stats->total_time_ns[BLOCK_ACCT_WRITE];
561 ds->unmap_merged = stats->merged[BLOCK_ACCT_UNMAP];
562 ds->flush_operations = stats->nr_ops[BLOCK_ACCT_FLUSH];
563 ds->wr_total_time_ns = stats->total_time_ns[BLOCK_ACCT_WRITE];
564 ds->zone_append_total_time_ns =
565 stats->total_time_ns[BLOCK_ACCT_ZONE_APPEND];
557 ds->rd_total_time_ns = stats->total_time_ns[BLOCK_ACCT_READ];
558 ds->flush_total_time_ns = stats->total_time_ns[BLOCK_ACCT_FLUSH];
559 ds->unmap_total_time_ns = stats->total_time_ns[BLOCK_ACCT_UNMAP];
560
561 ds->has_idle_time_ns = stats->last_access_time_ns > 0;
562 if (ds->has_idle_time_ns) {
563 ds->idle_time_ns = block_acct_idle_time_ns(stats);
564 }
565
566 ds->account_invalid = stats->account_invalid;
567 ds->account_failed = stats->account_failed;
568
569 while ((ts = block_acct_interval_next(stats, ts))) {
570 BlockDeviceTimedStats *dev_stats = g_malloc0(sizeof(*dev_stats));
571
572 TimedAverage *rd = &ts->latency[BLOCK_ACCT_READ];
573 TimedAverage *wr = &ts->latency[BLOCK_ACCT_WRITE];
566 ds->rd_total_time_ns = stats->total_time_ns[BLOCK_ACCT_READ];
567 ds->flush_total_time_ns = stats->total_time_ns[BLOCK_ACCT_FLUSH];
568 ds->unmap_total_time_ns = stats->total_time_ns[BLOCK_ACCT_UNMAP];
569
570 ds->has_idle_time_ns = stats->last_access_time_ns > 0;
571 if (ds->has_idle_time_ns) {
572 ds->idle_time_ns = block_acct_idle_time_ns(stats);
573 }
574
575 ds->account_invalid = stats->account_invalid;
576 ds->account_failed = stats->account_failed;
577
578 while ((ts = block_acct_interval_next(stats, ts))) {
579 BlockDeviceTimedStats *dev_stats = g_malloc0(sizeof(*dev_stats));
580
581 TimedAverage *rd = &ts->latency[BLOCK_ACCT_READ];
582 TimedAverage *wr = &ts->latency[BLOCK_ACCT_WRITE];
583 TimedAverage *zap = &ts->latency[BLOCK_ACCT_ZONE_APPEND];
574 TimedAverage *fl = &ts->latency[BLOCK_ACCT_FLUSH];
575
576 dev_stats->interval_length = ts->interval_length;
577
578 dev_stats->min_rd_latency_ns = timed_average_min(rd);
579 dev_stats->max_rd_latency_ns = timed_average_max(rd);
580 dev_stats->avg_rd_latency_ns = timed_average_avg(rd);
581
582 dev_stats->min_wr_latency_ns = timed_average_min(wr);
583 dev_stats->max_wr_latency_ns = timed_average_max(wr);
584 dev_stats->avg_wr_latency_ns = timed_average_avg(wr);
585
584 TimedAverage *fl = &ts->latency[BLOCK_ACCT_FLUSH];
585
586 dev_stats->interval_length = ts->interval_length;
587
588 dev_stats->min_rd_latency_ns = timed_average_min(rd);
589 dev_stats->max_rd_latency_ns = timed_average_max(rd);
590 dev_stats->avg_rd_latency_ns = timed_average_avg(rd);
591
592 dev_stats->min_wr_latency_ns = timed_average_min(wr);
593 dev_stats->max_wr_latency_ns = timed_average_max(wr);
594 dev_stats->avg_wr_latency_ns = timed_average_avg(wr);
595
596 dev_stats->min_zone_append_latency_ns = timed_average_min(zap);
597 dev_stats->max_zone_append_latency_ns = timed_average_max(zap);
598 dev_stats->avg_zone_append_latency_ns = timed_average_avg(zap);
599
586 dev_stats->min_flush_latency_ns = timed_average_min(fl);
587 dev_stats->max_flush_latency_ns = timed_average_max(fl);
588 dev_stats->avg_flush_latency_ns = timed_average_avg(fl);
589
590 dev_stats->avg_rd_queue_depth =
591 block_acct_queue_depth(ts, BLOCK_ACCT_READ);
592 dev_stats->avg_wr_queue_depth =
593 block_acct_queue_depth(ts, BLOCK_ACCT_WRITE);
600 dev_stats->min_flush_latency_ns = timed_average_min(fl);
601 dev_stats->max_flush_latency_ns = timed_average_max(fl);
602 dev_stats->avg_flush_latency_ns = timed_average_avg(fl);
603
604 dev_stats->avg_rd_queue_depth =
605 block_acct_queue_depth(ts, BLOCK_ACCT_READ);
606 dev_stats->avg_wr_queue_depth =
607 block_acct_queue_depth(ts, BLOCK_ACCT_WRITE);
608 dev_stats->avg_zone_append_queue_depth =
609 block_acct_queue_depth(ts, BLOCK_ACCT_ZONE_APPEND);
594
595 QAPI_LIST_PREPEND(ds->timed_stats, dev_stats);
596 }
597
598 hgram = stats->latency_histogram;
599 ds->rd_latency_histogram
600 = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_READ]);
601 ds->wr_latency_histogram
602 = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_WRITE]);
610
611 QAPI_LIST_PREPEND(ds->timed_stats, dev_stats);
612 }
613
614 hgram = stats->latency_histogram;
615 ds->rd_latency_histogram
616 = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_READ]);
617 ds->wr_latency_histogram
618 = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_WRITE]);
619 ds->zone_append_latency_histogram
620 = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_ZONE_APPEND]);
603 ds->flush_latency_histogram
604 = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_FLUSH]);
605}
606
607static BlockStats * GRAPH_RDLOCK
608bdrv_query_bds_stats(BlockDriverState *bs, bool blk_level)
609{
610 BdrvChild *parent_child;

--- 421 unchanged lines hidden ---
621 ds->flush_latency_histogram
622 = bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_FLUSH]);
623}
624
625static BlockStats * GRAPH_RDLOCK
626bdrv_query_bds_stats(BlockDriverState *bs, bool blk_level)
627{
628 BdrvChild *parent_child;

--- 421 unchanged lines hidden ---