]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileJournal: clarify meaning of start_seq and fix initialization
authorSamuel Just <sam.just@inktank.com>
Tue, 9 Apr 2013 17:27:50 +0000 (10:27 -0700)
committerSamuel Just <sam.just@inktank.com>
Tue, 9 Apr 2013 17:46:03 +0000 (10:46 -0700)
Second guessing the first sequence number from the FileStore
was silly and broke tests which had the temerity to start at
1 instead of 2...

Fixes: #4687
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/os/FileJournal.cc
src/os/FileJournal.h

index f5e8f34137eccc25584da660ba77eee09d72addf..29139c12bca9065cda7e1d2d312e24d2b0af898c 100644 (file)
@@ -389,9 +389,7 @@ int FileJournal::create()
     header.alignment = 16;  // at least stay word aligned on 64bit machines...
 
   header.start = get_top();
-  /* FileStore::mkfs initializes the fs op sequence file at 1.  Therefore,
-   * the first entry written must be  at sequence 2.*/
-  header.start_seq = 2;
+  header.start_seq = 0;
 
   print_header();
 
index 7b1777928cdb1490dcd3a573436315c1054909ec..0e826fb4940b654c1b51f9fe203b6e5dda58b393 100644 (file)
@@ -109,7 +109,22 @@ public:
     int64_t max_size;   // max size of journal ring buffer
     int64_t start;      // offset of first entry
     uint64_t committed_up_to; // committed up to
-    uint64_t start_seq;   // entry at header.start
+
+    /**
+     * start_seq
+     *
+     * entry at header.start has sequence >= start_seq
+     *
+     * Generally, the entry at header.start will have sequence
+     * start_seq if it exists.  The only exception is immediately
+     * after journal creation since the first sequence number is
+     * not known.
+     *
+     * If the first read on open fails, we can assume corruption
+     * if start_seq > committed_up_thru because the entry would have
+     * a sequence >= start_seq and therefore > committed_up_thru.
+     */
+    uint64_t start_seq;
 
     header_t() :
       flags(0), block_size(0), alignment(0), max_size(0), start(0),