]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: create but do not clobber current/commit_op_seq
authorSage Weil <sage@inktank.com>
Sat, 19 May 2012 22:23:49 +0000 (15:23 -0700)
committerSage Weil <sage@inktank.com>
Wed, 23 May 2012 00:24:10 +0000 (17:24 -0700)
If it exists, preserve its value.  Otherwise, create and set it to 1.

Signed-off-by: Sage Weil <sage@inktank.com>
src/os/FileStore.cc

index 7bcd0b4b1c8dcd4919e6224a4d3f62c99fda91d1..15e887d1f1fb9b089bd47feadca119f58720751c 100644 (file)
@@ -979,19 +979,21 @@ int FileStore::mkfs()
 
   // write initial op_seq
   {
-    uint64_t initial_seq;
+    uint64_t initial_seq = 0;
     int fd = read_op_seq(&initial_seq);
     if (fd < 0) {
       derr << "mkfs: failed to create " << current_op_seq_fn << ": "
           << cpp_strerror(fd) << dendl;
       goto close_fsid_fd;
     }
-    int err = write_op_seq(fd, 1);
-    if (err < 0) {
-      TEMP_FAILURE_RETRY(::close(fd));  
-      derr << "mkfs: failed to write to " << current_op_seq_fn << ": "
-          << cpp_strerror(err) << dendl;
-      goto close_fsid_fd;
+    if (initial_seq == 0) {
+      int err = write_op_seq(fd, 1);
+      if (err < 0) {
+       TEMP_FAILURE_RETRY(::close(fd));  
+       derr << "mkfs: failed to write to " << current_op_seq_fn << ": "
+            << cpp_strerror(err) << dendl;
+       goto close_fsid_fd;
+      }
     }
     TEMP_FAILURE_RETRY(::close(fd));  
   }