main - reporter: restore report type to initial value after processing report_for_selection
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e2ecc6c763557462a4b...
Commit: e2ecc6c763557462a4bc3d88bbc883917eb0f010
Parent: 0591131a539fb668412fc38807686d2a89decd27
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue May 30 21:14:37 2023 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed May 31 09:38:11 2023 +0200
reporter: restore report type to initial value after processing report_for_selection
If we are executing 'report_for_selection' to do an internal report
just for the selection itself (not for display), we can call it more
than once. In that case, we are reusing the same selection handle
(e.g. inside 'process_each_lv_in_vg').
The selection handle has 'report_type' field which is a union of all
report types needed for the report based on selection fields we actually
use.
The 'report_type' is further clarified based on checks and rules inside
'_get_final_report_type' which 'report_for_selection' calls. Then, this
final report type unambiguously identifies proper branch to take in
'report_all_in_{pv,vg,lv}' that is called next.
If the 'report_for_selection' is called more than once with the same
selection handle, we need to make sure that we always restore the report
type to its initial value, so all the rules inside 'report_for_selection'
are applied correctly next time.
This patch fixes the missing restoration of the 'report_type' value in
'selection_handle' that is reused for recurring 'report_for_selection'
calls.
An example scenario where this failed was with selecting an LV for
removal with "lvremove --select" while using a field in the selection
that required extra DM info or DM status call for the LV (that is,
"Logical Volume Device Info Fields" and "Logical Volume Device Status Fields"
as visible in 'lvs -S help').
---
WHATS_NEW | 1 +
tools/reporter.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ad870317d..493567c5d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
version 2.03.22 -
=================================
+ Fix failing -S|--select for non-reporting cmds if using LV info/status fields.
version 2.03.21 - 21st April 2023
=================================
diff --git a/tools/reporter.c b/tools/reporter.c
index e62858f42..45273c0a4 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -633,6 +633,7 @@ int report_for_selection(struct cmd_context *cmd,
struct logical_volume *lv)
{
struct selection_handle *sh = parent_handle->selection_handle;
+ report_type_t initial_report_type = sh->report_type;
struct report_args args = {0};
struct single_report_args *single_args = &args.single_args[REPORT_IDX_SINGLE];
int do_lv_info, do_lv_seg_status;
@@ -648,8 +649,10 @@ int report_for_selection(struct cmd_context *cmd,
&sh->report_type))
return_0;
- if (!(handle = init_processing_handle(cmd, parent_handle)))
+ if (!(handle = init_processing_handle(cmd, parent_handle))) {
+ sh->report_type = initial_report_type;
return_0;
+ }
/*
* We're already reporting for select so override
@@ -695,6 +698,8 @@ int report_for_selection(struct cmd_context *cmd,
break;
}
+ sh->report_type = initial_report_type;
+
/*
* Keep the selection handle provided from the caller -
* do not destroy it - the caller will still use it to
3 months, 4 weeks
main - reporter: restore report type to initial value after processing report_for_selection
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=031f7a4639eb808e2a8...
Commit: 031f7a4639eb808e2a86e57a215dd9def7519ac4
Parent: 0591131a539fb668412fc38807686d2a89decd27
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue May 30 21:14:37 2023 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed May 31 09:28:11 2023 +0200
reporter: restore report type to initial value after processing report_for_selection
If we are executing 'report_for_selection' to do an internal report
just for the selection itself (not for display), we call
'report_for_selection'. We can call this more than once, in which case
we are reusing the same selection handle (e.g. inside 'process_each_lv_in_vg').
The selection handle has 'report_type' field which is a union of all
report types needed for the report based on selection fields we actually
use.
The 'report_type' is further clarified based on checks and rules inside
'_get_final_report_type' which 'report_for_selection' calls. Then, this
final report type unambiguously identifies proper branch to take in
'report_all_in_{pv,vg,lv}' that is called next.
If the 'report_for_selection' is called more than once with the same
selection handle, we need to make sure that we always restore the report
type to its initial value, so all the rules inside 'report_for_selection'
are applied correctly next time.
This patch fixes the missing restoration of the 'report_type' value in
'selection_handle' that is reused for recurring 'report_for_selection'
calls.
An example scenario where this failed was with selecting an LV for
removal with "lvremove --select" while using a field in the selection
that required extra DM info or DM status call for the LV (that is,
"Logical Volume Device Info Fields" and "Logical Volume Device Status Fields"
as visible in 'lvs -S help').
---
WHATS_NEW | 1 +
tools/reporter.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ad870317d..493567c5d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
version 2.03.22 -
=================================
+ Fix failing -S|--select for non-reporting cmds if using LV info/status fields.
version 2.03.21 - 21st April 2023
=================================
diff --git a/tools/reporter.c b/tools/reporter.c
index e62858f42..45273c0a4 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -633,6 +633,7 @@ int report_for_selection(struct cmd_context *cmd,
struct logical_volume *lv)
{
struct selection_handle *sh = parent_handle->selection_handle;
+ report_type_t initial_report_type = sh->report_type;
struct report_args args = {0};
struct single_report_args *single_args = &args.single_args[REPORT_IDX_SINGLE];
int do_lv_info, do_lv_seg_status;
@@ -648,8 +649,10 @@ int report_for_selection(struct cmd_context *cmd,
&sh->report_type))
return_0;
- if (!(handle = init_processing_handle(cmd, parent_handle)))
+ if (!(handle = init_processing_handle(cmd, parent_handle))) {
+ sh->report_type = initial_report_type;
return_0;
+ }
/*
* We're already reporting for select so override
@@ -695,6 +698,8 @@ int report_for_selection(struct cmd_context *cmd,
break;
}
+ sh->report_type = initial_report_type;
+
/*
* Keep the selection handle provided from the caller -
* do not destroy it - the caller will still use it to
3 months, 4 weeks
main - lvreduce: simplify _lvseg_get_stripes integrity check
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0591131a539fb668412...
Commit: 0591131a539fb668412fc38807686d2a89decd27
Parent: 4cdb178968b44125c41dee6dd28997283c0afefa
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 25 12:09:41 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu May 25 12:09:41 2023 -0500
lvreduce: simplify _lvseg_get_stripes integrity check
Simplify unnecessary loop to avoid coverity complaint.
---
lib/metadata/lv_manip.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index fa3661739..a4593c969 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5187,7 +5187,7 @@ int lv_extend_policy_calculate_percent(struct logical_volume *lv,
static uint32_t _lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
{
- uint32_t s, a;
+ uint32_t s;
struct lv_segment *seg_get, *seg_image, *seg_iorig;
struct logical_volume *lv_image, *lv_iorig;
@@ -5203,12 +5203,9 @@ static uint32_t _lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
if (seg_is_integrity(seg_image)) {
/* Get stripe values from the iorig layer. */
- for (a = 0; a < seg_image->area_count; a++) {
- lv_iorig = seg_lv(seg_image, a);
- seg_iorig = first_seg(lv_iorig);
- seg_get = seg_iorig;
- break;
- }
+ lv_iorig = seg_lv(seg_image, 0);
+ seg_iorig = first_seg(lv_iorig);
+ seg_get = seg_iorig;
} else {
/* Get stripe values from the image layer. */
seg_get = seg_image;
4 months
main - device_id: ignore trailing underscores in t10 wwid from devices file
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4cdb178968b44125c41...
Commit: 4cdb178968b44125c41dee6dd28997283c0afefa
Parent: 24e4b6df1182d0d41763176c175e98e5fa6153ab
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri May 19 12:52:48 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri May 19 14:05:10 2023 -0500
device_id: ignore trailing underscores in t10 wwid from devices file
In previous lvm versions, trailing spaces at the end of a t10 wwid would
be replaced with underscores, so the IDNAME string in system.devices
would look something like "t10.123_". Current versions of lvm ignore
trailing spaces in a t10 wwid, so the IDNAME string used would be
"t10.123". The different values would cause lvm to not recognize a
device in system.devices with the trailing _. Fix this by ignoring
trailing underscores in the IDNAME string from system.devices.
---
lib/device/device_id.c | 46 +++++++++++++---
test/shell/devicesfile-vpd-ids.sh | 113 ++++++++++++++++++++++++++++++++++++++
2 files changed, 152 insertions(+), 7 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 38677d1fe..3e05a40a8 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -1728,7 +1728,8 @@ static int _match_dm_devnames(struct cmd_context *cmd, struct device *dev,
return 0;
}
-static void _reduce_underscores(char *in, int in_len, char *out, int out_size)
+/* More than one _ in a row is replaced with one _ */
+static void _reduce_repeating_underscores(char *in, int in_len, char *out, int out_size)
{
int us = 0, i, j = 0;
@@ -1750,6 +1751,17 @@ static void _reduce_underscores(char *in, int in_len, char *out, int out_size)
}
}
+/* Remove any _ at the end of the string. */
+static void _remove_trailing_underscores(char *buf)
+{
+ char *end;
+
+ end = buf + strlen(buf) - 1;
+ while ((end > buf) && (*end == '_'))
+ end--;
+ end[1] = '\0';
+}
+
/*
* du is a devices file entry. dev is any device on the system.
* check if du is for dev by comparing the device's ids to du->idname.
@@ -1764,6 +1776,7 @@ static void _reduce_underscores(char *in, int in_len, char *out, int out_size)
static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct device *dev)
{
char du_t10[DEV_WWID_SIZE] = { 0 };
+ char id_t10[DEV_WWID_SIZE];
struct dev_id *id;
const char *idname;
int part;
@@ -1818,10 +1831,17 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
* for IDNAME were saved in the past with each space replaced
* by one _. Now we convert multiple spaces to a single _.
* So, convert a df entry with the old style to the new shorter
- * style to compare.
+ * style to compare. Also, in past versions, trailing spaces
+ * in the wwid would be replaced by _, but now trailing spaces
+ * are ignored. This means devices file entries created by
+ * past versions may have _ at the end of the IDNAME string.
+ * So, exclude trailing underscores when comparing a t10 wwid
+ * from a device with a t10 wwid in the devices file.
*/
- if (du->idtype == DEV_ID_TYPE_SYS_WWID && !strncmp(du->idname, "t10", 3) && strstr(du->idname, "__"))
- _reduce_underscores(du->idname, strlen(du->idname), du_t10, sizeof(du_t10) - 1);
+ if (du->idtype == DEV_ID_TYPE_SYS_WWID && !strncmp(du->idname, "t10", 3) && strchr(du->idname, '_')) {
+ _reduce_repeating_underscores(du->idname, strlen(du->idname), du_t10, sizeof(du_t10) - 1);
+ _remove_trailing_underscores(du_t10);
+ }
/*
* Try to match du with ids that have already been read for the dev
@@ -1829,6 +1849,20 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
*/
dm_list_iterate_items(id, &dev->ids) {
if (id->idtype == du->idtype) {
+
+ /*
+ * For t10 wwids, remove actual trailing underscores from the dev wwid
+ * (in id->idname), because all trailing underscores were removed from
+ * the du->idname read from the devices file. i.e. no trailing _ are
+ * used in t10 wwid comparisons.
+ */
+ if ((id->idtype == DEV_ID_TYPE_SYS_WWID) &&
+ id->idname && !strncmp(id->idname, "t10", 3) && du_t10[0]) {
+ memset(id_t10, 0, sizeof(id_t10));
+ strncpy(id_t10, id->idname, DEV_WWID_SIZE-1);
+ _remove_trailing_underscores(id_t10);
+ }
+
if ((id->idtype == DEV_ID_TYPE_DEVNAME) && _match_dm_devnames(cmd, dev, id, du)) {
/* dm devs can have differing names that we know still match */
du->dev = dev;
@@ -1846,9 +1880,7 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
idtype_to_str(du->idtype), du->idname, dev_name(dev));
return 1;
- } else if ((id->idtype == DEV_ID_TYPE_SYS_WWID) && id->idname &&
- !strncmp(id->idname, "t10", 3) && du_t10[0] && !strcmp(id->idname, du_t10)) {
- /* Compare the shorter form du t10 wwid to the dev t10 wwid. */
+ } else if ((id->idtype == DEV_ID_TYPE_SYS_WWID) && du_t10[0] && id_t10[0] && !strcmp(id_t10, du_t10)) {
du->dev = dev;
dev->id = id;
dev->flags |= DEV_MATCHED_USE_ID;
diff --git a/test/shell/devicesfile-vpd-ids.sh b/test/shell/devicesfile-vpd-ids.sh
index b2042fb9a..52805737b 100644
--- a/test/shell/devicesfile-vpd-ids.sh
+++ b/test/shell/devicesfile-vpd-ids.sh
@@ -80,6 +80,7 @@ echo $DEV1
DFDIR="$LVM_SYSTEM_DIR/devices"
mkdir -p "$DFDIR" || true
DF="$DFDIR/system.devices"
+DFTMP="$DFDIR/system.devices_tmp"
touch $DF
pvcreate "$DEV1"
@@ -243,6 +244,118 @@ vgremove $vg
rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
cleanup_sysfs
+# Test t10 wwid with trailing space and line feed at the end
+rm $DF
+aux wipefs_a "$DEV1"
+mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
+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/wwid
+cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+lvmdevices --adddev "$DEV1"
+cat $DF
+vgcreate $vg "$DEV1"
+lvcreate -l1 -an $vg
+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
+lvremove -y $vg
+vgremove $vg
+rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+cleanup_sysfs
+
+# Test t10 wwid with trailing space at the end that was created by 9.0/9.1
+rm $DF
+aux wipefs_a "$DEV1"
+mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
+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/wwid
+cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+lvmdevices --adddev "$DEV1"
+cat $DF
+vgcreate $vg "$DEV1"
+PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
+T10_WWID_RHEL91="t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc_"
+lvcreate -l1 -an $vg
+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
+# 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
+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
+vgs
+pvs
+pvs -o+deviceidtype,deviceid "$DEV1"
+lvremove -y $vg
+vgremove $vg
+rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+cleanup_sysfs
+
+# test a t10 wwid that has actual trailing underscore which
+# is followed by a trailing space.
+rm $DF
+aux wipefs_a "$DEV1"
+mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
+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/wwid
+cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/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
+vgcreate $vg "$DEV1"
+PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
+lvcreate -l1 -an $vg
+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
+# 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
+vgs
+pvs
+pvs -o+deviceidtype,deviceid "$DEV1"
+lvremove -y $vg
+vgremove $vg
+rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+cleanup_sysfs
+
+
# TODO: lvmdevices --adddev <dev> --deviceidtype <type> --deviceid <val>
# This would let the user specify the second naa wwid.
4 months, 1 week
main - tests: integrity-caching: ensure raid redundancy
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=24e4b6df1182d0d4176...
Commit: 24e4b6df1182d0d41763176c175e98e5fa6153ab
Parent: 3a757047560d75a28d7e4c7d9a5253a72d786544
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 17 14:15:25 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 17 14:15:25 2023 -0500
tests: integrity-caching: ensure raid redundancy
The recent fix 05c2b10c5d0a9 ensures that raid LV images are not
using the same devices. This was happening in the lvextend commands
used by this test, so fix the test to use more devices to ensue
redundancy.
---
lib/metadata/lv_manip.c | 5 ++++-
test/shell/integrity-caching.sh | 23 ++++++++++++++++-------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 9a9e547be..fa3661739 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4471,8 +4471,11 @@ static int _lv_raid_redundant(struct logical_volume *lv,
for (s = 0; s < seg->area_count; s++) {
struct logical_volume *slv = meta ? seg_metalv(seg, s) : seg_lv(seg, s);
- if (slv && lv_is_on_pv(slv, pvl->pv) && nlvs++)
+ if (slv && lv_is_on_pv(slv, pvl->pv) && nlvs++) {
+ log_error("LV %s using PV %s is not redundant.",
+ display_lvname(slv), dev_name(pvl->pv->dev));
return 0;
+ }
}
}
diff --git a/test/shell/integrity-caching.sh b/test/shell/integrity-caching.sh
index 838bbded0..72fb4af4a 100644
--- a/test/shell/integrity-caching.sh
+++ b/test/shell/integrity-caching.sh
@@ -23,7 +23,7 @@ aux kernel_at_least 5 10 || export LVM_TEST_PREFER_BRD=0
mnt="mnt"
mkdir -p $mnt
-aux prepare_devs 6 80
+aux prepare_devs 9 80
# Use awk instead of anoyingly long log out from printf
#printf "%0.sA" {1..16384} >> fileA
@@ -276,7 +276,7 @@ vgremove -ff $vg
# Test lvextend while inactive
_prepare_vg
-lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg
+lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg "$dev1" "$dev2"
aux wait_recalc $vg/${lv1}_rimage_0
aux wait_recalc $vg/${lv1}_rimage_1
aux wait_recalc $vg/$lv1
@@ -286,7 +286,11 @@ lvs -a -o name,size,segtype,devices,sync_percent $vg
_add_new_data_to_mnt
umount $mnt
lvchange -an $vg/$lv1
-lvextend -l 16 $vg/$lv1
+# use two new devs for raid extend to ensure redundancy
+vgextend $vg "$dev7" "$dev8"
+lvs -a -o name,segtype,devices $vg
+lvextend -l 16 $vg/$lv1 "$dev7" "$dev8"
+lvs -a -o name,segtype,devices $vg
lvchange -ay $vg/$lv1
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
resize2fs "$DM_DEV_DIR/$vg/$lv1"
@@ -303,15 +307,18 @@ vgremove -ff $vg
# Test lvextend while active
_prepare_vg
-lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg
+lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg "$dev1" "$dev2"
aux wait_recalc $vg/${lv1}_rimage_0
aux wait_recalc $vg/${lv1}_rimage_1
aux wait_recalc $vg/$lv1
lvcreate --type $create_type -n fast -l 4 -an $vg "$dev6"
lvconvert -y --type $convert_type $convert_option fast $vg/$lv1
+# use two new devs for raid extend to ensure redundancy
+vgextend $vg "$dev7" "$dev8"
lvs -a -o name,size,segtype,devices,sync_percent $vg
_add_new_data_to_mnt
-lvextend -l 16 $vg/$lv1
+lvextend -l 16 $vg/$lv1 "$dev7" "$dev8"
+lvs -a -o name,size,segtype,devices,sync_percent $vg
resize2fs "$DM_DEV_DIR/$vg/$lv1"
aux wait_recalc $vg/${lv1}_${suffix}_rimage_0
aux wait_recalc $vg/${lv1}_${suffix}_rimage_1
@@ -324,16 +331,18 @@ lvremove $vg/$lv1
vgremove -ff $vg
_prepare_vg
-lvcreate --type raid5 --raidintegrity y -n $lv1 -I4 -l 8 $vg
+lvcreate --type raid5 --raidintegrity y -n $lv1 -I4 -l 8 $vg "$dev1" "$dev2" "$dev3"
aux wait_recalc $vg/${lv1}_rimage_0
aux wait_recalc $vg/${lv1}_rimage_1
aux wait_recalc $vg/${lv1}_rimage_2
aux wait_recalc $vg/$lv1
lvcreate --type $create_type -n fast -l 4 -an $vg "$dev6"
lvconvert -y --type $convert_type $convert_option fast $vg/$lv1
+vgextend $vg "$dev7" "$dev8" "$dev9"
lvs -a -o name,size,segtype,devices,sync_percent $vg
_add_new_data_to_mnt
-lvextend -l 16 $vg/$lv1
+lvextend -l 16 $vg/$lv1 "$dev7" "$dev8" "$dev9"
+lvs -a -o name,size,segtype,devices,sync_percent $vg
resize2fs "$DM_DEV_DIR/$vg/$lv1"
aux wait_recalc $vg/${lv1}_${suffix}_rimage_0
aux wait_recalc $vg/${lv1}_${suffix}_rimage_1
4 months, 1 week
main - tests: integrity: snapshots now work on raid+integrity
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3a757047560d75a28d7...
Commit: 3a757047560d75a28d7e4c7d9a5253a72d786544
Parent: 3b4e7d1625ddc48dd9393f03a59cc6b74113275a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 17 11:10:45 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 17 11:10:45 2023 -0500
tests: integrity: snapshots now work on raid+integrity
---
test/shell/integrity.sh | 8 --------
1 file changed, 8 deletions(-)
diff --git a/test/shell/integrity.sh b/test/shell/integrity.sh
index 1ba75d230..61229c83a 100644
--- a/test/shell/integrity.sh
+++ b/test/shell/integrity.sh
@@ -585,7 +585,6 @@ not lvconvert --splitmirrors 1 -n tmp -y $vg/$lv1
not lvconvert --splitmirrors 1 --trackchanges -y $vg/$lv1
not lvchange --syncaction repair $vg/$lv1
not lvreduce -L4M $vg/$lv1
-not lvcreate -s -n snap -L4M $vg/$lv1
not pvmove -n $vg/$lv1 "$dev1"
not pvmove "$dev1"
_verify_data_on_mnt
@@ -769,11 +768,4 @@ not lvconvert --raidintegrity y $vg/${lv2}_cpool_cdata
not lvconvert --raidintegrity y $vg/${lv2}_cpool_cmeta
lvremove -y $vg/$lv1
-# cannot add integrity to raid that has a snapshot
-
-lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
-lvcreate -s -n $lv2 -l 8 $vg/$lv1
-not lvconvert --raidintegrity y $vg/$lv1
-lvremove -y $vg/$lv1
-
vgremove -ff $vg
4 months, 1 week
main - toollib: provide proper hint for referencing VG uuid in case of duplicate VG names
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3b4e7d1625ddc48dd93...
Commit: 3b4e7d1625ddc48dd9393f03a59cc6b74113275a
Parent: fd6e113bba5fed5ee41152cde33220294c24ce2b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue May 16 17:17:55 2023 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue May 16 17:17:55 2023 +0200
toollib: provide proper hint for referencing VG uuid in case of duplicate VG names
vgrename does not support -S|--select, so do not provide a hint about
using it. Instead, provide a hint about using VG uuid directly.
��� vgs
WARNING: VG name vg1 is used by VGs DXjcSK-gWfu-5gLh-9Kbg-sG49-dtRr-GqXzGL and MVMfyM-sjOa-M2xV-AT4Y-JddR-h4SP-UO5Ttk.
Fix duplicate VG names with vgrename uuid, a device filter, or system IDs.
VG #PV #LV #SN Attr VSize VFree
vg1 1 0 0 wz--n- 124.00m 124.00m
vg1 1 0 0 wz--n- 124.00m 124.00m
(vgrename does not support -S|--select)
��� vgrename vg1 vg2
WARNING: VG name vg1 is used by VGs DXjcSK-gWfu-5gLh-9Kbg-sG49-dtRr-GqXzGL and MVMfyM-sjOa-M2xV-AT4Y-JddR-h4SP-UO5Ttk.
Fix duplicate VG names with vgrename uuid, a device filter, or system IDs.
Multiple VGs found with the same name: skipping vg1
Use VG uuid in place of the VG name.
(vgchange does support -S|--select)
��� vgchange --addtag a vg1
WARNING: VG name vg1 is used by VGs DXjcSK-gWfu-5gLh-9Kbg-sG49-dtRr-GqXzGL and MVMfyM-sjOa-M2xV-AT4Y-JddR-h4SP-UO5Ttk.
Fix duplicate VG names with vgrename uuid, a device filter, or system IDs.
Multiple VGs found with the same name: skipping vg1
Use --select vg_uuid=<uuid> in place of the VG name.
---
tools/lvmcmdline.c | 12 ++++++++++++
tools/toollib.c | 7 ++++++-
tools/tools.h | 1 +
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index a5bb6a5c5..6bbf1af26 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -179,6 +179,18 @@ static const struct command_function _command_functions[CMD_COUNT] = {
/* Command line args */
+int arg_is_valid_for_command(const struct cmd_context *cmd, int a)
+{
+ int i;
+
+ for (i = 0; i < cmd->cname->num_args; i++) {
+ if (cmd->cname->valid_args[i] == a)
+ return 1;
+ }
+
+ return 0;
+}
+
unsigned arg_count(const struct cmd_context *cmd, int a)
{
return cmd->opt_arg_values ? cmd->opt_arg_values[a].count : 0;
diff --git a/tools/toollib.c b/tools/toollib.c
index 6b590189b..2f4756b6b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2313,7 +2313,12 @@ static int _resolve_duplicate_vgnames(struct cmd_context *cmd,
* is unknown.
*/
log_error("Multiple VGs found with the same name: skipping %s", sl->str);
- log_error("Use --select vg_uuid=<uuid> in place of the VG name.");
+
+ if (arg_is_valid_for_command(cmd, select_ARG))
+ log_error("Use --select vg_uuid=<uuid> in place of the VG name.");
+ else
+ log_error("Use VG uuid in place of the VG name.");
+
dm_list_del(&sl->list);
ret = ECMD_FAILED;
}
diff --git a/tools/tools.h b/tools/tools.h
index 36da3bc7e..60952a2aa 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -193,6 +193,7 @@ int repairtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_v
int dumptype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
/* we use the enums to access the switches */
+int arg_is_valid_for_command(const struct cmd_context *cmd, int a);
unsigned arg_count(const struct cmd_context *cmd, int a);
unsigned arg_is_set(const struct cmd_context *cmd, int a);
int arg_from_list_is_set(const struct cmd_context *cmd, const char *err_found, ...);
4 months, 2 weeks
main - raidintegrity: allow snapshots
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fd6e113bba5fed5ee41...
Commit: fd6e113bba5fed5ee41152cde33220294c24ce2b
Parent: 05c2b10c5d0a99993430ffbcef684a099ba810ad
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 22 13:05:43 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu May 11 11:02:52 2023 -0500
raidintegrity: allow snapshots
---
lib/activate/dev_manager.c | 6 +-
lib/metadata/integrity_manip.c | 5 -
lib/metadata/snapshot_manip.c | 2 -
test/shell/snapshot-raid.sh | 441 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 446 insertions(+), 8 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index ac3f01718..1f4d7c98b 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -3039,7 +3039,11 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
if (((seg_type(seg, s) == AREA_PV) && _bad_pv_area(seg, s)) ||
((seg_type(seg, s) == AREA_LV) && !seg_lv(seg, s))) {
if (!cmd->partial_activation) {
- if (!cmd->degraded_activation || !lv_is_raid_type(seg->lv)) {
+ if (!cmd->degraded_activation ||
+ (!lv_is_raid_type(seg->lv) &&
+ !lv_is_integrity(seg->lv) &&
+ !lv_is_integrity_metadata(seg->lv) &&
+ !lv_is_integrity_origin(seg->lv))) {
log_error("Aborting. LV %s is incomplete and --activationmode partial was not specified.",
display_lvname(seg->lv));
return 0;
diff --git a/lib/metadata/integrity_manip.c b/lib/metadata/integrity_manip.c
index d71fbaeb6..6b507f7e9 100644
--- a/lib/metadata/integrity_manip.c
+++ b/lib/metadata/integrity_manip.c
@@ -508,11 +508,6 @@ int lv_add_integrity_to_raid(struct logical_volume *lv, struct integrity_setting
return 0;
}
- if (lv_is_origin(lv)) {
- log_error("Integrity cannot be added to snapshot origins.");
- return 0;
- }
-
seg_top = first_seg(lv);
area_count = seg_top->area_count;
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index 822b8da77..b34079d08 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -423,8 +423,6 @@ int validate_snapshot_origin(const struct logical_volume *origin_lv)
}
} else if (lv_is_raid_type(origin_lv) && !lv_is_raid(origin_lv)) {
err = "raid subvolumes";
- } else if (lv_is_raid(origin_lv) && lv_raid_has_integrity((struct logical_volume *)origin_lv)) {
- err = "raid with integrity";
}
out:
diff --git a/test/shell/snapshot-raid.sh b/test/shell/snapshot-raid.sh
new file mode 100644
index 000000000..757bf911e
--- /dev/null
+++ b/test/shell/snapshot-raid.sh
@@ -0,0 +1,441 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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 snapshots of raid
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+which mkfs.ext4 || skip
+
+mount_dir="mnt"
+mkdir -p "$mount_dir"
+
+snap_dir="mnt_snap"
+mkdir -p "$snap_dir"
+
+_sync_percent() {
+ local checklv=$1
+ get lv_field "$checklv" sync_percent | cut -d. -f1
+}
+
+_wait_sync() {
+ local checklv=$1
+
+ for i in $(seq 1 10) ; do
+ sync=$(_sync_percent "$checklv")
+ echo "sync_percent is $sync"
+
+ if test "$sync" = "100"; then
+ return
+ fi
+
+ sleep 1
+ done
+ echo "timeout waiting for recalc"
+ dmsetup status "$DM_DEV_DIR/mapper/${checklv/\//-}"
+ return 1
+}
+
+
+# add and remove a snapshot
+
+test_add_del_snap() {
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+ mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+ touch "$mount_dir/B"
+ not ls "$snap_dir/B"
+ touch "$snap_dir/C"
+ not ls "$mount_dir/C"
+ ls "$mount_dir/A"
+ ls "$snap_dir/A"
+
+ umount "$snap_dir"
+ lvremove -y $vg/snap
+ umount "$mount_dir"
+}
+
+# add and remove snapshot while origin has a missing raid image
+
+test_snap_with_missing_image() {
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ aux disable_dev "$dev1"
+ lvs -a -o+devices $vg
+
+ not lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+
+ aux enable_dev "$dev1"
+ _wait_sync $vg/$lv1
+
+ lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+
+ aux disable_dev "$dev1"
+ lvs -a -o+devices $vg
+
+ lvremove -y $vg/snap
+
+ aux enable_dev "$dev1"
+ vgextend --restoremissing $vg "$dev1"
+ lvs -a -o+devices $vg
+ _wait_sync $vg/$lv1
+
+ umount "$mount_dir"
+}
+
+# raid image is lost and restored while a snapshot exists
+
+test_missing_image_with_snap() {
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+ mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+ aux disable_dev "$dev1"
+ lvs -a -o+devices $vg
+
+ touch "$mount_dir/B"
+ not ls "$snap_dir/B"
+ touch "$snap_dir/C"
+ not ls "$mount_dir/C"
+ ls "$mount_dir/A"
+ ls "$snap_dir/A"
+
+ aux enable_dev "$dev1"
+ _wait_sync $vg/$lv1
+
+ ls "$mount_dir/B"
+ ls "$snap_dir/C"
+
+ umount "$snap_dir"
+ lvremove -y $vg/snap
+ umount "$mount_dir"
+}
+
+# add and remove raid image while snapshot exists
+
+test_add_del_image_with_snap() {
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+ mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+ touch "$mount_dir/B"
+ touch "$snap_dir/C"
+
+ lvconvert -y -m+1 $vg/$lv1 "$dev4"
+ _wait_sync $vg/$lv1
+
+ ls "$mount_dir/B"
+ ls "$snap_dir/C"
+ ls "$mount_dir/A"
+ ls "$snap_dir/A"
+
+ touch "$mount_dir/B2"
+ touch "$snap_dir/C2"
+
+ lvconvert -y -m-1 $vg/$lv1 "$dev4"
+
+ ls "$mount_dir/B"
+ ls "$snap_dir/C"
+ ls "$mount_dir/A"
+ ls "$snap_dir/A"
+ ls "$mount_dir/B2"
+ ls "$snap_dir/C2"
+ umount "$snap_dir"
+ lvremove -y $vg/snap
+
+ umount "$mount_dir"
+}
+
+test_replace_image_with_snap() {
+ # add an image to replace
+ lvconvert -y -m+1 $vg/$lv1 "$dev4"
+ _wait_sync $vg/$lv1
+
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+ mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+ touch "$mount_dir/B"
+ touch "$snap_dir/C"
+
+ lvconvert -y --replace "$dev4" $vg/$lv1 "$dev5"
+ _wait_sync $vg/$lv1
+
+ ls "$mount_dir/B"
+ ls "$snap_dir/C"
+ ls "$mount_dir/A"
+ ls "$snap_dir/A"
+
+ touch "$mount_dir/B2"
+ touch "$snap_dir/C2"
+
+ umount "$snap_dir"
+ lvremove -y $vg/snap
+
+ # put lv1 back to original state with images on dev1 and dev2
+ lvconvert -y -m-1 $vg/$lv1 "$dev5"
+
+ umount "$mount_dir"
+}
+
+test_repair_image_with_snap() {
+ # add an image to repair
+ lvconvert -y -m+1 $vg/$lv1 "$dev4"
+ _wait_sync $vg/$lv1
+
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+ mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+ touch "$mount_dir/B"
+ touch "$snap_dir/C"
+
+ aux disable_dev "$dev4"
+ lvs -a -o+devices $vg
+
+ lvconvert -y --repair $vg/$lv1 "$dev5"
+ _wait_sync $vg/$lv1
+
+ ls "$mount_dir/B"
+ ls "$snap_dir/C"
+ ls "$mount_dir/A"
+ ls "$snap_dir/A"
+
+ touch "$mount_dir/B2"
+ touch "$snap_dir/C2"
+
+ umount "$snap_dir"
+ lvremove -y $vg/snap
+
+ aux enable_dev "$dev4"
+ lvs -a -o+devices $vg
+ vgck --updatemetadata $vg
+
+ # put lv1 back to original state with images on dev1 and dev2
+ lvconvert -y -m-1 $vg/$lv1 "$dev5"
+
+ umount "$mount_dir"
+}
+
+test_merge_snap()
+{
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+ mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+ touch "$mount_dir/B"
+ touch "$snap_dir/C"
+
+ umount "$snap_dir"
+
+ lvconvert --merge $vg/snap
+
+ # the merge will begin once the origin is not in use
+ umount "$mount_dir"
+
+ lvs -a $vg
+ lvchange -an $vg/$lv1
+ lvchange -ay $vg/$lv1
+ lvs -a $vg
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ ls "$mount_dir/A"
+ ls "$mount_dir/C"
+ not ls "$mount_dir/B"
+
+ umount "$mount_dir"
+}
+
+test_extend_snap()
+{
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ lvcreate -s -n snap -L8M $vg/$lv1 "$dev3"
+ mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+ touch "$mount_dir/B"
+ touch "$snap_dir/C"
+
+ lvextend -L+8M $vg/snap
+
+ umount "$mount_dir"
+ umount "$snap_dir"
+ lvremove -y $vg/snap
+}
+
+test_fill_snap()
+{
+ mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+ touch "$mount_dir/A"
+
+ lvcreate -s -n snap -L4M $vg/$lv1 "$dev3"
+
+ lvs -a $vg
+ get lv_field $vg/snap lv_attr | grep "swi-a-s---"
+
+ dd if=/dev/zero of="$mount_dir/1" bs=1M count=1 oflag=sync
+ dd if=/dev/zero of="$mount_dir/2" bs=1M count=1 oflag=sync
+ dd if=/dev/zero of="$mount_dir/3" bs=1M count=1 oflag=sync
+ dd if=/dev/zero of="$mount_dir/4" bs=1M count=1 oflag=sync
+ dd if=/dev/zero of="$mount_dir/5" bs=1M count=1 oflag=sync
+
+ lvs -a $vg
+ get lv_field $vg/snap lv_attr | grep "swi-I-s---"
+ check lv_field $vg/snap data_percent "100.00"
+
+ umount "$mount_dir"
+ lvremove -y $vg/snap
+}
+
+aux prepare_devs 5 200
+
+vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
+
+lvcreate --type raid1 -m1 -n $lv1 -L128M $vg "$dev1" "$dev2"
+_wait_sync $vg/$lv1
+test_add_del_snap
+test_snap_with_missing_image
+test_missing_image_with_snap
+test_add_del_image_with_snap
+test_replace_image_with_snap
+test_repair_image_with_snap
+test_merge_snap
+test_extend_snap
+test_fill_snap
+lvremove -y $vg/$lv1
+
+lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -L128M $vg "$dev1" "$dev2"
+_wait_sync $vg/${lv1}_rimage_0
+_wait_sync $vg/${lv1}_rimage_1
+_wait_sync $vg/$lv1
+test_add_del_snap
+test_snap_with_missing_image
+test_missing_image_with_snap
+test_add_del_image_with_snap
+test_replace_image_with_snap
+test_repair_image_with_snap
+test_merge_snap
+test_extend_snap
+test_fill_snap
+lvremove -y $vg/$lv1
+
+# Repeat above with cache|writecache on the raid image?
+
+#
+# Add/remove integrity while a snapshot exists
+#
+
+lvcreate --type raid1 -m1 -n $lv1 -L128M $vg "$dev1" "$dev2"
+_wait_sync $vg/$lv1
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+touch "$mount_dir/A"
+
+lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+touch "$mount_dir/B"
+touch "$snap_dir/C"
+
+lvconvert --raidintegrity y $vg/$lv1
+_wait_sync $vg/${lv1}_rimage_0
+_wait_sync $vg/${lv1}_rimage_1
+
+ls "$mount_dir/B"
+ls "$snap_dir/C"
+ls "$mount_dir/A"
+ls "$snap_dir/A"
+
+touch "$mount_dir/B2"
+touch "$snap_dir/C2"
+
+lvconvert --raidintegrity n $vg/$lv1
+
+ls "$mount_dir/B"
+ls "$snap_dir/C"
+ls "$mount_dir/A"
+ls "$snap_dir/A"
+ls "$mount_dir/B2"
+ls "$snap_dir/C2"
+umount "$snap_dir"
+umount "$mount_dir"
+lvremove -y $vg/snap
+lvremove -y $vg/$lv1
+
+#
+# Add integrity not allowed with missing image and snapshot exists
+#
+
+lvcreate --type raid1 -m1 -n $lv1 -L128M $vg "$dev1" "$dev2"
+_wait_sync $vg/$lv1
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+
+mount "$DM_DEV_DIR/$vg/$lv1" "$mount_dir"
+touch "$mount_dir/A"
+
+lvcreate -s -n snap -L12M $vg/$lv1 "$dev3"
+mount "$DM_DEV_DIR/$vg/snap" "$snap_dir"
+
+touch "$mount_dir/B"
+touch "$snap_dir/C"
+
+aux disable_dev "$dev1"
+lvs -a $vg
+
+not lvconvert --raidintegrity y $vg/$lv1
+
+aux enable_dev "$dev1"
+lvs -a $vg
+
+umount "$snap_dir"
+umount "$mount_dir"
+lvremove -y $vg/snap
+lvremove -y $vg/$lv1
+
+vgremove -ff $vg
+
4 months, 2 weeks
main - Fix "multisegment RAID1, allocator uses one disk for both legs"
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=05c2b10c5d0a9999343...
Commit: 05c2b10c5d0a99993430ffbcef684a099ba810ad
Parent: bf794b66f412765e49c4d79a4bb95b454f2357fc
Author: heinzm <heinzm(a)redhat.com>
AuthorDate: Wed May 10 18:22:11 2023 +0200
Committer: heinzm <heinzm(a)redhat.com>
CommitterDate: Wed May 10 18:35:21 2023 +0200
Fix "multisegment RAID1, allocator uses one disk for both legs"
In case of e.g. 3 PVs, creating or extending a RaidLV causes SubLV
collocation thus putting segments of diffent rimage (and potentially
larger rmeta) SubLVs onto the same PV. For redundant RaidLVs this'll
compromise redundancy. Fix by detecting such bogus allocation on
lvcreate/lvextend and reject the request.
---
lib/metadata/lv_manip.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 298d307f3..9a9e547be 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4454,6 +4454,38 @@ static int _lv_extend_layered_lv(struct alloc_handle *ah,
return 1;
}
+/* Check either RAID images and metas are being allocated redundantly. */
+static int _lv_raid_redundant(struct logical_volume *lv,
+ struct dm_list *allocatable_pvs, int meta)
+{
+ uint32_t nlvs, s;
+ struct lv_segment *seg = first_seg(lv);
+ struct pv_list *pvl;
+
+ if (meta && !seg->meta_areas)
+ return 1;
+
+ dm_list_iterate_items(pvl, allocatable_pvs) {
+ nlvs = 0;
+
+ for (s = 0; s < seg->area_count; s++) {
+ struct logical_volume *slv = meta ? seg_metalv(seg, s) : seg_lv(seg, s);
+
+ if (slv && lv_is_on_pv(slv, pvl->pv) && nlvs++)
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/* Check both RAID images and metas are being allocated redundantly. */
+static int _lv_raid_redundant_allocation(struct logical_volume *lv, struct dm_list *allocatable_pvs)
+{
+ return _lv_raid_redundant(lv, allocatable_pvs, 0) &&
+ _lv_raid_redundant(lv, allocatable_pvs, 1);
+}
+
/*
* Entry point for single-step LV allocation + extension.
* Extents is the number of logical extents to append to the LV unless
@@ -4556,6 +4588,15 @@ int lv_extend(struct logical_volume *lv,
mirrors, stripes, stripe_size)))
goto_out;
+ if (segtype_is_raid(segtype) &&
+ alloc != ALLOC_ANYWHERE &&
+ !(r = _lv_raid_redundant_allocation(lv, allocatable_pvs))) {
+ log_error("Insufficient suitable allocatable extents for logical volume %s", display_lvname(lv));
+ if (!lv_remove(lv) || !vg_write(lv->vg) || !vg_commit(lv->vg))
+ return_0;
+ goto out;
+ }
+
if (lv_raid_has_integrity(lv)) {
if (!lv_extend_integrity_in_raid(lv, allocatable_pvs)) {
r = 0;
4 months, 2 weeks
main - tests: more updates for 300M xfs
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bf794b66f412765e49c...
Commit: bf794b66f412765e49c4d79a4bb95b454f2357fc
Parent: bc28082b990bf752a2ce6ffa13aff9452c655ab8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed May 10 16:17:38 2023 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed May 10 16:19:46 2023 +0200
tests: more updates for 300M xfs
Fix some sizing for larger xfs testing.
Also fix resize of reiserfs which requires resize_fsadm.
---
test/shell/fsadm-crypt-fsresize.sh | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/test/shell/fsadm-crypt-fsresize.sh b/test/shell/fsadm-crypt-fsresize.sh
index b2847928f..da5688610 100644
--- a/test/shell/fsadm-crypt-fsresize.sh
+++ b/test/shell/fsadm-crypt-fsresize.sh
@@ -20,7 +20,7 @@ export LVM_TEST_PREFER_BRD=0
. lib/inittest
-aux prepare_vg 1 400
+aux prepare_vg 1 1100
# Tests require a libblkid version that shows FSLASTBLOCK
which mkfs.ext4 || skip
@@ -299,8 +299,10 @@ test_xfs_small_shrink() {
test_reiserfs_resize() {
mkfs.reiserfs -s 513 -f "$3"
- fsadm --lvresize resize $1 30M
- lvresize -L+10M --fs resize $1
+ fsadm -y --lvresize resize $1 30M
+ # resize fs does not support resiserfs and requires resize_fsadm
+ not lvresize -L+10M --fs resize $1
+ lvresize -L+10M --fs resize_fsadm $1
fsadm --lvresize -y resize $1 10M
fscheck_reiserfs "$3"
@@ -314,8 +316,9 @@ test_reiserfs_resize() {
test_reiserfs_small_shrink() {
mkfs.reiserfs -s 513 -f "$3"
- lvresize -y -L-1 --fs resize $1
- lvresize -y -L-1 --fs resize $1
+ not lvresize -y -L-1 --fs resize $1
+ lvresize -y -L-1 --fs resize_fsadm $1
+ lvresize -y -L-1 --fs resize_fsadm $1
fscheck_reiserfs "$3"
}
@@ -569,12 +572,10 @@ if check_missing ext3; then
fi
if check_missing xfs; then
- lvresize -r -y -L310M $vg_lv
+ lvresize --fs ignore -y -L325M $vg_lv
cryptsetup resize $CRYPT_NAME
test_xfs_resize "$vg_lv" "$dev_vg_lv" "$CRYPT_DEV"
- lvresize --fs ignore -y -L325M $vg_lv
- cryptsetup resize $CRYPT_NAME
test_xfs_inactive "$vg_lv2" "$dev_vg_lv2" "$CRYPT_DEV2" "$CRYPT_NAME2"
4 months, 2 weeks