From: Samuel Just Date: Fri, 15 Feb 2013 01:29:46 +0000 (-0800) Subject: PG: write_log if we read an old-format log X-Git-Tag: v0.58~53^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5f92b6cb9587bc9de925d599e40fd4789782cb0f;p=ceph.git PG: write_log if we read an old-format log Signed-off-by: Samuel Just --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index ee1df9fc253f..2bebff3d72e0 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2656,7 +2656,17 @@ void PG::read_state(ObjectStore *store, bufferlist &bl) assert(r >= 0); ostringstream oss; - read_log(store, coll, log_oid, info, ondisklog, log, missing, oss, this); + if (read_log( + store, coll, log_oid, info, + ondisklog, log, missing, oss, this)) { + /* We don't want to leave the old format around in case the next log + * write happens to be an append_log() + */ + ObjectStore::Transaction t; + write_log(t); + int r = osd->store->apply_transaction(t); + assert(!r); + } if (oss.str().length()) osd->clog.error() << oss; @@ -5043,7 +5053,7 @@ std::ostream& operator<<(std::ostream& oss, #undef dout_prefix #define dout_prefix if (passedpg) _prefix(_dout, passedpg) -void PG::read_log(ObjectStore *store, coll_t coll, hobject_t log_oid, +bool PG::read_log(ObjectStore *store, coll_t coll, hobject_t log_oid, const pg_info_t &info, OndiskLog &ondisklog, IndexedLog &log, pg_missing_t &missing, ostringstream &oss, const PG *passedpg) { @@ -5055,7 +5065,7 @@ void PG::read_log(ObjectStore *store, coll_t coll, hobject_t log_oid, assert(r == 0); if (st.st_size > 0) { read_log_old(store, coll, log_oid, info, ondisklog, log, missing, oss, passedpg); - return; + return true; } log.tail = info.log_tail; @@ -5135,6 +5145,7 @@ void PG::read_log(ObjectStore *store, coll_t coll, hobject_t log_oid, } } dout(10) << "read_log done" << dendl; + return false; } void PG::read_log_old(ObjectStore *store, coll_t coll, hobject_t log_oid, diff --git a/src/osd/PG.h b/src/osd/PG.h index 26c536889715..ec3d4664a907 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1798,7 +1798,8 @@ public: void append_log( vector& logv, eversion_t trim_to, ObjectStore::Transaction &t); - static void read_log(ObjectStore *store, coll_t coll, hobject_t log_oid, + /// return true if the log should be rewritten + static bool read_log(ObjectStore *store, coll_t coll, hobject_t log_oid, const pg_info_t &info, OndiskLog &ondisklog, IndexedLog &log, pg_missing_t &missing, ostringstream &oss, const PG *passedpg = NULL); static void read_log_old(ObjectStore *store, coll_t coll, hobject_t log_oid,