diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2012-11-26 11:20:13 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2012-11-26 12:16:47 +0100 |
commit | 1ef98310187a7b287255cacd4b56160e48100d03 (patch) | |
tree | e815161b4cc1299ab4e9f0d1826cb894ed8f7678 /tools/toollib.c | |
parent | 953080e4fc271ad200736f3584f41e24dfe063ca (diff) | |
download | lvm2-1ef98310187a7b287255cacd4b56160e48100d03.tar.gz |
thin: support configurable thin pool defaults
Configurable settings for thin pool create
if they are not specified on command line.
New supported lvm.conf options are:
allocation/thin_pool_chunk_size
allocation/thin_pool_discards
allocation/thin_pool_zero
Diffstat (limited to 'tools/toollib.c')
-rw-r--r-- | tools/toollib.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/tools/toollib.c b/tools/toollib.c index ba1ba94b5..4c9a43d05 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1528,20 +1528,41 @@ int get_pool_params(struct cmd_context *cmd, uint64_t *pool_metadata_size, int *zero) { - if (arg_count(cmd, zero_ARG)) - *zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n"); - else - *zero = 1; /* TODO: Make default configurable */ - - *discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, - THIN_DISCARDS_PASSDOWN); + const char *dstr; - if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) { - log_error("Negative chunk size is invalid."); - return 0; + if (arg_count(cmd, zero_ARG)) { + *zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n"); + log_very_verbose("Setting pool zeroing: %u", *zero); + } else + *zero = find_config_tree_int(cmd, + "allocation/thin_pool_zero", + DEFAULT_THIN_POOL_ZERO); + + if (arg_count(cmd, discards_ARG)) { + *discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, 0); + log_very_verbose("Setting pool discards: %s", + get_pool_discards_name(*discards)); + } else { + dstr = find_config_tree_str(cmd, + "allocation/thin_pool_discards", + DEFAULT_THIN_POOL_DISCARDS); + if (!get_pool_discards(dstr, discards)) + return_0; } - *chunk_size = arg_uint_value(cmd, chunksize_ARG, - DM_THIN_MIN_DATA_BLOCK_SIZE); + + if (arg_count(cmd, chunksize_ARG)) { + if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) { + log_error("Negative chunk size is invalid."); + return 0; + } + *chunk_size = arg_uint_value(cmd, chunksize_ARG, + DM_THIN_MIN_DATA_BLOCK_SIZE); + log_very_verbose("Setting pool chunk size: %s", + display_size(cmd, *chunk_size)); + } else + *chunk_size = find_config_tree_int(cmd, + "allocation/thin_pool_chunk_size", + DEFAULT_THIN_POOL_CHUNK_SIZE) * 2; if ((*chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE) || (*chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE)) { @@ -1619,7 +1640,8 @@ int update_pool_params(struct cmd_context *cmd, unsigned attr, else if (*chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE) *chunk_size = DM_THIN_MAX_DATA_BLOCK_SIZE; - log_verbose("Setting chunk size %uKiB.", *chunk_size / 2); + log_verbose("Setting chunk size %s.", + display_size(cmd, *chunk_size)); } else if (*chunk_size < estimate_chunk_size) { /* Suggest bigger chunk size */ log_warn("WARNING: Chunk size is smaller then suggested minimum size %s.", |