[sheepdog] [PATCH 3/6] plain: clean up stale directory at startup

Liu Yuan namei.unix at gmail.com
Fri Aug 24 14:10:14 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

When we start up, the objects in .stale is useless. This patch also reworks the
->cleanup() interface to reflect the current implementation.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/ops.c         |    4 +---
 sheep/plain_store.c |    5 ++++-
 sheep/sheep_priv.h  |    4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/sheep/ops.c b/sheep/ops.c
index 0215312..f30b8ba 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -536,8 +536,6 @@ static int cluster_cleanup(const struct sd_req *req, struct sd_rsp *rsp,
 				void *data)
 {
 	int ret;
-	struct siocb iocb = { 0 };
-	iocb.epoch = sys->epoch;
 
 	if (node_in_recovery())
 		return SD_RES_NODE_IN_RECOVERY;
@@ -546,7 +544,7 @@ static int cluster_cleanup(const struct sd_req *req, struct sd_rsp *rsp,
 		return SD_RES_SUCCESS;
 
 	if (sd_store->cleanup)
-		ret = sd_store->cleanup(&iocb);
+		ret = sd_store->cleanup();
 	else
 		ret = SD_RES_NO_SUPPORT;
 
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 4b322b4..0f946c9 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -132,7 +132,7 @@ out:
 	return ret;
 }
 
-int default_cleanup(struct siocb *iocb)
+int default_cleanup(void)
 {
 	rmdir_r(stale_dir);
 	if (mkdir(stale_dir, 0755) < 0) {
@@ -196,6 +196,9 @@ int default_init(char *p)
 		}
 	}
 
+	/* When we start up, the objects in .stale is useless */
+	default_cleanup();
+
 	return for_each_objects(init_objlist_and_vdi_bitmap);
 }
 
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index bff3198..bbc1ee5 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -154,7 +154,7 @@ struct store_driver {
 	int (*purge_obj)(void);
 	/* Operations for snapshot */
 	int (*snapshot)(struct siocb *);
-	int (*cleanup)(struct siocb *);
+	int (*cleanup)(void);
 	int (*restore)(struct siocb *);
 	int (*get_snap_file)(struct siocb *);
 };
@@ -166,7 +166,7 @@ int default_read(uint64_t oid, struct siocb *iocb);
 int default_link(uint64_t oid, struct siocb *iocb, uint32_t tgt_epoch);
 int default_atomic_put(uint64_t oid, struct siocb *iocb);
 int default_end_recover(uint32_t old_epoch, struct vnode_info *old_vnode_info);
-int default_cleanup(struct siocb *iocb);
+int default_cleanup(void);
 int default_format(struct siocb *iocb);
 int default_remove_object(uint64_t oid);
 int default_purge_obj(void);
-- 
1.7.10.2




More information about the sheepdog mailing list