[sheepdog] [PATCH stable-0.6 1/3] sheep: push dirty bits correctly for successive FLUSH req

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue Aug 13 07:44:51 CEST 2013


From: Liu Yuan <namei.unix at gmail.com>

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>
Reviewed-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 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 16fd1f8..bdce813 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -1224,12 +1224,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.8.1.2




More information about the sheepdog mailing list