[sheepdog] [PATCH v2 2/5] sheep: introduce ec_max_data_strip
Liu Yuan
namei.unix at gmail.com
Sat Oct 26 14:17:48 CEST 2013
This is a preparation patch
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
sheep/ops.c | 3 ++-
sheep/sheep_priv.h | 1 +
sheep/vdi.c | 14 ++++++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/sheep/ops.c b/sheep/ops.c
index 35e0b9c..b715af6 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -676,7 +676,8 @@ static int cluster_recovery_completion(const struct sd_req *req,
sd_debug("all nodes are recovered, epoch %d", epoch);
last_gathered_epoch = epoch;
/* sd_store can be NULL if this node is a gateway */
- if (sd_store && sd_store->cleanup)
+ if (vnode_info->nr_zones >= ec_max_data_strip &&
+ sd_store && sd_store->cleanup)
sd_store->cleanup();
}
}
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index bea76fb..20ec2be 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -296,6 +296,7 @@ int vdi_snapshot(const struct vdi_iocb *iocb, uint32_t *new_vid);
int vdi_delete(const struct vdi_iocb *iocb, struct request *req);
int vdi_lookup(const struct vdi_iocb *iocb, struct vdi_info *info);
void clean_vdi_state(void);
+extern int ec_max_data_strip;
int read_vdis(char *data, int len, unsigned int *rsp_len);
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 221905d..333a5f7 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -22,6 +22,13 @@ struct vdi_state_entry {
static struct rb_root vdi_state_root = RB_ROOT;
static struct sd_lock vdi_state_lock = SD_LOCK_INITIALIZER;
+/*
+ * ec_max_data_strip represent max number of data strips in the cluster. When
+ * nr_zones < it, we don't purge the stale objects because for erasure coding,
+ * there is only one copy of data.
+ */
+int ec_max_data_strip;
+
static int vdi_state_cmp(const struct vdi_state_entry *a,
const struct vdi_state_entry *b)
{
@@ -126,6 +133,13 @@ int add_vdi_state(uint32_t vid, int nr_copies, bool snapshot, uint8_t cp)
entry->snapshot = snapshot;
entry->copy_policy = cp;
+ if (cp) {
+ int d;
+
+ ec_policy_to_dp(cp, &d, NULL);
+ ec_max_data_strip = max(d, ec_max_data_strip);
+ }
+
sd_debug("%" PRIx32 ", %d, %d", vid, nr_copies, cp);
sd_write_lock(&vdi_state_lock);
--
1.7.9.5
More information about the sheepdog
mailing list