From d1973f3ba0f3ddf960863a02030371fc47006e8d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 23 Nov 2014 14:18:17 -0800 Subject: [PATCH] osd/PGLog: drop support for ancient logs Assume that users have at least upgraded to dumpling first. Signed-off-by: Sage Weil --- src/osd/PG.cc | 20 ++---- src/osd/PGLog.cc | 167 +++++------------------------------------------ src/osd/PGLog.h | 12 +--- 3 files changed, 25 insertions(+), 174 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 614c148d21130..a4cee105912d7 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3003,21 +3003,11 @@ void PG::read_state(ObjectStore *store, bufferlist &bl) assert(r >= 0); ostringstream oss; - if (pg_log.read_log(store, - coll, - info_struct_v < 8 ? META_COLL : coll, - info_struct_v < 8 ? OSD::make_pg_log_oid(pg_id) : pgmeta_oid, - info, oss)) { - /* We don't want to leave the old format around in case the next log - * write happens to be an append_log() - */ - pg_log.mark_log_for_rewrite(); - ObjectStore::Transaction t; - t.remove(META_COLL, log_oid); // remove old version - pg_log.write_log(t, coll, pgmeta_oid); - int r = osd->store->apply_transaction(t); - assert(!r); - } + pg_log.read_log(store, + coll, + info_struct_v < 8 ? META_COLL : coll, + info_struct_v < 8 ? OSD::make_pg_log_oid(pg_id) : pgmeta_oid, + info, oss); if (oss.str().length()) osd->clog->error() << oss; diff --git a/src/osd/PGLog.cc b/src/osd/PGLog.cc index bdb507c0dfb12..4052c00073f12 100644 --- a/src/osd/PGLog.cc +++ b/src/osd/PGLog.cc @@ -799,33 +799,31 @@ void PGLog::_write_log( t.omap_setkeys(coll, log_oid, keys); } -bool PGLog::read_log(ObjectStore *store, coll_t pg_coll, - coll_t log_coll, ghobject_t log_oid, - const pg_info_t &info, map &divergent_priors, - IndexedLog &log, - pg_missing_t &missing, - ostringstream &oss, - set *log_keys_debug) +void PGLog::read_log(ObjectStore *store, coll_t pg_coll, + coll_t log_coll, + ghobject_t log_oid, + const pg_info_t &info, + map &divergent_priors, + IndexedLog &log, + pg_missing_t &missing, + ostringstream &oss, + set *log_keys_debug) { - dout(10) << "read_log" << dendl; - bool rewrite_log = false; + dout(20) << "read_log coll " << pg_coll << " log_oid " << log_oid << dendl; // legacy? struct stat st; int r = store->stat(log_coll, log_oid, &st); assert(r == 0); - if (st.st_size > 0) { - read_log_old(store, pg_coll, log_oid, info, divergent_priors, log, missing, oss, log_keys_debug); - rewrite_log = true; - } else { - log.tail = info.log_tail; - - // will get overridden below if it had been recorded - log.can_rollback_to = info.last_update; - log.rollback_info_trimmed_to = eversion_t(); + assert(st.st_size == 0); - ObjectMap::ObjectMapIterator p = store->get_omap_iterator(log_coll, log_oid); - if (p) for (p->seek_to_first(); p->valid() ; p->next()) { + log.tail = info.log_tail; + // will get overridden below if it had been recorded + log.can_rollback_to = info.last_update; + log.rollback_info_trimmed_to = eversion_t(); + ObjectMap::ObjectMapIterator p = store->get_omap_iterator(log_coll, log_oid); + if (p) { + for (p->seek_to_first(); p->valid() ; p->next()) { // non-log pgmeta_oid keys are prefixed with _; skip those if (p->key()[0] == '_') continue; @@ -929,134 +927,5 @@ bool PGLog::read_log(ObjectStore *store, coll_t pg_coll, } } dout(10) << "read_log done" << dendl; - return rewrite_log; } -void PGLog::read_log_old(ObjectStore *store, coll_t coll, ghobject_t log_oid, - const pg_info_t &info, map &divergent_priors, - IndexedLog &log, - pg_missing_t &missing, ostringstream &oss, - set *log_keys_debug) -{ - // load bounds, based on old OndiskLog encoding. - uint64_t ondisklog_tail = 0; - uint64_t ondisklog_head = 0; - bool ondisklog_has_checksums; - - bufferlist blb; - store->collection_getattr(coll, "ondisklog", blb); - { - bufferlist::iterator bl = blb.begin(); - DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl); - ondisklog_has_checksums = (struct_v >= 2); - ::decode(ondisklog_tail, bl); - ::decode(ondisklog_head, bl); - if (struct_v >= 4) { - uint64_t ondisklog_zero_to; - ::decode(ondisklog_zero_to, bl); - } - if (struct_v >= 5) - ::decode(divergent_priors, bl); - DECODE_FINISH(bl); - } - uint64_t ondisklog_length = ondisklog_head - ondisklog_tail; - dout(10) << "read_log " << ondisklog_tail << "~" << ondisklog_length << dendl; - - log.tail = info.log_tail; - - if (ondisklog_head > 0) { - // read - bufferlist bl; - store->read(META_COLL, log_oid, ondisklog_tail, ondisklog_length, bl); - if (bl.length() < ondisklog_length) { - std::ostringstream oss; - oss << "read_log got " << bl.length() << " bytes, expected " - << ondisklog_head << "-" << ondisklog_tail << "=" - << ondisklog_length; - throw read_log_error(oss.str().c_str()); - } - - pg_log_entry_t e; - bufferlist::iterator p = bl.begin(); - assert(log.empty()); - eversion_t last; - bool reorder = false; - - while (!p.end()) { - uint64_t pos = ondisklog_tail + p.get_off(); - if (ondisklog_has_checksums) { - bufferlist ebl; - ::decode(ebl, p); - __u32 crc; - ::decode(crc, p); - - __u32 got = ebl.crc32c(0); - if (crc == got) { - bufferlist::iterator q = ebl.begin(); - ::decode(e, q); - } else { - std::ostringstream oss; - oss << "read_log " << pos << " bad crc got " << got << " expected" << crc; - throw read_log_error(oss.str().c_str()); - } - } else { - ::decode(e, p); - } - dout(20) << "read_log " << pos << " " << e << dendl; - - // [repair] in order? - if (e.version < last) { - dout(0) << "read_log " << pos << " out of order entry " << e << " follows " << last << dendl; - oss << info.pgid << " log has out of order entry " - << e << " following " << last << "\n"; - reorder = true; - } - - if (e.version <= log.tail) { - dout(20) << "read_log ignoring entry at " << pos << " below log.tail" << dendl; - continue; - } - if (last.version == e.version.version) { - dout(0) << "read_log got dup " << e.version << " (last was " << last << ", dropping that one)" << dendl; - log.log.pop_back(); - oss << info.pgid << " read_log got dup " - << e.version << " after " << last << "\n"; - } - - assert(!e.invalid_hash); - - if (e.invalid_pool) { - e.soid.pool = info.pgid.pool(); - } - - e.offset = pos; - uint64_t endpos = ondisklog_tail + p.get_off(); - log.log.push_back(e); - if (log_keys_debug) - log_keys_debug->insert(e.get_key_name()); - last = e.version; - - // [repair] at end of log? - if (!p.end() && e.version == info.last_update) { - oss << info.pgid << " log has extra data at " - << endpos << "~" << (ondisklog_head-endpos) << " after " - << info.last_update << "\n"; - - dout(0) << "read_log " << endpos << " *** extra gunk at end of log, " - << "adjusting ondisklog_head" << dendl; - ondisklog_head = endpos; - break; - } - } - - if (reorder) { - dout(0) << "read_log reordering log" << dendl; - map m; - for (list::iterator p = log.log.begin(); p != log.log.end(); ++p) - m[p->version] = *p; - log.log.clear(); - for (map::iterator p = m.begin(); p != m.end(); ++p) - log.log.push_back(p->second); - } - } -} diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index 5ac3a7fc38615..1961ec5fc8d25 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -561,7 +561,7 @@ public: set *log_keys_debug ); - bool read_log(ObjectStore *store, coll_t pg_coll, + void read_log(ObjectStore *store, coll_t pg_coll, coll_t log_coll, ghobject_t log_oid, const pg_info_t &info, ostringstream &oss) { return read_log( @@ -570,21 +570,13 @@ public: (pg_log_debug ? &log_keys_debug : 0)); } - /// return true if the log should be rewritten - static bool read_log(ObjectStore *store, coll_t pg_coll, + static void read_log(ObjectStore *store, coll_t pg_coll, coll_t log_coll, ghobject_t log_oid, const pg_info_t &info, map &divergent_priors, IndexedLog &log, pg_missing_t &missing, ostringstream &oss, set *log_keys_debug = 0 ); - -protected: - static void read_log_old(ObjectStore *store, coll_t coll, ghobject_t log_oid, - const pg_info_t &info, map &divergent_priors, - IndexedLog &log, - pg_missing_t &missing, ostringstream &oss, - set *log_keys_debug); }; #endif // CEPH_PG_LOG_H -- 2.39.5