1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

writecache: display layout and role fields

This commit is contained in:
David Teigland 2019-09-20 14:54:00 -05:00
parent 6f7d7089b4
commit 27c3c1d7c8
3 changed files with 44 additions and 3 deletions

View File

@ -131,7 +131,10 @@ enum {
LV_TYPE_RAID6_NR, LV_TYPE_RAID6_NR,
LV_TYPE_RAID6_NC, LV_TYPE_RAID6_NC,
LV_TYPE_LOCKD, LV_TYPE_LOCKD,
LV_TYPE_SANLOCK LV_TYPE_SANLOCK,
LV_TYPE_CACHEVOL,
LV_TYPE_WRITECACHE,
LV_TYPE_WRITECACHEORIGIN
}; };
static const char *_lv_type_names[] = { static const char *_lv_type_names[] = {
@ -184,6 +187,9 @@ static const char *_lv_type_names[] = {
[LV_TYPE_RAID6_NC] = SEG_TYPE_NAME_RAID6_NC, [LV_TYPE_RAID6_NC] = SEG_TYPE_NAME_RAID6_NC,
[LV_TYPE_LOCKD] = "lockd", [LV_TYPE_LOCKD] = "lockd",
[LV_TYPE_SANLOCK] = "sanlock", [LV_TYPE_SANLOCK] = "sanlock",
[LV_TYPE_CACHEVOL] = "cachevol",
[LV_TYPE_WRITECACHE] = "writecache",
[LV_TYPE_WRITECACHEORIGIN] = "writecacheorigin",
}; };
static int _lv_layout_and_role_mirror(struct dm_pool *mem, static int _lv_layout_and_role_mirror(struct dm_pool *mem,
@ -410,6 +416,14 @@ static int _lv_layout_and_role_cache(struct dm_pool *mem,
if (lv_is_cache(lv) && if (lv_is_cache(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE])) !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
goto_bad; goto_bad;
} else if (lv_is_writecache_origin(lv)) {
if (!str_list_add(mem, role, _lv_type_names[LV_TYPE_WRITECACHE]) ||
!str_list_add(mem, role, _lv_type_names[LV_TYPE_ORIGIN]) ||
!str_list_add_no_dup_check(mem, role, _lv_type_names[LV_TYPE_WRITECACHEORIGIN]))
goto_bad;
if (lv_is_writecache(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_WRITECACHE]))
goto_bad;
} else } else
top_level = 1; top_level = 1;
@ -422,7 +436,20 @@ static int _lv_layout_and_role_cache(struct dm_pool *mem,
if (lv_is_cache(lv) && if (lv_is_cache(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE])) !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
goto_bad; goto_bad;
else if (lv_is_cache_pool(lv) || lv_is_cache_vol(lv)) { else if (lv_is_writecache(lv) &&
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_WRITECACHE]))
goto_bad;
else if (lv_is_writecache_cachevol(lv)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_WRITECACHE]) ||
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHEVOL]))
goto_bad;
*public_lv = 0;
} else if (lv_is_cache_vol(lv)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]) ||
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHEVOL]))
goto_bad;
*public_lv = 0;
} else if (lv_is_cache_pool(lv)) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]) || if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]) ||
!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL])) !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_POOL]))
goto_bad; goto_bad;
@ -546,7 +573,7 @@ int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
goto_bad; goto_bad;
/* Caches and related */ /* Caches and related */
if ((lv_is_cache_type(lv) || lv_is_cache_origin(lv)) && if ((lv_is_cache_type(lv) || lv_is_cache_origin(lv) || lv_is_writecache(lv) || lv_is_writecache_origin(lv)) &&
!_lv_layout_and_role_cache(mem, lv, *layout, *role, &public_lv)) !_lv_layout_and_role_cache(mem, lv, *layout, *role, &public_lv))
goto_bad; goto_bad;

View File

@ -1081,6 +1081,7 @@ int lv_is_cow(const struct logical_volume *lv);
int lv_is_cache_origin(const struct logical_volume *lv); int lv_is_cache_origin(const struct logical_volume *lv);
int lv_is_writecache_origin(const struct logical_volume *lv); int lv_is_writecache_origin(const struct logical_volume *lv);
int lv_is_writecache_cachevol(const struct logical_volume *lv);
int lv_is_merging_cow(const struct logical_volume *cow); int lv_is_merging_cow(const struct logical_volume *cow);
uint32_t cow_max_extents(const struct logical_volume *origin, uint32_t chunk_size); uint32_t cow_max_extents(const struct logical_volume *origin, uint32_t chunk_size);

View File

@ -5180,3 +5180,16 @@ int lv_is_writecache_origin(const struct logical_volume *lv)
return 0; return 0;
} }
int lv_is_writecache_cachevol(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->writecache)
continue;
if (lv_is_writecache(sl->seg->lv) && (sl->seg->writecache == lv))
return 1;
}
return 0;
}