Skip to content

Commit 60bf547

Browse files
authored
Merge pull request ceph#63930 from cbodley/wip-cls-rgw-BucketIndexAioManager
cls/rgw: remove unused class BucketIndexAioManager Reviewed-by: Adam C. Emerson <[email protected]>
2 parents 9695812 + 4cc8997 commit 60bf547

File tree

2 files changed

+0
-213
lines changed

2 files changed

+0
-213
lines changed

src/cls/rgw/cls_rgw_client.cc

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -49,82 +49,6 @@ class ClsBucketIndexOpCtx : public ObjectOperationCompletion {
4949
}
5050
};
5151

52-
void BucketIndexAioManager::do_completion(const int request_id) {
53-
std::lock_guard l{lock};
54-
55-
auto iter = pendings.find(request_id);
56-
ceph_assert(iter != pendings.end());
57-
completions[request_id] = iter->second;
58-
pendings.erase(iter);
59-
60-
// If the caller needs a list of finished objects, store them
61-
// for further processing
62-
auto miter = pending_objs.find(request_id);
63-
if (miter != pending_objs.end()) {
64-
completion_objs.emplace(request_id, miter->second);
65-
pending_objs.erase(miter);
66-
}
67-
68-
cond.notify_all();
69-
}
70-
71-
bool BucketIndexAioManager::wait_for_completions(int valid_ret_code,
72-
int *num_completions,
73-
int *ret_code,
74-
std::map<int, std::string> *completed_objs,
75-
std::map<int, std::string> *retry_objs)
76-
{
77-
std::unique_lock locker{lock};
78-
if (pendings.empty() && completions.empty()) {
79-
return false;
80-
}
81-
82-
if (completions.empty()) {
83-
// Wait for AIO completion
84-
cond.wait(locker);
85-
}
86-
87-
// Clear the completed AIOs
88-
auto iter = completions.begin();
89-
for (; iter != completions.end(); ++iter) {
90-
int r = iter->second->get_return_value();
91-
92-
// see if we may need to copy completions or retries
93-
if (completed_objs || retry_objs) {
94-
auto liter = completion_objs.find(iter->first);
95-
if (liter != completion_objs.end()) {
96-
if (completed_objs && r == 0) { /* update list of successfully completed objs */
97-
(*completed_objs)[liter->second.shard_id] = liter->second.oid;
98-
}
99-
100-
if (r == RGWBIAdvanceAndRetryError) {
101-
r = 0;
102-
if (retry_objs) {
103-
(*retry_objs)[liter->second.shard_id] = liter->second.oid;
104-
}
105-
}
106-
} else {
107-
// NB: should we log an error here; currently no logging
108-
// context to use
109-
}
110-
}
111-
112-
if (ret_code && (r < 0 && r != valid_ret_code)) {
113-
(*ret_code) = r;
114-
}
115-
116-
iter->second->release();
117-
}
118-
119-
if (num_completions) {
120-
(*num_completions) = completions.size();
121-
}
122-
123-
completions.clear();
124-
125-
return true;
126-
}
127-
12852
void cls_rgw_bucket_init_index(ObjectWriteOperation& o)
12953
{
13054
bufferlist in;

src/cls/rgw/cls_rgw_client.h

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -16,143 +16,6 @@
1616
#include "common/ceph_mutex.h"
1717

1818

19-
// Forward declaration
20-
class BucketIndexAioManager;
21-
/*
22-
* Bucket index AIO request argument, this is used to pass a argument
23-
* to callback.
24-
*/
25-
struct BucketIndexAioArg : public RefCountedObject {
26-
BucketIndexAioArg(int _id, BucketIndexAioManager* _manager) :
27-
id(_id), manager(_manager) {}
28-
int id;
29-
BucketIndexAioManager* manager;
30-
};
31-
32-
/*
33-
* This class manages AIO completions. This class is not completely
34-
* thread-safe, methods like *get_next_request_id* is not thread-safe
35-
* and is expected to be called from within one thread.
36-
*/
37-
class BucketIndexAioManager {
38-
public:
39-
40-
// allows us to reaccess the shard id and shard's oid during and
41-
// after the asynchronous call is made
42-
struct RequestObj {
43-
int shard_id;
44-
std::string oid;
45-
46-
RequestObj(int _shard_id, const std::string& _oid) :
47-
shard_id(_shard_id), oid(_oid)
48-
{/* empty */}
49-
};
50-
51-
52-
private:
53-
// NB: the following 4 maps use the request_id as the key; this
54-
// is not the same as the shard_id!
55-
std::map<int, librados::AioCompletion*> pendings;
56-
std::map<int, librados::AioCompletion*> completions;
57-
std::map<int, const RequestObj> pending_objs;
58-
std::map<int, const RequestObj> completion_objs;
59-
60-
int next = 0;
61-
ceph::mutex lock = ceph::make_mutex("BucketIndexAioManager::lock");
62-
ceph::condition_variable cond;
63-
/*
64-
* Callback implementation for AIO request.
65-
*/
66-
static void bucket_index_op_completion_cb(void* cb, void* arg) {
67-
BucketIndexAioArg* cb_arg = (BucketIndexAioArg*) arg;
68-
cb_arg->manager->do_completion(cb_arg->id);
69-
cb_arg->put();
70-
}
71-
72-
/*
73-
* Get next request ID. This method is not thread-safe.
74-
*
75-
* Return next request ID.
76-
*/
77-
int get_next_request_id() { return next++; }
78-
79-
/*
80-
* Add a new pending AIO completion instance.
81-
*
82-
* @param id - the request ID.
83-
* @param completion - the AIO completion instance.
84-
* @param oid - the object id associated with the object, if it is NULL, we don't
85-
* track the object id per callback.
86-
*/
87-
void add_pending(int request_id, librados::AioCompletion* completion, const int shard_id, const std::string& oid) {
88-
pendings[request_id] = completion;
89-
pending_objs.emplace(request_id, RequestObj(shard_id, oid));
90-
}
91-
92-
public:
93-
/*
94-
* Create a new instance.
95-
*/
96-
BucketIndexAioManager() = default;
97-
98-
/*
99-
* Do completion for the given AIO request.
100-
*/
101-
void do_completion(int request_id);
102-
103-
/*
104-
* Wait for AIO completions.
105-
*
106-
* valid_ret_code - valid AIO return code.
107-
* num_completions - number of completions.
108-
* ret_code - return code of failed AIO.
109-
* objs - a std::list of objects that has been finished the AIO.
110-
*
111-
* Return false if there is no pending AIO, true otherwise.
112-
*/
113-
bool wait_for_completions(int valid_ret_code,
114-
int *num_completions = nullptr,
115-
int *ret_code = nullptr,
116-
std::map<int, std::string> *completed_objs = nullptr,
117-
std::map<int, std::string> *retry_objs = nullptr);
118-
119-
/**
120-
* Do aio read operation.
121-
*/
122-
bool aio_operate(librados::IoCtx& io_ctx, const int shard_id, const std::string& oid, librados::ObjectReadOperation *op) {
123-
std::lock_guard l{lock};
124-
const int request_id = get_next_request_id();
125-
BucketIndexAioArg *arg = new BucketIndexAioArg(request_id, this);
126-
librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, bucket_index_op_completion_cb);
127-
int r = io_ctx.aio_operate(oid, c, (librados::ObjectReadOperation*)op, NULL);
128-
if (r >= 0) {
129-
add_pending(arg->id, c, shard_id, oid);
130-
} else {
131-
arg->put();
132-
c->release();
133-
}
134-
return r;
135-
}
136-
137-
/**
138-
* Do aio write operation.
139-
*/
140-
bool aio_operate(librados::IoCtx& io_ctx, const int shard_id, const std::string& oid, librados::ObjectWriteOperation *op) {
141-
std::lock_guard l{lock};
142-
const int request_id = get_next_request_id();
143-
BucketIndexAioArg *arg = new BucketIndexAioArg(request_id, this);
144-
librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, bucket_index_op_completion_cb);
145-
int r = io_ctx.aio_operate(oid, c, (librados::ObjectWriteOperation*)op);
146-
if (r >= 0) {
147-
add_pending(arg->id, c, shard_id, oid);
148-
} else {
149-
arg->put();
150-
c->release();
151-
}
152-
return r;
153-
}
154-
};
155-
15619
class RGWGetDirHeader_CB : public boost::intrusive_ref_counter<RGWGetDirHeader_CB> {
15720
public:
15821
virtual ~RGWGetDirHeader_CB() {}

0 commit comments

Comments
 (0)