Accepting request 1112038 from home:gsu

- Update lvm2 from LVM2.2.03.16 to LVM2.2.03.22 (jsc#PED-6339)
  *** WHATS_NEW from 2.03.17 to 2.03.22 ***
  
  version 2.03.22 - 02nd August 2023
  ==================================
    Fix pv_major/pv_minor report field types so they are integers, not strings.
    Add lvmdevices --delnotfound to delete entries for missing devices.
    Always use cachepool name for metadata backup LV for lvconvert --repair.
    Make metadata backup LVs read-only after pool's lvconvert --repair.
    Improve VDO and Thin support with lvmlockd.
    Handle 'lvextend --usepolicies' for pools for all activation variants.
    Fix memleak in vgchange autoactivation setup.
    Update py-compile building script.
    Support conversion from thick to fully provisioned thin LV.
    Cache/Thin-pool can use error and zero volumes for testing.
    Individual thin volume can be cached, but cannot take snapshot.
    Better internal support for handling error and zero target (for testing).
    Resize COW above trimmed maximal size is does not return error.
    Support parsing of vdo geometry format version 4.
    Add lvm.conf thin_restore and cache_restore settings.
    Handle multiple mounts while resizing volume with a FS.
    Handle leading/trailing spaces in sys_wwid and sys_serial used by deivce_id.
    Enhance lvm_import_vdo and use snapshot when converting VDO volume.
    Fix parsing of VDO metadata.
    Fix failing -S|--select for non-reporting cmds if using LV info/status fields.
    Allow snapshots of raid+integrity LV.
    Fix multisegment RAID1 allocator to prevent using single disk for more legs.
  version 2.03.21 - 21st April 2023
  =================================
    Fix activation of vdo-pool for with 0 length headers (converted pools).
    Avoid printing internal init messages when creation integration devices.
    Allow (write)cache over raid+integrity LV.
  version 2.03.20 - 21st March 2023
  =================================
    Fix segfault if using -S|--select with log/report_command_log=1 setting.
    Configure now fails when requested lvmlockd dependencies are missing.
    Add some configure Gentoo enhancements for static builds.
  version 2.03.19 - 21st February 2023
  ====================================
    Configure supports --with-systemd-run executed from udev rules.
    Enhancement for build with MuslC systemd and non-bash system shells (dash).
    Do not reset SYSTEMD_READY variable in udev for PVs on MD and loop devices.
    Ensure udev is processing origin LV before its thick snapshots LVs.
    Fix and improve runtime memory size detection for VDO volumes.
  version 2.03.18 - 22nd December 2022
  ====================================
    Fix issues reported by coverity scan.
    Fix warning for thin pool overprovisioning on lvextend (2.03.17).
    Add support for writecache metadata_only and pause_writeback settings.
    Fix missing error messages in lvmdbusd.
  Version 2.03.17 - 10th November 2022
  ====================================
    Add new options (--fs, --fsmode) for FS handling when resizing LVs.
    Fix 'lvremove -S|--select LV' to not also remove its historical LV right away.
    Fix lv_active field type to binary so --select and --binary applies properly.
    Switch to use mallinfo2 and use it only with glibc.
    Error out in lvm shell if using a cmd argument not supported in the shell.
    Fix lvm shell's lastlog command to report previous pre-command failures.
    Extend VDO and VDOPOOL without flushing and locking fs.
    Add --valuesonly option to lvmconfig to print only values without keys.
    Updates configure with recent autoconf tooling.
    Fix lvconvert --test --type vdo-pool execution.
    Add json_std output format for more JSON standard compliant version of output.
    Fix vdo_slab_size_mb value for converted VDO volume.
    Fix many corner cases in device_id, including handling of S/N duplicates.
    Fix various issues in lvmdbusd.
- Drop patches that have been merged into upstream
  - 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
  - bug-1203216_lvmlockd-purge-the-lock-resources-left-in-previous-l.patch
  - bug-1212613_apply-multipath_component_detection-0-to-duplicate-P.patch
- Add upstream patch
  + 0001-lvconvert-swapmetadata-fix-lvmlockd-locking.patch
  + 0002-lvconvert-fix-ret-values-fro-integrity-remove.patch
  + 0003-lvconvert-fix-regresion-from-integrity-check.patch
  + 0004-gcc-cleanup-warnings.patch
  + 0005-lvmlockd-fix-thick-to-thin-lv-conversion.patch
  + 0006-lvmlockd-let-lockd_init_lv_args-set-lock_args.patch
  + 0007-lvmlockd-fix-lvconvert-to-thin-pool.patch
  + 0008-lvconvert-run-error-path-code-only-for-shared-VG.patch
  + 0009-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch
  + 0010-lvmlockd-client-mutex-ordering.patch
  + 0011-filesystem-move-stat-after-open-check.patch
  + 0012-tests-check-for-writecache.patch
  + 0013-lvresize-fix-32-bit-overflow-in-size-calculation.patch
  + 0014-gcc-fix-warnings-for-x32-architecture.patch
  + 0015-gcc-warning-missing-braces-around-initializer.patch
  + 0016-test-improve-aux-teardown.patch
  + 0017-tests-aux-try-with-extra-sleep.patch
  + 0018-tests-aux-using-singl-lvmconf-call.patch
  + 0019-tests-missing-to-check-for-writecache-support.patch
  + 0020-tests-pvmove-large-disk-area.patch
  + 0021-tests-enforce-full-fs-check.patch
  + 0022-tests-update-for-work-in-fake-dev-environment.patch
  + 0023-tests-skip-test-when-lvmdbusd-runs-on-the-system.patch
  + 0024-tests-better-slowdown.patch
- Update patch
  - bug-1037309_Makefile-skip-compliling-daemons-lvmlockd-directory.patch
  - bug-1184124-link-tests-as-PIE.patch
  - bug-1184687_Add-nolvm-for-kernel-cmdline.patch
  - fate-31841-03_tests-new-test-suite-of-fsadm-for-btrfs.patch
  
- Rename & Update patch
  - bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-metadata.patch
  + bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-rules.patch
  
- update lvm2.spec
  - change upstream_device_mapper_version to 1.02.196
  - change device_mapper_version to %{lvm2_version}_1.02.196
  - add config item "-with-libexecdir=%{_libexecdir}" to fix libexec path since commit a2d33cdf
  - add new binary "%{_libexecdir}/lvresize_fs_helper" to lvm2 package

OBS-URL: https://build.opensuse.org/request/show/1112038
OBS-URL: https://build.opensuse.org/package/show/Base:System/lvm2?expand=0&rev=332
This commit is contained in:
heming zhao 2023-09-19 00:36:45 +00:00 committed by Git OBS Bridge
parent fbdfb470ca
commit bde51e3862
51 changed files with 2321 additions and 2278 deletions

View File

@ -1,47 +0,0 @@
From 9dfa6f38793f6b5f7de2a4148ab2f7790e3c39da Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 27 May 2022 12:38:43 -0500
Subject: [PATCH] devices file: move clean up after command is run
devices_file_exit wasn't being called between lvm_shell
commands, so the file lock wouldn't be released.
---
lib/commands/toolcontext.c | 2 --
tools/lvmcmdline.c | 1 +
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 4cb81bf94279..2666d7b42be6 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1905,7 +1905,6 @@ int refresh_toolcontext(struct cmd_context *cmd)
_destroy_segtypes(&cmd->segtypes);
_destroy_formats(cmd, &cmd->formats);
- devices_file_exit(cmd);
if (!dev_cache_exit())
stack;
_destroy_dev_types(cmd);
@@ -2034,7 +2033,6 @@ void destroy_toolcontext(struct cmd_context *cmd)
_destroy_segtypes(&cmd->segtypes);
_destroy_formats(cmd, &cmd->formats);
_destroy_filters(cmd);
- devices_file_exit(cmd);
dev_cache_exit();
_destroy_dev_types(cmd);
_destroy_tags(cmd);
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 1e3547ed72f3..b052d698fed7 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -3305,6 +3305,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
hints_exit(cmd);
lvmcache_destroy(cmd, 1, 1);
label_scan_destroy(cmd);
+ devices_file_exit(cmd);
if ((config_string_cft = remove_config_tree_by_source(cmd, CONFIG_STRING)))
dm_config_destroy(config_string_cft);
--
2.26.2

View File

@ -0,0 +1,96 @@
From ff0a8d7b6734c745e52652fc5e7dd3a0f2efb518 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 8 Aug 2023 16:57:22 -0500
Subject: [PATCH 01/24] lvconvert swapmetadata: fix lvmlockd locking
The lockd lock needs to be freed for the LV that is becoming
the new metadata LV, and a new lockd lock needs to be created
for the old metadata LV that is becoming an independent LV.
Fixes b3e45219c2f4
---
tools/lvconvert.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 0004422f2..49047abb0 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2818,6 +2818,9 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
struct lv_type *lvtype;
char meta_name[NAME_LEN];
const char *swap_name;
+ char *lockd_meta_args = NULL;
+ char *lockd_meta_name = NULL;
+ struct id lockd_meta_id;
uint32_t chunk_size;
int is_thinpool;
int is_cachepool;
@@ -2872,6 +2875,12 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
if (!lockd_lv(cmd, lv, "ex", 0))
return 0;
+ /* If new metadata LV is inactive here, ensure it's not active elsewhere */
+ if (!lockd_lv(cmd, metadata_lv, "ex", 0)) {
+ log_error("New pool metadata LV %s cannot be locked.", display_lvname(metadata_lv));
+ return 0;
+ }
+
if (!deactivate_lv(cmd, metadata_lv)) {
log_error("Aborting. Failed to deactivate %s.",
display_lvname(metadata_lv));
@@ -2883,8 +2892,22 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
return 0;
}
- metadata_lv->lock_args = NULL;
-
+ /*
+ * metadata_lv is currently an independent LV with its own lockd lock allocated.
+ * A pool metadata LV does not have its own lockd lock (only the pool LV does.)
+ * So, when metadata_lv is added to the thin pool, it's lock needs to be freed.
+ * Save info about the metadata_lv here that will be used to free the lock.
+ * The current pool metadata LV does not currently have its own lockd lock
+ * allocated, and once it becomes an independent LV it will need its own lock.
+ * (see setting prev_metadata_lv->lock_args below.)
+ */
+ if (vg_is_shared(vg) && metadata_lv->lock_args) {
+ lockd_meta_args = dm_pool_strdup(cmd->mem, metadata_lv->lock_args);
+ lockd_meta_name = dm_pool_strdup(cmd->mem, metadata_lv->name);
+ memcpy(&lockd_meta_id, &metadata_lv->lvid.id[1], sizeof(struct id));
+ /* Without lock_args, a lock will no longer be acquired for this LV. */
+ metadata_lv->lock_args = NULL;
+ }
seg = first_seg(lv);
@@ -2950,9 +2973,27 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
if (!attach_pool_metadata_lv(seg, metadata_lv))
return_0;
+ /*
+ * The previous metadata LV will now be an independent LV so it now
+ * requires a lockd lock. We could call lockd_init_lv_args() directly
+ * here, but reuse the existing code in vg_write() to be consistent
+ * with the way lvcreate allocates locks.
+ */
+ if (is_lockd_type(vg->lock_type)) {
+ if (!strcmp(vg->lock_type, "sanlock"))
+ prev_metadata_lv->lock_args = "pending";
+ else if (!strcmp(vg->lock_type, "dlm"))
+ prev_metadata_lv->lock_args = "dlm";
+ else if (!strcmp(vg->lock_type, "idm"))
+ prev_metadata_lv->lock_args = "idm";
+ }
+
if (!vg_write(vg) || !vg_commit(vg))
return_0;
+ if (lockd_meta_name)
+ lockd_free_lv(cmd, vg, lockd_meta_name, &lockd_meta_id, lockd_meta_args);
+
return 1;
}
--
2.35.3

View File

@ -1,52 +0,0 @@
From bfe072e4388b530cbf5369be8a8f1305220198bf Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 27 May 2022 14:27:03 -0500
Subject: [PATCH] devices file: fail if --devicesfile filename doesn't exist
A typo of the filename after --devicesfile should result in a
command error rather than the command falling back to using no
devices file at all. Exception is vgcreate|pvcreate which
create a new devices file if the file name doesn't exist.
---
lib/device/dev-cache.c | 9 +++++++++
test/shell/devicesfile-basic.sh | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 3aaf6a2e55b8..ed9c726c9748 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1863,6 +1863,15 @@ int setup_devices(struct cmd_context *cmd)
file_exists = devices_file_exists(cmd);
+ /*
+ * Fail if user specifies a file name that doesn't exist and
+ * the command is not creating a new devices file.
+ */
+ if (!file_exists && !cmd->create_edit_devices_file && cmd->devicesfile && strlen(cmd->devicesfile)) {
+ log_error("Devices file not found: %s", cmd->devices_file_path);
+ return 0;
+ }
+
/*
* Removing the devices file is another way of disabling the use of
* a devices file, unless the command creates the devices file.
diff --git a/test/shell/devicesfile-basic.sh b/test/shell/devicesfile-basic.sh
index 9c3455c7678e..77fe265a0c54 100644
--- a/test/shell/devicesfile-basic.sh
+++ b/test/shell/devicesfile-basic.sh
@@ -104,6 +104,10 @@ not ls "$DFDIR/system.devices"
vgs --devicesfile test.devices $vg1
not vgs --devicesfile test.devices $vg2
+# misspelled override name fails
+not vgs --devicesfile doesnotexist $vg1
+not vgs --devicesfile doesnotexist $vg2
+
# devicesfile and devices cannot be used together
not vgs --devicesfile test.devices --devices "$dev1","$dev1" $vg1
--
2.26.2

View File

@ -0,0 +1,105 @@
From b982d9ac56a709f1ffcdfb052029556bd8d56635 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 9 Aug 2023 13:02:13 +0200
Subject: [PATCH 02/24] lvconvert: fix ret values fro integrity remove
Fix return value from _lvconvert_integrity_remove()
as it is expected to match _add() and be 0/1.
Also add some missing log_error() messages.
---
tools/lvconvert.c | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 49047abb0..c25c87db4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -6410,24 +6410,26 @@ int lvconvert_to_cache_with_cachevol_cmd(struct cmd_context *cmd, int argc, char
static int _lvconvert_integrity_remove(struct cmd_context *cmd, struct logical_volume *lv)
{
- int ret = 0;
-
- if (!lv_is_integrity(lv) && !lv_is_raid(lv)) {
+ if (!lv_is_integrity(lv)) {
log_error("LV does not have integrity.");
- return ECMD_FAILED;
+ return 0;
+ }
+
+ if (!lv_is_raid(lv)) {
+ log_error("Cannot remove integrity from non raid type LV %s.",
+ display_lvname(lv));
+ return 0;
}
/* ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
- return_ECMD_FAILED;
+ return_0;
- if (lv_is_raid(lv))
- ret = lv_remove_integrity_from_raid(lv);
- if (!ret)
- return_ECMD_FAILED;
+ if (!lv_remove_integrity_from_raid(lv))
+ return_0;
log_print_unless_silent("Logical volume %s has removed integrity.", display_lvname(lv));
- return ECMD_PROCESSED;
+ return 1;
}
static int _lvconvert_integrity_add(struct cmd_context *cmd, struct logical_volume *lv,
@@ -6435,7 +6437,6 @@ static int _lvconvert_integrity_add(struct cmd_context *cmd, struct logical_volu
{
struct volume_group *vg = lv->vg;
struct dm_list *use_pvh;
- int ret = 0;
/* ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
@@ -6453,9 +6454,13 @@ static int _lvconvert_integrity_add(struct cmd_context *cmd, struct logical_volu
return 0;
}
- if (lv_is_raid(lv))
- ret = lv_add_integrity_to_raid(lv, set, use_pvh, NULL);
- if (!ret)
+ if (!lv_is_raid(lv)) {
+ log_error("Cannot add integrity to non raid type LV %s.",
+ display_lvname(lv));
+ return 0;
+ }
+
+ if (!lv_add_integrity_to_raid(lv, set, use_pvh, NULL))
return_0;
log_print_unless_silent("Logical volume %s has added integrity.", display_lvname(lv));
@@ -6466,10 +6471,8 @@ static int _lvconvert_integrity_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
- struct integrity_settings settings;
- int ret = 0;
-
- memset(&settings, 0, sizeof(settings));
+ struct integrity_settings settings = { 0 };
+ int ret;
if (!integrity_mode_set(arg_str_value(cmd, raidintegritymode_ARG, NULL), &settings))
return_ECMD_FAILED;
@@ -6483,7 +6486,8 @@ static int _lvconvert_integrity_single(struct cmd_context *cmd,
ret = _lvconvert_integrity_remove(cmd, lv);
if (!ret)
- return ECMD_FAILED;
+ return_ECMD_FAILED;
+
return ECMD_PROCESSED;
}
--
2.35.3

View File

@ -1,52 +0,0 @@
From c302903dbab1d5fd05b344c654bed83c9ecb69f8 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 6 Jun 2022 11:39:02 -0500
Subject: [PATCH] filter-mpath: handle other wwid types in blacklist
Fixes commit 494372b4eed0c8f6040e3357939eb7511ac25745
"filter-mpath: use multipath blacklist"
to handle wwids with initial type digits 1 and 2 used
for t10 and eui ids. Originally recognized type 3 naa.
---
lib/device/dev-mpath.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/device/dev-mpath.c b/lib/device/dev-mpath.c
index 270366ad7cfe..846f6c8bab13 100644
--- a/lib/device/dev-mpath.c
+++ b/lib/device/dev-mpath.c
@@ -54,7 +54,7 @@ static void _read_blacklist_file(const char *path)
int section_black = 0;
int section_exceptions = 0;
int found_quote;
- int found_three;
+ int found_type;
int i, j;
if (!(fp = fopen(path, "r")))
@@ -114,7 +114,7 @@ static void _read_blacklist_file(const char *path)
memset(wwid, 0, sizeof(wwid));
found_quote = 0;
- found_three = 0;
+ found_type = 0;
j = 0;
for (; i < MAX_WWID_LINE; i++) {
@@ -132,9 +132,10 @@ static void _read_blacklist_file(const char *path)
/* 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;
+ /* exclude initial 3/2/1 for naa/eui/t10 */
+ if (!j && !found_type &&
+ ((line[i] == '3') || (line[i] == '2') || (line[i] == '1'))) {
+ found_type = 1;
continue;
}
--
2.26.2

View File

@ -0,0 +1,29 @@
From 5829b341ea6826d70772af941859359475976b40 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 15 Aug 2023 23:06:29 +0200
Subject: [PATCH 03/24] lvconvert: fix regresion from integrity check
Testing code sliped into commit and cause regression in testing for
a raid with integrity.
---
tools/lvconvert.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c25c87db4..6d2abb2e7 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -6410,8 +6410,8 @@ int lvconvert_to_cache_with_cachevol_cmd(struct cmd_context *cmd, int argc, char
static int _lvconvert_integrity_remove(struct cmd_context *cmd, struct logical_volume *lv)
{
- if (!lv_is_integrity(lv)) {
- log_error("LV does not have integrity.");
+ if (!lv_is_integrity(lv) && !lv_is_raid(lv)) {
+ log_error("LV %s does not have integrity.", display_lvname(lv));
return 0;
}
--
2.35.3

View File

@ -1,741 +0,0 @@
From 3b0f9cec7e999c33f17714358d2b469bda6967d2 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 6 Jun 2022 14:04:20 -0500
Subject: [PATCH] filter-mpath: get wwids from sysfs vpd_pg83
to compare with wwids in /etc/multipath/wwids when
excluding multipath components. The wwid printed
from the sysfs wwid file may not be the wwid used
in multipath wwids. Save the wwids found for each
device on dev->wwids to avoid repeating reading
and parsing the sysfs files.
---
lib/Makefile.in | 1 +
lib/device/dev-cache.c | 18 ++++
lib/device/dev-cache.h | 1 +
lib/device/dev-mpath.c | 232 ++++++++++++++++++++++++++++++++++-------
lib/device/device.h | 13 +++
lib/device/device_id.c | 31 +++++-
lib/device/device_id.h | 2 +
lib/device/parse_vpd.c | 199 +++++++++++++++++++++++++++++++++++
8 files changed, 454 insertions(+), 43 deletions(-)
create mode 100644 lib/device/parse_vpd.c
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 22b96134b58a..3ab5cb2f1d53 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -41,6 +41,7 @@ SOURCES =\
device/dev-dasd.c \
device/dev-lvm1-pool.c \
device/online.c \
+ device/parse_vpd.c \
display/display.c \
error/errseg.c \
unknown/unknown.c \
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index ed9c726c9748..193eb7585f45 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -80,6 +80,7 @@ static void _dev_init(struct device *dev)
dm_list_init(&dev->aliases);
dm_list_init(&dev->ids);
+ dm_list_init(&dev->wwids);
}
void dev_destroy_file(struct device *dev)
@@ -383,6 +384,22 @@ out:
return 1;
}
+int get_sysfs_binary(const char *path, char *buf, size_t buf_size, int *retlen)
+{
+ int ret;
+ int fd;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return 0;
+ ret = read(fd, buf, buf_size);
+ close(fd);
+ if (ret <= 0)
+ return 0;
+ *retlen = ret;
+ return 1;
+}
+
int get_sysfs_value(const char *path, char *buf, size_t buf_size, int error_if_no_value)
{
FILE *fp;
@@ -1336,6 +1353,7 @@ int dev_cache_exit(void)
dm_hash_iterate(n, _cache.names) {
dev = (struct device *) dm_hash_get_data(_cache.names, n);
free_dids(&dev->ids);
+ free_wwids(&dev->wwids);
}
}
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 46b1da72c1ad..7ffe01152510 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -74,6 +74,7 @@ void dev_cache_failed_path(struct device *dev, const char *path);
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt);
int get_sysfs_value(const char *path, char *buf, size_t buf_size, int error_if_no_value);
+int get_sysfs_binary(const char *path, char *buf, size_t buf_size, int *retlen);
int get_dm_uuid_from_sysfs(char *buf, size_t buf_size, int major, int minor);
int setup_devices_file(struct cmd_context *cmd);
diff --git a/lib/device/dev-mpath.c b/lib/device/dev-mpath.c
index 846f6c8bab13..27b0f41a6a8a 100644
--- a/lib/device/dev-mpath.c
+++ b/lib/device/dev-mpath.c
@@ -200,11 +200,12 @@ static void _read_wwid_exclusions(void)
log_debug("multipath config ignored %d wwids", rem_count);
}
-static void _read_wwid_file(const char *config_wwids_file)
+static void _read_wwid_file(const char *config_wwids_file, int *entries)
{
FILE *fp;
char line[MAX_WWID_LINE];
char *wwid, *p;
+ char typestr[2] = { 0 };
int count = 0;
if (config_wwids_file[0] != '/') {
@@ -226,8 +227,17 @@ static void _read_wwid_file(const char *config_wwids_file)
if (line[0] == '/')
wwid++;
- /* skip the initial '3' */
- wwid++;
+
+ /*
+ * the initial character is the id type,
+ * 1 is t10, 2 is eui, 3 is naa, 8 is scsi name.
+ * wwids are stored in the hash table without the type charater.
+ * It seems that sometimes multipath does not include
+ * the type charater (seen with t10 scsi_debug devs).
+ */
+ typestr[0] = *wwid;
+ if (typestr[0] == '1' || typestr[0] == '2' || typestr[0] == '3')
+ wwid++;
if ((p = strchr(wwid, '/')))
*p = '\0';
@@ -240,6 +250,7 @@ static void _read_wwid_file(const char *config_wwids_file)
stack;
log_debug("multipath wwids read %d from %s", count, config_wwids_file);
+ *entries = count;
}
int dev_mpath_init(const char *config_wwids_file)
@@ -247,6 +258,7 @@ int dev_mpath_init(const char *config_wwids_file)
struct dm_pool *mem;
struct dm_hash_table *minor_tab;
struct dm_hash_table *wwid_tab;
+ int entries = 0;
dm_list_init(&_ignored);
dm_list_init(&_ignored_exceptions);
@@ -283,10 +295,16 @@ int dev_mpath_init(const char *config_wwids_file)
_wwid_hash_tab = wwid_tab;
if (config_wwids_file) {
- _read_wwid_file(config_wwids_file);
+ _read_wwid_file(config_wwids_file, &entries);
_read_wwid_exclusions();
}
+ if (!entries) {
+ /* reading dev wwids is skipped with null wwid_hash_tab */
+ dm_hash_destroy(_wwid_hash_tab);
+ _wwid_hash_tab = NULL;
+ }
+
return 1;
}
@@ -434,10 +452,10 @@ static int _dev_is_mpath_component_udev(struct device *dev)
/* mpath_devno is major:minor of the dm multipath device currently using the component dev. */
-static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device *dev, dev_t *mpath_devno)
+static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device *dev,
+ int primary_result, dev_t primary_dev, dev_t *mpath_devno)
{
struct dev_types *dt = cmd->dev_types;
- const char *part_name;
const char *name; /* e.g. "sda" for "/dev/sda" */
char link_path[PATH_MAX]; /* some obscure, unpredictable sysfs path */
char holders_path[PATH_MAX]; /* e.g. "/sys/block/sda/holders/" */
@@ -451,25 +469,15 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
int dm_dev_major;
int dm_dev_minor;
struct stat info;
- dev_t primary_dev;
int is_mpath_component = 0;
- /* multipathing is only known to exist for SCSI or NVME devices */
- if (!major_is_scsi_device(dt, dev_major) && !dev_is_nvme(dt, dev))
- return 0;
-
- switch (dev_get_primary_dev(dt, dev, &primary_dev)) {
+ switch (primary_result) {
case 2: /* The dev is partition. */
- part_name = dev_name(dev); /* name of original dev for log_debug msg */
/* gets "foo" for "/dev/foo" where "/dev/foo" comes from major:minor */
if (!(name = _get_sysfs_name_by_devt(sysfs_dir, primary_dev, link_path, sizeof(link_path))))
return_0;
-
- log_debug_devs("%s: Device is a partition, using primary "
- "device %s for mpath component detection",
- part_name, name);
break;
case 1: /* The dev is already a primary dev. Just continue with the dev. */
@@ -593,47 +601,189 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
return is_mpath_component;
}
-static int _dev_in_wwid_file(struct cmd_context *cmd, struct device *dev)
+static int _read_sys_wwid(struct cmd_context *cmd, struct device *dev,
+ char *idbuf, int idbufsize)
{
- char sysbuf[PATH_MAX] = { 0 };
- char *wwid;
- long look;
+ char idtmp[DEV_WWID_SIZE];
- if (!_wwid_hash_tab)
+ if (!read_sys_block(cmd, dev, "device/wwid", idbuf, idbufsize)) {
+ /* the wwid file is not under device for nvme devs */
+ if (!read_sys_block(cmd, dev, "wwid", idbuf, idbufsize))
+ return 0;
+ }
+ if (!idbuf[0])
return 0;
- if (!read_sys_block(cmd, dev, "device/wwid", sysbuf, sizeof(sysbuf)))
+ /* in t10 id, replace series of spaces with one _ like multipath */
+ if (!strncmp(idbuf, "t10.", 4) && strchr(idbuf, ' ')) {
+ if (idbufsize < DEV_WWID_SIZE)
+ return 0;
+ memcpy(idtmp, idbuf, DEV_WWID_SIZE);
+ memset(idbuf, 0, idbufsize);
+ format_t10_id((const unsigned char *)idtmp, DEV_WWID_SIZE, (unsigned char *)idbuf, idbufsize);
+ }
+ return 1;
+}
+
+#define VPD_SIZE 4096
+
+static int _read_sys_vpd_wwids(struct cmd_context *cmd, struct device *dev,
+ struct dm_list *ids)
+{
+ unsigned char vpd_data[VPD_SIZE] = { 0 };
+ int vpd_datalen = 0;
+
+ if (!read_sys_block_binary(cmd, dev, "device/vpd_pg83", (char *)vpd_data, VPD_SIZE, &vpd_datalen))
+ return 0;
+ if (!vpd_datalen)
return 0;
- if (!sysbuf[0])
+ /* adds dev_wwid entry to dev->wwids for each id in vpd data */
+ parse_vpd_ids(vpd_data, vpd_datalen, ids);
+ return 1;
+}
+
+void free_wwids(struct dm_list *ids)
+{
+ struct dev_wwid *dw, *safe;
+
+ dm_list_iterate_items_safe(dw, safe, ids) {
+ dm_list_del(&dw->list);
+ free(dw);
+ }
+}
+
+static int _wwid_type_num(char *id)
+{
+ if (!strncmp(id, "naa.", 4))
+ return 3;
+ else if (!strncmp(id, "eui.", 4))
+ return 2;
+ else if (!strncmp(id, "t10.", 4))
+ return 1;
+ else
+ return -1;
+}
+
+/*
+ * TODO: if each of the different wwid types (naa/eui/t10) were
+ * represented by different DEV_ID_TYPE_FOO values, and used
+ * as device_id types, then we could drop struct dev_wwid and
+ * drop dev->wwids, and just use dev->ids for each of the
+ * different wwids found in vpd_pg83. This would also require
+ * the ability to handle both the original method of replacing
+ * every space in the id string with _ and the new/multipath
+ * format_t10_id replacing series of spaces with one _.
+ */
+struct dev_wwid *add_wwid(char *id, int id_type, struct dm_list *ids)
+{
+ struct dev_wwid *dw;
+ int len;
+
+ if (!id_type) {
+ id_type = _wwid_type_num(id);
+ if (id_type == -1)
+ log_debug("unknown wwid type %s", id);
+ }
+
+ if (!(dw = zalloc(sizeof(struct dev_wwid))))
+ return NULL;
+ len = strlen(id);
+ if (len >= DEV_WWID_SIZE)
+ len = DEV_WWID_SIZE - 1;
+ memcpy(dw->id, id, len);
+ dw->type = id_type;
+ dm_list_add(ids, &dw->list);
+ return dw;
+}
+
+/*
+ * we save ids with format: naa.<value>, eui.<value>, t10.<value>.
+ * multipath wwids file uses format: 3<value>, 2<value>, 1<value>.
+ * The values are saved in wwid_hash_tab without the type prefix.
+ */
+
+static int _dev_in_wwid_file(struct cmd_context *cmd, struct device *dev,
+ int primary_result, dev_t primary_dev)
+{
+ char idbuf[DEV_WWID_SIZE] = { 0 };
+ struct dev_wwid *dw;
+ char *wwid;
+
+ if (!_wwid_hash_tab)
return 0;
/*
- * sysfs prints wwid as <typestr>.<value>
- * multipath wwid uses '3'<value>
- * does "<typestr>." always correspond to "3"?
+ * Check the primary device, not the partition.
*/
- if (!(wwid = strchr(sysbuf, '.')))
- return 0;
+ if (primary_result == 2) {
+ if (!(dev = dev_cache_get_by_devt(cmd, primary_dev))) {
+ log_debug("dev_is_mpath_component %s no primary dev", dev_name(dev));
+ return 0;
+ }
+ }
- /* skip the type and dot, just as '3' was skipped from wwids entry */
- wwid++;
-
- look = (long) dm_hash_lookup_binary(_wwid_hash_tab, wwid, strlen(wwid));
+ /*
+ * This function may be called multiple times for the same device, in
+ * particular if partitioned for each partition.
+ */
+ if (!dm_list_empty(&dev->wwids))
+ goto lookup;
- if (look) {
- log_debug_devs("dev_is_mpath_component %s multipath wwid %s", dev_name(dev), wwid);
- return 1;
+ /*
+ * Get all the ids for the device from vpd_pg83 and check if any of
+ * those are in /etc/multipath/wwids. These ids should include the
+ * value printed from the sysfs wwid file.
+ */
+ _read_sys_vpd_wwids(cmd, dev, &dev->wwids);
+ if (!dm_list_empty(&dev->wwids))
+ goto lookup;
+
+ /*
+ * This will read the sysfs wwid file, nvme devices in particular have
+ * a wwid file but not a vpd_pg83 file.
+ */
+ if (_read_sys_wwid(cmd, dev, idbuf, sizeof(idbuf)))
+ add_wwid(idbuf, 0, &dev->wwids);
+
+ lookup:
+ dm_list_iterate_items(dw, &dev->wwids) {
+ if (dw->type == 1 || dw->type == 2 || dw->type == 3)
+ wwid = &dw->id[4];
+ else
+ wwid = dw->id;
+
+ if (dm_hash_lookup_binary(_wwid_hash_tab, wwid, strlen(wwid))) {
+ log_debug_devs("dev_is_mpath_component %s %s in wwids file", dev_name(dev), dw->id);
+ return 1;
+ }
}
+
return 0;
}
int dev_is_mpath_component(struct cmd_context *cmd, struct device *dev, dev_t *holder_devno)
{
- if (_dev_is_mpath_component_sysfs(cmd, dev, holder_devno) == 1)
+ struct dev_types *dt = cmd->dev_types;
+ int primary_result;
+ dev_t primary_dev;
+
+ /*
+ * multipath only uses SCSI or NVME devices
+ */
+ if (!major_is_scsi_device(dt, MAJOR(dev->dev)) && !dev_is_nvme(dt, dev))
+ return 0;
+
+ /*
+ * primary_result 2: dev is a partition, primary_dev is the whole device
+ * primary_result 1: dev is a whole device
+ */
+ primary_result = dev_get_primary_dev(dt, dev, &primary_dev);
+
+ if (_dev_is_mpath_component_sysfs(cmd, dev, primary_result, primary_dev, holder_devno) == 1)
goto found;
- if (_dev_in_wwid_file(cmd, dev))
+ if (_dev_in_wwid_file(cmd, dev, primary_result, primary_dev))
goto found;
if (external_device_info_source() == DEV_EXT_UDEV) {
@@ -641,6 +791,12 @@ int dev_is_mpath_component(struct cmd_context *cmd, struct device *dev, dev_t *h
goto found;
}
+ /*
+ * TODO: save the result of this function in dev->flags and use those
+ * flags on repeated calls to avoid repeating the work multiple times
+ * for the same device when there are partitions on the device.
+ */
+
return 0;
found:
return 1;
diff --git a/lib/device/device.h b/lib/device/device.h
index d0d670ec3708..06440f44b3fa 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -59,6 +59,14 @@ struct dev_ext {
void *handle;
};
+#define DEV_WWID_SIZE 128
+
+struct dev_wwid {
+ struct dm_list list;
+ int type;
+ char id[DEV_WWID_SIZE];
+};
+
#define DEV_ID_TYPE_SYS_WWID 0x0001
#define DEV_ID_TYPE_SYS_SERIAL 0x0002
#define DEV_ID_TYPE_MPATH_UUID 0x0003
@@ -105,6 +113,7 @@ struct dev_use {
*/
struct device {
struct dm_list aliases; /* struct dm_str_list */
+ struct dm_list wwids; /* struct dev_wwid, used for multipath component detection */
struct dm_list ids; /* struct dev_id, different entries for different idtypes */
struct dev_id *id; /* points to the the ids entry being used for this dev */
dev_t dev;
@@ -206,5 +215,9 @@ void dev_destroy_file(struct device *dev);
int dev_mpath_init(const char *config_wwids_file);
void dev_mpath_exit(void);
+struct dev_wwid *add_wwid(char *id, int id_type, struct dm_list *ids);
+void free_wwids(struct dm_list *ids);
+int parse_vpd_ids(const unsigned char *vpd_data, int vpd_datalen, struct dm_list *ids);
+int format_t10_id(const unsigned char *in, int in_bytes, unsigned char *out, int out_bytes);
#endif
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index f1928347c127..9dec9f884da4 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -182,7 +182,9 @@ void free_dids(struct dm_list *ids)
}
}
-int read_sys_block(struct cmd_context *cmd, struct device *dev, const char *suffix, char *sysbuf, int sysbufsize)
+static int _read_sys_block(struct cmd_context *cmd, struct device *dev,
+ const char *suffix, char *sysbuf, int sysbufsize,
+ int binary, int *retlen)
{
char path[PATH_MAX];
dev_t devt = dev->dev;
@@ -196,11 +198,17 @@ int read_sys_block(struct cmd_context *cmd, struct device *dev, const char *suff
return 0;
}
- get_sysfs_value(path, sysbuf, sysbufsize, 0);
+ if (binary) {
+ ret = get_sysfs_binary(path, sysbuf, sysbufsize, retlen);
+ if (ret && !*retlen)
+ ret = 0;
+ } else {
+ ret = get_sysfs_value(path, sysbuf, sysbufsize, 0);
+ if (ret && !sysbuf[0])
+ ret = 0;
+ }
- if (sysbuf[0]) {
- if (prim)
- log_debug("Using primary device_id for partition %s.", dev_name(dev));
+ if (ret) {
sysbuf[sysbufsize - 1] = '\0';
return 1;
}
@@ -220,6 +228,19 @@ int read_sys_block(struct cmd_context *cmd, struct device *dev, const char *suff
return 0;
}
+int read_sys_block(struct cmd_context *cmd, struct device *dev,
+ const char *suffix, char *sysbuf, int sysbufsize)
+{
+ return _read_sys_block(cmd, dev, suffix, sysbuf, sysbufsize, 0, NULL);
+}
+
+int read_sys_block_binary(struct cmd_context *cmd, struct device *dev,
+ const char *suffix, char *sysbuf, int sysbufsize,
+ int *retlen)
+{
+ return _read_sys_block(cmd, dev, suffix, sysbuf, sysbufsize, 1, retlen);
+}
+
static int _dm_uuid_has_prefix(char *sysbuf, const char *prefix)
{
if (!strncmp(sysbuf, prefix, strlen(prefix)))
diff --git a/lib/device/device_id.h b/lib/device/device_id.h
index 94773a65e588..9b9c9ce03c65 100644
--- a/lib/device/device_id.h
+++ b/lib/device/device_id.h
@@ -58,6 +58,8 @@ void devices_file_exit(struct cmd_context *cmd);
void unlink_searched_devnames(struct cmd_context *cmd);
int read_sys_block(struct cmd_context *cmd, struct device *dev, const char *suffix, char *sysbuf, int sysbufsize);
+int read_sys_block_binary(struct cmd_context *cmd, struct device *dev,
+ const char *suffix, char *sysbuf, int sysbufsize, int *retlen);
int dev_has_mpath_uuid(struct cmd_context *cmd, struct device *dev, const char **idname_out);
diff --git a/lib/device/parse_vpd.c b/lib/device/parse_vpd.c
new file mode 100644
index 000000000000..4bafa7b9eff6
--- /dev/null
+++ b/lib/device/parse_vpd.c
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2022 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/device/device.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <limits.h>
+#include <dirent.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <assert.h>
+
+/*
+ * Replace series of spaces with a single _.
+ */
+int format_t10_id(const unsigned char *in, int in_bytes, unsigned char *out, int out_bytes)
+{
+ int in_space = 0;
+ int retlen = 0;
+ int j = 0;
+ int i;
+
+ for (i = 0; i < in_bytes; i++) {
+ if (!in[i])
+ break;
+ if (j >= (out_bytes - 2))
+ break;
+ /* skip leading spaces */
+ if (!retlen && (in[i] == ' '))
+ continue;
+ /* replace one or more spaces with _ */
+ if (in[i] == ' ') {
+ in_space = 1;
+ continue;
+ }
+ /* spaces are finished so insert _ */
+ if (in_space) {
+ out[j++] = '_';
+ in_space = 0;
+ retlen++;
+ }
+ out[j++] = in[i];
+ retlen++;
+ }
+ return retlen;
+}
+
+static int _to_hex(const unsigned char *in, int in_bytes, unsigned char *out, int out_bytes)
+{
+ int off = 0;
+ int num;
+ int i;
+
+ for (i = 0; i < in_bytes; i++) {
+ num = sprintf((char *)out + off, "%02x", in[i]);
+ if (num < 0)
+ break;
+ off += num;
+ if (off + 2 >= out_bytes)
+ break;
+ }
+ return off;
+}
+
+#define ID_BUFSIZE 1024
+
+/*
+ * based on linux kernel function
+ */
+int parse_vpd_ids(const unsigned char *vpd_data, int vpd_datalen, struct dm_list *ids)
+{
+ char id[ID_BUFSIZE];
+ unsigned char tmp_str[ID_BUFSIZE];
+ const unsigned char *d, *cur_id_str;
+ size_t id_len = ID_BUFSIZE;
+ int id_size = -1;
+ uint8_t cur_id_size = 0;
+
+ memset(id, 0, ID_BUFSIZE);
+ for (d = vpd_data + 4;
+ d < vpd_data + vpd_datalen;
+ d += d[3] + 4) {
+ memset(tmp_str, 0, sizeof(tmp_str));
+
+ switch (d[1] & 0xf) {
+ case 0x1:
+ /* T10 Vendor ID */
+ cur_id_size = d[3];
+ if (cur_id_size + 4 > id_len)
+ cur_id_size = id_len - 4;
+ cur_id_str = d + 4;
+ format_t10_id(cur_id_str, cur_id_size, tmp_str, sizeof(tmp_str));
+ id_size = snprintf(id, ID_BUFSIZE, "t10.%s", tmp_str);
+ if (id_size < 0)
+ break;
+ if (id_size >= ID_BUFSIZE)
+ id_size = ID_BUFSIZE - 1;
+ add_wwid(id, 1, ids);
+ break;
+ case 0x2:
+ /* EUI-64 */
+ cur_id_size = d[3];
+ cur_id_str = d + 4;
+ switch (cur_id_size) {
+ case 8:
+ _to_hex(cur_id_str, 8, tmp_str, sizeof(tmp_str));
+ id_size = snprintf(id, ID_BUFSIZE, "eui.%s", tmp_str);
+ break;
+ case 12:
+ _to_hex(cur_id_str, 12, tmp_str, sizeof(tmp_str));
+ id_size = snprintf(id, ID_BUFSIZE, "eui.%s", tmp_str);
+ break;
+ case 16:
+ _to_hex(cur_id_str, 16, tmp_str, sizeof(tmp_str));
+ id_size = snprintf(id, ID_BUFSIZE, "eui.%s", tmp_str);
+ break;
+ default:
+ break;
+ }
+ if (id_size < 0)
+ break;
+ if (id_size >= ID_BUFSIZE)
+ id_size = ID_BUFSIZE - 1;
+ add_wwid(id, 2, ids);
+ break;
+ case 0x3:
+ /* NAA */
+ cur_id_size = d[3];
+ cur_id_str = d + 4;
+ switch (cur_id_size) {
+ case 8:
+ _to_hex(cur_id_str, 8, tmp_str, sizeof(tmp_str));
+ id_size = snprintf(id, ID_BUFSIZE, "naa.%s", tmp_str);
+ break;
+ case 16:
+ _to_hex(cur_id_str, 16, tmp_str, sizeof(tmp_str));
+ id_size = snprintf(id, ID_BUFSIZE, "naa.%s", tmp_str);
+ break;
+ default:
+ break;
+ }
+ if (id_size < 0)
+ break;
+ if (id_size >= ID_BUFSIZE)
+ id_size = ID_BUFSIZE - 1;
+ add_wwid(id, 3, ids);
+ break;
+ case 0x8:
+ /* SCSI name string */
+ cur_id_size = d[3];
+ cur_id_str = d + 4;
+ if (cur_id_size >= id_len)
+ cur_id_size = id_len - 1;
+ memcpy(id, cur_id_str, cur_id_size);
+ id_size = cur_id_size;
+
+ /*
+ * Not in the kernel version, copying multipath code,
+ * which checks if this string begins with naa or eui
+ * and if so does tolower() on the chars.
+ */
+ if (!strncmp(id, "naa.", 4) || !strncmp(id, "eui.", 4)) {
+ int i;
+ for (i = 0; i < id_size; i++)
+ id[i] = tolower(id[i]);
+ }
+ add_wwid(id, 8, ids);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return id_size;
+}
--
2.26.2

View File

@ -0,0 +1,103 @@
From 2cd58bb4c9ef063c5283daf0e618c2ed0c77eb89 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 16 Aug 2023 15:12:36 +0200
Subject: [PATCH 04/24] gcc: cleanup warnings
Correcting signess comparation.
Also use standalone /* fall through */ comment as that's
the only one supported by gcc to quiet warning.
---
daemons/cmirrord/local.c | 2 +-
lib/metadata/metadata.c | 2 +-
libdm/datastruct/bitset.c | 3 ++-
tools/lvconvert.c | 2 +-
tools/lvmcmdline.c | 6 +++---
5 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/daemons/cmirrord/local.c b/daemons/cmirrord/local.c
index d0a25e105..27396ad98 100644
--- a/daemons/cmirrord/local.c
+++ b/daemons/cmirrord/local.c
@@ -266,7 +266,7 @@ static int do_local_work(void *data __attribute__((unused)))
RQ_TYPE(u_rq->request_type));
break;
}
- /* ELSE, fall through */
+ /* ELSE */ /* fall through */
case DM_ULOG_IS_CLEAN:
case DM_ULOG_FLUSH:
case DM_ULOG_MARK_REGION:
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 819c6fd9a..f56b5002d 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1133,7 +1133,7 @@ uint32_t extents_from_percent_size(struct volume_group *vg, const struct dm_list
}
break;
}
- /* fall through to use all PVs in VG like %FREE */
+ /* fall through */ /* to use all PVs in VG like %FREE */
case PERCENT_FREE:
if (!(extents = vg->free_count)) {
log_error("No free extents in Volume group %s.", vg->name);
diff --git a/libdm/datastruct/bitset.c b/libdm/datastruct/bitset.c
index 220ea2f26..25407f521 100644
--- a/libdm/datastruct/bitset.c
+++ b/libdm/datastruct/bitset.c
@@ -149,7 +149,8 @@ dm_bitset_t dm_bitset_parse_list(const char *str, struct dm_pool *mem,
size_t min_num_bits)
{
unsigned a, b;
- int c, old_c, totaldigits, ndigits, nmaskbits;
+ int c, old_c, totaldigits, ndigits;
+ size_t nmaskbits;
int at_start, in_range;
dm_bitset_t mask = NULL;
const char *start = str;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 6d2abb2e7..d98d34ce0 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1352,7 +1352,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
else
image_count = lp->mirrors + 1;
- images_reduced = (image_count < lv_raid_image_count(lv));
+ images_reduced = (image_count < (int) lv_raid_image_count(lv));
if (image_count < 1) {
log_error("Unable to %s images by specified amount.",
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 57f9f2651..87f829f19 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1456,7 +1456,7 @@ static int _command_optional_opt_matches(struct cmd_context *cmd, int ci, int oo
}
if (val_bit_is_set(commands[ci].optional_opt_args[oo].def.val_bits, constnum_VAL)) {
- if (commands[ci].optional_opt_args[oo].def.num == arg_int_value(cmd, opt_enum, 0))
+ if (commands[ci].optional_opt_args[oo].def.num == arg_uint64_value(cmd, opt_enum, 0))
return 1;
return 0;
}
@@ -1475,7 +1475,7 @@ static int _command_ignore_opt_matches(struct cmd_context *cmd, int ci, int io)
}
if (val_bit_is_set(commands[ci].ignore_opt_args[io].def.val_bits, constnum_VAL)) {
- if (commands[ci].ignore_opt_args[io].def.num == arg_int_value(cmd, opt_enum, 0))
+ if (commands[ci].ignore_opt_args[io].def.num == arg_uint64_value(cmd, opt_enum, 0))
return 1;
return 0;
}
@@ -1519,7 +1519,7 @@ check_val:
}
if (val_bit_is_set(commands[ci].required_opt_args[ro].def.val_bits, constnum_VAL)) {
- if (commands[ci].required_opt_args[ro].def.num == arg_int_value(cmd, opt_enum, 0))
+ if (commands[ci].required_opt_args[ro].def.num == arg_uint64_value(cmd, opt_enum, 0))
return 1;
return 0;
}
--
2.35.3

View File

@ -0,0 +1,379 @@
From 76a4599500aef12442c8c24be8aacc89f6a27e68 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 15 Aug 2023 09:53:39 -0500
Subject: [PATCH 05/24] lvmlockd: fix thick to thin lv conversion
---
lib/locking/lvmlockd.c | 2 +
lib/metadata/metadata.c | 2 +
tools/lvconvert.c | 231 ++++++++++++++++++++++++----------------
3 files changed, 143 insertions(+), 92 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index a8db25d7a..d44b7333a 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2908,6 +2908,8 @@ static int _free_lv(struct cmd_context *cmd, struct volume_group *vg,
if (!id_write_format(lv_id, lv_uuid, sizeof(lv_uuid)))
return_0;
+ log_debug("lockd free LV %s/%s %s lock_args %s", vg->name, lv_name, lv_uuid, lock_args ?: "none");
+
reply = _lockd_send("free_lv",
"pid = " FMTd64, (int64_t) getpid(),
"vg_name = %s", vg->name,
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index f56b5002d..f8a4f6279 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2924,6 +2924,8 @@ int vg_write(struct volume_group *vg)
vgid[ID_LEN] = 0;
memcpy(vgid, &vg->id.uuid, ID_LEN);
+ log_debug("Writing metadata for VG %s.", vg->name);
+
if (vg_is_shared(vg)) {
dm_list_iterate_items(lvl, &vg->lvs) {
if (lvl->lv->lock_args && !strcmp(lvl->lv->lock_args, "pending")) {
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index d98d34ce0..7c9540712 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3007,9 +3007,22 @@ static struct logical_volume *_lvconvert_insert_thin_layer(struct logical_volume
if (!(thin_segtype = get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_THIN)))
return_NULL;
+ /*
+ * input lv foo (often linear)
+ * creates new lv foo_tpoolN (no seg)
+ * segment from foo is moved to foo_tpoolN
+ * new linear segment is created for foo that maps to foo_tpoolN
+ * returns foo_tpoolN
+ *
+ * In spite of the "pool" variable naming, pool_lv foo_tpoolN is *not*
+ * yet a pool type, but rather is whatever type the input lv was.
+ */
if (!(pool_lv = insert_layer_for_lv(vg->cmd, lv, 0, "_tpool%d")))
return_NULL;
+ /*
+ * change lv foo to a thin LV using foo_tpoolN
+ */
lv->status |= THIN_VOLUME | VIRTUAL;
lv_set_visible(pool_lv);
@@ -3079,9 +3092,12 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
const char *pool_metadata_name; /* user-specified lv name */
char converted_names[3*NAME_LEN]; /* preserve names of converted lv */
struct segment_type *pool_segtype; /* thinpool or cachepool */
+ const char *str_seg_type = to_cachepool ? SEG_TYPE_NAME_CACHE_POOL : SEG_TYPE_NAME_THIN_POOL;
struct lv_segment *seg;
unsigned int target_attr = ~0;
unsigned int activate_pool;
+ unsigned int lock_active_pool;
+ unsigned int lock_active_pool_done = 0;
unsigned int zero_metadata;
uint64_t meta_size;
uint32_t meta_extents;
@@ -3096,16 +3112,18 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
thin_discards_t discards;
thin_zero_t zero_new_blocks;
int error_when_full;
- int r = 0;
+ int end_error = 0;
+ int is_active;
/* for handling lvmlockd cases */
char *lockd_data_args = NULL;
char *lockd_meta_args = NULL;
char *lockd_data_name = NULL;
char *lockd_meta_name = NULL;
+ uint32_t lockd_data_flags = 0;
+ uint32_t lockd_meta_flags = 0;
struct id lockd_data_id;
struct id lockd_meta_id;
- const char *str_seg_type = to_cachepool ? SEG_TYPE_NAME_CACHE_POOL : SEG_TYPE_NAME_THIN_POOL;
if (!_raid_split_image_conversion(lv))
return_0;
@@ -3124,8 +3142,10 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
return 0;
}
- /* Allow to have only thinpool active and restore it's active state. */
- activate_pool = to_thinpool && lv_is_active(lv);
+ is_active = lv_is_active(lv);
+
+ activate_pool = to_thinpool && is_active;
+ lock_active_pool = (to_thinpool || to_thin) && is_active;
/* Wipe metadata_lv by default, but allow skipping this for cache pools. */
zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
@@ -3356,20 +3376,11 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
}
}
- /*
- * When the LV referenced by the original function arg "lv"
- * is layered
- *
- * pool_name pool name taken from lv arg
- * data_name sub lv name, generated
- * meta_name sub lv name, generated
- *
- * pool_lv new lv for pool object, created here
- * data_lv sub lv, was lv arg, now renamed
- * metadata_lv sub lv, existing or created here
- */
-
if (to_thin) {
+ /*
+ * pool_lv is not yet a pool, when returned, pool_lv contains
+ * the segment that belonged to "lv".
+ */
if (!(pool_lv = _lvconvert_insert_thin_layer(lv)))
goto_bad;
} else {
@@ -3383,6 +3394,17 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
pool_lv = lv;
}
+ /*
+ * starts with pool_lv foo (not a pool yet)
+ * creates new data_lv foo_tdata
+ * segment from pool_lv foo is moved to data_lv foo_tdata
+ * pool_lv foo linear segment is created that maps to foo_tdata
+ * returns data_lv foo_tdata
+ *
+ * (In the to_thin case, the segment from the original lv is first
+ * moved to pool_lv by _lvconvert_insert_thin_layer, and now is
+ * moved to data_lv.)
+ */
if (!(data_lv = insert_layer_for_lv(cmd, pool_lv, 0,
(to_cachepool ? "_cdata" : "_tdata"))))
goto_bad;
@@ -3390,33 +3412,15 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
data_lv->status |= (to_cachepool) ? CACHE_POOL_DATA : THIN_POOL_DATA;
data_lv->status |= LVM_WRITE; /* Pool data LV is writable */
+ /*
+ * pool_lv now becomes a pool type.
+ * FIXME: change variable naming to avoid this confusion.
+ */
pool_lv->status |= (to_cachepool) ? CACHE_POOL : THIN_POOL;
seg = first_seg(pool_lv);
seg->segtype = pool_segtype;
- /*
- * Create a new lock for a thin pool LV. A cache pool LV has no lock.
- * Locks are removed from existing LVs that are being converted to
- * data and meta LVs (they are unlocked and deleted below.)
- */
- if (vg_is_shared(vg)) {
- lv->lock_args = NULL;
- pool_lv->lock_args = NULL;
- data_lv->lock_args = NULL;
- metadata_lv->lock_args = NULL;
-
- if (!to_cachepool) {
- if (!strcmp(vg->lock_type, "sanlock"))
- pool_lv->lock_args = "pending";
- else if (!strcmp(vg->lock_type, "dlm"))
- pool_lv->lock_args = "dlm";
- else if (!strcmp(vg->lock_type, "idm"))
- pool_lv->lock_args = "idm";
- /* The lock_args will be set in vg_write(). */
- }
- }
-
/* Apply settings to the new pool seg */
if (to_cachepool) {
if (!cache_set_params(seg, chunk_size, cache_metadata_format, cache_mode, policy_name, policy_settings))
@@ -3453,87 +3457,130 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
if (!_lvconvert_attach_metadata_to_pool(seg, metadata_lv))
goto_bad;
- if (!handle_pool_metadata_spare(vg,
- metadata_lv->le_count,
- use_pvh, pool_metadata_spare))
- goto_bad;
+ /*
+ * Create a new lock for a thin pool LV. A cache pool LV has no lock.
+ * Locks are removed from existing LVs that are being converted to
+ * data and meta LVs (they are unlocked and deleted below.)
+ * Acquire the new thin pool lock if the pool will remain active at
+ * the end of the command.
+ */
+ if (vg_is_shared(vg)) {
+ lv->lock_args = NULL;
+ pool_lv->lock_args = NULL;
+ data_lv->lock_args = NULL;
+ metadata_lv->lock_args = NULL;
- if (to_thin) {
- if (!lockd_lv(cmd, pool_lv, "ex", LDLV_PERSISTENT)) {
- log_error("Failed to lock pool LV %s.", display_lvname(pool_lv));
- goto out;
+ if (!to_cachepool) {
+ if (!strcmp(vg->lock_type, "sanlock")) {
+ if (!lockd_init_lv_args(cmd, vg, pool_lv,
+ vg->lock_type, &pool_lv->lock_args)) {
+ log_error("Cannot allocate lock for new pool LV.");
+ goto_bad;
+ }
+ pool_lv->new_lock_args = 1; /* tells vg_revert to lockd_free_lv */
+ } else if (!strcmp(vg->lock_type, "dlm")) {
+ pool_lv->lock_args = "dlm";
+ } else if (!strcmp(vg->lock_type, "idm")) {
+ pool_lv->lock_args = "idm";
+ }
+
+ if (lock_active_pool) {
+ if (!lockd_lv(cmd, pool_lv, "ex", LDLV_PERSISTENT)) {
+ log_error("Failed to lock new pool LV %s.", display_lvname(pool_lv));
+ goto_bad;
+ }
+ lock_active_pool_done = 1;
+ }
}
+ }
+
+ if (to_thin) {
if (!lv_update_and_reload(lv))
goto_bad;
} else {
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
+ }
- if (activate_pool) {
- if (!lockd_lv(cmd, pool_lv, "ex", LDLV_PERSISTENT)) {
- log_error("Failed to lock pool LV %s.", display_lvname(pool_lv));
- goto out;
- }
+ /*
+ * The main conversion is successfully committed. If any subsequent
+ * steps fail (creating spare, activating, unlocking), we do not
+ * currently have the ability to undo the changes committed up to this
+ * point. Failures in the remaining steps can print an error and cause
+ * the command to exit with an error, but no partial revert of the
+ * completed steps is attempted.
+ */
+ log_print_unless_silent("Converted %s to %s %s.", converted_names,
+ (to_cachepool) ? "cache" : "thin",
+ (to_thin) ? "volume" : "pool");
- if (!activate_lv(cmd, pool_lv)) {
- log_error("Failed to activate pool logical volume %s.",
- display_lvname(pool_lv));
-
- /* Deactivate subvolumes */
- if (!deactivate_lv(cmd, seg_lv(seg, 0)))
- log_error("Failed to deactivate pool data logical volume %s.",
- display_lvname(seg_lv(seg, 0)));
- if (!deactivate_lv(cmd, seg->metadata_lv))
- log_error("Failed to deactivate pool metadata logical volume %s.",
- display_lvname(seg->metadata_lv));
- goto out;
- }
- }
+ /*
+ * FIXME handle_pool_metadata_spare() calls vg_write() vg_commit()
+ * after creating a new lvolN, but then lvolN is renamed and hidden as
+ * [lvolN_pmspare] without any further vg_write(). So, there's an extra
+ * vg_write and vg_commit required here to cover the renaming/hiding.
+ */
+ if (!handle_pool_metadata_spare(vg, metadata_lv->le_count, use_pvh, pool_metadata_spare) ||
+ !vg_write(vg) || !vg_commit(vg)) {
+ log_error("Failed to set up spare metadata LV for thin pool.");
+ end_error = 1;
}
- r = 1;
-
-out:
- if (r)
- log_print_unless_silent("Converted %s to %s %s.",
- converted_names, (to_cachepool) ? "cache" : "thin",
- (to_thin) ? "volume" : "pool");
+ if (activate_pool && !activate_lv(cmd, pool_lv)) {
+ log_error("Failed to activate pool logical volume %s.", display_lvname(pool_lv));
+ end_error = 1;
+ }
/*
* Unlock and free the locks from existing LVs that became pool data
* and meta LVs.
*/
if (lockd_data_name) {
- if (!lockd_lv_name(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args, "un", LDLV_PERSISTENT))
+ if (!lockd_lv_name(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args, "un", lockd_data_flags)) {
log_error("Failed to unlock pool data LV %s/%s", vg->name, lockd_data_name);
- lockd_free_lv(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args);
+ end_error = 1;
+ }
+ if (!lockd_free_lv(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args)) {
+ log_error("Failed to free lock for pool data LV %s/%s", vg->name, lockd_data_name);
+ end_error = 1;
+ }
}
-
if (lockd_meta_name) {
- if (!lockd_lv_name(cmd, vg, lockd_meta_name, &lockd_meta_id, lockd_meta_args, "un", LDLV_PERSISTENT))
+ if (!lockd_lv_name(cmd, vg, lockd_meta_name, &lockd_meta_id, lockd_meta_args, "un", lockd_meta_flags)) {
log_error("Failed to unlock pool metadata LV %s/%s", vg->name, lockd_meta_name);
- lockd_free_lv(cmd, vg, lockd_meta_name, &lockd_meta_id, lockd_meta_args);
+ end_error = 1;
+ }
+ if (!lockd_free_lv(cmd, vg, lockd_meta_name, &lockd_meta_id, lockd_meta_args)) {
+ log_error("Failed to free lock for pool metadata LV %s/%s", vg->name, lockd_meta_name);
+ end_error = 1;
+ }
}
-bad:
+
if (policy_settings)
dm_config_destroy(policy_settings);
- return r;
-#if 0
-revert_new_lv:
- /* TBD */
- if (!pool_metadata_lv_name) {
- if (!deactivate_lv(cmd, metadata_lv)) {
- log_error("Failed to deactivate metadata lv.");
- return 0;
- }
- if (!lv_remove(metadata_lv) || !vg_write(vg) || !vg_commit(vg))
- log_error("Manual intervention may be required to remove "
- "abandoned LV(s) before retrying.");
+ if (end_error) {
+ log_error("Manual intervention may be required to handle reported errors.");
+ return 0;
}
+ return 1;
+
+ /*
+ * Error exit path for failures that occur before the main conversion
+ * is committed. Failures that occur after the main conversion is
+ * committed should not exit here. There is some cleanup missing here.
+ */
+bad:
+ if (lock_active_pool_done)
+ lockd_lv(cmd, pool_lv, "un", LDLV_PERSISTENT);
+ if (pool_lv && pool_lv->lock_args && pool_lv->new_lock_args)
+ lockd_free_lv(cmd, vg, pool_lv->name, &pool_lv->lvid.id[1], pool_lv->lock_args);
+
+ if (policy_settings)
+ dm_config_destroy(policy_settings);
+
return 0;
-#endif
}
static int _cache_vol_attach(struct cmd_context *cmd,
--
2.35.3

View File

@ -1,34 +0,0 @@
From db5277c97155632ce83e1125e348eda97c871968 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 24 Jun 2022 10:40:54 -0500
Subject: [PATCH] pvdisplay: restore --reportformat option
Fixes commit b8f4ec846 "display: ignore --reportformat"
by restoring the --reportformat option to pvdisplay.
Adding -C to pvdisplay turns the command into a reporting
command (like pvs, vgs, lvs) in which --reportformat can
be useful.
---
tools/command-lines.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index b64fd0dda232..b6a03d158daa 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1593,10 +1593,10 @@ pvdisplay
OO: --aligned, --all, --binary, --colon, --columns, --configreport ConfigReport,
--foreign, --ignorelockingfailure,
--logonly, --maps, --noheadings, --nosuffix, --options String,
---readonly, --select String, --separator String, --shared,
+--readonly, --reportformat ReportFmt, --select String, --separator String, --shared,
--short, --sort String, --unbuffered, --units Units
OP: PV|Tag ...
-IO: --ignoreskippedcluster, --reportformat ReportFmt
+IO: --ignoreskippedcluster
ID: pvdisplay_general
---
--
2.26.2

View File

@ -1,246 +0,0 @@
From 92b4fcf57f3c6d212d06b72b097e1a06e6efb84b Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 5 Jul 2022 17:08:00 -0500
Subject: [PATCH] exit with error when --devicesfile name doesn't exist
---
lib/cache/lvmcache.c | 3 ++-
lib/label/label.c | 4 ++--
test/shell/devicesfile-basic.sh | 1 +
tools/pvcreate.c | 3 ++-
tools/pvremove.c | 3 ++-
tools/pvscan.c | 3 ++-
tools/toollib.c | 27 +++++++++++++++++++++------
tools/vgcfgrestore.c | 5 ++++-
tools/vgcreate.c | 5 ++++-
tools/vgextend.c | 3 ++-
tools/vgmerge.c | 3 ++-
tools/vgsplit.c | 3 ++-
12 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 22edcfd849e3..a1c4a61c82fa 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -1612,7 +1612,8 @@ int lvmcache_label_scan(struct cmd_context *cmd)
* with infos/vginfos based on reading headers from
* each device, and a vg summary from each mda.
*/
- label_scan(cmd);
+ if (!label_scan(cmd))
+ return_0;
/*
* When devnames are used as device ids (which is dispreferred),
diff --git a/lib/label/label.c b/lib/label/label.c
index 711edb6f4085..f845abb9640f 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -801,7 +801,7 @@ static int _setup_bcache(void)
}
if (!(scan_bcache = bcache_create(BCACHE_BLOCK_SIZE_IN_SECTORS, cache_blocks, ioe))) {
- log_error("Failed to create bcache with %d cache blocks.", cache_blocks);
+ log_error("Failed to set up io layer with %d blocks.", cache_blocks);
return 0;
}
@@ -1292,7 +1292,7 @@ int label_scan(struct cmd_context *cmd)
* data to invalidate.)
*/
if (!(iter = dev_iter_create(NULL, 0))) {
- log_error("Scanning failed to get devices.");
+ log_error("Failed to get device list.");
return 0;
}
while ((dev = dev_iter_get(cmd, iter))) {
diff --git a/test/shell/devicesfile-basic.sh b/test/shell/devicesfile-basic.sh
index 77fe265a0c54..715c579b394c 100644
--- a/test/shell/devicesfile-basic.sh
+++ b/test/shell/devicesfile-basic.sh
@@ -107,6 +107,7 @@ not vgs --devicesfile test.devices $vg2
# misspelled override name fails
not vgs --devicesfile doesnotexist $vg1
not vgs --devicesfile doesnotexist $vg2
+not vgs --devicesfile doesnotexist
# devicesfile and devices cannot be used together
not vgs --devicesfile test.devices --devices "$dev1","$dev1" $vg1
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 71eb060a37ae..a1ef0e9e1941 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -144,7 +144,8 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
cmd->create_edit_devices_file = 1;
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd))
+ return_ECMD_FAILED;
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 2dfdbd016826..5c39ee0c7904 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -45,7 +45,8 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv)
clear_hint_file(cmd);
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd))
+ return_ECMD_FAILED;
/* When forcibly clearing a PV we don't care about a VG lock. */
if (pp.force == DONT_PROMPT_OVERRIDE)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 1e47d754ab7e..72c3279c3179 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -1407,7 +1407,8 @@ static int _pvscan_cache_all(struct cmd_context *cmd, int argc, char **argv,
* which we want 'pvscan --cache' to do, and that uses
* info from lvmcache, e.g. duplicate pv info.
*/
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd))
+ return_0;
cmd->pvscan_recreate_hints = 0;
cmd->use_hints = 0;
diff --git a/tools/toollib.c b/tools/toollib.c
index d77092d894d2..544791808f6c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1655,7 +1655,10 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv,
log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_LABEL);
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd)) {
+ ret_max = ECMD_FAILED;
+ goto_out;
+ }
if (argc) {
for (; opt < argc; opt++) {
@@ -2435,8 +2438,13 @@ int process_each_vg(struct cmd_context *cmd,
* Scan all devices to populate lvmcache with initial
* list of PVs and VGs.
*/
- if (!(read_flags & PROCESS_SKIP_SCAN))
- lvmcache_label_scan(cmd);
+ if (!(read_flags & PROCESS_SKIP_SCAN)) {
+ if (!lvmcache_label_scan(cmd)) {
+ ret_max = ECMD_FAILED;
+ goto_out;
+ }
+ }
+
/*
* A list of all VGs on the system is needed when:
@@ -3987,7 +3995,10 @@ int process_each_lv(struct cmd_context *cmd,
* Scan all devices to populate lvmcache with initial
* list of PVs and VGs.
*/
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd)) {
+ ret_max = ECMD_FAILED;
+ goto_out;
+ }
/*
* A list of all VGs on the system is needed when:
@@ -4623,8 +4634,12 @@ int process_each_pv(struct cmd_context *cmd,
goto_out;
}
- if (!(read_flags & PROCESS_SKIP_SCAN))
- lvmcache_label_scan(cmd);
+ if (!(read_flags & PROCESS_SKIP_SCAN)) {
+ if (!lvmcache_label_scan(cmd)) {
+ ret_max = ECMD_FAILED;
+ goto_out;
+ }
+ }
if (!lvmcache_get_vgnameids(cmd, &all_vgnameids, only_this_vgname, 1)) {
ret_max = ret;
diff --git a/tools/vgcfgrestore.c b/tools/vgcfgrestore.c
index e49313d144e8..9fcba89d44d5 100644
--- a/tools/vgcfgrestore.c
+++ b/tools/vgcfgrestore.c
@@ -132,7 +132,10 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
clear_hint_file(cmd);
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd)) {
+ unlock_vg(cmd, NULL, vg_name);
+ return_ECMD_FAILED;
+ }
cmd->handles_unknown_segments = 1;
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index dde3f1eac279..14608777fd59 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -84,7 +84,10 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
cmd->create_edit_devices_file = 1;
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd)) {
+ unlock_vg(cmd, NULL, vp_new.vg_name);
+ return_ECMD_FAILED;
+ }
if (lvmcache_vginfo_from_vgname(vp_new.vg_name, NULL)) {
unlock_vg(cmd, NULL, vp_new.vg_name);
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 0856b4c78d25..fecd6bdd5b4f 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -160,7 +160,8 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
cmd->edit_devices_file = 1;
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd))
+ return_ECMD_FAILED;
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index 08615cd62305..4ed4a8f0b752 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -72,7 +72,8 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
return ECMD_FAILED;
}
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd))
+ return_ECMD_FAILED;
if (strcmp(vg_name_to, vg_name_from) > 0)
lock_vg_from_first = 1;
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 5f113b3635e2..c7f4b8af4db1 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -559,7 +559,8 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- lvmcache_label_scan(cmd);
+ if (!lvmcache_label_scan(cmd))
+ return_ECMD_FAILED;
if (!(vginfo_to = lvmcache_vginfo_from_vgname(vg_name_to, NULL))) {
if (!validate_name(vg_name_to)) {
--
2.26.2

View File

@ -0,0 +1,63 @@
From ae13074a0a6ea7997cdb370cdd2185801646b2c5 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 16 Aug 2023 13:24:36 -0500
Subject: [PATCH 06/24] lvmlockd: let lockd_init_lv_args set lock_args
Set the lock_args string in addition to doing initialization.
lvconvert calls lockd_init_lv_args() directly, skipping
the normal lockd_init_lv() which usually sets lock_args.
---
lib/locking/lvmlockd.c | 9 +++++++--
tools/lvconvert.c | 15 +++------------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index d44b7333a..627aa2625 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2938,8 +2938,13 @@ int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg,
struct logical_volume *lv,
const char *lock_type, const char **lock_args)
{
- /* sanlock is the only lock type that sets per-LV lock_args. */
- if (!strcmp(lock_type, "sanlock"))
+ if (!lock_type)
+ return 1;
+ if (!strcmp(lock_type, "dlm"))
+ *lock_args = "dlm";
+ else if (!strcmp(lock_type, "idm"))
+ *lock_args = "idm";
+ else if (!strcmp(lock_type, "sanlock"))
return _init_lv_sanlock(cmd, vg, lv->name, &lv->lvid.id[1], lock_args);
return 1;
}
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 7c9540712..40e7a6871 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3471,19 +3471,10 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
metadata_lv->lock_args = NULL;
if (!to_cachepool) {
- if (!strcmp(vg->lock_type, "sanlock")) {
- if (!lockd_init_lv_args(cmd, vg, pool_lv,
- vg->lock_type, &pool_lv->lock_args)) {
- log_error("Cannot allocate lock for new pool LV.");
- goto_bad;
- }
- pool_lv->new_lock_args = 1; /* tells vg_revert to lockd_free_lv */
- } else if (!strcmp(vg->lock_type, "dlm")) {
- pool_lv->lock_args = "dlm";
- } else if (!strcmp(vg->lock_type, "idm")) {
- pool_lv->lock_args = "idm";
+ if (!lockd_init_lv_args(cmd, vg, pool_lv, vg->lock_type, &pool_lv->lock_args)) {
+ log_error("Cannot allocate lock for new pool LV.");
+ goto_bad;
}
-
if (lock_active_pool) {
if (!lockd_lv(cmd, pool_lv, "ex", LDLV_PERSISTENT)) {
log_error("Failed to lock new pool LV %s.", display_lvname(pool_lv));
--
2.35.3

View File

@ -0,0 +1,97 @@
From 3e92798473a04bec26a91632e1436aa415c2bb3c Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 16 Aug 2023 15:00:47 -0500
Subject: [PATCH 07/24] lvmlockd: fix lvconvert to thin-pool
---
tools/lvconvert.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 40e7a6871..7d5057254 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3096,7 +3096,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
struct lv_segment *seg;
unsigned int target_attr = ~0;
unsigned int activate_pool;
- unsigned int lock_active_pool;
unsigned int lock_active_pool_done = 0;
unsigned int zero_metadata;
uint64_t meta_size;
@@ -3145,12 +3144,10 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
is_active = lv_is_active(lv);
activate_pool = to_thinpool && is_active;
- lock_active_pool = (to_thinpool || to_thin) && is_active;
/* Wipe metadata_lv by default, but allow skipping this for cache pools. */
zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
- /* An existing LV needs to have its lock freed once it becomes a data LV. */
if (vg_is_shared(vg) && lv->lock_args) {
lockd_data_args = dm_pool_strdup(cmd->mem, lv->lock_args);
lockd_data_name = dm_pool_strdup(cmd->mem, lv->name);
@@ -3458,11 +3455,11 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
goto_bad;
/*
- * Create a new lock for a thin pool LV. A cache pool LV has no lock.
- * Locks are removed from existing LVs that are being converted to
- * data and meta LVs (they are unlocked and deleted below.)
- * Acquire the new thin pool lock if the pool will remain active at
- * the end of the command.
+ * If the input LV is being converted to a thin pool, the input LV lock
+ * is used for the thin pool LV. If the input LV is being converted to
+ * a thin LV, a new lock is created for the thin pool and the lock from
+ * the input LV is freed. A cache pool LV has no lock, so the lock for
+ * the input LV is freed.
*/
if (vg_is_shared(vg)) {
lv->lock_args = NULL;
@@ -3470,18 +3467,25 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
data_lv->lock_args = NULL;
metadata_lv->lock_args = NULL;
- if (!to_cachepool) {
+ if (to_thin) {
if (!lockd_init_lv_args(cmd, vg, pool_lv, vg->lock_type, &pool_lv->lock_args)) {
log_error("Cannot allocate lock for new pool LV.");
goto_bad;
}
- if (lock_active_pool) {
- if (!lockd_lv(cmd, pool_lv, "ex", LDLV_PERSISTENT)) {
- log_error("Failed to lock new pool LV %s.", display_lvname(pool_lv));
- goto_bad;
- }
- lock_active_pool_done = 1;
+ } else if (to_thinpool) {
+ pool_lv->lock_args = lockd_data_args;
+ /* Don't free this lock below. */
+ lockd_data_args = NULL;
+ lockd_data_name = NULL;
+ }
+
+ /* Acquire the thin pool lock if the pool will remain active. */
+ if ((to_thin || to_thinpool) && is_active) {
+ if (!lockd_lv(cmd, pool_lv, "ex", LDLV_PERSISTENT)) {
+ log_error("Failed to lock new pool LV %s.", display_lvname(pool_lv));
+ goto_bad;
}
+ lock_active_pool_done = 1;
}
}
@@ -3523,8 +3527,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
}
/*
- * Unlock and free the locks from existing LVs that became pool data
- * and meta LVs.
+ * Unlock and free locks that are no longer used.
*/
if (lockd_data_name) {
if (!lockd_lv_name(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args, "un", lockd_data_flags)) {
--
2.35.3

View File

@ -1,38 +0,0 @@
From fc8fda641781d0978ff22ad0a59d5a19b5e450e1 Mon Sep 17 00:00:00 2001
From: Peter Rajnoha <prajnoha@redhat.com>
Date: Fri, 5 Aug 2022 11:02:25 +0200
Subject: [PATCH] report: fix pe_start column type from NUM to SIZ
The 'pe_start' column was incorrectly marked as being of type NUM.
This was not correct as pe_start is actually of type SIZ, which means
it can have a size suffix and hence it's not a pure numeric value.
Proper column type is important for selection to work correctly, so we
can also do comparisons while using suffixes.
This is also important for new "json_std" output format which does not
put double quotes around pure numeric values. With pe_start incorrectly
marked as NUM instead of SIZ, this produced invalid JSON output
like '"pe_start" = 1.00m' because it contained the 'm' (or other)
size suffix. If properly marked as SIZ, this is then put in double
quotes like '"pe_start" = "1.00m"'.
---
lib/report/columns.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 7e450dacef66..d702635d2f15 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -191,7 +191,7 @@ FIELD(LABEL, label, NUM, "PExtVsn", type, 0, pvextvsn, pv_ext_vsn, "PV header ex
/*
* PVS type fields
*/
-FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, pe_start, "Offset to the start of data on the underlying device.", 0)
+FIELD(PVS, pv, SIZ, "1st PE", pe_start, 7, size64, pe_start, "Offset to the start of data on the underlying device.", 0)
FIELD(PVS, pv, SIZ, "PSize", id, 0, pvsize, pv_size, "Size of PV in current units.", 0)
FIELD(PVS, pv, SIZ, "PFree", id, 0, pvfree, pv_free, "Total amount of unallocated space in current units.", 0)
FIELD(PVS, pv, SIZ, "Used", id, 0, pvused, pv_used, "Total amount of allocated space in current units.", 0)
--
2.26.2

View File

@ -1,35 +0,0 @@
From ce58e9d5b37c3e408f2b41c8095980490a87f2a4 Mon Sep 17 00:00:00 2001
From: Wu Guanghao <wuguanghao3@huawei.com>
Date: Mon, 15 Aug 2022 09:39:02 -0500
Subject: [PATCH] _vg_read_raw_area: fix segfault caused by using null pointer
When we tested lvm2, the kernel injected various random faults.
(gdb) bt
...
(gdb) p vg
$1 = (struct volume_group *) 0x0
(gdb) p use_previous_vg
$2 = (unsigned int *) 0x0
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
---
lib/format_text/format-text.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 07aaa0b28880..c1ccdb0316d8 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -428,7 +428,7 @@ static struct volume_group *_vg_read_raw_area(struct cmd_context *cmd,
rlocn->checksum,
&when, &desc);
- if (!vg && !*use_previous_vg) {
+ if (!vg && (!use_previous_vg || !*use_previous_vg)) {
log_warn("WARNING: Failed to read metadata text at %llu off %llu size %llu VG %s on %s",
(unsigned long long)(area->start + rlocn->offset),
(unsigned long long)rlocn->offset,
--
2.26.2

View File

@ -0,0 +1,34 @@
From 33b804a80e24d58e57936f7c5a6cbe7c77981483 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 17 Aug 2023 21:50:03 +0200
Subject: [PATCH 08/24] lvconvert: run error path code only for shared VG
Error path for locking only for share VG.
---
tools/lvconvert.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 7d5057254..49e9248a6 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3566,10 +3566,12 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
* committed should not exit here. There is some cleanup missing here.
*/
bad:
- if (lock_active_pool_done)
- lockd_lv(cmd, pool_lv, "un", LDLV_PERSISTENT);
- if (pool_lv && pool_lv->lock_args && pool_lv->new_lock_args)
- lockd_free_lv(cmd, vg, pool_lv->name, &pool_lv->lvid.id[1], pool_lv->lock_args);
+ if (vg_is_shared(vg)) {
+ if (lock_active_pool_done)
+ lockd_lv(cmd, pool_lv, "un", LDLV_PERSISTENT);
+ if (pool_lv && pool_lv->lock_args && pool_lv->new_lock_args)
+ lockd_free_lv(cmd, vg, pool_lv->name, &pool_lv->lvid.id[1], pool_lv->lock_args);
+ }
if (policy_settings)
dm_config_destroy(policy_settings);
--
2.35.3

View File

@ -1,26 +0,0 @@
From a3eb6ba425773224076c41aabc3c490a6a016ee6 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 18 Aug 2022 14:31:27 +0200
Subject: [PATCH] mm: remove libaio from being skipped
Since libaio is now used also in critical section,
keep the libaio locked in memory.
---
lib/mm/memlock.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 3d1a3927ceb4..f43bacdcdf27 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -105,7 +105,6 @@ static const char * const _blacklist_maps[] = {
"/LC_MESSAGES/",
"gconv/gconv-modules.cache",
"/ld-2.", /* not using dlopen,dlsym during mlock */
- "/libaio.so.", /* not using aio during mlock */
"/libattr.so.", /* not using during mlock (udev) */
"/libblkid.so.", /* not using blkid during mlock (udev) */
"/libbz2.so.", /* not using during mlock (udev) */
--
2.26.2

View File

@ -0,0 +1,30 @@
From b6ab049c3184edcb4d56789d32991bbf8c97de77 Mon Sep 17 00:00:00 2001
From: wangzhiqiang <wangzhiqiang95@huawei.com>
Date: Wed, 30 Aug 2023 15:47:42 -0500
Subject: [PATCH 09/24] vgchange: acquire an exclusive VG lock for refresh
Concurrent vgchange --refresh commands can lead to hung
tasks in dm code.
Signed-off-by: wangzhiqiang <wangzhiqiang95@huawei.com>
---
tools/vgchange.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index e2d3dad02..8c1d605c6 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -1008,7 +1008,8 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
if (update)
flags |= READ_FOR_UPDATE;
- else if (arg_is_set(cmd, activate_ARG))
+ else if (arg_is_set(cmd, activate_ARG) ||
+ arg_is_set(cmd, refresh_ARG))
flags |= READ_FOR_ACTIVATE;
if (!(handle = init_processing_handle(cmd, NULL))) {
--
2.35.3

View File

@ -1,28 +0,0 @@
From 718e38d5faf3a3ca23690d2f4203df1df65eba77 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 18 Aug 2022 13:56:03 +0200
Subject: [PATCH] dmsetup: check also for ouf of range value
Check errno result from strtoull().
---
libdm/dm-tools/dmsetup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 8502d9adc170..42eeead68f4d 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -5106,8 +5106,9 @@ static int _size_from_string(char *argptr, uint64_t *size, const char *name)
if (!argptr)
return_0;
+ errno = 0;
*size = strtoull(argptr, &endptr, 10);
- if (endptr == argptr) {
+ if (errno || endptr == argptr) {
*size = 0;
log_error("Invalid %s argument: \"%s\"",
name, (*argptr) ? argptr : "");
--
2.26.2

View File

@ -0,0 +1,40 @@
From cd17ccbc684590e8655888af6d6b0452287fd47d Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 31 Aug 2023 13:15:07 -0500
Subject: [PATCH 10/24] lvmlockd: client mutex ordering
Avoid deadlock between threads on mutexes (in theory.)
---
daemons/lvmlockd/lvmlockd-core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 887226f1a..1261f6482 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -4690,9 +4690,12 @@ static int dump_info(int *dump_len)
/*
* clients
+ * Proper lock order is client_mutex then cl->mutex,
+ * but cl->mutex is already held so skip client info
+ * if it would block.
*/
-
- pthread_mutex_lock(&client_mutex);
+ if (pthread_mutex_trylock(&client_mutex))
+ goto print_ls;
list_for_each_entry(cl, &client_list, list) {
ret = print_client(cl, "client", pos, len);
if (ret >= len - pos) {
@@ -4706,6 +4709,7 @@ static int dump_info(int *dump_len)
if (rv < 0)
return rv;
+ print_ls:
/*
* lockspaces with their action/resource/lock info
*/
--
2.35.3

View File

@ -1,90 +0,0 @@
From 1a981e9b6efb0bbc0881f5ed1f17900e9c669f48 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 10 Aug 2022 15:09:34 +0200
Subject: [PATCH] devices: drop double // from sysfs path
dm_sysfs_dir() comes internally as /sys/.
---
lib/device/dev-mpath.c | 4 ++--
lib/device/dev-type.c | 8 ++++----
lib/metadata/vdo_manip.c | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/device/dev-mpath.c b/lib/device/dev-mpath.c
index 27b0f41a6a8a..2040edac3bb8 100644
--- a/lib/device/dev-mpath.c
+++ b/lib/device/dev-mpath.c
@@ -815,7 +815,7 @@ const char *dev_mpath_component_wwid(struct cmd_context *cmd, struct device *dev
/* /sys/dev/block/253:7/slaves/sda/device/wwid */
- if (dm_snprintf(slaves_path, sizeof(slaves_path), "%s/dev/block/%d:%d/slaves",
+ if (dm_snprintf(slaves_path, sizeof(slaves_path), "%sdev/block/%d:%d/slaves",
dm_sysfs_dir(), (int)MAJOR(dev->dev), (int)MINOR(dev->dev)) < 0) {
log_warn("Sysfs path to check mpath components is too long.");
return NULL;
@@ -845,7 +845,7 @@ const char *dev_mpath_component_wwid(struct cmd_context *cmd, struct device *dev
/* read /sys/block/sda/device/wwid */
- if (dm_snprintf(wwid_path, sizeof(wwid_path), "%s/block/%s/device/wwid",
+ if (dm_snprintf(wwid_path, sizeof(wwid_path), "%sblock/%s/device/wwid",
dm_sysfs_dir(), slave_name) < 0) {
log_warn("Failed to create sysfs wwid path for %s", slave_name);
continue;
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 939eb4aeb514..1dc895b54216 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -548,7 +548,7 @@ static int _has_sys_partition(struct device *dev)
int minor = (int) MINOR(dev->dev);
/* check if dev is a partition */
- if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d/partition",
+ if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/partition",
dm_sysfs_dir(), major, minor) < 0) {
log_warn("WARNING: %s: partition path is too long.", dev_name(dev));
return 0;
@@ -775,7 +775,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
* - basename ../../block/md0/md0 = md0
* Parent's 'dev' sysfs attribute = /sys/block/md0/dev
*/
- if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d",
+ if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d",
dm_sysfs_dir(), major, minor) < 0) {
log_warn("WARNING: %s: major:minor sysfs path is too long.", dev_name(dev));
return 0;
@@ -787,7 +787,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
temp_path[size] = '\0';
- if (dm_snprintf(path, sizeof(path), "%s/block/%s/dev",
+ if (dm_snprintf(path, sizeof(path), "%sblock/%s/dev",
dm_sysfs_dir(), basename(dirname(temp_path))) < 0) {
log_warn("WARNING: sysfs path for %s is too long.",
basename(dirname(temp_path)));
@@ -1095,7 +1095,7 @@ int wipe_known_signatures(struct cmd_context *cmd, struct device *dev,
static int _snprintf_attr(char *buf, size_t buf_size, const char *sysfs_dir,
const char *attribute, dev_t dev)
{
- if (dm_snprintf(buf, buf_size, "%s/dev/block/%d:%d/%s", sysfs_dir,
+ if (dm_snprintf(buf, buf_size, "%sdev/block/%d:%d/%s", sysfs_dir,
(int)MAJOR(dev), (int)MINOR(dev),
attribute) < 0) {
log_warn("WARNING: sysfs path for %s attribute is too long.", attribute);
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 0db401537d7c..779883d03bc3 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -148,7 +148,7 @@ static int _sysfs_get_kvdo_value(const char *dm_name, const struct dm_info *dmin
char temp[64];
int fd, size, r = 0;
- if (dm_snprintf(path, sizeof(path), "%s/block/dm-%d/vdo/%s",
+ if (dm_snprintf(path, sizeof(path), "%sblock/dm-%d/vdo/%s",
dm_sysfs_dir(), dminfo->minor, vdo_param) < 0) {
log_debug("Failed to build kvdo path.");
return 0;
--
2.26.2

View File

@ -0,0 +1,57 @@
From b5b97c2b663565833218f68b196327ef63b1a114 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 31 Aug 2023 18:50:33 +0200
Subject: [PATCH 11/24] filesystem: move stat after open check
To avoid time-of-check-time-of-use clash, take the stat()
after successful open with fstat().
Also add some debugs for failing sys calls.
---
lib/device/filesystem.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/device/filesystem.c b/lib/device/filesystem.c
index 53cbc2d02..29b57d0c9 100644
--- a/lib/device/filesystem.c
+++ b/lib/device/filesystem.c
@@ -155,26 +155,26 @@ int fs_get_info(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- if (stat(crypt_path, &st_crypt) < 0) {
- log_error("Failed to get crypt path %s", crypt_path);
- return 0;
- }
-
memset(&info, 0, sizeof(info));
log_print_unless_silent("Checking crypt device %s on LV %s.",
crypt_path, display_lvname(lv));
if ((fd = open(crypt_path, O_RDONLY)) < 0) {
- log_error("Failed to open crypt path %s", crypt_path);
+ log_error("Failed to open crypt path %s.", crypt_path);
return 0;
}
- if (ioctl(fd, BLKGETSIZE64, &info.crypt_dev_size_bytes) < 0) {
- log_error("Failed to get crypt device size %s", crypt_path);
- close(fd);
+
+ if ((ret = fstat(fd, &st_crypt)) < 0)
+ log_sys_error("fstat", crypt_path);
+ else if ((ret = ioctl(fd, BLKGETSIZE64, &info.crypt_dev_size_bytes)) < 0)
+ log_error("Failed to get crypt device size %s.", crypt_path);
+
+ if (close(fd))
+ log_sys_debug("close", crypt_path);
+
+ if (ret < 0)
return 0;
- }
- close(fd);
if (!fs_get_blkid(crypt_path, &info)) {
log_error("No file system info from blkid for dm-crypt device %s on LV %s.",
--
2.35.3

View File

@ -1,66 +0,0 @@
From 8c3cfc75c72696ae8b620555fcc4f815b0c1d6b6 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 19 Aug 2022 13:31:22 -0500
Subject: [PATCH] devices file: fix pvcreate --uuid matching pvid entry with no
device id
pvcreate with --uuid would segfault if a devices file entry matched
the specified pvid, but the devices file entry had no device_id, which
could happen if the entry has a devname idtype.
---
lib/device/device_id.c | 7 ++++---
test/shell/devicesfile-devname.sh | 13 +++++++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 9dec9f884da4..6c70f110c820 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -1168,8 +1168,9 @@ id_done:
du_devname->devname);
if (du_pvid && (du_pvid->dev != dev))
- log_warn("WARNING: adding device %s with PVID %s which is already used for %s.",
- dev_name(dev), pvid, du_pvid->dev ? dev_name(du_pvid->dev) : "missing device");
+ log_warn("WARNING: adding device %s with PVID %s which is already used for %s device_id %s.",
+ dev_name(dev), pvid, du_pvid->dev ? dev_name(du_pvid->dev) : "missing device",
+ du_pvid->idname ?: "none");
if (du_devid && (du_devid->dev != dev)) {
if (!du_devid->dev) {
@@ -1215,7 +1216,7 @@ id_done:
else
check_idname = device_id_system_read(cmd, dev, du_pvid->idtype);
- if (check_idname && !strcmp(check_idname, du_pvid->idname)) {
+ if (!du_pvid->idname || (check_idname && !strcmp(check_idname, du_pvid->idname))) {
update_du = du_pvid;
dm_list_del(&update_du->list);
update_matching_kind = "PVID";
diff --git a/test/shell/devicesfile-devname.sh b/test/shell/devicesfile-devname.sh
index 338637275ec5..211f4dbed36b 100644
--- a/test/shell/devicesfile-devname.sh
+++ b/test/shell/devicesfile-devname.sh
@@ -550,6 +550,19 @@ vgchange -an $vg2
vgremove -ff $vg1
vgremove -ff $vg2
+# bz 2119473
+
+aux lvmconf "devices/search_for_devnames = \"none\""
+sed -e "s|DEVNAME=$dev1|DEVNAME=.|" "$ORIG" > tmp1.devices
+sed -e "s|IDNAME=$dev1|IDNAME=.|" tmp1.devices > "$DF"
+pvs
+lvmdevices
+pvcreate -ff --yes --uuid "$PVID1" --norestorefile $dev1
+grep "$PVID1" "$DF" |tee out
+grep "DEVNAME=$dev1" out
+grep "IDNAME=$dev1" out
+aux lvmconf "devices/search_for_devnames = \"auto\""
+
# devnames change so the new devname now refers to a filtered device,
# e.g. an mpath or md component, which is not scanned
--
2.26.2

View File

@ -0,0 +1,49 @@
From 950edf73781807b07d97717b460ae682edb38fdf Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Mon, 4 Sep 2023 17:32:26 +0200
Subject: [PATCH 12/24] tests: check for writecache
Writecache needs writecache kernel target to be present.
---
test/shell/caching-snapshot.sh | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/test/shell/caching-snapshot.sh b/test/shell/caching-snapshot.sh
index d73f4ad06..854d8bad7 100644
--- a/test/shell/caching-snapshot.sh
+++ b/test/shell/caching-snapshot.sh
@@ -22,6 +22,9 @@ lvm segtypes 2>/dev/null | grep writecache$ >/dev/null || {
aux have_cache 1 10 0 || skip
which mkfs.ext4 || skip
+HAVE_WRITECACHE=1
+aux have_writecache 1 0 0 || HAVE_WRITECACHE=0
+
mount_dir="mnt"
mkdir -p "$mount_dir"
@@ -105,7 +108,10 @@ test_snap_remove() {
test_snap_remove cache --cachepool
test_snap_remove cache --cachevol
+
+if [ "$HAVE_WRITECACHE" = "1" ]; then
test_snap_remove writecache --cachevol
+fi
# adding cache|writecache to an LV that has a snapshot
@@ -143,7 +149,10 @@ test_caching_with_snap() {
test_caching_with_snap cache --cachepool
test_caching_with_snap cache --cachevol
+
+if [ "$HAVE_WRITECACHE" = "1" ]; then
test_caching_with_snap writecache --cachevol
+fi
# adding cache|writecache to a snapshot is not allowed
--
2.35.3

View File

@ -0,0 +1,34 @@
From 25618d71b57e380ab692b640419dc89a9c6fe20e Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 11 Sep 2023 12:18:12 -0500
Subject: [PATCH 13/24] lvresize: fix 32 bit overflow in size calculation
---
lib/metadata/lv_manip.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 9bec8b54d..23e04c3a8 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6445,7 +6445,7 @@ static int _fs_reduce(struct cmd_context *cmd, struct logical_volume *lv,
}
/* extent_size units is SECTOR_SIZE (512) */
- newsize_bytes_lv = lp->extents * lv->vg->extent_size * SECTOR_SIZE;
+ newsize_bytes_lv = (uint64_t) lp->extents * lv->vg->extent_size * SECTOR_SIZE;
newsize_bytes_fs = newsize_bytes_lv;
/*
@@ -6591,7 +6591,7 @@ static int _fs_extend(struct cmd_context *cmd, struct logical_volume *lv,
*/
/* extent_size units is SECTOR_SIZE (512) */
- newsize_bytes_lv = lp->extents * lv->vg->extent_size * SECTOR_SIZE;
+ newsize_bytes_lv = (uint64_t) lp->extents * lv->vg->extent_size * SECTOR_SIZE;
newsize_bytes_fs = newsize_bytes_lv;
if (fsinfo.needs_crypt) {
newsize_bytes_fs -= fsinfo.crypt_offset_bytes;
--
2.35.3

View File

@ -1,442 +0,0 @@
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

View File

@ -0,0 +1,44 @@
From afb60167d6268a61d51b1a33efa741f46c7e73ee Mon Sep 17 00:00:00 2001
From: Mikulas Patocka <mpatocka@redhat.com>
Date: Wed, 6 Sep 2023 15:28:29 +0200
Subject: [PATCH 14/24] gcc: fix warnings for x32 architecture
Warning from x32 ABI compilation.
---
lib/log/log.c | 2 +-
lib/metadata/vdo_manip.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/log/log.c b/lib/log/log.c
index 6dc269675..b654737f1 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -515,7 +515,7 @@ static void _set_time_prefix(char *prefix, int buflen)
if (!len)
goto fail;
- len = dm_snprintf(prefix + len, buflen - len, ".%06ld ", ts.tv_nsec/1000);
+ len = dm_snprintf(prefix + len, buflen - len, ".%06d ", (int)ts.tv_nsec/1000);
if (len < 0)
goto fail;
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index d51ef2dbf..516d42d8b 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -522,9 +522,9 @@ static int _get_sysinfo_memory(uint64_t *total_mb, uint64_t *available_mb)
if (sysinfo(&si) != 0)
return 0;
- log_debug("Sysinfo free:%lu bufferram:%lu sharedram:%lu freehigh:%lu unit:%u.",
- si.freeram >> 20, si.bufferram >> 20, si.sharedram >> 20,
- si.freehigh >> 20, si.mem_unit);
+ log_debug("Sysinfo free:%llu bufferram:%llu sharedram:%llu freehigh:%llu unit:%u.",
+ (unsigned long long)si.freeram >> 20, (unsigned long long)si.bufferram >> 20, (unsigned long long)si.sharedram >> 20,
+ (unsigned long long)si.freehigh >> 20, si.mem_unit);
*available_mb = ((uint64_t)(si.freeram + si.bufferram) * si.mem_unit) >> 30;
*total_mb = si.totalram >> 30;
--
2.35.3

View File

@ -1,76 +0,0 @@
From 0eebd9d7802c724ee71b6ebb80940ea6007f9c7a Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 30 Aug 2022 14:40:48 -0500
Subject: [PATCH] vgimportdevices: fix locking when creating devices file
Take the devices file lock before creating a new devices file.
(Was missed by the change to preemptively create the devices
file prior to setup_devices(), which was done to improve the
error path.)
---
lib/device/dev-cache.c | 7 +++----
lib/device/device_id.c | 1 +
tools/vgimportdevices.c | 10 ++++++++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 193eb7585f45..85f9b499af4d 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1937,10 +1937,9 @@ int setup_devices(struct cmd_context *cmd)
if (!file_exists) {
/*
- * pvcreate/vgcreate/vgimportdevices/lvmdevices-add create
- * a new devices file here if it doesn't exist.
- * They have the create_edit_devices_file flag set.
- * First they create/lock-ex the devices file lockfile.
+ * pvcreate/vgcreate create a new devices file here if it
+ * doesn't exist. They have create_edit_devices_file=1.
+ * First create/lock-ex the devices file lockfile.
* Other commands will not use a devices file if none exists.
*/
lock_mode = LOCK_EX;
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 6c70f110c820..a0a6265336ed 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -2468,6 +2468,7 @@ static int _lock_devices_file(struct cmd_context *cmd, int mode, int nonblock, i
if (_devices_file_locked == mode) {
/* can happen when a command holds an ex lock and does an update in device_ids_validate */
+ /* can happen when vgimportdevices calls this directly, followed later by setup_devices */
if (held)
*held = 1;
return 1;
diff --git a/tools/vgimportdevices.c b/tools/vgimportdevices.c
index 9ade1b9e4b21..23c2718ffe0f 100644
--- a/tools/vgimportdevices.c
+++ b/tools/vgimportdevices.c
@@ -132,8 +132,10 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
/*
- * Prepare devices file preemptively because the error path for this
- * case from process_each is not as clean.
+ * Prepare/create devices file preemptively because the error path for
+ * this case from process_each/setup_devices is not as clean.
+ * This means that when setup_devices is called, it the devices
+ * file steps will be redundant, and need to handle being repeated.
*/
if (!setup_devices_file(cmd)) {
log_error("Failed to set up devices file.");
@@ -143,6 +145,10 @@ int vgimportdevices(struct cmd_context *cmd, int argc, char **argv)
log_error("Devices file not enabled.");
return ECMD_FAILED;
}
+ if (!lock_devices_file(cmd, LOCK_EX)) {
+ log_error("Failed to lock the devices file.");
+ return ECMD_FAILED;
+ }
if (!devices_file_exists(cmd)) {
if (!devices_file_touch(cmd)) {
log_error("Failed to create devices file.");
--
2.26.2

View File

@ -0,0 +1,26 @@
From ae65e71b3d519ed99f0bab6a595d6d255e0635bb Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 12 Sep 2023 16:40:26 +0200
Subject: [PATCH 15/24] gcc: warning: missing braces around initializer
Fix warning emitted by some older gcc...
---
tools/lvconvert.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 49e9248a6..aa601d4ca 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -6514,7 +6514,7 @@ static int _lvconvert_integrity_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
- struct integrity_settings settings = { 0 };
+ struct integrity_settings settings = { .tag_size = 0 };
int ret;
if (!integrity_mode_set(arg_str_value(cmd, raidintegritymode_ARG, NULL), &settings))
--
2.35.3

View File

@ -0,0 +1,53 @@
From fbbf796dd89007fe57a3c7043f27aed2fbf0775c Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 13 Sep 2023 00:39:33 +0200
Subject: [PATCH 16/24] test: improve aux teardown
Handle the case of device teardown where the first pass
could have only a single, but opened device, for removal.
In such case we want to at least once go through
the udev_wait and retry removal again.
TODO: maybe a sleep .1 might be usable as well with udev_wait
---
test/lib/aux.sh | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 3f66e9290..4474dc72c 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -239,8 +239,8 @@ prepare_lvmpolld() {
echo $! > LOCAL_LVMPOLLD
for i in {200..0} ; do
test -e "$TESTDIR/lvmpolld.socket" && break
- echo -n .;
- sleep .1;
+ echo -n .
+ sleep .1
done # wait for the socket
test "$i" -gt 0 || die "Startup of lvmpolld is too slow."
echo ok
@@ -395,10 +395,10 @@ teardown_devs_prefixed() {
# 2nd. loop is trying --force removal which can possibly 'unstuck' some bloked operations
for i in 0 1; do
test "$i" = 1 && test "$stray" = 0 && break # no stray device removal
+ local progress=1
while :; do
local sortby="name"
- local progress=0
# HACK: sort also by minors - so we try to close 'possibly later' created device first
test "$i" = 0 || sortby="-minor"
@@ -426,6 +426,7 @@ teardown_devs_prefixed() {
udev_wait
wait
+ progress=0
done # looping till there are some removed devices
done
}
--
2.35.3

View File

@ -0,0 +1,26 @@
From cf8a0c94fff754e4b6a504a430e53439d67b6ca0 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 13 Sep 2023 23:27:55 +0200
Subject: [PATCH 17/24] tests: aux try with extra sleep
Since udev_wait is not really adding any major delay to wait
for any udev worker processing - add extra sleep .1.
---
test/lib/aux.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 4474dc72c..816a13223 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -424,6 +424,7 @@ teardown_devs_prefixed() {
test "$progress" = 1 || break
+ sleep .1
udev_wait
wait
progress=0
--
2.35.3

View File

@ -0,0 +1,27 @@
From cb34be9ba90613cd49f4822fc118cecfc93ac897 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 14 Sep 2023 01:41:45 +0200
Subject: [PATCH 18/24] tests: aux using singl lvmconf call
lvmconf can handle multiple options in a single pass.
---
test/lib/aux.sh | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 816a13223..20dbecec2 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1444,8 +1444,7 @@ extend_filter_md() {
for rx in "$@"; do
filter=$(echo "$filter" | sed -e "s:\\[:[ \"$rx\", :")
done
- lvmconf "$filter"
- lvmconf "devices/scan = [ \"$DM_DEV_DIR\", \"/dev\" ]"
+ lvmconf "$filter" "devices/scan = [ \"$DM_DEV_DIR\", \"/dev\" ]"
}
extend_filter_LVMTEST() {
--
2.35.3

View File

@ -0,0 +1,49 @@
From da95bb6883810863a394525c9a66196b7b0dda21 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 13 Sep 2023 23:23:47 +0200
Subject: [PATCH 19/24] tests: missing to check for writecache support
Ono more case requires writecache presence.
---
test/shell/caching-snapshot.sh | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/test/shell/caching-snapshot.sh b/test/shell/caching-snapshot.sh
index 854d8bad7..b31cb520f 100644
--- a/test/shell/caching-snapshot.sh
+++ b/test/shell/caching-snapshot.sh
@@ -72,7 +72,8 @@ test_snap_create() {
test_snap_create cache --cachepool
test_snap_create cache --cachevol
-test_snap_create writecache --cachevol
+
+[ "$HAVE_WRITECACHE" = "1" ] && test_snap_create writecache --cachevol
# removing cache|writecache while snapshot exists
@@ -109,9 +110,7 @@ test_snap_remove() {
test_snap_remove cache --cachepool
test_snap_remove cache --cachevol
-if [ "$HAVE_WRITECACHE" = "1" ]; then
-test_snap_remove writecache --cachevol
-fi
+[ "$HAVE_WRITECACHE" = "1" ] && test_snap_remove writecache --cachevol
# adding cache|writecache to an LV that has a snapshot
@@ -150,9 +149,7 @@ test_caching_with_snap() {
test_caching_with_snap cache --cachepool
test_caching_with_snap cache --cachevol
-if [ "$HAVE_WRITECACHE" = "1" ]; then
-test_caching_with_snap writecache --cachevol
-fi
+[ "$HAVE_WRITECACHE" = "1" ] && test_caching_with_snap writecache --cachevol
# adding cache|writecache to a snapshot is not allowed
--
2.35.3

View File

@ -0,0 +1,40 @@
From befc30b610ed3a648f967e50cea752d0f5a09073 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 13 Sep 2023 23:39:08 +0200
Subject: [PATCH 20/24] tests: pvmove large disk area
With some faster test hw machine we need to make this test
a bit more resource consuming.
---
test/shell/pvmove-abort-all.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/shell/pvmove-abort-all.sh b/test/shell/pvmove-abort-all.sh
index 872db041e..081c02911 100644
--- a/test/shell/pvmove-abort-all.sh
+++ b/test/shell/pvmove-abort-all.sh
@@ -26,7 +26,7 @@ aux target_at_least dm-mirror 1 10 0 || skip
# Throttle mirroring
aux throttle_dm_mirror || skip
-aux prepare_pvs 6 60
+aux prepare_pvs 6 90
vgcreate -s 512k $vg "$dev1" "$dev2"
pvcreate --metadatacopies 0 "$dev3"
@@ -41,9 +41,9 @@ for backgroundarg in "-b" "" ;
do
# Create multisegment LV
-lvcreate -an -Zn -l30 -n $lv1 $vg "$dev1"
-lvcreate -an -Zn -l30 -n $lv2 $vg "$dev2"
-lvcreate -an -Zn -l30 -n $lv1 $vg1 "$dev4"
+lvcreate -an -Zn -l60 -n $lv1 $vg "$dev1"
+lvcreate -an -Zn -l60 -n $lv2 $vg "$dev2"
+lvcreate -an -Zn -l60 -n $lv1 $vg1 "$dev4"
lvextend -l+30 -n $vg1/$lv1 "$dev5"
cmd1=(pvmove -i1 $backgroundarg $mode "$dev1" "$dev3")
--
2.35.3

View File

@ -0,0 +1,25 @@
From 8257181f9e4e54505de158a98d54c8a11b127553 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 13 Sep 2023 23:40:16 +0200
Subject: [PATCH 21/24] tests: enforce full fs check
---
test/shell/lvresize-fs-crypt.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/shell/lvresize-fs-crypt.sh b/test/shell/lvresize-fs-crypt.sh
index 966870d5d..302fd5fc9 100644
--- a/test/shell/lvresize-fs-crypt.sh
+++ b/test/shell/lvresize-fs-crypt.sh
@@ -139,7 +139,7 @@ dd if=/dev/zero of="$mount_dir/zeros1" bs=1M count=10 oflag=direct
df --output=size "$mount_dir" |tee df1
# resize only the fs (to 256M), not the crypt dev or LV
umount "$mount_dir"
-fsck -n /dev/mapper/$cr
+fsck -fn /dev/mapper/$cr
resize2fs /dev/mapper/$cr 262144k
mount /dev/mapper/$cr "$mount_dir"
# this lvresize will not resize the fs (which is already reduced
--
2.35.3

View File

@ -0,0 +1,588 @@
From 9683478371c60e78920c22cb4f5ca14b39bb9fcb Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 14 Sep 2023 00:51:58 +0200
Subject: [PATCH 22/24] tests: update for work in fake dev environment
No write outside of $LVM_TEST_DIR (removed /test access).
Use 'aux prepare_scsi_debug_dev' for automated scsi_debug handling
Properly use "" around shell vars.
Smarter read of PVS values.
Relax requirement to only work with real /dev dir.
---
test/shell/devicesfile-vpd-ids.sh | 328 +++++++++++++++---------------
1 file changed, 164 insertions(+), 164 deletions(-)
diff --git a/test/shell/devicesfile-vpd-ids.sh b/test/shell/devicesfile-vpd-ids.sh
index 9a12f49f9..37fb6b79f 100644
--- a/test/shell/devicesfile-vpd-ids.sh
+++ b/test/shell/devicesfile-vpd-ids.sh
@@ -16,12 +16,10 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
-test "$DM_DEV_DIR" = "/dev" || skip "Only works with /dev access -> make check LVM_TEST_DEVDIR=/dev"
-
-aux lvmconf 'devices/use_devicesfile = 1'
+SYS_DIR="sys"
# requires trailing / to match dm
-aux lvmconf 'devices/device_id_sysfs_dir = "/test/sys/"'
-SYS_DIR="/test/sys"
+aux lvmconf "devices/device_id_sysfs_dir = \"$PWD/$SYS_DIR/\"" \
+ "devices/use_devicesfile = 1"
# These values match the values encoded in the binary blob
# written to dev1_vpd_pg83
@@ -34,7 +32,7 @@ DEV1_NAA2=naa.600a098000000002ac18542400000dbd
DEV1_NAA3=naa.553b13644430344b4e3f486d32647962
create_base() {
- mkdir -p $SYS_DIR/dev/block
+ mkdir -p "$SYS_DIR/dev/block"
echo -n "0083 009c 0201 0020 4c56 4d54 5354 2020 \
204c 554e 2038 3039 7741 4c56 4d54 5354 \
@@ -45,39 +43,36 @@ create_base() {
0000 0dbd 0114 0004 0101 0005 0115 0004 \
0000 03ec 0328 0028 6e61 612e 3535 3342 \
3133 3634 3434 3330 3334 3442 3445 3346 \
- 3438 3644 3332 3634 3739 3632 0000 0000" | xxd -r -p > $SYS_DIR/dev1_vpd_pg83
+ 3438 3644 3332 3634 3739 3632 0000 0000" | xxd -r -p > "$SYS_DIR/dev1_vpd_pg83"
}
remove_base() {
- rm $SYS_DIR/dev1_vpd_pg83
- rmdir $SYS_DIR/dev/block
- rmdir $SYS_DIR/dev
- rmdir $SYS_DIR
+ rm "$SYS_DIR/dev1_vpd_pg83"
+ rmdir "$SYS_DIR/dev/block"
+ rmdir "$SYS_DIR/dev"
+ rmdir "$SYS_DIR"
}
setup_sysfs() {
- mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
- echo $1 > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
- cp $SYS_DIR/dev1_vpd_pg83 $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83
+ mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+ echo "$1" > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+ cp "$SYS_DIR/dev1_vpd_pg83" "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83"
}
cleanup_sysfs() {
- rm -f $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
- rm -f $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83
- rmdir $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device || true
- rmdir $SYS_DIR/dev/block/$MAJOR1:$MINOR1 || true
+ rm -f "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+ rm -f "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83"
+ rmdir "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device" || true
+ rmdir "$SYS_DIR/dev/block/$MAJOR1:$MINOR1" || true
}
+aux prepare_scsi_debug_dev 16 || skip
-modprobe scsi_debug dev_size_mb=16 num_tgts=1
-sleep 2
# Get scsi device name created by scsi_debug.
# SD = sdh
# DEV1 = /dev/sdh
-SD=$(grep -H scsi_debug /sys/block/sd*/device/model | cut -f4 -d /);
-echo $SD
-DEV1=/dev/$SD
-echo $DEV1
+DEV1=$(< SCSI_DEBUG_DEV)
+echo "Using scsi_debug device: $DEV1"
DFDIR="$LVM_SYSTEM_DIR/devices"
mkdir -p "$DFDIR" || true
@@ -87,22 +82,23 @@ touch $DF
pvcreate "$DEV1"
vgcreate $vg "$DEV1"
-MAJOR1=`pvs "$DEV1" --noheading -o major | tr -d - | awk '{print $1}'`
-MINOR1=`pvs "$DEV1" --noheading -o minor | tr -d - | awk '{print $1}'`
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
+eval "$(pvs --noheading --nameprefixes -o major,minor,uuid "$DEV1")"
+MAJOR1=$LVM2_PV_MAJOR
+MINOR1=$LVM2_PV_MINOR
+PVID1=${LVM2_PV_UUID//-/}
create_base
# No sys/wwid, lvm uses wwid from sys/vpd
-setup_sysfs $DEV1_NAA
+setup_sysfs "$DEV1_NAA"
# no sys/wwid is reported
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
-rm $DF
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
pvs "$DEV1"
-grep $DEV1_NAA $DF
+grep "$DEV1_NAA" "$DF"
cleanup_sysfs
# Kernel changes the type printed from sys/wwid from t10 to naa
@@ -113,15 +109,15 @@ cleanup_sysfs
# reporting pvs should still find the dev based on using vpd data
# and find the t10 value there
-setup_sysfs $DEV1_T10
-rm $DF
+setup_sysfs "$DEV1_T10"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-grep sys_wwid $DF
-grep $DEV1_T10 $DF
+cat "$DF"
+grep sys_wwid "$DF"
+grep "$DEV1_T10" "$DF"
pvs "$DEV1"
# kernel changes what it reports from sys/wwid
-echo $DEV1_NAA > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+echo "$DEV1_NAA" > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
# lvm finds the original t10 id in vpd
pvs "$DEV1"
cleanup_sysfs
@@ -132,229 +128,231 @@ cleanup_sysfs
# df entry uses the specified type
# reporting pvs should show the pv
-setup_sysfs $DEV1_T10
-rm $DF
+setup_sysfs "$DEV1_T10"
+rm "$DF"
lvmdevices --adddev "$DEV1" --deviceidtype wwid_naa
-cat $DF
-grep wwid_naa $DF
-grep $DEV1_NAA $DF
+cat "$DF"
+grep wwid_naa "$DF"
+grep "$DEV1_NAA" "$DF"
pvs "$DEV1"
lvmdevices --deldev "$DEV1"
lvmdevices --addpvid "$PVID1" --deviceidtype wwid_naa
-cat $DF
-grep $DEV1_NAA $DF
+cat "$DF"
+grep "$DEV1_NAA" "$DF"
pvs "$DEV1"
lvmdevices --deldev "$DEV1"
lvmdevices --adddev "$DEV1" --deviceidtype wwid_eui
-cat $DF
-grep wwid_eui $DF
-grep $DEV1_EUI $DF
+cat "$DF"
+grep wwid_eui "$DF"
+grep "$DEV1_EUI" "$DF"
pvs "$DEV1"
cleanup_sysfs
-# Any of the vpd wwids can be used in the devices file
+# Any of the vpd wwids can be used in the devices file
# with type sys_wwid and the device will be matched to
# it by finding that wwid in the vpd data.
-setup_sysfs $DEV1_NAA
-rm $DF
+setup_sysfs "$DEV1_NAA"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
-setup_sysfs $DEV1_NAA2
-rm $DF
+setup_sysfs "$DEV1_NAA2"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
-setup_sysfs $DEV1_NAA3
-rm $DF
+setup_sysfs "$DEV1_NAA3"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
-setup_sysfs $DEV1_EUI
-rm $DF
+setup_sysfs "$DEV1_EUI"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
-setup_sysfs $DEV1_T10
-rm $DF
+setup_sysfs "$DEV1_T10"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
# Test nvme wwid that starts with "nvme" instead of naa/eui/t10
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
-echo "nvme.111111111111111111122222222222333333333333333-44444444444444444445555555555556666666666666666662-00000001" > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1"
+echo "nvme.111111111111111111122222222222333333333333333-44444444444444444445555555555556666666666666666662-00000001" > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
grep nvme.111 out
-grep sys_wwid $DF
-grep nvme.111 $DF
+grep sys_wwid "$DF"
+grep nvme.111 "$DF"
lvmdevices --deldev "$DEV1"
not lvmdevices --adddev "$DEV1" --deviceidtype wwid_eui
lvmdevices --adddev "$DEV1" --deviceidtype sys_wwid
lvmdevices | grep nvme.111
lvremove -y $vg
-sleep 1
+sleep .1
lvs $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid"
cleanup_sysfs
# Test t10 wwid containing quote
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
-echo "t10.ATA_2.5\"_SATA_SSD_1112-A___111111111111" > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+echo "t10.ATA_2.5\"_SATA_SSD_1112-A___111111111111" > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
# check wwid string in metadata output
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
# the quote is removed after the 5
grep 2.5_SATA_SSD out
# check wwid string in system.devices
-grep sys_wwid $DF
+grep sys_wwid "$DF"
# the quote is removed after the 5
-grep 2.5_SATA_SSD $DF
+grep 2.5_SATA_SSD "$DF"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
# Test t10 wwid with trailing space and line feed at the end
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
2048 4152 4444 4953 4b20 2020 2020 2020 \
2020 2020 2020 2020 2020 2020 2020 2020 \
2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 6320 0a" | xxd -r -p > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+3838 6439 6562 6320 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
# check wwid string in metadata output
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
# check wwid string in system.devices
-grep sys_wwid $DF
+grep sys_wwid "$DF"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
# Test t10 wwid with trailing space at the end that was created by 9.0/9.1
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
2048 4152 4444 4953 4b20 2020 2020 2020 \
2020 2020 2020 2020 2020 2020 2020 2020 \
2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 6320 0a" | xxd -r -p > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+3838 6439 6562 6320 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
T10_WWID_RHEL91="t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc_"
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
# check wwid string in metadata output
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
# check wwid string in system.devices
-grep sys_wwid $DF
+grep sys_wwid "$DF"
# Replace IDNAME with the IDNAME that 9.0/9.1 created from this wwid
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc_ DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc_ DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs
pvs -o+deviceidtype,deviceid "$DEV1"
# Removing the trailing _ which should then work
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
# test a t10 wwid that has actual trailing underscore which
# is followed by a trailing space.
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
2048 4152 4444 4953 4b20 2020 2020 2020 \
2020 2020 2020 2020 2020 2020 2020 2020 \
2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 5f20 0a" | xxd -r -p > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+3838 6439 6562 5f20 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
# The wwid has an actual underscore char (5f) followed by a space char (20)
# 9.1 converts the trailing space to an underscore
T10_WWID_RHEL91="t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9eb__"
# 9.2 ignores the trailing space
T10_WWID_RHEL92="t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9eb_"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
# check wwid string in metadata output
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
# check wwid string in system.devices
-grep sys_wwid $DF
+grep sys_wwid "$DF"
# Replace IDNAME with the IDNAME that 9.0/9.1 created from this wwid
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=${T10_WWID_RHEL91} DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=${T10_WWID_RHEL91} DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
#
@@ -363,67 +361,70 @@ cleanup_sysfs
# underscores are understood.
#
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
-echo -n " s123 456 " > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+echo -n " s123 456 " > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial"
lvmdevices --adddev "$DEV1"
-cat $DF
-grep "IDNAME=s123__456 DEVNAME" $DF
+cat "$DF"
+grep "IDNAME=s123__456 DEVNAME" "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_serial IDNAME=__s123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_serial IDNAME=__s123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial"
cleanup_sysfs
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
-echo -n " t10.123 456 " > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+echo -n " t10.123 456 " > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
-grep "IDNAME=t10.123_456 DEVNAME" $DF
+cat "$DF"
+grep "IDNAME=t10.123_456 DEVNAME" "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=__t10.123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=__t10.123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
-echo -n " naa.123 456 " > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+echo -n " naa.123 456 " > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
-grep "IDNAME=naa.123__456 DEVNAME" $DF
+cat "$DF"
+grep "IDNAME=naa.123__456 DEVNAME" "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=__naa.123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=__naa.123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
@@ -433,4 +434,3 @@ cleanup_sysfs
# This would let the user specify the second naa wwid.
remove_base
-rmmod scsi_debug || true
--
2.35.3

View File

@ -0,0 +1,27 @@
From a55bd2ddc1ca21ca6fb44df58d7287f619cb54f6 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 14 Sep 2023 01:42:29 +0200
Subject: [PATCH 23/24] tests: skip test when lvmdbusd runs on the system
lvmdbusd changes $RUNDIR results.
---
test/shell/duplicate-pvs-md0.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/test/shell/duplicate-pvs-md0.sh b/test/shell/duplicate-pvs-md0.sh
index ea800cf5a..9c1005b0b 100644
--- a/test/shell/duplicate-pvs-md0.sh
+++ b/test/shell/duplicate-pvs-md0.sh
@@ -27,6 +27,9 @@ _clear_online_files() {
. lib/inittest
+# Running lvmdbusd with its fullreport scannnig changes $RUNDIR results
+pgrep lvmdbusd && skip "Test cannot work, while there is running lvmdbusd."
+
MD_LEVEL=${MD_LEVEL-0}
aux prepare_devs 4 10
--
2.35.3

View File

@ -0,0 +1,38 @@
From dc31f8bdd8d6685c04802a023b769fe9310f1c91 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Wed, 23 Aug 2023 13:47:06 +0200
Subject: [PATCH 24/24] tests: better slowdown
---
test/shell/lvconvert-mirror.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvconvert-mirror.sh b/test/shell/lvconvert-mirror.sh
index 17ed033b2..461d14748 100644
--- a/test/shell/lvconvert-mirror.sh
+++ b/test/shell/lvconvert-mirror.sh
@@ -323,10 +323,10 @@ SHOULD=
aux throttle_dm_mirror || SHOULD=should
# Use large enough mirror that takes time to sychronize with small regionsize
-lvcreate -aey -L30 -Zn -Wn --type mirror --regionsize 16k -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev4" "$dev3:$DEVRANGE"
+lvcreate -aey -L20 -Zn -Wn --type mirror --regionsize 4k -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev4" "$dev3:$DEVRANGE"
$SHOULD not lvconvert -m-1 $vg/$lv1 "$dev1" 2>&1 | tee out
aux restore_dm_mirror
-grep "not in-sync" out
+$SHOULD grep "not in-sync" out
lvconvert $vg/$lv1 # wait
@@ -341,7 +341,7 @@ lvremove -ff $vg
aux throttle_dm_mirror || :
# No parallel lvconverts on a single LV please
# Use big enough mirror size and small regionsize to run on all test machines succesfully
-lvcreate -aey -Zn -Wn -L30 --type mirror --regionsize 16k -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0-8"
+lvcreate -aey -Zn -Wn -L20 --type mirror --regionsize 4k -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0-8"
check mirror $vg $lv1
check mirror_legs $vg $lv1 2
--
2.35.3

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e661ece15b5d88d8abe39a4c1e1db2f43e1896f019948bb98b0e15d777680786
size 2658805

View File

@ -1,16 +0,0 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEE1QGkeEQK4v0TChvouREkMeUJA58FAmKFHcYACgkQuREkMeUJ
A58CdQ//UthHUyGSHS2LiNKPhpr4vKuxstwlOclxHjvardZ1QW7ry5Ype5Elrnfb
GVot/9oZPzoYzuHaMp6E8rRTfdsmiuSU9mQ3sTDAzPcuB9QbiZUW9oTCLfACTRqK
bP8XdKVE/sJgllUFz93kQke69GntBuvrvXFzUF4yMSSRwvWMtZ4jTs2KSfCdFJUB
3r4d9ynxTdcskexYQ0fnXubl5FRokKlmi7k5G0n2BnI/eqMMMsJg8lGYiw7kmkPc
7cqE9FJzVhzEv3rLYz0+gc7/6JymAJAJcUD5jaToI3eyA6KhqauH03HZhc5JDtxL
nthpURhCETDp/St/DsXWffVCKXBKq5TIa44Hh/n1TgFKVvgshEwOCWMmsh4P1MKI
ilvwkjmpzGbVOAgFUIJnMPOpg5aQ8jatFDbzcFwUXpIXdfSS+0ghMyc4Vihh1sa0
wAM7hYSvzjYAXPb+UjRrwRunmU36SgvUpg8ZI8ZxvFgLw57IAxqlx41MbQjtPg4B
3hI/ibtiWckVwROmga1daeLe696h4lrXjRCjj85EG8FsAuZpUikuSf1ym/3uF0aP
142Dd8lvWjfjl9nXDU8cl3Ke7JFfEtQUplswaaIpwKXv37dlwyfaCrgR/laLTs4V
xLh50C5Hxr1RPQwt1qPzM6tNYS+R3O8B56iWzcF8WIBiOOG5XWc=
=HIKn
-----END PGP SIGNATURE-----

BIN
LVM2.2.03.22.tgz (Stored with Git LFS) Normal file

Binary file not shown.

16
LVM2.2.03.22.tgz.asc Normal file
View File

@ -0,0 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEE1QGkeEQK4v0TChvouREkMeUJA58FAmTKUZsACgkQuREkMeUJ
A5+Z1A//eTi65tos1se3+iivR+K1soXQLagU3WdwgOUbPu5amjipNZ6iMWCuGLOH
XleuHRGQb0ytnkRwlUeYgUkcaFqbofH9FmY5Hugp20BE+8P3bfeAX5a5ApsoU0wF
fY+XlSyuq3waFAM7XadxTgiOqWNT4Y+CnO3IUfAlkupOZi2h+00U8FlroIZdLqKR
919CpIyh9obPxvvQeE30vNQVA8jUazG7pkq9J/bVFf4ZYqJ1AieDFQ05dqAvdO4e
I8A/0Hc6n5OZBgbK1eX8EvpYuQOd5YYVFtsLoYzCl6Q1AZ5hviddifqxwnSHyPX7
iXt82ppRBIEO500QK/R+6ZAu1qF7S5ZVQMvWuSQM4hYwxJfipFaWDljpS2Gc8x8h
YIB7BSbNJMFu1Qf1iE/I8yqTt7x+Q/zL8paat5P5ZpsD//tG/CAWyfcml7ieTGDY
yoMuIY8GzAFYYzSWtubQEJx75E757cexOeZu5oiDfjSU6JxYFzoNWoF79NUVzTgU
bscvzWnibIjGpDoSD6aCjjmmNbbpnSALjUdKnUlt+KDR72u66KDssTQOpbg/W17T
Ghxe+I0kF8FObSD9T7CockCx81dqS7lrq8jLkMmAk9TKzr4OPi8mMjCMqGha+swg
Z/Sy/z/V7BAdknyRvg4ZQKxrA+9rRizt/xMlgpnRY8nvk+8VgYw=
=yBW6
-----END PGP SIGNATURE-----

View File

@ -1,7 +1,7 @@
From 0913b597d61b9b430654d7ab06528cdfcfaf06f4 Mon Sep 17 00:00:00 2001
From 5633a8ad6522f0f1340ef35c2f3943a3b20cc200 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Wed, 4 Jan 2017 14:20:53 +1100
Subject: [PATCH] Simplify special-case for md in 69-dm-lvm-metadata.rules
Subject: [PATCH] Simplify special-case for md in 69-dm-lvm.rules.in
This special casing brings little value. It appears to attempt to
determine if the array is active yet or not, and to skip
@ -28,15 +28,24 @@ So replace the special handling with code that simply jumps to lvm_scan
on any 'add' or 'change' event.
Signed-off-by: NeilBrown <neilb@suse.com>
---
udev/69-dm-lvm-metad.rules.in | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index bd75fc8efcd5..fcbb7f755eba 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -54,13 +54,11 @@ ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}=="1", GOTO="lvm_scan"
2023-09-18:
udev/69-dm-lvm-metadata.rules was removed in v2_03_09 and 69-dm-lvm.rules.in
should be modified instead. The subject of this patch should be modified too.
NOTE: the updated patch may let shell/duplicate-pvs-md0.sh fail because
we change timing of lvm_scan in the rule file.
Signed-off-by: Glass Su <glass.su@suse.com>
---
udev/69-dm-lvm.rules.in | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/udev/69-dm-lvm.rules.in b/udev/69-dm-lvm.rules.in
index 3ec50a5cb878..45fdad444562 100644
--- a/udev/69-dm-lvm.rules.in
+++ b/udev/69-dm-lvm.rules.in
@@ -35,12 +35,11 @@ ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}=="1", GOTO="lvm_scan"
GOTO="lvm_end"
# MD device:
@ -47,12 +56,11 @@ index bd75fc8efcd5..fcbb7f755eba 100644
-ACTION=="add", ENV{LVM_MD_PV_ACTIVATED}=="1", GOTO="lvm_scan"
-ACTION=="change", ENV{LVM_MD_PV_ACTIVATED}!="1", TEST=="md/array_state", ENV{LVM_MD_PV_ACTIVATED}="1", GOTO="lvm_scan"
-ACTION=="add", KERNEL=="md[0-9]*p[0-9]*", GOTO="lvm_scan"
-ENV{LVM_MD_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0"
+ACTION=="add", GOTO="lvm_scan"
+ACTION=="change", GOTO="lvm_scan"
GOTO="lvm_end"
# Loop device:
--
2.11.0
2.42.0

View File

@ -1,4 +1,4 @@
From c0d05011007bb46232e64435e05f6f6da212655b Mon Sep 17 00:00:00 2001
From 6cfd57627c7c8b1aee4cf8164d88e206660bf753 Mon Sep 17 00:00:00 2001
From: Eric Ren <zren@suse.com>
Date: Tue, 4 Jul 2017 20:11:17 +0800
Subject: [PATCH] build: skip compliling daemons/lvmlockd directory
@ -12,36 +12,36 @@ Signed-off-by: Eric Ren <zren@suse.com>
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/configure b/configure
index e1ae0e8..c442459 100755
index 0bb5b3dbc6ca..ea657178076b 100755
--- a/configure
+++ b/configure
@@ -11865,7 +11865,8 @@ test -n "$LVMPOLLD" && BUILD_LVMPOLLD=$LVMPOLLD
$as_echo "$BUILD_LVMPOLLD" >&6; }
@@ -12023,7 +12023,8 @@ fi
printf "%s\n" "$BUILD_LVMPOLLD" >&6; }
################################################################################
-BUILD_LVMLOCKD=no
+# BUILD_LVMLOCKD=no
+#BUILD_LVMLOCKD=no
+BUILD_LVMLOCKD=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build lvmlockdsanlock" >&5
$as_echo_n "checking whether to build lvmlockdsanlock... " >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build lvmlockdsanlock" >&5
printf %s "checking whether to build lvmlockdsanlock... " >&6; }
diff --git a/daemons/Makefile.in b/daemons/Makefile.in
index ebbd740..58d5fef 100644
index e548b1556478..642d839c046f 100644
--- a/daemons/Makefile.in
+++ b/daemons/Makefile.in
@@ -40,9 +40,9 @@ ifeq ("@BUILD_LVMPOLLD@", "yes")
@@ -32,9 +32,9 @@ ifeq ("@BUILD_LVMPOLLD@", "yes")
SUBDIRS += lvmpolld
endif
-ifeq ("@BUILD_LVMLOCKD@", "yes")
- SUBDIRS += lvmlockd
-endif
+# ifeq ("@BUILD_LVMLOCKD@", "yes")
+# SUBDIRS += lvmlockd
+# endif
+#ifeq ("@BUILD_LVMLOCKD@", "yes")
+# SUBDIRS += lvmlockd
+#endif
ifeq ("@BUILD_LVMDBUSD@", "yes")
SUBDIRS += lvmdbusd
--
2.10.2
2.42.0

View File

@ -1,10 +1,10 @@
Index: LVM2.2.03.10/test/Makefile.in
===================================================================
--- LVM2.2.03.10.orig/test/Makefile.in
+++ LVM2.2.03.10/test/Makefile.in
diff --git a/test/Makefile.in b/test/Makefile.in
index 20e97ebd0f4d..d4d3ce9f6dc7 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -31,6 +31,7 @@ LVM_TEST_RESULTS ?= results
SOURCES = lib/not.c lib/harness.c lib/dmsecuretest.c
CXXSOURCES = lib/runner.cpp
SOURCES := lib/not.c lib/harness.c lib/dmsecuretest.c
CXXSOURCES := lib/runner.cpp
CXXFLAGS += $(EXTRA_EXEC_CFLAGS)
+LDFLAGS += -pie

View File

@ -11,6 +11,13 @@ line. One of usecases is in rescue mode, disabling lvm2 will
allow user to enable lvm2 devices by manual.
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
2023-09-07:
The file udev/69-dm-lvm-metad.rules.in has been removed since v2_03_19.
So remove the change of above file.
Signed-off-by: Glass Su <glass.su@suse.com>
---
diff -Nupr a/scripts/lvm2-pvscan.service.in b/scripts/lvm2-pvscan.service.in
@ -24,19 +31,6 @@ diff -Nupr a/scripts/lvm2-pvscan.service.in b/scripts/lvm2-pvscan.service.in
[Service]
Type=oneshot
diff -Nupr a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
--- a/udev/69-dm-lvm-metad.rules.in 2022-09-02 14:04:42.618917180 +0800
+++ b/udev/69-dm-lvm-metad.rules.in 2022-09-02 14:03:39.707191529 +0800
@@ -12,6 +12,9 @@ SUBSYSTEM!="block", GOTO="lvm_end"
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="lvm_end"
+IMPORT{cmdline}="nolvm"
+ENV{nolvm}=="?*", GOTO="lvm_end"
+
# Detect removed PV label by comparing previous ID_FS_TYPE value with current one.
ENV{.ID_FS_TYPE_NEW}="$env{ID_FS_TYPE}"
IMPORT{db}="ID_FS_TYPE"
diff -Nupr a/udev/69-dm-lvm.rules.in b/udev/69-dm-lvm.rules.in
--- a/udev/69-dm-lvm.rules.in 2022-09-02 14:04:51.074880312 +0800
+++ b/udev/69-dm-lvm.rules.in 2022-09-02 14:07:19.978230990 +0800

View File

@ -1,159 +0,0 @@
From 39e6c4f749e97c0efae116e1fa0dbc25451de80e Mon Sep 17 00:00:00 2001
From: Lidong Zhong <lidong.zhong@suse.com>
Date: Fri, 30 Sep 2022 16:34:51 +0800
Subject: [PATCH] lvmlockd: purge the lock resources left in previous lockspace
If lvmlockd in cluster is killed accidently or any other reason, the
lock resources will become orphaned in the VG lockspace. When the
cluster manager tries to restart this daemon, the LVs will probably
become inactive because of resource schedule policy and thus the lock
resouce will be omited during the adoption process. This patch will
try to purge the lock resources left in previous lockspace, so the
following actions can work again.
---
daemons/lvmlockd/lvmlockd-core.c | 13 ++++-
daemons/lvmlockd/lvmlockd-dlm.c | 79 ++++++++++++++++++++++++++++
daemons/lvmlockd/lvmlockd-internal.h | 6 +++
3 files changed, 97 insertions(+), 1 deletion(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 6d0d4d98c..b2e98efa3 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -5954,7 +5954,18 @@ static void adopt_locks(void)
}
- /* FIXME: purge any remaining orphan locks in each rejoined ls? */
+ /* Try to purge the orphan locks when lock manager is dlm */
+ if (lm_support_dlm() && lm_is_running_dlm()) {
+ list_for_each_entry(ls, &ls_found, list) {
+ pthread_mutex_lock(&lockspaces_mutex);
+ ls1 = find_lockspace_name(ls->name);
+ if (ls1) {
+ log_debug("ls: %s purge locks", ls->name);
+ lm_purge_locks_dlm(ls1);
+ }
+ pthread_mutex_unlock(&lockspaces_mutex);
+ }
+ }
if (count_start_fail || count_adopt_fail)
goto fail;
diff --git a/daemons/lvmlockd/lvmlockd-dlm.c b/daemons/lvmlockd/lvmlockd-dlm.c
index 1305c3dc2..01bec6f43 100644
--- a/daemons/lvmlockd/lvmlockd-dlm.c
+++ b/daemons/lvmlockd/lvmlockd-dlm.c
@@ -220,6 +220,85 @@ int lm_prepare_lockspace_dlm(struct lockspace *ls)
return 0;
}
+#define DLM_COMMS_PATH "/sys/kernel/config/dlm/cluster/comms"
+#define LOCK_LINE_MAX 1024
+static int get_local_nodeid()
+{
+ struct dirent *de;
+ DIR *ls_dir;
+ char ls_comms_path[PATH_MAX];
+ FILE *file = NULL;
+ char line[LOCK_LINE_MAX];
+ int rv = -1, val;
+
+ memset(ls_comms_path, 0, sizeof(ls_comms_path));
+ snprintf(ls_comms_path, PATH_MAX, "%s",DLM_COMMS_PATH);
+
+ if (!(ls_dir = opendir(ls_comms_path)))
+ return -ECONNREFUSED;
+
+ while ((de = readdir(ls_dir))) {
+ if (de->d_name[0] == '.')
+ continue;
+ memset(ls_comms_path, 0, sizeof(ls_comms_path));
+ snprintf(ls_comms_path, PATH_MAX, "%s/%s/local",
+ DLM_COMMS_PATH, de->d_name);
+ file = fopen(ls_comms_path, "r");
+ if (!file)
+ continue;
+ if (fgets(line, LOCK_LINE_MAX, file)) {
+ fclose(file);
+ rv = sscanf(line, "%d", &val);
+ if ((rv == 1) && (val == 1 )) {
+ memset(ls_comms_path, 0, sizeof(ls_comms_path));
+ snprintf(ls_comms_path, PATH_MAX, "%s/%s/nodeid",
+ DLM_COMMS_PATH, de->d_name);
+ file = fopen(ls_comms_path, "r");
+ if (!file)
+ continue;
+ if (fgets(line, LOCK_LINE_MAX, file)) {
+ rv = sscanf(line, "%d", &val);
+ if (rv == 1) {
+ fclose(file);
+ return val;
+ }
+ }
+ }
+ }
+ fclose(file);
+ }
+
+ if (closedir(ls_dir))
+ log_error("get_local_nodeid closedir error");
+ return rv;
+}
+
+int lm_purge_locks_dlm(struct lockspace *ls)
+{
+ struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data;
+ int nodeid;
+ int rv = -1;
+
+ if (!lmd || !lmd->dh) {
+ log_error("purge_locks_dlm %s no dlm_handle_t error", ls->name);
+ goto fail;
+ }
+
+ nodeid = get_local_nodeid();
+ if (nodeid < 0) {
+ log_error("failed to get local nodeid");
+ goto fail;
+ }
+ if (dlm_ls_purge(lmd->dh, nodeid, 0)) {
+ log_error("purge_locks_dlm %s error", ls->name);
+ goto fail;
+ }
+
+ rv = 0;
+fail:
+ return rv;
+}
+
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt)
{
struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data;
diff --git a/daemons/lvmlockd/lvmlockd-internal.h b/daemons/lvmlockd/lvmlockd-internal.h
index ad32eb3a4..dd59b6a5d 100644
--- a/daemons/lvmlockd/lvmlockd-internal.h
+++ b/daemons/lvmlockd/lvmlockd-internal.h
@@ -392,6 +392,7 @@ static inline const char *mode_str(int x)
int lm_init_vg_dlm(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
int lm_prepare_lockspace_dlm(struct lockspace *ls);
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt);
+int lm_purge_locks_dlm(struct lockspace *ls);
int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg);
int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
struct val_blk *vb_out, int adopt);
@@ -429,6 +430,11 @@ static inline int lm_add_lockspace_dlm(struct lockspace *ls, int adopt)
return -1;
}
+static inline int lm_purge_locks_dlm(struct lockspace *ls)
+{
+ return -1;
+}
+
static inline int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg)
{
return -1;
--
2.38.0

View File

@ -1,53 +0,0 @@
From 99ce09ae778c2cc4aa2611e425bba5287b8b9513 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 25 Jul 2022 13:50:43 -0500
Subject: [PATCH] apply multipath_component_detection=0 to duplicate PV
handling
multipath_component_detection=0 has always applied to the filter-based
component detection. Also apply this setting to the duplicate-PV
handling which also eliminates multipath components (based on duplicate
PVs having the same wwid.)
---
lib/cache/lvmcache.c | 3 +++
test/shell/duplicate-pvs-multipath.sh | 10 +++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index a1c4a61c82fa..00916885c509 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -652,6 +652,9 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
*dev_mpath = NULL;
+ if (!find_config_tree_bool(cmd, devices_multipath_component_detection_CFG, NULL))
+ return 0;
+
/* This function only makes sense with more than one dev. */
if ((info && dm_list_empty(altdevs)) || (!info && (dm_list_size(altdevs) == 1))) {
log_debug("Skip multipath component checks with single device for PVID %s", pvid);
diff --git a/test/shell/duplicate-pvs-multipath.sh b/test/shell/duplicate-pvs-multipath.sh
index 59c15b0d4f9b..bc98d2d5aa8c 100644
--- a/test/shell/duplicate-pvs-multipath.sh
+++ b/test/shell/duplicate-pvs-multipath.sh
@@ -24,9 +24,13 @@ modprobe --dry-run scsi_debug || skip
multipath -l || skip
multipath -l | grep scsi_debug && skip
-# Turn off multipath_component_detection so that the duplicate
-# resolution of mpath components is used.
-aux lvmconf 'devices/multipath_component_detection = 0'
+# FIXME: setting multipath_component_detection=0 now also disables
+# the wwid-based mpath component detection, so this test will need
+# to find another way to disable only the filter-mpath code (using
+# sysfs and multipath/wwids) while keeping the code enabled that
+# eliminates duplicates based on their matching wwids which this
+# tries to test.
+
# Prevent wwids from being used for filtering.
aux lvmconf 'devices/multipath_wwids_file = "/dev/null"'
# Need to use /dev/mapper/mpath
--
2.35.3

View File

@ -1,27 +1,29 @@
From 17b99e3950eb4457ab2d063fe3c4c93aeb13894a Mon Sep 17 00:00:00 2001
From 24ec9af4513890b2ab1a6f3683e8aba007a3c983 Mon Sep 17 00:00:00 2001
From: Heming Zhao <heming.zhao@suse.com>
Date: Wed, 30 Jun 2021 18:41:42 +0800
Subject: [PATCH 3/3] tests: new test suite of fsadm for btrfs
To: lvm-devel@redhat.com,
zkabelac@redhat.com,
teigland@redhat.com
Subject: [PATCH] tests: new test suite of fsadm for btrfs
refer legacy patche:
- Ondrej Kozina <okozina@redhat.com>
https://listman.redhat.com/archives/lvm-devel/2012-November/msg00055.html
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
2023-09-08:
LVs should be resized to 64M after each test.
Signed-off-by: Su Yue <glass.su@suse.com>
---
test/shell/fsadm-btrfs.sh | 165 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 165 insertions(+)
test/shell/fsadm-btrfs.sh | 176 ++++++++++++++++++++++++++++++++++++++
1 file changed, 176 insertions(+)
create mode 100644 test/shell/fsadm-btrfs.sh
diff --git a/test/shell/fsadm-btrfs.sh b/test/shell/fsadm-btrfs.sh
new file mode 100644
index 000000000000..cd83a95ace41
index 000000000000..c1b65036efb2
--- /dev/null
+++ b/test/shell/fsadm-btrfs.sh
@@ -0,0 +1,165 @@
@@ -0,0 +1,176 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
@ -67,6 +69,14 @@ index 000000000000..cd83a95ace41
+ aux teardown
+}
+
+reset_lvs()
+{
+ # Since we call mkfs.btrfs with '-f', lvreduce to 64M is enough
+ lvreduce -L64M -nf $vg_lv || true
+ lvreduce -L64M -nf $vg_lv2 || true
+ lvreduce -L64M -nf $vg_lv3 || true
+}
+
+check_missing_btrfs()
+{
+ eval local t=$check_btrfs
@ -183,10 +193,13 @@ index 000000000000..cd83a95ace41
+if check_missing_btrfs; then
+
+ single_device_test
+ # after each test, reset_lv_size should be called to make sure
+ # all lvs are in same state/size.
+ reset_lvs
+ multiple_devices_test
+fi
+
+vgremove -ff $vg
--
1.8.3.1
2.35.3

View File

@ -1,3 +1,139 @@
-------------------------------------------------------------------
Mon Sep 18 02:06:09 UTC 2023 - Glass Su <glass.su@suse.com>
- Update lvm2 from LVM2.2.03.16 to LVM2.2.03.22 (jsc#PED-6339)
*** WHATS_NEW from 2.03.17 to 2.03.22 ***
version 2.03.22 - 02nd August 2023
==================================
Fix pv_major/pv_minor report field types so they are integers, not strings.
Add lvmdevices --delnotfound to delete entries for missing devices.
Always use cachepool name for metadata backup LV for lvconvert --repair.
Make metadata backup LVs read-only after pool's lvconvert --repair.
Improve VDO and Thin support with lvmlockd.
Handle 'lvextend --usepolicies' for pools for all activation variants.
Fix memleak in vgchange autoactivation setup.
Update py-compile building script.
Support conversion from thick to fully provisioned thin LV.
Cache/Thin-pool can use error and zero volumes for testing.
Individual thin volume can be cached, but cannot take snapshot.
Better internal support for handling error and zero target (for testing).
Resize COW above trimmed maximal size is does not return error.
Support parsing of vdo geometry format version 4.
Add lvm.conf thin_restore and cache_restore settings.
Handle multiple mounts while resizing volume with a FS.
Handle leading/trailing spaces in sys_wwid and sys_serial used by deivce_id.
Enhance lvm_import_vdo and use snapshot when converting VDO volume.
Fix parsing of VDO metadata.
Fix failing -S|--select for non-reporting cmds if using LV info/status fields.
Allow snapshots of raid+integrity LV.
Fix multisegment RAID1 allocator to prevent using single disk for more legs.
version 2.03.21 - 21st April 2023
=================================
Fix activation of vdo-pool for with 0 length headers (converted pools).
Avoid printing internal init messages when creation integration devices.
Allow (write)cache over raid+integrity LV.
version 2.03.20 - 21st March 2023
=================================
Fix segfault if using -S|--select with log/report_command_log=1 setting.
Configure now fails when requested lvmlockd dependencies are missing.
Add some configure Gentoo enhancements for static builds.
version 2.03.19 - 21st February 2023
====================================
Configure supports --with-systemd-run executed from udev rules.
Enhancement for build with MuslC systemd and non-bash system shells (dash).
Do not reset SYSTEMD_READY variable in udev for PVs on MD and loop devices.
Ensure udev is processing origin LV before its thick snapshots LVs.
Fix and improve runtime memory size detection for VDO volumes.
version 2.03.18 - 22nd December 2022
====================================
Fix issues reported by coverity scan.
Fix warning for thin pool overprovisioning on lvextend (2.03.17).
Add support for writecache metadata_only and pause_writeback settings.
Fix missing error messages in lvmdbusd.
Version 2.03.17 - 10th November 2022
====================================
Add new options (--fs, --fsmode) for FS handling when resizing LVs.
Fix 'lvremove -S|--select LV' to not also remove its historical LV right away.
Fix lv_active field type to binary so --select and --binary applies properly.
Switch to use mallinfo2 and use it only with glibc.
Error out in lvm shell if using a cmd argument not supported in the shell.
Fix lvm shell's lastlog command to report previous pre-command failures.
Extend VDO and VDOPOOL without flushing and locking fs.
Add --valuesonly option to lvmconfig to print only values without keys.
Updates configure with recent autoconf tooling.
Fix lvconvert --test --type vdo-pool execution.
Add json_std output format for more JSON standard compliant version of output.
Fix vdo_slab_size_mb value for converted VDO volume.
Fix many corner cases in device_id, including handling of S/N duplicates.
Fix various issues in lvmdbusd.
- Drop patches that have been merged into upstream
- 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
- bug-1203216_lvmlockd-purge-the-lock-resources-left-in-previous-l.patch
- bug-1212613_apply-multipath_component_detection-0-to-duplicate-P.patch
- Add upstream patch
+ 0001-lvconvert-swapmetadata-fix-lvmlockd-locking.patch
+ 0002-lvconvert-fix-ret-values-fro-integrity-remove.patch
+ 0003-lvconvert-fix-regresion-from-integrity-check.patch
+ 0004-gcc-cleanup-warnings.patch
+ 0005-lvmlockd-fix-thick-to-thin-lv-conversion.patch
+ 0006-lvmlockd-let-lockd_init_lv_args-set-lock_args.patch
+ 0007-lvmlockd-fix-lvconvert-to-thin-pool.patch
+ 0008-lvconvert-run-error-path-code-only-for-shared-VG.patch
+ 0009-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch
+ 0010-lvmlockd-client-mutex-ordering.patch
+ 0011-filesystem-move-stat-after-open-check.patch
+ 0012-tests-check-for-writecache.patch
+ 0013-lvresize-fix-32-bit-overflow-in-size-calculation.patch
+ 0014-gcc-fix-warnings-for-x32-architecture.patch
+ 0015-gcc-warning-missing-braces-around-initializer.patch
+ 0016-test-improve-aux-teardown.patch
+ 0017-tests-aux-try-with-extra-sleep.patch
+ 0018-tests-aux-using-singl-lvmconf-call.patch
+ 0019-tests-missing-to-check-for-writecache-support.patch
+ 0020-tests-pvmove-large-disk-area.patch
+ 0021-tests-enforce-full-fs-check.patch
+ 0022-tests-update-for-work-in-fake-dev-environment.patch
+ 0023-tests-skip-test-when-lvmdbusd-runs-on-the-system.patch
+ 0024-tests-better-slowdown.patch
- Update patch
- bug-1037309_Makefile-skip-compliling-daemons-lvmlockd-directory.patch
- bug-1184124-link-tests-as-PIE.patch
- bug-1184687_Add-nolvm-for-kernel-cmdline.patch
- fate-31841-03_tests-new-test-suite-of-fsadm-for-btrfs.patch
- Rename & Update patch
- bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-metadata.patch
+ bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-rules.patch
- update lvm2.spec
- change upstream_device_mapper_version to 1.02.196
- change device_mapper_version to %{lvm2_version}_1.02.196
- add config item "-with-libexecdir=%{_libexecdir}" to fix libexec path since commit a2d33cdf
- add new binary "%{_libexecdir}/lvresize_fs_helper" to lvm2 package
-------------------------------------------------------------------
Sun Aug 20 03:48:00 UTC 2023 - heming.zhao@suse.com

View File

@ -21,11 +21,11 @@
%define libname_event libdevmapper-event1_03
%define _udevdir %(pkg-config --variable=udevdir udev)
%define cmdlib liblvm2cmd2_03
%define lvm2_version 2.03.16
%define lvm2_version 2.03.22
# For device_mapper_version, it's package version, see bsc#1199074.
# Also note there is another dm version on below "sed -ie ... VERSION_DM".
%define upstream_device_mapper_version 1.02.185
%define device_mapper_version %{lvm2_version}_1.02.185
%define upstream_device_mapper_version 1.02.196
%define device_mapper_version %{lvm2_version}_1.02.196
%define thin_provisioning_version 0.7.0
%define _supportsanlock 1
%define dlm_version 4.0.9
@ -71,22 +71,30 @@ Source42: ftp://sourceware.org/pub/lvm2/LVM2.%{version}.tgz.asc
Source99: baselibs.conf
# Upstream patches
Patch0001: 0001-devices-file-move-clean-up-after-command-is-run.patch
Patch0002: 0002-devices-file-fail-if-devicesfile-filename-doesn-t-ex.patch
Patch0003: 0003-filter-mpath-handle-other-wwid-types-in-blacklist.patch
Patch0004: 0004-filter-mpath-get-wwids-from-sysfs-vpd_pg83.patch
Patch0005: 0005-pvdisplay-restore-reportformat-option.patch
Patch0006: 0006-exit-with-error-when-devicesfile-name-doesn-t-exist.patch
Patch0007: 0007-report-fix-pe_start-column-type-from-NUM-to-SIZ.patch
Patch0008: 0008-_vg_read_raw_area-fix-segfault-caused-by-using-null-.patch
Patch0009: 0009-mm-remove-libaio-from-being-skipped.patch
Patch0010: 0010-dmsetup-check-also-for-ouf-of-range-value.patch
Patch0011: 0011-devices-drop-double-from-sysfs-path.patch
Patch0012: 0012-devices-file-fix-pvcreate-uuid-matching-pvid-entry-w.patch
Patch0013: 0013-vgimportdevices-change-result-when-devices-are-not-a.patch
Patch0014: 0014-vgimportdevices-fix-locking-when-creating-devices-fi.patch
Patch0015: bug-1203216_lvmlockd-purge-the-lock-resources-left-in-previous-l.patch
Patch0016: bug-1212613_apply-multipath_component_detection-0-to-duplicate-P.patch
Patch0001: 0001-lvconvert-swapmetadata-fix-lvmlockd-locking.patch
Patch0002: 0002-lvconvert-fix-ret-values-fro-integrity-remove.patch
Patch0003: 0003-lvconvert-fix-regresion-from-integrity-check.patch
Patch0004: 0004-gcc-cleanup-warnings.patch
Patch0005: 0005-lvmlockd-fix-thick-to-thin-lv-conversion.patch
Patch0006: 0006-lvmlockd-let-lockd_init_lv_args-set-lock_args.patch
Patch0007: 0007-lvmlockd-fix-lvconvert-to-thin-pool.patch
Patch0008: 0008-lvconvert-run-error-path-code-only-for-shared-VG.patch
Patch0009: 0009-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch
Patch0010: 0010-lvmlockd-client-mutex-ordering.patch
Patch0011: 0011-filesystem-move-stat-after-open-check.patch
Patch0012: 0012-tests-check-for-writecache.patch
Patch0013: 0013-lvresize-fix-32-bit-overflow-in-size-calculation.patch
Patch0014: 0014-gcc-fix-warnings-for-x32-architecture.patch
Patch0015: 0015-gcc-warning-missing-braces-around-initializer.patch
Patch0016: 0016-test-improve-aux-teardown.patch
Patch0017: 0017-tests-aux-try-with-extra-sleep.patch
Patch0018: 0018-tests-aux-using-singl-lvmconf-call.patch
Patch0019: 0019-tests-missing-to-check-for-writecache-support.patch
Patch0020: 0020-tests-pvmove-large-disk-area.patch
Patch0021: 0021-tests-enforce-full-fs-check.patch
Patch0022: 0022-tests-update-for-work-in-fake-dev-environment.patch
Patch0023: 0023-tests-skip-test-when-lvmdbusd-runs-on-the-system.patch
Patch0024: 0024-tests-better-slowdown.patch
# SUSE patches: 1000+ for LVM
# Never upstream
Patch1001: cmirrord_remove_date_time_from_compilation.patch
@ -99,7 +107,7 @@ Patch1007: fate-31841-02_man-add-support-for-btrfs.patch
Patch1008: fate-31841-03_tests-new-test-suite-of-fsadm-for-btrfs.patch
Patch1009: bug-1214071-blkdeactivate_calls_wrong_mountpoint.patch
# SUSE patches 2000+ for device mapper, udev rules
Patch2001: bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-metadata.patch
Patch2001: bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-rules.patch
# SUSE patches 3000+ for test code
Patch3001: bug-1184124-link-tests-as-PIE.patch
# SUSE patches 4000+ for lvm2.spec
@ -162,6 +170,14 @@ Volume Manager.
%patch0014 -p1
%patch0015 -p1
%patch0016 -p1
%patch0017 -p1
%patch0018 -p1
%patch0019 -p1
%patch0020 -p1
%patch0021 -p1
%patch0022 -p1
%patch0023 -p1
%patch0024 -p1
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
@ -227,6 +243,7 @@ sed -ie "s/%{upstream_device_mapper_version}/1.03.01/g" VERSION_DM
--enable-pkgconfig \
--with-usrlibdir=%{_libdir} \
--with-usrsbindir=%{_sbindir} \
--with-libexecdir=%{_libexecdir} \
--with-default-dm-run-dir=/run \
--with-tmpfilesdir=%{_tmpfilesdir} \
--with-thin=internal \
@ -555,6 +572,7 @@ LVM commands use lvmlockd to coordinate access to shared storage.
# Main binaries
%{_sbindir}/blkdeactivate
%{_sbindir}/fsadm
%{_libexecdir}/lvresize_fs_helper
%{_sbindir}/lvm
%{_sbindir}/lvmconfig
%{_sbindir}/lvmdevices