main - Revert "makefiles: fix grep warning from make"
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=49c650423a17197c66b...
Commit: 49c650423a17197c66b1c839a0274db8fba9a7d9
Parent: ed808a9b548ca59221d512bfb7ae581e8367fe50
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Wed Jan 25 09:46:18 2023 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Wed Jan 25 09:46:18 2023 +0100
Revert "makefiles: fix grep warning from make"
This reverts commit 92199ad0b98586182a52e2f8cd82c06336e306f1.
This breaks make rpm.
---
udev/Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/udev/Makefile.in b/udev/Makefile.in
index ac4de0a6a..e777dda16 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -20,7 +20,7 @@ include $(top_builddir)/make.tmpl
DM_RULES=10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
LVM_RULES=11-dm-lvm.rules 69-dm-lvm.rules
-DM_DIR=$(shell $(GREP) "#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | $(AWK) '{print $$3}')
+DM_DIR=$(shell $(GREP) "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | $(AWK) '{print $$3}')
BINDIR=@bindir@
ifeq ("@UDEV_RULE_EXEC_DETECTION@", "yes")
1 year, 2 months
main - lvresize: enable crypt resizing with --force
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ed808a9b548ca59221d...
Commit: ed808a9b548ca59221d512bfb7ae581e8367fe50
Parent: 3bb55765286dc8e4f0000957d85a6b8ee2752852
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jan 20 11:56:40 2023 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jan 20 12:04:55 2023 -0600
lvresize: enable crypt resizing with --force
Update previous commit
"lvresize: only resize crypt when fs resize is enabled"
to enable crypt resizing when --force is set and --resizefs
is not set. This is because it's been allowed in the past
and people have used it, but it's not a good idea.
---
lib/metadata/lv_manip.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index cfb118f11..f06b08254 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6417,9 +6417,13 @@ static int _fs_reduce(struct cmd_context *cmd, struct logical_volume *lv,
goto out;
}
if (!strcmp(lp->fsopt, "checksize")) {
- log_error("crypt reduce is required (see --resizefs or cryptsetup resize.)");
- ret = 0;
- goto out;
+ if (!lp->force) {
+ log_error("crypt reduce is required (see --resizefs or cryptsetup resize.)");
+ ret = 0;
+ goto out;
+ }
+ /* This is only because it has been allowed in the past. */
+ log_print("Forcing cryptsetup resize (--resizefs preferred.)");
}
if (test_mode()) {
ret = 1;
1 year, 2 months
main - lvresize: only resize crypt when fs resize is enabled
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3bb55765286dc8e4f00...
Commit: 3bb55765286dc8e4f0000957d85a6b8ee2752852
Parent: 92199ad0b98586182a52e2f8cd82c06336e306f1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 19 11:36:51 2023 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jan 19 11:52:14 2023 -0600
lvresize: only resize crypt when fs resize is enabled
There were a couple of cases where lvresize, without --fs resize,
was resizing the crypt layer above the LV. Resizing the crypt
layer should only be done when fs resizing is enabled (even if the
fs is already small enough due to being independently reduced.)
Also, check the size of the crypt device to see if it's already
been reduced independently, and skip the cryptsetup resize if
it's not needed.
---
lib/device/filesystem.c | 13 +++++++++++++
lib/device/filesystem.h | 1 +
lib/metadata/lv_manip.c | 18 +++++++++++++++++-
test/shell/lvresize-fs-crypt.sh | 7 ++++++-
4 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/lib/device/filesystem.c b/lib/device/filesystem.c
index 61e4d805e..b4c43a626 100644
--- a/lib/device/filesystem.c
+++ b/lib/device/filesystem.c
@@ -22,6 +22,7 @@
#include <dirent.h>
#include <mntent.h>
+#include <sys/ioctl.h>
static const char *_lvresize_fs_helper_path;
@@ -105,6 +106,7 @@ int fs_get_info(struct cmd_context *cmd, struct logical_volume *lv,
struct fs_info info;
FILE *fme = NULL;
struct mntent *me;
+ int fd;
int ret;
if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", lv->vg->cmd->dev_dir,
@@ -150,6 +152,17 @@ int fs_get_info(struct cmd_context *cmd, struct logical_volume *lv,
log_print("File system found on crypt device %s on LV %s.",
crypt_path, display_lvname(lv));
+ if ((fd = open(crypt_path, O_RDONLY)) < 0) {
+ log_error("Failed to open crypt path %s", crypt_path);
+ return 0;
+ }
+ if (ioctl(fd, BLKGETSIZE64, &info.crypt_dev_size_bytes) < 0) {
+ log_error("Failed to get crypt device size %s", crypt_path);
+ close(fd);
+ return 0;
+ }
+ close(fd);
+
if (!fs_get_blkid(crypt_path, &info)) {
log_error("No file system info from blkid for dm-crypt device %s on LV %s.",
crypt_path, display_lvname(lv));
diff --git a/lib/device/filesystem.h b/lib/device/filesystem.h
index 7a34d2ae0..fd1af0416 100644
--- a/lib/device/filesystem.h
+++ b/lib/device/filesystem.h
@@ -25,6 +25,7 @@ struct fs_info {
uint64_t fs_last_byte; /* last byte on the device used by the fs */
uint32_t crypt_offset_bytes; /* offset in bytes of crypt data on LV */
dev_t crypt_devt; /* dm-crypt device between the LV and FS */
+ uint64_t crypt_dev_size_bytes;
unsigned nofs:1;
unsigned unmounted:1;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index cb7f26069..cfb118f11 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6408,7 +6408,23 @@ static int _fs_reduce(struct cmd_context *cmd, struct logical_volume *lv,
* but the crypt dev over the LV should be shrunk to correspond with
* the LV size, so that the FS does not see an incorrect device size.
*/
- if (!fsinfo.needs_reduce && fsinfo.needs_crypt && !test_mode()) {
+ if (!fsinfo.needs_reduce && fsinfo.needs_crypt) {
+ /* Check if the crypt device is already sufficiently reduced. */
+ if (fsinfo.crypt_dev_size_bytes <= newsize_bytes_fs) {
+ log_print("crypt device is already reduced to %llu bytes.",
+ (unsigned long long)fsinfo.crypt_dev_size_bytes);
+ ret = 1;
+ goto out;
+ }
+ if (!strcmp(lp->fsopt, "checksize")) {
+ log_error("crypt reduce is required (see --resizefs or cryptsetup resize.)");
+ ret = 0;
+ goto out;
+ }
+ if (test_mode()) {
+ ret = 1;
+ goto_out;
+ }
ret = crypt_resize_script(cmd, lv, &fsinfo, newsize_bytes_fs);
goto out;
}
diff --git a/test/shell/lvresize-fs-crypt.sh b/test/shell/lvresize-fs-crypt.sh
index 61a6de022..4bef771dc 100644
--- a/test/shell/lvresize-fs-crypt.sh
+++ b/test/shell/lvresize-fs-crypt.sh
@@ -151,7 +151,12 @@ mount /dev/mapper/$cr "$mount_dir"
# this lvresize will not resize the fs (which is already reduced
# to smaller than the requested LV size), but lvresize will use
# the helper to resize the crypt dev before resizing the LV.
-lvresize -L-100M $vg/$lv
+# Using --fs resize is required to allow lvresize to look above
+# the lv at crypt&fs layers for potential resizing. Without
+# --fs resize, lvresize fails because it sees that crypt resize
+# is needed and --fs resize is needed to enable that.
+not lvresize -L-100 $vg/$lv
+lvresize -L-100M --fs resize $vg/$lv
check lv_field $vg/$lv lv_size "356.00m"
df --output=size "$mount_dir" |tee df2
not diff df1 df2
1 year, 2 months
main - makefiles: fix grep warning from make
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=92199ad0b98586182a5...
Commit: 92199ad0b98586182a52e2f8cd82c06336e306f1
Parent: 3a58e08b8c1ef8b988a588301e097f50c843f0aa
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jan 15 21:42:41 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 16 12:37:40 2023 +0100
makefiles: fix grep warning from make
Remove unnecessary '\'.
---
udev/Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/udev/Makefile.in b/udev/Makefile.in
index e777dda16..ac4de0a6a 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -20,7 +20,7 @@ include $(top_builddir)/make.tmpl
DM_RULES=10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
LVM_RULES=11-dm-lvm.rules 69-dm-lvm.rules
-DM_DIR=$(shell $(GREP) "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | $(AWK) '{print $$3}')
+DM_DIR=$(shell $(GREP) "#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | $(AWK) '{print $$3}')
BINDIR=@bindir@
ifeq ("@UDEV_RULE_EXEC_DETECTION@", "yes")
1 year, 3 months
main - makefiles: comment out hiding dir entering
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3a58e08b8c1ef8b988a...
Commit: 3a58e08b8c1ef8b988a588301e097f50c843f0aa
Parent: 3bedceec3882e00caf62df6fbeb946aeafea9df2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 12 16:52:01 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 16 12:37:40 2023 +0100
makefiles: comment out hiding dir entering
While the output of building looks more polished, text editors fail to
find source file from compile errors - so until we start to print
all file with full paths - comment out this make build parameter.
---
make.tmpl.in | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index e942893a0..222ed671a 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -182,9 +182,10 @@ ifndef MAKEFLAGS
MAKEFLAGS = @JOBS@
endif
-ifneq (1, $(firstword $(V)))
-MAKEFLAGS += --no-print-directory
-endif
+# Hiding dir entering makes hard for editors to look for files
+#ifneq (1, $(firstword $(V)))
+#MAKEFLAGS += --no-print-directory
+#endif
# Handle installation of files
ifeq ("@WRITE_INSTALL@", "yes")
1 year, 3 months
main - libdm: correcting ifdef possition
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3bedceec3882e00caf6...
Commit: 3bedceec3882e00caf62df6fbeb946aeafea9df2
Parent: aa09232dc4fb825f4e643bbe87a95e2318dd5a93
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jan 15 21:42:13 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 16 12:37:40 2023 +0100
libdm: correcting ifdef possition
Fix building without ioctl support.
---
device_mapper/ioctl/libdm-iface.c | 4 +++-
libdm/ioctl/libdm-iface.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c
index 738807f8f..d25b07800 100644
--- a/device_mapper/ioctl/libdm-iface.c
+++ b/device_mapper/ioctl/libdm-iface.c
@@ -139,7 +139,6 @@ static char *_align(char *ptr, unsigned int a)
return (char *) (((unsigned long) ptr + agn) & ~agn);
}
-#ifdef DM_IOCTLS
static unsigned _kernel_major = 0;
static unsigned _kernel_minor = 0;
static unsigned _kernel_release = 0;
@@ -182,6 +181,9 @@ int get_uname_version(unsigned *major, unsigned *minor, unsigned *release)
return 1;
}
+
+#ifdef DM_IOCTLS
+
/*
* Set number to NULL to populate _dm_bitset - otherwise first
* match is returned.
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 0fba79ce4..dfa91b866 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -138,7 +138,6 @@ static char *_align(char *ptr, unsigned int a)
return (char *) (((unsigned long) ptr + agn) & ~agn);
}
-#ifdef DM_IOCTLS
static unsigned _kernel_major = 0;
static unsigned _kernel_minor = 0;
static unsigned _kernel_release = 0;
@@ -181,6 +180,9 @@ int get_uname_version(unsigned *major, unsigned *minor, unsigned *release)
return 1;
}
+
+#ifdef DM_IOCTLS
+
/*
* Set number to NULL to populate _dm_bitset - otherwise first
* match is returned.
1 year, 3 months
main - tests: vdo resizing
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=aa09232dc4fb825f4e6...
Commit: aa09232dc4fb825f4e643bbe87a95e2318dd5a93
Parent: c20f01a0cbb24e8276734a00f26a510cf6daaf21
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 16 01:11:37 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 16 12:37:40 2023 +0100
tests: vdo resizing
---
test/shell/lvresize-vdo.sh | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/test/shell/lvresize-vdo.sh b/test/shell/lvresize-vdo.sh
index 6fe0e9c26..cbe8ce967 100644
--- a/test/shell/lvresize-vdo.sh
+++ b/test/shell/lvresize-vdo.sh
@@ -32,4 +32,19 @@ check lv_field $vg/${lv2}_vdata size "6.00g"
lvresize -L6G $vg/$lv1
check lv_field $vg/$lv1 size "6.00g"
+# Check too large size
+not lvresize -L4P $vg/$lv1 2>err
+grep "Volume too large" err
+
+# Can't resize inactive VDO
+lvchange -an $vg
+not lvresize -L10G $vg/$lv1 2>err
+grep "Cannot resize inactive" err
+
+not lvresize -L10G $vg/$lv2 2>err
+grep "Cannot resize inactive" err
+
+not lvresize -L10G $vg/${lv2}_vdata 2>err
+grep "Cannot resize inactive" err
+
vgremove -ff $vg
1 year, 3 months
main - vdo: resize requires active vdopool volume
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c20f01a0cbb24e82767...
Commit: c20f01a0cbb24e8276734a00f26a510cf6daaf21
Parent: 2451bc568feb9b3d0cb4d7c15e3c723f4d0c8cc9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jan 15 21:27:57 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 16 12:37:40 2023 +0100
vdo: resize requires active vdopool volume
ATM kernel VDO target does not handle resize of inactive VDO LVs
so prevent users corrupting such LVs and require active such LVs.
---
lib/metadata/lv_manip.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 305be8578..cb7f26069 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5954,6 +5954,16 @@ static int _lv_resize_check_used(struct logical_volume *lv)
return 0;
}
+ if (lv_is_vdo(lv) && !lv_is_active(lv)) {
+ log_error("Cannot resize inactive VDO logical volume %s.", display_lvname(lv));
+ return 0;
+ }
+
+ if (lv_is_vdo_pool(lv) && !lv_is_active(lv_lock_holder(lv))) {
+ log_error("Cannot resize inactive VDO POOL volume %s.", display_lvname(lv));
+ return 0;
+ }
+
if (lv_is_external_origin(lv)) {
/*
* Since external-origin can be activated read-only,
1 year, 3 months
main - vdo: fix and enhance vdo constain checking
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2451bc568feb9b3d0cb...
Commit: 2451bc568feb9b3d0cb4d7c15e3c723f4d0c8cc9
Parent: 1bed2cafe83096cf01cfff5cd2cd64ecb32b7d78
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jan 15 21:27:37 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 16 12:37:40 2023 +0100
vdo: fix and enhance vdo constain checking
Enhance checking vdo constains so it also handles changes of active VDO LVs
where only added difference is considered now.
For this also the reported informational message about used memory
was improved to only list consuming RAM blocks.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 4 +--
lib/metadata/vdo_manip.c | 77 ++++++++++++++++++++++++++++++----------
lib/vdo/vdo.c | 24 +++++++++++--
tools/lvcreate.c | 8 +++--
5 files changed, 89 insertions(+), 25 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 357203a4d..191338868 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
version 2.03.19 -
====================================
+ Fix and improve runtime memory size detection for VDO volumes.
version 2.03.18 - 22nd december 2022
====================================
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 7c481905a..a27345781 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1382,8 +1382,8 @@ struct vdo_pool_size_config {
uint32_t block_map_cache_size_mb;
uint32_t index_memory_size_mb;
};
-int check_vdo_constrains(struct cmd_context *cmd, uint64_t physical_size,
- uint64_t virtual_size, struct dm_vdo_target_params *vtp);
+
+int check_vdo_constrains(struct cmd_context *cmd, const struct vdo_pool_size_config *cfg);
/* -- metadata/vdo_manip.c */
struct logical_volume *find_pvmove_lv(struct volume_group *vg,
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index b73d40d2c..19291c9d6 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -24,6 +24,7 @@
#include "lib/misc/lvm-exec.h"
#include <sys/sysinfo.h> // sysinfo
+#include <stdarg.h>
const char *get_vdo_compression_state_name(enum dm_vdo_compression_state state)
{
@@ -647,39 +648,76 @@ static uint64_t _round_sectors_to_tib(uint64_t s)
return (s + ((UINT64_C(1) << (40 - SECTOR_SHIFT)) - 1)) >> (40 - SECTOR_SHIFT);
}
-int check_vdo_constrains(struct cmd_context *cmd, uint64_t physical_size,
- uint64_t virtual_size, struct dm_vdo_target_params *vtp)
+__attribute__ ((format(printf, 3, 4)))
+static int _vdo_snprintf(char **buf, size_t *bufsize, const char *format, ...)
{
+ int n;
+ va_list ap;
+
+ va_start(ap, format);
+ n = vsnprintf(*buf, *bufsize, format, ap);
+ va_end(ap);
+
+ if (n < 0 || ((unsigned) n >= *bufsize))
+ return -1;
+
+ *buf += n;
+ *bufsize -= n;
+
+ return n;
+}
+
+int check_vdo_constrains(struct cmd_context *cmd, const struct vdo_pool_size_config *cfg)
+{
+ static const char *_split[] = { "", " and", ",", "," };
uint64_t req_mb, total_mb, available_mb;
- uint64_t phy_mb = _round_sectors_to_tib(UINT64_C(268) * physical_size); // 268 MiB per 1 TiB of physical size
- uint64_t virt_mb = _round_1024(UINT64_C(1638) * _round_sectors_to_tib(virtual_size)); // 1.6 MiB per 1 TiB
- uint64_t cache_mb = _round_1024(UINT64_C(1177) * vtp->block_map_cache_size_mb); // 1.15 MiB per 1 MiB cache size
+ uint64_t phy_mb = _round_sectors_to_tib(UINT64_C(268) * cfg->physical_size); // 268 MiB per 1 TiB of physical size
+ uint64_t virt_mb = _round_1024(UINT64_C(1638) * _round_sectors_to_tib(cfg->virtual_size)); // 1.6 MiB per 1 TiB
+ uint64_t cache_mb = _round_1024(UINT64_C(1177) * cfg->block_map_cache_size_mb); // 1.15 MiB per 1 MiB cache size
char msg[512];
+ size_t mlen = sizeof(msg);
+ char *pmsg = msg;
+ int cnt, has_cnt;
- if (cache_mb < 150)
+ if (cfg->block_map_cache_size_mb && (cache_mb < 150))
cache_mb = 150; // always at least 150 MiB for block map
// total required memory for VDO target
- req_mb = 38 + vtp->index_memory_size_mb + virt_mb + phy_mb + cache_mb;
+ req_mb = 38 + cfg->index_memory_size_mb + virt_mb + phy_mb + cache_mb;
_get_memory_info(&total_mb, &available_mb);
- (void)snprintf(msg, sizeof(msg), "VDO configuration needs %s RAM for physical volume size %s, "
- "%s RAM for virtual volume size %s, %s RAM for block map cache size %s and "
- "%s RAM for index memory.",
- display_size(cmd, phy_mb << (20 - SECTOR_SHIFT)),
- display_size(cmd, physical_size),
- display_size(cmd, virt_mb << (20 - SECTOR_SHIFT)),
- display_size(cmd, virtual_size),
- display_size(cmd, cache_mb << (20 - SECTOR_SHIFT)),
- display_size(cmd, ((uint64_t)vtp->block_map_cache_size_mb) << (20 - SECTOR_SHIFT)),
- display_size(cmd, ((uint64_t)vtp->index_memory_size_mb) << (20 - SECTOR_SHIFT)));
+ has_cnt = cnt = (phy_mb ? 1 : 0) +
+ (virt_mb ? 1 : 0) +
+ (cfg->block_map_cache_size_mb ? 1 : 0) +
+ (cfg->index_memory_size_mb ? 1 : 0);
+
+ if (phy_mb)
+ (void)_vdo_snprintf(&pmsg, &mlen, " %s RAM for physical volume size %s%s",
+ display_size(cmd, phy_mb << (20 - SECTOR_SHIFT)),
+ display_size(cmd, cfg->physical_size), _split[--cnt]);
+
+ if (virt_mb)
+ (void)_vdo_snprintf(&pmsg, &mlen, " %s RAM for virtual volume size %s%s",
+ display_size(cmd, virt_mb << (20 - SECTOR_SHIFT)),
+ display_size(cmd, cfg->virtual_size), _split[--cnt]);
+
+ if (cfg->block_map_cache_size_mb)
+ (void)_vdo_snprintf(&pmsg, &mlen, " %s RAM for block map cache size %s%s",
+ display_size(cmd, cache_mb << (20 - SECTOR_SHIFT)),
+ display_size(cmd, ((uint64_t)cfg->block_map_cache_size_mb) << (20 - SECTOR_SHIFT)),
+ _split[--cnt]);
+
+ if (cfg->index_memory_size_mb)
+ (void)_vdo_snprintf(&pmsg, &mlen, " %s RAM for index memory",
+ display_size(cmd, ((uint64_t)cfg->index_memory_size_mb) << (20 - SECTOR_SHIFT)));
if (req_mb > available_mb) {
log_error("Not enough free memory for VDO target. %s RAM is required, but only %s RAM is available.",
display_size(cmd, req_mb << (20 - SECTOR_SHIFT)),
display_size(cmd, available_mb << (20 - SECTOR_SHIFT)));
- log_print_unless_silent("%s", msg);
+ if (has_cnt)
+ log_print_unless_silent("VDO configuration needs%s.", msg);
return 0;
}
@@ -687,7 +725,8 @@ int check_vdo_constrains(struct cmd_context *cmd, uint64_t physical_size,
display_size(cmd, req_mb << (20 - SECTOR_SHIFT)),
display_size(cmd, available_mb << (20 - SECTOR_SHIFT)));
- log_verbose("%s", msg);
+ if (has_cnt)
+ log_verbose("VDO configuration needs%s.", msg);
return 1;
}
diff --git a/lib/vdo/vdo.c b/lib/vdo/vdo.c
index d2d14d146..133678ae7 100644
--- a/lib/vdo/vdo.c
+++ b/lib/vdo/vdo.c
@@ -355,6 +355,27 @@ static int _vdo_pool_target_status_compatible(const char *type)
return (strcmp(type, TARGET_NAME_VDO) == 0);
}
+static int _vdo_check(struct cmd_context *cmd, const struct lv_segment *seg)
+{
+
+ struct vdo_pool_size_config cfg = { 0 };
+
+ if (!lv_vdo_pool_size_config(seg->lv, &cfg))
+ return_0;
+
+ /* Check if we are just adding more size to the already running vdo pool */
+ if (seg->lv->size >= cfg.physical_size)
+ cfg.physical_size = seg->lv->size - cfg.physical_size;
+ if (get_vdo_pool_virtual_size(seg) >= cfg.virtual_size)
+ cfg.virtual_size = get_vdo_pool_virtual_size(seg) - cfg.virtual_size;
+ if (seg->vdo_params.block_map_cache_size_mb >= cfg.block_map_cache_size_mb)
+ cfg.block_map_cache_size_mb = seg->vdo_params.block_map_cache_size_mb - cfg.block_map_cache_size_mb;
+ if (seg->vdo_params.index_memory_size_mb >= cfg.index_memory_size_mb)
+ cfg.index_memory_size_mb = seg->vdo_params.index_memory_size_mb - cfg.index_memory_size_mb;
+
+ return check_vdo_constrains(cmd, &cfg);
+}
+
static int _vdo_pool_add_target_line(struct dev_manager *dm,
struct dm_pool *mem,
struct cmd_context *cmd,
@@ -375,8 +396,7 @@ static int _vdo_pool_add_target_line(struct dev_manager *dm,
return 0;
}
- if (!critical_section() &&
- !check_vdo_constrains(cmd, seg->lv->size, get_vdo_pool_virtual_size(seg), &seg->vdo_params))
+ if (!critical_section() && !_vdo_check(cmd, seg))
return_0;
if (!(vdo_pool_name = dm_build_dm_name(mem, seg->lv->vg->name, seg->lv->name, lv_layer(seg->lv))))
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 3c89fd2c1..06d24430f 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1762,8 +1762,12 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
if (!_update_extents_params(vg, lp, lcp))
goto_out;
- if (seg_is_vdo(lp) && !check_vdo_constrains(cmd, (uint64_t)lp->extents * vg->extent_size,
- lcp->virtual_size, &lp->vdo_params))
+ if (seg_is_vdo(lp) &&
+ !check_vdo_constrains(cmd, &(struct vdo_pool_size_config) {
+ .physical_size = (uint64_t)lp->extents * vg->extent_size,
+ .virtual_size = lcp->virtual_size,
+ .block_map_cache_size_mb = lp->vdo_params.block_map_cache_size_mb,
+ .index_memory_size_mb = lp->vdo_params.index_memory_size_mb }))
goto_out;
if (seg_is_thin(lp) && !_validate_internal_thin_processing(lp))
1 year, 3 months
main - vdo: read live vdo size configuration
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1bed2cafe83096cf01c...
Commit: 1bed2cafe83096cf01cfff5cd2cd64ecb32b7d78
Parent: 773b88e028ab2965a8c185f5f2147334f8f2bbfd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jan 15 21:24:28 2023 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 16 12:37:40 2023 +0100
vdo: read live vdo size configuration
Introduce struct vdo_pool_size_config usable to calculate necessary
memory size for active VDO volume.
Function lv_vdo_pool_size_config() is able to read out this
configuration out of runtime DM table line.
---
lib/activate/activate.c | 31 +++++++++++++++++++
lib/activate/activate.h | 2 ++
lib/activate/dev_manager.c | 65 ++++++++++++++++++++++++++++++++++++++++
lib/activate/dev_manager.h | 3 ++
lib/metadata/metadata-exported.h | 6 ++++
5 files changed, 107 insertions(+)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 2f3c231cc..d6c1eca2f 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -322,6 +322,11 @@ int lv_vdo_pool_percent(const struct logical_volume *lv, dm_percent_t *percent)
{
return 0;
}
+int lv_vdo_pool_size_config(const struct logical_volume *lv,
+ struct vdo_pool_size_config *cfg)
+{
+ return 0;
+}
int lvs_in_vg_activated(const struct volume_group *vg)
{
return 0;
@@ -1363,6 +1368,32 @@ int lv_vdo_pool_percent(const struct logical_volume *lv, dm_percent_t *percent)
return 1;
}
+/*
+ * lv_vdo_pool_size_config obtains size configuration from active VDO table line
+ *
+ * If the 'params' string has been already retrieved, use it.
+ * If the mempool already exists, use it.
+ *
+ */
+int lv_vdo_pool_size_config(const struct logical_volume *lv,
+ struct vdo_pool_size_config *cfg)
+{
+ struct dev_manager *dm;
+ int r;
+
+ if (!lv_info(lv->vg->cmd, lv, 1, NULL, 0, 0))
+ return 1; /* Inactive VDO pool -> no runtime config */
+
+ if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, !lv_is_pvmove(lv))))
+ return_0;
+
+ r = dev_manager_vdo_pool_size_config(dm, lv, cfg);
+
+ dev_manager_destroy(dm);
+
+ return r;
+}
+
static int _lv_active(struct cmd_context *cmd, const struct logical_volume *lv)
{
struct lvinfo info;
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index a276b48a7..e550ec5b0 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -204,6 +204,8 @@ int lv_thin_pool_status(const struct logical_volume *lv, int flush,
int lv_vdo_pool_status(const struct logical_volume *lv, int flush,
struct lv_status_vdo **status);
int lv_vdo_pool_percent(const struct logical_volume *lv, dm_percent_t *percent);
+int lv_vdo_pool_size_config(const struct logical_volume *lv,
+ struct vdo_pool_size_config *cfg);
/*
* Return number of LVs in the VG that are active.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index cafb94ad5..689305f7b 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1957,6 +1957,71 @@ out:
return r;
}
+int dev_manager_vdo_pool_size_config(struct dev_manager *dm,
+ const struct logical_volume *lv,
+ struct vdo_pool_size_config *cfg)
+{
+ const char *dlid;
+ struct dm_info info;
+ uint64_t start, length;
+ struct dm_task *dmt = NULL;
+ char *type = NULL;
+ char *params = NULL;
+ int r = 0;
+ unsigned version = 0;
+
+ memset(cfg, 0, sizeof(*cfg));
+
+ if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
+ return_0;
+
+ if (!(dmt = _setup_task_run(DM_DEVICE_TABLE, &info, NULL, dlid, 0, 0, 0, 0, 0, 0)))
+ return_0;
+
+ if (!info.exists)
+ goto inactive; /* VDO device is not active, should not happen here... */
+
+ log_debug_activation("Checking VDO pool table line for LV %s.",
+ display_lvname(lv));
+
+ if (dm_get_next_target(dmt, NULL, &start, &length, &type, ¶ms)) {
+ log_error("More then one table line found for %s.",
+ display_lvname(lv));
+ goto out;
+ }
+
+ if (!type || strcmp(type, TARGET_NAME_VDO)) {
+ log_error("Expected %s segment type but got %s instead.",
+ TARGET_NAME_VDO, type ? type : "NULL");
+ goto out;
+ }
+
+ if (sscanf(params, "V%u %*s " FMTu64 " %*u " FMTu32,
+ &version, &cfg->physical_size, &cfg->block_map_cache_size_mb) != 3) {
+ log_error("Failed to parse VDO parameters %s for LV %s.",
+ params, display_lvname(lv));
+ goto out;
+ }
+
+ switch (version) {
+ case 2: break;
+ case 4: break;
+ default: log_warn("WARNING: Unknown VDO table line version %u.", version);
+ }
+
+ cfg->virtual_size = length;
+ cfg->physical_size *= 8; // From 4K unit to 512B
+ cfg->block_map_cache_size_mb /= 256; // From 4K unit to MiB
+ cfg->index_memory_size_mb = first_seg(lv)->vdo_params.index_memory_size_mb; // Preserved
+
+inactive:
+ r = 1;
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
/*************************/
/* NEW CODE STARTS HERE */
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index b494e3eaf..59f45b6f1 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -83,6 +83,9 @@ int dev_manager_thin_pool_status(struct dev_manager *dm,
int dev_manager_vdo_pool_status(struct dev_manager *dm,
const struct logical_volume *lv, int flush,
struct lv_status_vdo **status, int *exists);
+int dev_manager_vdo_pool_size_config(struct dev_manager *dm,
+ const struct logical_volume *lv,
+ struct vdo_pool_size_config *cfg);
int dev_manager_suspend(struct dev_manager *dm, const struct logical_volume *lv,
struct lv_activate_opts *laopts, int lockfs, int flush_required);
int dev_manager_activate(struct dev_manager *dm, const struct logical_volume *lv,
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c7eaa5233..7c481905a 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1376,6 +1376,12 @@ int fill_vdo_target_params(struct cmd_context *cmd,
struct dm_vdo_target_params *vtp,
uint64_t *vdo_pool_header_size,
struct profile *profile);
+struct vdo_pool_size_config {
+ uint64_t physical_size;
+ uint64_t virtual_size;
+ uint32_t block_map_cache_size_mb;
+ uint32_t index_memory_size_mb;
+};
int check_vdo_constrains(struct cmd_context *cmd, uint64_t physical_size,
uint64_t virtual_size, struct dm_vdo_target_params *vtp);
/* -- metadata/vdo_manip.c */
1 year, 3 months