]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Import necessary functions to fix rebase.
authorAdam Kupczyk <akupczyk@redhat.com>
Wed, 7 Aug 2019 14:21:29 +0000 (10:21 -0400)
committerNeha Ojha <nojha@redhat.com>
Wed, 7 Aug 2019 19:56:08 +0000 (15:56 -0400)
This commit is specific to luminous to make the backport of
https://github.com/ceph/ceph/pull/29425 simpler.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 7671c9378b2c7dab20ff20569347ba14d68ae772..9c75341a944a96c96079aed4802258a5a2e6a56f 100644 (file)
@@ -4800,6 +4800,102 @@ bool BlueStore::test_mount_in_use()
   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;
@@ -5816,7 +5912,7 @@ int BlueStore::cold_open()
   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;
   }
index 2f70dff72119013da86d9ac7caf9d0518053335f..c3b9cd1f858d4ad60496707156c91c33df77bf95 100644 (file)
@@ -2111,6 +2111,13 @@ private:
   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();