xen-blkback: fix dispatch_rw_block_io() error path
[pandora-kernel.git] / drivers / block / xen-blkback / blkback.c
index 15ec4db..85fdd4b 100644 (file)
@@ -758,13 +758,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
                }
        }
 
                }
        }
 
-       /*
-        * We set it one so that the last submit_bio does not have to call
-        * atomic_inc.
-        */
        atomic_set(&pending_req->pendcnt, nbio);
        atomic_set(&pending_req->pendcnt, nbio);
-
-       /* Get a reference count for the disk queue and start sending I/O */
        blk_start_plug(&plug);
 
        for (i = 0; i < nbio; i++)
        blk_start_plug(&plug);
 
        for (i = 0; i < nbio; i++)
@@ -792,6 +786,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
  fail_put_bio:
        for (i = 0; i < nbio; i++)
                bio_put(biolist[i]);
  fail_put_bio:
        for (i = 0; i < nbio; i++)
                bio_put(biolist[i]);
+       atomic_set(&pending_req->pendcnt, 1);
        __end_block_io_op(pending_req, -EINVAL);
        msleep(1); /* back off a bit */
        return -EIO;
        __end_block_io_op(pending_req, -EINVAL);
        msleep(1); /* back off a bit */
        return -EIO;