[sheepdog] [PATCH v2 1/2] sheep: enhance STAT_RECOVERY for prividing information of recovery progress

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Thu Aug 1 06:03:08 CEST 2013


Current SD_OP_STAT_RECOVERY only provides an information that
indicates the node is doing recovery or not. For providing more useful
information about progress of recovery, this patch enhances this
request.

The enhanced SD_OP_STAT_RECOVERY returns the information with struct
recovery_progress. The struct contains these information:
1. state of recovery. With this information, collie can know which
   phase of progress sheep is in.
2. Number of copied object during a recovery process.
3. Number of entire objects which should be copied during a recovery
   process.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
v2:
 - don't use new variables for indicating the progress
 - clean coding style
 -- change names of struct recovery_info's members
 -- fill_recovery_progress() -> get_recovery_progress()

 include/internal_proto.h |   12 ++++++++++++
 sheep/ops.c              |   11 ++++++++---
 sheep/recovery.c         |   19 +++++++++++++------
 sheep/sheep_priv.h       |    1 +
 4 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/include/internal_proto.h b/include/internal_proto.h
index 0061007..9fab5eb 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -192,4 +192,16 @@ static inline __attribute__((used)) void __sd_epoch_format_build_bug_ons(void)
 	BUILD_BUG_ON(sizeof(struct sd_node) != SD_NODE_SIZE);
 }
 
+enum rw_state {
+	RW_PREPARE_LIST, /* the recovery thread is preparing object list */
+	RW_RECOVER_OBJ, /* the thread is recoering objects */
+	RW_NOTIFY_COMPLETION, /* the thread is notifying recovery completion */
+};
+
+struct recovery_progress {
+	enum rw_state state;
+	uint32_t nr_finished;
+	uint32_t nr_total;
+};
+
 #endif /* __INTERNAL_PROTO_H__ */
diff --git a/sheep/ops.c b/sheep/ops.c
index 5d7686c..60da83f 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -390,10 +390,15 @@ static int local_stat_sheep(struct request *req)
 static int local_stat_recovery(const struct sd_req *req, struct sd_rsp *rsp,
 					void *data)
 {
-	if (node_in_recovery())
-		return SD_RES_NODE_IN_RECOVERY;
+	if (!node_in_recovery())
+		return SD_RES_SUCCESS;
 
-	return SD_RES_SUCCESS;
+	if (req->data_length == sizeof(struct recovery_progress)) {
+		get_recovery_progress(data);
+		rsp->data_length = sizeof(struct recovery_progress);
+	}
+
+	return SD_RES_NODE_IN_RECOVERY;
 }
 
 static int local_stat_cluster(struct request *req)
diff --git a/sheep/recovery.c b/sheep/recovery.c
index ea3101a..9b23544 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -11,12 +11,6 @@
 
 #include "sheep_priv.h"
 
-enum rw_state {
-	RW_PREPARE_LIST, /* the recovery thread is preparing object list */
-	RW_RECOVER_OBJ, /* the thread is recoering objects */
-	RW_NOTIFY_COMPLETION, /* the thread is notifying recovery completion */
-};
-
 /* base structure for the recovery thread */
 struct recovery_work {
 	uint32_t epoch;
@@ -882,3 +876,16 @@ static void queue_recovery_work(struct recovery_info *rinfo)
 
 	queue_work(sys->recovery_wqueue, &rw->work);
 }
+
+void get_recovery_progress(struct recovery_progress *progress)
+{
+	struct recovery_info *rinfo = main_thread_get(current_rinfo);
+
+	if (!rinfo)
+		return;
+
+	progress->state = rinfo->state;
+	progress->nr_finished = rinfo->done;
+	progress->nr_total = rinfo->count;
+}
+
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 09303ff..eac93ea 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -320,6 +320,7 @@ int objlist_cache_cleanup(uint32_t vid);
 int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *, bool);
 bool oid_in_recovery(uint64_t oid);
 bool node_in_recovery(void);
+void get_recovery_progress(struct recovery_progress *progress);
 
 int read_backend_object(uint64_t oid, char *data, unsigned int datalen,
 		       uint64_t offset);
-- 
1.7.10.4




More information about the sheepdog mailing list