[sheepdog] [PATCH] sheep: remove SD_MAX_COPIES use SD_MAX_REDUNDANCY instead

Yunkai Zhang yunkai.me at gmail.com
Sun Aug 5 16:33:24 CEST 2012


On Sun, Aug 5, 2012 at 10:15 PM, levin li <levin108 at gmail.com> wrote:
> From: levin li <xingke.lwp at taobao.com>
>
> Since there's already SD_MAX_REDUNDANCY defined as the max copies
> number, there's no need to keep the duplicated micro SD_MAX_COPIES
>
> Signed-off-by: levin li <xingke.lwp at taobao.com>
> ---
>  collie/vdi.c             |    2 +-
>  include/internal_proto.h |    1 -
>  include/sheep.h          |    2 +-
>  sheep/farm/trunk.c       |    2 +-
>  sheep/gateway.c          |    4 ++--
>  sheep/ops.c              |    2 +-
>  sheep/recovery.c         |    2 +-
>  sheep/request.c          |    2 +-
>  8 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/collie/vdi.c b/collie/vdi.c
> index e4f4f65..c277d9c 100644
> --- a/collie/vdi.c
> +++ b/collie/vdi.c
> @@ -800,7 +800,7 @@ static int print_obj_epoch(uint64_t oid)
>         struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
>         unsigned rlen, wlen;
>         struct sd_vnode vnodes[SD_MAX_VNODES];
> -       struct sd_vnode *vnode_buf[SD_MAX_COPIES];
> +       struct sd_vnode *vnode_buf[SD_MAX_REDUNDANCY];
>         struct epoch_log *logs;
>         int vnodes_nr, nr_logs, log_length;
>         char host[128];
> diff --git a/include/internal_proto.h b/include/internal_proto.h
> index 114f98a..2996433 100644
> --- a/include/internal_proto.h
> +++ b/include/internal_proto.h
> @@ -24,7 +24,6 @@
>  #define SD_DEFAULT_REDUNDANCY 3
>  #define SD_MAX_REDUNDANCY 8
>
> -#define SD_MAX_COPIES 16

I like SD_MAX_COPIES, it's shorter and simpler. I suggest to delete
SD_MAX_REDUNDANCY and rename SD_DEFAULT_REDUNDANCY to
SD_DEFAULT_COPIES.

>  #define SD_MAX_NODES 1024
>  #define SD_DEFAULT_VNODES 64
>  #define SD_MAX_VNODES 65536
> diff --git a/include/sheep.h b/include/sheep.h
> index d37aaa2..883bdc9 100644
> --- a/include/sheep.h
> +++ b/include/sheep.h
> @@ -153,7 +153,7 @@ static inline void oid_to_vnodes(struct sd_vnode *entries, int nr_entries,
>                                  uint64_t oid, int nr_copies,
>                                  struct sd_vnode **vnodes)
>  {
> -       int idx, idxs[SD_MAX_COPIES], i;
> +       int idx, idxs[SD_MAX_REDUNDANCY], i;
>
>         idx = get_vnode_first_idx(entries, nr_entries, oid);
>         idxs[0] = idx;
> diff --git a/sheep/farm/trunk.c b/sheep/farm/trunk.c
> index cd1fd20..1968555 100644
> --- a/sheep/farm/trunk.c
> +++ b/sheep/farm/trunk.c
> @@ -242,7 +242,7 @@ static int oid_stale(uint64_t oid)
>         struct vnode_info *vinfo;
>         struct sd_vnode *v;
>         int ret = 1;
> -       struct sd_vnode *obj_vnodes[SD_MAX_COPIES];
> +       struct sd_vnode *obj_vnodes[SD_MAX_REDUNDANCY];
>
>         vinfo = get_vnode_info();
>         nr_copies = get_nr_copies(vinfo);
> diff --git a/sheep/gateway.c b/sheep/gateway.c
> index 382dc7c..85d1ad0 100644
> --- a/sheep/gateway.c
> +++ b/sheep/gateway.c
> @@ -28,7 +28,7 @@ int gateway_read_obj(struct request *req)
>         struct sd_req fwd_hdr;
>         struct sd_rsp *rsp = (struct sd_rsp *)&fwd_hdr;
>         struct sd_vnode *v;
> -       struct sd_vnode *obj_vnodes[SD_MAX_COPIES];
> +       struct sd_vnode *obj_vnodes[SD_MAX_REDUNDANCY];
>         uint64_t oid = req->rq.obj.oid;
>         int nr_copies, j;
>
> @@ -231,7 +231,7 @@ static int gateway_forward_request(struct request *req)
>         unsigned wlen;
>         struct sd_rsp *rsp = (struct sd_rsp *)&req->rp;
>         struct sd_vnode *v;
> -       struct sd_vnode *obj_vnodes[SD_MAX_COPIES];
> +       struct sd_vnode *obj_vnodes[SD_MAX_REDUNDANCY];
>         uint64_t oid = req->rq.obj.oid;
>         int nr_copies;
>         struct write_info wi;
> diff --git a/sheep/ops.c b/sheep/ops.c
> index 945ebff..f59249e 100644
> --- a/sheep/ops.c
> +++ b/sheep/ops.c
> @@ -637,7 +637,7 @@ static int read_copy_from_replica(struct vnode_info *vnodes, uint32_t epoch,
>         int i, j, nr_copies, ret;
>         struct sd_req hdr;
>         struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
> -       struct sd_vnode *obj_vnodes[SD_MAX_COPIES];
> +       struct sd_vnode *obj_vnodes[SD_MAX_REDUNDANCY];
>         struct sd_vnode *v;
>         char name[128];
>         int rounded_rand, local = -1;
> diff --git a/sheep/recovery.c b/sheep/recovery.c
> index 5164aa7..9092c7a 100644
> --- a/sheep/recovery.c
> +++ b/sheep/recovery.c
> @@ -510,7 +510,7 @@ static int fetch_object_list(struct sd_node *e, uint32_t epoch,
>  static void screen_object_list(struct recovery_work *rw,
>                                uint64_t *oids, int nr_oids)
>  {
> -       struct sd_vnode *vnodes[SD_MAX_COPIES];
> +       struct sd_vnode *vnodes[SD_MAX_REDUNDANCY];
>         int old_count = rw->count;
>         int nr_objs;
>         int i, j;
> diff --git a/sheep/request.c b/sheep/request.c
> index ab7c63a..8294567 100644
> --- a/sheep/request.c
> +++ b/sheep/request.c
> @@ -26,7 +26,7 @@ static void requeue_request(struct request *req);
>
>  static int is_access_local(struct request *req, uint64_t oid)
>  {
> -       struct sd_vnode *obj_vnodes[SD_MAX_COPIES];
> +       struct sd_vnode *obj_vnodes[SD_MAX_REDUNDANCY];
>         int nr_copies;
>         int i;
>
> --
> 1.7.10
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



-- 
Yunkai Zhang
Work at Taobao



More information about the sheepdog mailing list