[PATCH, v2] qemu/xendisk: properly update stats in ioreq_release()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH, v2] qemu/xendisk: properly update stats in ioreq_release()

Jan Beulich-2
While for the "normal" case (called from blk_send_response_all())
decrementing requests_finished is correct, doing so in the parse error
case is wrong; requests_inflight needs to be decremented instead.

Change in v2: Adjust coding style.

Signed-off-by: Jan Beulich <[hidden email]>

--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -154,7 +154,7 @@ static void ioreq_finish(struct ioreq *i
     blkdev->requests_finished++;
 }
 
-static void ioreq_release(struct ioreq *ioreq)
+static void ioreq_release(struct ioreq *ioreq, bool finish)
 {
     struct XenBlkDev *blkdev = ioreq->blkdev;
 
@@ -162,7 +162,11 @@ static void ioreq_release(struct ioreq *
     memset(ioreq, 0, sizeof(*ioreq));
     ioreq->blkdev = blkdev;
     QLIST_INSERT_HEAD(&blkdev->freelist, ioreq, list);
-    blkdev->requests_finished--;
+    if (finish) {
+        blkdev->requests_finished--;
+    } else {
+        blkdev->requests_inflight--;
+    }
 }
 
 /*
@@ -449,7 +453,7 @@ static void blk_send_response_all(struct
     while (!QLIST_EMPTY(&blkdev->finished)) {
         ioreq = QLIST_FIRST(&blkdev->finished);
         send_notify += blk_send_response_one(ioreq);
-        ioreq_release(ioreq);
+        ioreq_release(ioreq, true);
     }
     if (send_notify) {
         xen_be_send_notify(&blkdev->xendev);
@@ -505,7 +509,7 @@ static void blk_handle_requests(struct X
             if (blk_send_response_one(ioreq)) {
                 xen_be_send_notify(&blkdev->xendev);
             }
-            ioreq_release(ioreq);
+            ioreq_release(ioreq, false);
             continue;
         }
 




_______________________________________________
Xen-devel mailing list
[hidden email]
http://lists.xen.org/xen-devel

qemu-xendisk-accounting.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Qemu-devel] [PATCH, v2] qemu/xendisk: properly update stats in ioreq_release()

Kevin Wolf
Am 14.05.2012 12:30, schrieb Jan Beulich:
> While for the "normal" case (called from blk_send_response_all())
> decrementing requests_finished is correct, doing so in the parse error
> case is wrong; requests_inflight needs to be decremented instead.
>
> Change in v2: Adjust coding style.
>
> Signed-off-by: Jan Beulich <[hidden email]>

I think it would be nicer if a struct ioreq had an explicit state so
that you don't have to pass the right state when releasing it. But
anyway, the patch looks correct to me:

Reviewed-by: Kevin Wolf <[hidden email]>

_______________________________________________
Xen-devel mailing list
[hidden email]
http://lists.xen.org/xen-devel