master - cache+thin: add lv_is_{cache, thin}_origin fn to identify origin LVs
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8eba33510f95572316a743d6b68d5c7c31743672 Commit: 8eba33510f95572316a743d6b68d5c7c31743672 Parent: ec0d2f7aa4da4e433e26bc252626eae6febbe4d6 Author: Peter Rajnoha <[email protected]> AuthorDate: Fri Aug 15 13:08:30 2014 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Fri Aug 15 13:28:43 2014 +0200
cache+thin: add lv_is_{cache,thin}_origin fn to identify origin LVs
--- lib/metadata/cache_manip.c | 13 +++++++++++++ lib/metadata/metadata-exported.h | 2 ++ lib/metadata/thin_manip.c | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 0 deletions(-)
lib/metadata/cache_manip.c +13 -0
@@ -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); +}
lib/metadata/metadata-exported.h +2 -0
@@ -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);
lib/metadata/thin_manip.c +16 -0
@@ -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 ; +}