@@ -69,44 +69,6 @@ class BtreeLBAManager : public LBAManager {
6969 Transaction &t,
7070 laddr_t offset) final ;
7171
72- struct alloc_mapping_info_t {
73- laddr_t key = L_ADDR_NULL; // once assigned, the allocation to
74- // key must be exact and successful
75- extent_len_t len = 0 ;
76- pladdr_t val;
77- uint32_t checksum = 0 ;
78- LogicalChildNode* extent = nullptr ;
79-
80- static alloc_mapping_info_t create_zero (extent_len_t len) {
81- return {
82- L_ADDR_NULL,
83- len,
84- P_ADDR_ZERO,
85- 0 ,
86- static_cast <LogicalChildNode*>(get_reserved_ptr<LBALeafNode, laddr_t >())};
87- }
88- static alloc_mapping_info_t create_indirect (
89- laddr_t laddr,
90- extent_len_t len,
91- laddr_t intermediate_key) {
92- return {
93- laddr,
94- len,
95- intermediate_key,
96- 0 , // crc will only be used and checked with LBA direct mappings
97- // also see pin_to_extent(_by_type)
98- static_cast <LogicalChildNode*>(get_reserved_ptr<LBALeafNode, laddr_t >())};
99- }
100- static alloc_mapping_info_t create_direct (
101- laddr_t laddr,
102- extent_len_t len,
103- paddr_t paddr,
104- uint32_t checksum,
105- LogicalChildNode& extent) {
106- return {laddr, len, paddr, checksum, &extent};
107- }
108- };
109-
11072 alloc_extent_ret reserve_region (
11173 Transaction &t,
11274 laddr_t hint,
@@ -120,8 +82,7 @@ class BtreeLBAManager : public LBAManager {
12082 return _alloc_extents (
12183 t,
12284 hint,
123- alloc_infos,
124- EXTENT_DEFAULT_REF_COUNT
85+ alloc_infos
12586 ).si_then ([](auto mappings) {
12687 assert (mappings.size () == 1 );
12788 auto mapping = std::move (mappings.front ());
@@ -169,7 +130,7 @@ class BtreeLBAManager : public LBAManager {
169130 Transaction &t,
170131 laddr_t hint,
171132 LogicalChildNode &ext,
172- extent_ref_count_t refcount = EXTENT_DEFAULT_REF_COUNT ) final
133+ extent_ref_count_t refcount) final
173134 {
174135 // The real checksum will be updated upon transaction commit
175136 assert (ext.get_last_committed_crc () == 0 );
@@ -179,6 +140,7 @@ class BtreeLBAManager : public LBAManager {
179140 L_ADDR_NULL,
180141 ext.get_length (),
181142 ext.get_paddr (),
143+ refcount,
182144 ext.get_last_committed_crc (),
183145 ext)};
184146 return seastar::do_with (
@@ -187,8 +149,7 @@ class BtreeLBAManager : public LBAManager {
187149 return _alloc_extents (
188150 t,
189151 hint,
190- alloc_infos,
191- refcount
152+ alloc_infos
192153 ).si_then ([](auto mappings) {
193154 assert (mappings.size () == 1 );
194155 auto mapping = std::move (mappings.front ());
@@ -211,13 +172,14 @@ class BtreeLBAManager : public LBAManager {
211172 extent->has_laddr () ? extent->get_laddr () : L_ADDR_NULL,
212173 extent->get_length (),
213174 extent->get_paddr (),
175+ refcount,
214176 extent->get_last_committed_crc (),
215177 *extent));
216178 }
217179 return seastar::do_with (
218180 std::move (alloc_infos),
219- [this , &t, hint, refcount ](auto &alloc_infos) {
220- return _alloc_extents (t, hint, alloc_infos, refcount );
181+ [this , &t, hint](auto &alloc_infos) {
182+ return _alloc_extents (t, hint, alloc_infos);
221183 });
222184 }
223185
@@ -396,6 +358,49 @@ class BtreeLBAManager : public LBAManager {
396358 uint64_t num_alloc_extents_iter_nexts = 0 ;
397359 } stats;
398360
361+ struct alloc_mapping_info_t {
362+ laddr_t key = L_ADDR_NULL; // once assigned, the allocation to
363+ // key must be exact and successful
364+ lba_map_val_t value;
365+ LogicalChildNode* extent = nullptr ;
366+
367+ static alloc_mapping_info_t create_zero (extent_len_t len) {
368+ return {
369+ L_ADDR_NULL,
370+ {
371+ len,
372+ pladdr_t (P_ADDR_ZERO),
373+ EXTENT_DEFAULT_REF_COUNT,
374+ 0
375+ },
376+ static_cast <LogicalChildNode*>(get_reserved_ptr<LBALeafNode, laddr_t >())};
377+ }
378+ static alloc_mapping_info_t create_indirect (
379+ laddr_t laddr,
380+ extent_len_t len,
381+ laddr_t intermediate_key) {
382+ return {
383+ laddr,
384+ {
385+ len,
386+ pladdr_t (intermediate_key),
387+ EXTENT_DEFAULT_REF_COUNT,
388+ 0 // crc will only be used and checked with LBA direct mappings
389+ // also see pin_to_extent(_by_type)
390+ },
391+ static_cast <LogicalChildNode*>(get_reserved_ptr<LBALeafNode, laddr_t >())};
392+ }
393+ static alloc_mapping_info_t create_direct (
394+ laddr_t laddr,
395+ extent_len_t len,
396+ paddr_t paddr,
397+ extent_ref_count_t refcount,
398+ checksum_t checksum,
399+ LogicalChildNode& extent) {
400+ return {laddr, {len, pladdr_t (paddr), refcount, checksum}, &extent};
401+ }
402+ };
403+
399404 op_context_t get_context (Transaction &t) {
400405 return op_context_t {cache, t};
401406 }
@@ -445,8 +450,7 @@ class BtreeLBAManager : public LBAManager {
445450 alloc_extents_ret _alloc_extents (
446451 Transaction &t,
447452 laddr_t hint,
448- std::vector<alloc_mapping_info_t > &alloc_infos,
449- extent_ref_count_t refcount);
453+ std::vector<alloc_mapping_info_t > &alloc_infos);
450454
451455 ref_ret _incref_extent (
452456 Transaction &t,
@@ -466,7 +470,8 @@ class BtreeLBAManager : public LBAManager {
466470 {
467471#ifndef NDEBUG
468472 for (auto &alloc_info : alloc_infos) {
469- assert (alloc_info.val .get_laddr () != L_ADDR_NULL);
473+ assert (alloc_info.value .pladdr .get_laddr () != L_ADDR_NULL);
474+ assert (alloc_info.value .refcount == EXTENT_DEFAULT_REF_COUNT);
470475 }
471476#endif
472477 return seastar::do_with (
@@ -475,8 +480,7 @@ class BtreeLBAManager : public LBAManager {
475480 return _alloc_extents (
476481 t,
477482 laddr,
478- alloc_infos,
479- EXTENT_DEFAULT_REF_COUNT
483+ alloc_infos
480484 ).si_then ([&alloc_infos](auto mappings) {
481485 assert (alloc_infos.size () == mappings.size ());
482486 std::vector<BtreeLBAMappingRef> rets;
@@ -487,8 +491,8 @@ class BtreeLBAManager : public LBAManager {
487491 [[maybe_unused]] auto &alloc_info = *ait;
488492 assert (mapping->get_key () == alloc_info.key );
489493 assert (mapping->get_raw_val ().get_laddr () ==
490- alloc_info.val .get_laddr ());
491- assert (mapping->get_length () == alloc_info.len );
494+ alloc_info.value . pladdr .get_laddr ());
495+ assert (mapping->get_length () == alloc_info.value . len );
492496 rets.emplace_back (mapping);
493497 }
494498 return rets;
0 commit comments