if (lv_is_vdo(lv))
return seg_lv(first_seg(lv), 0);
+ if (lv_is_writecache(lv))
+ return first_seg(lv)->writecache;
+
return NULL;
}
repstr[0] = 'l';
else if (lv_is_cow(lv))
repstr[0] = (lv_is_merging_cow(lv)) ? 'S' : 's';
- else if (lv_is_cache_origin(lv))
+ else if (lv_is_cache_origin(lv) || lv_is_writecache_origin(lv))
repstr[0] = 'o';
else
repstr[0] = '-';
if (lv_is_thin_pool(lv) || lv_is_thin_volume(lv))
repstr[6] = 't';
- else if (lv_is_cache_pool(lv) || lv_is_cache_vol(lv) || lv_is_cache(lv) || lv_is_cache_origin(lv))
+ else if (lv_is_cache_pool(lv) ||
+ lv_is_cache_vol(lv) ||
+ lv_is_cache(lv) ||
+ lv_is_cache_origin(lv) ||
+ lv_is_writecache(lv) ||
+ lv_is_writecache_origin(lv))
repstr[6] = 'C';
else if (lv_is_raid_type(lv))
repstr[6] = 'r';
#define lv_is_removed(lv) (((lv)->status & LV_REMOVED) ? 1 : 0)
/* Recognize component LV (matching lib/misc/lvm-string.c _lvname_has_reserved_component_string()) */
-#define lv_is_component(lv) (lv_is_cache_origin(lv) || ((lv)->status & (\
- CACHE_POOL_DATA |\
- CACHE_POOL_METADATA |\
- LV_VDO_POOL_DATA |\
- MIRROR_IMAGE |\
- MIRROR_LOG |\
- RAID_IMAGE |\
- RAID_META |\
- THIN_POOL_DATA |\
- THIN_POOL_METADATA)) ? 1 : 0)
+#define lv_is_component(lv) (lv_is_cache_origin(lv) || \
+ lv_is_writecache_origin(lv) || \
+ ((lv)->status & (\
+ CACHE_POOL_DATA |\
+ CACHE_POOL_METADATA |\
+ LV_CACHE_VOL |\
+ LV_VDO_POOL_DATA |\
+ MIRROR_IMAGE |\
+ MIRROR_LOG |\
+ RAID_IMAGE |\
+ RAID_META |\
+ THIN_POOL_DATA |\
+ THIN_POOL_METADATA)) ? 1 : 0)
int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
struct dm_list **layout, struct dm_list **role);
#define lv_is_thick_snapshot lv_is_cow
int lv_is_cache_origin(const struct logical_volume *lv);
+int lv_is_writecache_origin(const struct logical_volume *lv);
int lv_is_merging_cow(const struct logical_volume *cow);
uint32_t cow_max_extents(const struct logical_volume *origin, uint32_t chunk_size);
return vg;
}
+
+int lv_is_writecache_origin(const struct logical_volume *lv)
+{
+ struct seg_list *sl;
+
+ dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
+ if (!sl->seg || !sl->seg->lv || !sl->seg->origin)
+ continue;
+ if (lv_is_writecache(sl->seg->lv) && (sl->seg->origin == lv))
+ return 1;
+ }
+ return 0;
+}
+
"_cmeta",
"_corig",
"_cvol",
+ "_wcorig",
"_mimage",
"_mlog",
"_rimage",
*/
/* Suffixes used here MUST match lib/activate/dev_manager.c */
layer = lv_is_cache_origin(lv) ? "real" :
+ lv_is_writecache_origin(lv) ? "real" :
(lv_is_cache(lv) && lv_is_pending_delete(lv)) ? "real" :
lv_is_cache_pool_data(lv) ? "cdata" :
lv_is_cache_pool_metadata(lv) ? "cmeta" :
if ((pmem = lv_on_pmem(seg->writecache)) < 0)
return_0;
- if (!(origin_uuid = build_dm_uuid(mem, seg_lv(seg, 0), NULL)))
+ if (!(origin_uuid = build_dm_uuid(mem, seg_lv(seg, 0), "real")))
return_0;
- if (!(fast_uuid = build_dm_uuid(mem, seg->writecache, NULL)))
+ if (!(fast_uuid = build_dm_uuid(mem, seg->writecache, "cvol")))
return_0;
if (!dm_tree_node_add_writecache_target(node, len,
lv->status &= ~WRITECACHE;
seg->writecache = NULL;
+ lv_fast->status &= ~LV_CACHE_VOL;
+
if (!remove_layer_from_lv(lv, origin))
return_0;
if (!archive(vg))
goto_bad;
+ lv_fast->status |= LV_CACHE_VOL;
+
/*
* TODO: use libblkid to get the sector size of lv. If it doesn't
* match the block_size we are using for the writecache, then warn that