- Update lvm2 from LVM2.2.03.15 to LVM2.2.03.16 *** WHATS_NEW for 2.03.16 *** Version 2.03.16 - 18th May 2022 =============================== Fix segfault when handling selection with historical LVs. Add support --vdosettings with lvcreate, lvconvert, lvchange. Filtering multipath devices respects blacklist setting from multipath configuration. lvmdevices support for removing by device id using --deviceidtype and --deldev. Display writecache block size with lvs -o writecache_block_size. Improve cachesettings description in man lvmcache. Fix lossing of delete message on thin-pool extension. - Drop patches that have been merged into upstream - 0001-post-release.patch - 0002-asan-fix-some-reports-from-libasan.patch - 0003-make-generate.patch - 0004-tests-udev-pvscan-vgchange-fix-service-wait.patch - 0005-devices-file-do-not-clear-PVID-of-unread-devices.patch - 0006-tests-skip-vgchange-pvs-online.sh-on-rhel5.patch - 0007-dev_manager-fix-dm_task_get_device_list.patch - 0008-dev_manager-failing-status-is-not-internal-error.patch - 0009-clang-add-extra-check.patch - 0010-clang-possible-better-compilation-with-musl-c.patch - 0011-dev_manager-do-not-query-for-open_count.patch - 0012-dev_manager-use-list-info-for-preset-devs.patch - 0013-man-lvmcache-add-more-writecache-cachesettings-info.patch - 0014-man-update-cachesettings-option-description.patch - 0015-man-lvmcache-mention-writecache-memory-usage.patch - 0016-writecache-display-block-size-from-lvs.patch - 0017-devices-simplify-dev_cache_get_by_devt.patch - 0018-devices-drop-incorrect-paths-from-aliases-list.patch - 0019-devices-initial-use-of-existing-option.patch - 0020-devices-fix-dev_name-assumptions.patch - 0021-devices-use-dev-cache-aliases-handling-from-label-sc.patch - 0022-devices-only-close-PVs-on-LVs-when-scan_lvs-is-enabl.patch - 0023-writecache-check-memory-usage.patch - 0024-pvscan-don-t-use-udev-for-external-device-info.patch - 0025-vgchange-monitor-don-t-use-udev-info.patch - Add upstream patch - 0001-devices-file-move-clean-up-after-command-is-run.patch - 0002-devices-file-fail-if-devicesfile-filename-doesn-t-ex.patch - 0003-filter-mpath-handle-other-wwid-types-in-blacklist.patch - 0004-filter-mpath-get-wwids-from-sysfs-vpd_pg83.patch - 0005-pvdisplay-restore-reportformat-option.patch - 0006-exit-with-error-when-devicesfile-name-doesn-t-exist.patch - 0007-report-fix-pe_start-column-type-from-NUM-to-SIZ.patch - 0008-_vg_read_raw_area-fix-segfault-caused-by-using-null-.patch - 0009-mm-remove-libaio-from-being-skipped.patch - 0010-dmsetup-check-also-for-ouf-of-range-value.patch - 0011-devices-drop-double-from-sysfs-path.patch - 0012-devices-file-fix-pvcreate-uuid-matching-pvid-entry-w.patch - 0013-vgimportdevices-change-result-when-devices-are-not-a.patch - 0014-vgimportdevices-fix-locking-when-creating-devices-fi.patch - update lvm2.spec - indent some lines for easy read - remove config item '--enable-cmirrord' - add new man lvm_import_vdo.8 - add new man dmfilemapd.8 OBS-URL: https://build.opensuse.org/request/show/1000764 OBS-URL: https://build.opensuse.org/package/show/Base:System/lvm2?expand=0&rev=312
443 lines
10 KiB
Diff
443 lines
10 KiB
Diff
From 3c49a2e43ccfbad720a3134484c7870a14b1135b Mon Sep 17 00:00:00 2001
|
|
From: David Teigland <teigland@redhat.com>
|
|
Date: Mon, 29 Aug 2022 15:17:36 -0500
|
|
Subject: [PATCH] vgimportdevices: change result when devices are not added
|
|
|
|
When using --all, if one VG is skipped, continue adding
|
|
other VGs, and do not return an error from the command
|
|
if some VGs are added. (A VG is skipped if it's missing PVs.)
|
|
|
|
If the command fails during devices file setup or device
|
|
scanning, then remove the devices file if it has been
|
|
newly created by the command, and exit with an error.
|
|
|
|
If devices from a named VG are not imported (e.g. the
|
|
VG is missing devices), then remove the devices file if
|
|
it has been newly created by the command, and exit with
|
|
an error.
|
|
|
|
If --all VGs are being imported, and no devices are found
|
|
to include in the devices file, then remove the devices
|
|
file if it has been newly created by the command, and
|
|
exit with an error.
|
|
---
|
|
test/shell/vgimportdevices.sh | 308 ++++++++++++++++++++++++++++++++++
|
|
tools/vgimportdevices.c | 41 +++--
|
|
2 files changed, 336 insertions(+), 13 deletions(-)
|
|
create mode 100644 test/shell/vgimportdevices.sh
|
|
|
|
diff --git a/test/shell/vgimportdevices.sh b/test/shell/vgimportdevices.sh
|
|
new file mode 100644
|
|
index 000000000000..47363cec350a
|
|
--- /dev/null
|
|
+++ b/test/shell/vgimportdevices.sh
|
|
@@ -0,0 +1,308 @@
|
|
+
|
|
+#!/usr/bin/env bash
|
|
+
|
|
+# Copyright (C) 2020 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='vgimportdevices'
|
|
+
|
|
+. lib/inittest
|
|
+
|
|
+aux prepare_devs 5
|
|
+
|
|
+DFDIR="$LVM_SYSTEM_DIR/devices"
|
|
+mkdir "$DFDIR" || true
|
|
+DF="$DFDIR/system.devices"
|
|
+
|
|
+aux lvmconf 'devices/use_devicesfile = 1'
|
|
+
|
|
+not ls "$DF"
|
|
+pvcreate "$dev1"
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+rm -f "$DF"
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+
|
|
+#
|
|
+# vgimportdevices -a with no prev df
|
|
+#
|
|
+
|
|
+# no devs found
|
|
+not vgimportdevices -a
|
|
+not ls "$DF"
|
|
+
|
|
+# one orphan pv, no vgs
|
|
+pvcreate "$dev1"
|
|
+rm -f "$DF"
|
|
+not vgimportdevices -a
|
|
+not ls "$DF"
|
|
+
|
|
+# one complete vg
|
|
+vgcreate $vg1 "$dev1"
|
|
+rm -f "$DF"
|
|
+vgimportdevices -a
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# two complete vgs
|
|
+vgcreate $vg1 "$dev1"
|
|
+vgcreate $vg2 "$dev2"
|
|
+rm -f "$DF"
|
|
+vgimportdevices -a
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+grep "$dev2" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# one incomplete vg
|
|
+vgcreate $vg1 "$dev1" "$dev2"
|
|
+lvcreate -l1 -an $vg1
|
|
+rm -f "$DF"
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+not vgimportdevices -a
|
|
+not ls "$DF"
|
|
+vgs $vg1
|
|
+pvs "$dev2"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# three complete, one incomplete vg
|
|
+vgcreate $vg1 "$dev1"
|
|
+vgcreate $vg2 "$dev2"
|
|
+vgcreate $vg3 "$dev3"
|
|
+vgcreate $vg4 "$dev4" "$dev5"
|
|
+rm -f "$DF"
|
|
+dd if=/dev/zero of="$dev5" bs=1M count=1
|
|
+vgimportdevices -a
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+grep "$dev2" "$DF"
|
|
+grep "$dev3" "$DF"
|
|
+not grep "$dev4" "$DF"
|
|
+not grep "$dev5" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev3" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev4" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+
|
|
+#
|
|
+# vgimportdevices -a with existing df
|
|
+#
|
|
+
|
|
+# no devs found
|
|
+vgcreate $vg1 "$dev1"
|
|
+grep "$dev1" "$DF"
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+not vgimportdevices -a
|
|
+ls "$DF"
|
|
+
|
|
+# one complete vg
|
|
+vgcreate $vg1 "$dev1"
|
|
+vgimportdevices -a
|
|
+grep "$dev1" "$DF"
|
|
+vgcreate --devicesfile "" $vg2 "$dev2"
|
|
+not grep "$dev2" "$DF"
|
|
+vgimportdevices -a
|
|
+grep "$dev1" "$DF"
|
|
+grep "$dev2" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# two complete vgs
|
|
+vgcreate --devicesfile "" $vg1 "$dev1"
|
|
+vgcreate --devicesfile "" $vg2 "$dev2"
|
|
+rm -f "$DF"
|
|
+vgimportdevices -a
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+grep "$dev2" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# one incomplete vg
|
|
+vgcreate $vg1 "$dev1"
|
|
+vgimportdevices -a
|
|
+grep "$dev1" "$DF"
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+vgcreate --devicesfile "" $vg2 "$dev2" "$dev3"
|
|
+not grep "$dev2" "$DF"
|
|
+not grep "$dev3" "$DF"
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+not vgimportdevices -a
|
|
+ls "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev3" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# import the same vg again
|
|
+vgcreate --devicesfile "" $vg1 "$dev1"
|
|
+not ls "$DF"
|
|
+vgimportdevices -a
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+vgimportdevices -a
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# import a series of vgs
|
|
+vgcreate --devicesfile "" $vg1 "$dev1"
|
|
+vgimportdevices -a
|
|
+grep "$dev1" "$DF"
|
|
+vgcreate --devicesfile "" $vg2 "$dev2"
|
|
+vgimportdevices -a
|
|
+grep "$dev1" "$DF"
|
|
+grep "$dev2" "$DF"
|
|
+vgcreate --devicesfile "" $vg3 "$dev3"
|
|
+vgimportdevices -a
|
|
+grep "$dev1" "$DF"
|
|
+grep "$dev2" "$DF"
|
|
+grep "$dev3" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev3" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+#
|
|
+# vgimportdevices vg with no prev df
|
|
+#
|
|
+
|
|
+# no devs found
|
|
+not vgimportdevices $vg1
|
|
+not ls "$DF"
|
|
+
|
|
+# one complete vg
|
|
+vgcreate $vg1 "$dev1"
|
|
+rm -f "$DF"
|
|
+vgimportdevices $vg1
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# two complete vgs
|
|
+vgcreate $vg1 "$dev1"
|
|
+vgcreate $vg2 "$dev2"
|
|
+rm -f "$DF"
|
|
+vgimportdevices $vg1
|
|
+ls "$DF"
|
|
+grep "$dev1" "$DF"
|
|
+vgimportdevices $vg2
|
|
+ls "$DF"
|
|
+grep "$dev2" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# one incomplete vg
|
|
+vgcreate $vg1 "$dev1" "$dev2"
|
|
+lvcreate -l1 -an $vg1
|
|
+rm -f "$DF"
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+not vgimportdevices $vg1
|
|
+not ls "$DF"
|
|
+vgs $vg1
|
|
+pvs "$dev2"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# three complete, one incomplete vg
|
|
+vgcreate $vg1 "$dev1"
|
|
+vgcreate $vg2 "$dev2"
|
|
+vgcreate $vg3 "$dev3"
|
|
+vgcreate $vg4 "$dev4" "$dev5"
|
|
+rm -f "$DF"
|
|
+dd if=/dev/zero of="$dev5" bs=1M count=1
|
|
+not vgimportdevices $vg4
|
|
+not ls "$DF"
|
|
+vgimportdevices $vg3
|
|
+ls "$DF"
|
|
+grep "$dev3" "$DF"
|
|
+not grep "$dev1" "$DF"
|
|
+not grep "$dev2" "$DF"
|
|
+not grep "$dev4" "$DF"
|
|
+not grep "$dev5" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev3" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev4" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+#
|
|
+# vgimportdevices vg with existing df
|
|
+#
|
|
+
|
|
+# vg not found
|
|
+vgcreate $vg1 "$dev1"
|
|
+vgimportdevices -a
|
|
+grep "$dev1" "$DF"
|
|
+not vgimportdevices $vg2
|
|
+grep "$dev1" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
+# vg incomplete
|
|
+vgcreate $vg1 "$dev1"
|
|
+vgimportdevices -a
|
|
+grep "$dev1" "$DF"
|
|
+vgcreate --devicesfile "" $vg2 "$dev2" "$dev3"
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+not vgimportdevices $vg2
|
|
+grep "$dev1" "$DF"
|
|
+not grep "$dev2" "$DF"
|
|
+not grep "$dev3" "$DF"
|
|
+
|
|
+# reset
|
|
+dd if=/dev/zero of="$dev1" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev2" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev3" bs=1M count=1
|
|
+dd if=/dev/zero of="$dev4" bs=1M count=1
|
|
+rm -f "$DF"
|
|
+
|
|
diff --git a/tools/vgimportdevices.c b/tools/vgimportdevices.c
|
|
index ea205d941073..9ade1b9e4b21 100644
|
|
--- a/tools/vgimportdevices.c
|
|
+++ b/tools/vgimportdevices.c
|
|
@@ -36,9 +36,9 @@ static int _vgimportdevices_single(struct cmd_context *cmd,
|
|
dm_list_iterate_items(pvl, &vg->pvs) {
|
|
if (is_missing_pv(pvl->pv) || !pvl->pv->dev) {
|
|
memcpy(pvid, &pvl->pv->id.uuid, ID_LEN);
|
|
- log_error("Not importing devices for VG %s with missing PV %s.",
|
|
- vg->name, pvid);
|
|
- goto bad;
|
|
+ log_print("Not importing devices for VG %s with missing PV %s.",
|
|
+ vg->name, pvid);
|
|
+ return ECMD_PROCESSED;
|
|
}
|
|
}
|
|
|
|
@@ -71,14 +71,17 @@ static int _vgimportdevices_single(struct cmd_context *cmd,
|
|
updated_pvs++;
|
|
}
|
|
|
|
+ /*
|
|
+ * Writes the device_id of each PV into the vg metadata.
|
|
+ * This is not a critial step and should not influence
|
|
+ * the result of the command.
|
|
+ */
|
|
if (updated_pvs) {
|
|
if (!vg_write(vg) || !vg_commit(vg))
|
|
- goto_bad;
|
|
+ log_print("Failed to write device ids in VG metadata.");
|
|
}
|
|
|
|
return ECMD_PROCESSED;
|
|
-bad:
|
|
- return ECMD_FAILED;
|
|
}
|
|
|
|
/*
|
|
@@ -114,6 +117,7 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
|
|
{
|
|
struct vgimportdevices_params vp = { 0 };
|
|
struct processing_handle *handle;
|
|
+ int created_file = 0;
|
|
int ret = ECMD_FAILED;
|
|
|
|
if (arg_is_set(cmd, foreign_ARG))
|
|
@@ -139,9 +143,12 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
|
|
log_error("Devices file not enabled.");
|
|
return ECMD_FAILED;
|
|
}
|
|
- if (!devices_file_exists(cmd) && !devices_file_touch(cmd)) {
|
|
- log_error("Failed to create devices file.");
|
|
- return ECMD_FAILED;
|
|
+ if (!devices_file_exists(cmd)) {
|
|
+ if (!devices_file_touch(cmd)) {
|
|
+ log_error("Failed to create devices file.");
|
|
+ return ECMD_FAILED;
|
|
+ }
|
|
+ created_file = 1;
|
|
}
|
|
|
|
/*
|
|
@@ -195,22 +202,30 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
|
|
*/
|
|
ret = process_each_vg(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
|
|
0, handle, _vgimportdevices_single);
|
|
- if (ret == ECMD_FAILED)
|
|
- goto out;
|
|
+ if (ret == ECMD_FAILED) {
|
|
+ /*
|
|
+ * Error from setting up devices file or label_scan,
|
|
+ * _vgimportdevices_single does not return an error.
|
|
+ */
|
|
+ goto_out;
|
|
+ }
|
|
|
|
if (!vp.added_devices) {
|
|
- log_print("No devices to add.");
|
|
+ log_error("No devices to add.");
|
|
+ ret = ECMD_FAILED;
|
|
goto out;
|
|
}
|
|
|
|
if (!device_ids_write(cmd)) {
|
|
- log_print("Failed to update devices file.");
|
|
+ log_error("Failed to write the devices file.");
|
|
ret = ECMD_FAILED;
|
|
goto out;
|
|
}
|
|
|
|
log_print("Added %u devices to devices file.", vp.added_devices);
|
|
out:
|
|
+ if ((ret == ECMD_FAILED) && created_file)
|
|
+ unlink(cmd->devices_file_path);
|
|
destroy_processing_handle(cmd, handle);
|
|
return ret;
|
|
}
|
|
--
|
|
2.26.2
|
|
|