[sheepdog] [PATCH v2] sheep: push dirty bits correctly for successive FLUSH req

Liu Yuan namei.unix at gmail.com
Tue Aug 6 17:33:13 CEST 2013


This will fix a bug that 'qemu-img convert' fail to convert images intact with
default unsafe mode.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/object_cache.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index c267a1f..dcf6972 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -1218,12 +1218,13 @@ int object_cache_flush_vdi(uint32_t vid)
 		return SD_RES_SUCCESS;
 	}
 
-	if (!uatomic_set_true(&cache->in_push)) {
-		/* Guest expects synchronous flush, busy-wait for simplicity */
-		while (uatomic_is_true(&cache->in_push))
-			usleep(100000);
-		return SD_RES_SUCCESS;
-	}
+	/*
+	 * We have to wait for last pusher finishing and push again so
+	 * that dirty bits produced while it is waiting are guaranteed
+	 * to be pushed back
+	 */
+	while (!uatomic_set_true(&cache->in_push))
+		usleep(100000);
 
 	ret = object_cache_push(cache);
 	uatomic_set_false(&cache->in_push);
-- 
1.7.9.5




More information about the sheepdog mailing list