main - filter-mpath: use multipath blacklist
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=494372b4eed0c8f6040...
Commit: 494372b4eed0c8f6040e3357939eb7511ac25745
Parent: 5c50590b22b37055e93b571fb26d1854f73ae2fd
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 21 13:45:01 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 22 16:07:47 2022 -0500
filter-mpath: use multipath blacklist
Explicit wwid's from these sections control whether the
same wwid in /etc/multipath/wwids is recognized as a
multipath component. Other non-wwid keywords are not
used, and may require disabling the use of the multipath
wwids file in lvm.conf.
---
lib/device/dev-mpath.c | 181 +++++++++++++++++++++++++++++++---
test/shell/duplicate-pvs-multipath.sh | 2 +-
test/shell/multipath-config.sh | 171 ++++++++++++++++++++++++++++++++
3 files changed, 342 insertions(+), 12 deletions(-)
diff --git a/lib/device/dev-mpath.c b/lib/device/dev-mpath.c
index 808d5201f..270366ad7 100644
--- a/lib/device/dev-mpath.c
+++ b/lib/device/dev-mpath.c
@@ -17,12 +17,14 @@
#include "lib/activate/activate.h"
#include "lib/commands/toolcontext.h"
#include "lib/device/device_id.h"
+#include "lib/datastruct/str_list.h"
#ifdef UDEV_SYNC_SUPPORT
#include <libudev.h>
#include "lib/device/dev-ext-udev-constants.h"
#endif
#include <dirent.h>
+#include <ctype.h>
#define MPATH_PREFIX "mpath-"
@@ -35,15 +37,167 @@
* If dm-3 is not an mpath device, then the constant "1" is stored in
* the hash table with the key of the dm minor number.
*/
-static struct dm_pool *_hash_mem;
+static struct dm_pool *_wwid_mem;
static struct dm_hash_table *_minor_hash_tab;
static struct dm_hash_table *_wwid_hash_tab;
+static struct dm_list _ignored;
+static struct dm_list _ignored_exceptions;
#define MAX_WWID_LINE 512
-/*
- * do we need to check the multipath.conf blacklist?
- */
+static void _read_blacklist_file(const char *path)
+{
+ FILE *fp;
+ char line[MAX_WWID_LINE];
+ char wwid[MAX_WWID_LINE];
+ char *word, *p;
+ int section_black = 0;
+ int section_exceptions = 0;
+ int found_quote;
+ int found_three;
+ int i, j;
+
+ if (!(fp = fopen(path, "r")))
+ return;
+
+ while (fgets(line, sizeof(line), fp)) {
+ word = NULL;
+
+ /* skip initial white space on the line */
+ for (i = 0; i < MAX_WWID_LINE; i++) {
+ if ((line[i] == '\n') || (line[i] == '\0'))
+ break;
+ if (isspace(line[i]))
+ continue;
+ word = &line[i];
+ break;
+ }
+
+ if (!word || word[0] == '#')
+ continue;
+
+ /* identify the start of the section we want to read */
+ if (strchr(word, '{')) {
+ if (!strncmp(word, "blacklist_exceptions", 20))
+ section_exceptions = 1;
+ else if (!strncmp(word, "blacklist", 9))
+ section_black = 1;
+ continue;
+ }
+ /* identify the end of the section we've been reading */
+ if (strchr(word, '}')) {
+ section_exceptions = 0;
+ section_black = 0;
+ continue;
+ }
+ /* skip lines that are not in a section we want */
+ if (!section_black && !section_exceptions)
+ continue;
+
+ /*
+ * read a wwid from the blacklist{_exceptions} section.
+ * does not recognize other non-wwid entries in the
+ * section, and skips those (should the entire mp
+ * config filtering be disabled if non-wwids are seen?
+ */
+ if (!(p = strstr(word, "wwid")))
+ continue;
+
+ i += 4; /* skip "wwid" */
+
+ /*
+ * copy wwid value from the line.
+ * the wwids copied here need to match the
+ * wwids read from /etc/multipath/wwids,
+ * which are matched to wwids from sysfs.
+ */
+
+ memset(wwid, 0, sizeof(wwid));
+ found_quote = 0;
+ found_three = 0;
+ j = 0;
+
+ for (; i < MAX_WWID_LINE; i++) {
+ if ((line[i] == '\n') || (line[i] == '\0'))
+ break;
+ if (!j && isspace(line[i]))
+ continue;
+ if (isspace(line[i]))
+ break;
+ /* quotes around wwid are optional */
+ if ((line[i] == '"') && !found_quote) {
+ found_quote = 1;
+ continue;
+ }
+ /* second quote is end of wwid */
+ if ((line[i] == '"') && found_quote)
+ break;
+ /* ignore first "3" in wwid */
+ if ((line[i] == '3') && !found_three) {
+ found_three = 1;
+ continue;
+ }
+
+ wwid[j] = line[i];
+ j++;
+ }
+
+ if (j < 8)
+ continue;
+
+ log_debug("multipath wwid %s in %s %s",
+ wwid, section_exceptions ? "blacklist_exceptions" : "blacklist", path);
+
+ if (section_exceptions) {
+ if (!str_list_add(_wwid_mem, &_ignored_exceptions, dm_pool_strdup(_wwid_mem, wwid)))
+ stack;
+ } else {
+ if (!str_list_add(_wwid_mem, &_ignored, dm_pool_strdup(_wwid_mem, wwid)))
+ stack;
+ }
+ }
+
+ if (fclose(fp))
+ stack;
+}
+
+static void _read_wwid_exclusions(void)
+{
+ char path[PATH_MAX] = { 0 };
+ DIR *dir;
+ struct dirent *de;
+ struct dm_str_list *sl, *sl2;
+ int rem_count = 0;
+
+ _read_blacklist_file("/etc/multipath.conf");
+
+ if ((dir = opendir("/etc/multipath/conf.d"))) {
+ while ((de = readdir(dir))) {
+ if (de->d_name[0] == '.')
+ continue;
+ snprintf(path, PATH_MAX-1, "/etc/multipath/conf.d/%s", de->d_name);
+ _read_blacklist_file(path);
+ }
+ closedir(dir);
+ }
+
+ /* for each wwid in ignored_exceptions, remove it from ignored */
+
+ dm_list_iterate_items_safe(sl, sl2, &_ignored) {
+ if (str_list_match_item(&_ignored_exceptions, sl->str))
+ str_list_del(&_ignored, sl->str);
+ }
+
+ /* for each wwid in ignored, remove it from wwid_hash */
+
+ dm_list_iterate_items(sl, &_ignored) {
+ dm_hash_remove_binary(_wwid_hash_tab, sl->str, strlen(sl->str));
+ rem_count++;
+ }
+
+ if (rem_count)
+ log_debug("multipath config ignored %d wwids", rem_count);
+}
static void _read_wwid_file(const char *config_wwids_file)
{
@@ -93,6 +247,9 @@ int dev_mpath_init(const char *config_wwids_file)
struct dm_hash_table *minor_tab;
struct dm_hash_table *wwid_tab;
+ dm_list_init(&_ignored);
+ dm_list_init(&_ignored_exceptions);
+
if (!(mem = dm_pool_create("mpath", 256))) {
log_error("mpath pool creation failed.");
return 0;
@@ -104,7 +261,7 @@ int dev_mpath_init(const char *config_wwids_file)
return 0;
}
- _hash_mem = mem;
+ _wwid_mem = mem;
_minor_hash_tab = minor_tab;
/* multipath_wwids_file="" disables the use of the file */
@@ -116,16 +273,18 @@ int dev_mpath_init(const char *config_wwids_file)
if (!(wwid_tab = dm_hash_create(110))) {
log_error("mpath hash table creation failed.");
dm_hash_destroy(_minor_hash_tab);
- dm_pool_destroy(_hash_mem);
+ dm_pool_destroy(_wwid_mem);
_minor_hash_tab = NULL;
- _hash_mem = NULL;
+ _wwid_mem = NULL;
return 0;
}
_wwid_hash_tab = wwid_tab;
- if (config_wwids_file)
+ if (config_wwids_file) {
_read_wwid_file(config_wwids_file);
+ _read_wwid_exclusions();
+ }
return 1;
}
@@ -136,12 +295,12 @@ void dev_mpath_exit(void)
dm_hash_destroy(_minor_hash_tab);
if (_wwid_hash_tab)
dm_hash_destroy(_wwid_hash_tab);
- if (_hash_mem)
- dm_pool_destroy(_hash_mem);
+ if (_wwid_mem)
+ dm_pool_destroy(_wwid_mem);
_minor_hash_tab = NULL;
_wwid_hash_tab = NULL;
- _hash_mem = NULL;
+ _wwid_mem = NULL;
}
diff --git a/test/shell/duplicate-pvs-multipath.sh b/test/shell/duplicate-pvs-multipath.sh
index a145e4afb..59c15b0d4 100644
--- a/test/shell/duplicate-pvs-multipath.sh
+++ b/test/shell/duplicate-pvs-multipath.sh
@@ -10,7 +10,7 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-test_description='udev rule and systemd unit run vgchange'
+test_description='duplicate pv detection of mpath components using wwid'
SKIP_WITH_LVMPOLLD=1
SKIP_WITH_LVMLOCKD=1
diff --git a/test/shell/multipath-config.sh b/test/shell/multipath-config.sh
new file mode 100644
index 000000000..ffb7d632a
--- /dev/null
+++ b/test/shell/multipath-config.sh
@@ -0,0 +1,171 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+test_description='using multipath blacklist'
+
+SKIP_WITH_LVMPOLLD=1
+SKIP_WITH_LVMLOCKD=1
+
+. lib/inittest
+
+# FIXME: don't run this test by default because it destroys the
+# local multipath config, the timing of multipath/dm/lvm interactions
+# is fragile, and there's insufficient cleanup after a test fails.
+skip
+
+systemctl stop multipathd
+multipath -F || true
+rm /etc/multipath/wwids || true
+rmmod scsi_debug || true
+rm /etc/multipath/conf.d/lvmtest.conf || true
+
+modprobe --dry-run scsi_debug || skip
+multipath -l || skip
+multipath -l | grep scsi_debug && skip
+ls /etc/multipath/wwids && skip
+
+# Need to use /dev/mapper/mpath
+aux lvmconf 'devices/dir = "/dev"'
+aux lvmconf 'devices/scan = "/dev"'
+# Could set filter to $MP and the component /dev/sd devs
+aux lvmconf "devices/filter = [ \"a|.*|\" ]"
+aux lvmconf "devices/global_filter = [ \"a|.*|\" ]"
+
+modprobe scsi_debug dev_size_mb=16 num_tgts=1
+sleep 2
+
+# Get scsi device name created by scsi_debug.
+# SD = sdh
+# SD_DEV = /dev/sdh
+
+SD=$(grep -H scsi_debug /sys/block/sd*/device/model | cut -f4 -d /);
+echo $SD
+SD_DEV=/dev/$SD
+echo $SD_DEV
+
+# if multipath claimed SD, then io will fail
+#dd if=$SD_DEV of=/dev/null bs=4k count=1 iflag=direct
+#dd if=/dev/zero of=$SD_DEV bs=4k count=1 oflag=direct
+
+# check if multipathd claimed the scsi dev when it appears and create mp dm device
+sleep 2
+multipath -l
+# create the mp dm device
+multipath $SD_DEV
+
+# Get mpath device name created by multipath.
+# MP = mpatha
+# MP_DEV = /dev/maper/mpatha
+
+MP=$(multipath -l | grep scsi_debug | cut -f1 -d ' ')
+echo $MP
+MP_DEV=/dev/mapper/$MP
+echo $MP_DEV
+
+dd if=$MP_DEV of=/dev/null bs=4k count=1 iflag=direct
+dd if=/dev/zero of=$MP_DEV bs=4k count=1 oflag=direct
+
+# Get wwid for the mp and sd dev.
+WWID=$(multipath -l $MP_DEV | head -1 | awk '{print $2}' | tr -d ')' | tr -d '(')
+echo $WWID
+
+grep $WWID /etc/multipath/wwids
+
+pvcreate $MP_DEV
+vgcreate $vg1 $MP_DEV
+
+not pvs $SD_DEV
+pvs $MP_DEV
+
+# remove mpath dm device then check that SD_DEV is
+# filtered based on /etc/multipath/wwids instead of
+# based on sysfs holder
+multipath -f $MP
+sleep 2
+not pvs $SD_DEV
+multipath $SD_DEV
+sleep 2
+multipath -l | grep $SD
+
+#
+# Add the wwid to the blacklist, then restart multipath
+# so the sd dev should no longer be used by multipath,
+# but the sd dev wwid is still in /etc/multipath/wwids.
+#
+
+mkdir /etc/multipath/conf.d/ || true
+rm -f /etc/multipath/conf.d/lvmtest.conf
+
+cat <<EOF > "/etc/multipath/conf.d/lvmtest.conf"
+blacklist {
+ wwid $WWID
+}
+EOF
+
+cat /etc/multipath/conf.d/lvmtest.conf
+
+multipath -r
+sleep 2
+
+grep $WWID /etc/multipath/wwids
+
+multipath -l |tee out
+not grep $SD out
+not grep $MP out
+not grep $WWID out
+
+not pvs $MP_DEV
+pvs $SD_DEV
+vgs $vg1
+
+#
+# Add the wwid to the blacklist_exceptions, in addition
+# to the blacklist, then restart multipath so the
+# sd dev should again be used by multipath.
+#
+
+rm -f /etc/multipath/conf.d/lvmtest.conf
+
+cat <<EOF > "/etc/multipath/conf.d/lvmtest.conf"
+blacklist {
+wwid $WWID
+}
+blacklist_exceptions {
+wwid $WWID
+}
+EOF
+
+cat /etc/multipath/conf.d/lvmtest.conf
+
+multipath -r
+sleep 2
+
+grep $WWID /etc/multipath/wwids
+
+multipath -l |tee out
+grep $SD out
+grep $MP out
+grep $WWID out
+
+pvs $MP_DEV
+not pvs $SD_DEV
+vgs $vg1
+lvs $vg1
+
+sleep 2
+vgremove -ff $vg1
+sleep 2
+multipath -f $MP
+rm /etc/multipath/conf.d/lvmtest.conf
+rm /etc/multipath/wwids
+sleep 1
+rmmod scsi_debug
1 year, 5 months
main - tests: devicesfile-edit.sh fix loop file name
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5c50590b22b37055e93...
Commit: 5c50590b22b37055e93b571fb26d1854f73ae2fd
Parent: bee575d678399a45db09ec8fcba79eae3890ec54
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 21 11:31:06 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Apr 21 11:31:06 2022 -0500
tests: devicesfile-edit.sh fix loop file name
don't remove dash from loop file name
---
test/shell/devicesfile-edit.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/devicesfile-edit.sh b/test/shell/devicesfile-edit.sh
index 2a046e213..a71ca0c43 100644
--- a/test/shell/devicesfile-edit.sh
+++ b/test/shell/devicesfile-edit.sh
@@ -141,8 +141,8 @@ rm $DF
lvmdevices --adddev "$LOOP1"
lvmdevices --adddev "$LOOP2"
vgcreate $vg "$LOOP1" "$LOOP2"
-IDNAME1=`pvs "$LOOP1" --noheading -o deviceid | tr -d - | awk '{print $1}'`
-IDNAME2=`pvs "$LOOP2" --noheading -o deviceid | tr -d - | awk '{print $1}'`
+IDNAME1=`pvs "$LOOP1" --noheading -o deviceid | awk '{print $1}'`
+IDNAME2=`pvs "$LOOP2" --noheading -o deviceid | awk '{print $1}'`
lvmdevices --deldev "$IDNAME2" --deviceidtype loop_file
not grep "$IDNAME2" $DF
not grep "$LOOP2" $DF
1 year, 5 months
main - devices file: remove extraneous unlock in vgchange -u
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bee575d678399a45db0...
Commit: bee575d678399a45db09ec8fcba79eae3890ec54
Parent: d14245c72425b99c3bc33a533da46962d010871a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Apr 13 12:16:57 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Apr 13 12:19:04 2022 -0500
devices file: remove extraneous unlock in vgchange -u
vgchange -u exit path was unlocking the devices file in cases
when it wasn't needed, which produced an warning.
---
lib/device/device_id.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 6c7136d5f..f1928347c 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -1298,15 +1298,15 @@ void device_id_update_vg_uuid(struct cmd_context *cmd, struct volume_group *vg,
int update = 0;
if (!cmd->enable_devices_file)
- goto out;
+ return;
/* Without this setting there is no stacking LVs on PVs. */
if (!cmd->scan_lvs)
- goto out;
+ return;
/* Check if any devices file entries are stacked on LVs. */
if (!_device_ids_use_lvmlv(cmd))
- goto out;
+ return;
memcpy(old_vgid, old_vg_id, ID_LEN);
memcpy(new_vgid, &vg->id, ID_LEN);
@@ -1336,7 +1336,6 @@ void device_id_update_vg_uuid(struct cmd_context *cmd, struct volume_group *vg,
if (update &&
!device_ids_write(cmd))
stack;
- out:
unlock_devices_file(cmd);
}
1 year, 5 months
main - lvmlockd: return error from vgcreate init_vg_sanlock
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d14245c72425b99c3bc...
Commit: d14245c72425b99c3bc33a533da46962d010871a
Parent: 99f9bb28c9bf9cc5bda14674a3827ec5164b2872
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Apr 8 11:28:53 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 8 11:34:04 2022 -0500
lvmlockd: return error from vgcreate init_vg_sanlock
in vgcreate for shared sanlock vg, if sanlock_write_resource
returns an unexpected error, then make init_vg_sanlock fail
which will cause the vgcreate to fail.
---
daemons/lvmlockd/lvmlockd-sanlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c
index 3f078ea41..3f3ee14f3 100644
--- a/daemons/lvmlockd/lvmlockd-sanlock.c
+++ b/daemons/lvmlockd/lvmlockd-sanlock.c
@@ -684,10 +684,10 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
break;
}
- if (rv) {
+ if (rv < 0) {
log_error("clear lv resource area %llu error %d",
(unsigned long long)offset, rv);
- break;
+ return rv;
}
offset += align_size;
}
1 year, 5 months
main - filters: remove unused internal filter
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=99f9bb28c9bf9cc5bda...
Commit: 99f9bb28c9bf9cc5bda14674a3827ec5164b2872
Parent: 6cb0b44cd2f518ed32c9bef571986d51c775c99b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Apr 1 15:09:18 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Apr 6 12:51:34 2022 -0500
filters: remove unused internal filter
---
lib/Makefile.in | 1 -
lib/commands/toolcontext.c | 9 +----
lib/filters/filter-internal.c | 86 -------------------------------------------
lib/filters/filter.h | 4 --
4 files changed, 1 insertion(+), 99 deletions(-)
diff --git a/lib/Makefile.in b/lib/Makefile.in
index e97f57a4d..22b96134b 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -54,7 +54,6 @@ SOURCES =\
filters/filter-partitioned.c \
filters/filter-type.c \
filters/filter-usable.c \
- filters/filter-internal.c \
filters/filter-signature.c \
filters/filter-deviceid.c \
format_text/archive.c \
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 301596482..4cb81bf94 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1128,7 +1128,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
return 1;
}
-#define MAX_FILTERS 11
+#define MAX_FILTERS 10
static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
{
@@ -1143,13 +1143,6 @@ static struct dev_filter *_init_filter_chain(struct cmd_context *cmd)
* Update MAX_FILTERS definition above when adding new filters.
*/
- /* internal filter used by command processing. */
- if (!(filters[nr_filt] = internal_filter_create())) {
- log_error("Failed to create internal device filter");
- goto bad;
- }
- nr_filt++;
-
/* global regex filter. Optional. */
if ((cn = find_config_tree_node(cmd, devices_global_filter_CFG, NULL))) {
if (!(filters[nr_filt] = regex_filter_create(cn->v, 0, 1))) {
diff --git a/lib/filters/filter-internal.c b/lib/filters/filter-internal.c
deleted file mode 100644
index a49c07e53..000000000
--- a/lib/filters/filter-internal.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2006 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "base/memory/zalloc.h"
-#include "lib/misc/lib.h"
-#include "lib/filters/filter.h"
-
-static DM_LIST_INIT(_allow_devs);
-
-int internal_filter_allow(struct dm_pool *mem, struct device *dev)
-{
- struct device_list *devl;
-
- if (!(devl = dm_pool_alloc(mem, sizeof(*devl)))) {
- log_error("device_list element allocation failed");
- return 0;
- }
- devl->dev = dev;
-
- dm_list_add(&_allow_devs, &devl->list);
- return 1;
-}
-
-void internal_filter_clear(void)
-{
- dm_list_init(&_allow_devs);
-}
-
-static int _passes_internal(struct cmd_context *cmd, struct dev_filter *f __attribute__((unused)),
- struct device *dev, const char *use_filter_name)
-{
- struct device_list *devl;
-
- dev->filtered_flags &= ~DEV_FILTERED_INTERNAL;
-
- if (!internal_filtering())
- return 1;
-
- dm_list_iterate_items(devl, &_allow_devs) {
- if (devl->dev == dev)
- return 1;
- }
-
- dev->filtered_flags |= DEV_FILTERED_INTERNAL;
- log_debug_devs("%s: Skipping for internal filtering.", dev_name(dev));
- return 0;
-}
-
-static void _destroy(struct dev_filter *f)
-{
- if (f->use_count)
- log_error(INTERNAL_ERROR "Destroying internal filter while in use %u times.", f->use_count);
-
- free(f);
-}
-
-struct dev_filter *internal_filter_create(void)
-{
- struct dev_filter *f;
-
- if (!(f = zalloc(sizeof(*f)))) {
- log_error("md filter allocation failed");
- return NULL;
- }
-
- f->passes_filter = _passes_internal;
- f->destroy = _destroy;
- f->use_count = 0;
- f->name = "internal";
-
- log_debug_devs("Internal filter initialised.");
-
- return f;
-}
-
diff --git a/lib/filters/filter.h b/lib/filters/filter.h
index bff58c9a4..4cdfa2c9b 100644
--- a/lib/filters/filter.h
+++ b/lib/filters/filter.h
@@ -32,10 +32,6 @@ struct dev_filter *sysfs_filter_create(void);
struct dev_filter *signature_filter_create(struct dev_types *dt);
struct dev_filter *deviceid_filter_create(struct cmd_context *cmd);
-struct dev_filter *internal_filter_create(void);
-int internal_filter_allow(struct dm_pool *mem, struct device *dev);
-void internal_filter_clear(void);
-
/*
* patterns must be an array of strings of the form:
* [ra]<sep><regex><sep>, eg,
1 year, 5 months
main - filter: remove unused EAGAIN case and flag
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6cb0b44cd2f518ed32c...
Commit: 6cb0b44cd2f518ed32c9bef571986d51c775c99b
Parent: fb7698b0ce47b965db056022cad712a965554f3a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Apr 1 15:06:03 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Apr 6 12:51:34 2022 -0500
filter: remove unused EAGAIN case and flag
The case of filters returning EAGAIN and using the
FILTER_AFTER_SCAN flag is no longer used.
---
lib/device/dev-cache.c | 21 +--------------------
lib/device/dev-luks.c | 3 ---
lib/device/dev-md.c | 6 ------
lib/device/dev-swap.c | 3 ---
lib/device/dev-type.c | 5 -----
lib/device/device.h | 4 ++--
lib/filters/filter-md.c | 8 --------
lib/filters/filter-partitioned.c | 8 --------
lib/filters/filter-persistent.c | 20 +++++---------------
lib/filters/filter-signature.c | 7 -------
10 files changed, 8 insertions(+), 77 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 5607beefc..3aaf6a2e5 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1606,18 +1606,6 @@ static struct device *_dev_cache_get(struct cmd_context *cmd, const char *name,
return dev;
ret = f->passes_filter(cmd, f, dev, NULL);
-
- /*
- * This might happen if this function is called before
- * filters can do i/o. I don't think this will happen
- * any longer and this EAGAIN case can be removed.
- */
- if (ret == -EAGAIN) {
- log_debug_devs("dev_cache_get filter deferred %s", dev_name(dev));
- dev->flags |= DEV_FILTER_AFTER_SCAN;
- ret = 1;
- }
-
if (!ret) {
log_debug_devs("dev_cache_get filter excludes %s", dev_name(dev));
return NULL;
@@ -1688,16 +1676,9 @@ struct device *dev_iter_get(struct cmd_context *cmd, struct dev_iter *iter)
f = iter->filter;
- if (f && !(d->flags & DEV_REGULAR)) {
+ if (f && !(d->flags & DEV_REGULAR))
ret = f->passes_filter(cmd, f, d, NULL);
- if (ret == -EAGAIN) {
- log_debug_devs("get device by iter defer filter %s", dev_name(d));
- d->flags |= DEV_FILTER_AFTER_SCAN;
- ret = 1;
- }
- }
-
if (!f || (d->flags & DEV_REGULAR) || ret)
return d;
}
diff --git a/lib/device/dev-luks.c b/lib/device/dev-luks.c
index d8c422519..2434d6291 100644
--- a/lib/device/dev-luks.c
+++ b/lib/device/dev-luks.c
@@ -23,9 +23,6 @@ int dev_is_luks(struct cmd_context *cmd, struct device *dev, uint64_t *offset_fo
char buf[LUKS_SIGNATURE_SIZE];
int ret = -1;
- if (!scan_bcache)
- return -EAGAIN;
-
if (offset_found)
*offset_found = 0;
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index 4debe9e99..fa4ff123f 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -178,12 +178,6 @@ static int _dev_is_md_component_native(struct device *dev, uint64_t *offset_foun
uint64_t size, sb_offset = 0;
int ret;
- /* i/o layer has not been set up */
- if (!scan_bcache) {
- log_error(INTERNAL_ERROR "dev_is_md_component_native requires io layer.");
- return -1;
- }
-
if (!dev_get_size(dev, &size)) {
stack;
return -1;
diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c
index 1d2a4c9d1..86d67df3c 100644
--- a/lib/device/dev-swap.c
+++ b/lib/device/dev-swap.c
@@ -42,9 +42,6 @@ int dev_is_swap(struct cmd_context *cmd, struct device *dev, uint64_t *offset_fo
unsigned page;
int ret = 0;
- if (!scan_bcache)
- return -EAGAIN;
-
if (!dev_get_size(dev, &size)) {
stack;
return -1;
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index c67a86fa3..939eb4aeb 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -674,11 +674,6 @@ static int _dev_is_partitioned_native(struct dev_types *dt, struct device *dev)
{
int r;
- if (!scan_bcache) {
- log_error(INTERNAL_ERROR "dev_is_partitioned_native requires i/o.");
- return -1;
- }
-
/* Unpartitioned DASD devices are not supported. */
if ((MAJOR(dev->dev) == dt->dasd_major) && dasd_is_cdl_formatted(dev))
return 1;
diff --git a/lib/device/device.h b/lib/device/device.h
index 572994bb9..d0d670ec3 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -32,8 +32,8 @@
#define DEV_NOT_O_NOATIME 0x00000400 /* Don't use O_NOATIME */
#define DEV_IN_BCACHE 0x00000800 /* dev fd is open and used in bcache */
#define DEV_BCACHE_EXCL 0x00001000 /* bcache_fd should be open EXCL */
-#define DEV_FILTER_AFTER_SCAN 0x00002000 /* apply filter after bcache has data */
-#define DEV_FILTER_OUT_SCAN 0x00004000 /* filtered out during label scan */
+/* unused 0x00002000 */
+/* unused 0x00004000 */
#define DEV_BCACHE_WRITE 0x00008000 /* bcache_fd is open with RDWR */
#define DEV_SCAN_FOUND_LABEL 0x00010000 /* label scan read dev and found label */
#define DEV_IS_MD_COMPONENT 0x00020000 /* device is an md component */
diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c
index 865fde1a2..84bfcadb0 100644
--- a/lib/filters/filter-md.c
+++ b/lib/filters/filter-md.c
@@ -99,14 +99,6 @@ static int _passes_md_filter(struct cmd_context *cmd, struct dev_filter *f __att
return 1;
ret = dev_is_md_component(cmd, dev, NULL, cmd->use_full_md_check);
-
- if (ret == -EAGAIN) {
- /* let pass, call again after scan */
- dev->flags |= DEV_FILTER_AFTER_SCAN;
- log_debug_devs("filter md deferred %s", dev_name(dev));
- return 1;
- }
-
if (ret == 0)
return 1;
diff --git a/lib/filters/filter-partitioned.c b/lib/filters/filter-partitioned.c
index 642553ef2..cab86e9b4 100644
--- a/lib/filters/filter-partitioned.c
+++ b/lib/filters/filter-partitioned.c
@@ -30,14 +30,6 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED;
ret = dev_is_partitioned(cmd, dev);
-
- if (ret == -EAGAIN) {
- /* let pass, call again after scan */
- log_debug_devs("filter partitioned deferred %s", dev_name(dev));
- dev->flags |= DEV_FILTER_AFTER_SCAN;
- return 1;
- }
-
if (ret) {
if (dev->ext.src == DEV_EXT_NONE)
log_debug_devs(MSG_SKIPPING, dev_name(dev));
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index c164c4a99..212a5c183 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -109,8 +109,6 @@ static int _lookup_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
/* Uncached, check filters and cache the result */
if (!l) {
- dev->flags &= ~DEV_FILTER_AFTER_SCAN;
-
pass = pf->real->passes_filter(cmd, pf->real, dev, use_filter_name);
if (!pass) {
@@ -120,21 +118,13 @@ static int _lookup_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
* because the deferred result won't change the exclude.
*/
l = PF_BAD_DEVICE;
-
- } else if ((pass == -EAGAIN) || (dev->flags & DEV_FILTER_AFTER_SCAN)) {
- /*
- * When the filter result is deferred, we let the device
- * pass for now, but do not cache the result. We need to
- * rerun the filters later. At that point the final result
- * will be cached.
- */
- log_debug_devs("filter cache deferred %s", dev_name(dev));
- dev->flags |= DEV_FILTER_AFTER_SCAN;
+ } else if (pass == 1) {
+ l = PF_GOOD_DEVICE;
+ } else {
+ log_error("Ignore invalid filter result %d %s", pass, dev_name(dev));
pass = 1;
+ /* don't cache invalid result */
goto out;
-
- } else if (pass) {
- l = PF_GOOD_DEVICE;
}
if (!dev->filtered_flags) /* skipping reason already logged by filter */
diff --git a/lib/filters/filter-signature.c b/lib/filters/filter-signature.c
index eeefa4f58..dd9922471 100644
--- a/lib/filters/filter-signature.c
+++ b/lib/filters/filter-signature.c
@@ -33,13 +33,6 @@ static int _ignore_signature(struct cmd_context *cmd, struct dev_filter *f __att
dev->filtered_flags &= ~DEV_FILTERED_SIGNATURE;
- if (!scan_bcache) {
- /* let pass, call again after scan */
- log_debug_devs("filter signature deferred %s", dev_name(dev));
- dev->flags |= DEV_FILTER_AFTER_SCAN;
- return 1;
- }
-
memset(buf, 0, BUFSIZE);
if (!dev_read_bytes(dev, 0, BUFSIZE, buf)) {
1 year, 5 months
main - lvmdevices: --deldev using device id
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fb7698b0ce47b965db0...
Commit: fb7698b0ce47b965db056022cad712a965554f3a
Parent: 151ce8b27672134438d0bc457f49123db96a176c
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Apr 6 12:29:26 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Apr 6 12:51:34 2022 -0500
lvmdevices: --deldev using device id
When used with --deviceidtype, --deldev can specify
a device id to remove.
---
lib/device/device_id.c | 6 +++---
lib/device/device_id.h | 1 +
man/lvmdevices.8_des | 1 +
test/shell/devicesfile-edit.sh | 21 +++++++++++++++++++
tools/args.h | 8 +++++--
tools/command-lines.in | 3 ++-
tools/lvmdevices.c | 47 +++++++++++++++++++++++++++++++++++++++++-
7 files changed, 80 insertions(+), 7 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 0f7c42f79..6c7136d5f 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -935,7 +935,7 @@ struct dev_use *get_du_for_devname(struct cmd_context *cmd, const char *devname)
return NULL;
}
-static struct dev_use *_get_du_for_device_id(struct cmd_context *cmd, uint16_t idtype, const char *idname)
+struct dev_use *get_du_for_device_id(struct cmd_context *cmd, uint16_t idtype, const char *idname)
{
struct dev_use *du;
@@ -1128,7 +1128,7 @@ id_done:
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);
+ du_devid = get_du_for_device_id(cmd, id->idtype, id->idname);
if (du_dev)
log_debug("device_id_add %s pvid %s matches entry %p dev %s",
@@ -1322,7 +1322,7 @@ void device_id_update_vg_uuid(struct cmd_context *cmd, struct volume_group *vg,
memcpy(old_idname+4, old_vgid, ID_LEN);
memcpy(old_idname+4+ID_LEN, &lvl->lv->lvid.id[1], ID_LEN);
- if ((du = _get_du_for_device_id(cmd, DEV_ID_TYPE_LVMLV_UUID, old_idname))) {
+ if ((du = get_du_for_device_id(cmd, DEV_ID_TYPE_LVMLV_UUID, old_idname))) {
log_debug("device_id update %s pvid %s vgid %s to %s",
du->devname ?: ".", du->pvid ?: ".", old_vgid, new_vgid);
memcpy(du->idname+4, new_vgid, ID_LEN);
diff --git a/lib/device/device_id.h b/lib/device/device_id.h
index 03c3ecaec..94773a65e 100644
--- a/lib/device/device_id.h
+++ b/lib/device/device_id.h
@@ -43,6 +43,7 @@ struct dev_use *get_du_for_devno(struct cmd_context *cmd, dev_t devno);
struct dev_use *get_du_for_dev(struct cmd_context *cmd, struct device *dev);
struct dev_use *get_du_for_pvid(struct cmd_context *cmd, const char *pvid);
struct dev_use *get_du_for_devname(struct cmd_context *cmd, const char *devname);
+struct dev_use *get_du_for_device_id(struct cmd_context *cmd, uint16_t idtype, const char *idname);
char *devices_file_version(void);
int devices_file_exists(struct cmd_context *cmd);
diff --git a/man/lvmdevices.8_des b/man/lvmdevices.8_des
index 2335456ad..289aad466 100644
--- a/man/lvmdevices.8_des
+++ b/man/lvmdevices.8_des
@@ -85,6 +85,7 @@ is used for dm crypt devices, reported by sysfs.
.IP \[bu] 2
.B md_uuid
is used for md devices, reported by sysfs.
+.IP \[bu] 2
.B lvmlv_uuid
is used if a PV is placed on top of an lvm LV, reported by sysfs.
.IP \[bu] 2
diff --git a/test/shell/devicesfile-edit.sh b/test/shell/devicesfile-edit.sh
index 1675cb732..2a046e213 100644
--- a/test/shell/devicesfile-edit.sh
+++ b/test/shell/devicesfile-edit.sh
@@ -135,6 +135,24 @@ lvmdevices --deldev "$LOOP1"
not grep "$LOOP1" $DF
lvmdevices --deldev "$LOOP2"
not grep "$LOOP2" $DF
+rm $DF
+
+# deldev using idname
+lvmdevices --adddev "$LOOP1"
+lvmdevices --adddev "$LOOP2"
+vgcreate $vg "$LOOP1" "$LOOP2"
+IDNAME1=`pvs "$LOOP1" --noheading -o deviceid | tr -d - | awk '{print $1}'`
+IDNAME2=`pvs "$LOOP2" --noheading -o deviceid | tr -d - | awk '{print $1}'`
+lvmdevices --deldev "$IDNAME2" --deviceidtype loop_file
+not grep "$IDNAME2" $DF
+not grep "$LOOP2" $DF
+lvmdevices --deldev "$IDNAME1" --deviceidtype loop_file
+not grep "$IDNAME1" $DF
+not grep "$LOOP1" $DF
+lvmdevices --adddev "$LOOP1"
+lvmdevices --adddev "$LOOP2"
+vgremove $vg
+rm $DF
# add/delpvid with default idtype loop_file
lvmdevices --addpvid "$PVID1"
@@ -151,6 +169,7 @@ not grep "$PVID1" $DF
lvmdevices --delpvid "$PVID2"
not grep "$LOOP2" $DF
not grep "$PVID2" $DF
+rm $DF
# add/deldev with non-default idtype devname
lvmdevices --adddev "$LOOP1" --deviceidtype devname
@@ -165,6 +184,7 @@ lvmdevices --deldev "$LOOP1"
not grep "$LOOP1" $DF
lvmdevices --deldev "$LOOP2"
not grep "$LOOP2" $DF
+rm $DF
# add/delpvid with non-default idtype devname
lvmdevices --addpvid "$PVID1" --deviceidtype devname
@@ -179,6 +199,7 @@ lvmdevices --deldev "$LOOP1"
not grep "$LOOP1" $DF
lvmdevices --deldev "$LOOP2"
not grep "$LOOP2" $DF
+rm $DF
# add/deldev when dev is missing, using default idtype
lvmdevices --adddev "$LOOP1"
diff --git a/tools/args.h b/tools/args.h
index 03fe24556..c4d8fe7ff 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -46,8 +46,12 @@ arg(addtag_ARG, '\0', "addtag", tag_VAL, ARG_GROUPABLE, 0,
arg(adddev_ARG, '\0', "adddev", pv_VAL, 0, 0,
"Add a device to the devices file.\n")
-arg(deldev_ARG, '\0', "deldev", pv_VAL, 0, 0,
- "Remove a device from the devices file.\n")
+
+arg(deldev_ARG, '\0', "deldev", string_VAL, 0, 0,
+ "Remove a device from the devices file.\n"
+ "When used alone, --deldev specifies a device name.\n"
+ "When used with --deviceidtype, --deldev specifies a device id.\n")
+
arg(addpvid_ARG, '\0', "addpvid", string_VAL, 0, 0,
"Find a device with the PVID and add the device to the devices file.\n")
arg(delpvid_ARG, '\0', "delpvid", string_VAL, 0, 0,
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 6f431e233..ce350e95c 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1434,7 +1434,8 @@ OO: --deviceidtype String
ID: lvmdevices_edit
DESC: Add a device to the devices file.
-lvmdevices --deldev PV
+lvmdevices --deldev PV|String
+OO: --deviceidtype String
ID: lvmdevices_edit
DESC: Remove a device from the devices file.
diff --git a/tools/lvmdevices.c b/tools/lvmdevices.c
index b03411b8b..04f707519 100644
--- a/tools/lvmdevices.c
+++ b/tools/lvmdevices.c
@@ -416,12 +416,15 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
goto out;
}
- if (arg_is_set(cmd, deldev_ARG)) {
+ if (arg_is_set(cmd, deldev_ARG) && !arg_is_set(cmd, deviceidtype_ARG)) {
const char *devname;
if (!(devname = arg_str_value(cmd, deldev_ARG, NULL)))
goto_bad;
+ if (strncmp(devname, "/dev/", 5))
+ log_warn("WARNING: to remove a device by device id, include --deviceidtype.");
+
/*
* No filter because we always want to allow removing a device
* by name from the devices file.
@@ -453,6 +456,48 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
goto out;
}
+ /*
+ * By itself, --deldev <devname> specifies a device name to remove.
+ * With an id type specified, --deldev specifies a device id to remove:
+ * --deldev <idname> --deviceidtype <idtype>
+ */
+ if (arg_is_set(cmd, deldev_ARG) && arg_is_set(cmd, deviceidtype_ARG)) {
+ const char *idtype_str = arg_str_value(cmd, deviceidtype_ARG, NULL);
+ const char *idname = arg_str_value(cmd, deldev_ARG, NULL);
+ int idtype;
+
+ if (!idtype_str || !idname || !strlen(idname) || !strlen(idtype_str))
+ goto_bad;
+
+ if (!(idtype = idtype_from_str(idtype_str))) {
+ log_error("Unknown device_id type.");
+ goto_bad;
+ }
+
+ if (!strncmp(idname, "/dev/", 5))
+ log_warn("WARNING: to remove a device by name, do not include --deviceidtype.");
+
+ if (!(du = get_du_for_device_id(cmd, idtype, idname))) {
+ log_error("No devices file entry with device id %s %s.", idtype_str, idname);
+ goto_bad;
+ }
+
+ dev = du->dev;
+
+ if (dev && dev_is_used_by_active_lv(cmd, dev, NULL, NULL, NULL, NULL)) {
+ if (!arg_count(cmd, yes_ARG) &&
+ yes_no_prompt("Device %s is used by an active LV, continue to remove? ", dev_name(dev)) == 'n') {
+ log_error("Device not removed.");
+ goto bad;
+ }
+ }
+
+ dm_list_del(&du->list);
+ free_du(du);
+ device_ids_write(cmd);
+ goto out;
+ }
+
if (arg_is_set(cmd, delpvid_ARG)) {
struct id id;
char pvid[ID_LEN+1] = { 0 };
1 year, 5 months
main - vgimportdevices: fix incorrect deviceidtype usage
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=151ce8b27672134438d...
Commit: 151ce8b27672134438d0bc457f49123db96a176c
Parent: f840dbb3205754db1a339aba8e0f68fa40138ba1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Apr 6 12:20:26 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Apr 6 12:20:26 2022 -0500
vgimportdevices: fix incorrect deviceidtype usage
When a VG has PVs with different device id types,
it would try to use the idtype of the previous PV
in the loop. This would produce an unncessary warning,
or could lead to using the devname idtype when a better
idtype is available.
---
tools/vgimportdevices.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/vgimportdevices.c b/tools/vgimportdevices.c
index 2580613c4..ea205d941 100644
--- a/tools/vgimportdevices.c
+++ b/tools/vgimportdevices.c
@@ -57,8 +57,7 @@ static int _vgimportdevices_single(struct cmd_context *cmd,
dm_list_iterate_items(pvl, &vg->pvs) {
pv = pvl->pv;
- if (!idtypestr && pv->device_id_type)
- idtypestr = pv->device_id_type;
+ idtypestr = pv->device_id_type;
memcpy(pvid, &pvl->pv->id.uuid, ID_LEN);
device_id_add(cmd, pv->dev, pvid, idtypestr, NULL);
1 year, 5 months
main - pvscan: warn about /dev/sda excluded by devices file
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f840dbb3205754db1a3...
Commit: f840dbb3205754db1a339aba8e0f68fa40138ba1
Parent: 8db3b11e4ed94974bc25c26e2f1271c34f6ccf15
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Mar 31 14:47:42 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 1 13:38:21 2022 -0500
pvscan: warn about /dev/sda excluded by devices file
In most installations, /dev/sda* or /dev/vda* should be included
in system.devices because the root, home, etc LVs are usually on
sda or vda.
Add a special case warning when a pvscan autoactivation command
sees that /dev/sda* or /dev/vda* are excluded by system.devices,
either not listed or having a different device id.
---
tools/pvscan.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index cf1772165..1e47d754a 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -19,6 +19,7 @@
#include "lib/metadata/metadata.h"
#include "lib/label/hints.h"
#include "lib/device/online.h"
+#include "lib/filters/filter.h"
#include <dirent.h>
@@ -1435,6 +1436,27 @@ static int _pvscan_cache_all(struct cmd_context *cmd, int argc, char **argv,
return 1;
}
+/*
+ * If /dev/sda* of /dev/vda* is excluded by the devices file
+ * it's usually a misconfiguration that prevents proper booting,
+ * so make it a special case to give extra info to help debugging.
+ */
+static void _warn_excluded_root(struct cmd_context *cmd, struct device *dev)
+{
+ struct dev_use *du;
+ const char *cur_idname;
+
+ if (!(du = get_du_for_devname(cmd, dev_name(dev)))) {
+ log_warn("WARNING: no autoactivation for %s: not found in system.devices.", dev_name(dev));
+ return;
+ }
+
+ cur_idname = device_id_system_read(cmd, dev, du->idtype);
+
+ log_warn("WARNING: no autoactivation for %s: system.devices %s current %s.",
+ dev_name(dev), du->idname, cur_idname ?: "missing device id");
+}
+
static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
struct dm_list *complete_vgnames)
{
@@ -1545,6 +1567,12 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
log_print_pvscan(cmd, "%s excluded: %s.",
dev_name(devl->dev), dev_filtered_reason(devl->dev));
dm_list_del(&devl->list);
+
+ /* Special case warning when probable root dev is missing from system.devices */
+ if ((devl->dev->filtered_flags & DEV_FILTERED_DEVICES_FILE) &&
+ (!strncmp(dev_name(devl->dev), "/dev/sda", 8) ||
+ !strncmp(dev_name(devl->dev), "/dev/vda", 8)))
+ _warn_excluded_root(cmd, devl->dev);
}
}
1 year, 6 months
main - change messages about filtered devices
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8db3b11e4ed94974bc2...
Commit: 8db3b11e4ed94974bc25c26e2f1271c34f6ccf15
Parent: 23a9bd549a27cba63c525e7b3042a67e428c798f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Mar 31 11:38:08 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 1 13:38:21 2022 -0500
change messages about filtered devices
Change messages that refer to devices being "excluded by filters"
to say just "excluded". This will avoid mistaking the word
"filters" with the lvm.conf filter setting.
---
lib/device/device_id.c | 6 +++---
lib/label/label.c | 4 ++--
tools/lvmdevices.c | 4 ++--
tools/pvscan.c | 4 ++--
tools/vgimportclone.c | 4 ++--
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index fa71874d0..0f7c42f79 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -1777,7 +1777,7 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
* probably wants to do something about it.
*/
if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, "persistent")) {
- log_warn("Devices file %s is excluded by filter: %s.",
+ log_warn("Devices file %s is excluded: %s.",
dev_name(dev), dev_filtered_reason(dev));
continue;
}
@@ -1863,7 +1863,7 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs,
continue;
if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, "persistent")) {
- log_warn("Devices file %s is excluded by filter: %s.",
+ log_warn("Devices file %s is excluded: %s.",
dev_name(dev), dev_filtered_reason(dev));
/* FIXME: what if this dev is wrongly matched and should be checked below? */
continue;
@@ -2305,7 +2305,7 @@ void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_l
if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, NULL)) {
/* I don't think this would happen */
- log_warn("WARNING: new device %s for PVID %s does not pass filter %s.",
+ log_warn("WARNING: new device %s for PVID %s is excluded: %s.",
dev_name(dev), dil->pvid, dev_filtered_reason(dev));
if (du) /* Should not happen 'du' is NULL */
du->dev = NULL;
diff --git a/lib/label/label.c b/lib/label/label.c
index e6bc791a7..711edb6f4 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1103,7 +1103,7 @@ int label_scan_vg_online(struct cmd_context *cmd, const char *vgname,
dm_list_iterate_items_safe(devl, devl2, &devs) {
if (!cmd->filter->passes_filter(cmd, cmd->filter, devl->dev, NULL)) {
- log_print("%s excluded by filters: %s.",
+ log_print("%s excluded: %s.",
dev_name(devl->dev), dev_filtered_reason(devl->dev));
dm_list_del(&devl->list);
dm_list_add(&devs_drop, &devl->list);
@@ -1169,7 +1169,7 @@ int label_scan_vg_online(struct cmd_context *cmd, const char *vgname,
/* Applies all filters, including those that need data from dev. */
if (!cmd->filter->passes_filter(cmd, cmd->filter, devl->dev, NULL)) {
- log_print("%s excluded by filters: %s.",
+ log_print("%s excluded: %s.",
dev_name(devl->dev), dev_filtered_reason(devl->dev));
dm_list_del(&devl->list);
dm_list_add(&devs_drop, &devl->list);
diff --git a/tools/lvmdevices.c b/tools/lvmdevices.c
index d30f86b75..b03411b8b 100644
--- a/tools/lvmdevices.c
+++ b/tools/lvmdevices.c
@@ -113,7 +113,7 @@ static void _search_devs_for_pvids(struct cmd_context *cmd, struct dm_list *sear
dev = devl->dev;
cmd->filter->wipe(cmd, cmd->filter, dev, NULL);
if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, NULL)) {
- log_warn("WARNING: PVID %s found on %s which is excluded by filter: %s",
+ log_warn("WARNING: PVID %s found on %s which is excluded: %s",
dev->pvid, dev_name(dev), dev_filtered_reason(dev));
dm_list_del(&devl->list);
}
@@ -353,7 +353,7 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
cmd->filter_deviceid_skip = 1;
if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, NULL)) {
- log_warn("WARNING: adding device %s that is excluded by filter: %s.",
+ log_warn("WARNING: adding device %s that is excluded: %s.",
dev_name(dev), dev_filtered_reason(dev));
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index db6709a5a..cf1772165 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -1542,7 +1542,7 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
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 by filters: %s.",
+ log_print_pvscan(cmd, "%s excluded: %s.",
dev_name(devl->dev), dev_filtered_reason(devl->dev));
dm_list_del(&devl->list);
}
@@ -1599,7 +1599,7 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
/* Applies all filters, including those that need data from dev. */
if (!cmd->filter->passes_filter(cmd, cmd->filter, devl->dev, NULL)) {
- log_print_pvscan(cmd, "%s excluded by filters: %s.",
+ log_print_pvscan(cmd, "%s excluded: %s.",
dev_name(devl->dev), dev_filtered_reason(devl->dev));
dm_list_del(&devl->list);
}
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
index 23bb6271f..cab501619 100644
--- a/tools/vgimportclone.c
+++ b/tools/vgimportclone.c
@@ -311,8 +311,8 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
*/
dm_list_iterate_items(devl, &vp.new_devs) {
if (!cmd->filter->passes_filter(cmd, cmd->filter, devl->dev, "persistent")) {
- /* FIXME: print which filter */
- log_error("Device %s was excluded by filters.", dev_name(devl->dev));
+ log_error("Device %s is excluded: %s.",
+ dev_name(devl->dev), dev_filtered_reason(devl->dev));
goto out;
}
}
1 year, 6 months