From: Adam Kupczyk Date: Wed, 7 Aug 2019 14:21:29 +0000 (-0400) Subject: os/bluestore: Import necessary functions to fix rebase. X-Git-Tag: v12.2.13~157^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=974eae57d55a0ea847b25b486b58540287292254;p=ceph.git os/bluestore: Import necessary functions to fix rebase. This commit is specific to luminous to make the backport of https://github.com/ceph/ceph/pull/29425 simpler. Signed-off-by: Adam Kupczyk --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 7671c9378b2..9c75341a944 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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; } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 2f70dff7211..c3b9cd1f858 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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();