]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: preserve allocation hint attribute during recovery
authoryaoning <yaoning@unitedstack.com>
Mon, 6 Jun 2016 05:31:52 +0000 (13:31 +0800)
committeryaoning <yaoning@unitedstack.com>
Sat, 25 Feb 2017 05:17:27 +0000 (13:17 +0800)
Signed-off-by: yaoning <yaoning@unitedstack.com>
(cherry picked from commit e15be792960da6bac2bd469acf7d30007be61781)

Conflicts:
    src/osd/ReplicatedBackend.cc (in master, it contains alloc_hint_flags for set_alloc_hint)
    src/osd/ReplicatedPG.cc (in master, it contains alloc_hint_flags in object_info_t struct)
    src/osd/osd_types.cc (in master, it contains alloc_hint_flags in message serialization)
    alloc_hint_flags is used in master bluestore, filestore does not use alloc_hint_flags.
    therefore, remove alloc_hint_flags here in jewel

Signed-off-by: yaoning <yaoning@unitedstack.com>
src/osd/ReplicatedBackend.cc
src/osd/ReplicatedPG.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index 32b9f17654f1818133acf2d082ffcbe930784f3e..415f25f9aca6065205e9dff1b3f614cd0f95a7d8 100644 (file)
@@ -1676,6 +1676,12 @@ void ReplicatedBackend::submit_push_data(
     t->touch(coll, ghobject_t(target_oid));
     t->truncate(coll, ghobject_t(target_oid), recovery_info.size);
     t->omap_setheader(coll, ghobject_t(target_oid), omap_header);
+
+    bufferlist bv = attrs[OI_ATTR];
+    object_info_t oi(bv);
+    t->set_alloc_hint(coll, ghobject_t(target_oid),
+                     oi.expected_object_size,
+                     oi.expected_write_size);
   }
   uint64_t off = 0;
   uint32_t fadvise_flags = CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL;
index dcc9860bc8c7a5da196ed8265a023b3021255033..15f1efc2707c78029e500342e2f3ab0a28913876 100644 (file)
@@ -4936,6 +4936,8 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
           ctx->mod_desc.create();
           t->touch(soid);
        }
+       oi.expected_object_size = op.alloc_hint.expected_object_size;
+       oi.expected_write_size = op.alloc_hint.expected_write_size;
         t->set_alloc_hint(soid, op.alloc_hint.expected_object_size,
                           op.alloc_hint.expected_write_size);
         ctx->delta_stats.num_wr++;
index 171b3f1734000f5b0424c70f09c03b084ce2dd0b..6035e4217b99067703ee6f1e3109bca07c703031 100644 (file)
@@ -4724,7 +4724,7 @@ void object_info_t::encode(bufferlist& bl) const
        ++i) {
     old_watchers.insert(make_pair(i->first.second, i->second));
   }
-  ENCODE_START(15, 8, bl);
+  ENCODE_START(16, 8, bl);
   ::encode(soid, bl);
   ::encode(myoloc, bl);        //Retained for compatibility
   ::encode((__u32)0, bl); // was category, no longer used
@@ -4752,13 +4752,15 @@ void object_info_t::encode(bufferlist& bl) const
   ::encode(local_mtime, bl);
   ::encode(data_digest, bl);
   ::encode(omap_digest, bl);
+  ::encode(expected_object_size, bl);
+  ::encode(expected_write_size, bl);
   ENCODE_FINISH(bl);
 }
 
 void object_info_t::decode(bufferlist::iterator& bl)
 {
   object_locator_t myoloc;
-  DECODE_START_LEGACY_COMPAT_LEN(15, 8, 8, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(16, 8, 8, bl);
   map<entity_name_t, watch_info_t> old_watchers;
   ::decode(soid, bl);
   ::decode(myoloc, bl);
@@ -4831,6 +4833,13 @@ void object_info_t::decode(bufferlist::iterator& bl)
     clear_flag(FLAG_DATA_DIGEST);
     clear_flag(FLAG_OMAP_DIGEST);
   }
+  if (struct_v >= 16) {
+    ::decode(expected_object_size, bl);
+    ::decode(expected_write_size, bl);
+  } else {
+    expected_object_size = 0;
+    expected_write_size = 0;
+  }
   DECODE_FINISH(bl);
 }
 
@@ -4856,6 +4865,8 @@ void object_info_t::dump(Formatter *f) const
   f->dump_unsigned("truncate_size", truncate_size);
   f->dump_unsigned("data_digest", data_digest);
   f->dump_unsigned("omap_digest", omap_digest);
+  f->dump_unsigned("expected_object_size", expected_object_size);
+  f->dump_unsigned("expected_write_size", expected_write_size);
   f->open_object_section("watchers");
   for (map<pair<uint64_t, entity_name_t>,watch_info_t>::const_iterator p =
          watchers.begin(); p != watchers.end(); ++p) {
@@ -4890,6 +4901,8 @@ ostream& operator<<(ostream& out, const object_info_t& oi)
     out << " dd " << std::hex << oi.data_digest << std::dec;
   if (oi.is_omap_digest())
     out << " od " << std::hex << oi.omap_digest << std::dec;
+  out << " alloc_hint [" << oi.expected_object_size
+      << " " << oi.expected_write_size << "]";
 
   out << ")";
   return out;
index 1c5d71db308bea26439589c9aaaae99cf2644b7a..2a7c0044a2dcd67fcb69283e3e8eaf5786ca97a1 100644 (file)
@@ -3318,6 +3318,10 @@ struct object_info_t {
   // opportunistic checksums; may or may not be present
   __u32 data_digest;  ///< data crc32c
   __u32 omap_digest;  ///< omap crc32c
+  
+  // alloc hint attribute
+  uint64_t expected_object_size, expected_write_size;
+  uint32_t alloc_hint_flags;
 
   void copy_user_bits(const object_info_t& other);
 
@@ -3388,14 +3392,18 @@ struct object_info_t {
   explicit object_info_t()
     : user_version(0), size(0), flags((flag_t)0),
       truncate_seq(0), truncate_size(0),
-      data_digest(-1), omap_digest(-1)
+      data_digest(-1), omap_digest(-1),
+      expected_object_size(0), expected_write_size(0),
+      alloc_hint_flags(0)
   {}
 
   explicit object_info_t(const hobject_t& s)
     : soid(s),
       user_version(0), size(0), flags((flag_t)0),
       truncate_seq(0), truncate_size(0),
-      data_digest(-1), omap_digest(-1)
+      data_digest(-1), omap_digest(-1),
+      expected_object_size(0), expected_write_size(0),
+      alloc_hint_flags(0)
   {}
 
   explicit object_info_t(bufferlist& bl) {