summaryrefslogtreecommitdiffstats
path: root/recipes-extended/ceph/ceph/0002-common-replace-BitVector-NoInitAllocator-with-wrappe.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-extended/ceph/ceph/0002-common-replace-BitVector-NoInitAllocator-with-wrappe.patch')
-rw-r--r--recipes-extended/ceph/ceph/0002-common-replace-BitVector-NoInitAllocator-with-wrappe.patch101
1 files changed, 0 insertions, 101 deletions
diff --git a/recipes-extended/ceph/ceph/0002-common-replace-BitVector-NoInitAllocator-with-wrappe.patch b/recipes-extended/ceph/ceph/0002-common-replace-BitVector-NoInitAllocator-with-wrappe.patch
deleted file mode 100644
index 4f46d223..00000000
--- a/recipes-extended/ceph/ceph/0002-common-replace-BitVector-NoInitAllocator-with-wrappe.patch
+++ /dev/null
@@ -1,101 +0,0 @@
1From cca3144aca7f7c19772065421f9b02205a84e0b8 Mon Sep 17 00:00:00 2001
2From: Casey Bodley <cbodley@redhat.com>
3Date: Tue, 15 Feb 2022 18:27:10 -0500
4Subject: [PATCH] common: replace BitVector::NoInitAllocator with wrapper
5 struct
6
7in c++20, the deprecated `struct std::allocator<T>::rebind` template was
8removed, so `BitVector` no longer compiles. without a `rebind` to
9inherit, `std::allocator_traits<NoInitAllocator>::rebind_alloc<U>` was
10looking for `NoInitAllocator<U>`, but it isn't a template class
11
12further investigation found that in c++17, `vector<__u32, NoInitAllocator>`
13was rebinding this `NoInitAllocator` to `std::allocator<__u32>` and
14preventing the no-init optimization from taking effect
15
16instead of messing with the allocator to avoid zero-initialization, wrap
17each __u32 in a struct whose constructor does not initialize the value
18
19Fixes: https://tracker.ceph.com/issues/54279
20
21Signed-off-by: Casey Bodley <cbodley@redhat.com>
22---
23Fixes:
24http://errors.yoctoproject.org/Errors/Details/701862/
25
26Upstream-Status: Backport [https://github.com/ceph/ceph/commit/4f0ad8aab6b21a1fd57a7c1630d298e31b5d9bb6]
27
28 src/common/bit_vector.hpp | 27 +++++++++++----------------
29 1 file changed, 11 insertions(+), 16 deletions(-)
30
31diff --git a/src/common/bit_vector.hpp b/src/common/bit_vector.hpp
32index 10ee6c3e..9ce3e8b1 100644
33--- a/src/common/bit_vector.hpp
34+++ b/src/common/bit_vector.hpp
35@@ -223,23 +223,18 @@ public:
36
37 static void generate_test_instances(std::list<BitVector *> &o);
38 private:
39- struct NoInitAllocator : public std::allocator<__u32> {
40- NoInitAllocator() {}
41- NoInitAllocator(const std::allocator<__u32>& alloc)
42- : std::allocator<__u32>(alloc) {
43- }
44-
45- template <class U, class... Args>
46- void construct(U* p, Args&&... args) const {
47- }
48- };
49-
50 bufferlist m_data;
51 uint64_t m_size;
52 bool m_crc_enabled;
53
54 mutable __u32 m_header_crc;
55- mutable std::vector<__u32, NoInitAllocator> m_data_crcs;
56+
57+ // inhibit value-initialization when used in std::vector
58+ struct u32_struct {
59+ u32_struct() {}
60+ __u32 val;
61+ };
62+ mutable std::vector<u32_struct> m_data_crcs;
63
64 void resize(uint64_t elements, bool zero);
65
66@@ -351,7 +346,7 @@ void BitVector<_b>::encode_data(bufferlist& bl, uint64_t data_byte_offset,
67
68 bufferlist bit;
69 bit.substr_of(m_data, data_byte_offset, len);
70- m_data_crcs[data_byte_offset / BLOCK_SIZE] = bit.crc32c(0);
71+ m_data_crcs[data_byte_offset / BLOCK_SIZE].val = bit.crc32c(0);
72
73 bl.claim_append(bit);
74 data_byte_offset += BLOCK_SIZE;
75@@ -385,7 +380,7 @@ void BitVector<_b>::decode_data(bufferlist::const_iterator& it,
76 bufferlist bit;
77 bit.append(ptr);
78 if (m_crc_enabled &&
79- m_data_crcs[data_byte_offset / BLOCK_SIZE] != bit.crc32c(0)) {
80+ m_data_crcs[data_byte_offset / BLOCK_SIZE].val != bit.crc32c(0)) {
81 throw buffer::malformed_input("invalid data block CRC");
82 }
83 data.append(bit);
84@@ -499,7 +494,7 @@ void BitVector<_b>::encode_data_crcs(bufferlist& bl, uint64_t offset,
85 compute_index(offset + length - 1, &index, &shift);
86 uint64_t end_crc_index = index / BLOCK_SIZE;
87 while (crc_index <= end_crc_index) {
88- __u32 crc = m_data_crcs[crc_index++];
89+ __u32 crc = m_data_crcs[crc_index++].val;
90 ceph::encode(crc, bl);
91 }
92 }
93@@ -520,7 +515,7 @@ void BitVector<_b>::decode_data_crcs(bufferlist::const_iterator& it,
94 while (remaining > 0) {
95 __u32 crc;
96 ceph::decode(crc, it);
97- m_data_crcs[crc_index++] = crc;
98+ m_data_crcs[crc_index++].val = crc;
99 --remaining;
100 }
101 }