From: Mykola Golub Date: Mon, 19 Nov 2018 17:59:46 +0000 (+0200) Subject: librbd: restart io if migration parent gone X-Git-Tag: v14.1.0~716^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cda8ce13dcceafaf784d166ddbe8d25a5ec29699;p=ceph.git librbd: restart io if migration parent gone Fixes: http://tracker.ceph.com/issues/36710 Signed-off-by: Mykola Golub --- diff --git a/src/librbd/io/ObjectRequest.cc b/src/librbd/io/ObjectRequest.cc index a66a06f4da23..fd1c509f153f 100644 --- a/src/librbd/io/ObjectRequest.cc +++ b/src/librbd/io/ObjectRequest.cc @@ -378,20 +378,25 @@ AbstractObjectWriteRequest::AbstractObjectWriteRequest( { m_snaps.insert(m_snaps.end(), snapc.snaps.begin(), snapc.snaps.end()); - { - RWLock::RLocker snap_locker(ictx->snap_lock); - RWLock::RLocker parent_locker(ictx->parent_lock); - this->compute_parent_extents(&m_parent_extents, false); - } - if (this->m_object_off == 0 && this->m_object_len == ictx->get_object_size()) { m_full_object = true; } + compute_parent_info(); +} + +template +void AbstractObjectWriteRequest::compute_parent_info() { + I *image_ctx = this->m_ictx; + RWLock::RLocker snap_locker(image_ctx->snap_lock); + RWLock::RLocker parent_locker(image_ctx->parent_lock); + + this->compute_parent_extents(&m_parent_extents, false); + if (!this->has_parent() || (m_full_object && m_snaps.empty() && !is_post_copyup_write_required())) { - this->m_copyup_enabled = false; + m_copyup_enabled = false; } } @@ -494,6 +499,7 @@ void AbstractObjectWriteRequest::write_object() { if (m_copyup_enabled) { ldout(image_ctx->cct, 20) << "guarding write" << dendl; if (!image_ctx->migration_info.empty()) { + m_guarding_migration_write = true; cls_client::assert_snapc_seq( &write, m_snap_seq, cls::rbd::ASSERT_SNAPC_SEQ_LE_SNAPSET_SEQ); } else { @@ -521,11 +527,21 @@ void AbstractObjectWriteRequest::handle_write_object(int r) { ldout(image_ctx->cct, 20) << "r=" << r << dendl; r = filter_write_result(r); - if (r == -ENOENT || (r == -ERANGE && !image_ctx->migration_info.empty())) { + if (r == -ENOENT) { if (m_copyup_enabled) { copyup(); return; } + } else if (r == -ERANGE && m_guarding_migration_write) { + if (!image_ctx->migration_info.empty()) { + copyup(); + } else { + ldout(image_ctx->cct, 10) << "migration parent gone, restart io" << dendl; + m_guarding_migration_write = false; + compute_parent_info(); + write_object(); + } + return; } else if (r == -EILSEQ) { ldout(image_ctx->cct, 10) << "failed to write object" << dendl; this->finish(r); diff --git a/src/librbd/io/ObjectRequest.h b/src/librbd/io/ObjectRequest.h index f27dc9668c7e..7c111c968d46 100644 --- a/src/librbd/io/ObjectRequest.h +++ b/src/librbd/io/ObjectRequest.h @@ -244,6 +244,9 @@ private: bool m_object_may_exist = false; bool m_copyup_enabled = true; bool m_copyup_in_progress = false; + bool m_guarding_migration_write = false; + + void compute_parent_info(); void pre_write_object_map_update(); void handle_pre_write_object_map_update(int r);