[sheepdog] [PATCH v6 4/9] extend MAX number of objects

Liu Yuan namei.unix at gmail.com
Mon Nov 11 10:12:57 CET 2013


On Mon, Nov 11, 2013 at 02:55:30PM +0800, Robin Dong wrote:
> Add the max number of objects and add new MACRO for index of inode.
> Add store_policy into 'struct vdi_iocq' and 'struct sd_req'
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  dog/common.c             |    4 ++-
>  dog/dog.h                |    2 +-
>  dog/farm/farm.c          |   12 ++++++++--
>  dog/vdi.c                |   47 +++++++++++++++++++++++++++++++-------------
>  include/sheepdog_proto.h |   15 +++++++++----
>  lib/option.c             |    7 ++++-
>  lib/sd_inode.c           |   48 +++++++++++++++++++++++----------------------
>  sheep/ops.c              |    1 +
>  sheep/sheep_priv.h       |    1 +
>  sheep/vdi.c              |    9 +++++--
>  10 files changed, 94 insertions(+), 52 deletions(-)
> 
> diff --git a/dog/common.c b/dog/common.c
> index 1d088c8..bc8cb79 100644
> --- a/dog/common.c
> +++ b/dog/common.c
> @@ -155,7 +155,9 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
>  
>  		oid = vid_to_vdi_oid(nr);
>  
> -		ret = sd_read_object(oid, &i, SD_INODE_HEADER_SIZE, 0, true);
> +		/* for B-tree inode, we also need sd_extent_header */
> +		ret = sd_read_object(oid, &i, SD_INODE_HEADER_SIZE +
> +				     sizeof(struct sd_extent_header), 0, true);
>  		if (ret != SD_RES_SUCCESS) {
>  			sd_err("Failed to read inode header");
>  			continue;
> diff --git a/dog/dog.h b/dog/dog.h
> index 0475cbc..5651ee6 100644
> --- a/dog/dog.h
> +++ b/dog/dog.h
> @@ -79,7 +79,7 @@ void confirm(const char *message);
>  void work_queue_wait(struct work_queue *q);
>  int do_vdi_create(const char *vdiname, int64_t vdi_size,
>  		  uint32_t base_vid, uint32_t *vdi_id, bool snapshot,
> -		  uint8_t nr_copies, uint8_t copy_policy);
> +		  uint8_t nr_copies, uint8_t copy_policy, uint8_t store_policy);
>  int do_vdi_check(const struct sd_inode *inode);
>  void show_progress(uint64_t done, uint64_t total, bool raw);
>  size_t get_store_objsize(uint8_t copy_policy, uint64_t oid);
> diff --git a/dog/farm/farm.c b/dog/farm/farm.c
> index 990d26b..54ea895 100644
> --- a/dog/farm/farm.c
> +++ b/dog/farm/farm.c
> @@ -29,6 +29,7 @@ struct vdi_entry {
>  	uint32_t snap_id;
>  	uint8_t  nr_copies;
>  	uint8_t copy_policy;
> +	uint8_t store_policy;
>  	struct rb_node rb;
>  };
>  static struct rb_root last_vdi_tree = RB_ROOT;
> @@ -57,7 +58,8 @@ static struct vdi_entry *find_vdi(const char *name)
>  
>  static struct vdi_entry *new_vdi(const char *name, uint64_t vdi_size,
>  				 uint32_t vdi_id, uint32_t snap_id,
> -				 uint8_t nr_copies, uint8_t copy_policy)
> +				 uint8_t nr_copies, uint8_t copy_policy,
> +				 uint8_t store_policy)
>  {
>  	struct vdi_entry *vdi;
>  	vdi = xmalloc(sizeof(struct vdi_entry));
> @@ -67,6 +69,7 @@ static struct vdi_entry *new_vdi(const char *name, uint64_t vdi_size,
>  	vdi->snap_id = snap_id;
>  	vdi->nr_copies = nr_copies;
>  	vdi->copy_policy = copy_policy;
> +	vdi->store_policy = store_policy;
>  	return vdi;
>  }
>  
> @@ -80,7 +83,8 @@ static void insert_vdi(struct sd_inode *new)
>  			      new->vdi_id,
>  			      new->snap_id,
>  			      new->nr_copies,
> -			      new->copy_policy);
> +			      new->copy_policy,
> +			      new->store_policy);
>  		rb_insert(&last_vdi_tree, vdi, rb, vdi_cmp);
>  	} else if (vdi->snap_id < new->snap_id) {
>  		vdi->vdi_size = new->vdi_size;
> @@ -88,6 +92,7 @@ static void insert_vdi(struct sd_inode *new)
>  		vdi->snap_id = new->snap_id;
>  		vdi->nr_copies = new->nr_copies;
>  		vdi->copy_policy = new->copy_policy;
> +		vdi->store_policy = new->copy_policy;
>  	}
>  }
>  
> @@ -100,7 +105,8 @@ static int create_active_vdis(void)
>  				  vdi->vdi_size,
>  				  vdi->vdi_id, &new_vid,
>  				  false, vdi->nr_copies,
> -				  vdi->copy_policy) < 0)
> +				  vdi->copy_policy,
> +				  vdi->store_policy) < 0)
>  			return -1;
>  	}
>  	return 0;
> diff --git a/dog/vdi.c b/dog/vdi.c
> index a76e665..4fe2b37 100644
> --- a/dog/vdi.c
> +++ b/dog/vdi.c
> @@ -31,6 +31,7 @@ static struct sd_option vdi_options[] = {
>  	{'c', "copies", true, "specify the data redundancy level"},
>  	{'F', "from", true, "create a differential backup from the snapshot"},
>  	{'f', "force", false, "do operation forcibly"},
> +	{'b', "btree", false, "specify the index format of VDI to be B-tree"},

I think btree is too technical, I'd suggest 'hyper' for it. So it would be
	{'b', "hyper", false, "create a hyper volume"},

>  	{ 0, NULL, false, NULL },
>  };
>  
> @@ -47,6 +48,7 @@ static struct vdi_cmd_data {
>  	char from_snapshot_tag[SD_MAX_VDI_TAG_LEN];
>  	bool force;
>  	uint8_t copy_policy;
> +	uint8_t store_policy;
>  } vdi_cmd_data = { ~0, };
>  
>  struct get_vdi_info {
> @@ -494,7 +496,7 @@ static int read_vdi_obj(const char *vdiname, int snapid, const char *tag,
>  
>  int do_vdi_create(const char *vdiname, int64_t vdi_size,
>  		  uint32_t base_vid, uint32_t *vdi_id, bool snapshot,
> -		  uint8_t nr_copies, uint8_t copy_policy)
> +		  uint8_t nr_copies, uint8_t copy_policy, uint8_t store_policy)
>  {
>  	struct sd_req hdr;
>  	struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
> @@ -513,6 +515,7 @@ int do_vdi_create(const char *vdiname, int64_t vdi_size,
>  	hdr.vdi.vdi_size = vdi_size;
>  	hdr.vdi.copies = nr_copies;
>  	hdr.vdi.copy_policy = copy_policy;
> +	hdr.vdi.store_policy = store_policy;
>  
>  	ret = dog_exec_req(&sd_nid, &hdr, buf);
>  	if (ret < 0)
> @@ -546,8 +549,11 @@ static int vdi_create(int argc, char **argv)
>  	ret = option_parse_size(argv[optind], &size);
>  	if (ret < 0)
>  		return EXIT_USAGE;
> -	if (size > SD_MAX_VDI_SIZE) {
> -		sd_err("VDI size is too large");
> +	if (size > SD_OLD_MAX_VDI_SIZE && 0 == vdi_cmd_data.store_policy) {
> +		sd_err("VDI size is larger than %s bytes, please use '-b' to "
> +		       "create B-tree VDI with size up to %s bytes",

"create a hyper volume"

Thanks
Yuan



More information about the sheepdog mailing list