From c57ceff2e831e23e601f848bd293e0e855286190 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Fri, 20 Nov 2015 12:27:27 +0800 Subject: [PATCH] librbd: Fix rebase with new io flow Signed-off-by: Haomai Wang --- src/librbd/AioCompletion.h | 3 ++- src/librbd/AioImageRequestWQ.cc | 22 +++++++++++----------- src/librbd/AioImageRequestWQ.h | 8 ++++---- src/librbd/librbd.cc | 4 ++-- src/tracing/librbd.tp | 1 - 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/librbd/AioCompletion.h b/src/librbd/AioCompletion.h index 975c916fe6e0..9b83ab252503 100644 --- a/src/librbd/AioCompletion.h +++ b/src/librbd/AioCompletion.h @@ -10,6 +10,7 @@ #include "include/rbd/librbd.hpp" #include "librbd/AsyncOperation.h" +#include "librbd/ImageCtx.h" #include "osdc/Striper.h" @@ -73,7 +74,7 @@ namespace librbd { ref(1), released(false), ictx(NULL), aio_type(AIO_TYPE_NONE), read_bl(NULL), read_buf(NULL), read_buf_len(0), - journal_tid(0) { + journal_tid(0), m_xlist_item(this), event_notify(false) { } ~AioCompletion() { diff --git a/src/librbd/AioImageRequestWQ.cc b/src/librbd/AioImageRequestWQ.cc index b0e7d3ad0399..7d57849a41f1 100644 --- a/src/librbd/AioImageRequestWQ.cc +++ b/src/librbd/AioImageRequestWQ.cc @@ -35,7 +35,7 @@ ssize_t AioImageRequestWQ::read(uint64_t off, uint64_t len, char *buf, C_SaferCond cond; AioCompletion *c = aio_create_completion_internal(&cond, rbd_ctx_cb); - aio_read(c, off, len, buf, NULL, op_flags); + aio_read(c, off, len, buf, NULL, op_flags, false); return cond.wait(); } @@ -54,7 +54,7 @@ ssize_t AioImageRequestWQ::write(uint64_t off, uint64_t len, const char *buf, C_SaferCond cond; AioCompletion *c = aio_create_completion_internal(&cond, rbd_ctx_cb); - aio_write(c, off, len, buf, op_flags); + aio_write(c, off, len, buf, op_flags, false); r = cond.wait(); if (r < 0) { @@ -77,7 +77,7 @@ int AioImageRequestWQ::discard(uint64_t off, uint64_t len) { C_SaferCond cond; AioCompletion *c = aio_create_completion_internal(&cond, rbd_ctx_cb); - aio_discard(c, off, len); + aio_discard(c, off, len, false); r = cond.wait(); if (r < 0) { @@ -87,14 +87,14 @@ int AioImageRequestWQ::discard(uint64_t off, uint64_t len) { } void AioImageRequestWQ::aio_read(AioCompletion *c, uint64_t off, uint64_t len, - char *buf, bufferlist *pbl, int op_flags) { + char *buf, bufferlist *pbl, int op_flags, bool native_async) { c->init_time(&m_image_ctx, librbd::AIO_TYPE_READ); CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "aio_read: ictx=" << &m_image_ctx << ", " << "completion=" << c << ", off=" << off << ", " << "len=" << len << ", " << "flags=" << op_flags << dendl; - if (ictx->event_socket.is_valid()) + if (native_async && m_image_ctx.event_socket.is_valid()) c->set_event_notify(true); RWLock::RLocker owner_locker(m_image_ctx.owner_lock); @@ -106,14 +106,14 @@ void AioImageRequestWQ::aio_read(AioCompletion *c, uint64_t off, uint64_t len, } void AioImageRequestWQ::aio_write(AioCompletion *c, uint64_t off, uint64_t len, - const char *buf, int op_flags) { + const char *buf, int op_flags, bool native_async) { c->init_time(&m_image_ctx, librbd::AIO_TYPE_WRITE); CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "aio_write: ictx=" << &m_image_ctx << ", " << "completion=" << c << ", off=" << off << ", " << "len=" << len << ", flags=" << op_flags << dendl; - if (ictx->event_socket.is_valid()) + if (native_async && m_image_ctx.event_socket.is_valid()) c->set_event_notify(true); RWLock::RLocker owner_locker(m_image_ctx.owner_lock); @@ -126,14 +126,14 @@ void AioImageRequestWQ::aio_write(AioCompletion *c, uint64_t off, uint64_t len, } void AioImageRequestWQ::aio_discard(AioCompletion *c, uint64_t off, - uint64_t len) { + uint64_t len, bool native_async) { c->init_time(&m_image_ctx, librbd::AIO_TYPE_DISCARD); CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "aio_discard: ictx=" << &m_image_ctx << ", " << "completion=" << c << ", off=" << off << ", len=" << len << dendl; - if (ictx->event_socket.is_valid()) + if (native_async && m_image_ctx.event_socket.is_valid()) c->set_event_notify(true); RWLock::RLocker owner_locker(m_image_ctx.owner_lock); @@ -145,13 +145,13 @@ void AioImageRequestWQ::aio_discard(AioCompletion *c, uint64_t off, } } -void AioImageRequestWQ::aio_flush(AioCompletion *c) { +void AioImageRequestWQ::aio_flush(AioCompletion *c, bool native_async) { c->init_time(&m_image_ctx, librbd::AIO_TYPE_FLUSH); CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "aio_flush: ictx=" << &m_image_ctx << ", " << "completion=" << c << dendl; - if (ictx->event_socket.is_valid()) + if (native_async && m_image_ctx.event_socket.is_valid()) c->set_event_notify(true); RWLock::RLocker owner_locker(m_image_ctx.owner_lock); diff --git a/src/librbd/AioImageRequestWQ.h b/src/librbd/AioImageRequestWQ.h index 9cdb05c6cac6..732a2a8c320d 100644 --- a/src/librbd/AioImageRequestWQ.h +++ b/src/librbd/AioImageRequestWQ.h @@ -25,11 +25,11 @@ public: int discard(uint64_t off, uint64_t len); void aio_read(AioCompletion *c, uint64_t off, uint64_t len, char *buf, - bufferlist *pbl, int op_flags); + bufferlist *pbl, int op_flags, bool native_async=true); void aio_write(AioCompletion *c, uint64_t off, uint64_t len, const char *buf, - int op_flags); - void aio_discard(AioCompletion *c, uint64_t off, uint64_t len); - void aio_flush(AioCompletion *c); + int op_flags, bool native_async=true); + void aio_discard(AioCompletion *c, uint64_t off, uint64_t len, bool native_async=true); + void aio_flush(AioCompletion *c, bool native_async=true); using ThreadPool::PointerWQ::drain; using ThreadPool::PointerWQ::empty; diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc index 53ed8b80bb66..35a33c66ecdd 100644 --- a/src/librbd/librbd.cc +++ b/src/librbd/librbd.cc @@ -1000,7 +1000,7 @@ namespace librbd { { AioCompletion *cs[numcomp]; ImageCtx *ictx = (ImageCtx *)ctx; - tracepoint(librbd, poll_io_events_enter, numcomp); + tracepoint(librbd, poll_io_events_enter, ictx, numcomp); int r = librbd::poll_io_events(ictx, cs, numcomp); tracepoint(librbd, poll_io_events_exit, r); if (r > 0) { @@ -2153,7 +2153,7 @@ extern "C" int rbd_poll_io_events(rbd_image_t image, rbd_completion_t *comps, in { librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; librbd::AioCompletion *cs[numcomp]; - tracepoint(librbd, poll_io_events_enter, numcomp); + tracepoint(librbd, poll_io_events_enter, ictx, numcomp); int r = librbd::poll_io_events(ictx, cs, numcomp); tracepoint(librbd, poll_io_events_exit, r); if (r > 0) { diff --git a/src/tracing/librbd.tp b/src/tracing/librbd.tp index dbe3d8ff554b..146e06ebc8d4 100644 --- a/src/tracing/librbd.tp +++ b/src/tracing/librbd.tp @@ -511,7 +511,6 @@ TRACEPOINT_EVENT(librbd, poll_io_events_enter, TP_FIELDS( ctf_integer_hex(void*, imagectx, imagectx) ctf_integer(int, numcomp, numcomp) - ctf_integer(int, max, max) ) ) -- 2.47.3