From: Sage Weil Date: Fri, 1 Mar 2019 14:57:36 +0000 (-0600) Subject: ceph-osd: infer objectstore type of 'type' file is missing X-Git-Tag: v14.1.1~79^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9c09ff2d0c78fbaeab3d7f55108409fc88766ea3;p=ceph-ci.git 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 --- 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); + } + } } }