Skip to content

Commit 7472911

Browse files
committed
os/bluestore: Segmentation review comments addressed
1. Inserted fallback code to avoid div 0 2. Fixed inconsistency in segment_size value between - onode created - onode upgraded When settings tell to disable segmentation. 3. Improved decision on appending one more segment to current shard Signed-off-by: Adam Kupczyk <[email protected]>
1 parent 14fc61b commit 7472911

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/os/bluestore/BlueStore.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,7 +3656,17 @@ void BlueStore::ExtentMap::reshard(
36563656
<< ", slop " << slop << dendl;
36573657

36583658
uint32_t next_boundary = segment_size;
3659-
uint32_t encoded_segment_estimate = bytes * segment_size / (data_reshard_end - needs_reshard_begin);
3659+
uint32_t encoded_segment_estimate = 0;
3660+
if (segment_size != 0) {
3661+
if (data_reshard_end != needs_reshard_begin) {
3662+
encoded_segment_estimate = bytes * segment_size / (data_reshard_end - needs_reshard_begin);
3663+
} else {
3664+
derr << __func__ << " 0 reshard-range doing 0x" << std::hex << needs_reshard_begin
3665+
<< "-0x" << needs_reshard_end << std::dec << " on"
3666+
<< pretty_binary_string(onode->oid.hobj.to_str()) << dendl;
3667+
encoded_segment_estimate = 500; // just something, instead div0 ....
3668+
}
3669+
}
36603670

36613671
// reshard
36623672
unsigned estimate = 0;
@@ -3678,9 +3688,7 @@ void BlueStore::ExtentMap::reshard(
36783688
// beginning of the extent is a place that might be a shard boundary
36793689
// we want to decide whether to continue streaming to the current shard
36803690
// or move to the next one
3681-
if ((estimate >= target /*we have enough already*/) ||
3682-
(estimate + encoded_segment_estimate >= (target * 3 / 2))
3683-
/*we will be too large if we wait for next segment*/) {
3691+
if (estimate + encoded_segment_estimate/2 >= target /*it is better to go undersize*/) {
36843692
make_shard_here = true;
36853693
}
36863694
next_boundary = p2roundup(extent->blob_end(), segment_size);
@@ -4865,7 +4873,9 @@ BlueStore::Onode* BlueStore::Onode::create_decode(
48654873
} else {
48664874
// init segment_size
48674875
uint32_t segment_size = c->store->segment_size.load();
4868-
if (c->comp_max_blob_size.has_value() && segment_size < c->comp_max_blob_size.value()) {
4876+
if (segment_size != 0 &&
4877+
c->comp_max_blob_size.has_value() &&
4878+
segment_size < c->comp_max_blob_size.value()) {
48694879
segment_size = c->comp_max_blob_size.value(); // compression larger than global segment_size, use it
48704880
}
48714881
on->onode.segment_size = segment_size;

0 commit comments

Comments
 (0)