return ret;
}
+int BlueStore::_is_bluefs(bool create, bool* ret)
+{
+ if (create) {
+ *ret = cct->_conf->bluestore_bluefs;
+ } else {
+ string s;
+ int r = read_meta("bluefs", &s);
+ if (r < 0) {
+ derr << __func__ << " unable to read 'bluefs' meta" << dendl;
+ return -EIO;
+ }
+ if (s == "1") {
+ *ret = true;
+ } else if (s == "0") {
+ *ret = false;
+ } else {
+ derr << __func__ << " bluefs = " << s << " : not 0 or 1, aborting"
+ << dendl;
+ return -EIO;
+ }
+ }
+ return 0;
+}
+
+/*
+* opens both DB and dependant super_meta, FreelistManager and allocator
+* in the proper order
+*/
+int BlueStore::_open_db_and_around()
+{
+ int r;
+ bool do_bluefs = false;
+ _is_bluefs(false, &do_bluefs); // ignore err code
+ if (do_bluefs) {
+ // open in read-only first to read FM list and init allocator
+ // as they might be needed for some BlueFS procedures
+ r = _open_db(false);
+ if (r < 0)
+ return r;
+
+ r = _open_super_meta();
+ if (r < 0) {
+ goto out_db;
+ }
+
+ r = _open_fm(nullptr);
+ if (r < 0)
+ goto out_db;
+
+ r = _open_alloc();
+ if (r < 0)
+ goto out_fm;
+
+ } else {
+ r = _open_db(false);
+ if (r < 0) {
+ return r;
+ }
+ r = _open_super_meta();
+ if (r < 0) {
+ goto out_db;
+ }
+
+ r = _open_fm(nullptr);
+ if (r < 0)
+ goto out_db;
+
+ r = _open_alloc();
+ if (r < 0)
+ goto out_fm;
+ }
+ return 0;
+
+ out_fm:
+ _close_fm();
+ out_db:
+ _close_db();
+ return r;
+}
+
+void BlueStore::_close_db_and_around()
+{
+ if (bluefs) {
+ _close_db();
+ if (!_kv_only) {
+ _close_alloc();
+ _close_fm();
+ }
+ } else {
+ _close_alloc();
+ _close_fm();
+ _close_db();
+ }
+}
+
+
int BlueStore::_open_db(bool create)
{
int r;
r = _open_bdev(false);
if (r < 0)
goto out_fsid;
- r = _open_db_and_around(true);
+ r = _open_db_and_around();
if (r < 0) {
goto out_bdev;
}
void _set_alloc_sizes();
void _set_blob_size();
void _set_finisher_num();
+ int _is_bluefs(bool create, bool* ret);
+ /*
+ * opens both DB and dependant super_meta, FreelistManager and allocator
+ * in the proper order
+ */
+ int _open_db_and_around();
+ void _close_db_and_around();
int _open_bdev(bool create);
void _close_bdev();