From 0d96ff19afb4161d9b113ef49dea76bce6797401 Mon Sep 17 00:00:00 2001 From: Abutalib Aghayev Date: Fri, 12 Jun 2020 10:40:41 -0400 Subject: [PATCH] os/bluestore: Support adding a region that spans two zones in ZonedAllocator Added a fix to ZonedAllocator that stops the assertion from triggering when a free region that spans two zones and ends at arbitrary bounds is added. This fix is temporary; a new FreelistManager implementation that is aware of the zone states will be added for a proper fix. Signed-off-by: Abutalib Aghayev --- src/os/bluestore/ZonedAllocator.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/ZonedAllocator.cc b/src/os/bluestore/ZonedAllocator.cc index 90468e4f00a8b..7386f4ff06e83 100644 --- a/src/os/bluestore/ZonedAllocator.cc +++ b/src/os/bluestore/ZonedAllocator.cc @@ -120,13 +120,18 @@ void ZonedAllocator::init_add_free(uint64_t offset, uint64_t length) { ldout(cct, 10) << __func__ << " set zone " << std::hex << zone << " write pointer to 0x" << offset << dendl; - length -= zone_size - offset; - ceph_assert(length % zone_size == 0); - - for ( ; length; length -= zone_size) { - write_pointers[++zone] = 0; - ldout(cct, 30) << __func__ << " set zone 0x" << std::hex - << zone << " write pointer to 0x" << 0 << dendl; + if (length > zone_size - offset) { + length -= zone_size - offset; + for (++zone; length >= zone_size; length -= zone_size) { + ldout(cct, 30) << __func__ << " set zone 0x" << std::hex + << zone << " write pointer to 0x" << 0 << dendl; + write_pointers[zone++] = 0; + } + if (length > 0) { + ldout(cct, 20) << __func__ << " set zone 0x" << std::hex + << zone << " write pointer to 0x" << 0 << dendl; + write_pointers[zone] = length; + } } } -- 2.47.3