Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 47 additions & 76 deletions extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2643,24 +2643,24 @@ my_bool regex_list_check_match(
}

static
my_bool
bool
find_filter_in_hashtable(
const char* name,
hash_table_t* table,
xb_filter_entry_t** result
)
{
xb_filter_entry_t* found = NULL;
const ulint fold = my_crc32c(0, name, strlen(name));
HASH_SEARCH(name_hash, table, fold,
xb_filter_entry_t*,
found, (void) 0,
!strcmp(found->name, name));

if (found && result) {
*result = found;
}
return (found != NULL);
const ulint fold= my_crc32c(0, name, strlen(name));
for (xb_filter_entry_t *found= static_cast<xb_filter_entry_t*>
(table->cell_get(fold)->node);
found; found= found->name_hash)
if (!strcmp(found->name, name))
{
if (result)
*result= found;
return true;
}
return false;
}

/************************************************************************
Expand Down Expand Up @@ -4143,14 +4143,13 @@ xb_add_filter(
const char* name, /*!< in: name of table/database */
hash_table_t* hash) /*!< in/out: hash to insert into */
{
xb_filter_entry_t* entry = xb_new_filter_entry(name);
xb_filter_entry_t *entry= xb_new_filter_entry(name);

if (UNIV_UNLIKELY(!hash->array)) {
hash->create(1000);
}
const ulint fold = my_crc32c(0, entry->name, strlen(entry->name));
HASH_INSERT(xb_filter_entry_t, name_hash, hash, fold, entry);
return entry;
if (UNIV_UNLIKELY(!hash->array))
hash->create(1000);
hash->cell_get(my_crc32c(0, entry->name, strlen(entry->name)))->
append(*entry, &xb_filter_entry_t::name_hash);
return entry;
}

/***********************************************************************
Expand Down Expand Up @@ -4204,11 +4203,13 @@ xb_register_filter_entry(

if (databases_hash && databases_hash->array) {
const ulint fold = my_crc32c(0, dbname, p - name);
HASH_SEARCH(name_hash, databases_hash,
fold,
xb_filter_entry_t*,
db_entry, (void) 0,
!strcmp(db_entry->name, dbname));
db_entry = static_cast<xb_filter_entry_t*>(
databases_hash->cell_get(fold)->node);
for (; db_entry; db_entry = db_entry->name_hash) {
if (!strcmp(db_entry->name, dbname)) {
break;
}
}
}
if (!db_entry) {
db_entry = xb_add_filter(dbname, databases_hash);
Expand Down Expand Up @@ -4396,33 +4397,17 @@ xb_filters_init()
}
}

static
void
xb_filter_hash_free(hash_table_t* hash)
static void xb_filter_hash_free(hash_table_t* hash)
{
ulint i;

/* free the hash elements */
for (i = 0; i < hash->n_cells; i++) {
xb_filter_entry_t* table;

table = static_cast<xb_filter_entry_t *>
(HASH_GET_FIRST(hash, i));

while (table) {
xb_filter_entry_t* prev_table = table;

table = static_cast<xb_filter_entry_t *>
(HASH_GET_NEXT(name_hash, prev_table));
const ulint fold = my_crc32c(0, prev_table->name,
strlen(prev_table->name));
HASH_DELETE(xb_filter_entry_t, name_hash, hash,
fold, prev_table);
free(prev_table);
}
}

hash->free();
for (ulint i= 0; i < hash->n_cells; i++)
for (auto prev= static_cast<xb_filter_entry_t*>(hash->array[i].node);
prev; )
{
auto next= prev->name_hash;
free(prev);
prev= next;
}
hash->free();
}

static void xb_regex_list_free(regex_list_t* list)
Expand Down Expand Up @@ -5331,8 +5316,8 @@ xb_delta_open_matching_space(
table->name = ((char*)table) + sizeof(xb_filter_entry_t);
memcpy(table->name, dest_space_name, len + 1);
const ulint fold = my_crc32c(0, dest_space_name, len);
HASH_INSERT(xb_filter_entry_t, name_hash, &inc_dir_tables_hash,
fold, table);
inc_dir_tables_hash.cell_get(fold)->append(
*table, &xb_filter_entry_t::name_hash);

mysql_mutex_lock(&fil_system.mutex);
fil_space = fil_space_get_by_name(dest_space_name);
Expand Down Expand Up @@ -5752,8 +5737,8 @@ static ibool prepare_handle_new_files(const char *data_home_dir,
strcpy(table->name, table_name.c_str());
const ulint fold = my_crc32c(0, table->name,
table_name.size());
HASH_INSERT(xb_filter_entry_t, name_hash, &inc_dir_tables_hash,
fold, table);
inc_dir_tables_hash.cell_get(fold)->append(
*table, &xb_filter_entry_t::name_hash);
}

return TRUE;
Expand All @@ -5769,29 +5754,15 @@ rm_if_not_found(
const char* data_home_dir, /*!<in: path to datadir */
const char* db_name, /*!<in: database name */
const char* file_name, /*!<in: file name with suffix */
void* arg __attribute__((unused)))
void*)
{
char name[FN_REFLEN];
xb_filter_entry_t* table;

snprintf(name, FN_REFLEN, "%s/%s", db_name, file_name);
/* Truncate ".ibd" */
const size_t len = strlen(name) - 4;
name[len] = '\0';
const ulint fold = my_crc32c(0, name, len);

HASH_SEARCH(name_hash, &inc_dir_tables_hash, fold,
xb_filter_entry_t*,
table, (void) 0,
!strcmp(table->name, name));

if (!table) {
snprintf(name, FN_REFLEN, "%s/%s/%s", data_home_dir,
db_name, file_name);
return os_file_delete(0, name);
}

return(TRUE);
char name[FN_REFLEN];
/* Truncate ".ibd" */
name[snprintf(name, FN_REFLEN, "%s/%s", db_name, file_name) - 4]= '\0';
if (find_filter_in_hashtable(name, &inc_dir_tables_hash, nullptr))
return true;
snprintf(name, FN_REFLEN, "%s/%s/%s", data_home_dir, db_name, file_name);
return os_file_delete(0, name);
}

/** Function enumerates files in datadir (provided by path) which are matched
Expand Down
7 changes: 2 additions & 5 deletions storage/innobase/btr/btr0sea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,7 @@ static void ha_delete_hash_node(hash_table_t *table, mem_heap_t *heap,
ut_a(del_node->block->n_pointers-- < MAX_N_POINTERS);
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */

const ulint fold= del_node->fold;

HASH_DELETE(ha_node_t, next, table, fold, del_node);
table->cell_get(del_node->fold)->remove(*del_node, &ha_node_t::next);

ha_node_t *top= static_cast<ha_node_t*>(mem_heap_get_top(heap, sizeof *top));

Expand All @@ -564,8 +562,7 @@ static void ha_delete_hash_node(hash_table_t *table, mem_heap_t *heap,
/* We have to look for the predecessor */
ha_node_t *node= static_cast<ha_node_t*>(cell->node);

while (top != HASH_GET_NEXT(next, node))
node= static_cast<ha_node_t*>(HASH_GET_NEXT(next, node));
while (top != node->next) node= node->next;

/* Now we have the predecessor node */
node->next= del_node;
Expand Down
86 changes: 40 additions & 46 deletions storage/innobase/buf/buf0buddy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,58 +341,52 @@ static buf_buddy_free_t* buf_buddy_alloc_zip(ulint i)
}

/** Deallocate a buffer frame of srv_page_size.
@param[in] buf buffer frame to deallocate */
static
void
buf_buddy_block_free(void* buf)
@param buf buffer frame to deallocate */
static void buf_buddy_block_free(void *buf) noexcept
{
const ulint fold = BUF_POOL_ZIP_FOLD_PTR(buf);
buf_page_t* bpage;
buf_block_t* block;

mysql_mutex_assert_owner(&buf_pool.mutex);
ut_a(!ut_align_offset(buf, srv_page_size));

HASH_SEARCH(hash, &buf_pool.zip_hash, fold, buf_page_t*, bpage,
ut_ad(bpage->state() == buf_page_t::MEMORY
&& bpage->in_zip_hash),
bpage->frame == buf);
ut_a(bpage);
ut_a(bpage->state() == buf_page_t::MEMORY);
ut_ad(bpage->in_zip_hash);
ut_d(bpage->in_zip_hash = false);
HASH_DELETE(buf_page_t, hash, &buf_pool.zip_hash, fold, bpage);
bpage->hash = nullptr;

ut_d(memset(buf, 0, srv_page_size));
MEM_UNDEFINED(buf, srv_page_size);

block = (buf_block_t*) bpage;
buf_LRU_block_free_non_file_page(block);

ut_ad(buf_pool.buddy_n_frames > 0);
ut_d(buf_pool.buddy_n_frames--);
mysql_mutex_assert_owner(&buf_pool.mutex);
ut_a(!ut_align_offset(buf, srv_page_size));

const ulint fold= BUF_POOL_ZIP_FOLD_PTR(buf);
buf_page_t **prev;
for (prev= reinterpret_cast<buf_page_t**>
(&buf_pool.zip_hash.cell_get(fold)->node); *prev; prev= &(*prev)->hash)
{
ut_ad((*prev)->in_zip_hash);
ut_ad((*prev)->state() == buf_page_t::MEMORY);
if ((*prev)->frame == buf)
goto found;
}

ut_error;
found:
ut_d((*prev)->in_zip_hash= false);
buf_page_t *bpage= *prev;
*prev= bpage->hash;
bpage->hash= nullptr;

ut_d(memset(buf, 0, srv_page_size));
MEM_UNDEFINED(buf, srv_page_size);

buf_LRU_block_free_non_file_page(reinterpret_cast<buf_block_t*>(bpage));
ut_ad(buf_pool.buddy_n_frames > 0);
ut_d(buf_pool.buddy_n_frames--);
}

/**********************************************************************//**
Allocate a buffer block to the buddy allocator. */
static
void
buf_buddy_block_register(
/*=====================*/
buf_block_t* block) /*!< in: buffer frame to allocate */
/** Allocate a buffer block to the buddy allocator.
@param block buffer block to register */
static void buf_buddy_block_register(buf_block_t *block) noexcept
{
const ulint fold = BUF_POOL_ZIP_FOLD(block);
ut_ad(block->page.state() == buf_page_t::MEMORY);

ut_a(block->page.frame);
ut_a(!ut_align_offset(block->page.frame, srv_page_size));
const ulint fold= BUF_POOL_ZIP_FOLD(block);
ut_ad(block->page.state() == buf_page_t::MEMORY);

ut_ad(!block->page.in_zip_hash);
ut_d(block->page.in_zip_hash = true);
HASH_INSERT(buf_page_t, hash, &buf_pool.zip_hash, fold, &block->page);
ut_a(block->page.frame);
ut_a(!ut_align_offset(block->page.frame, srv_page_size));

ut_d(buf_pool.buddy_n_frames++);
ut_ad(!block->page.in_zip_hash);
ut_d(block->page.in_zip_hash= true);
buf_pool.zip_hash.cell_get(fold)->append(block->page, &buf_page_t::hash);
ut_d(buf_pool.buddy_n_frames++);
}

/** Allocate a block from a bigger object.
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/dict/dict0crea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ dict_create_index_step(
return(thr);
}

bool dict_sys_t::load_sys_tables()
bool dict_sys_t::load_sys_tables() noexcept
{
ut_ad(!srv_any_background_activity());
bool mismatch= false;
Expand Down Expand Up @@ -1352,7 +1352,7 @@ bool dict_sys_t::load_sys_tables()
return mismatch;
}

dberr_t dict_sys_t::create_or_check_sys_tables()
dberr_t dict_sys_t::create_or_check_sys_tables() noexcept
{
if (sys_tables_exist())
return DB_SUCCESS;
Expand Down
Loading