Selaa lähdekoodia

fix the requested size of big raw blocks

Ioannis Koutras 12 vuotta sitten
vanhempi
commit
0e30e1d2b0
1 muutettua tiedostoa jossa 7 lisäystä ja 7 poistoa
  1. 7 7
      src/raw_block.c

+ 7 - 7
src/raw_block.c

@@ -43,8 +43,12 @@ raw_block_header_t *create_raw_block(size_t raw_block_size, rb_type type) {
     size_t remaining_cells;
 #endif /* BITMAP_RB_ONLY */
 
-    // In case mmap() function is used, align the requested size to multiple of
-    // pagesizes
+#ifdef REQUEST_SIZE_INFO
+    size_t requested_size = raw_block_size - sizeof(raw_block_header_t);
+#endif /* REQUEST_SIZE_INFO */
+
+    /* In case mmap() function is used, align the requested size to multiple of
+     * pagesizes */
 #ifdef PAGESIZE_ALIGN
     size_t pagesize = (size_t) sysconf(_SC_PAGESIZE);
     raw_block_size = pagesize * ((raw_block_size + pagesize - 1) / pagesize);
@@ -59,10 +63,6 @@ raw_block_header_t *create_raw_block(size_t raw_block_size, rb_type type) {
     INIT_RAW_BLOCK_LOCK(ptr);
     LOCK_RAW_BLOCK(ptr);
 
-#ifdef REQUEST_SIZE_INFO
-    ptr->requested_size = raw_block_size;
-#endif /* REQUEST_SIZE_INFO */
-
     ptr->size = raw_block_size;
 
     switch(type) {
@@ -122,7 +122,7 @@ raw_block_header_t *create_raw_block(size_t raw_block_size, rb_type type) {
 
         case BIGBLOCK:
 #ifdef REQUEST_SIZE_INFO
-            ptr->requested_size -= sizeof(raw_block_header_t);
+            ptr->requested_size = requested_size;
 #endif /* REQUEST_SIZE_INFO */
             break;
     }