]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: fix initial btrfs snap creation (on mkfs)
authorSage Weil <sage@inktank.com>
Thu, 24 May 2012 21:05:09 +0000 (14:05 -0700)
committerSage Weil <sage@inktank.com>
Thu, 24 May 2012 21:05:09 +0000 (14:05 -0700)
Create the snap_1 snap of current *after* we write the op_seq.  Otherwise
we will mistakingly believe the snapshot is of op seq 0.

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

index 0c3b85bb09c4fb820287cd6ffb12ac1b775058c1..aee914787ba2a730ed02358ad7fa4f65ba006032 100644 (file)
@@ -1013,9 +1013,16 @@ int FileStore::mkfs()
       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;
+      }
 
       if (btrfs_stable_commits) {
-       // create snap_0 too
+       // create snap_1 too
        snprintf(volargs.name, sizeof(volargs.name), COMMIT_SNAP_ITEM, 1ull);
        volargs.fd = ::open(current_fn.c_str(), O_RDONLY);
        assert(volargs.fd >= 0);
@@ -1036,14 +1043,6 @@ int FileStore::mkfs()
        }
        TEMP_FAILURE_RETRY(::close(volargs.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;
-      }
     }
     TEMP_FAILURE_RETRY(::close(fd));  
   }