From: Daniel Stodden Date: Fri, 15 Oct 2010 01:17:31 +0000 (-0700) Subject: CP-1840: Count ENOSPC redirects. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3982b28d1c5d35f4226b2e113d2072000f2d2f92;p=people%2Fdstodden%2Fblktap.git CP-1840: Count ENOSPC redirects. Signed-off-by: Daniel Stodden --- diff --git a/drivers/tapdisk-vbd.c b/drivers/tapdisk-vbd.c index d20a07b..ae52f0c 100644 --- a/drivers/tapdisk-vbd.c +++ b/drivers/tapdisk-vbd.c @@ -1305,6 +1305,16 @@ tapdisk_vbd_complete_vbd_request(td_vbd_t *vbd, td_vbd_request_t *vreq) } } +static void +FIXME_maybe_count_enospc_redirect(td_vbd_t *vbd, td_request_t treq) +{ + int write = treq.op == TD_OP_WRITE; + if (write && + treq.image == tapdisk_vbd_first_image(vbd) && + vbd->FIXME_enospc_redirect_count_enabled) + vbd->FIXME_enospc_redirect_count += treq.secs; +} + static void __tapdisk_vbd_complete_td_request(td_vbd_t *vbd, td_vbd_request_t *vreq, td_request_t treq, int res) @@ -1322,6 +1332,8 @@ __tapdisk_vbd_complete_td_request(td_vbd_t *vbd, td_vbd_request_t *vreq, if (err) td_sector_count_add(&image->stats.fail, treq.secs, write); + + FIXME_maybe_count_enospc_redirect(vbd, treq); } if (err) { @@ -1439,6 +1451,7 @@ tapdisk_vbd_complete_td_request(td_request_t treq, int res) } else if (vbd->secondary_mode == TD_VBD_SECONDARY_STANDBY) { DPRINTF("ENOSPC: failing over to secondary image\n"); list_add(&vbd->secondary->next, leaf->next.prev); + vbd->FIXME_enospc_redirect_count_enabled = 1; } if (vbd->secondary_mode != TD_VBD_SECONDARY_DISABLED) { vbd->secondary = NULL; @@ -1875,5 +1888,9 @@ tapdisk_vbd_stats(td_vbd_t *vbd, td_stats_t *st) tapdisk_image_stats(image, st); tapdisk_stats_leave(st, ']'); + tapdisk_stats_field(st, + "FIXME_enospc_redirect_count", + "llu", vbd->FIXME_enospc_redirect_count); + tapdisk_stats_leave(st, '}'); } diff --git a/drivers/tapdisk-vbd.h b/drivers/tapdisk-vbd.h index d69804a..00bd966 100644 --- a/drivers/tapdisk-vbd.h +++ b/drivers/tapdisk-vbd.h @@ -103,6 +103,9 @@ struct td_vbd_handle { td_image_t *secondary; uint8_t secondary_mode; + int FIXME_enospc_redirect_count_enabled; + uint64_t FIXME_enospc_redirect_count; + /* when we encounter ENOSPC on the primary leaf image in mirror mode, * we need to remove it from the VBD chain so that writes start going * on the secondary leaf. However, we cannot free the image at that