[sheepdog] [PATCH] object list cache: cleanup object list cache when format cluster

Meng Lingkun menglingkun at cmss.chinamobile.com
Fri May 15 06:56:43 CEST 2015


Cleanup the object list cache when format cluster to keep data
consistency.

Signed-off-by: Meng Lingkun <menglingkun at cmss.chinamobile.com>
---
 sheep/object_list_cache.c |    8 ++++++++
 sheep/ops.c               |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/sheep/object_list_cache.c b/sheep/object_list_cache.c
index b9acaa0..86642cd 100644
--- a/sheep/object_list_cache.c
+++ b/sheep/object_list_cache.c
@@ -196,3 +196,11 @@ int objlist_cache_cleanup(uint32_t vid)
 
 	return SD_RES_SUCCESS;
 }
+
+void objlist_cache_format(void)
+{
+	sd_write_lock(&obj_list_cache.lock);
+	rb_destroy(&obj_list_cache.root, struct objlist_cache_entry, node);
+	INIT_RB_ROOT(&obj_list_cache.root);
+	sd_rw_unlock(&obj_list_cache.lock);
+}
diff --git a/sheep/ops.c b/sheep/ops.c
index c6065d5..7b92f8c 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -342,6 +342,7 @@ static int cluster_make_fs(const struct sd_req *req, struct sd_rsp *rsp,
 	memset(sys->vdi_inuse, 0, sizeof(sys->vdi_inuse));
 	memset(sys->vdi_deleted, 0, sizeof(sys->vdi_deleted));
 	clean_vdi_state();
+	objlist_cache_format();
 
 	sys->cinfo.epoch = 0;
 
-- 
1.7.1





More information about the sheepdog mailing list