_get_disk_space(in_blob_end - in_blob_offset, blob_allocs);
bblob.allocated(in_blob_offset, in_blob_end - in_blob_offset, blob_allocs);
_schedule_io(blob_allocs, 0, disk_data);
- bstore->_buffer_cache_write(txc, blob, in_blob_offset, disk_data,
- wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
dout(25) << __func__ << " 0x" << std::hex << disk_data.length()
<< "@" << in_blob_offset << std::dec << " -> "
_get_disk_space(in_blob_alloc_end - in_blob_alloc_offset, blob_allocs);
bblob.allocated(in_blob_alloc_offset, in_blob_alloc_end - in_blob_alloc_offset, blob_allocs);
_schedule_io(blob_allocs, in_blob_offset - in_blob_alloc_offset, disk_data);
- bstore->_buffer_cache_write(txc, blob, in_blob_offset, disk_data,
- wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
dout(25) << __func__ << " 0x" << std::hex << disk_data.length()
<< "@" << in_blob_offset << std::dec << " -> "
<< blob->print(pp_mode) << " no ref yet" << dendl;
<< " alloc_offset=" << alloc_offset
<< " -> " << blob->print(pp_mode) << dendl;
_schedule_io(blob_allocs, in_blob_offset - alloc_offset, disk_data);
- bstore->_buffer_cache_write(txc, blob, in_blob_offset, disk_data,
- wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
return blob;
}
_schedule_io(blob_allocs, 0, disk_data); //have to do before move()
bblob.allocated_full(blob_length, std::move(blob_allocs));
bblob.mark_used(0, blob_length); //todo - optimize; this obviously clears it
- bstore->_buffer_cache_write(txc, blob, 0, disk_data,
- wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
return blob;
}
emap.extent_map.insert(*le);
logical_offset += data_size;
- bstore->_buffer_cache_write(txc, b, in_blob_offset, data_at_left,
- wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
break;
}
}
emap.extent_map.insert(*le);
end_offset -= data_size;
- bstore->_buffer_cache_write(txc, b, in_blob_offset, data_at_right,
- wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
break;
}
}
released, pruned_blobs, shared_changed, statfs_delta);
dout(25) << "after punch_hole_2: " << std::endl << onode->print(pp_mode) << dendl;
+ // todo: if we align to disk block before splitting, we could do it in one go
+ uint32_t pos = location;
+ for (auto& b : bd) {
+ bstore->_buffer_cache_write(this->txc, onode, pos, b.disk_data,
+ wctx->buffered ? 0 : Buffer::FLAG_NOCACHE);
+ pos += b.disk_data.length();
+ }
+ ceph_assert(pos == data_end);
+
uint32_t au_size = bstore->min_alloc_size;
if (au_size != bstore->block_size) {
_try_put_data_on_allocated(location, data_end, ref_end, bd, after_punch_it);
void BlueStore::Writer::debug_iterate_buffers(
std::function<void(uint32_t offset, const bufferlist& data)> data_callback)
{
- for (auto& e : onode->extent_map.extent_map) {
- auto b = e.blob->dirty_bc()._data_lower_bound(e.blob_offset);
- uint32_t in_blob_offset = e.blob_offset;
- ceph_assert(b->second.offset <= in_blob_offset);
- ceph_assert(in_blob_offset + e.length <= b->second.offset + b->second.data.length());
- bufferlist data;
- data.substr_of(b->second.data, in_blob_offset - b->second.offset, e.length);
- data_callback(e.logical_offset, data);
+ for (const auto& b : onode->bc.buffer_map) {
+ data_callback(b.offset, b.data);
}
}
au_size = _au_size;
store = new BlueStore(g_ceph_context, "", au_size);
oc = BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- bc = BlueStore::BufferCacheShard::create(g_ceph_context, "lru", NULL);
+ bc = BlueStore::BufferCacheShard::create(store, "lru", NULL);
coll = ceph::make_ref<BlueStore::Collection>(store, oc, bc, coll_t());
}
void SetUp() override {
PExtentVector d_c = allocate_continue(al_end - al_hole_end);
bool blob_remains = al_start != al_hole_begin || al_hole_end != al_end;
- BlueStore::BlobRef b(new BlueStore::Blob);
+ BlueStore::BlobRef b(coll->new_blob());
coll->open_shared_blob(0, b);
blobs_created.insert(b);
if (!blob_remains) {
y = hole_range;
}
coll->make_blob_shared(rand(), b);
- BlueStore::BlobRef cb = new BlueStore::Blob();
+ BlueStore::BlobRef cb = coll->new_blob();
b->dup(*cb);
ceph_assert(d_b.size() == 1);
ceph_assert(d_b[0].length == hole_range);
}
append(disk_to_free, d_b_non_shared);
if (x < y) {
- cb->shared_blob->get_ref(d_b[0].offset + x, y - x);
+ cb->get_dirty_shared_blob()->get_ref(d_b[0].offset + x, y - x);
statfs_to_free.allocated() += y - x;
}
} else {
will_punch.offset + will_punch.length < blob_like.offset + blob_like.length;
PExtentVector disk = allocate(al_size);
- BlueStore::BlobRef b(new BlueStore::Blob);
+ BlueStore::BlobRef b(coll->new_blob());
coll->open_shared_blob(0, b);
blobs_created.insert(b);
if (!blob_remains) {
if (do_shared) {
create_additional_ref = rand() % 2 == 0;
coll->make_blob_shared(rand(), b);
- BlueStore::BlobRef cb = new BlueStore::Blob();
+ BlueStore::BlobRef cb = coll->new_blob();
b->dup(*cb);
ceph_assert(disk.size() == 1);
ceph_assert(disk[0].length == al_size);
if (create_additional_ref) {
- cb->shared_blob->get_ref(disk[0].offset, al_size);
+ cb->get_dirty_shared_blob()->get_ref(disk[0].offset, al_size);
}
}
statfs_to_free.stored() -= will_punch.length;