mirror of
https://github.com/ceph/ceph
synced 2025-02-19 17:08:05 +00:00
osd/: add sync/async read methods to PGBackend
Signed-off-by: Samuel Just <sam.just@inktank.com>
This commit is contained in:
parent
66bc91cf0a
commit
2fe5e1f2d2
@ -185,6 +185,7 @@ OSDService::OSDService(OSD *osd) :
|
||||
scrub_finalize_wq(osd->scrub_finalize_wq),
|
||||
rep_scrub_wq(osd->rep_scrub_wq),
|
||||
push_wq("push_wq", cct->_conf->osd_recovery_thread_timeout, &osd->recovery_tp),
|
||||
gen_wq("gen_wq", cct->_conf->osd_recovery_thread_timeout, &osd->recovery_tp),
|
||||
class_handler(osd->class_handler),
|
||||
publish_lock("OSDService::publish_lock"),
|
||||
pre_publish_lock("OSDService::pre_publish_lock"),
|
||||
|
@ -312,6 +312,7 @@ public:
|
||||
ThreadPool::WorkQueue<PG> &scrub_finalize_wq;
|
||||
ThreadPool::WorkQueue<MOSDRepScrub> &rep_scrub_wq;
|
||||
GenContextWQ push_wq;
|
||||
GenContextWQ gen_wq;
|
||||
ClassHandler *&class_handler;
|
||||
|
||||
void dequeue_pg(PG *pg, list<OpRequestRef> *dequeued);
|
||||
|
@ -416,6 +416,19 @@
|
||||
virtual int objects_get_attrs(
|
||||
const hobject_t &hoid,
|
||||
map<string, bufferlist> *out) = 0;
|
||||
|
||||
virtual int objects_read_sync(
|
||||
const hobject_t &hoid,
|
||||
uint64_t off,
|
||||
uint64_t len,
|
||||
bufferlist *bl) = 0;
|
||||
|
||||
virtual void objects_read_async(
|
||||
const hobject_t &hoid,
|
||||
uint64_t off,
|
||||
uint64_t len,
|
||||
bufferlist *bl,
|
||||
Context *on_complete) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -324,6 +324,41 @@ int ReplicatedBackend::objects_get_attrs(
|
||||
*out);
|
||||
}
|
||||
|
||||
int ReplicatedBackend::objects_read_sync(
|
||||
const hobject_t &hoid,
|
||||
uint64_t off,
|
||||
uint64_t len,
|
||||
bufferlist *bl)
|
||||
{
|
||||
return osd->store->read(coll, hoid, off, len, *bl);
|
||||
}
|
||||
|
||||
struct AsyncReadCallback : public GenContext<ThreadPool::TPHandle&> {
|
||||
int r;
|
||||
Context *c;
|
||||
AsyncReadCallback(int r, Context *c) : r(r), c(c) {}
|
||||
void finish(ThreadPool::TPHandle&) {
|
||||
c->complete(r);
|
||||
c = NULL;
|
||||
}
|
||||
~AsyncReadCallback() {
|
||||
delete c;
|
||||
}
|
||||
};
|
||||
void ReplicatedBackend::objects_read_async(
|
||||
const hobject_t &hoid,
|
||||
uint64_t off,
|
||||
uint64_t len,
|
||||
bufferlist *bl,
|
||||
Context *on_complete)
|
||||
{
|
||||
int r = osd->store->read(coll, hoid, off, len, *bl);
|
||||
osd->gen_wq.queue(
|
||||
get_parent()->bless_gencontext(
|
||||
new AsyncReadCallback(r, on_complete)));
|
||||
}
|
||||
|
||||
|
||||
class RPGTransaction : public PGBackend::PGTransaction {
|
||||
coll_t coll;
|
||||
coll_t temp_coll;
|
||||
|
@ -176,6 +176,19 @@ public:
|
||||
const hobject_t &hoid,
|
||||
map<string, bufferlist> *out);
|
||||
|
||||
int objects_read_sync(
|
||||
const hobject_t &hoid,
|
||||
uint64_t off,
|
||||
uint64_t len,
|
||||
bufferlist *bl);
|
||||
|
||||
void objects_read_async(
|
||||
const hobject_t &hoid,
|
||||
uint64_t off,
|
||||
uint64_t len,
|
||||
bufferlist *bl,
|
||||
Context *on_complete);
|
||||
|
||||
private:
|
||||
// push
|
||||
struct PushInfo {
|
||||
|
Loading…
Reference in New Issue
Block a user