assert(0 == "this is all broken");
- uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size;
-
- uint64_t offset = 0;
- uint64_t length = 0;
- bluestore_wal_op_t *op = NULL;
-
- map<uint64_t,bluestore_overlay_t>::iterator p =
- o->onode.overlay_map.lower_bound(orig_offset);
- while (true) {
- if (p != o->onode.overlay_map.end() && p->first < orig_offset + orig_length) {
- if (!op) {
- dout(10) << __func__ << " overlay " << p->first
- << "~" << p->second.length << " " << p->second
- << " (first)" << dendl;
- op = _get_wal_op(txc, o);
- op->nid = o->onode.nid;
- op->op = bluestore_wal_op_t::OP_WRITE;
- op->overlays.push_back(p->second);
- offset = p->first;
- length = p->second.length;
-
- if (o->onode.put_overlay_ref(p->second.key)) {
- string key;
- get_overlay_key(o->onode.nid, p->second.key, &key);
- txc->t->rm_single_key(PREFIX_OVERLAY, key);
- }
- o->onode.overlay_map.erase(p++);
- continue;
- }
-
- // contiguous? and in the same allocation unit?
- if (offset + length == p->first &&
- p->first % min_alloc_size) {
- dout(10) << __func__ << " overlay " << p->first
- << "~" << p->second.length << " " << p->second
- << " (contiguous)" << dendl;
- op->overlays.push_back(p->second);
- length += p->second.length;
-
- if (o->onode.put_overlay_ref(p->second.key)) {
- string key;
- get_overlay_key(o->onode.nid, p->second.key, &key);
- txc->t->rm_single_key(PREFIX_OVERLAY, key);
- }
- o->onode.overlay_map.erase(p++);
- continue;
- }
- }
- if (!op) {
- break;
- }
- assert(length <= min_alloc_size);
-
- // emit
- map<uint64_t, bluestore_extent_t>::iterator bp = o->onode.find_extent(offset);
- if (bp == o->onode.block_map.end() ||
- length == min_alloc_size) {
- uint64_t cow_rmw_head = 0, cow_rmw_tail = 0;
- int r = _do_allocate(txc, c, o, offset, length, 0, false,
- &cow_rmw_head, &cow_rmw_tail);
- if (r < 0)
- return r;
- bp = o->onode.find_extent(offset);
- if (bp->second.has_flag(bluestore_extent_t::FLAG_UNWRITTEN)) {
- dout(10) << __func__ << " zero new allocation " << bp->second << dendl;
- bdev->aio_zero(bp->second.offset, bp->second.length, &txc->ioc);
- bp->second.clear_flag(bluestore_extent_t::FLAG_UNWRITTEN);
- }
- }
- uint64_t x_off = offset - bp->first;
- dout(10) << __func__ << " wal write " << offset << "~" << length
- << " to extent " << bp->first << ": " << bp->second
- << " x_off " << x_off << " overlay data from "
- << offset << "~" << length << dendl;
- op->extent.offset = bp->second.offset + x_off;
- op->extent.length = length;
- op = NULL;
-
- if (p == o->onode.overlay_map.end() || p->first >= orig_offset + orig_length) {
- break;
- }
- ++p;
- }
-
txc->write_onode(o);
return 0;
}