plb.add_u64_counter(l_librbd_discard_bytes, "discard_bytes", "Discarded data");
plb.add_time_avg(l_librbd_discard_latency, "discard_latency", "Discard latency");
plb.add_u64_counter(l_librbd_flush, "flush", "Flushes");
- plb.add_u64_counter(l_librbd_aio_flush, "aio_flush", "Async flushes");
- plb.add_time_avg(l_librbd_aio_flush_latency, "aio_flush_latency", "Latency of async flushes");
+ plb.add_time_avg(l_librbd_flush_latency, "flush_latency", "Latency of flushes");
plb.add_u64_counter(l_librbd_ws, "ws", "WriteSames");
plb.add_u64_counter(l_librbd_ws_bytes, "ws_bytes", "WriteSame data");
plb.add_time_avg(l_librbd_ws_latency, "ws_latency", "WriteSame latency");
#include "librbd/ImageCtx.h"
#include "librbd/LibrbdAdminSocketHook.h"
#include "librbd/internal.h"
+#include "librbd/io/ImageRequestWQ.h"
#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
explicit FlushCacheCommand(ImageCtx *ictx) : ictx(ictx) {}
bool call(stringstream *ss) override {
- int r = flush(ictx);
+ int r = ictx->io_work_queue->flush();
if (r < 0) {
*ss << "flush: " << cpp_strerror(r);
return false;
return 0;
}
- int flush(ImageCtx *ictx)
- {
- CephContext *cct = ictx->cct;
- ldout(cct, 20) << "flush " << ictx << dendl;
-
- int r = ictx->state->refresh_if_required();
- if (r < 0) {
- return r;
- }
-
- ictx->user_flushed();
- C_SaferCond ctx;
- {
- RWLock::RLocker owner_locker(ictx->owner_lock);
- ictx->flush(&ctx);
- }
- r = ctx.wait();
-
- ictx->perfcounter->inc(l_librbd_flush);
- return r;
- }
-
int invalidate_cache(ImageCtx *ictx)
{
CephContext *cct = ictx->cct;
l_librbd_discard_bytes,
l_librbd_discard_latency,
l_librbd_flush,
-
- l_librbd_aio_flush,
- l_librbd_aio_flush_latency,
+ l_librbd_flush_latency,
l_librbd_ws,
l_librbd_ws_bytes,
l_librbd_ws_latency,
void readahead(ImageCtx *ictx,
const vector<pair<uint64_t,uint64_t> >& image_extents);
- int flush(ImageCtx *ictx);
int invalidate_cache(ImageCtx *ictx);
int poll_io_events(ImageCtx *ictx, io::AioCompletion **comps, int numcomp);
int metadata_list(ImageCtx *ictx, const string &last, uint64_t max, map<string, bufferlist> *pairs);
case AIO_TYPE_DISCARD:
ictx->perfcounter->tinc(l_librbd_discard_latency, elapsed); break;
case AIO_TYPE_FLUSH:
- ictx->perfcounter->tinc(l_librbd_aio_flush_latency, elapsed); break;
+ ictx->perfcounter->tinc(l_librbd_flush_latency, elapsed); break;
case AIO_TYPE_WRITESAME:
ictx->perfcounter->tinc(l_librbd_ws_latency, elapsed); break;
case AIO_TYPE_COMPARE_AND_WRITE:
aio_comp->put();
}
- image_ctx.perfcounter->inc(l_librbd_aio_flush);
+ image_ctx.perfcounter->inc(l_librbd_flush);
}
template <typename I>
return len;
}
+template <typename I>
+int ImageRequestWQ<I>::flush() {
+ CephContext *cct = m_image_ctx.cct;
+ ldout(cct, 20) << "ictx=" << &m_image_ctx << dendl;
+
+ C_SaferCond cond;
+ AioCompletion *c = AioCompletion::create(&cond);
+ aio_flush(c, false);
+
+ int r = cond.wait();
+ if (r < 0) {
+ return r;
+ }
+
+ return 0;
+}
+
template <typename I>
void ImageRequestWQ<I>::aio_read(AioCompletion *c, uint64_t off, uint64_t len,
ReadResult &&read_result, int op_flags,
ssize_t compare_and_write(uint64_t off, uint64_t len,
bufferlist &&cmp_bl, bufferlist &&bl,
uint64_t *mismatch_off, int op_flags);
+ int flush();
void aio_read(AioCompletion *c, uint64_t off, uint64_t len,
ReadResult &&read_result, int op_flags, bool native_async=true);
{
ImageCtx *ictx = (ImageCtx *)ctx;
tracepoint(librbd, flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
- int r = librbd::flush(ictx);
+ int r = ictx->io_work_queue->flush();
tracepoint(librbd, flush_exit, r);
return r;
}
{
librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
tracepoint(librbd, flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only);
- int r = librbd::flush(ictx);
+ int r = ictx->io_work_queue->flush();
tracepoint(librbd, flush_exit, r);
return r;
}
bl.append(std::string(1 << ictx->order, '1'));
ASSERT_EQ((ssize_t)bl.length(),
ictx->io_work_queue->write(0, bl.length(), bufferlist{bl}, 0));
- ASSERT_EQ(0, librbd::flush(ictx));
+ ASSERT_EQ(0, ictx->io_work_queue->flush());
ASSERT_EQ(0, create_snapshot("snap1", true));