main - thin: fix message processing on thin-pool extension
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=09371131469f7398c59...
Commit: 09371131469f7398c597a5fb30dc565859253cc2
Parent: 86a0a652a9eedd932c7428ed82656f3fd40d13f8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 30 14:16:11 2022 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Mar 30 14:49:04 2022 +0200
thin: fix message processing on thin-pool extension
When thin-pool had queued some delete message on extension operation
such message has been 'lost' and thin-pool kernel metadata has been
left with a thin volume that no longer existed for lvm2 metadata.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 2 +-
test/shell/lvextend-thin-adddel.sh | 78 ++++++++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 006d0acb1..7c93d804d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.16 -
====================================
+ Fix lossing of delete message on thin-pool extension.
Version 2.03.15 - 07th February 2022
====================================
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 003748d6f..9523e3e66 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6179,7 +6179,7 @@ int lv_resize(struct logical_volume *lv,
if (lv_is_thin_pool(lock_lv)) {
/* Update lvm pool metadata (drop messages). */
- if (!update_pool_lv(lock_lv, 0))
+ if (!update_pool_lv(lock_lv, 1))
goto_bad;
}
diff --git a/test/shell/lvextend-thin-adddel.sh b/test/shell/lvextend-thin-adddel.sh
new file mode 100644
index 000000000..59b1bfa41
--- /dev/null
+++ b/test/shell/lvextend-thin-adddel.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2022 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
+
+#
+# Play with thin-pool and thin removal and creation in corner cases
+#
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
+
+. lib/inittest
+
+aux have_thin 1 0 0 || skip
+
+test -n "$LVM_TEST_THIN_RESTORE_CMD" || LVM_TEST_THIN_RESTORE_CMD=$(which thin_restore) || skip
+"$LVM_TEST_THIN_RESTORE_CMD" -V || skip
+
+aux have_thin 1 10 0 || skip
+
+aux prepare_vg 2
+
+lvcreate -V10 -n $lv1 -L10 -T $vg/pool
+lvcreate -V10 -n $lv2 $vg/pool
+
+# Forcibly 'error' _tmeta thin-pool metadata device
+not dmsetup remove -f $vg-pool_tmeta
+
+# Now try to schedule removal of thin volume id 1
+# that will fail with errored meta device
+not lvremove -y $vg/$lv1
+
+# Check we have queued 'message'
+vgcfgbackup -f out0 $vg
+grep "message1" out0
+
+vgchange -an $vg || true
+
+not dmsetup table ${vg}-pool-tpool
+
+# Reactivate thin-pool
+vgchange -ay $vg
+
+# Check message is still queued there
+vgcfgbackup -f out1 $vg
+grep "message1" out1
+
+lvchange -an $vg
+
+lvextend -L+10 $vg/pool
+
+# Messages should be now processed and gone
+vgcfgbackup -f out2 $vg
+not grep "message1" out2
+
+lvchange -an $vg
+
+lvchange -y -ay $vg/pool_tmeta
+
+# Kernel metadata must not see dev_id 1 either
+thin_dump $DM_DEV_DIR/$vg/pool_tmeta | tee meta
+not grep 'dev_id="1"' meta
+
+lvremove -ff $vg
+
+lvs -a $vg
+
+vgremove -ff $vg
1 year, 8 months
main - fix args entry for nolocking
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=86a0a652a9eedd932c7...
Commit: 86a0a652a9eedd932c7428ed82656f3fd40d13f8
Parent: f1578b4a5d0bf49ab2b07c86c982cfa5aaa60a84
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Mar 25 17:25:29 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Mar 25 17:25:29 2022 -0500
fix args entry for nolocking
typo in previous commit
---
tools/args.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/args.h b/tools/args.h
index ecb650234..03fe24556 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -499,7 +499,7 @@ arg(nohistory_ARG, '\0', "nohistory", 0, 0, 0,
"metadata/record_lvs_history is enabled.\n")
arg(nolocking_ARG, '\0', "nolocking", 0, 0, 0,
- "Disable locking. Use with caution, concurrent commands may produce\n")
+ "Disable locking. Use with caution, concurrent commands may produce\n"
"incorrect results.\n")
arg(norestorefile_ARG, '\0', "norestorefile", 0, 0, 0,
1 year, 8 months
main - Move nolocking warning to man page
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f1578b4a5d0bf49ab2b...
Commit: f1578b4a5d0bf49ab2b07c86c982cfa5aaa60a84
Parent: 72f0b637d239c893ca49b05b83e2ebddc327e900
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Mar 25 15:43:53 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Mar 25 15:43:53 2022 -0500
Move nolocking warning to man page
It's more logical to warn about --nolocking in the man page
before it's used rather than after it's used and too late.
Also, warnings are usually for things the user may not know.
---
tools/args.h | 3 ++-
tools/lvmcmdline.c | 5 +----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 56669645d..ecb650234 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -499,7 +499,8 @@ arg(nohistory_ARG, '\0', "nohistory", 0, 0, 0,
"metadata/record_lvs_history is enabled.\n")
arg(nolocking_ARG, '\0', "nolocking", 0, 0, 0,
- "Disable locking.\n")
+ "Disable locking. Use with caution, concurrent commands may produce\n")
+ "incorrect results.\n")
arg(norestorefile_ARG, '\0', "norestorefile", 0, 0, 0,
"In conjunction with --uuid, this allows a uuid to be specified\n"
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 241c6df18..1e3547ed7 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -3267,10 +3267,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, readonly_ARG))
readonly = 1;
- if (cmd->nolocking) {
- if (!_cmd_no_meta_proc(cmd))
- log_warn("WARNING: File locking is disabled.");
- } else {
+ if (!cmd->nolocking) {
if (!init_locking(cmd, sysinit, readonly, cmd->ignorelockingfailure)) {
ret = ECMD_FAILED;
goto_out;
1 year, 8 months
main - vgchange monitor: don't use udev info
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=72f0b637d239c893ca4...
Commit: 72f0b637d239c893ca49b05b83e2ebddc327e900
Parent: c7a5b5cca067496f5912bf992dcfedb6771dd083
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Mar 25 14:13:56 2022 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Mar 25 14:13:56 2022 -0500
vgchange monitor: don't use udev info
vgchange --monitor y is run during startup when udev is being
initialized and is not yet ready to be used.
---
tools/vgchange.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index fc076c1d5..09ade96a6 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -992,6 +992,17 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return ECMD_PROCESSED;
}
+ /*
+ * Do not use udev for device listing or device info because
+ * vgchange --monitor y is called during boot when udev is being
+ * initialized and is not yet ready to be used.
+ */
+ if (arg_is_set(cmd, monitor_ARG) &&
+ arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)) {
+ init_obtain_device_list_from_udev(0);
+ init_external_device_info_source(DEV_EXT_NONE);
+ }
+
if (update)
flags |= READ_FOR_UPDATE;
else if (arg_is_set(cmd, activate_ARG))
1 year, 8 months
main - pvscan: don't use udev for external device info
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c7a5b5cca067496f591...
Commit: c7a5b5cca067496f5912bf992dcfedb6771dd083
Parent: bef1363c0064f42e8063571143a428ad163d1bd9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 9 11:54:59 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 9 11:54:59 2022 -0600
pvscan: don't use udev for external device info
pvscan is used to populate udev info, so it can't expect
to use that udev info.
---
tools/pvscan.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index dcf183a46..db6709a5a 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -1710,13 +1710,11 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
}
/*
- * If obtain_device_list_from_udev was set to 1, force it to 0.
- * Don't ask udev for info since pvscan is running from udev.
- * If a pvscan attempts to get dev info from udev, udev can
- * repeatedly return errors about the dev not being initialized
- * which will stall the pvscan.
+ * Do not use udev for device listing or device info because pvscan
+ * is used to populate udev info.
*/
init_obtain_device_list_from_udev(0);
+ init_external_device_info_source(DEV_EXT_NONE);
if (arg_is_set(cmd, major_ARG) + arg_is_set(cmd, minor_ARG))
devno_args = 1;
1 year, 9 months
main - writecache: check memory usage
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bef1363c0064f42e806...
Commit: bef1363c0064f42e8063571143a428ad163d1bd9
Parent: cc73d99886dfd6e0da3c6ca685669f77fac3c1cd
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 1 14:31:39 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Mar 1 16:29:53 2022 -0600
writecache: check memory usage
warn if writecache neds > 50% of system memory, and
confirm if writecache needs > 90% of system memory.
---
tools/lvconvert.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index a3eb60b20..1c4351e9d 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -6070,6 +6070,69 @@ bad:
return 0;
}
+static int _check_writecache_memory(struct cmd_context *cmd, struct logical_volume *lv_fast,
+ uint32_t block_size_sectors)
+{
+ char line[128];
+ FILE *fp;
+ uint64_t cachevol_size_bytes = lv_fast->size * SECTOR_SIZE;
+ uint64_t need_mem_bytes = 0;
+ uint64_t proc_mem_bytes = 0;
+ uint64_t need_mem_gb;
+ uint64_t proc_mem_gb;
+ unsigned long long proc_mem_kb = 0;
+
+ if (!(fp = fopen("/proc/meminfo", "r")))
+ goto skip_proc;
+
+ while (fgets(line, sizeof(line), fp)) {
+ if (strncmp(line, "MemTotal:", 9))
+ continue;
+ if (sscanf(line, "%*s%llu%*s", &proc_mem_kb) != 1)
+ break;
+ break;
+ }
+ (void)fclose(fp);
+
+ proc_mem_bytes = proc_mem_kb * 1024;
+
+ skip_proc:
+ /* dm-writecache memory consumption per block is 88 bytes */
+ if (block_size_sectors == 8) {
+ need_mem_bytes = cachevol_size_bytes * 88 / 4096;
+ } else if (block_size_sectors == 1) {
+ need_mem_bytes = cachevol_size_bytes * 88 / 512;
+ } else {
+ /* shouldn't happen */
+ log_warn("Unknown memory usage for unknown writecache block_size_sectors %u", block_size_sectors);
+ return 1;
+ }
+
+ need_mem_gb = need_mem_bytes / 1073741824;
+ proc_mem_gb = proc_mem_bytes / 1073741824;
+
+ /*
+ * warn if writecache needs > 50% of main memory, and
+ * confirm if writecache needs > 90% of main memory.
+ */
+ if (need_mem_bytes >= (proc_mem_bytes / 2)) {
+ log_warn("WARNING: writecache size %s will use %llu GiB of system memory (%llu GiB).",
+ display_size(cmd, lv_fast->size),
+ (unsigned long long)need_mem_gb,
+ (unsigned long long)proc_mem_gb);
+
+ if (need_mem_gb >= (proc_mem_gb * 9 / 10)) {
+ if (!arg_is_set(cmd, yes_ARG) &&
+ yes_no_prompt("Continue adding writecache? [y/n]: ") == 'n') {
+ log_error("Conversion aborted.");
+ return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
int lvconvert_writecache_attach_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
@@ -6158,6 +6221,12 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,
goto_bad;
}
+ if (!_check_writecache_memory(cmd, lv_fast, block_size_sectors)) {
+ if (!is_active && !deactivate_lv(cmd, lv))
+ stack;
+ goto_bad;
+ }
+
if (!is_active) {
if (!deactivate_lv(cmd, lv)) {
log_error("Failed to deactivate LV after checking block size %s", display_lvname(lv));
1 year, 9 months
main - devices: only close PVs on LVs when scan_lvs is enabled
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cc73d99886dfd6e0da3...
Commit: cc73d99886dfd6e0da3c6ca685669f77fac3c1cd
Parent: 7b1a857d5ac480b789af07d85e55bc87c6a76934
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 1 12:22:46 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Mar 1 14:11:05 2022 -0600
devices: only close PVs on LVs when scan_lvs is enabled
This code is only needed when lvm scans PVs that are stacked on LVs.
---
lib/label/label.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index c20863875..e6bc791a7 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1661,9 +1661,11 @@ void label_scan_invalidate_lvs(struct cmd_context *cmd, struct dm_list *lvs)
dev_t devt;
/*
- * FIXME: this is all unnecessary unless there are PVs stacked on LVs,
- * so we can skip all of this if scan_lvs=0.
+ * This is only needed when the command sees PVs stacked on LVs which
+ * will only happen with scan_lvs=1.
*/
+ if (!cmd->scan_lvs)
+ return;
log_debug("invalidating devs for any pvs on lvs");
if (get_device_list(NULL, &devs, &devs_features)) {
1 year, 9 months
main - devices: use dev-cache aliases handling from label scan functions
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7b1a857d5ac480b789a...
Commit: 7b1a857d5ac480b789af07d85e55bc87c6a76934
Parent: 4eb04c8c05e52776891f62863375ceacf866de77
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 28 17:37:12 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 28 17:37:12 2022 -0600
devices: use dev-cache aliases handling from label scan functions
The label scan functions where doing some device alias validation
which is now better handled by the dev-cache layer, so just use
that.
---
lib/device/dev-cache.c | 4 +-
lib/device/dev-cache.h | 1 +
lib/label/label.c | 143 ++++++++++++-------------------------------------
3 files changed, 36 insertions(+), 112 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 8db28bd84..5607beefc 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1410,7 +1410,7 @@ static void _remove_alias(struct device *dev, const char *name)
* deactivated LV. Those old paths are all invalid and are dropped here.
*/
-static void _verify_aliases(struct device *dev)
+void dev_cache_verify_aliases(struct device *dev)
{
struct dm_str_list *strl, *strl2;
struct stat st;
@@ -1459,7 +1459,7 @@ static struct device *_dev_cache_get(struct cmd_context *cmd, const char *name,
_remove_alias(dev, name);
/* Remove any other names in dev->aliases that are incorrect. */
- _verify_aliases(dev);
+ dev_cache_verify_aliases(dev);
}
return NULL;
}
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 622335982..46b1da72c 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -55,6 +55,7 @@ int dev_cache_add_dir(const char *path);
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
struct device *dev_cache_get_existing(struct cmd_context *cmd, const char *name, struct dev_filter *f);
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t devt);
+void dev_cache_verify_aliases(struct device *dev);
struct device *dev_hash_get(const char *name);
diff --git a/lib/label/label.c b/lib/label/label.c
index ffb393891..c20863875 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -459,7 +459,6 @@ static int _scan_dev_open(struct device *dev)
const char *name;
const char *modestr;
struct stat sbuf;
- int retried = 0;
int flags = 0;
int fd, di;
@@ -479,14 +478,23 @@ static int _scan_dev_open(struct device *dev)
return 0;
}
+ next_name:
/*
* All the names for this device (major:minor) are kept on
* dev->aliases, the first one is the primary/preferred name.
+ *
+ * The default name preferences in dev-cache mean that the first
+ * name in dev->aliases is not a symlink for scsi devices, but is
+ * the /dev/mapper/ symlink for mpath devices.
+ *
+ * If preferred names are set to symlinks, should this
+ * first attempt to open using a non-symlink?
+ *
+ * dm_list_first() returns NULL if the list is empty.
*/
if (!(name_list = dm_list_first(&dev->aliases))) {
- /* Shouldn't happen */
- log_error("Device open %s %d:%d has no path names.",
- dev_name(dev), (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
+ log_error("Device open %d:%d has no path names.",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
return 0;
}
name_sl = dm_list_item(name_list, struct dm_str_list);
@@ -514,50 +522,34 @@ static int _scan_dev_open(struct device *dev)
modestr = "ro";
}
-retry_open:
-
fd = open(name, flags, 0777);
-
if (fd < 0) {
if ((errno == EBUSY) && (flags & O_EXCL)) {
log_error("Can't open %s exclusively. Mounted filesystem?",
dev_name(dev));
+ return 0;
} else {
- int major, minor;
-
/*
- * Shouldn't happen, if it does, print stat info to help figure
- * out what's wrong.
+ * drop name from dev->aliases and use verify_aliases to
+ * drop any other invalid aliases before retrying open with
+ * any remaining valid paths.
*/
-
- major = (int)MAJOR(dev->dev);
- minor = (int)MINOR(dev->dev);
-
- log_error("Device open %s %d:%d failed errno %d", name, major, minor, errno);
-
- if (stat(name, &sbuf)) {
- log_debug_devs("Device open %s %d:%d stat failed errno %d",
- name, major, minor, errno);
- } else if (sbuf.st_rdev != dev->dev) {
- log_debug_devs("Device open %s %d:%d stat %d:%d does not match.",
- name, major, minor,
- (int)MAJOR(sbuf.st_rdev), (int)MINOR(sbuf.st_rdev));
- }
-
- if (!retried) {
- /*
- * FIXME: remove this, the theory for this retry is that
- * there may be a udev race that we can sometimes mask by
- * retrying. This is here until we can figure out if it's
- * needed and if so fix the real problem.
- */
- usleep(5000);
- log_debug_devs("Device open %s retry", dev_name(dev));
- retried = 1;
- goto retry_open;
- }
+ log_debug("Drop alias for %d:%d failed open %s (%d)",
+ (int)MAJOR(dev->dev), (int)MINOR(dev->dev), name, errno);
+ dev_cache_failed_path(dev, name);
+ dev_cache_verify_aliases(dev);
+ goto next_name;
}
- return 0;
+ }
+
+ /* Verify that major:minor from the path still match dev. */
+ if ((fstat(fd, &sbuf) < 0) || (sbuf.st_rdev != dev->dev)) {
+ log_warn("Invalid path %s for device %d:%d, trying different path.",
+ name, (int)MAJOR(dev->dev), (int)MINOR(dev->dev));
+ (void)close(fd);
+ dev_cache_failed_path(dev, name);
+ dev_cache_verify_aliases(dev);
+ goto next_name;
}
dev->flags |= DEV_IN_BCACHE;
@@ -605,37 +597,6 @@ static int _scan_dev_close(struct device *dev)
return 1;
}
-static void _drop_bad_aliases(struct device *dev)
-{
- struct dm_str_list *strl, *strl2;
- const char *name;
- struct stat sbuf;
- int major = (int)MAJOR(dev->dev);
- int minor = (int)MINOR(dev->dev);
- int bad;
-
- dm_list_iterate_items_safe(strl, strl2, &dev->aliases) {
- name = strl->str;
- bad = 0;
-
- if (stat(name, &sbuf)) {
- bad = 1;
- log_debug_devs("Device path check %d:%d %s stat failed errno %d",
- major, minor, name, errno);
- } else if (sbuf.st_rdev != dev->dev) {
- bad = 1;
- log_debug_devs("Device path check %d:%d %s stat %d:%d does not match.",
- major, minor, name,
- (int)MAJOR(sbuf.st_rdev), (int)MINOR(sbuf.st_rdev));
- }
-
- if (bad) {
- log_debug_devs("Device path check %d:%d dropping path %s.", major, minor, name);
- dev_cache_failed_path(dev, name);
- }
- }
-}
-
// Like bcache_invalidate, only it throws any dirty data away if the
// write fails.
static void _invalidate_di(struct bcache *cache, int di)
@@ -663,10 +624,8 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
char headers_buf[HEADERS_BUF_SIZE];
struct dm_list wait_devs;
struct dm_list done_devs;
- struct dm_list reopen_devs;
struct device_list *devl, *devl2;
struct block *bb;
- int retried_open = 0;
int scan_read_errors = 0;
int scan_process_errors = 0;
int scan_failed_count = 0;
@@ -677,7 +636,6 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
dm_list_init(&wait_devs);
dm_list_init(&done_devs);
- dm_list_init(&reopen_devs);
log_debug_devs("Scanning %d devices for VG info", dm_list_size(devs));
@@ -701,9 +659,9 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
if (!_in_bcache(devl->dev)) {
if (!_scan_dev_open(devl->dev)) {
- log_debug_devs("Scan failed to open %s.", dev_name(devl->dev));
+ log_debug_devs("Scan failed to open %d:%d %s.",
+ (int)MAJOR(devl->dev->dev), (int)MINOR(devl->dev->dev), dev_name(devl->dev));
dm_list_del(&devl->list);
- dm_list_add(&reopen_devs, &devl->list);
devl->dev->flags |= DEV_SCAN_NOT_READ;
continue;
}
@@ -787,41 +745,6 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
if (!dm_list_empty(devs))
goto scan_more;
- /*
- * We're done scanning all the devs. If we failed to open any of them
- * the first time through, refresh device paths and retry. We failed
- * to open the devs on the reopen_devs list.
- *
- * FIXME: it's not clear if or why this helps.
- */
- if (!dm_list_empty(&reopen_devs)) {
- if (retried_open) {
- /* Don't try again. */
- scan_failed_count += dm_list_size(&reopen_devs);
- dm_list_splice(&done_devs, &reopen_devs);
- goto out;
- }
- retried_open = 1;
-
- dm_list_iterate_items_safe(devl, devl2, &reopen_devs) {
- _drop_bad_aliases(devl->dev);
-
- if (dm_list_empty(&devl->dev->aliases)) {
- log_warn("WARNING: Scan ignoring device %d:%d with no paths.",
- (int)MAJOR(devl->dev->dev),
- (int)MINOR(devl->dev->dev));
-
- dm_list_del(&devl->list);
- lvmcache_del_dev(devl->dev);
- scan_failed_count++;
- }
- }
-
- /* Put devs that failed to open back on the original list to retry. */
- dm_list_splice(devs, &reopen_devs);
- goto scan_more;
- }
-out:
log_debug_devs("Scanned devices: read errors %d process errors %d failed %d",
scan_read_errors, scan_process_errors, scan_failed_count);
1 year, 9 months