From 18f545b546b1d73165f79b77c2198beb630a5a30 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Thu, 18 Dec 2014 16:51:51 +0800 Subject: [PATCH] librados: Avoid copy data from librados to caller buff when using rados_read_op_read. Signed-off-by: Jianpeng Ma --- src/osdc/Objecter.cc | 16 ++++++++-------- src/osdc/Objecter.h | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 152560c5aa84..516d315e590e 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -2953,6 +2953,14 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m) if (op->reply_epoch) *op->reply_epoch = m->get_map_epoch(); + // got data? + if (op->outbl) { + if (op->con) + op->con->revoke_rx_buffer(op->tid); + m->claim_data(*op->outbl); + op->outbl = 0; + } + // per-op result demuxing vector out_ops; m->claim_ops(out_ops); @@ -3003,14 +3011,6 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m) logger->inc(l_osdc_op_commit); } - // got data? - if (op->outbl) { - if (op->con) - op->con->revoke_rx_buffer(op->tid); - m->claim_data(*op->outbl); - op->outbl = 0; - } - /* get it before we call _finish_op() */ Mutex *completion_lock = (op->target.base_oid.name.size() ? s->get_lock(op->target.base_oid) : NULL); diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index d17b1ed92b94..735b14b07d8c 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1980,6 +1980,8 @@ public: o->priority = op.priority; o->snapid = snapid; o->outbl = pbl; + if (!o->outbl && op.size() == 1 && op.out_bl[0]->length()) + o->outbl = op.out_bl[0]; o->out_bl.swap(op.out_bl); o->out_handler.swap(op.out_handler); o->out_rval.swap(op.out_rval); -- 2.47.3