From: Abutalib Aghayev Date: Fri, 12 Jun 2020 14:40:41 +0000 (-0400) Subject: os/bluestore: Support adding a region that spans two zones in ZonedAllocator X-Git-Tag: v16.1.0~1998^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0d96ff19afb4161d9b113ef49dea76bce6797401;p=ceph.git 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 --- diff --git a/src/os/bluestore/ZonedAllocator.cc b/src/os/bluestore/ZonedAllocator.cc index 90468e4f00a8..7386f4ff06e8 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; + } } }