29 # include "buf0buddy.ic"
70 #define BUF_BUDDY_STAMP_OFFSET FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID
74 #define BUF_BUDDY_STAMP_FREE (SRV_LOG_SPACE_FIRST_ID)
78 #define BUF_BUDDY_STAMP_NONFREE (0XFFFFFFFF)
80 #if BUF_BUDDY_STAMP_FREE >= BUF_BUDDY_STAMP_NONFREE
81 # error "BUF_BUDDY_STAMP_FREE >= BUF_BUDDY_STAMP_NONFREE"
92 #ifdef UNIV_DEBUG_VALGRIND
97 buf_buddy_mem_invalid(
105 UNIV_MEM_ASSERT_W(buf, size);
106 UNIV_MEM_INVALID(buf, size);
109 # define buf_buddy_mem_invalid(buf, i) ut_ad((i) <= BUF_BUDDY_SIZES)
115 UNIV_INLINE __attribute__((warn_unused_result))
117 buf_buddy_stamp_is_free(
135 buf_buddy_mem_invalid(buf, i);
145 #define buf_buddy_stamp_nonfree(buf, i) do { \
146 buf_buddy_mem_invalid(buf, i); \
147 memset(buf->stamp.bytes + BUF_BUDDY_STAMP_OFFSET, 0xff, 4); \
149 #if BUF_BUDDY_STAMP_NONFREE != 0xffffffff
150 # error "BUF_BUDDY_STAMP_NONFREE != 0xffffffff"
170 if (((ulint) page) & size) {
184 ut_a(buf_buddy_stamp_is_free(elem));
189 #define BUF_BUDDY_LIST_VALIDATE(bp, i) \
190 UT_LIST_VALIDATE(list, buf_buddy_free_t, \
191 bp->zip_free[i], CheckZipFree(i))
200 buf_buddy_check_free(
210 ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
228 static __attribute__((warn_unused_result))
239 ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
256 if (!buf_buddy_stamp_is_free(buf)) {
264 ut_ad(buf->stamp.size <= i);
265 return(buf->stamp.size == i
274 buf_buddy_add_to_free(
282 ut_ad(buf_pool->zip_free[i].start != buf);
286 ut_d(BUF_BUDDY_LIST_VALIDATE(buf_pool, i));
293 buf_buddy_remove_from_free(
301 ut_ad(buf_buddy_check_free(buf_pool, buf, i));
321 ut_a(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
323 ut_d(BUF_BUDDY_LIST_VALIDATE(buf_pool, i));
328 buf_buddy_remove_from_free(buf_pool, buf, i);
331 buf = buf_buddy_alloc_zip(buf_pool, i + 1);
339 ut_ad(!buf_pool_contains_zip(buf_pool, buddy));
340 buf_buddy_add_to_free(buf_pool, buddy, i);
348 + buf->stamp.
bytes, ~i,
363 buf_buddy_block_free(
378 && bpage->in_zip_hash && !bpage->in_page_hash),
382 ut_ad(!bpage->in_page_hash);
383 ut_ad(bpage->in_zip_hash);
384 ut_d(bpage->in_zip_hash = FALSE);
387 ut_d(memset(buf, 0, UNIV_PAGE_SIZE));
388 UNIV_MEM_INVALID(buf, UNIV_PAGE_SIZE);
391 mutex_enter(&block->
mutex);
393 mutex_exit(&block->
mutex);
395 ut_ad(buf_pool->buddy_n_frames > 0);
396 ut_d(buf_pool->buddy_n_frames--);
403 buf_buddy_block_register(
408 const ulint fold = BUF_POOL_ZIP_FOLD(block);
420 ut_d(block->
page.in_zip_hash = TRUE);
423 ut_d(buf_pool->buddy_n_frames++);
431 buf_buddy_alloc_from(
442 ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
454 reinterpret_cast<byte*
>(
buf) + offs);
455 buf_buddy_add_to_free(buf_pool, zip_buf, j);
485 ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
489 block = (
buf_block_t*) buf_buddy_alloc_zip(buf_pool, i);
511 buf_buddy_block_register(block);
544 ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
545 UNIV_MEM_ASSERT_W(dst, size);
554 UNIV_MEM_VALID(&space,
sizeof space);
555 UNIV_MEM_VALID(&offset,
sizeof offset);
559 bpage = buf_page_hash_get(buf_pool, space, offset);
561 if (!bpage || bpage->
zip.
data != src) {
581 UNIV_MEM_ASSERT_W(src, size);
591 memcpy(dst, src, size);
594 buf_buddy_mem_invalid(
595 reinterpret_cast<buf_buddy_free_t*>(src), i);
624 ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
632 buf_buddy_block_free(buf_pool, buf);
638 ut_ad(!buf_pool_contains_zip(buf_pool, buf));
652 switch (buf_buddy_is_free(buddy, i)) {
655 buf_buddy_remove_from_free(buf_pool, buddy, i);
657 ut_ad(!buf_pool_contains_zip(buf_pool, buddy));
664 ut_d(BUF_BUDDY_LIST_VALIDATE(buf_pool, i));
674 buf_buddy_remove_from_free(buf_pool, zip_buf, i);
678 if (buf_buddy_relocate(buf_pool, buddy, zip_buf, i)) {
683 buf_buddy_add_to_free(buf_pool, zip_buf, i);
695 buf_buddy_add_to_free(buf_pool,
696 reinterpret_cast<buf_buddy_free_t*>(buf),