main - lvcreate: code move
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7f1f7ad694201533c04...
Commit: 7f1f7ad694201533c04ddfbe9ba047f832b38750
Parent: 89cec5b65af5533bcde358d8d4f7d1d5701a341b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jan 18 17:33:53 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 26 15:09:58 2022 +0100
lvcreate: code move
---
tools/lvcreate.c | 48 ++++++++++++++++++++++--------------------------
1 file changed, 22 insertions(+), 26 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 2c519d555..b58fd62bb 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1851,30 +1851,28 @@ static int _lvcreate_and_attach_writecache_single(struct cmd_context *cmd,
int lvcreate_and_attach_writecache_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle = NULL;
- struct processing_params pp;
struct lvcreate_params lp = {
.major = -1,
.minor = -1,
+ /*
+ * Tell lvcreate to ignore --type since we are using lvcreate
+ * to create a linear LV and using lvconvert to add cache.
+ * (Would be better if lvcreate code was split up so we could
+ * call a specific function that just created a linear/striped LV.)
+ */
+ .ignore_type = 1,
};
struct lvcreate_cmdline_params lcp = { 0 };
+ struct processing_params pp = {
+ .lp = &lp,
+ .lcp = &lcp,
+ };
int ret;
-
- /*
- * Tell lvcreate to ignore --type since we are using lvcreate
- * to create a linear LV and using lvconvert to add cache.
- * (Would be better if lvcreate code was split up so we could
- * call a specific function that just created a linear/striped LV.)
- */
- lp.ignore_type = 1;
-
if (!_lvcreate_params(cmd, argc, argv, &lp, &lcp)) {
stack;
return EINVALID_CMD_LINE;
}
- pp.lp = &lp;
- pp.lcp = &lcp;
-
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
@@ -1925,30 +1923,29 @@ static int _lvcreate_and_attach_cache_single(struct cmd_context *cmd,
int lvcreate_and_attach_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle = NULL;
- struct processing_params pp;
struct lvcreate_params lp = {
.major = -1,
.minor = -1,
+ /*
+ * Tell lvcreate to ignore --type since we are using lvcreate
+ * to create a linear LV and using lvconvert to add cache.
+ * (Would be better if lvcreate code was split up so we could
+ * call a specific function that just created a linear/striped LV.)
+ */
+ .ignore_type = 1,
};
struct lvcreate_cmdline_params lcp = { 0 };
+ struct processing_params pp = {
+ .lp = &lp,
+ .lcp = &lcp,
+ };
int ret;
- /*
- * Tell lvcreate to ignore --type since we are using lvcreate
- * to create a linear LV and using lvconvert to add cache.
- * (Would be better if lvcreate code was split up so we could
- * call a specific function that just created a linear/striped LV.)
- */
- lp.ignore_type = 1;
-
if (!_lvcreate_params(cmd, argc, argv, &lp, &lcp)) {
stack;
return EINVALID_CMD_LINE;
}
- pp.lp = &lp;
- pp.lcp = &lcp;
-
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
@@ -1963,4 +1960,3 @@ int lvcreate_and_attach_cache_cmd(struct cmd_context *cmd, int argc, char **argv
destroy_processing_handle(cmd, handle);
return ret;
}
-
2 years, 3 months
main - test: check writecache profile support
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=89cec5b65af5533bcde...
Commit: 89cec5b65af5533bcde358d8d4f7d1d5701a341b
Parent: b95506815fa149cf135687cbe047b7bdfcd6e00f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 24 14:49:53 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 26 15:09:58 2022 +0100
test: check writecache profile support
FIXME
---
test/shell/profiles-cache.sh | 10 ++++++++++
test/shell/writecache-misc.sh | 6 ++++++
2 files changed, 16 insertions(+)
diff --git a/test/shell/profiles-cache.sh b/test/shell/profiles-cache.sh
index 9e17ebf60..47a5cdf2f 100644
--- a/test/shell/profiles-cache.sh
+++ b/test/shell/profiles-cache.sh
@@ -43,6 +43,9 @@ allocation {
sequential_threshold = 100
random_threshold = 200
}
+ writecache {
+ high_watermark = 60
+ }
}
}
EOF
@@ -58,6 +61,13 @@ EOF
aux prepare_vg 2 1000000
+# Check writecache read data from profile
+lvcreate -n $lv1 -l 4 -an $vg "$dev1"
+lvcreate -y --type writecache -l 4 --cachevol $lv1 -n $lv2 --metadataprofile $PFILE $vg "$dev2"
+check lv_field $vg/$lv2 cachesettings "high_watermark=60"
+lvremove -y $vg
+exit
+
# Check chunk_size is grabbed from configuration
lvcreate -L1G --config 'allocation/cache_pool_chunk_size=512' --type cache-pool $vg/cpool
check lv_field $vg/cpool chunksize "512.00k"
diff --git a/test/shell/writecache-misc.sh b/test/shell/writecache-misc.sh
index 80b793256..f62974c54 100644
--- a/test/shell/writecache-misc.sh
+++ b/test/shell/writecache-misc.sh
@@ -52,6 +52,12 @@ aux prepare_devs 4
vgcreate $vg "$dev1" "$dev2" "$dev3" "$dev4"
+# Create writecache without a specified name so it gets automatic name
+lvcreate -n $lv1 -l 4 -an $vg "$dev1"
+lvcreate -y --type writecache -l 4 --cachevol $lv1 $vg "$dev2"
+check lv_exists $vg lvol0
+lvremove -y $vg
+
#
# Test pvmove with writecache
#
2 years, 3 months
main - man: doc writecache profile support
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b95506815fa149cf135...
Commit: b95506815fa149cf135687cbe047b7bdfcd6e00f
Parent: d8dbabb28e674e9f2aac2716b235f27f1d333e1a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 24 14:50:09 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 26 15:09:58 2022 +0100
man: doc writecache profile support
---
man/lvmcache.7_main | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/man/lvmcache.7_main b/man/lvmcache.7_main
index 48cf7b492..8d7d3d17b 100644
--- a/man/lvmcache.7_main
+++ b/man/lvmcache.7_main
@@ -299,6 +299,39 @@ perform. If not done beforehand, the splitcache command enables the
cleaner mode and waits for flushing to complete before detaching the
writecache. Adding cleaner=0 to the splitcache command will skip the
cleaner mode, and any required flushing is performed in device suspend.
+
+.SS dm-writecache using metadata profiles
+
+Writecache allows to set a variety of options. Lots of these settings
+can be specified in lvm.conf or profile settings. You can prepare
+a number of different profiles in the \fI#DEFAULT_SYS_DIR#/profile\fP directory
+and just specify the metadata profile file name when writecaching LV.
+.P
+.I Example
+.nf
+# cat <<EOF > #DEFAULT_SYS_DIR#/profile/cache_writecache.profile
+allocation {
+.RS
+cache_settings {
+.RS
+writecache {
+.RS
+high_watermark=60
+writeback_jobs=1024
+.RE
+}
+.RE
+}
+.RE
+}
+EOF
+.P
+
+# lvcreate -an -L10G --name wcache vg /dev/fast_ssd
+# lvcreate --type writecache -L10G --name main --cachevol wcache \\
+ --metadataprofile cache_writecache vg /dev/slow_hdd
+.fi
+
.
.SS dm-cache with separate data and metadata LVs
.
2 years, 3 months
main - lvcreate: cachesettings works also with writecache
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d8dbabb28e674e9f2aa...
Commit: d8dbabb28e674e9f2aac2716b235f27f1d333e1a
Parent: a06ccdf44bd385863792baed887303c714da9685
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jan 18 19:06:21 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 26 15:09:58 2022 +0100
lvcreate: cachesettings works also with writecache
---
tools/lvcreate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 0115b3c32..2c519d555 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -823,6 +823,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
alloc_ARG,\
autobackup_ARG,\
available_ARG,\
+ cachesettings_ARG,\
contiguous_ARG,\
devices_ARG,\
devicesfile_ARG,\
@@ -846,8 +847,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
cachemetadataformat_ARG,\
cachemode_ARG,\
cachepool_ARG,\
- cachepolicy_ARG,\
- cachesettings_ARG
+ cachepolicy_ARG
#define MIRROR_ARGS \
corelog_ARG,\
2 years, 3 months
main - lvcreate: fix crash for unspecified LV name for writecache
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a06ccdf44bd38586379...
Commit: a06ccdf44bd385863792baed887303c714da9685
Parent: c6639056e0bb2fc5f072b2c0d6bb629ad17eee6e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 20 16:01:17 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 26 15:09:58 2022 +0100
lvcreate: fix crash for unspecified LV name for writecache
Fix aplication crash when creating writecached LV with 'automatic' name.
---
tools/lvcreate.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 79af42685..0115b3c32 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1691,6 +1691,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
struct lvcreate_params *lp = pp->lp;
struct lvcreate_cmdline_params *lcp = pp->lcp;
struct logical_volume *spare = vg->pool_metadata_spare_lv;
+ struct logical_volume *lv;
int ret = ECMD_FAILED;
if (!_read_activation_params(cmd, vg, lp))
@@ -1759,9 +1760,12 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
lp->needs_lockd_init = 1;
}
- if (!lv_create_single(vg, lp))
+ if (!(lv = lv_create_single(vg, lp)))
goto_out;
+ if (!lp->lv_name)
+ lp->lv_name = lv->name; /* Get created LV name when it was not specified */
+
ret = ECMD_PROCESSED;
out:
if (ret != ECMD_PROCESSED && !spare && vg->pool_metadata_spare_lv)
2 years, 3 months
main - writecache: handle options from lvm.conf
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c6639056e0bb2fc5f07...
Commit: c6639056e0bb2fc5f072b2c0d6bb629ad17eee6e
Parent: 8f50c5e79b6ce619a53d51353dded2f84953af00
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 20 15:36:14 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 26 15:09:58 2022 +0100
writecache: handle options from lvm.conf
User can place default settings into lvm.conf i.e.:
allocation {
cache_settings {
writecache {
block_size = 4096
}
}
}
---
WHATS_NEW | 1 +
tools/toollib.c | 276 +++++++++++++++++++++++++++++++-------------------------
2 files changed, 156 insertions(+), 121 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 f95c98f51..e8873adee 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1196,117 +1196,136 @@ out:
return ok;
}
-static int _get_one_writecache_setting(struct cmd_context *cmd, struct writecache_settings *settings,
- char *key, char *val, uint32_t *block_size_sectors)
+static int _get_writecache_setting(struct cmd_context *cmd,
+ struct dm_config_node *cn,
+ struct writecache_settings *settings,
+ uint32_t *block_size_sectors)
{
- /* special case: block_size is not a setting but is set with the --cachesettings option */
- if (!strncmp(key, "block_size", strlen("block_size"))) {
- uint32_t block_size = 0;
- if (sscanf(val, "%u", &block_size) != 1)
- goto_bad;
- if (block_size == 512)
- *block_size_sectors = 1;
- else if (block_size == 4096)
- *block_size_sectors = 8;
- else
- goto_bad;
- return 1;
- }
-
- if (!strncmp(key, "high_watermark", strlen("high_watermark"))) {
- if (sscanf(val, "%llu", (unsigned long long *)&settings->high_watermark) != 1)
- goto_bad;
- if (settings->high_watermark > 100)
- goto_bad;
- settings->high_watermark_set = 1;
- return 1;
- }
-
- if (!strncmp(key, "low_watermark", strlen("low_watermark"))) {
- if (sscanf(val, "%llu", (unsigned long long *)&settings->low_watermark) != 1)
- goto_bad;
- if (settings->low_watermark > 100)
- goto_bad;
- settings->low_watermark_set = 1;
- return 1;
- }
-
- if (!strncmp(key, "writeback_jobs", strlen("writeback_jobs"))) {
- if (sscanf(val, "%llu", (unsigned long long *)&settings->writeback_jobs) != 1)
- goto_bad;
- settings->writeback_jobs_set = 1;
- return 1;
- }
-
- if (!strncmp(key, "autocommit_blocks", strlen("autocommit_blocks"))) {
- if (sscanf(val, "%llu", (unsigned long long *)&settings->autocommit_blocks) != 1)
- goto_bad;
- settings->autocommit_blocks_set = 1;
- return 1;
- }
-
- if (!strncmp(key, "autocommit_time", strlen("autocommit_time"))) {
- if (sscanf(val, "%llu", (unsigned long long *)&settings->autocommit_time) != 1)
- goto_bad;
- settings->autocommit_time_set = 1;
- return 1;
- }
-
- if (!strncmp(key, "fua", strlen("fua"))) {
- if (settings->nofua_set) {
- log_error("Setting fua and nofua cannot both be set.");
- return 0;
- }
- if (sscanf(val, "%u", &settings->fua) != 1)
- goto_bad;
- settings->fua_set = 1;
- return 1;
- }
-
- if (!strncmp(key, "nofua", strlen("nofua"))) {
- if (settings->fua_set) {
- log_error("Setting fua and nofua cannot both be set.");
+ char val[32];
+
+ /* Try to find our section for given policy */
+ for (; cn; cn = cn->sib) {
+ /* special case: block_size is not a setting but is set with the --cachesettings option */
+ if (!strcmp(cn->key, "block_size")) {
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ if (cn->v->v.i == 512)
+ *block_size_sectors = 1;
+ else if (cn->v->v.i == 4096)
+ *block_size_sectors = 8;
+ else
+ goto_bad;
+
+ } else if (!strcmp(cn->key, "high_watermark")) {
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->high_watermark = (uint64_t)cn->v->v.i;
+ if (settings->high_watermark > 100)
+ goto_bad;
+ settings->high_watermark_set = 1;
+
+ } else if (!strcmp(cn->key, "low_watermark")) {
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->low_watermark = (uint64_t)cn->v->v.i;
+ if (settings->low_watermark > 100)
+ goto_bad;
+ settings->low_watermark_set = 1;
+
+ } else if (!strcmp(cn->key, "writeback_jobs")) {
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->writeback_jobs = (uint64_t)cn->v->v.i;
+ settings->writeback_jobs_set = 1;
+
+ } else if (!strcmp(cn->key, "autocommit_blocks")) {
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->autocommit_blocks = (uint64_t)cn->v->v.i;
+ settings->autocommit_blocks_set = 1;
+
+ } else if (!strcmp(cn->key, "autocommit_time")) {
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->autocommit_time = (uint64_t)cn->v->v.i;
+ settings->autocommit_time_set = 1;
+
+ } else if (!strcmp(cn->key, "fua")) {
+ if (settings->nofua_set) {
+ log_error("Setting fua and nofua cannot both be set.");
+ return 0;
+ }
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->fua = (unsigned)cn->v->v.i;
+ settings->fua_set = 1;
+
+ } else if (!strcmp(cn->key, "nofua")) {
+ if (settings->fua_set) {
+ log_error("Setting fua and nofua cannot both be set.");
+ return 0;
+ }
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->nofua = (unsigned)cn->v->v.i;
+ settings->nofua_set = 1;
+
+ } else if (!strcmp(cn->key, "cleaner")) {
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->cleaner = (unsigned) cn->v->v.i;
+ settings->cleaner_set = 1;
+
+ } else if (!strcmp(cn->key, "max_age")) {
+ if (cn->v->type != DM_CFG_INT)
+ goto_bad;
+ settings->max_age = (unsigned) cn->v->v.i;
+ settings->max_age_set = 1;
+
+ } else if (settings->new_key) {
+ log_error("Setting %s is not recognized. Only one unrecognized setting is allowed.", cn->key);
return 0;
- }
- if (sscanf(val, "%u", &settings->nofua) != 1)
- goto_bad;
- settings->nofua_set = 1;
- return 1;
- }
- if (!strncmp(key, "cleaner", strlen("cleaner"))) {
- if (sscanf(val, "%u", &settings->cleaner) != 1)
- goto_bad;
- settings->cleaner_set = 1;
- return 1;
- }
+ } else {
+ log_warn("Unrecognized writecache setting \"%s\" may cause activation failure.", cn->key);
+ if (yes_no_prompt("Use unrecognized writecache setting? [y/n]: ") == 'n') {
+ log_error("Aborting writecache conversion.");
+ return 0;
+ }
- if (!strncmp(key, "max_age", strlen("max_age"))) {
- if (sscanf(val, "%u", &settings->max_age) != 1)
- goto_bad;
- settings->max_age_set = 1;
- return 1;
- }
+ settings->new_key = dm_pool_strdup(cmd->mem, cn->key);
+ switch (cn->v->type) {
+ case DM_CFG_INT:
+ snprintf(val, sizeof(val), FMTd64, cn->v->v.i);
+ settings->new_val = dm_pool_strdup(cmd->mem, val);
+ break;
+ case DM_CFG_STRING:
+ settings->new_val = dm_pool_strdup(cmd->mem, cn->v->v.str);
+ break;
+ default:
+ log_error("Unsupported unrecognized setting %s value.", cn->key);
+ return 0;
+ }
+ if (!settings->new_key || !settings->new_val) {
+ log_error("Failed to copy unrecognized setting %s.", cn->key);
+ return 0;
+ }
- if (settings->new_key) {
- log_error("Setting %s is not recognized. Only one unrecognized setting is allowed.", key);
- return 0;
+ log_warn("Using unrecognized writecache setting: %s = %s.",
+ settings->new_key, settings->new_val);
+ }
}
- log_warn("Unrecognized writecache setting \"%s\" may cause activation failure.", key);
- if (yes_no_prompt("Use unrecognized writecache setting? [y/n]: ") == 'n') {
- log_error("Aborting writecache conversion.");
+ 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.");
return 0;
}
- log_warn("Using unrecognized writecache setting: %s = %s.", key, val);
-
- settings->new_key = dm_pool_strdup(cmd->mem, key);
- settings->new_val = dm_pool_strdup(cmd->mem, val);
return 1;
- bad:
- log_error("Invalid setting: %s", key);
+bad:
+ log_error("Invalid setting: %s", cn->key);
return 0;
}
@@ -1314,11 +1333,10 @@ int get_writecache_settings(struct cmd_context *cmd, struct writecache_settings
uint32_t *block_size_sectors)
{
struct arg_value_group_list *group;
+ struct dm_config_tree *result = NULL, *prev = NULL, *current = NULL;
+ const struct dm_config_node *cns, *cn;
+ int ok = 0;
const char *str;
- char key[64];
- char val[64];
- int num;
- int pos;
/*
* "grouped" means that multiple --cachesettings options can be used.
@@ -1329,36 +1347,52 @@ int get_writecache_settings(struct cmd_context *cmd, struct writecache_settings
if (!grouped_arg_is_set(group->arg_values, cachesettings_ARG))
continue;
+ if (!(current = dm_config_create()))
+ goto_out;
+ if (prev)
+ current->cascade = prev;
+ prev = current;
+
if (!(str = grouped_arg_str_value(group->arg_values, cachesettings_ARG, NULL)))
break;
- pos = 0;
-
- while (pos < strlen(str)) {
- /* scan for "key1=val1 key2 = val2 key3= val3" */
+ if (!dm_config_parse_without_dup_node_check(current, str, str + strlen(str)))
+ goto_out;
+ }
- memset(key, 0, sizeof(key));
- memset(val, 0, sizeof(val));
+ if (current) {
+ if (!(result = dm_config_flatten(current)))
+ goto_out;
+ if (!_get_writecache_setting(cmd, result->root, settings, block_size_sectors))
+ goto_out;
- if (sscanf(str + pos, " %63[^=]=%63s %n", key, val, &num) != 2) {
- log_error("Invalid setting at: %s", str+pos);
- return 0;
- }
+ } else if ((cns = find_config_tree_node(cmd, allocation_cache_settings_CFG_SECTION, NULL))) {
+ /* Fallback to lvm.conf cache settings for 'writecache{}' */
+ /* TODO: support profiles */
+ for (cn = cns->child; cn; cn = cn->sib) {
+ if (!cn->child)
+ continue; /* Ignore section without settings */
- pos += num;
+ if (cn->v || strcmp(cn->key, "writecache") != 0)
+ continue; /* Ignore non-matching settings */
- if (!_get_one_writecache_setting(cmd, settings, key, val, block_size_sectors))
- return_0;
+ if (!_get_writecache_setting(cmd, cn->child, settings, block_size_sectors))
+ goto_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.");
- return 0;
+ ok = 1;
+out:
+ if (result)
+ dm_config_destroy(result);
+
+ while (prev) {
+ current = prev->cascade;
+ dm_config_destroy(prev);
+ prev = current;
}
- return 1;
+ return ok;
}
/* FIXME move to lib */
2 years, 3 months
main - lvmdevices: fix checks when adding entries
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8f50c5e79b6ce619a53...
Commit: 8f50c5e79b6ce619a53d51353dded2f84953af00
Parent: 9e9f02acf04a1dd002709b2239a28ac56dd76aba
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 25 11:35:36 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 25 15:18:29 2022 -0600
lvmdevices: fix checks when adding entries
Removes some incorrect and unnecessary checks for other entries
when adding a new devices. The removed checks and corrections were
mostly redundant with what is already done by device id matching.
Other checking is reworked so the warnings are a bit different.
---
lib/device/device_id.c | 153 ++++++++++++++++---------------------------------
1 file changed, 48 insertions(+), 105 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index ecf89918d..84f9f87ce 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -950,6 +950,10 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
struct dev_use *du, *update_du = NULL, *du_dev, *du_pvid, *du_devname, *du_devid;
struct dev_id *id;
int found_id = 0;
+ int part = 0;
+
+ if (!dev_get_partition_number(dev, &part))
+ return_0;
/*
* When enable_devices_file=0 and pending_devices_file=1 we let
@@ -968,10 +972,6 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
*/
memcpy(&pvid, pvid_arg, ID_LEN);
- du_dev = get_du_for_dev(cmd, dev);
- du_pvid = get_du_for_pvid(cmd, pvid);
- du_devname = _get_du_for_devname(cmd, dev_name(dev));
-
/*
* Choose the device_id type for the device being added.
*
@@ -1087,6 +1087,9 @@ id_done:
idtype = 0;
/*
+ * "dev" is the device we are adding.
+ * "id" is the device_id it's using, set in dev->id.
+ *
* Update the cmd->use_devices list for the new device. The
* use_devices list will be used to update the devices file.
*
@@ -1098,23 +1101,57 @@ id_done:
* those other entries to fix any incorrect info.
*/
+ /* Is there already an entry matched to this device? */
+ du_dev = get_du_for_dev(cmd, dev);
+
+ /* Is there already an entry matched to this device's pvid? */
+ du_pvid = get_du_for_pvid(cmd, pvid);
+
+ /* Is there already an entry using this device's name? */
+ du_devname = _get_du_for_devname(cmd, dev_name(dev));
+
+ /* Is there already an entry using the device_id for this device? */
du_devid = _get_du_for_device_id(cmd, id->idtype, id->idname);
if (du_dev)
- log_debug("device_id_add %s pvid %s matches du_dev %p dev %s",
+ log_debug("device_id_add %s pvid %s matches entry %p dev %s",
dev_name(dev), pvid, du_dev, dev_name(du_dev->dev));
if (du_pvid)
- log_debug("device_id_add %s pvid %s matches du_pvid %p dev %s pvid %s",
+ log_debug("device_id_add %s pvid %s matches entry %p dev %s with same pvid %s",
dev_name(dev), pvid, du_pvid, du_pvid->dev ? dev_name(du_pvid->dev) : ".",
du_pvid->pvid);
if (du_devid)
- log_debug("device_id_add %s pvid %s matches du_devid %p dev %s pvid %s",
+ log_debug("device_id_add %s pvid %s matches entry %p dev %s with same device_id %d %s",
dev_name(dev), pvid, du_devid, du_devid->dev ? dev_name(du_devid->dev) : ".",
- du_devid->pvid);
+ du_devid->idtype, du_devid->idname);
if (du_devname)
- log_debug("device_id_add %s pvid %s matches du_devname %p dev %s pvid %s",
+ log_debug("device_id_add %s pvid %s matches entry %p dev %s with same devname %s",
dev_name(dev), pvid, du_devname, du_devname->dev ? dev_name(du_devname->dev) : ".",
- du_devname->pvid);
+ du_devname->devname);
+
+ if (du_pvid && (du_pvid->dev != dev))
+ log_warn("WARNING: adding device %s with PVID %s which is already used for %s.",
+ dev_name(dev), pvid, du_pvid->dev ? dev_name(du_pvid->dev) : "missing device");
+
+ if (du_devid && (du_devid->dev != dev)) {
+ if (!du_devid->dev) {
+ log_warn("WARNING: adding device %s with idname %s which is already used for missing device.",
+ dev_name(dev), id->idname);
+ } else {
+ int ret1, ret2;
+ dev_t devt1, devt2;
+ /* Check if both entries are partitions of the same device. */
+ ret1 = dev_get_primary_dev(cmd->dev_types, dev, &devt1);
+ ret2 = dev_get_primary_dev(cmd->dev_types, du_devid->dev, &devt2);
+ if ((ret1 == 2) && (ret2 == 2) && (devt1 == devt2)) {
+ log_debug("Using separate entries for partitions of same device %s part %d %s part %d.",
+ dev_name(dev), part, dev_name(du_devid->dev), du_devid->part);
+ } else {
+ log_warn("WARNING: adding device %s with idname %s which is already used for %s.",
+ dev_name(dev), id->idname, dev_name(du_devid->dev));
+ }
+ }
+ }
/*
* If one of the existing entries (du_dev, du_pvid, du_devid, du_devname)
@@ -1127,29 +1164,6 @@ id_done:
dm_list_del(&update_du->list);
update_matching_kind = "device";
update_matching_name = dev_name(dev);
-
- if (du_devid && (du_devid != du_dev)) {
- log_warn("WARNING: device %s (%s) and %s (%s) have duplicate device ID.",
- dev_name(dev), id->idname,
- (du_pvid && du_pvid->dev) ? dev_name(du_pvid->dev) : "none",
- du_pvid ? du_pvid->idname : "");
- }
-
- if (du_pvid && (du_pvid != du_dev)) {
- log_warn("WARNING: device %s (%s) and %s (%s) have duplicate PVID %s",
- dev_name(dev), id->idname,
- du_pvid->dev ? dev_name(du_pvid->dev) : "none", du_pvid->idname,
- pvid);
- }
-
- if (du_devname && (du_devname != du_dev)) {
- /* clear devname in another entry with our devname */
- log_warn("Devices file PVID %s clearing wrong DEVNAME %s.",
- du_devname->pvid, du_devname->devname);
- free(du_devname->devname);
- du_devname->devname = NULL;
- }
-
} else if (du_pvid) {
/*
* If the device_id of the existing entry for PVID is the same
@@ -1169,11 +1183,6 @@ id_done:
update_matching_kind = "PVID";
update_matching_name = pvid;
} else {
- log_warn("WARNING: device %s (%s) and %s (%s) have duplicate PVID %s",
- dev_name(dev), id->idname,
- du_pvid->dev ? dev_name(du_pvid->dev) : "none", du_pvid->idname,
- pvid);
-
if (!cmd->current_settings.yes &&
yes_no_prompt("Add device with duplicate PV to devices file?") == 'n') {
log_print("Device not added.");
@@ -1181,21 +1190,6 @@ id_done:
return 1;
}
}
-
- if (du_devid && (du_devid != du_pvid)) {
- /* warn about another entry using the same device_id */
- log_warn("WARNING: duplicate device_id %s for PVIDs %s %s",
- du_devid->idname, du_devid->pvid, du_pvid->pvid);
- }
-
- if (du_devname && (du_devname != du_pvid)) {
- /* clear devname in another entry with our devname */
- log_warn("Devices file PVID %s clearing wrong DEVNAME %s.",
- du_devname->pvid, du_devname->devname);
- free(du_devname->devname);
- du_devname->devname = NULL;
- }
-
} else if (du_devid) {
/*
* Do we create a new du or update the existing du?
@@ -1210,64 +1204,13 @@ id_done:
* the same device_id (create a new du for dev.)
* If not, then update the existing du_devid.
*/
-
- if (du_devid->dev != dev)
- check_idname = device_id_system_read(cmd, du_devid->dev, id->idtype);
-
- if (check_idname && !strcmp(check_idname, id->idname)) {
- int ret1, ret2;
- dev_t devt1, devt2;
-
- /*
- * two different devices have the same device_id,
- * create a new du for the device being added
- */
-
- /* dev_is_partitioned() the dev open to read it. */
- if (!label_scan_open(du_devid->dev))
- log_warn("Cannot open %s", dev_name(du_devid->dev));
-
- if (dev_is_partitioned(cmd, du_devid->dev)) {
- /* Check if existing entry is whole device and new entry is a partition of it. */
- ret1 = dev_get_primary_dev(cmd->dev_types, dev, &devt1);
- if ((ret1 == 2) && (devt1 == du_devid->dev->dev))
- log_warn("Remove partitioned device %s from devices file.", dev_name(du_devid->dev));
- } else {
- /* Check if both entries are partitions of the same device. */
- ret1 = dev_get_primary_dev(cmd->dev_types, dev, &devt1);
- ret2 = dev_get_primary_dev(cmd->dev_types, du_devid->dev, &devt2);
-
- if ((ret1 == 2) && (ret2 == 2) && (devt1 == devt2)) {
- log_warn("Partitions %s %s have same device_id %s",
- dev_name(dev), dev_name(du_devid->dev), id->idname);
- } else {
- log_warn("Duplicate device_id %s %s for %s and %s",
- idtype_to_str(id->idtype), check_idname,
- dev_name(dev), dev_name(du_devid->dev));
- }
- }
- } else {
+ if (du_devid->dev == dev) {
/* update the existing entry with matching devid */
update_du = du_devid;
dm_list_del(&update_du->list);
update_matching_kind = "device_id";
update_matching_name = id->idname;
}
-
- if (du_devname && (du_devname != du_devid)) {
- /* clear devname in another entry with our devname */
- log_warn("Devices file PVID %s clearing wrong DEVNAME %s",
- du_devname->pvid, du_devname->devname);
- free(du_devname->devname);
- du_devname->devname = NULL;
- }
-
- } else if (du_devname) {
- /* clear devname in another entry with our devname */
- log_warn("Devices file PVID %s clearing wrong DEVNAME %s",
- du_devname->pvid, du_devname->devname);
- free(du_devname->devname);
- du_devname->devname = NULL;
}
free((void *)check_idname);
2 years, 3 months
main - device_id: fix search for renamed device when the wwid is ignored
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9e9f02acf04a1dd0027...
Commit: 9e9f02acf04a1dd002709b2239a28ac56dd76aba
Parent: de7892f0af275615d2db0c7e6a4bbc56cd4962e8
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 25 10:47:50 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 25 10:47:50 2022 -0600
device_id: fix search for renamed device when the wwid is ignored
When a device has a wwid (from sysfs), but lvm ignores the wwid,
e.g. because it contains an unreliable "QEMU" value, then lvm
falls back to using IDTYPE=devname (the device name) as the
device id. If the device name changes after reboot, then lvm
automatically searches for the PV on other devices to find the
new device name and correct system.devices. When searching for
the PV, lvm skips looking at devices that would use other id types,
e.g. if a device would use a wwid and not a devname, then it
skips checking it. However, it failed to account for the fact
that a device may have wwid that was ignored, in which case it
should be checked.
---
lib/device/device_id.c | 39 ++++++++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index ad9694b8a..ecf89918d 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -315,7 +315,6 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
/* qemu wwid begins "t10.ATA QEMU HARDDISK ..." */
if (strstr(sysbuf, "QEMU HARDDISK"))
sysbuf[0] = '\0';
-
}
else if (idtype == DEV_ID_TYPE_SYS_SERIAL)
@@ -366,7 +365,6 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
return idname;
bad:
- log_debug("No idtype %s for %s", idtype_to_str(idtype), dev_name(dev));
return NULL;
}
@@ -378,20 +376,40 @@ static int _dev_has_stable_id(struct cmd_context *cmd, struct device *dev)
{
char sysbuf[PATH_MAX] = { 0 };
struct dev_id *id;
+ const char *idname;
+ /*
+ * An idtype other than DEVNAME is stable, i.e. it doesn't change after
+ * reboot or device reattach.
+ * An id on dev->ids with idtype set and !idname means that idtype does
+ * not exist for the dev. (Optimization to avoid repeated negative
+ * system_read.)
+ */
dm_list_iterate_items(id, &dev->ids) {
- if (id->idtype != DEV_ID_TYPE_DEVNAME)
+ if ((id->idtype != DEV_ID_TYPE_DEVNAME) && id->idname)
return 1;
}
- if (read_sys_block(cmd, dev, "device/wwid", sysbuf, sizeof(sysbuf)))
+ /*
+ * Use device_id_system_read() instead of read_sys_block() when
+ * system_read ignores some values from sysfs.
+ */
+
+ if ((idname = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID))) {
+ free((void*)idname);
return 1;
+ }
- if (read_sys_block(cmd, dev, "wwid", sysbuf, sizeof(sysbuf)))
+ if ((idname = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_SERIAL))) {
+ free((void*)idname);
return 1;
+ }
- if (read_sys_block(cmd, dev, "device/serial", sysbuf, sizeof(sysbuf)))
+ if ((MAJOR(dev->dev) == cmd->dev_types->loop_major) &&
+ (idname = device_id_system_read(cmd, dev, DEV_ID_TYPE_LOOP_FILE))) {
+ free((void*)idname);
return 1;
+ }
if ((MAJOR(dev->dev) == cmd->dev_types->device_mapper_major)) {
if (!read_sys_block(cmd, dev, "dm/uuid", sysbuf, sizeof(sysbuf)))
@@ -409,9 +427,6 @@ static int _dev_has_stable_id(struct cmd_context *cmd, struct device *dev)
read_sys_block(cmd, dev, "md/uuid", sysbuf, sizeof(sysbuf)))
return 1;
- if ((MAJOR(dev->dev) == cmd->dev_types->loop_major) &&
- read_sys_block(cmd, dev, "loop/backing_file", sysbuf, sizeof(sysbuf)))
- return 1;
out:
/* DEV_ID_TYPE_DEVNAME would be used for this dev. */
return 0;
@@ -2169,6 +2184,12 @@ void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_l
*
* TODO: in auto mode should we look in other non-system
* devices files and skip any devs included in those?
+ *
+ * Note that a user can override a stable id type and use
+ * devname for a device's id, in which case this optimization
+ * can prevent a search from finding a renamed dev. So, if a
+ * user forces a devname id, then they should probably also
+ * set search_for_devnames=all.
*/
if (search_auto && _dev_has_stable_id(cmd, dev)) {
other_idtype++;
2 years, 3 months
stable-2.03.14 - Revert "pvcreate: overwrite partition header with -f"
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9375aebad1db72267dd...
Commit: 9375aebad1db72267dd67e3ed768aa3b0e698d52
Parent: bb477d63e336a10e5959962a9f26a028ea9e55eb
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 18 12:16:52 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 18 12:16:52 2022 -0600
Revert "pvcreate: overwrite partition header with -f"
This reverts commit a5c37afdca97d6565ea02bc4bc7d52f360823cd3.
This commit did not properly recognize GPT cases.
---
lib/commands/toolcontext.h | 1 -
lib/filters/filter-partitioned.c | 3 ---
man/pvcreate.8_des | 7 +++----
test/shell/test-partition.sh | 12 ++----------
tools/toollib.c | 10 ----------
5 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index b83883fb8..356c79f8a 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -201,7 +201,6 @@ struct cmd_context {
unsigned ignore_device_name_mismatch:1; /* skip updating devices file names */
unsigned backup_disabled:1; /* skip repeated debug message */
unsigned event_activation:1; /* whether event_activation is set */
- unsigned filter_partitioned_skip:1; /* don't use filter-partitioned */
/*
* Devices and filtering.
diff --git a/lib/filters/filter-partitioned.c b/lib/filters/filter-partitioned.c
index 8f468a567..642553ef2 100644
--- a/lib/filters/filter-partitioned.c
+++ b/lib/filters/filter-partitioned.c
@@ -27,9 +27,6 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
if (cmd->filter_nodata_only)
return 1;
- if (cmd->filter_partitioned_skip)
- return 1;
-
dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED;
ret = dev_is_partitioned(cmd, dev);
diff --git a/man/pvcreate.8_des b/man/pvcreate.8_des
index 4048eb71c..69bd133aa 100644
--- a/man/pvcreate.8_des
+++ b/man/pvcreate.8_des
@@ -7,10 +7,9 @@ Use \fBvgcreate\fP(8) to create a new VG on the PV, or \fBvgextend\fP(8)
to add the PV to an existing VG. Use \fBpvremove\fP(8) to remove the LVM
disk label from the device.
.P
-The force option will create a PV without confirmation, and will overwrite
-partition headers. Repeating the force option (\fB-ff\fP) will override other
-checks that would normally prevent a pvcreate, e.g. if the PV is already in a
-VG.
+The force option will create a PV without confirmation. Repeating the
+force option (\fB-ff\fP) will forcibly create a PV, overriding checks that
+normally prevent it, e.g. if the PV is already in a VG.
.P
.B Metadata location, size, and alignment
.P
diff --git a/test/shell/test-partition.sh b/test/shell/test-partition.sh
index 3a45f9089..0e92f00db 100644
--- a/test/shell/test-partition.sh
+++ b/test/shell/test-partition.sh
@@ -16,6 +16,7 @@
#
+
SKIP_WITH_LVMPOLLD=1
LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
@@ -24,7 +25,7 @@ LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
which sfdisk || skip
-aux prepare_pvs 2 30
+aux prepare_pvs 1 30
pvs "$dev1"
@@ -32,12 +33,3 @@ pvs "$dev1"
echo "1 2" | sfdisk --force "$dev1"
not pvs "$dev1"
-
-wipefs -a "$dev2"
-echo "1 2" | sfdisk --force "$dev2"
-partprobe
-not pvcreate "$dev2"
-pvcreate -f "$dev2"
-pvs "$dev2"
-pvremove "$dev2"
-
diff --git a/tools/toollib.c b/tools/toollib.c
index 80d3de57c..d6f48aad2 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5243,10 +5243,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1;
- /* pvcreate -f overwrites partitions */
- if (pp->force && !pp->is_remove)
- cmd->filter_partitioned_skip = 1;
-
log_debug("Scanning and filtering device args (%u).", dm_list_size(&scan_devs));
label_scan_devs(cmd, cmd->filter, &scan_devs);
@@ -5261,7 +5257,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
}
}
cmd->filter_deviceid_skip = 0;
- cmd->filter_partitioned_skip = 0;
/*
* Can the command continue if some specified devices were not found?
@@ -5474,9 +5469,6 @@ do_command:
if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1;
- if (pp->force && !pp->is_remove)
- cmd->filter_partitioned_skip = 1;
-
log_debug("Rescanning and filtering device args with exclusive open");
if (!label_scan_devs_excl(cmd, cmd->filter, &rescan_devs)) {
log_debug("Failed to rescan devs excl");
@@ -5490,9 +5482,7 @@ do_command:
dm_list_add(&pp->arg_fail, &pd->list);
}
}
-
cmd->filter_deviceid_skip = 0;
- cmd->filter_partitioned_skip = 0;
if (dm_list_empty(&pp->arg_process) && dm_list_empty(&remove_duplicates)) {
log_debug("No devices to process.");
2 years, 3 months
main - Revert "pvcreate: overwrite partition header with -f"
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=de7892f0af275615d2d...
Commit: de7892f0af275615d2db0c7e6a4bbc56cd4962e8
Parent: a972d63c547dc9699c0b3664175eb96b5d89ff8f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 18 12:15:03 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 18 12:15:03 2022 -0600
Revert "pvcreate: overwrite partition header with -f"
This reverts commit d5a950ca67c106403054ecb847e226e8b5a7c30e.
This commit did not properly recognize GPT cases.
---
lib/commands/toolcontext.h | 1 -
lib/filters/filter-partitioned.c | 3 ---
man/pvcreate.8_des | 7 +++----
test/shell/test-partition.sh | 12 ++----------
tools/toollib.c | 10 ----------
5 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 9c24559a6..f16322d4e 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -204,7 +204,6 @@ struct cmd_context {
unsigned udevoutput:1;
unsigned online_vg_file_removed:1;
unsigned disable_dm_devs:1; /* temporarily disable use of dm devs cache */
- unsigned filter_partitioned_skip:1; /* don't use filter-partitioned */
/*
* Devices and filtering.
diff --git a/lib/filters/filter-partitioned.c b/lib/filters/filter-partitioned.c
index 8f468a567..642553ef2 100644
--- a/lib/filters/filter-partitioned.c
+++ b/lib/filters/filter-partitioned.c
@@ -27,9 +27,6 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
if (cmd->filter_nodata_only)
return 1;
- if (cmd->filter_partitioned_skip)
- return 1;
-
dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED;
ret = dev_is_partitioned(cmd, dev);
diff --git a/man/pvcreate.8_des b/man/pvcreate.8_des
index 4048eb71c..69bd133aa 100644
--- a/man/pvcreate.8_des
+++ b/man/pvcreate.8_des
@@ -7,10 +7,9 @@ Use \fBvgcreate\fP(8) to create a new VG on the PV, or \fBvgextend\fP(8)
to add the PV to an existing VG. Use \fBpvremove\fP(8) to remove the LVM
disk label from the device.
.P
-The force option will create a PV without confirmation, and will overwrite
-partition headers. Repeating the force option (\fB-ff\fP) will override other
-checks that would normally prevent a pvcreate, e.g. if the PV is already in a
-VG.
+The force option will create a PV without confirmation. Repeating the
+force option (\fB-ff\fP) will forcibly create a PV, overriding checks that
+normally prevent it, e.g. if the PV is already in a VG.
.P
.B Metadata location, size, and alignment
.P
diff --git a/test/shell/test-partition.sh b/test/shell/test-partition.sh
index 3a45f9089..0e92f00db 100644
--- a/test/shell/test-partition.sh
+++ b/test/shell/test-partition.sh
@@ -16,6 +16,7 @@
#
+
SKIP_WITH_LVMPOLLD=1
LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
@@ -24,7 +25,7 @@ LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
which sfdisk || skip
-aux prepare_pvs 2 30
+aux prepare_pvs 1 30
pvs "$dev1"
@@ -32,12 +33,3 @@ pvs "$dev1"
echo "1 2" | sfdisk --force "$dev1"
not pvs "$dev1"
-
-wipefs -a "$dev2"
-echo "1 2" | sfdisk --force "$dev2"
-partprobe
-not pvcreate "$dev2"
-pvcreate -f "$dev2"
-pvs "$dev2"
-pvremove "$dev2"
-
diff --git a/tools/toollib.c b/tools/toollib.c
index 9b193bd2d..f95c98f51 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5248,10 +5248,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1;
- /* pvcreate -f overwrites partitions */
- if (pp->force && !pp->is_remove)
- cmd->filter_partitioned_skip = 1;
-
log_debug("Scanning and filtering device args (%u).", dm_list_size(&scan_devs));
label_scan_devs(cmd, cmd->filter, &scan_devs);
@@ -5266,7 +5262,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
}
}
cmd->filter_deviceid_skip = 0;
- cmd->filter_partitioned_skip = 0;
/*
* Can the command continue if some specified devices were not found?
@@ -5479,9 +5474,6 @@ do_command:
if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1;
- if (pp->force && !pp->is_remove)
- cmd->filter_partitioned_skip = 1;
-
log_debug("Rescanning and filtering device args with exclusive open");
if (!label_scan_devs_excl(cmd, cmd->filter, &rescan_devs)) {
log_debug("Failed to rescan devs excl");
@@ -5495,9 +5487,7 @@ do_command:
dm_list_add(&pp->arg_fail, &pd->list);
}
}
-
cmd->filter_deviceid_skip = 0;
- cmd->filter_partitioned_skip = 0;
if (dm_list_empty(&pp->arg_process) && dm_list_empty(&remove_duplicates)) {
log_debug("No devices to process.");
2 years, 3 months