1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

cache+thin: add lv_is_{cache,thin}_origin fn to identify origin LVs

This commit is contained in:
Peter Rajnoha 2014-08-15 13:08:30 +02:00
parent ec0d2f7aa4
commit 8eba33510f
3 changed files with 31 additions and 0 deletions

View File

@ -314,3 +314,16 @@ int get_cache_mode(const char *str, uint32_t *flags)
return 1;
}
int lv_is_cache_origin(const struct logical_volume *lv)
{
struct lv_segment *seg;
/* Make sure there's exactly one segment in segs_using_this_lv! */
if (dm_list_empty(&lv->segs_using_this_lv) ||
(dm_list_size(&lv->segs_using_this_lv) > 1))
return 0;
seg = get_only_segment_using_this_lv(lv);
return seg && lv_is_cache(seg->lv) && (seg_lv(seg, 0) == lv);
}

View File

@ -921,6 +921,8 @@ int lv_is_striped(const struct logical_volume *lv);
*/
int lv_is_origin(const struct logical_volume *lv);
int lv_is_virtual_origin(const struct logical_volume *lv);
int lv_is_thin_origin(const struct logical_volume *lv);
int lv_is_cache_origin(const struct logical_volume *lv);
int lv_is_cow(const struct logical_volume *lv);
int lv_is_merging_origin(const struct logical_volume *origin);
int lv_is_merging_cow(const struct logical_volume *snapshot);

View File

@ -499,3 +499,19 @@ const char *get_pool_discards_name(thin_discards_t discards)
return "unknown";
}
int lv_is_thin_origin(const struct logical_volume *lv)
{
struct seg_list *segl;
if (!lv_is_thin_volume(lv) ||
dm_list_empty(&lv->segs_using_this_lv))
return 0;
dm_list_iterate_items(segl, &lv->segs_using_this_lv) {
if (segl->seg->origin == lv)
return 1;
}
return 0;
}