From 9747e165b8794bbc95dd59be7950660bc94119fe Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 5 Feb 2010 11:32:48 -0800 Subject: [PATCH] filestore: fix up commit_op_seq 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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 873c82a3cf0ce..8a12ad2a934c5 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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; -- 2.39.5