From 3bdd4398f1dcad0b7e22f1750ca524b97feca15a Mon Sep 17 00:00:00 2001 From: yaoning Date: Mon, 6 Jun 2016 13:31:52 +0800 Subject: [PATCH] osd: preserve allocation hint attribute during recovery Signed-off-by: yaoning (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 --- src/osd/ReplicatedBackend.cc | 6 ++++++ src/osd/ReplicatedPG.cc | 2 ++ src/osd/osd_types.cc | 17 +++++++++++++++-- src/osd/osd_types.h | 12 ++++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 32b9f17654f1..415f25f9aca6 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -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; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index dcc9860bc8c7..15f1efc2707c 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4936,6 +4936,8 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& 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++; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 171b3f173400..6035e4217b99 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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 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,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; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 1c5d71db308b..2a7c0044a2dc 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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) { -- 2.47.3