if (result == -EAGAIN)
return;
+ // prepare the reply
+ ctx->reply = new MOSDOpReply(op, 0, osd->osdmap->get_epoch(), 0);
+ ctx->reply->set_data(ctx->outdata);
+ ctx->reply->get_header().data_off = ctx->data_off;
+ ctx->reply->set_result(result);
+
// read or error?
if (ctx->op_t.empty() || result < 0) {
- MOSDOpReply *reply = new MOSDOpReply(op, 0, osd->osdmap->get_epoch(),
- CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK);
- reply->set_data(ctx->outdata);
- reply->get_header().data_off = ctx->data_off;
- reply->set_result(result);
- //if the message came from an OSD, it needs to go back to originator,
- //but if the connection ISN't an OSD that connection is the originator
- if (op->get_connection()->get_peer_type() != CEPH_ENTITY_TYPE_OSD)
- osd->messenger->send_message(reply, op->get_connection());
- else
- osd->messenger->send_message(reply, op->get_orig_source_inst());
+ MOSDOpReply *reply = ctx->reply;
+ ctx->reply = NULL;
+ reply->add_flags(CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK);
+ osd->messenger->send_message(reply, op->get_connection());
op->put();
delete ctx;
put_object_context(obc);
// disk?
if (repop->can_send_disk() && op->wants_ondisk()) {
// send commit.
- MOSDOpReply *reply = new MOSDOpReply(op, 0, osd->osdmap->get_epoch(), CEPH_OSD_FLAG_ONDISK);
- dout(10) << " sending commit on " << *repop << " " << reply << dendl;
- //if the message came from an OSD, it needs to go back to originator,
- //but if the connection ISN't an OSD that connection is the originator
- if (op->get_connection()->get_peer_type() != CEPH_ENTITY_TYPE_OSD)
- osd->messenger->send_message(reply, op->get_connection());
+ MOSDOpReply *reply = repop->ctx->reply;
+ if (reply)
+ repop->ctx->reply = NULL;
else
- osd->messenger->send_message(reply, op->get_orig_source_inst());
+ reply = new MOSDOpReply(op, 0, osd->osdmap->get_epoch(), 0);
+ reply->add_flags(CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK);
+ dout(10) << " sending commit on " << *repop << " " << reply << dendl;
+ osd->messenger->send_message(reply, op->get_connection());
repop->sent_disk = true;
}
else if (repop->can_send_ack()) {
if (op->wants_ack()) {
// send ack
- MOSDOpReply *reply = new MOSDOpReply(op, 0, osd->osdmap->get_epoch(), CEPH_OSD_FLAG_ACK);
- dout(10) << " sending ack on " << *repop << " " << reply << dendl;
- //if the message came from an OSD, it needs to go back to originator,
- //but if the connection ISN't an OSD that connection is the originator
- if (op->get_connection()->get_peer_type() != CEPH_ENTITY_TYPE_OSD)
- osd->messenger->send_message(reply, op->get_connection());
+ MOSDOpReply *reply = repop->ctx->reply;
+ if (reply)
+ repop->ctx->reply = NULL;
else
- osd->messenger->send_message(reply, op->get_orig_source_inst());
+ reply = new MOSDOpReply(op, 0, osd->osdmap->get_epoch(), 0);
+ reply->add_flags(CEPH_OSD_FLAG_ACK);
+ dout(10) << " sending ack on " << *repop << " " << reply << dendl;
+ osd->messenger->send_message(reply, op->get_connection());
repop->sent_ack = true;
}
#include "PG.h"
#include "messages/MOSDOp.h"
+#include "messages/MOSDOpReply.h"
class MOSDSubOp;
class MOSDSubOpReply;
int data_off; // FIXME: we may want to kill this msgr hint off at some point!
+ MOSDOpReply *reply;
+
ReplicatedPG *pg;
OpContext(Message *_op, osd_reqid_t _reqid, vector<OSDOp>& _ops, bufferlist& _data,
ObjectState *_obs, ReplicatedPG *_pg) :
op(_op), reqid(_reqid), ops(_ops), indata(_data), obs(_obs),
- clone_obc(0), snapset_obc(0), data_off(0), pg(_pg) {}
+ clone_obc(0), snapset_obc(0), data_off(0), reply(NULL), pg(_pg) {}
~OpContext() {
assert(!clone_obc);
+ if (reply)
+ reply->put();
}
};