1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Thin add pool_below_threshold

Test both data and metadata percent usage.
This commit is contained in:
Zdenek Kabelac 2012-02-08 13:05:38 +00:00
parent cdcf7aaf07
commit a7e2da0585
4 changed files with 40 additions and 15 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.91 - Version 2.02.91 -
=================================== ===================================
Add pool_below_threshold() function to check thin pool percent status.
Fix test for snap percent for failing merge when removing LV. Fix test for snap percent for failing merge when removing LV.
Switch int to void return for str_list_del(). Switch int to void return for str_list_del().
Fix error path handling in _build_desc(). Fix error path handling in _build_desc().

View File

@ -4054,7 +4054,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
struct logical_volume *lv, *org = NULL; struct logical_volume *lv, *org = NULL;
struct logical_volume *pool_lv; struct logical_volume *pool_lv;
struct lv_list *lvl; struct lv_list *lvl;
percent_t percent;
int origin_active = 0; int origin_active = 0;
struct lvinfo info; struct lvinfo info;
@ -4375,26 +4374,20 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
if (seg_is_thin(lp)) { if (seg_is_thin(lp)) {
/* For snapshot, suspend active thin origin first */ /* For snapshot, suspend active thin origin first */
if (org && lv_is_active(org)) { if (org && lv_is_active(org)) {
/* Check if the pool is bellow threshold (Works only for active thin) */ if (!pool_below_threshold(first_seg(first_seg(org)->pool_lv))) {
if (!lv_thin_pool_percent(first_seg(org)->pool_lv, 0, &percent)) { log_error("Cannot create thin snapshot. Pool %s/%s is filled "
stack; "over the autoextend threshold.",
goto revert_new_lv; org->vg->name, first_seg(org)->pool_lv->name);
}
percent /= PERCENT_1;
if (percent >= (find_config_tree_int(cmd, "activation/thin_pool_autoextend_threshold",
DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD))) {
log_error("Failed to create snapshot, pool is filled over "
"the autoextend threshold (%d%%).", percent);
goto revert_new_lv; goto revert_new_lv;
} }
if (!suspend_lv_origin(cmd, org)) { if (!suspend_lv_origin(cmd, org)) {
log_error("Failed to suspend thin snapshot origin %s.", log_error("Failed to suspend thin snapshot origin %s/%s.",
org->name); org->vg->name, org->name);
goto revert_new_lv; goto revert_new_lv;
} }
if (!resume_lv_origin(cmd, org)) { /* deptree updates thin-pool */ if (!resume_lv_origin(cmd, org)) { /* deptree updates thin-pool */
log_error("Failed to resume thin snapshot origin %s.", log_error("Failed to resume thin snapshot origin %s/%s.",
org->name); org->vg->name, org->name);
goto revert_new_lv; goto revert_new_lv;
} }
/* At this point remove pool messages, snapshot is active */ /* At this point remove pool messages, snapshot is active */

View File

@ -464,6 +464,7 @@ int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
int auto_increment); int auto_increment);
int pool_has_message(const struct lv_segment *seg, int pool_has_message(const struct lv_segment *seg,
const struct logical_volume *lv, uint32_t device_id); const struct logical_volume *lv, uint32_t device_id);
int pool_below_threshold(const struct lv_segment *pool_seg);
int extend_pool(struct logical_volume *lv, const struct segment_type *segtype, int extend_pool(struct logical_volume *lv, const struct segment_type *segtype,
struct alloc_handle *ah, uint32_t stripes, uint32_t stripe_size); struct alloc_handle *ah, uint32_t stripes, uint32_t stripe_size);

View File

@ -19,6 +19,7 @@
#include "segtype.h" #include "segtype.h"
#include "lv_alloc.h" #include "lv_alloc.h"
#include "archiver.h" #include "archiver.h"
#include "defaults.h"
int attach_pool_metadata_lv(struct lv_segment *pool_seg, struct logical_volume *metadata_lv) int attach_pool_metadata_lv(struct lv_segment *pool_seg, struct logical_volume *metadata_lv)
{ {
@ -215,6 +216,35 @@ int pool_has_message(const struct lv_segment *seg,
return 0; return 0;
} }
int pool_below_threshold(const struct lv_segment *pool_seg)
{
percent_t percent;
int threshold = PERCENT_1 *
find_config_tree_int(pool_seg->lv->vg->cmd,
"activation/thin_pool_autoextend_threshold",
DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD);
/* Data */
if (!lv_thin_pool_percent(pool_seg->lv, 0, &percent)) {
stack;
return 0;
}
if (percent >= threshold)
return 0;
/* Metadata */
if (!lv_thin_pool_percent(pool_seg->lv, 1, &percent)) {
stack;
return 0;
}
if (percent >= threshold)
return 0;
return 1;
}
struct lv_segment *find_pool_seg(const struct lv_segment *seg) struct lv_segment *find_pool_seg(const struct lv_segment *seg)
{ {
struct lv_segment *pool_seg; struct lv_segment *pool_seg;