]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: mark osd backend type in osd_data dir 6759/head
authorSage Weil <sage@redhat.com>
Tue, 1 Dec 2015 22:21:00 +0000 (17:21 -0500)
committerSage Weil <sage@redhat.com>
Tue, 1 Dec 2015 22:21:00 +0000 (17:21 -0500)
When we create an osd, mark the type of the backend in the
osd_data dir in the 'type' file.  On startup, if this file is
present, us this to decide which ObjectStore to instantiate.  If
it is not present, use the osd_objectstore option as before.

Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph_osd.cc
src/os/FileStore.cc
src/os/KeyValueStore.cc
src/os/MemStore.cc

index aad4307d2e50d0b269c616e0a0225f523e77aebd..fb5de3688a582b6b498ea6ee695f32175d8eb04d 100644 (file)
@@ -240,8 +240,23 @@ int main(int argc, const char **argv)
   }
 
   // the store
+  string store_type = g_conf->osd_objectstore;
+  {
+    char fn[PATH_MAX];
+    snprintf(fn, sizeof(fn), "%s/type", g_conf->osd_data.c_str());
+    int fd = ::open(fn, O_RDONLY);
+    if (fd >= 0) {
+      bufferlist bl;
+      bl.read_fd(fd, 64);
+      if (bl.length()) {
+       store_type = string(bl.c_str(), bl.length() - 1);  // drop \n
+       dout(5) << "object store type is " << store_type << dendl;
+      }
+      ::close(fd);
+    }
+  }
   ObjectStore *store = ObjectStore::create(g_ceph_context,
-                                          g_conf->osd_objectstore,
+                                          store_type,
                                           g_conf->osd_data,
                                           g_conf->osd_journal);
   if (!store) {
index 24653164ff312b83b754f0ee4d03d2457d1113ea..d58fa5ffe4cf50c65f4cb831d5595d9c4aeaceee 100644 (file)
@@ -926,6 +926,10 @@ int FileStore::mkfs()
   if (ret)
     goto close_fsid_fd;
 
+  ret = write_meta("type", "filestore");
+  if (ret)
+    goto close_fsid_fd;
+
   dout(1) << "mkfs done in " << basedir << dendl;
   ret = 0;
 
index 1d715222a8758bc28a8f769fa1869ae4699513b4..481a8ac6f2c4e85da6d8a68bdf47bb2d476a3dbe 100644 (file)
@@ -718,6 +718,10 @@ int KeyValueStore::mkfs()
     delete store;
   }
 
+  ret = write_meta("type", "keyvaluestore");
+  if (ret < 0)
+    goto close_fsid_fd;
+
   dout(1) << "mkfs done in " << basedir << dendl;
   ret = 0;
 
index 678b16d2138fb99e215abbdf1a416e82fc86f6f6..f87e6287fb6979c7ff662181824d934402bbedfe 100644 (file)
@@ -224,6 +224,10 @@ int MemStore::mkfs()
   if (r < 0)
     return r;
 
+  r = write_meta("type", "memstore");
+  if (r < 0)
+    return r;
+
   return 0;
 }