From 4d0001fd6f14b94ad69912ad9ef243216e95c903 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Mon, 10 Dec 2018 21:12:10 +0800 Subject: [PATCH] os/bluestore: check return value of _open_bluefs. With an non-existing device as db, it met the following error messages: sceph7: 2018-12-11 04:52:28.117 7efe74b1f600 -1 bluestore(/var/lib/ceph/mnt/osd-device-0-data) _read_fsid unparsable uuid sceph7: 2018-12-11 04:52:28.121 7efe74b1f600 -1 bluestore(/var/lib/ceph/mnt/osd-device-0-data) _open_bluefs /var/lib/ceph/mnt/osd-device-0-data/block.db symlink exists but target unusable: (2) No such file or directory sceph7: *** Caught signal (Segmentation fault) ** sceph7: in thread 7efe74b1f600 thread_name:ceph-osd sceph7: ceph version 14.0.1-1121-gfbea0e658a (fbea0e658a94c83936d2f78c42b5a8650b9700c4) nautilus (dev) sceph7: 1: (()+0x29e7ebc) [0x564a473f8ebc] sceph7: 2: (()+0x12890) [0x7efe7235f890] sceph7: 3: (__pthread_mutex_trylock()+0x14) [0x7efe72357244] sceph7: 4: (ceph::mutex_debug_detail::mutex_debug_impl::try_lock_impl()+0x1f) [0x564a46ae5091] sceph7: 5: (ceph::mutex_debug_detail::mutex_debug_impl::try_lock(bool)+0x1d) [0x564a46abd3bf] sceph7: 6: (ceph::mutex_debug_detail::mutex_debug_impl::lock(bool)+0x49) [0x564a46a9b20b] sceph7: 7: (std::lock_guard >::lock_guard(ceph::mutex_debug_detail::mutex_debug_impl&)+0x2f) [0x564a46a98515] sceph7: 8: (BlueFS::mkdir(std::__cxx11::basic_string, std::allocator > const&)+0x45) [0x564a4739a7cb] sceph7: 9: (BlueRocksEnv::CreateDir(std::__cxx11::basic_string, std::allocator > const&)+0x3a) [0x564a473b691a] sceph7: 10: (BlueStore::_open_db(bool, bool)+0x11b3) [0x564a471ec2b7] sceph7: 11: (BlueStore::mkfs()+0x149a) [0x564a471f4e00] sceph7: 12: (OSD::mkfs(CephContext*, ObjectStore*, uuid_d, int)+0xc9) [0x564a46a07c2b] sceph7: 13: (main()+0x1bf0) [0x564a469d4850] sceph7: 14: (__libc_start_main()+0xe7) [0x7efe70ff4b97] sceph7: 15: (_start()+0x2a) [0x564a469d1c5a] sceph7: 2018-12-11 04:52:28.137 7efe74b1f600 -1 *** Caught signal (Segmentation fault) ** To avoid this occur, it should check return value of _open_bluefs. Signed-off-by: Jianpeng Ma --- src/os/bluestore/BlueStore.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index fa2356c3a399d..3c9dc1beeaa04 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5107,6 +5107,9 @@ int BlueStore::_open_db(bool create, bool to_repair_db) } r = _open_bluefs(create); + if (r < 0) { + return r; + } if (cct->_conf->bluestore_bluefs_env_mirror) { rocksdb::Env *a = new BlueRocksEnv(bluefs); -- 2.47.3