Merge pull request #21586 from trociny/wip-deep-copy-fixes

librbd: skip head object map update when deep copying object beyond image size

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2018-04-27 08:37:24 -04:00 committed by GitHub
commit 57a4628d11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

View File

@ -302,7 +302,8 @@ void ObjectMap<I>::aio_update(uint64_t snap_id, uint64_t start_object_no,
stringify(static_cast<uint32_t>(*current_state)) : "")
<< "->" << static_cast<uint32_t>(new_state) << dendl;
if (snap_id == CEPH_NOSNAP) {
if (end_object_no > m_object_map.size()) {
end_object_no = std::min(end_object_no, m_object_map.size());
if (start_object_no >= end_object_no) {
ldout(cct, 20) << "skipping update of invalid object map" << dendl;
m_image_ctx.op_work_queue->queue(on_finish, 0);
return;

View File

@ -69,6 +69,11 @@ public:
const ZTracer::Trace &parent_trace, T *callback_object) {
assert(start_object_no < end_object_no);
if (snap_id == CEPH_NOSNAP) {
end_object_no = std::min(end_object_no, m_object_map.size());
if (start_object_no >= end_object_no) {
return false;
}
auto it = m_object_map.begin() + start_object_no;
auto end_it = m_object_map.begin() + end_object_no;
for (; it != end_it; ++it) {

View File

@ -374,15 +374,16 @@ void ObjectCopyRequest<I>::send_update_object_map() {
finish_op_ctx->complete(0);
});
RWLock::WLocker object_map_locker(m_dst_image_ctx->object_map_lock);
m_dst_image_ctx->object_map_lock.get_write();
bool sent = m_dst_image_ctx->object_map->template aio_update<
Context, &Context::complete>(dst_snap_id, m_dst_object_number, object_state,
{}, {}, ctx);
m_dst_image_ctx->object_map_lock.put_write();
m_dst_image_ctx->snap_lock.put_read();
m_dst_image_ctx->owner_lock.put_read();
if (!sent) {
assert(dst_snap_id == CEPH_NOSNAP);
handle_update_object_map(0);
ctx->complete(0);
}
}

View File

@ -20,7 +20,7 @@ struct TestDeepCopy : public TestFixture {
int order = 22;
uint64_t size = (1 << order) * 20;
uint64_t features = 0;
bool old_format = get_features(&features);
bool old_format = !get_features(&features);
EXPECT_EQ(0, create_image_full_pp(m_rbd, m_ioctx, image_name, size,
features, old_format, &order));
ASSERT_EQ(0, open_image(image_name, &m_src_ictx));