]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add zero_to field to PG::OndiskLog; track zeroed region of pg log
authorSage Weil <sage@newdream.net>
Thu, 8 Mar 2012 22:29:42 +0000 (14:29 -0800)
committerSage Weil <sage@newdream.net>
Thu, 8 Mar 2012 22:30:09 +0000 (14:30 -0800)
Track which region of the log has been zeroed on disk.  This may be
different from tail if 'osd preserved trimmed log = false' in the config.

Only zero the portion of the log we need to.  This avoids rezeroing regions
or missing bits when 'osd preserved trimmed log' was off and is then turned
on.

Signed-off-by: Sage Weil <sage@newdream.net>
Reviewed-by: Samuel Just <samuel.just@dreamhost.com>
src/osd/PG.cc
src/osd/PG.h

index d48db381f77a051675ea0cbec03d7939d680cfe4..28277d0dcc0277ec0414a18d22f507deace3f082 100644 (file)
@@ -1911,8 +1911,15 @@ void PG::trim_ondisklog(ObjectStore::Transaction& t)
 
   ondisklog.tail = new_tail;
 
-  if (!g_conf->osd_preserve_trimmed_log)
-    t.zero(coll_t::META_COLL, log_oid, 0, ondisklog.tail & ~4095);
+  if (!g_conf->osd_preserve_trimmed_log) {
+    uint64_t zt = new_tail & ~4095;
+    if (zt > ondisklog.zero_to) {
+      t.zero(coll_t::META_COLL, log_oid, ondisklog.zero_to, zt);
+      dout(15) << "trim_ondisklog zeroing from " << ondisklog.zero_to
+              << " to " << zt << dendl;
+      ondisklog.zero_to = zt;
+    }
+  }
 
   bufferlist blb(sizeof(ondisklog));
   ::encode(ondisklog, blb);
index 3ab265dc8baeb1bf3dc07a3ea5ee5c26fd21faa4..8d56ddeec8f9f337da75a4880d6345c199424e89 100644 (file)
@@ -280,10 +280,11 @@ public:
   public:
     // ok
     uint64_t tail;                     // first byte of log. 
-    uint64_t head;                        // byte following end of log.
+    uint64_t head;                     // byte following end of log.
+    uint64_t zero_to;                // first non-zeroed byte of log.
     bool has_checksums;
 
-    OndiskLog() : tail(0), head(0) {}
+    OndiskLog() : tail(0), head(0), zero_to(0) {}
 
     uint64_t length() { return head - tail; }
     bool trim_to(eversion_t v, ObjectStore::Transaction& t);
@@ -291,12 +292,14 @@ public:
     void zero() {
       tail = 0;
       head = 0;
+      zero_to = 0;
     }
 
     void encode(bufferlist& bl) const {
-      ENCODE_START(3, 3, bl);
+      ENCODE_START(4, 3, bl);
       ::encode(tail, bl);
       ::encode(head, bl);
+      ::encode(zero_to, bl);
       ENCODE_FINISH(bl);
     }
     void decode(bufferlist::iterator& bl) {
@@ -304,17 +307,23 @@ public:
       has_checksums = (struct_v >= 2);
       ::decode(tail, bl);
       ::decode(head, bl);
+      if (struct_v >= 4)
+       ::decode(zero_to, bl);
+      else
+       zero_to = 0;
       DECODE_FINISH(bl);
     }
     void dump(Formatter *f) const {
       f->dump_unsigned("head", head);
       f->dump_unsigned("tail", tail);
+      f->dump_unsigned("zero_to", zero_to);
     }
     static void generate_test_instances(list<OndiskLog*>& o) {
       o.push_back(new OndiskLog);
       o.push_back(new OndiskLog);
-      o.back()->tail = 1;
-      o.back()->head = 2;
+      o.back()->tail = 2;
+      o.back()->head = 3;
+      o.back()->zero_to = 1;
     }
   };
   WRITE_CLASS_ENCODER(OndiskLog)