[sheepdog] [PATCH] dog: fix cluster-wide snapshot inconsistency due to vdi deleted
Liu Yuan
namei.unix at gmail.com
Wed Aug 20 11:08:15 CEST 2014
On Wed, Aug 20, 2014 at 04:53:46PM +0800, Ruoyu wrote:
> Once vdi snapshot is deleted before executing 'dog cluster snapshot
> save', error messsage just like as below is seen.
>
> Failed to read object 807c2b2500000000 No object found
> Failed to read inode header
>
> Once a vdi is deleted, cluster snapshot save will not backup it to
> farm so that cluster snapshot load cannot restore it to new cluster.
> However, the vdi id is marked as in use for safety, vdi list
> will try to read all vdis in use. Therefore, dog cannot read the object.
>
> The solution is saving the deleted vdi object too. To achieve it,
> a parameter, include_deleted, is added to the function parse_vdi.
s/include_deleted/no_deleted looks better.
> The default value is false. But for cluster snapshot save, it is true.
>
> Functional test 030 is also updated to simulate the scenario.
>
> Reported-by: Valerio Pachera <sirio81 at gmail.com>
> Signed-off-by: Ruoyu <liangry at ucweb.com>
> ---
> dog/cluster.c | 5 +++--
> dog/common.c | 9 ++++++---
> dog/dog.h | 3 ++-
> dog/node.c | 2 +-
> dog/vdi.c | 19 +++++++++++--------
> tests/functional/030 | 14 ++++++++++++++
> tests/functional/030.out | 13 +++++++++++++
> 7 files changed, 50 insertions(+), 15 deletions(-)
>
> diff --git a/dog/cluster.c b/dog/cluster.c
> index 9cf96a8..86188e2 100644
> --- a/dog/cluster.c
> +++ b/dog/cluster.c
> @@ -419,7 +419,8 @@ static int save_snapshot(int argc, char **argv)
>
> opt.count = argc - optind;
> opt.name = argv + optind;
> - if (parse_vdi(fill_object_tree, SD_INODE_SIZE, &opt) != SD_RES_SUCCESS)
> + if (parse_vdi(fill_object_tree, SD_INODE_SIZE,
> + &opt, true) != SD_RES_SUCCESS)
> goto out;
>
> if (object_tree_size() == 0) {
> @@ -657,7 +658,7 @@ static void cluster_check_cb(uint32_t vid, const char *name, const char *tag,
>
> static int cluster_check(int argc, char **argv)
> {
> - if (parse_vdi(cluster_check_cb, SD_INODE_SIZE, NULL) < 0)
> + if (parse_vdi(cluster_check_cb, SD_INODE_SIZE, NULL, false) < 0)
> return EXIT_SYSFAIL;
>
> return EXIT_SUCCESS;
> diff --git a/dog/common.c b/dog/common.c
> index 2335e14..8cbf44c 100644
> --- a/dog/common.c
> +++ b/dog/common.c
> @@ -128,7 +128,8 @@ int dog_write_object(uint64_t oid, uint64_t cow_oid, void *data,
>
> #define FOR_EACH_VDI(nr, vdis) FOR_EACH_BIT(nr, vdis, SD_NR_VDIS)
>
> -int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
> +int parse_vdi(vdi_parser_func_t func, size_t size, void *data,
> + bool include_deleted)
> {
> int ret;
> unsigned long nr;
> @@ -163,8 +164,10 @@ int parse_vdi(vdi_parser_func_t func, size_t size, void *data)
> continue;
> }
>
> - if (i->name[0] == '\0') /* this VDI has been deleted */
> - continue;
> + if (!include_deleted) {
> + if (i->name[0] == '\0') /* this VDI has been deleted */
> + continue;
> + }
then
if (no_deleted && i->name[0] == '\0')
continue;
looks better self-explained.
Thanks
Yuan
More information about the sheepdog
mailing list