From: Sage Weil Date: Tue, 24 Dec 2013 16:50:38 +0000 (-0800) Subject: osd/ReplicatedPG: include snaps in copy-get results X-Git-Tag: v0.77~22^2~45 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6dd0a1f0d6e164cbe626e07676cc0fbc8a5bde74;p=ceph.git osd/ReplicatedPG: include snaps in copy-get results When promoting a snapped object, we need to also get the set of snaps over which the clone is defined. This is not strictly available except via the list-snaps rados call, but that is only used on the snapdir object much earlier when the head (whiteout) is promoted, and is not conveniently available now. Adding it to the internal copy-get is not exposed via librados (copy-get is not exposed at all) so I don't think this is a problem. Signed-off-by: Sage Weil --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 7ba3efb6e3d8..6138945dca4d 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4709,6 +4709,7 @@ int ReplicatedPG::fill_in_copy_get(bufferlist::iterator& bp, OSDOp& osd_op, reply_obj.size = oi.size; reply_obj.mtime = oi.mtime; reply_obj.category = oi.category; + reply_obj.snaps = oi.snaps; // attrs map& out_attrs = reply_obj.attrs; @@ -4826,6 +4827,7 @@ void ReplicatedPG::_copy_some(ObjectContextRef obc, CopyOpRef cop) &cop->results->object_size, &cop->results->mtime, &cop->results->category, &cop->attrs, &cop->data, &cop->omap_header, &cop->omap, + &cop->results->snaps, &cop->rval); C_Copyfrom *fin = new C_Copyfrom(this, obc->obs.oi.soid, @@ -5047,6 +5049,7 @@ void ReplicatedPG::finish_promote(int r, OpRequestRef op, tctx->delta_stats.num_bytes += results->object_size; tctx->new_obs.oi.category = results->category; tctx->new_obs.oi.user_version = results->user_version; + tctx->new_obs.oi.snaps = results->snaps; } // take RWWRITE lock for duration of our local write diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index cfd4bc78d652..284635970dc2 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -115,6 +115,7 @@ public: string category; ///< The copy source's category version_t user_version; ///< The copy source's user version bool should_requeue; ///< op should be requeued on cancel + vector snaps; ///< src's snaps (if clone) CopyResults() : object_size(0), started_temp_obj(false), user_version(0), should_requeue(false) {} }; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 6f72b05e4d20..7d89a5ef8208 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2679,7 +2679,7 @@ void object_copy_data_t::decode_classic(bufferlist::iterator& bl) void object_copy_data_t::encode(bufferlist& bl) const { - ENCODE_START(2, 1, bl); + ENCODE_START(3, 1, bl); ::encode(size, bl); ::encode(mtime, bl); ::encode(category, bl); @@ -2688,6 +2688,7 @@ void object_copy_data_t::encode(bufferlist& bl) const ::encode(omap, bl); ::encode(cursor, bl); ::encode(omap_header, bl); + ::encode(snaps, bl); ENCODE_FINISH(bl); } @@ -2703,6 +2704,8 @@ void object_copy_data_t::decode(bufferlist::iterator& bl) ::decode(cursor, bl); if (struct_v >= 2) ::decode(omap_header, bl); + if (struct_v >= 3) + ::decode(snaps, bl); DECODE_FINISH(bl); } @@ -2732,6 +2735,7 @@ void object_copy_data_t::generate_test_instances(list& o) bufferptr databp("iamsomedatatocontain", 20); o.back()->data.push_back(databp); o.back()->omap_header.append("this is an omap header"); + o.back()->snaps.push_back(123); } void object_copy_data_t::dump(Formatter *f) const @@ -2747,6 +2751,11 @@ void object_copy_data_t::dump(Formatter *f) const f->dump_int("omap_size", omap.size()); f->dump_int("omap_header_length", omap_header.length()); f->dump_int("data_length", data.length()); + f->open_array_section("snaps"); + for (vector::const_iterator p = snaps.begin(); + p != snaps.end(); ++p) + f->dump_unsigned("snap", *p); + f->close_section(); } // -- pg_create_t -- diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index ddb55b71389f..11005b565752 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1948,6 +1948,9 @@ struct object_copy_data_t { bufferlist omap_header; map omap; string category; + + /// which snaps we are defined for (if a snap and not the head) + vector snaps; public: object_copy_data_t() : size((uint64_t)-1) {} diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 3777c6de5f0b..2f03a8f65e49 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -579,6 +579,7 @@ struct ObjectOperation { std::map *out_attrs; bufferlist *out_data, *out_omap_header; std::map *out_omap; + vector *out_snaps; int *prval; C_ObjectOperation_copyget(object_copy_cursor_t *c, uint64_t *s, @@ -587,11 +588,12 @@ struct ObjectOperation { std::map *a, bufferlist *d, bufferlist *oh, std::map *o, + std::vector *osnaps, int *r) : cursor(c), out_size(s), out_mtime(m), out_category(cat), out_attrs(a), out_data(d), out_omap_header(oh), - out_omap(o), prval(r) {} + out_omap(o), out_snaps(osnaps), prval(r) {} void finish(int r) { if (r < 0) return; @@ -613,6 +615,8 @@ struct ObjectOperation { out_omap_header->claim_append(copy_reply.omap_header); if (out_omap) *out_omap = copy_reply.omap; + if (out_snaps) + *out_snaps = copy_reply.snaps; *cursor = copy_reply.cursor; } catch (buffer::error& e) { if (prval) @@ -630,6 +634,7 @@ struct ObjectOperation { bufferlist *out_data, bufferlist *out_omap_header, std::map *out_omap, + vector *out_snaps, int *prval) { OSDOp& osd_op = add_op(CEPH_OSD_OP_COPY_GET); osd_op.op.copy_get.max = max; @@ -640,7 +645,7 @@ struct ObjectOperation { C_ObjectOperation_copyget *h = new C_ObjectOperation_copyget(cursor, out_size, out_mtime, out_category, out_attrs, out_data, out_omap_header, - out_omap, prval); + out_omap, out_snaps, prval); out_bl[p] = &h->bl; out_handler[p] = h; }