main - lvcreate: allow thin snapshot syntax that broke
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ea6b5b694bf0886052b...
Commit: ea6b5b694bf0886052b048b2e04b941ec65d90f9
Parent: 1dbb86f8c7cd95cb484a5b3c465b847f35d2b760
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 20 15:41:24 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 20 15:47:01 2023 -0500
lvcreate: allow thin snapshot syntax that broke
The command "lvcreate --type thin --snapshot ..." to create a thin
snapshot would fail.
commit d651b340e68d97ada25e558eb50aa40062bba936 removed the optional
"--type thin" from the command definition "lvcreate --snapshot LV_thin",
and added --type thin as AUTOTYPE. This was correct and should not have
changed anything if all the command defs were correct, but it broke
the "lvcreate --type thin --snapshot" case. It reveals a problem in a
different command definintion: "lvcreate --type thin LV_thin" that was
missing --snapshot in its OO list.
---
test/shell/lvcreate-thin-snap.sh | 20 ++++++++++++++++++++
tools/command-lines.in | 6 +++---
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvcreate-thin-snap.sh b/test/shell/lvcreate-thin-snap.sh
index 6e6410cc1..8f1987986 100644
--- a/test/shell/lvcreate-thin-snap.sh
+++ b/test/shell/lvcreate-thin-snap.sh
@@ -74,5 +74,25 @@ lvcreate -L10M --zero n -T $vg/pool -V10M --name $lv1
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
lvcreate -K -s $vg/$lv1 --name snap
fsck -n "$DM_DEV_DIR/$vg/snap"
+vgchange -an $vg
+lvremove -y $vg
+
+# One thin pool and one thin LV
+lvcreate --type thin-pool -L 10M -n tp $vg
+lvcreate --type thin -n thin1 -V 20M --thinpool tp $vg
+# Different syntaxes for creating a thin snapshot
+lvcreate --type thin -n snap1 $vg/thin1
+lvcreate --type thin --snapshot -n snap2 $vg/thin1
+lvcreate --type thin --thin -n snap3 $vg/thin1
+lvcreate --type thin --snapshot --thin -n snap4 $vg/thin1
+lvcreate --snapshot -n snap5 $vg/thin1
+lvcreate --thin -n snap6 $vg/thin1
+# The command defs allow --snapshot --thin, but the internal
+# lvcreate option checks disallow it. It doesn't seem to make
+# sense to disallow this from a syntax point of view, but it's
+# possible that the lvcreate implementation would do the wrong
+# thing (that should probably be fixed.)
+not lvcreate --thin --snapshot -n snap7 $vg/thin1
+vgchange -an $vg
vgremove -ff $vg
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 3d311288f..bb6e09933 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1088,7 +1088,7 @@ AUTOTYPE: thin
---
lvcreate --type thin LV_thin
-OO: --thin, OO_LVCREATE
+OO: --thin, --snapshot, OO_LVCREATE
IO: --mirrors 0
ID: lvcreate_thin_snapshot
DESC: Create a thin LV that is a snapshot of an existing thin LV.
@@ -1096,7 +1096,7 @@ FLAGS: SECONDARY_SYNTAX
# alternate form of lvcreate --type thin
lvcreate --thin LV_thin
-OO: OO_LVCREATE
+OO: --snapshot, OO_LVCREATE
IO: --mirrors 0
ID: lvcreate_thin_snapshot
DESC: Create a thin LV that is a snapshot of an existing thin LV.
@@ -1105,7 +1105,7 @@ AUTOTYPE: thin
# alternate form of lvcreate --type thin
lvcreate --snapshot LV_thin
-OO: OO_LVCREATE
+OO: --thin, OO_LVCREATE
IO: --mirrors 0
ID: lvcreate_thin_snapshot
DESC: Create a thin LV that is a snapshot of an existing thin LV.
11 months, 2 weeks
main - tests: lvresize fs mounted multiple times
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1dbb86f8c7cd95cb484...
Commit: 1dbb86f8c7cd95cb484a5b3c465b847f35d2b760
Parent: 7c3eca833ff7878d6d32198ed76380c91fdc15fc
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 20 13:13:06 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 20 13:13:06 2023 -0500
tests: lvresize fs mounted multiple times
---
test/shell/lvresize-fs.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/test/shell/lvresize-fs.sh b/test/shell/lvresize-fs.sh
index cf93a4222..d2c4ac707 100644
--- a/test/shell/lvresize-fs.sh
+++ b/test/shell/lvresize-fs.sh
@@ -38,6 +38,8 @@ mkdir -p "$mount_dir"
mount_dir_space="other mnt dir"
mkdir -p "$mount_dir_space"
+mount_dir_2="mnt_lvresize_fs_2"
+mkdir -p "$mount_dir_2"
# Test combinations of the following:
# lvreduce / lvextend
@@ -207,6 +209,47 @@ umount "$mount_dir_space"
lvremove -f $vg/$lv3
+#################################
+#
+# lvextend, ext4, multiple mounts
+#
+#################################
+
+# Use one instance of ext4 for series of lvextend tests:
+lvcreate -n $lv -L 32M $vg
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
+mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir"
+mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir_2"
+
+# lvextend, ext4, active, mounted twice, -r
+lvextend -r -L+8M $vg/$lv
+check lv_field $vg/$lv lv_size "40.00m"
+
+workaround_
+
+lvrename $vg/$lv $vg/$lv2
+not lvextend -r -L+8M $vg/$lv2
+not lvreduce -r -L-8M $vg/$lv2
+umount "$mount_dir"
+umount "$mount_dir_2"
+lvextend -r -L+8M $vg/$lv2
+
+mount "$DM_DEV_DIR/$vg/$lv2" "$mount_dir"
+mount --bind "$mount_dir" "$mount_dir_2"
+lvextend -r -L+8M $vg/$lv2
+check lv_field $vg/$lv2 lv_size "56.00m"
+lvrename $vg/$lv2 $vg/$lv3
+not lvextend -r -L+8M $vg/$lv3
+not lvreduce -r -L-8M $vg/$lv3
+umount "$mount_dir"
+umount "$mount_dir_2"
+mount "$DM_DEV_DIR/$vg/$lv3" "$mount_dir"
+lvextend -r -L+8M $vg/$lv3
+lvreduce -r -y -L-8M $vg/$lv3
+umount "$mount_dir"
+
+lvremove -f $vg/$lv3
+
#####################################
#
# Now let do some unmounted tests
11 months, 2 weeks
main - lvresize: fix multiple mounts
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7c3eca833ff7878d6d3...
Commit: 7c3eca833ff7878d6d32198ed76380c91fdc15fc
Parent: 228a8e8c1fd8e82a2e31a6060614dc3dd2f8bc51
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jun 16 12:06:40 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jun 16 12:11:51 2023 -0500
lvresize: fix multiple mounts
which was mistaken as a mounted LV that had been renamed.
---
lib/device/filesystem.c | 47 ++++++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 23 deletions(-)
diff --git a/lib/device/filesystem.c b/lib/device/filesystem.c
index 2572bca69..39e563117 100644
--- a/lib/device/filesystem.c
+++ b/lib/device/filesystem.c
@@ -243,8 +243,6 @@ int fs_mount_state_is_misnamed(struct cmd_context *cmd, struct logical_volume *l
FILE *fme = NULL;
struct mntent *me;
int renamed = 0;
- int found_dir = 0;
- int found_dev = 0;
int dev_match, dir_match;
if (stat(lv_path, &st_lv) < 0) {
@@ -281,6 +279,9 @@ int fs_mount_state_is_misnamed(struct cmd_context *cmd, struct logical_volume *l
}
endmntent(fme);
+ if (mtab_mntpath[0])
+ log_debug("%s mtab mntpath %s", display_lvname(lv), mtab_mntpath);
+
/*
* In mtab dir path, replace each ascii space character with the
* four characters \040 which is how /proc/mounts represents spaces.
@@ -319,15 +320,31 @@ int fs_mount_state_is_misnamed(struct cmd_context *cmd, struct logical_volume *l
if (strcmp(fstype, proc_fstype))
continue;
+ /*
+ * When an LV is mounted on two dirs, it appears in /proc/mounts twice as
+ * /dev/mapper/vg-lvol0 on /foo type xfs ...
+ * /dev/mapper/vg-lvol0 on /bar type xfs ...
+ * All entries match dm_devpath, one entry matches mntpath,
+ * and other entries don't match mntpath.
+ *
+ * When an LV is mounted on one dir, and is renamed from lvol0 to lvol1,
+ * it appears in /proc/mounts once as
+ * /dev/mapper/vg-lvol0 on /foo type xfs ...
+ */
+
dir_match = !strcmp(mtab_mntpath, proc_mntpath);
dev_match = !strcmp(dm_devpath, proc_devpath);
- if (dir_match)
- found_dir++;
- if (dev_match)
- found_dev++;
+ if (!dir_match && !dev_match)
+ continue;
+
+ if (dev_match && !dir_match) {
+ log_debug("LV %s mounted at %s also mounted at %s.",
+ dm_devpath, mtab_mntpath, proc_mntpath);
+ continue;
+ }
- if (dir_match != dev_match) {
+ if (!dev_match && dir_match) {
log_error("LV %s mounted at %s may have been renamed (from %s).",
dm_devpath, proc_mntpath, proc_devpath);
renamed = 1;
@@ -337,26 +354,10 @@ int fs_mount_state_is_misnamed(struct cmd_context *cmd, struct logical_volume *l
if (fclose(fp))
stack;
- /*
- * Don't try resizing if:
- * - different device names apppear for the mount point
- * (LVs probably renamed while mounted), or
- * - the mount point for the LV appears multiple times, or
- * - the LV device is listed for multiple mounts.
- */
if (renamed) {
log_error("File system resizing not supported: fs utilities do not support renamed devices.");
return 1;
}
- /* These two are likely detected as renamed, but include checks in case. */
- if (found_dir > 1) {
- log_error("File system resizing not supported: %s appears more than once in /proc/mounts.", mtab_mntpath);
- return 1;
- }
- if (found_dev > 1) {
- log_error("File system resizing not supported: %s appears more than once in /proc/mounts.", dm_devpath);
- return 1;
- }
return 0;
}
11 months, 3 weeks
main - device_id: ignore leading and trailing spaces for sys_wwid and sys_serial
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=228a8e8c1fd8e82a2e3...
Commit: 228a8e8c1fd8e82a2e31a6060614dc3dd2f8bc51
Parent: f0b48a23d9d8b5d858be1772ea5c9083d235b3b3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 15 13:58:48 2023 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 15 15:17:14 2023 -0500
device_id: ignore leading and trailing spaces for sys_wwid and sys_serial
Leading and trailing underscores are also ignored to handle device ids
written by previous versions which replaced all spaces with underscores.
---
lib/device/device.h | 1 +
lib/device/device_id.c | 280 ++++++++++++++++++++++++--------------
lib/device/parse_vpd.c | 50 +++++++
test/shell/devicesfile-vpd-ids.sh | 101 ++++++++++++--
4 files changed, 313 insertions(+), 119 deletions(-)
diff --git a/lib/device/device.h b/lib/device/device.h
index 446104218..84d87232b 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -239,6 +239,7 @@ int dev_mpath_init(const char *config_wwids_file);
void dev_mpath_exit(void);
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);
+int format_general_id(const char *in, int in_bytes, unsigned char *out, int out_bytes);
int parse_vpd_serial(const unsigned char *in, char *out, int outsize);
/* dev_util */
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 9a8716500..87fcf32ba 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -185,6 +185,71 @@ void free_dids(struct dm_list *ids)
}
}
+/* More than one _ in a row is replaced with one _ */
+static void _reduce_repeating_underscores(char *buf, int bufsize)
+{
+ char *tmpbuf;
+ int us = 0, i, j = 0;
+
+ if (!(tmpbuf = strndup(buf, bufsize-1)))
+ return;
+
+ memset(buf, 0, bufsize);
+
+ for (i = 0; i < strlen(tmpbuf); i++) {
+ if (tmpbuf[i] == '_')
+ us++;
+ else
+ us = 0;
+
+ if (us == 1)
+ buf[j++] = '_';
+ else if (us > 1)
+ continue;
+ else
+ buf[j++] = tmpbuf[i];
+
+ if (j == bufsize)
+ break;
+ }
+ buf[bufsize-1] = '\0';
+ free(tmpbuf);
+}
+
+static void _remove_leading_underscores(char *buf, int bufsize)
+{
+ char *tmpbuf;
+ int i, j = 0;
+
+ if (buf[0] != '_')
+ return;
+
+ if (!(tmpbuf = strndup(buf, bufsize-1)))
+ return;
+
+ memset(buf, 0, bufsize);
+
+ for (i = 0; i < strlen(tmpbuf); i++) {
+ if (!j && tmpbuf[i] == '_')
+ continue;
+ buf[j++] = tmpbuf[i];
+
+ if (j == bufsize)
+ break;
+ }
+ free(tmpbuf);
+}
+
+static void _remove_trailing_underscores(char *buf, int bufsize)
+{
+ char *end;
+
+ end = buf + strlen(buf) - 1;
+ while ((end > buf) && (*end == '_'))
+ end--;
+ end[1] = '\0';
+}
+
static int _read_sys_block(struct cmd_context *cmd, struct device *dev,
const char *suffix, char *sysbuf, int sysbufsize,
int binary, int *retlen)
@@ -406,7 +471,7 @@ struct dev_wwid *dev_add_wwid(char *id, int id_type, struct dm_list *ids)
int dev_read_vpd_wwids(struct cmd_context *cmd, struct device *dev)
{
- unsigned char vpd_data[VPD_SIZE] = { 0 };
+ char vpd_data[VPD_SIZE] = { 0 };
int vpd_datalen = 0;
dev->flags |= DEV_ADDED_VPD_WWIDS;
@@ -417,36 +482,47 @@ int dev_read_vpd_wwids(struct cmd_context *cmd, struct device *dev)
return 0;
/* adds dev_wwid entry to dev->wwids for each id in vpd data */
- parse_vpd_ids(vpd_data, vpd_datalen, &dev->wwids);
+ parse_vpd_ids((const unsigned char *)vpd_data, vpd_datalen, &dev->wwids);
return 1;
}
int dev_read_sys_wwid(struct cmd_context *cmd, struct device *dev,
- char *buf, int bufsize, struct dev_wwid **dw_out)
+ char *outbuf, int outbufsize, struct dev_wwid **dw_out)
{
- char tmpbuf[DEV_WWID_SIZE];
+ char buf[DEV_WWID_SIZE] = { 0 };
struct dev_wwid *dw;
- int ret;
+ int is_t10 = 0;
+ int i, ret;
dev->flags |= DEV_ADDED_SYS_WWID;
- ret = read_sys_block(cmd, dev, "device/wwid", buf, bufsize);
+ ret = read_sys_block(cmd, dev, "device/wwid", buf, sizeof(buf));
if (!ret || !buf[0]) {
/* the wwid file is not under device for nvme devs */
- ret = read_sys_block(cmd, dev, "wwid", buf, bufsize);
+ ret = read_sys_block(cmd, dev, "wwid", buf, sizeof(buf));
}
if (!ret || !buf[0])
return 0;
- /* in t10 id, replace characters like space and quote */
- if (!strncmp(buf, "t10.", 4)) {
- if (bufsize < DEV_WWID_SIZE)
- return 0;
- memcpy(tmpbuf, buf, DEV_WWID_SIZE);
- memset(buf, 0, bufsize);
- format_t10_id((const unsigned char *)tmpbuf, DEV_WWID_SIZE, (unsigned char *)buf, bufsize);
+ for (i = 0; i < sizeof(buf) - 4; i++) {
+ if (buf[i] == ' ')
+ continue;
+ if (!strncmp(&buf[i], "t10", 3))
+ is_t10 = 1;
+ break;
}
+ /*
+ * Remove leading and trailing spaces.
+ * Replace internal spaces with underscores.
+ * t10 wwids have multiple sequential spaces
+ * replaced by a single underscore.
+ */
+ if (is_t10)
+ format_t10_id((const unsigned char *)buf, sizeof(buf), (unsigned char *)outbuf, outbufsize);
+ else
+ format_general_id((const char *)buf, sizeof(buf), (unsigned char *)outbuf, outbufsize);
+
/* Note, if wwids are also read from vpd, this same wwid will be added again. */
if (!(dw = dev_add_wwid(buf, 0, &dev->wwids)))
@@ -457,9 +533,9 @@ int dev_read_sys_wwid(struct cmd_context *cmd, struct device *dev,
}
static int _dev_read_sys_serial(struct cmd_context *cmd, struct device *dev,
- char *buf, int bufsize)
+ char *outbuf, int outbufsize)
{
- unsigned char vpd_data[VPD_SIZE] = { 0 };
+ char buf[VPD_SIZE] = { 0 };
const char *devname;
int vpd_datalen = 0;
@@ -471,13 +547,16 @@ static int _dev_read_sys_serial(struct cmd_context *cmd, struct device *dev,
* (Only virtio disks /dev/vdx are known to use /sys/class/block/vdx/serial.)
*/
- read_sys_block(cmd, dev, "device/serial", buf, bufsize);
- if (buf[0])
- return 1;
+ read_sys_block(cmd, dev, "device/serial", buf, sizeof(buf));
+ if (buf[0]) {
+ format_general_id((const char *)buf, sizeof(buf), (unsigned char *)outbuf, outbufsize);
+ if (outbuf[0])
+ return 1;
+ }
- if (read_sys_block_binary(cmd, dev, "device/vpd_pg80", (char *)vpd_data, VPD_SIZE, &vpd_datalen) && vpd_datalen) {
- parse_vpd_serial(vpd_data, buf, bufsize);
- if (buf[0])
+ if (read_sys_block_binary(cmd, dev, "device/vpd_pg80", buf, VPD_SIZE, &vpd_datalen) && vpd_datalen) {
+ parse_vpd_serial((const unsigned char *)buf, outbuf, outbufsize);
+ if (outbuf[0])
return 1;
}
@@ -505,12 +584,13 @@ static int _dev_read_sys_serial(struct cmd_context *cmd, struct device *dev,
if (dm_snprintf(path, sizeof(path), "%s/class/block/%s/serial", sysfs_dir, vdx) < 0)
return 0;
- ret = get_sysfs_value(path, buf, bufsize, 0);
+ ret = get_sysfs_value(path, buf, sizeof(buf), 0);
if (ret && !buf[0])
ret = 0;
if (ret) {
- buf[bufsize - 1] = '\0';
- return 1;
+ format_general_id((const char *)buf, sizeof(buf), (unsigned char *)outbuf, outbufsize);
+ if (buf[0])
+ return 1;
}
}
@@ -520,6 +600,7 @@ static int _dev_read_sys_serial(struct cmd_context *cmd, struct device *dev,
const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, uint16_t idtype)
{
char sysbuf[PATH_MAX] = { 0 };
+ char sysbuf2[PATH_MAX] = { 0 };
const char *idname = NULL;
struct dev_wwid *dw;
int i;
@@ -584,16 +665,45 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
return NULL;
}
- /* wwids are already munged if needed */
- if (idtype != DEV_ID_TYPE_SYS_WWID) {
+ /*
+ * Replace all spaces, quotes, control chars with underscores.
+ * sys_wwid, sys_serial, and wwid_* have already been handled,
+ * and with slightly different replacement (see format_t10_id,
+ * format_general_id.)
+ */
+ if ((idtype != DEV_ID_TYPE_SYS_WWID) &&
+ (idtype != DEV_ID_TYPE_SYS_SERIAL) &&
+ (idtype != DEV_ID_TYPE_WWID_NAA) &&
+ (idtype != DEV_ID_TYPE_WWID_EUI) &&
+ (idtype != DEV_ID_TYPE_WWID_T10)) {
for (i = 0; i < strlen(sysbuf); i++) {
- if (sysbuf[i] == '"')
- continue;
- if (isblank(sysbuf[i]) || isspace(sysbuf[i]) || iscntrl(sysbuf[i]))
+ if ((sysbuf[i] == '"') ||
+ isblank(sysbuf[i]) ||
+ isspace(sysbuf[i]) ||
+ iscntrl(sysbuf[i]))
sysbuf[i] = '_';
}
}
+ /*
+ * Reduce actual leading and trailing underscores for sys_wwid
+ * and sys_serial, since underscores were previously used as
+ * replacements for leading/trailing spaces which are now ignored.
+ * Also reduce any actual repeated underscores in t10 wwid since
+ * multiple repeated spaces were also once replaced by underscores.
+ */
+ if ((idtype == DEV_ID_TYPE_SYS_WWID) ||
+ (idtype == DEV_ID_TYPE_SYS_SERIAL)) {
+ memcpy(sysbuf2, sysbuf, sizeof(sysbuf2));
+ _remove_leading_underscores(sysbuf2, sizeof(sysbuf2));
+ _remove_trailing_underscores(sysbuf2, sizeof(sysbuf2));
+ if (idtype == DEV_ID_TYPE_SYS_WWID && !strncmp(sysbuf2, "t10", 3) && strstr(sysbuf2, "__"))
+ _reduce_repeating_underscores(sysbuf2, sizeof(sysbuf2));
+ if (memcmp(sysbuf, sysbuf2, sizeof(sysbuf)))
+ log_debug("device_id_system_read reduced underscores %s to %s", sysbuf, sysbuf2);
+ memcpy(sysbuf, sysbuf2, sizeof(sysbuf));
+ }
+
if (!sysbuf[0])
goto bad;
@@ -1728,40 +1838,6 @@ static int _match_dm_devnames(struct cmd_context *cmd, struct device *dev,
return 0;
}
-/* 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;
-
- for (i = 0; i < in_len; i++) {
- if (in[i] == '_')
- us++;
- else
- us = 0;
-
- if (us == 1)
- out[j++] = '_';
- else if (us > 1)
- continue;
- else
- out[j++] = in[i];
-
- if (j == out_size)
- break;
- }
-}
-
-/* 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.
@@ -1775,8 +1851,7 @@ static void _remove_trailing_underscores(char *buf)
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];
+ char du_idname[PATH_MAX];
struct dev_id *id;
const char *idname;
int part;
@@ -1827,20 +1902,30 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
}
/*
- * Devices file entries with IDTYPE=sys_wwid and a T10 WWID
- * 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. 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.
+ * sys_wwid and sys_serial were saved in the past with leading and
+ * trailing spaces replaced with underscores, and t10 wwids also had
+ * repeated internal spaces replaced with one underscore each. Now we
+ * ignore leading and trailing spaces and replace multiple repeated
+ * spaces with one underscore in t10 wwids. In order to handle
+ * system.devices entries created by older versions, modify the IDNAME
+ * value that's read (du->idname) to remove leading and trailing
+ * underscores, and reduce repeated underscores to one in t10 wwids.
+ *
+ * Example: wwid is reported as " t10.123 456 " (without quotes)
+ * Previous versions would save this in system.devices as: __t10.123__456__
+ * Current versions will save this in system.devices as: t10.123_456
+ * device_id_system_read() now returns: t10.123_456
+ * When this code reads __t10.123__456__ from system.devices, that
+ * string is modified to t10.123_456 so that it will match the value
+ * returned from device_id_system_read().
*/
- 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);
+ strncpy(du_idname, du->idname, PATH_MAX-1);
+ if (((du->idtype == DEV_ID_TYPE_SYS_WWID) || (du->idtype == DEV_ID_TYPE_SYS_SERIAL)) &&
+ strchr(du_idname, '_')) {
+ _remove_leading_underscores(du_idname, sizeof(du_idname));
+ _remove_trailing_underscores(du_idname, sizeof(du_idname));
+ if (du->idtype == DEV_ID_TYPE_SYS_WWID && !strncmp(du_idname, "t10", 3) && strstr(du_idname, "__"))
+ _reduce_repeating_underscores(du_idname, sizeof(du_idname));
}
/*
@@ -1848,21 +1933,14 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
* (and saved on dev->ids to avoid rereading.)
*/
dm_list_iterate_items(id, &dev->ids) {
- if (id->idtype == du->idtype) {
+ if (!id->idname)
+ continue;
+ 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.
+ * dm names can have different forms, so matching names
+ * is not always a direct comparison.
*/
- 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;
@@ -1871,22 +1949,16 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
log_debug("Match device_id %s %s to %s: dm names",
idtype_to_str(du->idtype), du->idname, dev_name(dev));
return 1;
+ }
- } else if (id->idname && !strcmp(id->idname, du->idname)) {
+ if (!strcmp(id->idname, du_idname)) {
du->dev = dev;
dev->id = id;
dev->flags |= DEV_MATCHED_USE_ID;
log_debug("Match device_id %s %s to %s",
- idtype_to_str(du->idtype), du->idname, dev_name(dev));
+ idtype_to_str(du->idtype), du_idname, dev_name(dev));
return 1;
- } 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;
- log_debug("Match device_id %s %s to %s",
- idtype_to_str(du->idtype), du->idname, dev_name(dev));
- return 1;
} else {
/*
log_debug("Mismatch device_id %s %s to %s: idname %s",
@@ -1913,12 +1985,12 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
id->dev = dev;
dm_list_add(&dev->ids, &id->list);
- if (idname && !strcmp(idname, du->idname)) {
+ if (idname && !strcmp(idname, du_idname)) {
du->dev = dev;
dev->id = id;
dev->flags |= DEV_MATCHED_USE_ID;
log_debug("Match device_id %s %s to %s",
- idtype_to_str(du->idtype), du->idname, dev_name(dev));
+ idtype_to_str(du->idtype), idname, dev_name(dev));
return 1;
}
@@ -1944,7 +2016,7 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
dev_read_vpd_wwids(cmd, dev);
dm_list_iterate_items(dw, &dev->wwids) {
- if (!strcmp(dw->id, du->idname)) {
+ if (!strcmp(dw->id, du_idname)) {
if (!(id = zalloc(sizeof(struct dev_id))))
return_0;
/* wwid types are 1,2,3 and idtypes are DEV_ID_TYPE_ */
@@ -1956,7 +2028,7 @@ static int _match_du_to_dev(struct cmd_context *cmd, struct dev_use *du, struct
dev->id = id;
dev->flags |= DEV_MATCHED_USE_ID;
log_print_unless_silent("Match device_id %s %s to vpd_pg83 %s %s.",
- idtype_to_str(du->idtype), du->idname,
+ idtype_to_str(du->idtype), du_idname,
idtype_to_str(id->idtype), dev_name(dev));
du->idtype = id->idtype;
return 1;
diff --git a/lib/device/parse_vpd.c b/lib/device/parse_vpd.c
index c1ac974fd..938277e38 100644
--- a/lib/device/parse_vpd.c
+++ b/lib/device/parse_vpd.c
@@ -36,7 +36,57 @@
#include <assert.h>
/*
+ * Remove leading spaces.
+ * Remove trailing spaces.
+ * Replace each space with underscore.
+ * Skip quotes, non-ascii, non-printable.
+ */
+int format_general_id(const char *in, int in_bytes, unsigned char *out, int out_bytes)
+{
+ const char *end;
+ int end_bytes = strlen(in);
+ int retlen = 0;
+ int j = 0;
+ int i;
+
+ if (!end_bytes)
+ return 0;
+
+ end = in + end_bytes - 1;
+ while ((end > in) && (*end == ' ')) {
+ end--;
+ end_bytes--;
+ }
+
+ for (i = 0; i < end_bytes; i++) {
+ if (!in[i])
+ break;
+ if (j >= (out_bytes - 2))
+ break;
+ /* skip leading spaces */
+ if (!retlen && (in[i] == ' '))
+ continue;
+ /* skip non-ascii non-printable characters */
+ if (!isascii(in[i]) || !isprint(in[i]))
+ continue;
+ /* skip quote */
+ if (in[i] == '"')
+ continue;
+ /* replace each space with _ */
+ if (in[i] == ' ')
+ out[j++] = '_';
+ else
+ out[j++] = in[i];
+ retlen++;
+ }
+ return retlen;
+}
+
+/*
+ * Remove leading spaces.
+ * Remove trailing spaces.
* Replace series of spaces with a single _.
+ * Skip quotes, non-ascii, non-printable.
*/
int format_t10_id(const unsigned char *in, int in_bytes, unsigned char *out, int out_bytes)
{
diff --git a/test/shell/devicesfile-vpd-ids.sh b/test/shell/devicesfile-vpd-ids.sh
index 52805737b..04dbae7d0 100644
--- a/test/shell/devicesfile-vpd-ids.sh
+++ b/test/shell/devicesfile-vpd-ids.sh
@@ -223,8 +223,8 @@ cleanup_sysfs
# Test t10 wwid containing quote
rm $DF
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
-echo "t10.ATA_2.5\"_SATA_SSD_1112-A___111111111111" > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/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
vgcreate $vg "$DEV1"
@@ -241,19 +241,19 @@ grep sys_wwid $DF
grep 2.5_SATA_SSD $DF
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/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
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
+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/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/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
vgcreate $vg "$DEV1"
@@ -266,19 +266,19 @@ grep sys_wwid out
grep sys_wwid $DF
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/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
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
+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/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/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
vgcreate $vg "$DEV1"
@@ -311,20 +311,20 @@ pvs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/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
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
+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/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/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__"
@@ -352,9 +352,80 @@ pvs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cleanup_sysfs
+
+#
+# Test trailing/leading/center spaces in sys_wwid and sys_serial device
+# ids, and that old system.devices files that have trailing/leading
+# underscores are understood.
+#
+
+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
+lvmdevices --adddev "$DEV1"
+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
+vgs
+pvs -o+deviceidtype,deviceid "$DEV1"
+lvremove -y $vg
+vgremove $vg
+rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial
cleanup_sysfs
+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
+lvmdevices --adddev "$DEV1"
+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
+vgs
+pvs -o+deviceidtype,deviceid "$DEV1"
+lvremove -y $vg
+vgremove $vg
+rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cleanup_sysfs
+
+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
+lvmdevices --adddev "$DEV1"
+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
+vgs
+pvs -o+deviceidtype,deviceid "$DEV1"
+lvremove -y $vg
+vgremove $vg
+rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cleanup_sysfs
+
+
+
# TODO: lvmdevices --adddev <dev> --deviceidtype <type> --deviceid <val>
# This would let the user specify the second naa wwid.
11 months, 3 weeks
main - tests: Skip integrity tests if target not present
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f0b48a23d9d8b5d858b...
Commit: f0b48a23d9d8b5d858be1772ea5c9083d235b3b3
Parent: 4cf005d3959fdee5f78948164f22a0f0aff25173
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed Jun 14 13:48:51 2023 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Wed Jun 14 13:48:51 2023 +0200
tests: Skip integrity tests if target not present
---
test/shell/snapshot-raid.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/test/shell/snapshot-raid.sh b/test/shell/snapshot-raid.sh
index 757bf911e..7b045d79e 100644
--- a/test/shell/snapshot-raid.sh
+++ b/test/shell/snapshot-raid.sh
@@ -348,6 +348,9 @@ test_extend_snap
test_fill_snap
lvremove -y $vg/$lv1
+# INTEGRITY TESTS FOLLOWING:
+if aux have_integrity 1 5 0; then
+
lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -L128M $vg "$dev1" "$dev2"
_wait_sync $vg/${lv1}_rimage_0
_wait_sync $vg/${lv1}_rimage_1
@@ -437,5 +440,7 @@ umount "$mount_dir"
lvremove -y $vg/snap
lvremove -y $vg/$lv1
+fi # INTEGRITY TESTS SKIPPED
+
vgremove -ff $vg
11 months, 3 weeks
main - tests: tmp is used for TMPDIR
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4cf005d3959fdee5f78...
Commit: 4cf005d3959fdee5f78948164f22a0f0aff25173
Parent: 7ac5dbfd09e771f087a9467aca8a0d5905084459
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed Jun 14 13:23:41 2023 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Wed Jun 14 13:23:41 2023 +0200
tests: tmp is used for TMPDIR
Fixes tests failing due to previous commit 734d9791f817.
---
test/shell/pvck-dump.sh | 4 ++--
test/shell/pvscan-autoactivate.sh | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/shell/pvck-dump.sh b/test/shell/pvck-dump.sh
index 81e164d73..76da38d3e 100644
--- a/test/shell/pvck-dump.sh
+++ b/test/shell/pvck-dump.sh
@@ -100,8 +100,8 @@ grep "zero metadata copies" m4
diff m1 m2
diff m1 m3
-not diff m1 m3b > tmp
-grep "metadata text at" tmp
+not diff m1 m3b > out
+grep "metadata text at" out
lvcreate -an -l1 $vg
diff --git a/test/shell/pvscan-autoactivate.sh b/test/shell/pvscan-autoactivate.sh
index 297ceb96d..f57473104 100644
--- a/test/shell/pvscan-autoactivate.sh
+++ b/test/shell/pvscan-autoactivate.sh
@@ -169,9 +169,9 @@ _clear_online_files
pvscan --cache -aay "$dev3"
not ls "$RUNDIR/lvm/pvs_online/$PVID3"
-lvs --foreign $vg2 > tmp
-cat tmp
-grep $lv2 tmp
+lvs --foreign $vg2 > out
+cat out
+grep $lv2 out
check lv_field $vg2/$lv2 lv_active "" --foreign
fi
11 months, 3 weeks
main - WHATS_NEW: update
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7ac5dbfd09e771f087a...
Commit: 7ac5dbfd09e771f087a9467aca8a0d5905084459
Parent: 9105890d43bd1b6fe514114f671af2e946e13083
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 9 17:52:00 2023 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jun 9 18:01:35 2023 +0200
WHATS_NEW: update
---
WHATS_NEW | 2 ++
1 file changed, 2 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index 493567c5d..cb38ba72e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
version 2.03.22 -
=================================
+ Enhance lvm_import_vdo and use snapshot when converting VDO volume.
+ Fix parsed of VDO metadata.
Fix failing -S|--select for non-reporting cmds if using LV info/status fields.
version 2.03.21 - 21st April 2023
11 months, 4 weeks
main - tests: updates
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9105890d43bd1b6fe51...
Commit: 9105890d43bd1b6fe514114f671af2e946e13083
Parent: 7f661a24c4f7fa8f161f17da093e456f0d60e106
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 9 13:28:23 2023 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jun 9 18:01:16 2023 +0200
tests: updates
Add some more complicated conversion tests.
---
test/shell/vdo-convert.sh | 67 ++++++++++++++++++++++++++++++++---------------
1 file changed, 46 insertions(+), 21 deletions(-)
diff --git a/test/shell/vdo-convert.sh b/test/shell/vdo-convert.sh
index 5bf53d081..cb3dd7100 100644
--- a/test/shell/vdo-convert.sh
+++ b/test/shell/vdo-convert.sh
@@ -18,10 +18,12 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
# Use local for this test vdo configuratoin
-VDOCONF="-f vdotestconf.yml"
+VDO_CONFIG="vdotestconf.yml"
+VDOCONF="-f $VDO_CONFIG"
#VDOCONF=""
-export VDOCONF
+export VDOCONF VDO_CONFIG
VDONAME="${PREFIX}-TESTVDO"
+export DM_UUID_PREFIX=$PREFIX
# VDO automatically starts dmeventd
aux prepare_dmeventd
@@ -44,11 +46,11 @@ export MKE2FS_CONFIG="$TESTDIR/lib/mke2fs.conf"
aux have_vdo 6 2 0 || skip
-aux prepare_devs 2 10000
+aux prepare_devs 2 20000
aux extend_filter_LVMTEST
-
+export TMPDIR=$PWD
# Conversion can be made with this version of vdo driver
@@ -59,14 +61,16 @@ aux have_vdo 6 2 5 || skip
#
# In this case we do not need to move any VDO headers.
#
+if [ 1 -eq 0 ]; then
vgcreate $vg "$dev1"
lvcreate -L5G -n $lv1 $vg
+# use some not so 'well' aligned virtual|logical size
vdo create $VDOCONF --name "$VDONAME" --device "$DM_DEV_DIR/$vg/$lv1" --vdoSlabSize 128M --vdoLogicalSize 10G
mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME"
-
+##XXXXX
# Different VG name fails
not lvm_import_vdo -y -v --name $vg1/$lv1 "$DM_DEV_DIR/$vg/$lv1"
@@ -130,26 +134,25 @@ vdo create $VDOCONF --name "$VDONAME" --device "$dev1" --vdoSlabSize 128M --vdoL
mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME"
-lvm_import_vdo -y -v --name $vg1/$lv2 "$dev1"
+lvm_import_vdo --vdo-config "$VDO_CONFIG" -y -v --name $vg1/$lv2 "$dev1"
fsck -n "$DM_DEV_DIR/$vg1/$lv2"
vgremove -f $vg1
+fi
-aux teardown_devs
-
-
-# Check with some real non-DM device from system
-# this needs to dropping DM_DEV_DIR
+aux wipefs_a "$dev1"
-aux prepare_loop 60000 || skip
+# let's assume users with VDO target have 'new' enough version of stat too
+# otherwise use more universal code from lvm_vdo_import
+read major minor < <(stat -c '%Hr %Lr' $(readlink -e "$dev1"))
+dmsetup create "$PREFIX-vdotest" --table "0 30280004 linear $major:$minor 32"
-test -f LOOP
-LOOP=$(< LOOP)
-LOOP="${DM_DEV_DIR}/${LOOP##/dev/}"
+TEST="$DM_DEV_DIR/mapper/$PREFIX-vdotest"
-aux extend_filter "a|$LOOP|"
-aux extend_devices "$LOOP"
+aux wipefs_a "$TEST"
+aux extend_filter "a|$TEST|"
+aux extend_devices "$TEST"
#
# Unfortunatelly generates this in syslog:
@@ -165,7 +168,9 @@ aux extend_devices "$LOOP"
#
# automate...
#
-vdo create $VDOCONF --name "$VDONAME" --device "$LOOP" --vdoSlabSize 128M --vdoLogicalSize 23G\
+
+# use slightly smaller size then 'rounded' 23G - to enforce vdo_logicalSize rounding
+vdo create $VDOCONF --name "$VDONAME" --device "$TEST" --vdoSlabSize 128M --vdoLogicalSize 24117240K\
--blockMapCacheSize 192 \
--blockMapPeriod 2048 \
--emulate512 disabled \
@@ -179,19 +184,39 @@ vdo create $VDOCONF --name "$VDONAME" --device "$LOOP" --vdoSlabSize 128M --vdoL
--vdoHashZoneThreads 3 \
--vdoLogicalThreads 3 \
--writePolicy async-unsafe
+dmsetup table
# Get VDO table line
dmsetup table "$VDONAME" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee vdo-orig
+# For conversion we
aux lvmconf 'global/vdo_disabled_features = [ "version4" ]'
-lvm_import_vdo -y --name $vg/$lv "$LOOP"
-lvs -a $vg
+#
+# Try to prepare 'broken' case where header was moved by older tool to 2M position
+#
+export LVM_VDO_PREPARE=oldvdoprepareforlvm2M
+if which "$LVM_VDO_PREPARE" ; then
+# Use old vdoprepareforlvm tool, that always moves header to 2M offset
+cp "$VDO_CONFIG" "$VDO_CONFIG.backup"
+lvm_import_vdo --abort-after-vdo-convert --vdo-config "$VDO_CONFIG" -v -y --name $vg/$lv "$TEST"
+# Restore VDO configuration (as it's been removed with succeful vdo conversion
+cp "$VDO_CONFIG.backup" "$VDO_CONFIG"
+# Check VDO header is seen at 2M offset
+blkid -c /dev/null --probe --offset 2M "$TEST"
+fi
+unset LVM_VDO_PREPARE
+
+#lvm_import_vdo --no-snapshot --vdo-config "$VDO_CONFIG" -v -y --name $vg/$lv "$TEST"
+lvm_import_vdo --vdo-config "$VDO_CONFIG" --uuid-prefix "$PREFIX" -v -y --name $vg/$lv "$TEST"
+# Compare converted LV uses same VDO table line
dmsetup table "$vg-${lv}_vpool-vpool" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee new-vdo-lv
# Check there is a match between VDO and LV managed volume
# (when differentiating parameters are deleted first)
diff -u vdo-orig new-vdo-lv || die "Found mismatching VDO table lines!"
-check lv_field $vg/$lv size "23.00g"
+check lv_field $vg/$lv size "<23.00g"
+unset LVM_VDO_PREPARE
+
11 months, 4 weeks
main - tests: vdo manager wrapper tool updates
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7f661a24c4f7fa8f161...
Commit: 7f661a24c4f7fa8f161f17da093e456f0d60e106
Parent: 734d9791f817693f1d6f396b34d105894aacb16c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 9 13:24:56 2023 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jun 9 18:01:16 2023 +0200
tests: vdo manager wrapper tool updates
Support size specification in KiB units.
Add some theoretical support for some new options from vdoprepareforlvm.
---
test/lib/lvm_vdo_wrapper.sh | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/test/lib/lvm_vdo_wrapper.sh b/test/lib/lvm_vdo_wrapper.sh
index bcc3781f7..83332561a 100755
--- a/test/lib/lvm_vdo_wrapper.sh
+++ b/test/lib/lvm_vdo_wrapper.sh
@@ -11,7 +11,7 @@ LVM_VDO_FORMAT=${LVM_VDO_FORMAT-"oldvdoformat"}
# tool for shifting VDO metadata header by 2MiB
LVM_VDO_PREPARE=${LVM_VDO_PREPARE-"oldvdoprepareforlvm"}
# default vdo conf file
-LVM_VDO_DEFAULT_CONF=${LVM_VDO_DEFAULT_CONF-"/tmp/vdoconf.yml"}
+LVM_VDO_DEFAULT_CONF=${LVM_VDO_DEFAULT_CONF-"${TMPDIR:-/tmp}/vdoconf.yml"}
vdo_die_() {
echo -e "$@" >&2
@@ -39,6 +39,7 @@ vdo_get_kb_size_with_unit_() {
esac
case "$1" in
+ *[kK]) sz=1 ;;
*[mM]) sz=1024 ;;
*[gG]) sz=$(( 1024 * 1024 )) ;;
*[tT]) sz=$(( 1024 * 1024 * 1024 )) ;;
@@ -320,6 +321,10 @@ local vdo_force=
local vdo_name=
local vdo_verbose=
local vdo_device=
+local vdo_dry_run=
+local vdo_check=
+local vdo_version=
+local vdo_help=
while [ "$#" -ne 0 ]
do
@@ -328,6 +333,10 @@ do
"--name"|"-n") shift; vdo_name=$1 ;;
"--verbose"|"-d"|"--debug") vdo_verbose="-v" ;;
"--force") vdo_force="--force" ;;
+ "--dry-run") vdo_dry_run="--dry-run" ;;
+ "--check") vdo_check="--check" ;;
+ "--version") vdo_version="--version" ;;
+ "--help") vdo_help="--help" ;;
esac
shift
done
@@ -339,7 +348,7 @@ vdo_device=$(awk -v vdovolname="$vdo_name" 'BEGIN { have=0 }
"$vdo_confFile")
#dmsetup status --target vdo "$vdo_name" || true
-vdo_dry_ "$LVM_VDO_PREPARE" "$vdo_device"
+vdo_dry_ "$LVM_VDO_PREPARE" $vdo_dry_run $vdo_check $vdo_version $vdo_help "$vdo_device"
vdo_dry_ vdo_remove_ -f "$vdo_confFile" -n "$vdo_name" || true
}
11 months, 4 weeks
main - tests: tmp dir inside test dir
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=734d9791f817693f1d6...
Commit: 734d9791f817693f1d6f396b34d105894aacb16c
Parent: 4d648380484ecf58c33f92a84950bb0bf39424ef
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 29 14:17:43 2023 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jun 9 18:01:16 2023 +0200
tests: tmp dir inside test dir
Keep even temporary files within testing dir so generated files are
not left behind in system's /tmp directory.
---
test/lib/inittest.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 9f2713062..c41f4c5b4 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -106,7 +106,7 @@ else
fi
cd "$TESTDIR"
-mkdir lib
+mkdir lib tmp
# Setting up symlink from $i to $TESTDIR/lib
test -n "${abs_top_builddir+varset}" && \
@@ -118,6 +118,7 @@ find "$TESTOLDPWD/lib" ! \( -name '*.sh' -o -name '*.[cdo]' \
DM_DEFAULT_NAME_MANGLING_MODE=none
DM_DEV_DIR="$TESTDIR/dev"
LVM_SYSTEM_DIR="$TESTDIR/etc"
+TMPDIR="$TESTDIR/tmp"
# abort on the internal dm errors in the tests (allowing test user override)
DM_ABORT_ON_INTERNAL_ERRORS=${DM_ABORT_ON_INTERNAL_ERRORS:-1}
DM_DEBUG_WITH_LINE_NUMBERS=${DM_DEBUG_WITH_LINE_NUMBERS:-1}
11 months, 4 weeks