From: Sage Weil Date: Thu, 24 May 2012 21:05:09 +0000 (-0700) Subject: filestore: fix initial btrfs snap creation (on mkfs) X-Git-Tag: v0.48argonaut~151^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0f38d756ab83cde625fcfb827eaa87dc8ba01976;p=ceph.git filestore: fix initial btrfs snap creation (on mkfs) 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 --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 0c3b85bb09c4..aee914787ba2 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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)); }