}
class GetDirHeaderCompletion : public ObjectOperationCompletion {
- RGWGetDirHeader_CB *ret_ctx;
+ boost::intrusive_ptr<RGWGetDirHeader_CB> cb;
public:
- explicit GetDirHeaderCompletion(RGWGetDirHeader_CB *_ctx) : ret_ctx(_ctx) {}
- ~GetDirHeaderCompletion() override {
- ret_ctx->put();
- }
+ explicit GetDirHeaderCompletion(boost::intrusive_ptr<RGWGetDirHeader_CB> cb)
+ : cb(std::move(cb)) {}
+
void handle_completion(int r, bufferlist& outbl) override {
rgw_cls_list_ret ret;
try {
} catch (ceph::buffer::error& err) {
r = -EIO;
}
-
- ret_ctx->handle_response(r, ret.dir.header);
+ cb->handle_response(r, ret.dir.header);
}
};
-int cls_rgw_get_dir_header_async(IoCtx& io_ctx, string& oid, RGWGetDirHeader_CB *ctx)
+int cls_rgw_get_dir_header_async(IoCtx& io_ctx, const string& oid,
+ boost::intrusive_ptr<RGWGetDirHeader_CB> cb)
{
bufferlist in, out;
rgw_cls_list_op call;
call.num_entries = 0;
encode(call, in);
ObjectReadOperation op;
- GetDirHeaderCompletion *cb = new GetDirHeaderCompletion(ctx);
- op.exec(RGW_CLASS, RGW_BUCKET_LIST, in, cb);
+ op.exec(RGW_CLASS, RGW_BUCKET_LIST, in,
+ new GetDirHeaderCompletion(std::move(cb)));
AioCompletion *c = librados::Rados::aio_create_completion(nullptr, nullptr);
int r = io_ctx.aio_operate(oid, c, &op, NULL);
c->release();
#pragma once
+#include <boost/intrusive_ptr.hpp>
+#include <boost/smart_ptr/intrusive_ref_counter.hpp>
#include "include/str_list.h"
#include "include/rados/librados.hpp"
#include "cls_rgw_ops.h"
}
};
-class RGWGetDirHeader_CB : public RefCountedObject {
+class RGWGetDirHeader_CB : public boost::intrusive_ref_counter<RGWGetDirHeader_CB> {
public:
- ~RGWGetDirHeader_CB() override {}
- virtual void handle_response(int r, rgw_bucket_dir_header& header) = 0;
+ virtual ~RGWGetDirHeader_CB() {}
+ virtual void handle_response(int r, const rgw_bucket_dir_header& header) = 0;
};
class BucketIndexShardsManager {
virtual ~CLSRGWIssueBucketBILogStop() override {}
};
-int cls_rgw_get_dir_header_async(librados::IoCtx& io_ctx, std::string& oid, RGWGetDirHeader_CB *ctx);
+int cls_rgw_get_dir_header_async(librados::IoCtx& io_ctx, const std::string& oid,
+ boost::intrusive_ptr<RGWGetDirHeader_CB> cb);
void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, ceph::buffer::list& updates);
: cb(std::move(cb)), pendings(_pendings), stats(), ret_code(0), should_cb(true)
{}
- void handle_response(int r, rgw_bucket_dir_header& header) override {
+ void handle_response(int r, const rgw_bucket_dir_header& header) override {
std::lock_guard l{lock};
if (should_cb) {
if (r >= 0) {
int RGWRados::get_bucket_stats_async(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout, int shard_id, boost::intrusive_ptr<rgw::sal::ReadStatsCB> cb)
{
int num_aio = 0;
- RGWGetBucketStatsContext *get_ctx = new RGWGetBucketStatsContext(std::move(cb), bucket_info.layout.current_index.layout.normal.num_shards ? : 1);
- ceph_assert(get_ctx);
- int r = cls_bucket_head_async(dpp, bucket_info, idx_layout, shard_id, get_ctx, &num_aio);
+ boost::intrusive_ptr headercb = new RGWGetBucketStatsContext(std::move(cb), bucket_info.layout.current_index.layout.normal.num_shards ? : 1);
+ int r = cls_bucket_head_async(dpp, bucket_info, idx_layout, shard_id, headercb, &num_aio);
if (r < 0) {
if (num_aio) {
- get_ctx->unset_cb();
+ headercb->unset_cb();
}
}
- get_ctx->put();
return r;
}
return 0;
}
-int RGWRados::cls_bucket_head_async(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout, int shard_id, RGWGetDirHeader_CB *ctx, int *num_aio)
+int RGWRados::cls_bucket_head_async(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info,
+ const rgw::bucket_index_layout_generation& idx_layout, int shard_id,
+ boost::intrusive_ptr<RGWGetDirHeader_CB> cb, int *num_aio)
{
RGWSI_RADOS::Pool index_pool;
map<int, string> bucket_objs;
if (r < 0)
return r;
- map<int, string>::iterator iter = bucket_objs.begin();
- for (; iter != bucket_objs.end(); ++iter) {
- r = cls_rgw_get_dir_header_async(index_pool.ioctx(), iter->second, static_cast<RGWGetDirHeader_CB*>(ctx->get()));
+ for (auto& pair : bucket_objs) {
+ r = cls_rgw_get_dir_header_async(index_pool.ioctx(), pair.second, cb);
if (r < 0) {
- ctx->put();
- break;
- } else {
- (*num_aio)++;
+ return r;
}
+ (*num_aio)++;
}
- return r;
+ return 0;
}
int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info,
int cls_bucket_head_async(const DoutPrefixProvider *dpp,
const RGWBucketInfo& bucket_info,
const rgw::bucket_index_layout_generation& idx_layout,
- int shard_id, RGWGetDirHeader_CB *ctx, int *num_aio);
+ int shard_id, boost::intrusive_ptr<RGWGetDirHeader_CB> cb, int *num_aio);
int bi_get_instance(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, rgw_bucket_dir_entry *dirent, optional_yield y);
int bi_get_olh(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, rgw_bucket_olh_entry *olh, optional_yield y);
int bi_get(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, BIIndexType index_type, rgw_cls_bi_entry *entry, optional_yield y);