If refreshed inode is snapshot, we can reload entire inode and switch to working VDI immediately. Cc: Teruaki Ishizaki <ishizaki.teruaki@xxxxxxxxxxxxx> Cc: Takashi Menjo <menjo.takashi@xxxxxxxxxxxxx> Tested-by: Takashi Menjo <menjo.takashi@xxxxxxxxxxxxx> Signed-off-by: Hitoshi Mitake <mitake.hitoshi@xxxxxxxxxxxxx> --- usr/bs_sheepdog.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/usr/bs_sheepdog.c b/usr/bs_sheepdog.c index ecb5033..8f228b5 100644 --- a/usr/bs_sheepdog.c +++ b/usr/bs_sheepdog.c @@ -704,6 +704,34 @@ static int reload_inode(struct sheepdog_access_info *ai, int is_snapshot) ret = -1; goto ret; } + + if (!!ai->inode.snap_ctime) { + /* + * This is a case like below: + * take snapshot -> write something -> failover + * + * Because invalidated inode is readonly and latest + * working VDI can have COWed objects, we need to + * resolve VID and reload its entire inode object. + */ + memset(tag, 0, sizeof(tag)); + + ret = find_vdi_name(ai, ai->inode.name, CURRENT_VDI_ID, + tag, &vid, 0); + if (ret) { + ret = -1; + goto ret; + } + + ret = read_object(ai, (char *)&ai->inode, + vid_to_vdi_oid(vid), + ai->inode.nr_copies, SD_INODE_SIZE, 0, + &need_reload); + if (ret) { + ret = -1; + goto ret; + } + } } ai->min_dirty_data_idx = UINT32_MAX; -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html