Преглед на файлове

fix on coalesce for size-ordered free-list organised raw blocks

Ioannis Koutras преди 12 години
родител
ревизия
d0ee7ef872
променени са 1 файла, в които са добавени 19 реда и са изтрити 1 реда
  1. 19 1
      src/freelist/coalesce.c

+ 19 - 1
src/freelist/coalesce.c

@@ -15,7 +15,7 @@
  *
  */
 
-#include <dmmlib/config.h>
+#include "dmmlib/config.h"
 
 #ifdef WITH_KNOBS
 #include "dmmlib/dmmlib.h"
@@ -74,23 +74,41 @@ void coalesce(freelist_rb_t *raw_block, block_header_t *ptr) {
     if(three_blocks_size <= max_coal_size) {
         /* Remove the next block from the free list */
         REMOVE_FSLLIST(raw_block, next_block);
+
         /* Update border pointer if the next block was the border pointer */
         if(raw_block->border_ptr == next_block) {
             raw_block->border_ptr = previous_block;
         }
         /* Reset the previous block size */
         set_size_and_free(raw_block, previous_block, three_blocks_size);
+
+        /* In a size-ordered list, the previous block should be removed
+         * and added again to the free list, since its size changes. */
+#ifdef SIZE_ORDERED
+        REMOVE_FSLLIST(raw_block, previous_block);
+        ADD_BLOCK(previous_block);
+#endif /* SIZE_ORDERED */
+
         return;
     }
 
     /* Check if Previous + Current is ok */
     if(previous_current_size <= max_coal_size) {
+
         /* Update border pointer if the current block was the border pointer */
         if(raw_block->border_ptr == ptr) {
             raw_block->border_ptr = previous_block;
         }
         /* Reset the previous block size */
         set_size_and_free(raw_block, previous_block, previous_current_size);
+
+        /* In a size-ordered list, the previous block should be removed
+         * and added again to the free list, since its size changes. */
+#ifdef SIZE_ORDERED
+        REMOVE_FSLLIST(raw_block, previous_block);
+        ADD_BLOCK(previous_block);
+#endif /* SIZE_ORDERED */
+
         return;
     }