BufferHead *bh = p->second;
dout(10) << "map_write bh " << *bh << " intersected" << endl;
- /*if (bh->is_dirty()) {
- // already dirty, let's use it.
- final = bh;
- } else {
- */
if (p->first < cur) {
assert(final == 0);
if (cur + max >= p->first + p->second->length()) {
split(final, cur+max);
}
} else if (p->first == cur) {
- /*if (bh->is_dirty()) {
- // already dirty, use it.
- }
- else*/
if (p->second->length() <= max) {
// whole bufferhead, piece of cake.
} else {
split(bh, cur + max); // just split
}
if (final)
- merge_left(final,bh);
+ merge_left(final, bh);
else
final = bh;
}
if (bl.length() < length) {
bufferptr bp(length - bl.length());
- dout(7) << "bh_read_finish padding with " << bp.length() << " bytes of zeroes" << endl;
+ bp.zero();
+ dout(7) << "bh_read_finish " << oid << " padding " << start << "~" << length
+ << " with " << bp.length() << " bytes of zeroes" << endl;
bl.push_back(bp);
}
for (map<off_t, BufferHead*>::iterator bh_it = hits.begin();
bh_it != hits.end();
bh_it++) {
- dout(10) << "readx hit bh " << *bh_it->second << endl;
+ dout(10) << "readx hit bh " << *bh_it->second << endl;
hit_ls.push_back(bh_it->second);
- }
+ }
// create reverse map of buffer offset -> object for the eventual result.
// this is over a single ObjectExtent, so we know that
// - the buffer frags need not be (and almost certainly aren't)
off_t opos = ex_it->start;
map<off_t, BufferHead*>::iterator bh_it = hits.begin();
- assert(bh_it->second->start() <= opos);
+ assert(bh_it->second->start() <= opos);
size_t bhoff = opos - bh_it->second->start();
map<size_t,size_t>::iterator f_it = ex_it->buffer_extents.begin();
size_t foff = 0;
size_t len = MIN(f_it->second - foff,
bh->length() - bhoff);
- stripe_map[f_it->first].substr_of(bh->bl,
- opos - bh->start(),
- len);
+ bufferlist bit; // put substr here first, since substr_of clobbers, and
+ // we may get multiple bh's at this stripe_map position
+ bit.substr_of(bh->bl,
+ opos - bh->start(),
+ len);
+ stripe_map[f_it->first].claim_append(bit);
+
opos += len;
bhoff += len;
foff += len;
dout(10) << "readx adding buffer len " << i->second.length() << " at " << pos << endl;
pos += i->second.length();
rd->bl->claim_append(i->second);
+ assert(rd->bl->length() == pos);
}
dout(10) << "readx result is " << rd->bl->length() << endl;