Skip to content

Commit

Permalink
librbd: C_ImageCacheRead bridge from Context to AioCompletion
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
Jason Dillaman committed May 13, 2016
1 parent 68a26f5 commit c8ff315
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/librbd/AioCompletion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@ void C_AioRead::finish(int r)
C_AioRequest::finish(r);
}

void C_ImageCacheRead::finish(int r) {
CephContext *cct = m_completion->ictx->cct;
ldout(cct, 10) << "C_ImageCacheRead::finish() " << this << ": r=" << r
<< dendl;
if (r >= 0) {
size_t length = 0;
for (auto &image_extent : m_image_extents) {
length += image_extent.second;
}
assert(length == m_bl.length());

m_completion->lock.Lock();
m_completion->destriper.add_partial_result(cct, m_bl, m_image_extents);
m_completion->lock.Unlock();
r = length;
}
C_AioRequest::finish(r);
}

void C_CacheRead::complete(int r) {
if (!m_enqueued) {
// cache_lock creates a lock ordering issue -- so re-execute this context
Expand Down
20 changes: 20 additions & 0 deletions src/librbd/AioCompletion.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,26 @@ class C_AioRead : public C_AioRequest {
AioObjectRead *m_req;
};

class C_ImageCacheRead : public C_AioRequest {
public:
typedef std::vector<std::pair<uint64_t,uint64_t> > Extents;

C_ImageCacheRead(AioCompletion *completion, const Extents &image_extents)
: C_AioRequest(completion), m_image_extents(image_extents) {
}

inline bufferlist &get_data() {
return m_bl;
}

protected:
virtual void finish(int r);

private:
bufferlist m_bl;
Extents m_image_extents;
};

class C_CacheRead : public Context {
public:
explicit C_CacheRead(ImageCtx *ictx, AioObjectRead *req)
Expand Down

0 comments on commit c8ff315

Please sign in to comment.