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>
}
// 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) {
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;
delete store;
}
+ ret = write_meta("type", "keyvaluestore");
+ if (ret < 0)
+ goto close_fsid_fd;
+
dout(1) << "mkfs done in " << basedir << dendl;
ret = 0;
if (r < 0)
return r;
+ r = write_meta("type", "memstore");
+ if (r < 0)
+ return r;
+
return 0;
}