Skip to content

Commit

Permalink
librbd: clean up object map update interface, revisited
Browse files Browse the repository at this point in the history
In master, the "batch update" change [1] was merged before
the "order concurrent updates" [2], while in jewel the latter
is already backported [3]. A partial backport of [1]
was attempted, but the automated cherry-pick missed some
parts of it which this commit is adding manually.

[1] ceph#11510
[2] ceph#12420
[3] ceph#12909

Signed-off-by: Mykola Golub <mgolub@mirantis.com>
Signed-off-by: Nathan Cutler <ncutler@suse.com>
  • Loading branch information
smithfarm committed Aug 26, 2017
1 parent ca55778 commit c1124ec
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions src/librbd/operation/TrimRequest.cc
Expand Up @@ -264,32 +264,26 @@ void TrimRequest<I>::send_pre_copyup() {
m_copyup_start = m_delete_start;
m_delete_start = m_copyup_end;

bool copyup_objects = false;
{
RWLock::RLocker snap_locker(image_ctx.snap_lock);
if (image_ctx.object_map == nullptr) {
copyup_objects = true;
} else {
if (image_ctx.object_map != nullptr) {
ldout(image_ctx.cct, 5) << this << " send_pre_copyup: "
<< " copyup_start=" << m_copyup_start
<< " copyup_end=" << m_copyup_end << dendl;
m_state = STATE_PRE_COPYUP;

assert(image_ctx.exclusive_lock->is_lock_owner());

Context *ctx = this->create_callback_context();
RWLock::WLocker object_map_locker(image_ctx.object_map_lock);
if (!image_ctx.object_map->aio_update(m_copyup_start, m_copyup_end,
OBJECT_PENDING, OBJECT_EXISTS, ctx)) {
delete ctx;
copyup_objects = true;
if (image_ctx.object_map->template aio_update<AsyncRequest<I> >(
CEPH_NOSNAP, m_copyup_start, m_copyup_end, OBJECT_PENDING,
OBJECT_EXISTS, this)) {
return;
}
}
}

if (copyup_objects) {
send_copyup_objects();
}
send_copyup_objects();
}

template <typename I>
Expand Down Expand Up @@ -330,32 +324,26 @@ void TrimRequest<I>::send_post_copyup() {
I &image_ctx = this->m_image_ctx;
assert(image_ctx.owner_lock.is_locked());

bool pre_remove_objects = false;
{
RWLock::RLocker snap_locker(image_ctx.snap_lock);
if (image_ctx.object_map == nullptr) {
pre_remove_objects = true;
} else {
if (image_ctx.object_map != nullptr) {
ldout(image_ctx.cct, 5) << this << " send_post_copyup:"
<< " copyup_start=" << m_copyup_start
<< " copyup_end=" << m_copyup_end << dendl;
m_state = STATE_POST_COPYUP;

assert(image_ctx.exclusive_lock->is_lock_owner());

Context *ctx = this->create_callback_context();
RWLock::WLocker object_map_locker(image_ctx.object_map_lock);
if (!image_ctx.object_map->aio_update(m_copyup_start, m_copyup_end,
OBJECT_NONEXISTENT, OBJECT_PENDING, ctx)) {
delete ctx;
pre_remove_objects = true;
if (image_ctx.object_map->template aio_update<AsyncRequest<I> >(
CEPH_NOSNAP, m_copyup_start, m_copyup_end, OBJECT_NONEXISTENT,
OBJECT_PENDING, this)) {
return;
}
}
}

if (pre_remove_objects) {
send_pre_remove();
}
send_pre_remove();
}

template <typename I>
Expand Down

0 comments on commit c1124ec

Please sign in to comment.