From 9c09ff2d0c78fbaeab3d7f55108409fc88766ea3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 1 Mar 2019 08:57:36 -0600 Subject: [PATCH] ceph-osd: infer objectstore type of 'type' file is missing 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 --- src/ceph_osd.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc index c5cec6d8d98..998f3707468 100644 --- a/src/ceph_osd.cc +++ b/src/ceph_osd.cc @@ -267,7 +267,7 @@ int main(int argc, const char **argv) } // the store - std::string store_type = g_conf().get_val("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("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); + } + } } } -- 2.39.5