trace: Trace virtio-blk, multiwrite, and paio_submit
This patch adds trace events that make it possible to observe virtio-blk. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
This commit is contained in:
parent
cd245a1932
commit
6d519a5f95
8
block.c
8
block.c
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "config-host.h"
|
#include "config-host.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
#include "trace.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "block_int.h"
|
#include "block_int.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
@ -2063,6 +2064,8 @@ static void multiwrite_cb(void *opaque, int ret)
|
|||||||
{
|
{
|
||||||
MultiwriteCB *mcb = opaque;
|
MultiwriteCB *mcb = opaque;
|
||||||
|
|
||||||
|
trace_multiwrite_cb(mcb, ret);
|
||||||
|
|
||||||
if (ret < 0 && !mcb->error) {
|
if (ret < 0 && !mcb->error) {
|
||||||
mcb->error = ret;
|
mcb->error = ret;
|
||||||
}
|
}
|
||||||
@ -2203,6 +2206,8 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
|
|||||||
// Check for mergable requests
|
// Check for mergable requests
|
||||||
num_reqs = multiwrite_merge(bs, reqs, num_reqs, mcb);
|
num_reqs = multiwrite_merge(bs, reqs, num_reqs, mcb);
|
||||||
|
|
||||||
|
trace_bdrv_aio_multiwrite(mcb, mcb->num_callbacks, num_reqs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run the aio requests. As soon as one request can't be submitted
|
* Run the aio requests. As soon as one request can't be submitted
|
||||||
* successfully, fail all requests that are not yet submitted (we must
|
* successfully, fail all requests that are not yet submitted (we must
|
||||||
@ -2224,6 +2229,7 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
|
|||||||
*/
|
*/
|
||||||
mcb->num_requests = 1;
|
mcb->num_requests = 1;
|
||||||
|
|
||||||
|
// Run the aio requests
|
||||||
for (i = 0; i < num_reqs; i++) {
|
for (i = 0; i < num_reqs; i++) {
|
||||||
mcb->num_requests++;
|
mcb->num_requests++;
|
||||||
acb = bdrv_aio_writev(bs, reqs[i].sector, reqs[i].qiov,
|
acb = bdrv_aio_writev(bs, reqs[i].sector, reqs[i].qiov,
|
||||||
@ -2234,8 +2240,10 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
|
|||||||
// submitted yet. Otherwise we'll wait for the submitted AIOs to
|
// submitted yet. Otherwise we'll wait for the submitted AIOs to
|
||||||
// complete and report the error in the callback.
|
// complete and report the error in the callback.
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
trace_bdrv_aio_multiwrite_earlyfail(mcb);
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
|
trace_bdrv_aio_multiwrite_latefail(mcb, i);
|
||||||
multiwrite_cb(mcb, -EIO);
|
multiwrite_cb(mcb, -EIO);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <qemu-common.h>
|
#include <qemu-common.h>
|
||||||
#include "qemu-error.h"
|
#include "qemu-error.h"
|
||||||
|
#include "trace.h"
|
||||||
#include "blockdev.h"
|
#include "blockdev.h"
|
||||||
#include "virtio-blk.h"
|
#include "virtio-blk.h"
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -52,6 +53,8 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, int status)
|
|||||||
{
|
{
|
||||||
VirtIOBlock *s = req->dev;
|
VirtIOBlock *s = req->dev;
|
||||||
|
|
||||||
|
trace_virtio_blk_req_complete(req, status);
|
||||||
|
|
||||||
req->in->status = status;
|
req->in->status = status;
|
||||||
virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in));
|
virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in));
|
||||||
virtio_notify(&s->vdev, s->vq);
|
virtio_notify(&s->vdev, s->vq);
|
||||||
@ -88,6 +91,8 @@ static void virtio_blk_rw_complete(void *opaque, int ret)
|
|||||||
{
|
{
|
||||||
VirtIOBlockReq *req = opaque;
|
VirtIOBlockReq *req = opaque;
|
||||||
|
|
||||||
|
trace_virtio_blk_rw_complete(req, ret);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
int is_read = !(req->out->type & VIRTIO_BLK_T_OUT);
|
int is_read = !(req->out->type & VIRTIO_BLK_T_OUT);
|
||||||
if (virtio_blk_handle_rw_error(req, -ret, is_read))
|
if (virtio_blk_handle_rw_error(req, -ret, is_read))
|
||||||
@ -270,6 +275,8 @@ static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)
|
|||||||
{
|
{
|
||||||
BlockRequest *blkreq;
|
BlockRequest *blkreq;
|
||||||
|
|
||||||
|
trace_virtio_blk_handle_write(req, req->out->sector, req->qiov.size / 512);
|
||||||
|
|
||||||
if (req->out->sector & req->dev->sector_mask) {
|
if (req->out->sector & req->dev->sector_mask) {
|
||||||
virtio_blk_rw_complete(req, -EIO);
|
virtio_blk_rw_complete(req, -EIO);
|
||||||
return;
|
return;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "qemu-queue.h"
|
#include "qemu-queue.h"
|
||||||
#include "osdep.h"
|
#include "osdep.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
#include "trace.h"
|
||||||
#include "block_int.h"
|
#include "block_int.h"
|
||||||
|
|
||||||
#include "block/raw-posix-aio.h"
|
#include "block/raw-posix-aio.h"
|
||||||
@ -583,6 +584,7 @@ BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd,
|
|||||||
acb->next = posix_aio_state->first_aio;
|
acb->next = posix_aio_state->first_aio;
|
||||||
posix_aio_state->first_aio = acb;
|
posix_aio_state->first_aio = acb;
|
||||||
|
|
||||||
|
trace_paio_submit(acb, opaque, sector_num, nb_sectors, type);
|
||||||
qemu_paio_submit(acb);
|
qemu_paio_submit(acb);
|
||||||
return &acb->common;
|
return &acb->common;
|
||||||
}
|
}
|
||||||
|
14
trace-events
14
trace-events
@ -37,3 +37,17 @@ disable qemu_free(void *ptr) "ptr %p"
|
|||||||
disable qemu_memalign(size_t alignment, size_t size, void *ptr) "alignment %zu size %zu ptr %p"
|
disable qemu_memalign(size_t alignment, size_t size, void *ptr) "alignment %zu size %zu ptr %p"
|
||||||
disable qemu_valloc(size_t size, void *ptr) "size %zu ptr %p"
|
disable qemu_valloc(size_t size, void *ptr) "size %zu ptr %p"
|
||||||
disable qemu_vfree(void *ptr) "ptr %p"
|
disable qemu_vfree(void *ptr) "ptr %p"
|
||||||
|
|
||||||
|
# block.c
|
||||||
|
disable multiwrite_cb(void *mcb, int ret) "mcb %p ret %d"
|
||||||
|
disable bdrv_aio_multiwrite(void *mcb, int num_callbacks, int num_reqs) "mcb %p num_callbacks %d num_reqs %d"
|
||||||
|
disable bdrv_aio_multiwrite_earlyfail(void *mcb) "mcb %p"
|
||||||
|
disable bdrv_aio_multiwrite_latefail(void *mcb, int i) "mcb %p i %d"
|
||||||
|
|
||||||
|
# hw/virtio-blk.c
|
||||||
|
disable virtio_blk_req_complete(void *req, int status) "req %p status %d"
|
||||||
|
disable virtio_blk_rw_complete(void *req, int ret) "req %p ret %d"
|
||||||
|
disable virtio_blk_handle_write(void *req, unsigned long sector, unsigned long nsectors) "req %p sector %lu nsectors %lu"
|
||||||
|
|
||||||
|
# posix-aio-compat.c
|
||||||
|
disable paio_submit(void *acb, void *opaque, unsigned long sector_num, unsigned long nb_sectors, unsigned long type) "acb %p opaque %p sector_num %lu nb_sectors %lu type %lu"
|
||||||
|
Loading…
Reference in New Issue
Block a user