From 60778b02146e29e0e414345d519502be9fe876da Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 16 May 2017 15:30:32 -0700 Subject: [PATCH] rgw: update data log after index completion reshard handling Also rearrange code a bit. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 47 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 02d827154ada8..5bacb037afcbe 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3430,33 +3430,40 @@ int RGWIndexCompletionThread::process() completions.swap(comps); } - for (auto c: comps) { - if (!going_down()) { - ldout(store->ctx(), 20) << __func__ << "(): handling completion for key=" << c->key << dendl; + for (auto c : comps) { + std::unique_ptr up{c}; - RGWRados::BucketShard bs(store); + if (going_down()) { + continue; + } + ldout(store->ctx(), 20) << __func__ << "(): handling completion for key=" << c->key << dendl; - int r = bs.init(c->obj.bucket, c->obj); - if (r < 0) { - ldout(cct, 0) << "ERROR: " << __func__ << "(): failed to initialize BucketShard, obj=" << c->obj << " r=" << r << dendl; - /* not much to do */ - delete c; - continue; - } + RGWRados::BucketShard bs(store); - r = store->guard_reshard(&bs, c->obj, [&](RGWRados::BucketShard *bs) -> int { - librados::ObjectWriteOperation o; - cls_rgw_guard_bucket_resharding(o, -ERR_BUSY_RESHARDING); - cls_rgw_bucket_complete_op(o, c->op, c->tag, c->ver, c->key, c->dir_meta, &c->remove_objs, - c->log_op, c->bilog_op); + int r = bs.init(c->obj.bucket, c->obj); + if (r < 0) { + ldout(cct, 0) << "ERROR: " << __func__ << "(): failed to initialize BucketShard, obj=" << c->obj << " r=" << r << dendl; + /* not much to do */ + continue; + } - return bs->index_ctx.operate(bs->bucket_obj, &o); - }); - ldout(cct, 0) << "ERROR: " << __func__ << "(): bucket index completion failed, obj=" << c->obj << " r=" << r << dendl; + r = store->guard_reshard(&bs, c->obj, [&](RGWRados::BucketShard *bs) -> int { + librados::ObjectWriteOperation o; + cls_rgw_guard_bucket_resharding(o, -ERR_BUSY_RESHARDING); + cls_rgw_bucket_complete_op(o, c->op, c->tag, c->ver, c->key, c->dir_meta, &c->remove_objs, + c->log_op, c->bilog_op); + return bs->index_ctx.operate(bs->bucket_obj, &o); + }); + if (r < 0) { + ldout(cct, 0) << "ERROR: " << __func__ << "(): bucket index completion failed, obj=" << c->obj << " r=" << r << dendl; /* ignoring error, can't do anything about it */ + continue; + } + r = store->data_log->add_entry(bs.bucket, bs.shard_id); + if (r < 0) { + lderr(store->ctx()) << "ERROR: failed writing data log" << dendl; } - delete c; } return 0; -- 2.39.5