[sheepdog] [PATCH v2 3/5] sheep: use rbtree to manage vnodes hash ring
Liu Yuan
namei.unix at gmail.com
Wed Sep 11 08:05:56 CEST 2013
On Wed, Sep 11, 2013 at 02:31:46PM +0900, Hitoshi Mitake wrote:
> At Tue, 10 Sep 2013 10:53:50 +0800,
> Liu Yuan wrote:
> >
> > Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> > ---
> > dog/dog.c | 6 +-
> > dog/dog.h | 4 +-
> > dog/vdi.c | 20 ++---
> > include/internal_proto.h | 1 -
> > include/sheep.h | 199 +++++++++++++++-------------------------------
> > sheep/gateway.c | 8 +-
> > sheep/group.c | 12 ++-
> > sheep/plain_store.c | 3 +-
> > sheep/recovery.c | 7 +-
> > sheep/request.c | 6 +-
> > 10 files changed, 98 insertions(+), 168 deletions(-)
> >
> > diff --git a/dog/dog.c b/dog/dog.c
> > index 9ec41c1..0009c92 100644
> > --- a/dog/dog.c
> > +++ b/dog/dog.c
> > @@ -49,8 +49,8 @@ static void usage(const struct command *commands, int status);
> > uint32_t sd_epoch;
> >
> > struct sd_node sd_nodes[SD_MAX_NODES];
> > -struct sd_vnode sd_vnodes[SD_MAX_VNODES];
> > -int sd_nodes_nr, sd_vnodes_nr;
> > +int sd_nodes_nr;
> > +struct rb_root sd_vroot = RB_ROOT;
> >
> > int update_node_list(int max_nodes)
> > {
> > @@ -92,7 +92,7 @@ int update_node_list(int max_nodes)
> > }
> >
> > memcpy(sd_nodes, buf, size);
> > - sd_vnodes_nr = nodes_to_vnodes(sd_nodes, sd_nodes_nr, sd_vnodes);
> > + nodes_to_vnodes(sd_nodes, sd_nodes_nr, &sd_vroot);
> > sd_epoch = hdr.epoch;
> > out:
> > if (buf)
> > diff --git a/dog/dog.h b/dog/dog.h
> > index e1c499e..9b17eb7 100644
> > --- a/dog/dog.h
> > +++ b/dog/dog.h
> > @@ -56,8 +56,8 @@ extern bool verbose;
> >
> > extern uint32_t sd_epoch;
> > extern struct sd_node sd_nodes[SD_MAX_NODES];
> > -extern struct sd_vnode sd_vnodes[SD_MAX_VNODES];
> > -extern int sd_nodes_nr, sd_vnodes_nr;
> > +extern struct rb_root sd_vroot;
> > +extern int sd_nodes_nr;
> >
> > bool is_current(const struct sd_inode *i);
> > char *strnumber(uint64_t _size);
> > diff --git a/dog/vdi.c b/dog/vdi.c
> > index 82821ac..c99d0ae 100644
> > --- a/dog/vdi.c
> > +++ b/dog/vdi.c
> > @@ -904,14 +904,12 @@ static int do_track_object(uint64_t oid, uint8_t nr_copies)
> > int i, j, ret;
> > struct sd_req hdr;
> > struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
> > - struct sd_vnode *vnodes;
> > const struct sd_vnode *vnode_buf[SD_MAX_COPIES];
> > struct epoch_log *logs;
> > - int vnodes_nr, nr_logs, log_length;
> > + int nr_logs, log_length;
> >
> > log_length = sd_epoch * sizeof(struct epoch_log);
> > logs = xmalloc(log_length);
> > - vnodes = xmalloc(sizeof(*vnodes) * SD_MAX_VNODES);
> >
> > sd_init_req(&hdr, SD_OP_STAT_CLUSTER);
> > hdr.data_length = log_length;
> > @@ -927,6 +925,9 @@ static int do_track_object(uint64_t oid, uint8_t nr_copies)
> >
> > nr_logs = rsp->data_length / sizeof(struct epoch_log);
> > for (i = nr_logs - 1; i >= 0; i--) {
> > + struct rb_root vroot;
>
> This patch cannot pass the test 048. You need to declare the above vroot like this:
> struct rb_root vroot = RB_ROOT;
Oops, good catch. Thanks
Yuan
More information about the sheepdog
mailing list