From: Sage Weil Date: Tue, 1 Dec 2015 22:21:00 +0000 (-0500) Subject: osd: mark osd backend type in osd_data dir X-Git-Tag: v10.0.2~106^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db9ec690e6d7d173d978884d7a4cbd1f0bf3cf18;p=ceph.git osd: mark osd backend type in osd_data dir 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 --- diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc index aad4307d2e5..fb5de3688a5 100644 --- a/src/ceph_osd.cc +++ b/src/ceph_osd.cc @@ -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) { diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 24653164ff3..d58fa5ffe4c 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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; diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index 1d715222a87..481a8ac6f2c 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -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; diff --git a/src/os/MemStore.cc b/src/os/MemStore.cc index 678b16d2138..f87e6287fb6 100644 --- a/src/os/MemStore.cc +++ b/src/os/MemStore.cc @@ -224,6 +224,10 @@ int MemStore::mkfs() if (r < 0) return r; + r = write_meta("type", "memstore"); + if (r < 0) + return r; + return 0; }