[sheepdog] [PATCH 1/3] sheep: introduce ec_max_data_strip
MORITA Kazutaka
morita.kazutaka at gmail.com
Fri Oct 25 20:10:55 CEST 2013
At Wed, 23 Oct 2013 15:59:11 +0800,
Liu Yuan wrote:
>
> 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 7f73ab1..d8c652b 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 615d912..0c44651 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..3b39247 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;
> +
s/strip/stripe/ ?
> 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);
Use max, which is a type-safe version, instead of MAX.
Thanks,
Kazutaka
More information about the sheepdog
mailing list