[sheepdog] [PATCH 1/2] dog: add a new option for reducing identical snapshots

Liu Yuan namei.unix at gmail.com
Thu Feb 12 07:38:37 CET 2015


On Mon, Feb 09, 2015 at 05:25:48PM +0900, Hitoshi Mitake wrote:
> Current "dog vdi snapshot" command creates a new snapshot
> unconditionally, even if a working VDI doesn't have its own
> objects. In such a case, the created snapshot is redundant because
> same VDI is already existing.

What kind of use case will create two identical snapshots? This logic is simple
and code is clean, but I doubt if there is real users of this option.

> 
> This patch adds a new option -R to the dog command for reducing
> the identical snapshots.
> 
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
>  dog/vdi.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/dog/vdi.c b/dog/vdi.c
> index 8e612af..ee465c2 100644
> --- a/dog/vdi.c
> +++ b/dog/vdi.c
> @@ -40,6 +40,8 @@ static struct sd_option vdi_options[] = {
>  	 "                          neither comparing nor repairing"},
>  	{'z', "block_size_shift", true, "specify the bit shift num for"
>  			       " data object size"},
> +	{'R', "reduce-identical-snapshots", false, "do not create snapshot if "
> +	 "working VDI doesn't have its own objects"},
>  	{ 0, NULL, false, NULL },
>  };
>  
> @@ -61,6 +63,7 @@ static struct vdi_cmd_data {
>  	uint64_t oid;
>  	bool no_share;
>  	bool exist;
> +	bool reduce_identical_snapshots;
>  } vdi_cmd_data = { ~0, };
>  
>  struct get_vdi_info {
> @@ -605,6 +608,31 @@ fail:
>  	return NULL;
>  }
>  
> +static bool has_own_objects(uint32_t vid, int *ret)

Traditionally, we'll have functions return SD_RES_xxx because in this way we
could propragate the ret to upper callers.

So it is better to have has_own_objects return SD_RES_xxx for consistency.

Thanks,
Yuan



More information about the sheepdog mailing list