[sheepdog] [PATCH v2 5/6] replace structure of inode->data_vdi_id[] from array to btree

Liu Yuan namei.unix at gmail.com
Wed Oct 16 10:01:40 CEST 2013


On Tue, Oct 15, 2013 at 02:45:39PM +0800, Robin Dong wrote:
> Add implement of B-tree code into lib/sd_inode.c.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  include/sheepdog_proto.h |   43 ++++-
>  lib/sd_inode.c           |  519 +++++++++++++++++++++++++++++++++++++++++++++-
>  sheep/vdi.c              |    1 +
>  sheepfs/volume.c         |    2 +-
>  4 files changed, 557 insertions(+), 8 deletions(-)
> 
> diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
> index 2be9bc9..a826133 100644
> --- a/include/sheepdog_proto.h
> +++ b/include/sheepdog_proto.h
> @@ -74,6 +74,9 @@
>  #define SD_RES_JOIN_FAILED   0x18 /* Target node had failed to join sheepdog */
>  #define SD_RES_HALT          0x19 /* Sheepdog is stopped doing IO */
>  #define SD_RES_READONLY      0x1A /* Object is read-only */
> +#define SD_RES_BTREE_NOT_FOUND	0x1B /* Cannot found node in btree */
> +#define SD_RES_BTREE_FOUND   0x1C /* Found node in btree */
> +#define SD_RES_BTREE_REPEAT  0x1D /* Should repeat op in btree */
>  
>  /* errors above 0x80 are sheepdog-internal */
>  
> @@ -92,8 +95,9 @@
>  #define VDI_BIT (UINT64_C(1) << 63)
>  #define VMSTATE_BIT (UINT64_C(1) << 62)
>  #define VDI_ATTR_BIT (UINT64_C(1) << 61)
> +#define VDI_BTREE_BIT (UINT64_C(1) << 60)
>  #define MAX_DATA_OBJS (1ULL << 20)
> -#define MAX_CHILDREN 1024U
> +#define MAX_CHILDREN (1024U - 1)
>  #define SD_MAX_VDI_LEN 256U
>  #define SD_MAX_VDI_TAG_LEN 256U
>  #define SD_MAX_VDI_ATTR_KEY_LEN 256U
> @@ -104,8 +108,8 @@
>  #define SD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * MAX_DATA_OBJS)
>  
>  #define SD_INODE_SIZE (sizeof(struct sd_inode))
> -#define SD_INODE_HEADER_SIZE (sizeof(struct sd_inode) - \
> -			      sizeof(uint32_t) * MAX_DATA_OBJS)
> +#define SD_INODE_INDEX_SIZE (sizeof(uint32_t) * MAX_DATA_OBJS)
> +#define SD_INODE_HEADER_SIZE (sizeof(struct sd_inode) - SD_INODE_INDEX_SIZE)
>  #define SD_ATTR_OBJ_SIZE (sizeof(struct sheepdog_vdi_attr))
>  #define CURRENT_VDI_ID 0
>  
> @@ -213,16 +217,35 @@ struct sd_inode {
>  	uint64_t vdi_size;
>  	uint64_t vm_state_size;
>  	uint8_t  copy_policy;
> -	uint8_t  reserved;
> +	uint8_t  store_policy;
>  	uint8_t  nr_copies;
>  	uint8_t  block_size_shift;
>  	uint32_t snap_id;
>  	uint32_t vdi_id;
>  	uint32_t parent_vdi_id;
> +	uint32_t btree_counter;
>  	uint32_t child_vdi_id[MAX_CHILDREN];

I think we should put btree_counter after child_vdi_id[] for compatiblity issues

Thanks
Yuan



More information about the sheepdog mailing list