From db7502d37bc812f5ff7a986e9bf7b1f6b4e22881 Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Fri, 10 May 2024 07:38:56 +0000 Subject: [PATCH] os/bluestore: Review fixes Signed-off-by: Adam Kupczyk (cherry picked from commit 4adb942a6489bdd63199b0036cf6a22bf4880906) --- src/os/bluestore/BlueStore.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index f09613a078a99..93de73fb4838c 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6569,7 +6569,7 @@ int BlueStore::_read_bdev_label( bufferlist bl; unique_ptr buf(new char[BDEV_LABEL_BLOCK_SIZE]); uint64_t dev_size = bdev->get_size(); - if (dev_size <= disk_position + BDEV_LABEL_BLOCK_SIZE) { + if (dev_size < disk_position + BDEV_LABEL_BLOCK_SIZE) { dout(10) << __func__ << " position=0x" << std::hex << disk_position << " dev size=0x" << dev_size << std::dec << dendl; return 1; @@ -6579,6 +6579,7 @@ int BlueStore::_read_bdev_label( derr << __func__ << " failed to read from " << path << " at 0x" << std::hex << disk_position << std::dec <<": " << cpp_strerror(r) << dendl; + return -EIO; } bl.append(buf.get(), BDEV_LABEL_BLOCK_SIZE); @@ -8422,11 +8423,11 @@ int BlueStore::mkfs() if (cct->_conf.get_val("bluestore_bdev_label_multi")) { // take space for other bdev label copies for (size_t i = 1; i < bdev_label_positions.size(); i++) { - uint64_t location = bdev_label_positions[i]; - uint64_t size = p2roundup(BDEV_LABEL_BLOCK_SIZE, min_alloc_size); - if (location + size > bdev->get_size()) continue; - ceph_assert(p2align(location, min_alloc_size) == location); - alloc->init_rm_free(location, size); + uint64_t location = bdev_label_positions[i]; + uint64_t size = p2roundup(BDEV_LABEL_BLOCK_SIZE, min_alloc_size); + if (location + size > bdev->get_size()) continue; + ceph_assert(p2align(location, min_alloc_size) == location); + alloc->init_rm_free(location, size); } } -- 2.39.5