<< " target " << target << " slop " << slop << dendl;
// reshard
- auto ep = extent_map.begin();
auto sp = o->onode.extent_map_shards.begin();
auto esp = o->onode.extent_map_shards.end();
unsigned shard_end = 0;
unsigned offset = 0;
vector<bluestore_onode_t::shard_info> new_shard_info;
unsigned max_blob_end = 0;
- while (ep != extent_map.end()) {
- dout(30) << " ep " << *ep << dendl;
- assert(!ep->blob->is_spanning());
- if (shard_end == 0 ||
- ep->logical_offset >= shard_end) {
+ for (auto& e: extent_map) {
+ dout(30) << " extent " << e << dendl;
+ assert(!e.blob->is_spanning());
+ if (shard_end == 0 || e.logical_offset >= shard_end) {
if (sp == esp) {
// inline case
shard_end = o->onode.size;
<< std::dec << dendl;
}
// disfavor shard boundaries that span a blob
- bool would_span = (ep->logical_offset < max_blob_end) || ep->blob_offset;
+ bool would_span = (e.logical_offset < max_blob_end) || e.blob_offset;
if (estimate &&
estimate + extent_avg > target + (would_span ? slop : 0)) {
// new shard
dout(20) << __func__ << " new shard 0x" << std::hex << offset
<< std::dec << dendl;
}
- offset = ep->logical_offset;
+ offset = e.logical_offset;
new_shard_info.emplace_back(bluestore_onode_t::shard_info());
new_shard_info.back().offset = offset;
dout(20) << __func__ << " new shard 0x" << std::hex << offset << std::dec
estimate = 0;
}
estimate += extent_avg;
- uint32_t be = ep->blob_end();
+ uint32_t be = e.blob_end();
if (be > max_blob_end) {
max_blob_end = be;
}
- ++ep;
}
o->onode.extent_map_shards.swap(new_shard_info);
// identify spanning blobs
if (!o->onode.extent_map_shards.empty()) {
dout(20) << __func__ << " checking for spanning blobs" << dendl;
- auto ep = extent_map.begin();
auto sp = o->onode.extent_map_shards.begin();
auto esp = o->onode.extent_map_shards.end();
unsigned shard_start = 0;
shard_end = sp->offset;
}
int bid = 0;
- while (ep != extent_map.end()) {
- dout(30) << " ep " << *ep << dendl;
- while (ep->logical_offset >= shard_end) {
+ for (auto& e : extent_map) {
+ dout(30) << " extent " << e << dendl;
+ while (e.logical_offset >= shard_end) {
shard_start = shard_end;
++sp;
if (sp == esp) {
dout(30) << __func__ << " shard 0x" << std::hex << shard_start
<< " to 0x" << shard_end << std::dec << dendl;
}
- if (ep->blob->id < 0 &&
- ep->blob_escapes_range(shard_start, shard_end - shard_start)) {
+ if (e.blob->id < 0 &&
+ e.blob_escapes_range(shard_start, shard_end - shard_start)) {
// We have two options: (1) split the blob into pieces at the
// shard boundaries (and adjust extents accordingly), or (2)
// mark it spanning. We prefer to cut the blob if we can. Note that
// we may have to split it multiple times--potentially at every
// shard boundary.
bool must_span = false;
- BlobRef b = ep->blob;
+ BlobRef b = e.blob;
if (b->can_split()) {
- uint32_t bstart = ep->logical_offset - ep->blob_offset;
+ uint32_t bstart = e.logical_offset - e.blob_offset;
uint32_t bend = bstart + b->get_blob().get_logical_length();
for (const auto& sh : shards) {
if (bstart < sh.offset && bend > sh.offset) {
dout(20) << __func__ << " adding spanning " << *b << dendl;
}
}
- ++ep;
}
}
}