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:
parent
ec0d2f7aa4
commit
8eba33510f
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user