@@ -588,6 +588,26 @@ inline void BlueStore::Writer::_place_extent_in_blob(
588588 }
589589}
590590
591+ // Iterator it can be invalidated.
592+ void BlueStore::Writer::_maybe_meld_with_prev_extent (exmp_it it)
593+ {
594+ if (it == onode->extent_map .extent_map .end ()) return ; // can't merge with non-existent
595+ if (it == onode->extent_map .extent_map .begin ()) return ; // can't merge when there is only 1 extent
596+ if (it->logical_end () >= right_shard_bound) return ; // not allowed to escape shard range
597+ auto it_p = it;
598+ --it_p;
599+ if (it_p->logical_offset < left_shard_bound) return ; // we could jump here behind our inserted range
600+ if (it_p->blob == it->blob &&
601+ it_p->logical_end () == it->logical_offset &&
602+ it_p->blob_offset + it_p->length == it->blob_offset ) // this one is specifc, currently is always true
603+ {
604+ it_p->length += it->length ;
605+ onode->extent_map .rm (it);
606+ left_affected_range = std::min (left_affected_range, it_p->logical_offset );
607+ right_affected_range = std::max (right_affected_range, it_p->logical_end ());
608+ }
609+ }
610+
591611/* *
592612 * Note from developer
593613 * This module tries to keep naming convention:
@@ -1408,8 +1428,13 @@ void BlueStore::Writer::do_write(
14081428 _collect_released_allocated ();
14091429 // update statfs
14101430 txc->statfs_delta += statfs_delta;
1411- // note: compress extent is not needed; _try_reuse_allocated_* joins extents if possible
1412- // in other cases new blobs cannot be joined with existing ones
1431+ // Note: compress extent is mostly not needed; _try_reuse_allocated_* joins extents if possible;
1432+ // same is done after _blob_put_data_subau_allocate (allocate more to existing blob).
1433+ // New blobs cannot be joined with existing ones.
1434+ // The only case that adjecent extents can be meld together is on the boundary.
1435+ // More specific, since we are operating left side first, right side later
1436+ // the only non-joined extent is between after_punch_it - 1 and after_punch_it.
1437+ _maybe_meld_with_prev_extent (after_punch_it);
14131438 dout (25 ) << " result: " << std::endl << onode->print (pp_mode) << dendl;
14141439}
14151440
0 commit comments