When we executing a cluster snapshot load command with specified vdi,
deleted vdi object should be also loaded for the reason of keeping
cluster consistancy.

Signed-off-by: Ruoyu <lian...@ucweb.com>
---
 dog/farm/farm.c | 5 +++++
 dog/farm/farm.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/dog/farm/farm.c b/dog/farm/farm.c
index 83c297f..c87d488 100644
--- a/dog/farm/farm.c
+++ b/dog/farm/farm.c
@@ -487,6 +487,9 @@ static int visit_vdi_obj_entry(struct trunk_entry *entry, 
void *data)
        if (opt->count == 0) {
                if (opt->enable_if_blank)
                        opt->func(inode);
+       } else if (inode->name[0] == '\0') {
+               if (opt->enable_if_deleted)
+                       opt->func(inode);
        } else {
                for (int i = 0; i < opt->count; i++)
                        if (!strcmp(inode->name, opt->name[i])) {
@@ -541,6 +544,7 @@ int farm_load_snapshot(uint32_t idx, const char *tag, int 
count, char **name)
        opt.name = name;
        opt.func = register_obj;
        opt.enable_if_blank = false;
+       opt.enable_if_deleted = true;
 
        if (for_each_entry_in_trunk(trunk_sha1, visit_vdi_obj_entry, &opt) < 0)
                goto out;
@@ -592,6 +596,7 @@ int farm_show_snapshot(uint32_t idx, const char *tag, int 
count, char **name)
        opt.name = name;
        opt.func = print_vdi;
        opt.enable_if_blank = true;
+       opt.enable_if_deleted = false;
 
        if (for_each_entry_in_trunk(trunk_sha1, visit_vdi_obj_entry, &opt) < 0)
                goto out;
diff --git a/dog/farm/farm.h b/dog/farm/farm.h
index f4ec47f..0b86c0a 100644
--- a/dog/farm/farm.h
+++ b/dog/farm/farm.h
@@ -55,6 +55,7 @@ struct vdi_option {
        char **name;
        void (*func)(struct sd_inode *inode);
        bool enable_if_blank;
+       bool enable_if_deleted;
 };
 
 /* farm.c */
-- 
1.8.3.2


-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to