Skip to content

Commit

Permalink
rgw: RGWMetaSyncShardCR drops stack refs on destruction
Browse files Browse the repository at this point in the history
if the coroutine is canceled before collect_children() can clean up
all of its child stacks, those stack refs will leak. store these
stacks as boost::intrusive_ptr so the ref is dropped automatically on
destruction

Fixes: http://tracker.ceph.com/issues/18300

Signed-off-by: Casey Bodley <cbodley@redhat.com>
  • Loading branch information
cbodley committed Dec 21, 2016
1 parent af21f0d commit 9aeb2b4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/rgw/rgw_sync.cc
Expand Up @@ -1269,7 +1269,9 @@ class RGWMetaSyncShardCR : public RGWCoroutine {

bool *reset_backoff;

map<RGWCoroutinesStack *, string> stack_to_pos;
// hold a reference to the cr stack while it's in the map
using StackRef = boost::intrusive_ptr<RGWCoroutinesStack>;
map<StackRef, string> stack_to_pos;
map<string, string> pos_to_prev;

bool can_adjust_marker = false;
Expand Down Expand Up @@ -1331,7 +1333,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine {
int child_ret;
RGWCoroutinesStack *child;
while (collect_next(&child_ret, &child)) {
map<RGWCoroutinesStack *, string>::iterator iter = stack_to_pos.find(child);
auto iter = stack_to_pos.find(child);
if (iter == stack_to_pos.end()) {
/* some other stack that we don't care about */
continue;
Expand Down Expand Up @@ -1371,8 +1373,6 @@ class RGWMetaSyncShardCR : public RGWCoroutine {

ldout(sync_env->cct, 0) << *this << ": adjusting marker pos=" << sync_marker.marker << dendl;
stack_to_pos.erase(iter);

child->put();
}
}

Expand Down Expand Up @@ -1443,8 +1443,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine {
// fetch remote and write locally
yield {
RGWCoroutinesStack *stack = spawn(new RGWMetaSyncSingleEntryCR(sync_env, iter->first, iter->first, MDLOG_STATUS_COMPLETE, marker_tracker), false);
stack->get();

// stack_to_pos holds a reference to the stack
stack_to_pos[stack] = iter->first;
pos_to_prev[iter->first] = marker;
}
Expand Down Expand Up @@ -1592,8 +1591,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine {
yield {
RGWCoroutinesStack *stack = spawn(new RGWMetaSyncSingleEntryCR(sync_env, raw_key, log_iter->id, mdlog_entry.log_data.status, marker_tracker), false);
assert(stack);
stack->get();

// stack_to_pos holds a reference to the stack
stack_to_pos[stack] = log_iter->id;
pos_to_prev[log_iter->id] = marker;
}
Expand Down

0 comments on commit 9aeb2b4

Please sign in to comment.