master - lvmcache: remove unused flag
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=90b94ead12d739a3221...
Commit: 90b94ead12d739a3221e179bdcf1c482978f0f0f
Parent: d7054cd28ae6bb2fad216f8756ab030de3e8e65e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 30 14:59:27 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 30 14:59:27 2019 -0500
lvmcache: remove unused flag
The new label scan design is never called recursively,
so we don't need a flag to check for that.
---
lib/cache/lvmcache.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index f0b1d56..7d0c60d 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -66,7 +66,6 @@ static struct dm_hash_table *_vgname_hash = NULL;
static DM_LIST_INIT(_vginfos);
static DM_LIST_INIT(_found_duplicate_devs);
static DM_LIST_INIT(_unused_duplicate_devs);
-static int _scanning_in_progress = 0;
static int _vgs_locked = 0;
static int _found_duplicate_pvs = 0; /* If we never see a duplicate PV we can skip checking for them later. */
static int _found_duplicate_vgnames = 0;
@@ -855,12 +854,6 @@ int lvmcache_label_scan(struct cmd_context *cmd)
log_debug_cache("Finding VG info");
- /* Avoid recursion when a PVID can't be found! */
- if (_scanning_in_progress)
- return 0;
-
- _scanning_in_progress = 1;
-
/* FIXME: can this happen? */
if (!cmd->filter) {
log_error("label scan is missing filter");
@@ -941,8 +934,6 @@ int lvmcache_label_scan(struct cmd_context *cmd)
r = 1;
out:
- _scanning_in_progress = 0;
-
dm_list_iterate_items(vginfo, &_vginfos) {
if (is_orphan_vg(vginfo->vgname))
continue;
4 years, 4 months
master - vgcreate: remove the lvmcache locking workaround
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d7054cd28ae6bb2fad2...
Commit: d7054cd28ae6bb2fad216f8756ab030de3e8e65e
Parent: 366c1ac15b853fe3efc95472c569efc575f1237f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 30 14:26:16 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 30 14:26:16 2019 -0500
vgcreate: remove the lvmcache locking workaround
Recent cleanups and simplifications to lvmcache and locking
mean that the odd locking to workaround other issues is now
unnecessary.
---
tools/vgcreate.c | 15 ---------------
1 files changed, 0 insertions(+), 15 deletions(-)
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index d62925f..626cf15 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -91,15 +91,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- /*
- * FIXME: we have to unlock/relock the new VG name around the pvcreate
- * step because pvcreate needs to destroy lvmcache, which doesn't allow
- * any locks to be held. There shouldn't be any reason to require this
- * VG lock to be released, so the lvmcache destroy rule about locks
- * seems to be unwarranted here.
- */
- unlock_vg(cmd, NULL, vp_new.vg_name);
-
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
@@ -110,12 +101,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
}
- /* Relock the new VG name, see comment above. */
- if (!lock_vol(cmd, vp_new.vg_name, LCK_VG_WRITE, NULL)) {
- destroy_processing_handle(cmd, handle);
- return_ECMD_FAILED;
- }
-
if (!(vg = vg_create(cmd, vp_new.vg_name)))
goto_bad;
4 years, 4 months
master - pvcreate: call label scan prior to pvcreate_each_device
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=366c1ac15b853fe3efc...
Commit: 366c1ac15b853fe3efc95472c569efc575f1237f
Parent: 6d0f09f4783061054152ae0013d7ebfad949c343
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 30 14:10:27 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 30 14:10:27 2019 -0500
pvcreate: call label scan prior to pvcreate_each_device
and don't call it from inside pvcreate_each_device.
This avoids having to repeat it for users of
pvcreate_each_device (pvcreate/pvremove/vgcreate/vgextend.)
---
tools/pvcreate.c | 5 +++--
tools/pvremove.c | 2 ++
tools/toollib.c | 10 ++--------
tools/vgextend.c | 4 +++-
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 10d1a37..5b59a79 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -145,6 +145,8 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
clear_hint_file(cmd);
+ lvmcache_label_scan(cmd);
+
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
@@ -152,9 +154,8 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
if (!pvcreate_each_device(cmd, handle, &pp))
ret = ECMD_FAILED;
- else {
+ else
ret = ECMD_PROCESSED;
- }
destroy_processing_handle(cmd, handle);
return ret;
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 4ad1f42..2dfdbd0 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -45,6 +45,8 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv)
clear_hint_file(cmd);
+ lvmcache_label_scan(cmd);
+
/* When forcibly clearing a PV we don't care about a VG lock. */
if (pp.force == DONT_PROMPT_OVERRIDE)
cmd->lockd_vg_disable = 1;
diff --git a/tools/toollib.c b/tools/toollib.c
index b8be826..b352839 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2243,7 +2243,8 @@ int process_each_vg(struct cmd_context *cmd,
* Scan all devices to populate lvmcache with initial
* list of PVs and VGs.
*/
- lvmcache_label_scan(cmd);
+ if (!(read_flags & PROCESS_SKIP_SCAN))
+ lvmcache_label_scan(cmd);
/*
* A list of all VGs on the system is needed when:
@@ -5327,13 +5328,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
}
/*
- * Scan before calling process_each_pv so we can set up the PV args
- * first. We can then skip the scan that would normally occur at the
- * beginning of process_each_pv.
- */
- lvmcache_label_scan(cmd);
-
- /*
* Translate arg names into struct device's.
*/
dm_list_iterate_items(pd, &pp->arg_devices)
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 02da3a8..785be3f 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -162,6 +162,8 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
clear_hint_file(cmd);
+ lvmcache_label_scan(cmd);
+
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
@@ -185,7 +187,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
handle->custom_handle = &vp;
ret = process_each_vg(cmd, 0, NULL, vg_name, NULL,
- READ_FOR_UPDATE, 0, handle,
+ READ_FOR_UPDATE | PROCESS_SKIP_SCAN, 0, handle,
restoremissing ? &_vgextend_restoremissing : &_vgextend_single);
destroy_processing_handle(cmd, handle);
4 years, 4 months
stable-2.02 - tests: update parm for new kernel
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9d7afaaab85404a5629...
Commit: 9d7afaaab85404a562942f4662de8a2e7739d8fb
Parent: 71b9cb8e0f688289a817a8ec6b88548023e5c3d0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Nov 18 22:04:00 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 30 13:16:31 2019 +0200
tests: update parm for new kernel
---
test/shell/lvextend-thin-metadata-dmeventd.sh | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvextend-thin-metadata-dmeventd.sh b/test/shell/lvextend-thin-metadata-dmeventd.sh
index 437a04e..20b70d3 100644
--- a/test/shell/lvextend-thin-metadata-dmeventd.sh
+++ b/test/shell/lvextend-thin-metadata-dmeventd.sh
@@ -90,7 +90,9 @@ lvchange -an $vg/pool
# Consume more then (100% - 4MiB) out of 32MiB metadata volume (>87.5%)
# (Test for less than 4MiB free space in metadata, which is less than 25%)
-fake_metadata_ 7400 2 >data
+DATA=7200 # Newer version of thin-pool have hidden reserve, so use lower value
+aux target_at_least dm-thin-pool 1 20 0 || DATA=7400
+fake_metadata_ "$DATA" 2 >data
"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv2"
# Swap volume with restored fake metadata
lvconvert -y --chunksize 64k --thinpool $vg/pool --poolmetadata $vg/$lv2
4 years, 4 months
stable-2.02 - tests: extend
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=71b9cb8e0f688289a81...
Commit: 71b9cb8e0f688289a817a8ec6b88548023e5c3d0
Parent: 057d8668890367525fc830d7a08413eefe0243af
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 16 16:01:39 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 30 13:16:19 2019 +0200
tests: extend
---
test/shell/lvextend-thin-metadata-dmeventd.sh | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvextend-thin-metadata-dmeventd.sh b/test/shell/lvextend-thin-metadata-dmeventd.sh
index 3731bf6..437a04e 100644
--- a/test/shell/lvextend-thin-metadata-dmeventd.sh
+++ b/test/shell/lvextend-thin-metadata-dmeventd.sh
@@ -171,7 +171,9 @@ wait_for_change_ $pre
lvchange -an $vg
#
-fake_metadata_ 350 2 >data
+DATA=300 # Newer version of thin-pool have hidden reserve, so use lower value
+aux target_at_least dm-thin-pool 1 20 0 || DATA=350
+fake_metadata_ $DATA 2 >data
lvchange -ay $vg/$lv1
"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
4 years, 4 months
stable-2.02 - tests: rounding for pools changed to power of 2
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=057d8668890367525fc...
Commit: 057d8668890367525fc830d7a08413eefe0243af
Parent: e79e092f8bd41d3d589be0a10ac5addeaa8a3126
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 28 22:05:17 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 30 13:14:27 2019 +0200
tests: rounding for pools changed to power of 2
Even with 64K chunk support, lvm2 will target power-of-2 chunks.
---
test/shell/lvcreate-thin-big.sh | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/test/shell/lvcreate-thin-big.sh b/test/shell/lvcreate-thin-big.sh
index 0625a59..595b8a9 100644
--- a/test/shell/lvcreate-thin-big.sh
+++ b/test/shell/lvcreate-thin-big.sh
@@ -75,12 +75,10 @@ check lv_field $vg/pool1_tmeta size "2.50m"
check lv_field $vg/pool2_tmeta size "3.75m"
lvremove -ff $vg
-# Block size of multiple 64KB needs >= 1.4
-if aux have_thin 1 4 0 ; then
-# Test chunk size is rounded to 64KB boundary
+# Test chunk size is rounded to power-of-2
lvcreate -L10G --poolmetadatasize 4M -T $vg/pool
-check lv_field $vg/pool chunk_size "192.00k"
-fi
+check lv_field $vg/pool chunk_size "256.00k"
+
# Old thinpool target required rounding to power of 2
aux lvmconf "global/thin_disabled_features = [ \"block_size\" ]"
lvcreate -L10G --poolmetadatasize 4M -T $vg/pool_old
4 years, 4 months
stable-2.02 - lv_manip: better work with PERCENT_VG modifier
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e79e092f8bd41d3d589...
Commit: e79e092f8bd41d3d589be0a10ac5addeaa8a3126
Parent: 4729b4af0bee2e742ed4f765dd6dc8d72f808521
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 18 22:27:02 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 30 12:24:53 2019 +0200
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 dc2c4af..4b73ccc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.185 -
==================================
+ Improve -lXXX%VG modifier which improves cache segment estimation.
Add synchronization with udev before removing cached devices.
Fix missing growth of _pmsmare volume when extending _tmeta volume.
Automatically grow thin metadata, when thin data gets too big.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f960fad..9e7eff9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4925,6 +4925,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 > (lv->le_count + vg->free_count))) {
+ lp->extents = lv->le_count + 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 867cde1..6e8cc90 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -277,6 +277,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);
4 years, 4 months
stable-2.02 - lv_manip: insert remove layer skips pools
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f3be66c002b6dd5b6d1...
Commit: f3be66c002b6dd5b6d1eabc395e10e97d49a1e99
Parent: 2047d405af85d0f7e0d494510f439a1e644f3285
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 24 14:14:31 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 30 12:08:36 2019 +0200
lv_manip: insert remove layer skips pools
Fixing renaming of subLVs when removing and inserting layers - this
got visible when using stacked VDO pools.
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 68ad3c3..f960fad 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6781,7 +6781,7 @@ int remove_layer_from_lv(struct logical_volume *lv,
if (strstr(layer_lv->name, _suffixes[r]) == 0) {
lv_names.old = layer_lv->name;
lv_names.new = parent_lv->name;
- if (!for_each_sub_lv(parent_lv, _rename_cb, (void *) &lv_names))
+ if (!for_each_sub_lv(parent_lv, _rename_skip_pools_externals_cb, (void *) &lv_names))
return_0;
break;
}
@@ -6905,7 +6905,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
if (strcmp(layer_suffix, _suffixes[i]) == 0) {
lv_names.old = lv_where->name;
lv_names.new = layer_lv->name;
- if (!for_each_sub_lv(layer_lv, _rename_cb, (void *) &lv_names))
+ if (!for_each_sub_lv(layer_lv, _rename_skip_pools_externals_cb, (void *) &lv_names))
return_NULL;
break;
}
4 years, 4 months
stable-2.02 - tests: check auto-growth of thin-pool meta
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1370277ea7be06a9458...
Commit: 1370277ea7be06a945803a018ad9f38d681c6d67
Parent: f38cfd09c4a2b2ea76662264f3f99abff24b3ca0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 3 13:25:54 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 30 12:06:08 2019 +0200
tests: check auto-growth of thin-pool meta
---
test/shell/lvextend-thin-full.sh | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvextend-thin-full.sh b/test/shell/lvextend-thin-full.sh
index e23eca8..263ab2f 100644
--- a/test/shell/lvextend-thin-full.sh
+++ b/test/shell/lvextend-thin-full.sh
@@ -28,7 +28,7 @@ test -n "$LVM_TEST_THIN_RESTORE_CMD" || LVM_TEST_THIN_RESTORE_CMD=$(which thin_r
aux have_thin 1 10 0 || skip
-aux prepare_vg 3 256
+aux prepare_vg 3 4096
aux lvmconf 'activation/thin_pool_autoextend_percent = 30' \
'activation/thin_pool_autoextend_threshold = 70'
@@ -58,6 +58,12 @@ not lvcreate -V10 $vg/pool
lvextend --use-policies $vg/pool "$dev2" "$dev3"
#should lvextend -l+100%FREE $vg/pool2
+check lv_field $vg/pool_tmeta size "3.00m"
+
+lvextend -L+3G $vg/pool
+
+check lv_field $vg/pool_tmeta size "3.50m"
+
lvs -a $vg
vgremove -ff $vg
4 years, 4 months
stable-2.02 - thin: select chunk size as power of 2
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4729b4af0bee2e742ed...
Commit: 4729b4af0bee2e742ed4f765dd6dc8d72f808521
Parent: f3be66c002b6dd5b6d1eabc395e10e97d49a1e99
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jan 29 18:45:52 2019 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 30 12:11:50 2019 +0200
thin: select chunk size as power of 2
Whenever thin-pool chunk size is unspecified and left for lvm calculation
try to select the size as nearest highest power-of-2 instead of
just being a multiple of 64KiB. When multiple is bigger then 1MiB,
keep using 1MiB multiple.
---
lib/config/defaults.h | 2 ++
lib/metadata/thin_manip.c | 22 ++++++++--------------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 9e398d7..6d3c37c 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -111,6 +111,8 @@
#define DEFAULT_THIN_POOL_CHUNK_SIZE_POLICY "generic"
#define DEFAULT_THIN_POOL_CHUNK_SIZE 64 /* KB */
#define DEFAULT_THIN_POOL_CHUNK_SIZE_PERFORMANCE 512 /* KB */
+/* Chunk size big enough it no longer needs jump by power-of-2 */
+#define DEFAULT_THIN_POOL_CHUNK_SIZE_ALIGNED 1024 /* KB */
#define DEFAULT_THIN_POOL_DISCARDS "passdown"
#define DEFAULT_THIN_POOL_ZERO 1
#define DEFAULT_POOL_METADATA_SPARE 1 /* thin + cache */
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 313ef1b..2216927 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -579,21 +579,15 @@ static uint32_t _estimate_chunk_size(uint32_t data_extents, uint32_t extent_size
uint64_t metadata_size, int attr)
{
uint32_t chunk_size = _estimate_size(data_extents, extent_size, metadata_size);
+ const uint32_t BIG_CHUNK = 2 * DEFAULT_THIN_POOL_CHUNK_SIZE_ALIGNED - 1;
- if (attr & THIN_FEATURE_BLOCK_SIZE) {
- /* Round up to 64KB */
- chunk_size += DM_THIN_MIN_DATA_BLOCK_SIZE - 1;
- chunk_size &= ~(uint32_t)(DM_THIN_MIN_DATA_BLOCK_SIZE - 1);
- } else {
- /* Round up to nearest power of 2 */
- chunk_size--;
- chunk_size |= chunk_size >> 1;
- chunk_size |= chunk_size >> 2;
- chunk_size |= chunk_size >> 4;
- chunk_size |= chunk_size >> 8;
- chunk_size |= chunk_size >> 16;
- chunk_size++;
- }
+ if ((attr & THIN_FEATURE_BLOCK_SIZE) &&
+ (chunk_size > BIG_CHUNK) &&
+ (chunk_size < (UINT32_MAX - BIG_CHUNK)))
+ chunk_size = (chunk_size + BIG_CHUNK) & ~BIG_CHUNK;
+ else
+ /* Round up to nearest power of 2 of 32-bit */
+ chunk_size = 1 << (32 - clz(chunk_size - 1));
if (chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE)
chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
4 years, 4 months