summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2022-01-31 16:12:24 -0600
committerDavid Teigland <teigland@redhat.com>2022-01-31 16:59:37 -0600
commitf0cd54a873880286e0932c5cb38a9572677bee25 (patch)
tree1f95070497f815ae6682e5b82f1eb382e92195f1
parentffa07c8e398232150794767e05b95893c7b737b6 (diff)
downloadlvm2-f0cd54a873880286e0932c5cb38a9572677bee25.tar.gz
writecache: look for settings in lvm.conf
Restore the lvm.conf cache_settings for writecache added by c6639056e0bb2fc5f072b2c0d6bb629ad17eee6e. Shorter method reduces and isolates the complexity of config trees.
-rw-r--r--WHATS_NEW1
-rw-r--r--tools/toollib.c46
2 files changed, 47 insertions, 0 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index e2f6e166b..16235514e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.15 -
===================================
+ Improve support for metadata profiles for --type writecache.
Use cache or active DM device when available with new kernels.
Introduce function to utilize UUIDs from DM_DEVICE_LIST.
Increase some hash table size to better support large device sets.
diff --git a/tools/toollib.c b/tools/toollib.c
index c23f55c07..b08c044fa 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1317,12 +1317,15 @@ static int _get_one_writecache_setting(struct cmd_context *cmd, struct writecach
int get_writecache_settings(struct cmd_context *cmd, struct writecache_settings *settings,
uint32_t *block_size_sectors)
{
+ const struct dm_config_node *cns, *cn1, *cn2;
struct arg_value_group_list *group;
const char *str;
char key[64];
char val[64];
int num;
int pos;
+ int rn;
+ int found = 0;
/*
* "grouped" means that multiple --cachesettings options can be used.
@@ -1354,8 +1357,51 @@ int get_writecache_settings(struct cmd_context *cmd, struct writecache_settings
if (!_get_one_writecache_setting(cmd, settings, key, val, block_size_sectors))
return_0;
}
+ found = 1;
}
+ if (found)
+ goto out;
+
+ /*
+ * If there were no settings on the command line, look for settings in
+ * lvm.conf
+ *
+ * TODO: support profiles
+ */
+
+ if (!(cns = find_config_tree_node(cmd, allocation_cache_settings_CFG_SECTION, NULL)))
+ goto out;
+
+ for (cn1 = cns->child; cn1; cn1 = cn1->sib) {
+ if (!cn1->child)
+ continue; /* Ignore section without settings */
+
+ if (cn1->v || strcmp(cn1->key, "writecache") != 0)
+ continue; /* Ignore non-matching settings */
+
+ cn2 = cn1->child;
+
+ for (; cn2; cn2 = cn2->sib) {
+ memset(val, 0, sizeof(val));
+
+ if (cn2->v->type == DM_CFG_INT)
+ rn = dm_snprintf(val, sizeof(val), FMTd64, cn2->v->v.i);
+ else if (cn2->v->type == DM_CFG_STRING)
+ rn = dm_snprintf(val, sizeof(val), "%s", cn2->v->v.str);
+ else
+ rn = -1;
+ if (rn < 0) {
+ log_error("Invalid lvm.conf writecache setting value for %s.", cn2->key);
+ return 0;
+ }
+
+ if (!_get_one_writecache_setting(cmd, settings, (char *)cn2->key, val, block_size_sectors))
+ return_0;
+ }
+ }
+
+ out:
if (settings->high_watermark_set && settings->low_watermark_set &&
(settings->high_watermark <= settings->low_watermark)) {
log_error("High watermark must be greater than low watermark.");