From 633b114aca65548b91a898db7bbbef784b76180b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 8 Sep 2017 18:08:51 -0400 Subject: [PATCH] os/bluestore: use min_alloc_size for freelist resolution For HDD with min_alloc_size=64k, this is a 16x reduction in allocation metadata! Signed-off-by: Sage Weil (cherry picked from commit 6b8e4d512604095fb8a209229d4633ac19b499de) Conflicts: Slightly conflict with 834542c4027a8cc4d23eff089827d328919372d2, which drops the literal description of apply(). --- src/os/bluestore/BlueStore.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5e77da5ed96a6..3785efc2f2855 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4159,7 +4159,7 @@ int BlueStore::_open_fm(bool create) bl.append(freelist_type); t->set(PREFIX_SUPER, "freelist_type", bl); } - fm->create(bdev->get_size(), cct->_conf->bdev_block_size, t); + fm->create(bdev->get_size(), min_alloc_size, t); // allocate superblock reserved space. note that we do not mark // bluefs space as allocated in the freelist; we instead rely on @@ -5451,7 +5451,7 @@ int BlueStore::_fsck_check_extents( } bool already = false; apply( - e.offset, e.length, block_size, used_blocks, __func__, + e.offset, e.length, min_alloc_size, used_blocks, __func__, [&](uint64_t pos, mempool_dynamic_bitset &bs) { if (bs.test(pos)) already = true; @@ -5553,9 +5553,10 @@ int BlueStore::fsck(bool deep) if (r < 0) goto out_scan; - used_blocks.resize(bdev->get_size() / block_size); + used_blocks.resize(bdev->get_size() / min_alloc_size); apply( - 0, SUPER_RESERVED, block_size, used_blocks, "0~SUPER_RESERVED", + 0, MAX(min_alloc_size, SUPER_RESERVED), min_alloc_size, used_blocks, + "0~SUPER_RESERVED", [&](uint64_t pos, mempool_dynamic_bitset &bs) { bs.set(pos); } @@ -5564,7 +5565,7 @@ int BlueStore::fsck(bool deep) if (bluefs) { for (auto e = bluefs_extents.begin(); e != bluefs_extents.end(); ++e) { apply( - e.get_start(), e.get_len(), block_size, used_blocks, "bluefs", + e.get_start(), e.get_len(), min_alloc_size, used_blocks, "bluefs", [&](uint64_t pos, mempool_dynamic_bitset &bs) { bs.set(pos); } @@ -5963,7 +5964,7 @@ int BlueStore::fsck(bool deep) << " released 0x" << std::hex << wt.released << std::dec << dendl; for (auto e = wt.released.begin(); e != wt.released.end(); ++e) { apply( - e.get_start(), e.get_len(), block_size, used_blocks, "deferred", + e.get_start(), e.get_len(), min_alloc_size, used_blocks, "deferred", [&](uint64_t pos, mempool_dynamic_bitset &bs) { bs.set(pos); } @@ -5978,7 +5979,8 @@ int BlueStore::fsck(bool deep) // know they are allocated. for (auto e = bluefs_extents.begin(); e != bluefs_extents.end(); ++e) { apply( - e.get_start(), e.get_len(), block_size, used_blocks, "bluefs_extents", + e.get_start(), e.get_len(), min_alloc_size, used_blocks, + "bluefs_extents", [&](uint64_t pos, mempool_dynamic_bitset &bs) { bs.reset(pos); } @@ -5989,7 +5991,7 @@ int BlueStore::fsck(bool deep) while (fm->enumerate_next(&offset, &length)) { bool intersects = false; apply( - offset, length, block_size, used_blocks, "free", + offset, length, min_alloc_size, used_blocks, "free", [&](uint64_t pos, mempool_dynamic_bitset &bs) { if (bs.test(pos)) { intersects = true; @@ -6083,8 +6085,8 @@ int BlueStore::fsck(bool deep) size_t next = used_blocks.find_next(cur); if (next != cur + 1) { derr << __func__ << " error: leaked extent 0x" << std::hex - << ((uint64_t)start * block_size) << "~" - << ((cur + 1 - start) * block_size) << std::dec + << ((uint64_t)start * min_alloc_size) << "~" + << ((cur + 1 - start) * min_alloc_size) << std::dec << dendl; start = next; break; -- 2.39.5