1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-29 06:50:38 +03:00

thin: add helper functions

Add find_pool_lv() and pool_can_resize_metadata().
This commit is contained in:
Zdenek Kabelac 2013-06-11 12:32:01 +02:00
parent 55a3859632
commit 72c3ae253e
3 changed files with 35 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
Add helper functions find_pool_lv() and pool_can_resize_metadata().
Add detection for thin pool metadata resize kernel support.
Report lvs volume type 'e' with higher priority.
Report lvs volume type 'o' also for external origin volumes.

View File

@ -578,7 +578,9 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
uint32_t extent_size);
struct logical_volume *find_pool_lv(struct logical_volume *lv);
int pool_is_active(const struct logical_volume *pool_lv);
int pool_can_resize_metadata(const struct logical_volume *pool_lv);
int update_pool_lv(struct logical_volume *lv, int activate);
int update_pool_params(struct cmd_context *cmd, unsigned attr, int passed_args,
uint32_t data_extents, uint32_t extent_size,

View File

@ -309,6 +309,28 @@ int pool_is_active(const struct logical_volume *lv)
return 0;
}
int pool_can_resize_metadata(const struct logical_volume *lv)
{
static unsigned attr = 0U;
struct lv_segment *seg;
if (!lv_is_thin_pool(lv)) {
log_error(INTERNAL_ERROR "LV %s is not thin pool.", lv->name);
return 0;
}
seg = first_seg(lv);
if ((attr == 0U) && activation() && seg->segtype &&
seg->segtype->ops->target_present &&
!seg->segtype->ops->target_present(lv->vg->cmd, NULL, &attr)) {
log_error("%s: Required device-mapper target(s) not "
"detected in your kernel", seg->segtype->name);
return 0;
}
return (attr & THIN_FEATURE_METADATA_RESIZE) ? 1 : 0;
}
int pool_below_threshold(const struct lv_segment *pool_seg)
{
percent_t percent;
@ -352,6 +374,16 @@ struct lv_segment *find_pool_seg(const struct lv_segment *seg)
return pool_seg;
}
struct logical_volume *find_pool_lv(struct logical_volume *lv)
{
struct lv_segment *seg;
if (!(seg = find_pool_seg(first_seg(lv))))
return_NULL;
return seg->lv;
}
/*
* Find a free device_id for given thin_pool segment.
*