master - thin: add function pool_is_active
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=11eaf1c98c3fac8524f227956f57c3d486740a1a Commit: 11eaf1c98c3fac8524f227956f57c3d486740a1a Parent: 9d445f371c7658969d6580748233dc33c3ba0453 Author: Zdenek Kabelac <[email protected]> AuthorDate: Tue Feb 5 10:52:39 2013 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Tue Feb 5 14:35:44 2013 +0100
thin: add function pool_is_active
This internal function check for active pool device. For cluster it checks every thin volume,
On the non-clustered VG we need to check just for presence of -tpool device.
--- WHATS_NEW | 1 + lib/metadata/metadata.h | 1 + lib/metadata/thin_manip.c | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 0 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.99 - =================================== + Add pool_is_active() to check for any pool related active LV. Report blank field if the LV doesn't have an origin instead of 0. Do not take a free lv name argument for lvconvert --thinpool option. Avoid flushing thin pool when quering for transaction_id.
lib/metadata/metadata.h +1 -0
@@ -472,6 +472,7 @@ int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type, int auto_increment);int pool_has_message (const struct lv_segment *seg,const struct logical_volume *lv,uint32_t device_id); +int pool_is_active (const struct lv_segment *pool_seg);int pool_below_threshold (const struct lv_segment *pool_seg);int extend_pool (struct logical_volume *lv,const struct segment_type *segtype,struct alloc_handle *ah,uint32_t stripes,uint32_t stripe_size);
lib/metadata/thin_manip.c +27 -0
@@ -230,6 +230,33 @@ int pool_has_message(const struct lv_segment *seg,return 0 ; } +int pool_is_active (const struct lv_segment *pool_seg) +{ +struct lvinfo info; +const struct seg_list *sl; +const struct logical_volume *lv = pool_seg->lv; + +if (!seg_is_thin_pool (pool_seg)) { +log_error (INTERNAL_ERROR "LV %s is not pool." , lv->name); +return 0 ; + } + +/* On clustered VG, query every related thin pool volume */ +if (vg_is_clustered (lv->vg)) { +if (lv_is_active (lv)) +return 1 ; + + dm_list_iterate_items(sl, &lv->segs_using_this_lv) +if (lv_is_active (sl->seg->lv)) { +log_debug ("Thin volume \"%s\" is active." , sl->seg->lv->name); +return 1 ; + } + }else if (lv_info (lv->vg->cmd, lv,1 , &info,0 ,0 ) && info.exists) +return 1 ;/* Non clustered VG - just checks for '-tpool' */ + +return 0 ; +} +int pool_below_threshold (const struct lv_segment *pool_seg) {percent_t percent;