}
void sparse_copyup(neorados::WriteOp* op,
- const std::map<uint64_t, uint64_t> &extent_map,
+ const std::vector<std::pair<uint64_t, uint64_t>>& extent_map,
ceph::buffer::list data) {
sparse_copyup<neorados::WriteOp>(op, extent_map, data);
}
ceph::buffer::list data);
void sparse_copyup(neorados::WriteOp* op,
- const std::map<uint64_t, uint64_t> &extent_map,
+ const std::vector<std::pair<uint64_t, uint64_t>>& extent_map,
ceph::buffer::list data);
void sparse_copyup(librados::ObjectWriteOperation *op,
const std::map<uint64_t, uint64_t> &extent_map,
WRITE_OP_TYPE_REMOVE_TRUNC,
};
- typedef std::map<uint64_t, uint64_t> ExtentMap;
-
struct ReadOp {
interval_set<uint64_t> image_interval;
- ExtentMap image_extent_map;
+ io::Extents image_extent_map;
bufferlist out_bl;
};
}
// convert the image-extent extent map to object-extents
- ExtentMap image_extent_map;
+ Extents image_extent_map;
image_extent_map.swap(m_copyup_extent_map);
+ m_copyup_extent_map.reserve(m_copyup_extent_map.size());
+
for (auto [image_offset, image_length] : image_extent_map) {
striper::LightweightObjectExtents object_extents;
Striper::file_to_extents(
cct, &m_image_ctx->layout, image_offset, image_length, 0, 0,
&object_extents);
for (auto& object_extent : object_extents) {
- m_copyup_extent_map[object_extent.offset] = object_extent.length;
+ m_copyup_extent_map.emplace_back(
+ object_extent.offset, object_extent.length);
}
}
bool m_copyup_is_zero = true;
bool m_deep_copied = false;
- std::map<uint64_t, uint64_t> m_copyup_extent_map;
+ Extents m_copyup_extent_map;
ceph::bufferlist m_copyup_data;
AsyncOperation m_async_op;
}
void operator()(SparseBufferlist &sparse_bufferlist) const {
- sparse_bufferlist.extent_map->clear();
sparse_bufferlist.bl->clear();
- auto buffer_extents_length = destriper.assemble_result(
- cct, sparse_bufferlist.extent_map, sparse_bufferlist.bl);
ExtentMap buffer_extent_map;
- buffer_extent_map.swap(*sparse_bufferlist.extent_map);
+ auto buffer_extents_length = destriper.assemble_result(
+ cct, &buffer_extent_map, sparse_bufferlist.bl);
+
ldout(cct, 20) << "image_extents="
<< sparse_bufferlist.image_extents << ", "
<< "buffer_extent_map=" << buffer_extent_map << dendl;
+ sparse_bufferlist.extent_map->clear();
+ sparse_bufferlist.extent_map->reserve(buffer_extent_map.size());
+
// The extent-map is logically addressed by buffer-extents not image- or
// object-extents. Translate this address mapping to image-extent
// logical addressing since it's tied to an image-extent read
<< "~" << buffer_extent_length << " to image extent "
<< image_extent_offset << "~" << buffer_extent_length
<< dendl;
- (*sparse_bufferlist.extent_map)[image_extent_offset] =
- buffer_extent_length;
+ sparse_bufferlist.extent_map->emplace_back(
+ image_extent_offset, buffer_extent_length);
++bem_it;
}
: m_buffer(Bufferlist(bl)) {
}
-ReadResult::ReadResult(std::map<uint64_t, uint64_t> *extent_map,
- ceph::bufferlist *bl)
+ReadResult::ReadResult(Extents* extent_map, ceph::bufferlist* bl)
: m_buffer(SparseBufferlist(extent_map, bl)) {
}
ReadResult(char *buf, size_t buf_len);
ReadResult(const struct iovec *iov, int iov_count);
ReadResult(ceph::bufferlist *bl);
- ReadResult(std::map<uint64_t, uint64_t> *extent_map, ceph::bufferlist *bl);
+ ReadResult(Extents* extent_map, ceph::bufferlist* bl);
void set_clip_length(size_t length);
void set_image_extents(const Extents& image_extents);
};
struct SparseBufferlist {
- std::map<uint64_t, uint64_t> *extent_map;
+ Extents *extent_map;
ceph::bufferlist *bl;
Extents image_extents;
- SparseBufferlist(std::map<uint64_t, uint64_t> *extent_map,
- ceph::bufferlist *bl)
+ SparseBufferlist(Extents* extent_map, ceph::bufferlist* bl)
: extent_map(extent_map), bl(bl) {
}
};
BOOST_SCOPE_EXIT(ictx3) {
ictx3->state->close();
} BOOST_SCOPE_EXIT_END;
- std::map<uint64_t, uint64_t> expected_m;
+ std::vector<std::pair<uint64_t, uint64_t>> expected_m;
bufferlist expected_bl;
if (ictx3->enable_sparse_copyup && sparse_read_supported) {
if (snap_name == NULL) {
expected_bl.append(std::string(256 * 1, '1'));
}
}
- std::map<uint64_t, uint64_t> read_m;
+ std::vector<std::pair<uint64_t, uint64_t>> read_m;
librbd::io::ReadResult sparse_read_result{&read_m, &read_bl};
EXPECT_EQ(1024 + 256,
api::Io<>::read(*ictx3, 0, 1024 + 256,