From: Feng Hualong Date: Mon, 10 Aug 2020 03:10:55 +0000 (+0000) Subject: os/bluestore: do not update used_blocks with bluefs_extents if bluefs is X-Git-Tag: v16.1.0~1322^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b678697aeb87a7988a25f9b4ad1111f59a121cbb;p=ceph.git os/bluestore: do not update used_blocks with bluefs_extents if bluefs is not available When I disabled bluefs, the bluefs point is nullptr, but is still used. It caused the problem: *** Caught signal (Segmentation fault) ** in thread 7f733db01d80 thread_name:ceph-osd ceph version 16.0.0-4201-g2ccd47711b (2ccd47711b73b09069e6964730532fc3cf6e7382) pacific (dev) 1: (()+0x153c0) [0x7f733e1a73c0] 2: (pthread_mutex_lock()+0x4) [0x7f733e19dfc4] 3: (BlueFS::get_block_extents(unsigned int, interval_set*)+0x40) [0x562384a57680] 4: (BlueStore::_fsck_on_open(BlueStore::FSCKDepth, bool)+0x743) [0x5623849b1143] 5: (BlueStore::_fsck(BlueStore::FSCKDepth, bool)+0x32a) [0x5623849be1da] 6: (BlueStore::mkfs()+0xc77) [0x5623849c0967] 7: (OSD::mkfs(ceph::common::CephContext*, ObjectStore*, uuid_d, int, std::__cxx11::basic_string, std::allocator >)+0x1b2) [0x5623843e85c2] 8: (main()+0x1563) [0x56238436b3f3] 9: (__libc_start_main()+0xf3) [0x7f733dc0e0b3] 10: (_start()+0x2e) [0x5623843b734e] 2020-08-10T00:54:09.896+0000 7f733db01d80 -1 *** Caught signal (Segmentation fault) ** in thread 7f733db01d80 thread_name:ceph-osd ceph version 16.0.0-4201-g2ccd47711b (2ccd47711b73b09069e6964730532fc3cf6e7382) pacific (dev) Signed-off-by: Feng Hualong --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 97c5acb66dde..a43ffd5e468e 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8006,7 +8006,6 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) uint64_t num_sharded_objects = 0; BlueStoreRepairer repairer; - interval_set bluefs_extents; auto alloc_size = fm->get_alloc_size(); utime_t start = ceph_clock_now(); @@ -8014,16 +8013,19 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) _fsck_collections(&errors); used_blocks.resize(fm->get_alloc_units()); - int r = bluefs->get_block_extents(bluefs_layout.shared_bdev, &bluefs_extents); - ceph_assert(r == 0); - for (interval_set::iterator it = bluefs_extents.begin(); it != bluefs_extents.end(); ++it) { + if (bluefs) { + interval_set bluefs_extents; - apply_for_bitset_range(it.get_start(), it.get_len(), alloc_size, used_blocks, - [&](uint64_t pos, mempool_dynamic_bitset& bs) { - ceph_assert(pos < bs.size()); - bs.set(pos); - } - ); + int r = bluefs->get_block_extents(bluefs_layout.shared_bdev, &bluefs_extents); + ceph_assert(r == 0); + for (auto [start, len] : bluefs_extents) { + apply_for_bitset_range(start, len, alloc_size, used_blocks, + [&](uint64_t pos, mempool_dynamic_bitset& bs) { + ceph_assert(pos < bs.size()); + bs.set(pos); + } + ); + } } bluefs_used_blocks = used_blocks;