Hello community, here is the log from the commit of package lvm2 for openSUSE:Factory checked in at 2020-06-17 14:45:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lvm2 (Old) and /work/SRC/openSUSE:Factory/.lvm2.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lvm2" Wed Jun 17 14:45:35 2020 rev:137 rq:814712 version:2.03.05 Changes: -------- --- /work/SRC/openSUSE:Factory/lvm2/lvm2.changes 2020-06-03 20:28:51.896506477 +0200 +++ /work/SRC/openSUSE:Factory/.lvm2.new.3606/lvm2.changes 2020-06-17 14:45:44.132040822 +0200 @@ -1,0 +2,6 @@ +Fri Jun 12 01:28:08 UTC 2020 - heming.z...@suse.com + +- problem with LVM cache (data loss) (bsc#1172566) + + bug-1172566_cachevol-use-cachepool-code-for-metadata-size.patch + +------------------------------------------------------------------- New: ---- bug-1172566_cachevol-use-cachepool-code-for-metadata-size.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lvm2.spec ++++++ --- /var/tmp/diff_new_pack.gMeOPd/_old 2020-06-17 14:45:45.452045317 +0200 +++ /var/tmp/diff_new_pack.gMeOPd/_new 2020-06-17 14:45:45.456045330 +0200 @@ -94,6 +94,7 @@ Patch0037: bug-1150021_06-fix-dev_unset_last_byte-after-write-error.patch Patch0038: bug-1157736-add-suggestion-message-for-mirror-LVs.patch Patch0039: bug-1171907-lvremove-remove-attached-cachevol-with-removed-LV.patch +Patch0040: bug-1172566_cachevol-use-cachepool-code-for-metadata-size.patch # SUSE patches: 1000+ for LVM # Never upstream Patch1001: cmirrord_remove_date_time_from_compilation.patch @@ -187,6 +188,7 @@ %patch0037 -p1 %patch0038 -p1 %patch0039 -p1 +%patch0040 -p1 %patch1001 -p1 %patch1002 -p1 %patch1003 -p1 ++++++ bug-1172566_cachevol-use-cachepool-code-for-metadata-size.patch ++++++ By heming.z...@suse.com this patch is based on upstream commit ``` commit c08704cee7e34a96fdaa453faf900683283e8691 Author: David Teigland <teigl...@redhat.com> Date: Mon Oct 21 12:13:33 2019 -0500 cachevol: use cachepool code for metadata size Based on a more detailed calculation, but because of extent size rounding, the final result is about the same. ``` diff -Nupr a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c --- a/lib/metadata/cache_manip.c 2020-06-12 09:04:17.474637002 +0800 +++ b/lib/metadata/cache_manip.c 2020-06-12 09:04:28.914578582 +0800 @@ -184,12 +184,16 @@ void cache_check_for_warns(const struct */ static uint64_t _cache_min_metadata_size(uint64_t data_size, uint32_t chunk_size) { - uint64_t min_meta_size; - - min_meta_size = data_size / chunk_size; /* nr_chunks */ - min_meta_size *= (DM_BYTES_PER_BLOCK + DM_MAX_HINT_WIDTH + DM_HINT_OVERHEAD_PER_BLOCK); - min_meta_size = (min_meta_size + (SECTOR_SIZE - 1)) >> SECTOR_SHIFT; /* in sectors */ - min_meta_size += DM_TRANSACTION_OVERHEAD * (1024 >> SECTOR_SHIFT); + /* Used space for mapping and hints for each cached chunk in bytes + * (matching thin-tools cache_metadata_size.cc) */ + const uint64_t chunk_overhead = (DM_BYTES_PER_BLOCK + DM_MAX_HINT_WIDTH + DM_HINT_OVERHEAD_PER_BLOCK); + const uint64_t transaction_overhead = DM_TRANSACTION_OVERHEAD * 1024; /* 4MiB */ + + /* Number of cache chunks we have in caching volume */ + uint64_t nr_chunks = data_size / chunk_size; + /* Minimal size of metadata volume converted back to sectors */ + uint64_t min_meta_size = (transaction_overhead + nr_chunks * chunk_overhead + + (SECTOR_SIZE - 1)) >> SECTOR_SHIFT; return min_meta_size; } @@ -1242,14 +1246,7 @@ int cache_vol_set_params(struct cmd_cont } if (!meta_size) { - if (pool_lv->size < (128 * ONE_MB_S)) - meta_size = 16 * ONE_MB_S; - - else if (pool_lv->size < ONE_GB_S) - meta_size = 32 * ONE_MB_S; - - else if (pool_lv->size < (128 * ONE_GB_S)) - meta_size = 64 * ONE_MB_S; + meta_size = _cache_min_metadata_size(pool_lv->size, chunk_size); if (meta_size > (pool_lv->size / 2)) meta_size = pool_lv->size / 2;