[sheepdog] [PATCH v3 2/5] add basic read/write function framwork for btree

Liu Yuan namei.unix at gmail.com
Fri Oct 25 07:10:18 CEST 2013


On Thu, Oct 24, 2013 at 05:46:19PM +0800, Robin Dong wrote:
> B-tree is just a abstract structure so it need to call callback-function to read
> and write nodes.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  dog/cluster.c            |    2 +-
>  dog/dog.h                |    9 +++++++++
>  dog/vdi.c                |   38 ++++++++++++++++++++++++++++----------
>  include/sheepdog_proto.h |   18 +++++++++---------
>  lib/sd_inode.c           |    6 ++++--
>  sheep/sheep_priv.h       |    9 +++++++++
>  sheep/vdi.c              |   13 ++++++++++++-
>  sheepfs/volume.c         |   39 +++++++++++++++++++++++++++++++++++++--
>  8 files changed, 109 insertions(+), 25 deletions(-)
> 
> diff --git a/dog/cluster.c b/dog/cluster.c
> index 62b78d0..b432302 100644
> --- a/dog/cluster.c
> +++ b/dog/cluster.c
> @@ -259,7 +259,7 @@ static void fill_object_tree(uint32_t vid, const char *name, const char *tag,
>  	/* fill data object id */
>  	nr_objs = count_data_objs(i);
>  	for (uint64_t idx = 0; idx < nr_objs; idx++) {
> -		vdi_id = sd_inode_get_vdi(i, idx);
> +		vdi_id = INODE_GET_VDI(i, idx);
>  		if (vdi_id) {
>  			uint64_t oid = vid_to_data_oid(vdi_id, idx);
>  			object_tree_insert(oid, i->nr_copies, i->copy_policy);
> diff --git a/dog/dog.h b/dog/dog.h
> index 769fc6c..c2832bb 100644
> --- a/dog/dog.h
> +++ b/dog/dog.h
> @@ -85,6 +85,15 @@ void show_progress(uint64_t done, uint64_t total, bool raw);
>  size_t get_store_objsize(uint8_t copy_policy, uint64_t oid);
>  bool is_erasure_oid(uint64_t oid, uint8_t policy);
>  
> +int write_btree_node(uint64_t id, void *mem, unsigned int len,
> +				int copies, int copy_policy, int create);
> +int read_btree_node(uint64_t id, void **mem, unsigned int len);
> +

I'd suggest use different for reader/writer, e.g,  would better name them as 
{sheep,dog,sheepfs}_bnode_{reader,writer} for indexing friendly and readability

Thanks
Yuan



More information about the sheepdog mailing list