Patchwork [13/13] trace: trace bdrv_aio_readv/writev error paths

login
register
mail settings
Submitter Stefan Hajnoczi
Date June 14, 2011, 6:18 p.m.
Message ID <1308075511-4745-14-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/100412/
State New
Headers show

Comments

Stefan Hajnoczi - June 14, 2011, 6:18 p.m.
It is useful to understand why an I/O request was failed.  Add trace
events for the error paths in bdrv_aio_readv() and bdrv_aio_writev().

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 block.c      |   24 +++++++++++++++++++-----
 trace-events |    7 +++++++
 2 files changed, 26 insertions(+), 5 deletions(-)

Patch

diff --git a/block.c b/block.c
index 4da35be..816edd6 100644
--- a/block.c
+++ b/block.c
@@ -2129,10 +2129,14 @@  BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,
 
     trace_bdrv_aio_readv(bs, sector_num, nb_sectors, opaque);
 
-    if (!drv)
+    if (!drv) {
+        trace_bdrv_aio_readv_null_drv(bs, sector_num, nb_sectors, opaque);
         return NULL;
-    if (bdrv_check_request(bs, sector_num, nb_sectors))
+    }
+    if (bdrv_check_request(bs, sector_num, nb_sectors)) {
+        trace_bdrv_aio_readv_out_of_range(bs, sector_num, nb_sectors, opaque);
         return NULL;
+    }
 
     ret = drv->bdrv_aio_readv(bs, sector_num, qiov, nb_sectors,
                               cb, opaque);
@@ -2141,6 +2145,8 @@  BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,
 	/* Update stats even though technically transfer has not happened. */
 	bs->rd_bytes += (unsigned) nb_sectors * BDRV_SECTOR_SIZE;
 	bs->rd_ops ++;
+    } else {
+        trace_bdrv_aio_readv_failed(bs, sector_num, nb_sectors, opaque);
     }
 
     return ret;
@@ -2192,12 +2198,18 @@  BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
 
     trace_bdrv_aio_writev(bs, sector_num, nb_sectors, opaque);
 
-    if (!drv)
+    if (!drv) {
+        trace_bdrv_aio_writev_null_drv(bs, sector_num, nb_sectors, opaque);
         return NULL;
-    if (bs->read_only)
+    }
+    if (bs->read_only) {
+        trace_bdrv_aio_writev_read_only(bs, sector_num, nb_sectors, opaque);
         return NULL;
-    if (bdrv_check_request(bs, sector_num, nb_sectors))
+    }
+    if (bdrv_check_request(bs, sector_num, nb_sectors)) {
+        trace_bdrv_aio_writev_out_of_range(bs, sector_num, nb_sectors, opaque);
         return NULL;
+    }
 
     if (bs->dirty_bitmap) {
         blk_cb_data = blk_dirty_cb_alloc(bs, sector_num, nb_sectors, cb,
@@ -2216,6 +2228,8 @@  BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
         if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
             bs->wr_highest_sector = sector_num + nb_sectors - 1;
         }
+    } else {
+        trace_bdrv_aio_writev_failed(bs, sector_num, nb_sectors, opaque);
     }
 
     return ret;
diff --git a/trace-events b/trace-events
index 10faa07..3518254 100644
--- a/trace-events
+++ b/trace-events
@@ -53,7 +53,14 @@  disable bdrv_aio_multiwrite_earlyfail(void *mcb) "mcb %p"
 disable bdrv_aio_multiwrite_latefail(void *mcb, int i) "mcb %p i %d"
 disable bdrv_aio_flush(void *bs, void *opaque) "bs %p opaque %p"
 disable bdrv_aio_readv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+disable bdrv_aio_readv_null_drv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+disable bdrv_aio_readv_out_of_range(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+disable bdrv_aio_readv_failed(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
 disable bdrv_aio_writev(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+disable bdrv_aio_writev_null_drv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+disable bdrv_aio_writev_read_only(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+disable bdrv_aio_writev_out_of_range(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
+disable bdrv_aio_writev_failed(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
 disable bdrv_set_locked(void *bs, int locked) "bs %p locked %d"
 
 # hw/virtio-blk.c