]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-osd: infer objectstore type of 'type' file is missing 26720/head
authorSage Weil <sage@redhat.com>
Fri, 1 Mar 2019 14:57:36 +0000 (08:57 -0600)
committerSage Weil <sage@redhat.com>
Fri, 1 Mar 2019 21:51:38 +0000 (15:51 -0600)
The current value of osd_objectstore should have no bearing--we should
rely on the state in front of us.

- If there is a directory called current/, assume filestore.
- If there is a symlink called block, assume bluestore.
- If we see none of those, fail.

Fixes: http://tracker.ceph.com/issues/38517
Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph_osd.cc

index c5cec6d8d98db933ed187d58b54ad5f299ffb896..998f3707468b5a1500fcbbbfd686a759ae87857a 100644 (file)
@@ -267,7 +267,7 @@ int main(int argc, const char **argv)
   }
 
   // the store
-  std::string store_type = g_conf().get_val<std::string>("osd_objectstore");
+  std::string store_type;
   {
     char fn[PATH_MAX];
     snprintf(fn, sizeof(fn), "%s/type", data_path.c_str());
@@ -280,6 +280,29 @@ int main(int argc, const char **argv)
        dout(5) << "object store type is " << store_type << dendl;
       }
       ::close(fd);
+    } else if (mkfs) {
+      store_type = g_conf().get_val<std::string>("osd_objectstore");
+    } else {
+      // hrm, infer the type
+      snprintf(fn, sizeof(fn), "%s/current", data_path.c_str());
+      struct stat st;
+      if (::stat(fn, &st) == 0 &&
+         S_ISDIR(st.st_mode)) {
+       derr << "missing 'type' file, inferring filestore from current/ dir"
+            << dendl;
+       store_type = "filestore";
+      } else {
+       snprintf(fn, sizeof(fn), "%s/block", data_path.c_str());
+       if (::stat(fn, &st) == 0 &&
+           S_ISLNK(st.st_mode)) {
+         derr << "missing 'type' file, inferring bluestore from block symlink"
+              << dendl;
+         store_type = "bluestore";
+       } else {
+         derr << "missing 'type' file and unable to infer osd type" << dendl;
+         forker.exit(1);
+       }
+      }
     }
   }