Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6d14144d311fb347e4225…
Commit: 6d14144d311fb347e4225ad6a48d4900b39445c4
Parent: c9fdc828ff0504bc2e57f65862bc382f7663a8a2
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jan 27 16:46:03 2023 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 31 15:30:35 2023 -0600
pvscan: recognize "pci" as a common symlink component in filters
In case the filter strings don't include "/dev/disk", and only
include "pci".
---
lib/filters/filter-regex.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/filters/filter-regex.c b/lib/filters/filter-regex.c
index 40dc8aa1b..ecc32914b 100644
--- a/lib/filters/filter-regex.c
+++ b/lib/filters/filter-regex.c
@@ -284,6 +284,8 @@ static int _filter_contains_symlink(struct cmd_context *cmd, int filter_cfg)
return 1;
if (strstr(fname, "wwn-"))
return 1;
+ if (strstr(fname, "pci-"))
+ return 1;
}
}
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=17a3585cbb55d9a15ced9…
Commit: 17a3585cbb55d9a15ced9775a18b50c53a50ee8e
Parent: d9f8acb65a78c20ac806efaeb7a1e39208e1a443
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 19 17:37:31 2023 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 31 15:30:35 2023 -0600
pvscan: use alternate device names from DEVLINKS to check filter
pvscan --cache <dev> is called by our udev rule at a time when all
the symlinks for <dev> may not be created yet (by other udev rules.)
The regex filter in lvm.conf may refer to <dev> using a symlink name
that hasn't yet been created, which would cause <dev> to not match
the filter regex. The DEVLINKS env var, set by udev, contains all
the symlink names for <dev> that have been or will be created.
So, we add all these symlink names to dev->aliases, as if we had
found them in /dev. This allows <dev> to be recognized by a regex
filter containing a symlink for <dev>.
---
lib/commands/toolcontext.h | 1 +
lib/filters/filter-regex.c | 2 +-
man/lvmautoactivation.7_main | 13 ++++++++++
tools/pvscan.c | 60 ++++++++++++++++++++++++++------------------
4 files changed, 51 insertions(+), 25 deletions(-)
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 7f5fd12fc..4069b6116 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -207,6 +207,7 @@ 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_regex_set_preferred_name_disable:1; /* prevent dev_set_preferred_name */
/*
* Devices and filtering.
diff --git a/lib/filters/filter-regex.c b/lib/filters/filter-regex.c
index 05c5b3f2d..d9ed0104c 100644
--- a/lib/filters/filter-regex.c
+++ b/lib/filters/filter-regex.c
@@ -179,7 +179,7 @@ static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
if (m >= 0) {
if (dm_bit(rf->accept, m)) {
- if (!first)
+ if (!first && !cmd->filter_regex_set_preferred_name_disable)
dev_set_preferred_name(sl, dev);
return 1;
diff --git a/man/lvmautoactivation.7_main b/man/lvmautoactivation.7_main
index 808ea0d9f..0f7734557 100644
--- a/man/lvmautoactivation.7_main
+++ b/man/lvmautoactivation.7_main
@@ -184,6 +184,19 @@ system from booting. A custom systemd service could be written to run
autoactivation during system startup, in which case disabling event
autoactivation may be useful.
.
+.SS lvm.conf filter
+.P
+Device symlinks from /dev/disk/ can be used in the lvm.conf filter to
+guard against changes in kernel device names. The /dev/disk/by-path/ or
+/dev/disk/by-id/ prefixes should be included in the filter names; these
+prefixes help lvm detect that symlink names are used. Filters containing
+symlinks require special matching by commands run in the lvm udev rule.
+.P
+Common symlinks, e.g. beginning with wwn-, scsi-, pci-, or lvm-pv-uuid-,
+are recommended. Uncommon or custom symlinks created by custom udev rules
+may be less reliable. If a custom udev rule creates symlinks used in the
+lvm filter, then the udev rule should be started prior to the lvm rule.
+.
.SH EXAMPLES
.P
VG "vg" contains two PVs:
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 773862227..71485610b 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -910,30 +910,6 @@ static int _get_args_devs(struct cmd_context *cmd, struct dm_list *pvscan_args,
struct pvscan_arg *arg;
struct device_list *devl;
- /*
- * If no devices file is used, and lvm.conf filter is set to
- * accept /dev/disk/by-id/lvm-pv-uuid-xyz or another symlink,
- * but pvscan --cache is passed devname or major:minor, so
- * pvscan needs to match its arg device to the filter symlink.
- * setup_dev_in_dev_cache() adds /dev/sda2 to dev-cache which
- * does not match a symlink to /dev/sda2, so we need a full
- * dev_cache_scan that will associate all symlinks to sda2,
- * which allows filter-regex to work. This case could be
- * optimized if needed by adding dev-cache entries for each
- * filter "a" entry (filter symlink patterns would still need
- * a full dev_cache_scan.)
- * (When no devices file is used and 69-dm-lvm.rules is
- * used which calls pvscan directly, symlinks may not
- * have been created by other rules when pvscan runs, so
- * the full dev_cache_scan may still not find them.)
- */
- if (!cmd->enable_devices_file && !cmd->enable_devices_list &&
- (_filter_uses_symlinks(cmd, devices_filter_CFG) ||
- _filter_uses_symlinks(cmd, devices_global_filter_CFG))) {
- log_print_pvscan(cmd, "finding all devices for filter symlinks.");
- dev_cache_scan(cmd);
- }
-
/* pass NULL filter when getting devs from dev-cache, filtering is done separately */
/* in common usage, no dev will be found for a devno */
@@ -1550,6 +1526,42 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
cmd->filter_nodata_only = 1;
+ /*
+ * Hack to handle regex filter that contains a symlink name for dev arg.
+ * pvscan --cache <dev> is called by our udev rule at a time when the
+ * symlinks for <dev> may not all be created yet (by other udev rules.)
+ * The regex filter in lvm.conf may refer to <dev> using a symlink name,
+ * so we need to know all the symlinks for <dev> in order for the filter
+ * to work correctly. Scanning /dev with dev_cache_scan() would usually
+ * find all the symlink names for <dev>, adding them to dev->aliases,
+ * which would let the filter work, but all symlinks aren't created yet.
+ * But, the DEVLINKS env var, set by udev, contains all the symlink
+ * names for <dev> that have been or *will be* created. So, we add all
+ * these symlink names to dev->aliases, as if we had found them in /dev.
+ * This allows <dev> to be recognized by a regex filter containing a
+ * symlink for <dev>. We have to tell filter-regex to not set the
+ * preferred name for <dev> to a symlink name since the <dev> may not
+ * be usable by that symlink name yet.
+ */
+ if ((dm_list_size(&pvscan_devs) == 1) &&
+ !cmd->enable_devices_file && !cmd->enable_devices_list &&
+ (_filter_uses_symlinks(cmd, devices_filter_CFG) ||
+ _filter_uses_symlinks(cmd, devices_global_filter_CFG))) {
+ char *env_str;
+ struct dm_list *env_aliases;
+ devl = dm_list_item(dm_list_first(&pvscan_devs), struct device_list);
+ if ((env_str = getenv("DEVLINKS"))) {
+ log_debug("Finding symlink names from DEVLINKS for filter regex.");
+ log_debug("DEVLINKS %s", env_str);
+ env_aliases = str_to_str_list(cmd->mem, env_str, " ", 0);
+ dm_list_splice(&devl->dev->aliases, env_aliases);
+ } else {
+ log_debug("Finding symlink names from /dev for filter regex.");
+ dev_cache_scan(cmd);
+ }
+ cmd->filter_regex_set_preferred_name_disable = 1;
+ }
+
dm_list_iterate_items_safe(devl, devl2, &pvscan_devs) {
if (!cmd->filter->passes_filter(cmd, cmd->filter, devl->dev, NULL)) {
log_print_pvscan(cmd, "%s excluded: %s.",
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0441d340e752427d0d355…
Commit: 0441d340e752427d0d355a85e5e5e465e911a102
Parent: 4e34edd6e4e52328dd77b6a55aeadd9b0454c743
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Nov 29 10:04:17 2022 -0600
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Thu Jan 26 16:54:56 2023 +0100
lvmdbusd: Add command_log_selection to command line
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2145114
(cherry picked from commit e63b0c7262f50ab43fcde1c50b6d880acab68407)
---
daemons/lvmdbusd/cmdhandler.py | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index 0c7bd8528..9a76db4c9 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -17,7 +17,7 @@ import os
from lvmdbusd import cfg
from lvmdbusd.utils import pv_dest_ranges, log_debug, log_error, add_no_notify,\
- make_non_block, read_decoded, extract_stack_trace, LvmBug, add_config_option
+ make_non_block, read_decoded, extract_stack_trace, LvmBug, add_config_option, get_error_msg
from lvmdbusd.lvm_shell_proxy import LVMShellProxy
try:
@@ -121,6 +121,9 @@ def call_lvm(command, debug=False, line_cb=None,
command.insert(0, cfg.LVM_CMD)
command = add_no_notify(command)
+ # Ensure we get an error message when we fork & exec the lvm command line
+ command = add_config_option(command, "--config", 'log/command_log_selection="log_context!=''"')
+
process = Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True,
env=os.environ)
@@ -167,7 +170,17 @@ def call_lvm(command, debug=False, line_cb=None,
if debug or (process.returncode != 0 and (process.returncode != 5 and "fullreport" in command)):
_debug_c(command, process.returncode, (stdout_text, stderr_text))
- return process.returncode, stdout_text, stderr_text
+ try:
+ report_json = json.loads(stdout_text)
+ except json.decoder.JSONDecodeError:
+ # Some lvm commands don't return json even though we are asking for it to do so.
+ return process.returncode, stdout_text, stderr_text
+
+ error_msg = get_error_msg(report_json)
+ if error_msg:
+ stderr_text += error_msg
+
+ return process.returncode, report_json, stderr_text
else:
if cfg.run.value == 0:
raise SystemExit
@@ -619,20 +632,8 @@ def lvm_full_report_json():
rc, out, err = call(cmd)
# When we have an exported vg the exit code of lvs or fullreport will be 5
if rc == 0 or rc == 5:
- # If the 'call' implementation is lvmshell, the out is a dictionary as lvmshell has to
- # parse the output to get the exit value. When doing fork & exec, out is a string
- # representing the JSON. TODO: Make this consistent between implementations.
- if cfg.SHELL_IN_USE:
- assert(type(out) == dict)
- return out
- else:
- try:
- return json.loads(out)
- except json.decoder.JSONDecodeError as joe:
- log_error("JSONDecodeError %s, \n JSON=\n%s\n" %
- (str(joe), out))
- raise LvmBug("'fullreport' returned invalid JSON")
-
+ assert(type(out) == dict)
+ return out
raise LvmBug("'fullreport' exited with code '%d'" % rc)
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8f7b4456ad93c3907a82f…
Commit: 8f7b4456ad93c3907a82fd03d0feceb9785e3bfc
Parent: db067b9054d87ada6aa133394e65e3af9d75fc08
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 5 14:28:31 2023 -0600
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Thu Jan 26 16:51:12 2023 +0100
vgimportclone: fix importing PV without metadata
If one of the PVs in the VG does not hold metadata, then the
command would fail, thinking that PV was from a different VG.
Also add missing free on that error path.
(cherry picked from commit c4b898a53eec39bc28b5451e7fde87945303a644)
---
tools/vgimportclone.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
index 60ef20762..93fa3b18d 100644
--- a/tools/vgimportclone.c
+++ b/tools/vgimportclone.c
@@ -203,7 +203,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
struct device *dev;
struct device_list *devl;
struct dm_list other_devs;
- struct volume_group *vg, *error_vg;
+ struct volume_group *vg, *error_vg = NULL;
const char *vgname;
char base_vgname[NAME_LEN] = { 0 };
char tmp_vgname[NAME_LEN] = { 0 };
@@ -322,7 +322,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
goto out;
}
- if (!(vgname = lvmcache_vgname_from_info(info))) {
+ if (!(vgname = lvmcache_vgname_from_info(info)) || is_orphan_vg(vgname)) {
/* The PV may not have metadata, this will be resolved in
the process_each_vg/vg_read at the end. */
continue;
@@ -503,6 +503,8 @@ retry_name:
}
ret = ECMD_PROCESSED;
out:
+ if (error_vg)
+ release_vg(error_vg);
unlock_devices_file(cmd);
return ret;
}
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8adfcddc35be16ac1d1a0…
Commit: 8adfcddc35be16ac1d1a00a169ec89a7f12d69af
Parent: 49c650423a17197c66b1c839a0274db8fba9a7d9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jan 25 09:30:05 2023 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jan 25 10:10:57 2023 -0600
Revert "lvresize: enable crypt resizing with --force"
It looks like force was not being used to enable crypt resize,
but rather to force an inconsistency between LV and crypt
sizes, so this is either not needed or force in this case
should have some other meaning.
This reverts commit ed808a9b548ca59221d512bfb7ae581e8367fe50.
---
lib/metadata/lv_manip.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f06b08254..cfb118f11 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6417,13 +6417,9 @@ static int _fs_reduce(struct cmd_context *cmd, struct logical_volume *lv,
goto out;
}
if (!strcmp(lp->fsopt, "checksize")) {
- if (!lp->force) {
- log_error("crypt reduce is required (see --resizefs or cryptsetup resize.)");
- ret = 0;
- goto out;
- }
- /* This is only because it has been allowed in the past. */
- log_print("Forcing cryptsetup resize (--resizefs preferred.)");
+ log_error("crypt reduce is required (see --resizefs or cryptsetup resize.)");
+ ret = 0;
+ goto out;
}
if (test_mode()) {
ret = 1;