Commit e2e2f893 authored by Marko Mäkelä's avatar Marko Mäkelä Committed by Sergei Golubchik

MDEV-15528: Minor cleanup

buf_flush_freed_page(): Reformat in the common style, and
simplify some code. Prefer to request all information from
smaller data structures (buf_page_t) than from fil_space_t
or the global variable srv_immediate_scrub_data_uncompressed.

SysTablespace::open_or_create(): Assert that the temporary
tablespace will not be created in page_compressed format, so that
buf_flush_freed_page() can avoid checking that on every call.

IORequest: Remove duplicated constructors, and do not explicitly
declare a default constructor.
parent e0e5d8c5
......@@ -1035,51 +1035,46 @@ page status as NORMAL. It initiates the write to the file only after
releasing the page from flush list and its associated mutex.
@param[in,out] bpage freed buffer page
@param[in] space tablespace object of the freed page */
static void buf_flush_freed_page(buf_page_t* bpage, fil_space_t* space)
static void buf_flush_freed_page(buf_page_t *bpage, fil_space_t *space)
{
const page_id_t page_id(bpage->id.space(), bpage->id.page_no());
BPageMutex* block_mutex = buf_page_get_mutex(bpage);
const bool uncompressed = (buf_page_get_state(bpage)
== BUF_BLOCK_FILE_PAGE);
bool punch_hole = false;
mutex_enter(&buf_pool->mutex);
mutex_enter(block_mutex);
buf_page_set_io_fix(bpage, BUF_IO_NONE);
bpage->status = buf_page_t::NORMAL;
buf_flush_write_complete(bpage, false);
if (uncompressed) {
rw_lock_sx_unlock_gen(&((buf_block_t*) bpage)->lock,
BUF_IO_WRITE);
}
buf_pool->stat.n_pages_written++;
mutex_exit(block_mutex);
mutex_exit(&buf_pool->mutex);
if (space->is_compressed()) {
ut_ad(buf_page_in_file(bpage));
const bool uncompressed= buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE;
BPageMutex *block_mutex= uncompressed
? &reinterpret_cast<buf_block_t*>(bpage)->mutex
: &buf_pool->zip_mutex;
mutex_enter(&buf_pool->mutex);
mutex_enter(block_mutex);
buf_page_set_io_fix(bpage, BUF_IO_NONE);
bpage->status= buf_page_t::NORMAL;
buf_flush_write_complete(bpage, false);
if (uncompressed)
rw_lock_sx_unlock_gen(&reinterpret_cast<buf_block_t*>(bpage)->lock,
BUF_IO_WRITE);
buf_pool->stat.n_pages_written++;
mutex_exit(&buf_pool->mutex);
const page_id_t page_id(bpage->id);
const auto zip_size= bpage->zip_size();
mutex_exit(block_mutex);
const bool punch_hole=
#if defined(HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) || defined(_WIN32)
punch_hole = (space != fil_system.temp_space
&& space->is_compressed());
space->is_compressed() ||
#endif
}
false;
if (srv_immediate_scrub_data_uncompressed || punch_hole) {
/* Zero write the page */
ulint type = IORequest::WRITE;
IORequest request(type, NULL);
page_t* frame = const_cast<byte*>(field_ref_zero);
ut_ad(space->id == page_id.space());
ut_ad(space->zip_size() == zip_size);
fil_io(request, punch_hole ? true :false,
page_id, space->zip_size(), 0,
space->physical_size(), frame, NULL,
false, punch_hole);
}
if (punch_hole || srv_immediate_scrub_data_uncompressed)
fil_io(IORequestWrite, punch_hole, page_id, zip_size, 0,
zip_size ? zip_size : srv_page_size,
const_cast<byte*>(field_ref_zero), nullptr, false, punch_hole);
space->release_for_io();
space->release_for_io();
}
/********************************************************************//**
......
......@@ -912,6 +912,8 @@ SysTablespace::open_or_create(
if (!space) {
return DB_ERROR;
}
ut_ad(!space->is_compressed());
ut_ad(space->full_crc32());
} else {
ut_ad(!fil_system.sys_space);
ut_ad(space_id() == TRX_SYS_SPACE);
......
......@@ -212,39 +212,12 @@ class IORequest {
PUNCH_HOLE = 64,
};
/** Default constructor */
IORequest()
:
m_bpage(NULL),
m_fil_node(NULL),
m_type(READ)
{
/* No op */
}
/**
@param[in] type Request type, can be a value that is
ORed from the above enum */
explicit IORequest(ulint type)
:
m_bpage(NULL),
m_fil_node(NULL),
m_type(static_cast<uint16_t>(type))
{
if (!is_punch_hole_supported()) {
clear_punch_hole();
}
}
/**
@param[in] type Request type, can be a value that is
ORed from the above enum
@param[in] bpage Page to be written */
IORequest(ulint type, buf_page_t* bpage)
:
m_bpage(bpage),
m_fil_node(NULL),
m_type(static_cast<uint16_t>(type))
IORequest(ulint type= READ, buf_page_t *bpage= nullptr)
: m_bpage(bpage), m_type(static_cast<uint16_t>(type))
{
if (bpage && buf_page_should_punch_hole(bpage)) {
set_punch_hole();
......@@ -372,13 +345,13 @@ class IORequest {
private:
/** Page to be written on write operation. */
buf_page_t* m_bpage;
buf_page_t* const m_bpage= nullptr;
/** File node */
fil_node_t* m_fil_node;
fil_node_t* m_fil_node= nullptr;
/** Request type bit flags */
uint16_t m_type;
uint16_t m_type= READ;
};
/* @} */
......
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