]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: include omap header in copy-get
authorSage Weil <sage@inktank.com>
Mon, 23 Dec 2013 18:21:44 +0000 (10:21 -0800)
committerSage Weil <sage@inktank.com>
Mon, 23 Dec 2013 18:21:44 +0000 (10:21 -0800)
Missed this the first time around.  Thank you, ceph_test_rados!

Fixes: #7056
Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h
src/osd/osd_types.cc
src/osd/osd_types.h
src/osdc/Objecter.h

index 8334476ca894c2a5fe5a9e261134957d6e90b271..0eb16ba2131541ef9ec728a7b813c3bf20e8d570 100644 (file)
@@ -4676,6 +4676,9 @@ int ReplicatedPG::fill_in_copy_get(bufferlist::iterator& bp, OSDOp& osd_op,
   std::map<std::string,bufferlist>& out_omap = reply_obj.omap;
   if (left > 0 && !cursor.omap_complete) {
     assert(cursor.data_complete);
+    if (cursor.omap_offset.empty()) {
+      osd->store->omap_get_header(coll, oi.soid, &reply_obj.omap_header);
+    }
     ObjectMap::ObjectMapIterator iter =
       osd->store->get_omap_iterator(coll, oi.soid);
     assert(iter);
@@ -4701,6 +4704,10 @@ int ReplicatedPG::fill_in_copy_get(bufferlist::iterator& bp, OSDOp& osd_op,
                     << dendl;
   reply_obj.cursor = cursor;
   if (classic) {
+    if (reply_obj.omap_header.length() > 0) {
+      derr << oi.soid << " omap header being dropped by classic copy-get api"
+          << dendl;
+    }
     reply_obj.encode_classic(osd_op.outdata);
   } else {
     ::encode(reply_obj, osd_op.outdata);
@@ -4749,7 +4756,7 @@ void ReplicatedPG::_copy_some(ObjectContextRef obc, CopyOpRef cop)
   op.copy_get(&cop->cursor, cct->_conf->osd_copyfrom_max_chunk,
              &cop->results->object_size, &cop->results->mtime,
              &cop->results->category,
-             &cop->attrs, &cop->data, &cop->omap,
+             &cop->attrs, &cop->data, &cop->omap_header, &cop->omap,
              &cop->rval);
 
   C_Copyfrom *fin = new C_Copyfrom(this, obc->obs.oi.soid,
@@ -4842,6 +4849,10 @@ void ReplicatedPG::_write_copy_chunk(CopyOpRef cop, ObjectStore::Transaction *t)
     cop->data.clear();
   }
   if (!cop->temp_cursor.omap_complete) {
+    if (cop->omap_header.length()) {
+      t->omap_setheader(cop->temp_coll, cop->temp_oid, cop->omap_header);
+      cop->omap_header.clear();
+    }
     t->omap_setkeys(cop->temp_coll, cop->temp_oid, cop->omap);
     cop->omap.clear();
   }
index 46f09649c51c956e0936876ba7a52c02919b70ce..3ec3f048b832dec968292569ee9c2c013e915479 100644 (file)
@@ -133,6 +133,7 @@ public:
     object_copy_cursor_t cursor;
     map<string,bufferlist> attrs;
     bufferlist data;
+    bufferlist omap_header;
     map<string,bufferlist> omap;
     int rval;
 
index d1e23f5e7e42525cbc3b02042712d53ab992d2b2..85805afb3771c97e2aa6447909b9f4855aa3bff9 100644 (file)
@@ -2676,7 +2676,7 @@ void object_copy_data_t::decode_classic(bufferlist::iterator& bl)
 
 void object_copy_data_t::encode(bufferlist& bl) const
 {
-  ENCODE_START(1, 1, bl);
+  ENCODE_START(2, 1, bl);
   ::encode(size, bl);
   ::encode(mtime, bl);
   ::encode(category, bl);
@@ -2684,12 +2684,13 @@ void object_copy_data_t::encode(bufferlist& bl) const
   ::encode(data, bl);
   ::encode(omap, bl);
   ::encode(cursor, bl);
+  ::encode(omap_header, bl);
   ENCODE_FINISH(bl);
 }
 
 void object_copy_data_t::decode(bufferlist::iterator& bl)
 {
-  DECODE_START(1, bl);
+  DECODE_START(2, bl);
   ::decode(size, bl);
   ::decode(mtime, bl);
   ::decode(category, bl);
@@ -2697,6 +2698,8 @@ void object_copy_data_t::decode(bufferlist::iterator& bl)
   ::decode(data, bl);
   ::decode(omap, bl);
   ::decode(cursor, bl);
+  if (struct_v >= 2)
+    ::decode(omap_header, bl);
   DECODE_FINISH(bl);
 }
 
@@ -2725,6 +2728,7 @@ void object_copy_data_t::generate_test_instances(list<object_copy_data_t*>& o)
   o.back()->omap["why"] = bl2;
   bufferptr databp("iamsomedatatocontain", 20);
   o.back()->data.push_back(databp);
+  o.back()->omap_header.append("this is an omap header");
 }
 
 void object_copy_data_t::dump(Formatter *f) const
@@ -2738,6 +2742,7 @@ void object_copy_data_t::dump(Formatter *f) const
      const-correctness prents that */
   f->dump_int("attrs_size", attrs.size());
   f->dump_int("omap_size", omap.size());
+  f->dump_int("omap_header_length", omap_header.length());
   f->dump_int("data_length", data.length());
 }
 
index 576d37e855e27c514dfe1f877d007d9cf5b309d9..7ca9fecbf3d82b782cc69a41251cee68f8f59137 100644 (file)
@@ -1953,6 +1953,7 @@ struct object_copy_data_t {
   utime_t mtime;
   map<string, bufferlist> attrs;
   bufferlist data;
+  bufferlist omap_header;
   map<string, bufferlist> omap;
   string category;
 public:
index 228a744b0cb95a8ae8903b9ea7ade656135fdf3e..4a1a54da4863023a71728f98c11ab3ee9394d0fa 100644 (file)
@@ -571,7 +571,7 @@ struct ObjectOperation {
     utime_t *out_mtime;
     string *out_category;
     std::map<std::string,bufferlist> *out_attrs;
-    bufferlist *out_data;
+    bufferlist *out_data, *out_omap_header;
     std::map<std::string,bufferlist> *out_omap;
     int *prval;
     C_ObjectOperation_copyget(object_copy_cursor_t *c,
@@ -579,12 +579,13 @@ struct ObjectOperation {
                              utime_t *m,
                              string *cat,
                              std::map<std::string,bufferlist> *a,
-                             bufferlist *d,
+                             bufferlist *d, bufferlist *oh,
                              std::map<std::string,bufferlist> *o,
                              int *r)
       : cursor(c),
        out_size(s), out_mtime(m), out_category(cat),
-       out_attrs(a), out_data(d), out_omap(o), prval(r) {}
+       out_attrs(a), out_data(d), out_omap_header(oh),
+       out_omap(o), prval(r) {}
     void finish(int r) {
       if (r < 0)
        return;
@@ -602,6 +603,8 @@ struct ObjectOperation {
          *out_attrs = copy_reply.attrs;
        if (out_data)
          out_data->claim_append(copy_reply.data);
+       if (out_omap_header)
+         out_omap_header->claim_append(copy_reply.omap_header);
        if (out_omap)
          *out_omap = copy_reply.omap;
        *cursor = copy_reply.cursor;
@@ -619,6 +622,7 @@ struct ObjectOperation {
                string *out_category,
                std::map<std::string,bufferlist> *out_attrs,
                bufferlist *out_data,
+               bufferlist *out_omap_header,
                std::map<std::string,bufferlist> *out_omap,
                int *prval) {
     OSDOp& osd_op = add_op(CEPH_OSD_OP_COPY_GET);
@@ -629,7 +633,8 @@ struct ObjectOperation {
     out_rval[p] = prval;
     C_ObjectOperation_copyget *h =
       new C_ObjectOperation_copyget(cursor, out_size, out_mtime, out_category,
-                                    out_attrs, out_data, out_omap, prval);
+                                    out_attrs, out_data, out_omap_header,
+                                   out_omap, prval);
     out_bl[p] = &h->bl;
     out_handler[p] = h;
   }