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;
#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)
{
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;
}
}
dout(10) << "read_log done" << dendl;
+ return false;
}
void PG::read_log_old(ObjectStore *store, coll_t coll, hobject_t log_oid,
void append_log(
vector<pg_log_entry_t>& 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,