1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2013-02-05 10:52:39 +01:00
parent 9d445f371c
commit 11eaf1c98c
3 changed files with 29 additions and 0 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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;