-----BEGIN PGP SIGNATURE-----

Version: GnuPG v1
 
 iQEcBAABAgAGBQJXtbqTAAoJEJykq7OBq3PIPNUH/0jrO3CRN2c3gQrbm+tpgb3r
 /uR9qrfCiLBBMjha8g///jUMFSLz3TJwI+oP7owzNz3dHGVQgdae5rERBWbPms0T
 1l5/JLVHZ6DBpWiAMQpu3MCPIXY/09jQuYfkxuYKNz+oOo5aGTfPXBlRbE/Eu2Rz
 th/ivzSvDXnLX8Iepw836WVwhJaQiCNbhtCxIaq/DLG5DXx063GjkbK31UNnAyJs
 71x8LtPFjqlHM4MZDVsOhnJGBj+EdXSPk5KqbZ+fNm+XkSvr1b4hIjXlllmRHvjG
 sw++qHjrR4kwJ+jqb9YeB5jok/Wi9iQj2yqvtPv2djzLJ5TiVKYj1rvprCQoBMY=
 =T6Rt
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

# gpg: Signature made Thu 18 Aug 2016 14:39:31 BST
# gpg:                using RSA key 0x9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/block-pull-request:
  block: fix possible reorder of flush operations
  block: fix deadlock in bdrv_co_flush

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2016-08-18 14:42:51 +01:00
commit 02b1ad881c
2 changed files with 6 additions and 4 deletions

View file

@ -2283,11 +2283,11 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
int current_gen = bs->write_gen;
/* Wait until any previous flushes are completed */
while (bs->flush_started_gen != bs->flushed_gen) {
while (bs->active_flush_req != NULL) {
qemu_co_queue_wait(&bs->flush_queue);
}
bs->flush_started_gen = current_gen;
bs->active_flush_req = &req;
/* Write back all layers by calling one driver function */
if (bs->drv->bdrv_co_flush) {
@ -2357,7 +2357,9 @@ flush_parent:
out:
/* Notify any pending flushes that we have completed */
bs->flushed_gen = current_gen;
qemu_co_queue_restart_all(&bs->flush_queue);
bs->active_flush_req = NULL;
/* Return value is ignored - it's ok if wait queue is empty */
qemu_co_queue_next(&bs->flush_queue);
tracked_request_end(&req);
return ret;

View file

@ -443,8 +443,8 @@ struct BlockDriverState {
note this is a reference count */
CoQueue flush_queue; /* Serializing flush queue */
BdrvTrackedRequest *active_flush_req; /* Flush request in flight */
unsigned int write_gen; /* Current data generation */
unsigned int flush_started_gen; /* Generation for which flush has started */
unsigned int flushed_gen; /* Flushed write generation */
BlockDriver *drv; /* NULL means no media */