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 dso_state {
struct dm_pool *mem; struct dm_pool *mem;
int meta_percent_check; int metadata_percent_check;
int data_percent_check; int data_percent_check;
uint64_t known_meta_size; uint64_t known_metadata_size;
uint64_t known_data_size; uint64_t known_data_size;
char cmd_str[1024]; char cmd_str[1024];
}; };
@ -183,9 +183,9 @@ void process_event(struct dm_task *dmt,
#endif #endif
/* Thin pool size had changed. Clear the threshold. */ /* Thin pool size had changed. Clear the threshold. */
if (state->known_meta_size != tps->total_meta_blocks) { if (state->known_metadata_size != tps->total_metadata_blocks) {
state->meta_percent_check = CHECK_MINIMUM; state->metadata_percent_check = CHECK_MINIMUM;
state->known_meta_size = tps->total_meta_blocks; state->known_metadata_size = tps->total_metadata_blocks;
} }
if (state->known_data_size != tps->total_data_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; state->known_data_size = tps->total_data_blocks;
} }
percent = 100 * tps->used_meta_blocks / tps->total_meta_blocks; percent = 100 * tps->used_metadata_blocks / tps->total_metadata_blocks;
if (percent >= state->meta_percent_check) { if (percent >= state->metadata_percent_check) {
/* /*
* Usage has raised more than CHECK_STEP since the last * Usage has raised more than CHECK_STEP since the last
* time. Run actions. * 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! */ /* FIXME: extension of metadata needs to be written! */
if (percent >= WARNING_THRESH) /* Print a warning to syslog. */ if (percent >= WARNING_THRESH) /* Print a warning to syslog. */
@ -259,7 +259,7 @@ int register_device(const char *device,
} }
state->mem = statemem; state->mem = statemem;
state->meta_percent_check = CHECK_MINIMUM; state->metadata_percent_check = CHECK_MINIMUM;
state->data_percent_check = CHECK_MINIMUM; state->data_percent_check = CHECK_MINIMUM;
*private = state; *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. * This file is part of LVM2.
* *
@ -303,31 +303,28 @@ static int _thin_pool_target_percent(void **target_state __attribute__((unused))
percent_t *percent, percent_t *percent,
struct dm_pool *mem, struct dm_pool *mem,
struct cmd_context *cmd __attribute__((unused)), struct cmd_context *cmd __attribute__((unused)),
struct lv_segment *seg __attribute__((unused)), struct lv_segment *seg,
char *params, char *params,
uint64_t *total_numerator, uint64_t *total_numerator,
uint64_t *total_denominator) uint64_t *total_denominator)
{ {
struct dm_status_thin_pool *s; struct dm_status_thin_pool *s;
percent_t meta_percent;
percent_t data_percent;
if (!dm_get_status_thin_pool(mem, params, &s)) if (!dm_get_status_thin_pool(mem, params, &s))
return_0; return_0;
/* /* With seg report metadata percent, otherwice data percent */
* FIXME: how to handle exhaust of metadata space if (seg) {
* pick the max from data and meta? *percent = make_percent(s->used_metadata_blocks,
* Support for metadata resize is needed. s->total_metadata_blocks);
*/ *total_numerator += s->used_metadata_blocks;
meta_percent = make_percent(s->used_meta_blocks, *total_denominator += s->total_metadata_blocks;
s->total_meta_blocks); } else {
data_percent = make_percent(s->used_data_blocks, *percent = make_percent(s->used_data_blocks,
s->total_data_blocks); s->total_data_blocks);
*percent = data_percent;
*total_numerator += s->used_data_blocks; *total_numerator += s->used_data_blocks;
*total_denominator += s->total_data_blocks; *total_denominator += s->total_data_blocks;
}
return 1; return 1;
} }

View File

@ -243,10 +243,11 @@ struct dm_pool;
struct dm_status_thin_pool { struct dm_status_thin_pool {
uint64_t transaction_id; uint64_t transaction_id;
uint64_t used_meta_blocks; uint64_t used_metadata_blocks;
uint64_t total_meta_blocks; uint64_t total_metadata_blocks;
uint64_t used_data_blocks; uint64_t used_data_blocks;
uint64_t total_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, 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; return 0;
} }
/* FIXME: add support for held metadata root */
if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64, if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64,
&s->transaction_id, &s->transaction_id,
&s->used_meta_blocks, &s->used_metadata_blocks,
&s->total_meta_blocks, &s->total_metadata_blocks,
&s->used_data_blocks, &s->used_data_blocks,
&s->total_data_blocks) != 5) { &s->total_data_blocks) != 5) {
log_error("Failed to parse thin pool params: %s.", params); log_error("Failed to parse thin pool params: %s.", params);