]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Support adding a region that spans two zones in ZonedAllocator
authorAbutalib Aghayev <agayev@cs.cmu.edu>
Fri, 12 Jun 2020 14:40:41 +0000 (10:40 -0400)
committerAbutalib Aghayev <agayev@cs.cmu.edu>
Fri, 12 Jun 2020 14:49:26 +0000 (10:49 -0400)
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 <agayev@cs.cmu.edu>
src/os/bluestore/ZonedAllocator.cc

index 90468e4f00a8b9d5736f3a81835e5301793462f1..7386f4ff06e830fa5c883637224385a4720e8dc9 100644 (file)
@@ -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;
+    }
   }
 }