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

Thin use consistentely metadata

Do not shortcut to 'meta' and stay with 'metadata'
Also matches kernel doc for dm API then.
This commit is contained in:
Zdenek Kabelac 2012-01-19 15:21:23 +00:00
parent 64e353daec
commit 5fd459f0ab
4 changed files with 29 additions and 30 deletions

View File

@ -38,9 +38,9 @@
struct dso_state {
struct dm_pool *mem;
int meta_percent_check;
int metadata_percent_check;
int data_percent_check;
uint64_t known_meta_size;
uint64_t known_metadata_size;
uint64_t known_data_size;
char cmd_str[1024];
};
@ -183,9 +183,9 @@ void process_event(struct dm_task *dmt,
#endif
/* Thin pool size had changed. Clear the threshold. */
if (state->known_meta_size != tps->total_meta_blocks) {
state->meta_percent_check = CHECK_MINIMUM;
state->known_meta_size = tps->total_meta_blocks;
if (state->known_metadata_size != tps->total_metadata_blocks) {
state->metadata_percent_check = CHECK_MINIMUM;
state->known_metadata_size = tps->total_metadata_blocks;
}
if (state->known_data_size != tps->total_data_blocks) {
@ -193,13 +193,13 @@ void process_event(struct dm_task *dmt,
state->known_data_size = tps->total_data_blocks;
}
percent = 100 * tps->used_meta_blocks / tps->total_meta_blocks;
if (percent >= state->meta_percent_check) {
percent = 100 * tps->used_metadata_blocks / tps->total_metadata_blocks;
if (percent >= state->metadata_percent_check) {
/*
* Usage has raised more than CHECK_STEP since the last
* time. Run actions.
*/
state->meta_percent_check = (percent / CHECK_STEP) * CHECK_STEP + CHECK_STEP;
state->metadata_percent_check = (percent / CHECK_STEP) * CHECK_STEP + CHECK_STEP;
/* FIXME: extension of metadata needs to be written! */
if (percent >= WARNING_THRESH) /* Print a warning to syslog. */
@ -259,7 +259,7 @@ int register_device(const char *device,
}
state->mem = statemem;
state->meta_percent_check = CHECK_MINIMUM;
state->metadata_percent_check = CHECK_MINIMUM;
state->data_percent_check = CHECK_MINIMUM;
*private = state;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
* Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@ -303,31 +303,28 @@ static int _thin_pool_target_percent(void **target_state __attribute__((unused))
percent_t *percent,
struct dm_pool *mem,
struct cmd_context *cmd __attribute__((unused)),
struct lv_segment *seg __attribute__((unused)),
struct lv_segment *seg,
char *params,
uint64_t *total_numerator,
uint64_t *total_denominator)
{
struct dm_status_thin_pool *s;
percent_t meta_percent;
percent_t data_percent;
if (!dm_get_status_thin_pool(mem, params, &s))
return_0;
/*
* FIXME: how to handle exhaust of metadata space
* pick the max from data and meta?
* Support for metadata resize is needed.
*/
meta_percent = make_percent(s->used_meta_blocks,
s->total_meta_blocks);
data_percent = make_percent(s->used_data_blocks,
/* With seg report metadata percent, otherwice data percent */
if (seg) {
*percent = make_percent(s->used_metadata_blocks,
s->total_metadata_blocks);
*total_numerator += s->used_metadata_blocks;
*total_denominator += s->total_metadata_blocks;
} else {
*percent = make_percent(s->used_data_blocks,
s->total_data_blocks);
*percent = data_percent;
*total_numerator += s->used_data_blocks;
*total_denominator += s->total_data_blocks;
}
return 1;
}

View File

@ -243,10 +243,11 @@ struct dm_pool;
struct dm_status_thin_pool {
uint64_t transaction_id;
uint64_t used_meta_blocks;
uint64_t total_meta_blocks;
uint64_t used_metadata_blocks;
uint64_t total_metadata_blocks;
uint64_t used_data_blocks;
uint64_t total_data_blocks;
uint64_t held_metadata_root;
};
int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,

View File

@ -3117,10 +3117,11 @@ int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
return 0;
}
/* FIXME: add support for held metadata root */
if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64,
&s->transaction_id,
&s->used_meta_blocks,
&s->total_meta_blocks,
&s->used_metadata_blocks,
&s->total_metadata_blocks,
&s->used_data_blocks,
&s->total_data_blocks) != 5) {
log_error("Failed to parse thin pool params: %s.", params);