Skip to contentSkip to conversation

virtio-blk: Move resetting of req->mr_next to virtio_blk_handle_rw_error

PATCH Applied Fam Zheng 3 participants 3 messages Nov 23, 2015 – Nov 24, 2015

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 virtio-blk: Move resetting of req->mr_next to virtio_blk_handle_rw_error

"werror=report" would free the req in virtio_blk_handle_rw_error, we mustn't write to it in that case.

---
 hw/block/virtio-blk.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/block/virtio-blk.c +3 -4
index 848f3fe..756ae5c 100644
@@ -72,6 +72,9 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
     VirtIOBlock *s = req->dev;
 
     if (action == BLOCK_ERROR_ACTION_STOP) {
+        /* Break the link as the next request is going to be parsed from the
+         * ring again. Otherwise we may end up doing a double completion! */
+        req->mr_next = NULL;
         req->next = s->rq;
         s->rq = req;
     } else if (action == BLOCK_ERROR_ACTION_REPORT) {
@@ -112,10 +115,6 @@ static void virtio_blk_rw_complete(void *opaque, int ret)
              * happen on the other side of the migration).
              */
             if (virtio_blk_handle_rw_error(req, -ret, is_read)) {
-                /* Break the link in case the next request is added to the
-                 * restart queue and is going to be parsed from the ring again.
-                 */
-                req->mr_next = NULL;
                 continue;
             }
         }
Signature · 1 line
2.4.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Fam Zheng

"werror=report" would free the req in virtio_blk_handle_rw_error, we mustn't write to it in that case.

---
 hw/block/virtio-blk.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/block/virtio-blk.c +3 -0
index 848f3fe..756ae5c 100644
@@ -72,6 +72,9 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error,
     VirtIOBlock *s = req->dev;
 
     if (action == BLOCK_ERROR_ACTION_STOP) {
+        /* Break the link as the next request is going to be parsed from the
+         * ring again. Otherwise we may end up doing a double completion! */
+        req->mr_next = NULL;
         req->next = s->rq;
         s->rq = req;
     } else if (action == BLOCK_ERROR_ACTION_REPORT) {

hw/block/virtio-blk.c static void virtio_blk_rw_complete(void *opaque, int ret) · line 120

Quoted 10 lines
hw/block/virtio-blk.c +0 -4
@@ -112,10 +115,6 @@ static void virtio_blk_rw_complete(void *opaque, int ret)
              * happen on the other side of the migration).
              */
             if (virtio_blk_handle_rw_error(req, -ret, is_read)) {
-                /* Break the link in case the next request is added to the
-                 * restart queue and is going to be parsed from the ring again.
-                 */
-                req->mr_next = NULL;
                 continue;
             }
         }