Commit 0d5f0ab7 authored by marko's avatar marko

branches/zip: buf_buddy_alloc_free(), buf_buddy_alloc_free_low():

Add parameter "split" for enabling splits.
parent 2a25f556
...@@ -22,7 +22,9 @@ buf_buddy_alloc_free_low( ...@@ -22,7 +22,9 @@ buf_buddy_alloc_free_low(
/*=====================*/ /*=====================*/
/* out: allocated block, or NULL /* out: allocated block, or NULL
if buf_pool->zip_free[] was empty */ if buf_pool->zip_free[] was empty */
ulint i) /* in: index of buf_pool->zip_free[] */ ulint i, /* in: index of buf_pool->zip_free[] */
ibool split) /* in: TRUE=attempt splitting,
FALSE=try to allocate exact size */
{ {
buf_page_t* bpage; buf_page_t* bpage;
...@@ -37,6 +39,14 @@ buf_buddy_alloc_free_low( ...@@ -37,6 +39,14 @@ buf_buddy_alloc_free_low(
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE); ut_a(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE);
UT_LIST_REMOVE(list, buf_pool->zip_free[i], bpage); UT_LIST_REMOVE(list, buf_pool->zip_free[i], bpage);
} else if (split && i + 1 < BUF_BUDDY_SIZES) {
bpage = buf_buddy_alloc_free_low(i + 1, split);
if (bpage) {
buf_page_t* buddy = bpage + BUF_BUDDY_LOW << i;
UT_LIST_ADD_FIRST(list, buf_pool->zip_free[i], buddy);
}
} }
return(bpage); return(bpage);
......
...@@ -47,7 +47,9 @@ UNIV_INLINE ...@@ -47,7 +47,9 @@ UNIV_INLINE
void* void*
buf_buddy_alloc_free( buf_buddy_alloc_free(
/*=================*/ /*=================*/
ulint size) /* in: block size, up to UNIV_PAGE_SIZE / 2 */ ulint size, /* in: block size, up to UNIV_PAGE_SIZE / 2 */
ibool split) /* in: TRUE=attempt splitting,
FALSE=try to allocate exact size */
__attribute__((malloc)); __attribute__((malloc));
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
......
...@@ -22,7 +22,9 @@ buf_buddy_alloc_free_low( ...@@ -22,7 +22,9 @@ buf_buddy_alloc_free_low(
/*=====================*/ /*=====================*/
/* out: allocated block, or NULL /* out: allocated block, or NULL
if buf_pool->zip_free[] was empty */ if buf_pool->zip_free[] was empty */
ulint i) /* in: index of buf_pool->zip_free[] */ ulint i, /* in: index of buf_pool->zip_free[] */
ibool split) /* in: TRUE=attempt splitting,
FALSE=try to allocate exact size */
__attribute__((malloc)); __attribute__((malloc));
/************************************************************************** /**************************************************************************
...@@ -70,13 +72,15 @@ UNIV_INLINE ...@@ -70,13 +72,15 @@ UNIV_INLINE
void* void*
buf_buddy_alloc_free( buf_buddy_alloc_free(
/*=================*/ /*=================*/
ulint size) /* in: block size, up to UNIV_PAGE_SIZE / 2 */ ulint size, /* in: block size, up to UNIV_PAGE_SIZE / 2 */
ibool split) /* in: TRUE=attempt splitting,
FALSE=try to allocate exact size */
{ {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex)); ut_a(mutex_own(&buf_pool->mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
return(buf_buddy_alloc_free_low(buf_buddy_get_slot(size))); return(buf_buddy_alloc_free_low(buf_buddy_get_slot(size), split));
} }
#ifdef UNIV_MATERIALIZE #ifdef UNIV_MATERIALIZE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment