master - tests: aux fix testing for kvdo
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=246b0c444bfcea68fe6...
Commit: 246b0c444bfcea68fe6c6d7174e753ee08dd7d8f
Parent: 2cac4bfc150ea1e5459580e3bac4907446ea7f3a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jan 20 12:15:20 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
tests: aux fix testing for kvdo
---
test/lib/aux.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index a11eb3f..1e8f0de 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1410,6 +1410,7 @@ version_at_least() {
target_at_least() {
rm -f debug.log strace.log
case "$1" in
+ dm-vdo) modprobe "kvdo" || true ;;
dm-*) modprobe "$1" || true ;;
esac
5 years, 2 months
master - tests: update cache test
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2cac4bfc150ea1e5459...
Commit: 2cac4bfc150ea1e5459580e3bac4907446ea7f3a
Parent: 01cbdc4e673989c4d432e6bea8cde1f8f9e8cda5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Jan 20 12:11:04 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
tests: update cache test
Since migration_threshold is now protected to not be smaller
then 8*chunk_size - update tests to count with this modification.
---
test/shell/lvchange-cache.sh | 22 +++++++++++-----------
test/shell/lvcreate-cache.sh | 15 +++++++++------
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/test/shell/lvchange-cache.sh b/test/shell/lvchange-cache.sh
index 7e95f61..ab7c8b0 100644
--- a/test/shell/lvchange-cache.sh
+++ b/test/shell/lvchange-cache.sh
@@ -38,27 +38,27 @@ check lv_field $vg/corigin kernel_cache_policy "cleaner"
# device-mapper: space map common: index_check failed: blocknr 17179869216 != wanted 11
if aux have_cache 1 5 0 ; then
-lvchange --cachepolicy mq --cachesettings migration_threshold=333 $vg/corigin
+lvchange --cachepolicy mq --cachesettings migration_threshold=1333 $vg/corigin
# TODO once mq->smq happens we will get here some 0 for mq settings
check lv_field $vg/corigin kernel_cache_policy "mq"
-get lv_field $vg/corigin kernel_cache_settings | grep 'migration_threshold=333'
+get lv_field $vg/corigin kernel_cache_settings | grep 'migration_threshold=1333'
lvchange --refresh $vg/corigin
-get lv_field $vg/corigin kernel_cache_settings | grep 'migration_threshold=333'
+get lv_field $vg/corigin kernel_cache_settings | grep 'migration_threshold=1333'
lvchange -an $vg
lvchange -ay $vg
-get lv_field $vg/corigin kernel_cache_settings | grep 'migration_threshold=333'
+get lv_field $vg/corigin kernel_cache_settings | grep 'migration_threshold=1333'
-lvchange --cachesettings 'migration_threshold = 233 sequential_threshold = 13' $vg/corigin
+lvchange --cachesettings 'migration_threshold = 1233 sequential_threshold = 13' $vg/corigin
get lv_field $vg/corigin kernel_cache_settings | tee out
-grep 'migration_threshold=233' out
+grep 'migration_threshold=1233' out
if grep 'sequential_threshold=13' out ; then
-lvchange --cachesettings 'migration_threshold = 17' $vg/corigin
+lvchange --cachesettings 'migration_threshold = 1117' $vg/corigin
get lv_field $vg/corigin kernel_cache_settings | tee out
-grep 'migration_threshold=17' out
+grep 'migration_threshold=1117' out
grep 'sequential_threshold=13' out
lvchange --cachesettings 'migration_threshold = default' $vg/corigin
@@ -66,16 +66,16 @@ get lv_field $vg/corigin kernel_cache_settings | tee out
grep 'migration_threshold=2048' out
grep 'sequential_threshold=13' out
-lvchange --cachesettings 'migration_threshold = 233 sequential_threshold = 13 random_threshold = 1' $vg/corigin
+lvchange --cachesettings 'migration_threshold = 1233 sequential_threshold = 13 random_threshold = 1' $vg/corigin
lvchange --cachesettings 'random_threshold = default migration_threshold = default' $vg/corigin
get lv_field $vg/corigin kernel_cache_settings | tee out
grep 'migration_threshold=2048' out
grep 'sequential_threshold=13' out
grep 'random_threshold=4' out
-lvchange --cachesettings migration_threshold=233 --cachesettings sequential_threshold=13 --cachesettings random_threshold=1 $vg/corigin
+lvchange --cachesettings migration_threshold=1233 --cachesettings sequential_threshold=13 --cachesettings random_threshold=1 $vg/corigin
get lv_field $vg/corigin kernel_cache_settings | tee out
-grep 'migration_threshold=233' out
+grep 'migration_threshold=1233' out
grep 'sequential_threshold=13' out
grep 'random_threshold=1' out
diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh
index 010c06f..0663033 100644
--- a/test/shell/lvcreate-cache.sh
+++ b/test/shell/lvcreate-cache.sh
@@ -256,20 +256,23 @@ lvdisplay --maps $vg
lvremove -f $vg
+# migration_threshold is protected to not be smaller then 8*chunk_size
+# so even when user sets migration threshold to lower value,
+# activation will ensure the minimal size is preserved
lvcreate --type cache-pool -L10 $vg/cpool
-lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg --cachesettings migration_threshold=233
+lvcreate --type cache -l 1 --cachepool $vg/cpool -c 64k -n corigin $vg --cachesettings migration_threshold=233
dmsetup status | grep $vg
-dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 1024'
lvchange -an $vg
lvchange -ay $vg
-dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 1024'
lvremove -f $vg
-lvcreate --type cache-pool -L10 --cachepolicy mq --cachesettings migration_threshold=233 $vg/cpool
+lvcreate --type cache-pool -L10 --cachepolicy mq --cachesettings migration_threshold=1233 $vg/cpool
lvcreate --type cache -l 1 --cachepool $vg/cpool -n corigin $vg
dmsetup status | grep $vg
-dmsetup status | grep $vg-corigin | grep 'migration_threshold 233'
+dmsetup status | grep $vg-corigin | grep 'migration_threshold 1233'
lvremove -f $vg
@@ -281,7 +284,7 @@ lvremove -f $vg
# Creation of read-only cache pool is not supported
invalid lvcreate -pr --type cache-pool -l1 -n $vg/cpool
-# Atempt to use bigger chunk size then cache pool data size
+# Attempt to use bigger chunk size then cache pool data size
fail lvcreate -l 1 --type cache-pool --chunksize 16M $vg 2>out
grep "chunk size" out
5 years, 2 months
master - vdo: man documenting resize
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=01cbdc4e673989c4d43...
Commit: 01cbdc4e673989c4d432e6bea8cde1f8f9e8cda5
Parent: a16d914d34fff420c663ba34ac8dabfc4403de51
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 18 20:28:35 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
vdo: man documenting resize
---
man/lvmvdo.7_main | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/man/lvmvdo.7_main b/man/lvmvdo.7_main
index e789f7f..11ca3ac 100644
--- a/man/lvmvdo.7_main
+++ b/man/lvmvdo.7_main
@@ -219,6 +219,42 @@ Note: vdostats currently understands only /dev/mapper device names.
.fi
+.SS 4. Extending VDOPoolLV size
+
+Adding more space to hold VDO data and metadata can be made via
+extension of VDODataLV.
+
+Note: Size of VDOPoolLV cannot be reduced.
+
+.B lvextend -L+AddingSize VG/VDOPoolLV
+
+.I Example
+.br
+.nf
+# lvextend -L+50G vg/vdopool0
+# lvresize -L300G vg/vdopool1
+.fi
+
+.SS 4. Extending or reducing VDOLV size
+
+VDO LV can be extended or reduced as standard LV.
+
+Note: Reduction needs to process TRIM for reduced disk area
+to unmap used data blocks from VDOPoolLV and it may take
+a long time.
+
+.B lvextend -L+AddingSize VG/VDOLV
+.B lvreduce -L-ReducingSize VG/VDOLV
+
+.I Example
+.br
+.nf
+# lvextend -L+50G vg/vdo0
+# lvreduce -L-50G vg/vdo1
+# lvresize -L200G vg/vdo2
+.fi
+
+
.SH VDO Topics
.br
5 years, 2 months
master - cleanup: better naming
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a16d914d34fff420c66...
Commit: a16d914d34fff420c663ba34ac8dabfc4403de51
Parent: 08cabe9b83bcce59a5aabc100aad2cb61a7bac0c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 10 18:01:06 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
cleanup: better naming
---
lib/metadata/lv_manip.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d32bd24..7e542fe 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1852,21 +1852,21 @@ static void _init_alloc_parms(struct alloc_handle *ah,
/* Handles also stacking */
static int _setup_lv_size(struct logical_volume *lv, uint32_t extents)
{
- struct lv_segment *thin_pool_seg;
+ struct lv_segment *pool_seg;
lv->le_count = extents;
lv->size = (uint64_t) extents * lv->vg->extent_size;
if (lv_is_thin_pool_data(lv) ||
lv_is_vdo_pool_data(lv)) {
- if (!(thin_pool_seg = get_only_segment_using_this_lv(lv)))
+ if (!(pool_seg = get_only_segment_using_this_lv(lv)))
return_0;
- /* Update thin pool segment from the layered LV */
- thin_pool_seg->lv->le_count =
- thin_pool_seg->len =
- thin_pool_seg->area_len = lv->le_count;
- thin_pool_seg->lv->size = lv->size;
+ /* Update pool segment from the layered LV */
+ pool_seg->lv->le_count =
+ pool_seg->len =
+ pool_seg->area_len = lv->le_count;
+ pool_seg->lv->size = lv->size;
}
return 1;
5 years, 2 months
master - vdo: allow resize of VDO and VDO pool volumes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=08cabe9b83bcce59a5a...
Commit: 08cabe9b83bcce59a5aabc100aad2cb61a7bac0c
Parent: bd6709cec6ca9ecc2c5f4e5f7d587daee5bd8cd1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 10 18:00:06 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
vdo: allow resize of VDO and VDO pool volumes
Now with newer VDO kvdo target we can start to use standard mechanism
to enable resize of VDO volumes.
VDO pool can be grown.
Virtual volume grows on top of VDO pool when is not big enough.
Reduced VDOLV is calling discard for reduced areas - this can
take long time!
TODO: implement some pollable mechanism for out-of-lock TRIM.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 19 +++++++++++--------
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ba27b7d..06848ea 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
+ Support reszing for VDOPoolLV and VDOLV.
Improve -lXXX%VG modifier which improves cache segment estimation.
Ensure migration_threshold for cache is at least 8 chunks.
Restore missing man info lvcreate --zero for thin-pools.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 5418535..d32bd24 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1857,7 +1857,8 @@ static int _setup_lv_size(struct logical_volume *lv, uint32_t extents)
lv->le_count = extents;
lv->size = (uint64_t) extents * lv->vg->extent_size;
- if (lv_is_thin_pool_data(lv)) {
+ if (lv_is_thin_pool_data(lv) ||
+ lv_is_vdo_pool_data(lv)) {
if (!(thin_pool_seg = get_only_segment_using_this_lv(lv)))
return_0;
@@ -4902,12 +4903,6 @@ static int _lvresize_check(struct logical_volume *lv,
return 0;
}
- if (lv_is_vdo_type(lv)) {
- log_error("Resize of VDO type volume %s is not yet supported.",
- display_lvname(lv));
- return 0;
- }
-
if (lv_is_raid(lv) &&
lp->resize == LV_REDUCE) {
unsigned attrs;
@@ -4934,6 +4929,7 @@ static int _lvresize_check(struct logical_volume *lv,
if (!lv_is_visible(lv) &&
!lv_is_thin_pool_metadata(lv) &&
+ !lv_is_vdo_pool_data(lv) &&
!lv_is_lockd_sanlock_lv(lv)) {
log_error("Can't resize internal logical volume %s.", display_lvname(lv));
return 0;
@@ -4967,6 +4963,8 @@ static int _lvresize_check(struct logical_volume *lv,
(lv_is_thin_pool(lv) ||
lv_is_thin_pool_data(lv) ||
lv_is_thin_pool_metadata(lv) ||
+ lv_is_vdo_pool(lv) ||
+ lv_is_vdo_pool_data(lv) ||
lv_is_pool_metadata_spare(lv) ||
lv_is_lockd_sanlock_lv(lv))) {
log_print_unless_silent("Ignoring --resizefs as volume %s does not have a filesystem.",
@@ -5457,6 +5455,11 @@ static int _lvresize_check_type(const struct logical_volume *lv,
log_error("Thin pool metadata volumes cannot be reduced.");
return 0;
}
+ if (lv_is_vdo_pool_data(lv)) {
+ log_error("Cannot reduce VDO pool data volume %s.",
+ display_lvname(lv));
+ return 0;
+ }
} else if (lp->resize == LV_EXTEND) {
if (lv_is_thin_pool_metadata(lv) &&
(!(seg = find_pool_seg(first_seg(lv))) ||
@@ -5529,7 +5532,7 @@ static int _lvresize_prepare(struct logical_volume **lv,
{
struct volume_group *vg = (*lv)->vg;
- if (lv_is_thin_pool(*lv))
+ if (lv_is_thin_pool(*lv) || lv_is_vdo_pool(*lv))
*lv = seg_lv(first_seg(*lv), 0); /* switch to data LV */
/* Resolve extents from size */
5 years, 2 months
master - vdo: size reduction requires VDO to be active
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bd6709cec6ca9ecc2c5...
Commit: bd6709cec6ca9ecc2c5f4e5f7d587daee5bd8cd1
Parent: f1ad4b067962c36e6f8199a8c6d10496bd9fb3b7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jan 19 19:32:02 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
vdo: size reduction requires VDO to be active
To be able to send discard to reduced areas - the VDO LV needs to
be active.
---
lib/metadata/lv_manip.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1825abe..5418535 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4663,6 +4663,11 @@ static int _request_confirmation(const struct logical_volume *lv,
return 0;
}
return 1;
+ } else if (lv_is_vdo(lv) && !info.exists) {
+ log_error("Logical volume %s must be activated "
+ "before reducing device size.",
+ display_lvname(lv));
+ return 0;
}
if (!info.exists)
5 years, 2 months
master - vdo: estimate virtual size after resize
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ca72d19691683266f14...
Commit: ca72d19691683266f14dac7ae2eac755eeda6586
Parent: ab031d673d7c75ca1217864dffc3c8e79e97c8f6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 16 15:35:07 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
vdo: estimate virtual size after resize
---
lib/metadata/lv_manip.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index def1c03..9ef568c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3349,6 +3349,10 @@ static int _lv_add_vdo_segment(struct logical_volume *lv, uint64_t status,
lv->le_count += extents;
lv->size += (uint64_t) extents * lv->vg->extent_size;
+ if (seg_lv(seg, 0) &&
+ !update_vdo_pool_virtual_size(first_seg(seg_lv(seg, 0))))
+ return_0;
+
return 1;
}
5 years, 2 months
master - vdo: discard reduced area
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f1ad4b067962c36e6f8...
Commit: f1ad4b067962c36e6f8199a8c6d10496bd9fb3b7
Parent: ca72d19691683266f14dac7ae2eac755eeda6586
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 21 12:20:07 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
vdo: discard reduced area
Implement sending discard to reduced LV area.
---
lib/metadata/lv_manip.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 9ef568c..1825abe 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5570,6 +5570,8 @@ int lv_resize(struct logical_volume *lv,
int activated = 0;
int ret = 0;
int status;
+ struct device *dev;
+ char name[PATH_MAX];
if (lv_is_writecache(lv)) {
log_error("Resize not yet allowed on LVs with writecache attached.");
@@ -5695,6 +5697,41 @@ int lv_resize(struct logical_volume *lv,
activated = 1;
}
+ /* Send DISCARD/TRIM to reduced area of VDO volumes
+ * TODO: enable thin and provide
+ * TODO2: we need polling method */
+ if ((lp->resize == LV_REDUCE) && lv_is_vdo(lv)) {
+ if (dm_snprintf(name, sizeof(name), "%s%s/%s", lv->vg->cmd->dev_dir,
+ lv->vg->name, lv->name) < 0) {
+ log_error("Name too long - device not discarded (%s)", lv->name);
+ return 0;
+ }
+
+ if (!(dev = dev_cache_get(lv->vg->cmd, name, NULL))) {
+ log_error("%s: not found: device not discarded.", name);
+ return 0;
+ }
+
+ if (!dev_discard_max_bytes(cmd->dev_types, dev) ||
+ !dev_discard_granularity(cmd->dev_types, dev)) {
+ log_error("%s: max bytes and granularity query fails.", name);
+ dev_destroy_file(dev);
+ return 0;
+ }
+
+ log_warn("WARNING: %s: Discarding %s at offset " FMTu64 ", please wait...",
+ name, display_size(cmd, (uint64_t)(lv->le_count - lp->extents) * vg->extent_size),
+ ((uint64_t)lp->extents * vg->extent_size) << SECTOR_SHIFT);
+
+ if (!dev_discard_blocks(dev, ((uint64_t)lp->extents * vg->extent_size) << SECTOR_SHIFT,
+ ((uint64_t)(lv->le_count - lp->extents) * vg->extent_size) << SECTOR_SHIFT)) {
+ log_error("%s: discarding failed.", name);
+ dev_destroy_file(dev);
+ return 0;
+ }
+
+ dev_destroy_file(dev);
+ }
/*
* If the LV is locked from activation, this lock call is a no-op.
* Otherwise, this acquires a transient lock on the lv (not PERSISTENT).
5 years, 2 months
master - vdo: introduce function for estimation of virtual size
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ab031d673d7c75ca121...
Commit: ab031d673d7c75ca1217864dffc3c8e79e97c8f6
Parent: 022ebb0cfebee4ac8fdbe4e0c61e85db1038a115
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 16 15:34:28 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:16 2019 +0100
vdo: introduce function for estimation of virtual size
---
lib/metadata/metadata-exported.h | 1 +
lib/metadata/vdo_manip.c | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index f867231..c76e644 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1299,6 +1299,7 @@ const char *get_vdo_compression_state_name(enum dm_vdo_compression_state state);
const char *get_vdo_index_state_name(enum dm_vdo_index_state state);
const char *get_vdo_operating_mode_name(enum dm_vdo_operating_mode mode);
uint64_t get_vdo_pool_virtual_size(const struct lv_segment *vdo_pool_seg);
+int update_vdo_pool_virtual_size(struct lv_segment *vdo_pool_seg);
int parse_vdo_pool_status(struct dm_pool *mem, const struct logical_volume *vdo_pool_lv,
const char *params, struct lv_status_vdo *status);
struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
diff --git a/lib/metadata/vdo_manip.c b/lib/metadata/vdo_manip.c
index 04ab1ab..4be9d2b 100644
--- a/lib/metadata/vdo_manip.c
+++ b/lib/metadata/vdo_manip.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018-2019 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -91,6 +91,23 @@ uint64_t get_vdo_pool_virtual_size(const struct lv_segment *vdo_pool_seg)
vdo_pool_seg->vdo_pool_header_size);
}
+int update_vdo_pool_virtual_size(struct lv_segment *vdo_pool_seg)
+{
+ struct seg_list *sl;
+ uint32_t extents = 0;
+
+ /* FIXME: as long as we have only SINGLE VDO with vdo-pool this works */
+ /* after adding support for multiple VDO LVs - this needs heavy rework */
+ dm_list_iterate_items(sl, &vdo_pool_seg->lv->segs_using_this_lv)
+ extents += sl->seg->len;
+
+ /* Only growing virtual/logical VDO size */
+ if (extents > vdo_pool_seg->vdo_pool_virtual_extents)
+ vdo_pool_seg->vdo_pool_virtual_extents = extents;
+
+ return 1;
+}
+
static int _sysfs_get_kvdo_value(const char *dm_name, const char *vdo_param, uint64_t *value)
{
char path[PATH_MAX];
5 years, 2 months
master - lv_manip: better work with PERCENT_VG modifier
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=022ebb0cfebee4ac8fd...
Commit: 022ebb0cfebee4ac8fdbe4e0c61e85db1038a115
Parent: 74ae1c5bc1150005ae6e82c90415c433f4a24cbd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 18 22:27:02 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jan 21 12:53:15 2019 +0100
lv_manip: better work with PERCENT_VG modifier
When using 'lvcreate -l100%VG' and there is big disproportion between
real available space and requested setting - automatically fallback
to 100%FREE.
Difference can be seen when VG is big and already most space was
allocated, so the requestion 100%VG can end (and by spec for % modifier
it's correct) as LV with size of 1%VG. Usually this is not a big
problem - buit in some cases - like cache-pool allocation, this
can result a big difference for chunksize selection.
With this patch it's more closely match common-sense logic without
the need of reitteration of too big changes in lvm2 core ATM.
TODO: in the future there should be allocator solving all allocations
in a single call.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 6 ++++++
tools/lvcreate.c | 6 ++++++
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c8ea3d4..ba27b7d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
+ Improve -lXXX%VG modifier which improves cache segment estimation.
Ensure migration_threshold for cache is at least 8 chunks.
Restore missing man info lvcreate --zero for thin-pools.
Drop misleadning comment for metadata minimum_io_size for VDO segment.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 27c40d7..def1c03 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5028,6 +5028,12 @@ static int _lvresize_extents_from_percent(const struct logical_volume *lv,
case PERCENT_VG:
lp->extents = percent_of_extents(lp->extents, vg->extent_count,
(lp->sign != SIGN_MINUS));
+ if (lp->sign == SIGN_NONE && lp->extents > vg->free_count) {
+ lp->extents = vg->free_count;
+ log_print_unless_silent("Reducing %u%%VG to remaining free space %s in VG.",
+ old_extents,
+ display_size(vg->cmd, (uint64_t)vg->extent_size * lp->extents));
+ }
break;
case PERCENT_FREE:
lp->extents = percent_of_extents(lp->extents, vg->free_count,
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 3c22794..ebe51d9 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -278,6 +278,12 @@ static int _update_extents_params(struct volume_group *vg,
switch (lcp->percent) {
case PERCENT_VG:
extents = percent_of_extents(lp->extents, base_calc_extents = vg->extent_count, 0);
+ if (extents > vg->free_count) {
+ extents = vg->free_count;
+ log_print_unless_silent("Reducing %u%%VG to remaining free space %s in VG.",
+ lp->extents,
+ display_size(vg->cmd, (uint64_t)vg->extent_size * extents));
+ }
break;
case PERCENT_FREE:
extents = percent_of_extents(lp->extents, base_calc_extents = vg->free_count, 0);
5 years, 2 months