]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-disk: use the type file for bluestore
authorLoic Dachary <ldachary@redhat.com>
Sun, 24 Jan 2016 10:07:58 +0000 (17:07 +0700)
committerLoic Dachary <ldachary@redhat.com>
Thu, 4 Feb 2016 10:01:47 +0000 (17:01 +0700)
The type file in the OSD bluestore data exists and contains the
bluestore string. ceph-disk activate should use it instead of
the "osd objectstore" configuration value. It is better in case the
configuration file changes between prepare and activate.

The fsid file cannot be used by bluestore to signify that ceph-osd
--mkfs has completed successfully because it is pre-populated by
ceph-disk. Introduce the mkfs_done file, dedicated to this, instead of
overloading an existing file.

Signed-off-by: Sage Weil <sage@redhat.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
src/ceph-disk/ceph_disk/main.py
src/os/bluestore/BlueStore.cc

index e9556567074ac50695ae5835e052abf7de405a45..aaf31ac5e8a2a8ab24ba93aff7158079ca3f60e1 100755 (executable)
@@ -2412,11 +2412,9 @@ def mkfs(
         ],
     )
 
-    osd_objectstore = get_conf(
-                cluster=cluster,
-                variable='osd_objectstore',
-            )
-    if osd_objectstore == 'bluestore':
+    osd_type = read_one_line(path, 'type')
+
+    if osd_type == 'bluestore':
         command_check_call(
             [
                 'ceph-osd',
index 268ed5529801a2bfa44dd7a9dcfe2141f49c20ff..9c5bc52be9ef9e930d48172f927416abcb045ea0 100644 (file)
@@ -1641,6 +1641,29 @@ int BlueStore::mkfs()
   int r;
   uuid_d old_fsid;
 
+  {
+    string done;
+    r = read_meta("mkfs_done", &done);
+    if (r == 0) {
+      dout(1) << __func__ << " already created" << dendl;
+      return 0; // idempotent
+    }
+  }
+
+  {
+    string type;
+    r = read_meta("type", &type);
+    if (r == 0) {
+      if (type != "bluestore") {
+       dout(1) << __func__ << " expected bluestore, but type is " << type << dendl;
+       return -EIO;
+      }
+    }
+    r = write_meta("type", "bluestore");
+    if (r < 0)
+      return r;
+  }
+
   r = _open_path();
   if (r < 0)
     return r;
@@ -1670,8 +1693,6 @@ int BlueStore::mkfs()
       goto out_close_fsid;
     }
     fsid = old_fsid;
-    dout(1) << __func__ << " already created, fsid is " << fsid << dendl;
-    goto out_close_fsid;
   }
 
   r = _setup_block_symlink_or_file("block", g_conf->bluestore_block_path,
@@ -1748,16 +1769,20 @@ int BlueStore::mkfs()
   r = write_meta("bluefs", stringify((int)g_conf->bluestore_bluefs));
   if (r < 0)
     goto out_close_alloc;
-  r = write_meta("type", "bluestore");
+
+  if (fsid != old_fsid) {
+    r = _write_fsid();
+    if (r < 0) {
+      derr << __func__ << " error writing fsid: " << cpp_strerror(r) << dendl;
+      goto out_close_alloc;
+    }
+  }
+
+  // indicate success by writing the 'mkfs_done' file
+  r = write_meta("mkfs_done", "yes");
   if (r < 0)
     goto out_close_alloc;
-
-  // indicate mkfs completion/success by writing the fsid file
-  r = _write_fsid();
-  if (r == 0)
-    dout(10) << __func__ << " success" << dendl;
-  else
-    derr << __func__ << " error writing fsid: " << cpp_strerror(r) << dendl;
+  dout(10) << __func__ << " success" << dendl;
 
  out_close_alloc:
   _close_alloc();