]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix pg entry log encoding
authorSage Weil <sage@newdream.net>
Fri, 16 May 2008 20:30:04 +0000 (13:30 -0700)
committerSage Weil <sage@newdream.net>
Fri, 16 May 2008 20:30:16 +0000 (13:30 -0700)
src/osd/PG.cc
src/osd/PG.h

index 4367f7b0a8bd5ac4d4462c41f9f4cc890bcdf6cc..7888f18ad6a589b298408a89cf8cfb9aaa26a904 100644 (file)
@@ -1052,10 +1052,12 @@ void PG::write_log(ObjectStore::Transaction& t)
     if (bl.length() % 4096 == 0)
       ondisklog.block_map[bl.length()] = p->version;
     ::encode(*p, bl);
+    /*
     if (g_conf.osd_pad_pg_log) {  // pad to 4k, until i fix ebofs reallocation crap.  FIXME.
       bufferptr bp(4096 - sizeof(*p));
       bl.push_back(bp);
     }
+    */
   }
   ondisklog.top = bl.length();
   
@@ -1066,6 +1068,8 @@ void PG::write_log(ObjectStore::Transaction& t)
   t.collection_setattr(info.pgid, "ondisklog_top", &ondisklog.top, sizeof(ondisklog.top));
   
   t.collection_setattr(info.pgid, "info", &info, sizeof(info)); 
+
+  dout(10) << "write_log to [" << ondisklog.bottom << "," << ondisklog.top << ")" << dendl;
 }
 
 void PG::trim_ondisklog_to(ObjectStore::Transaction& t, eversion_t v) 
@@ -1103,18 +1107,20 @@ void PG::trim_ondisklog_to(ObjectStore::Transaction& t, eversion_t v)
 }
 
 
-void PG::append_log(ObjectStore::Transaction& t, PG::Log::Entry& logentry, 
+void PG::append_log(ObjectStore::Transaction &t, const PG::Log::Entry &logentry, 
                     eversion_t trim_to)
 {
   dout(10) << "append_log " << ondisklog.top << " " << logentry << dendl;
 
   // write entry on disk
   bufferlist bl;
-  bl.append( (char*)&logentry, sizeof(logentry) );
+  ::encode(logentry, bl);
+  /*
   if (g_conf.osd_pad_pg_log) {  // pad to 4k, until i fix ebofs reallocation crap.  FIXME.
     bufferptr bp(4096 - sizeof(logentry));
     bl.push_back(bp);
   }
+  */
   t.write( info.pgid.to_pobject(), ondisklog.top, bl.length(), bl );
   
   // update block map?
@@ -1160,10 +1166,11 @@ void PG::read_log(ObjectStore *store)
     }
     
     PG::Log::Entry e;
-    off_t pos = ondisklog.bottom;
+    bufferlist::iterator p = bl.begin();
     assert(log.log.empty());
-    while (pos < ondisklog.top) {
-      bl.copy(pos-ondisklog.bottom, sizeof(e), (char*)&e);
+    while (!p.end()) {
+      ::decode(e, p);
+      off_t pos = ondisklog.bottom + p.get_off();
       dout(10) << "read_log " << pos << " " << e << dendl;
 
       if (e.version > log.bottom || log.backlog) { // ignore items below log.bottom
@@ -1173,11 +1180,13 @@ void PG::read_log(ObjectStore *store)
       } else {
        dout(10) << "read_log ignoring entry at " << pos << dendl;
       }
-      
+
+      /*
       if (g_conf.osd_pad_pg_log)   // pad to 4k, until i fix ebofs reallocation crap.  FIXME.
        pos += 4096;
       else
        pos += sizeof(e);
+      */
     }
   }
   log.top = info.last_update;
index 1707c298d49fe6cca81bd1b2f4153e9a8678912c..aababd988cd55bb9c87796b13633b904a2d55d68 100644 (file)
@@ -663,8 +663,8 @@ public:
 
   // pg on-disk state
   void write_log(ObjectStore::Transaction& t);
-  void append_log(ObjectStore::Transactiont, 
-                  PG::Log::Entry& logentry, 
+  void append_log(ObjectStore::Transaction &t, 
+                  const PG::Log::Entry &logentry, 
                   eversion_t trim_to);
   void read_log(ObjectStore *store);
   void trim_ondisklog_to(ObjectStore::Transaction& t, eversion_t v);
@@ -709,9 +709,9 @@ WRITE_CLASS_ENCODER(PG::Log)
 
 inline ostream& operator<<(ostream& out, const PG::Info::History& h) 
 {
-  return out << " ec " << h.epoch_created
-            << " les " << h.last_epoch_started
-            << h.same_since << "/" << h.same_primary_since << "/" << h.same_acker_since;
+  return out << " ec=" << h.epoch_created
+            << " les=" << h.last_epoch_started
+            << " " << h.same_since << "/" << h.same_primary_since << "/" << h.same_acker_since;
 }
 
 inline ostream& operator<<(ostream& out, const PG::Info& pgi)