osd: flag new/old temp objects in MOSDSubOp

Allow us to mark when we start and stop using a temporary object in a
sub_op.  If we start to use it, make sure the collection exists on the
replica.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-09-04 17:07:19 -07:00
parent c4260fad29
commit 155cdd29a3
3 changed files with 27 additions and 1 deletions

View File

@ -25,7 +25,7 @@
class MOSDSubOp : public Message {
static const int HEAD_VERSION = 7;
static const int HEAD_VERSION = 8;
static const int COMPAT_VERSION = 1;
public:
@ -86,6 +86,9 @@ public:
// indicates that we must fix hobject_t encoding
bool hobject_incorrect_pool;
hobject_t new_temp_oid; ///< new temp object that we must now start tracking
hobject_t discard_temp_oid; ///< previously used temp object that we can now stop tracking
int get_cost() const {
if (ops.size() == 1 && ops[0].op.op == CEPH_OSD_OP_PULL)
return ops[0].op.extent.length;
@ -150,6 +153,11 @@ public:
poid.pool = pgid.pool();
hobject_incorrect_pool = true;
}
if (header.version >= 8) {
::decode(new_temp_oid, p);
::decode(discard_temp_oid, p);
}
}
virtual void encode_payload(uint64_t features) {
@ -194,6 +202,8 @@ public:
::encode(current_progress, payload);
::encode(omap_entries, payload);
::encode(omap_header, payload);
::encode(new_temp_oid, payload);
::encode(discard_temp_oid, payload);
}
MOSDSubOp()

View File

@ -4578,6 +4578,10 @@ void ReplicatedPG::issue_repop(RepGather *repop, utime_t now)
wr->pg_stats = info.stats;
wr->pg_trim_to = pg_trim_to;
wr->new_temp_oid = repop->ctx->new_temp_oid;
wr->discard_temp_oid = repop->ctx->discard_temp_oid;
osd->send_message_osd_cluster(peer, wr, get_osdmap()->get_epoch());
// keep peer_info up to date
@ -5175,6 +5179,16 @@ void ReplicatedPG::sub_op_modify(OpRequestRef op)
bufferlist::iterator p = m->get_data().begin();
if (m->new_temp_oid != hobject_t()) {
dout(20) << __func__ << " start tracking temp " << m->new_temp_oid << dendl;
temp_contents.insert(m->new_temp_oid);
get_temp_coll(&rm->localt);
}
if (m->discard_temp_oid != hobject_t()) {
dout(20) << __func__ << " stop tracking temp " << m->discard_temp_oid << dendl;
temp_contents.erase(m->discard_temp_oid);
}
::decode(rm->opt, p);
if (!(m->get_connection()->get_features() & CEPH_FEATURE_OSD_SNAPMAPPER))
rm->opt.set_tolerate_collection_add_enoent();

View File

@ -180,6 +180,8 @@ public:
CopyOpRef copy_op;
hobject_t new_temp_oid, discard_temp_oid; ///< temp objects we should start/stop tracking
OpContext(const OpContext& other);
const OpContext& operator=(const OpContext& other);