Cleanup: Remove duplicated code

buf_block_alloc(): Define as an alias in buf0lru.h, which defines
the underlying buf_LRU_get_free_block().

buf_block_free(): Define as an alias of the non-inline function
buf_pool.free_block(block).

Reviewed by: Vladislav Lesin
This commit is contained in:
Marko Mäkelä 2024-11-29 14:16:34 +02:00
parent 998a625d00
commit 507323abe6
6 changed files with 11 additions and 35 deletions

View file

@ -27,6 +27,7 @@ Created 2/17/1996 Heikki Tuuri
#include "btr0sea.h" #include "btr0sea.h"
#ifdef BTR_CUR_HASH_ADAPT #ifdef BTR_CUR_HASH_ADAPT
#include "buf0buf.h" #include "buf0buf.h"
#include "buf0lru.h"
#include "page0page.h" #include "page0page.h"
#include "page0cur.h" #include "page0cur.h"
#include "btr0cur.h" #include "btr0cur.h"

View file

@ -31,6 +31,7 @@ Created 11/11/1995 Heikki Tuuri
#include <sql_class.h> #include <sql_class.h>
#include "buf0flu.h" #include "buf0flu.h"
#include "buf0lru.h"
#include "buf0buf.h" #include "buf0buf.h"
#include "buf0checksum.h" #include "buf0checksum.h"
#include "buf0dblwr.h" #include "buf0dblwr.h"

View file

@ -143,17 +143,7 @@ operator<<(
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
# define buf_pool_get_curr_size() srv_buf_pool_curr_size # define buf_pool_get_curr_size() srv_buf_pool_curr_size
# define buf_block_free(block) buf_pool.free_block(block)
/** Allocate a buffer block.
@return own: the allocated block, state()==MEMORY */
inline buf_block_t *buf_block_alloc();
/********************************************************************//**
Frees a buffer block which does not contain a file page. */
UNIV_INLINE
void
buf_block_free(
/*===========*/
buf_block_t* block); /*!< in, own: block to be freed */
#define buf_page_get(ID, SIZE, LA, MTR) \ #define buf_page_get(ID, SIZE, LA, MTR) \
buf_page_get_gen(ID, SIZE, LA, NULL, BUF_GET, MTR) buf_page_get_gen(ID, SIZE, LA, NULL, BUF_GET, MTR)

View file

@ -75,26 +75,6 @@ inline bool buf_page_peek_if_too_old(const buf_page_t *bpage)
} }
} }
/** Allocate a buffer block.
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
inline buf_block_t *buf_block_alloc()
{
return buf_LRU_get_free_block(false);
}
/********************************************************************//**
Frees a buffer block which does not contain a file page. */
UNIV_INLINE
void
buf_block_free(
/*===========*/
buf_block_t* block) /*!< in, own: block to be freed */
{
mysql_mutex_lock(&buf_pool.mutex);
buf_LRU_block_free_non_file_page(block);
mysql_mutex_unlock(&buf_pool.mutex);
}
/********************************************************************//** /********************************************************************//**
Increments the modify clock of a frame by 1. The caller must (1) own the Increments the modify clock of a frame by 1. The caller must (1) own the
buf_pool mutex and block bufferfix count has to be zero, (2) or own an x-lock buf_pool mutex and block bufferfix count has to be zero, (2) or own an x-lock

View file

@ -81,14 +81,17 @@ we put it to free list to be used.
buf_block_t* buf_LRU_get_free_block(bool have_mutex) buf_block_t* buf_LRU_get_free_block(bool have_mutex)
MY_ATTRIBUTE((malloc,warn_unused_result)); MY_ATTRIBUTE((malloc,warn_unused_result));
#define buf_block_alloc() buf_LRU_get_free_block(false)
/** @return whether the unzip_LRU list should be used for evicting a victim /** @return whether the unzip_LRU list should be used for evicting a victim
instead of the general LRU list */ instead of the general LRU list */
bool buf_LRU_evict_from_unzip_LRU(); bool buf_LRU_evict_from_unzip_LRU();
/** Puts a block back to the free list. /** Free a buffer block which does not contain a file page,
@param[in] block block; not containing a file page */ while holding buf_pool.mutex.
void @param block block to be put to buf_pool.free */
buf_LRU_block_free_non_file_page(buf_block_t* block); void buf_LRU_block_free_non_file_page(buf_block_t *block);
/******************************************************************//** /******************************************************************//**
Adds a block to the LRU list. Please make sure that the page_size is Adds a block to the LRU list. Please make sure that the page_size is
already set when invoking the function, so that we can get correct already set when invoking the function, so that we can get correct

View file

@ -26,6 +26,7 @@ Created 6/9/1994 Heikki Tuuri
#include "mem0mem.h" #include "mem0mem.h"
#include "buf0buf.h" #include "buf0buf.h"
#include "buf0lru.h"
#include "srv0srv.h" #include "srv0srv.h"
#include <stdarg.h> #include <stdarg.h>