]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
PG: write_log if we read an old-format log
authorSamuel Just <sam.just@inktank.com>
Fri, 15 Feb 2013 01:29:46 +0000 (17:29 -0800)
committerSamuel Just <sam.just@inktank.com>
Fri, 15 Feb 2013 19:11:13 +0000 (11:11 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/PG.cc
src/osd/PG.h

index ee1df9fc253f26171667bcecb990ba22bbefe615..2bebff3d72e0c27f37516eaffb8173989b72e1ae 100644 (file)
@@ -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,
index 26c5368897155cb36b5cc89b07714525c6243b1c..ec3d4664a90796505c552c2303a78d69eb97c714 100644 (file)
@@ -1798,7 +1798,8 @@ public:
   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,