Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ea6b5b694bf0886052b04…
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.
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7c3eca833ff7878d6d321…
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;
}