]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: fix up commit_op_seq
authorSage Weil <sage@newdream.net>
Fri, 5 Feb 2010 19:32:48 +0000 (11:32 -0800)
committerSage Weil <sage@newdream.net>
Fri, 5 Feb 2010 19:32:48 +0000 (11:32 -0800)
Note that we now _only_ update commit_op_seq when doing a proper commit.
That means that any additional commit the fs does will be unknown to us. If
we have a journal, that's fine, we'll replay it.  If not, we're screwed.

So if there's no journal, we need to be using btrfs_snap mode, and roll
back to the last snap.

src/os/FileStore.cc

index 873c82a3cf0ce3dd7bbdfa2dc60470c54de8eae0..8a12ad2a934c53a5860e90f56c08aec01ad0b819 100644 (file)
@@ -420,8 +420,12 @@ int FileStore::mount()
   op_fd = ::open(fn, O_CREAT|O_RDWR, 0644);
   assert(op_fd >= 0);
   __u64 initial_op_seq = 0;
-  ::read(op_fd, &initial_op_seq, sizeof(initial_op_seq));
-
+  {
+    char s[40];
+    int l = ::read(op_fd, s, sizeof(s));
+    s[l] = 0;
+    initial_op_seq = atoll(s);
+  }
   dout(5) << "mount op_seq is " << initial_op_seq << dendl;
 
   // journal
@@ -1390,6 +1394,9 @@ void FileStore::sync_entry()
       sync_epoch++;
 
       dout(15) << "sync_entry committing " << cp << " sync_epoch " << sync_epoch << dendl;
+      char s[30];
+      sprintf(s, "%lld", (long long unsigned)cp);
+      ::pwrite(op_fd, s, strlen(s), 0);
 
       bool do_snap = g_conf.filestore_btrfs_snap;