summaryrefslogtreecommitdiff
path: root/storage/maria
diff options
context:
space:
mode:
Diffstat (limited to 'storage/maria')
-rw-r--r--storage/maria/CMakeLists.txt2
-rw-r--r--storage/maria/ha_maria.cc117
-rw-r--r--storage/maria/ma_bitmap.c80
-rw-r--r--storage/maria/ma_blockrec.c24
-rw-r--r--storage/maria/ma_cache.c4
-rw-r--r--storage/maria/ma_check.c103
-rw-r--r--storage/maria/ma_checkpoint.c55
-rw-r--r--storage/maria/ma_close.c34
-rw-r--r--storage/maria/ma_control_file.c18
-rw-r--r--storage/maria/ma_create.c51
-rw-r--r--storage/maria/ma_dbug.c6
-rw-r--r--storage/maria/ma_delete_all.c4
-rw-r--r--storage/maria/ma_delete_table.c11
-rw-r--r--storage/maria/ma_dynrec.c26
-rw-r--r--storage/maria/ma_extra.c56
-rw-r--r--storage/maria/ma_info.c4
-rw-r--r--storage/maria/ma_init.c9
-rw-r--r--storage/maria/ma_key_recover.c20
-rw-r--r--storage/maria/ma_keycache.c8
-rw-r--r--storage/maria/ma_locking.c12
-rw-r--r--storage/maria/ma_loghandler.c319
-rw-r--r--storage/maria/ma_open.c87
-rw-r--r--storage/maria/ma_packrec.c14
-rw-r--r--storage/maria/ma_page.c6
-rw-r--r--storage/maria/ma_pagecache.c4
-rw-r--r--storage/maria/ma_panic.c29
-rw-r--r--storage/maria/ma_range.c4
-rw-r--r--storage/maria/ma_recovery.c28
-rw-r--r--storage/maria/ma_rename.c17
-rw-r--r--storage/maria/ma_rkey.c4
-rw-r--r--storage/maria/ma_rnext.c4
-rw-r--r--storage/maria/ma_rnext_same.c4
-rw-r--r--storage/maria/ma_rprev.c4
-rw-r--r--storage/maria/ma_rsame.c4
-rw-r--r--storage/maria/ma_servicethread.c36
-rw-r--r--storage/maria/ma_servicethread.h4
-rw-r--r--storage/maria/ma_sort.c12
-rw-r--r--storage/maria/ma_state.c24
-rw-r--r--storage/maria/ma_static.c47
-rw-r--r--storage/maria/ma_write.c32
-rw-r--r--storage/maria/maria_def.h64
-rw-r--r--storage/maria/tablockman.c48
-rw-r--r--storage/maria/tablockman.h6
-rw-r--r--storage/maria/trnman.c82
-rw-r--r--storage/maria/trnman.h6
45 files changed, 841 insertions, 692 deletions
diff --git a/storage/maria/CMakeLists.txt b/storage/maria/CMakeLists.txt
index 4095c1fc594..d922b31f69c 100644
--- a/storage/maria/CMakeLists.txt
+++ b/storage/maria/CMakeLists.txt
@@ -32,7 +32,7 @@ SET(ARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c
ma_keycache.c ma_preload.c ma_ft_parser.c
ma_ft_update.c ma_ft_boolean_search.c
ma_ft_nlq_search.c ft_maria.c ma_sort.c
- ha_maria.cc trnman.c lockman.c tablockman.c
+ ha_maria.cc trnman.c lockman.c
ma_rt_index.c ma_rt_key.c ma_rt_mbr.c ma_rt_split.c
ma_sp_key.c ma_control_file.c ma_loghandler.c
ma_pagecache.c ma_pagecaches.c compat_aliases.cc compat_aliases.h
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 331257dbe3d..80589631909 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -280,6 +280,93 @@ static MYSQL_SYSVAR_BOOL(used_for_temp_tables,
"Whether temporary tables should be MyISAM or Aria", 0, 0,
1);
+#ifdef HAVE_PSI_INTERFACE
+
+static PSI_mutex_info all_aria_mutexes[]=
+{
+ { &key_THR_LOCK_maria, "THR_LOCK_maria", PSI_FLAG_GLOBAL},
+ { &key_LOCK_soft_sync, "LOCK_soft_sync", PSI_FLAG_GLOBAL},
+ { &key_LOCK_trn_list, "LOCK_trn_list", PSI_FLAG_GLOBAL},
+ { &key_SHARE_BITMAP_lock, "SHARE::bitmap::bitmap_lock", 0},
+ { &key_SORT_INFO_mutex, "SORT_INFO::mutex", 0},
+ { &key_TRANSLOG_BUFFER_mutex, "TRANSLOG_BUFFER::mutex", 0},
+ { &key_TRANSLOG_DESCRIPTOR_dirty_buffer_mask_lock, "TRANSLOG_DESCRIPTOR::dirty_buffer_mask_lock", 0},
+ { &key_TRANSLOG_DESCRIPTOR_sent_to_disk_lock, "TRANSLOG_DESCRIPTOR::sent_to_disk_lock", 0},
+ { &key_TRANSLOG_DESCRIPTOR_log_flush_lock, "TRANSLOG_DESCRIPTOR::log_flush_lock", 0},
+ { &key_TRANSLOG_DESCRIPTOR_file_header_lock, "TRANSLOG_DESCRIPTOR::file_header_lock", 0},
+ { &key_TRANSLOG_DESCRIPTOR_unfinished_files_lock, "TRANSLOG_DESCRIPTOR::unfinished_files_lock", 0},
+ { &key_TRANSLOG_DESCRIPTOR_purger_lock, "TRANSLOG_DESCRIPTOR::purger_lock", 0},
+ { &key_SHARE_intern_lock, "SHARE::intern_lock", 0},
+ { &key_SHARE_key_del_lock, "SHARE::key_del_lock", 0},
+ { &key_SHARE_close_lock, "SHARE::close_lock", 0},
+ { &key_SERVICE_THREAD_CONTROL_lock, "SERVICE_THREAD_CONTROL::LOCK_control", 0},
+ { &key_TRN_state_lock, "TRN::state_lock", 0},
+ { &key_PAGECACHE_cache_lock, "PAGECACHE::cache_lock", 0}
+};
+
+static PSI_cond_info all_aria_conds[]=
+{
+ { &key_COND_soft_sync, "COND_soft_sync", PSI_FLAG_GLOBAL},
+ { &key_SHARE_key_del_cond, "SHARE::key_del_cond", 0},
+ { &key_SERVICE_THREAD_CONTROL_cond, "SERVICE_THREAD_CONTROL::COND_control", 0},
+ { &key_SORT_INFO_cond, "SORT_INFO::cond", 0},
+ { &key_SHARE_BITMAP_cond, "BITMAP::bitmap_cond", 0},
+ { &key_TRANSLOG_BUFFER_waiting_filling_buffer, "TRANSLOG_BUFFER::waiting_filling_buffer", 0},
+ { &key_TRANSLOG_BUFFER_prev_sent_to_disk_cond, "TRANSLOG_BUFFER::prev_sent_to_disk_cond", 0},
+ { &key_TRANSLOG_DESCRIPTOR_log_flush_cond, "TRANSLOG_DESCRIPTOR::log_flush_cond", 0},
+ { &key_TRANSLOG_DESCRIPTOR_new_goal_cond, "TRANSLOG_DESCRIPTOR::new_goal_cond", 0}
+};
+
+static PSI_rwlock_info all_aria_rwlocks[]=
+{
+ { &key_KEYINFO_root_lock, "KEYINFO::root_lock", 0},
+ { &key_SHARE_mmap_lock, "SHARE::mmap_lock", 0},
+ { &key_TRANSLOG_DESCRIPTOR_open_files_lock, "TRANSLOG_DESCRIPTOR::open_files_lock", 0}
+};
+
+static PSI_thread_info all_aria_threads[]=
+{
+ { &key_thread_checkpoint, "checkpoint_background", PSI_FLAG_GLOBAL},
+ { &key_thread_soft_sync, "soft_sync_background", PSI_FLAG_GLOBAL},
+ { &key_thread_find_all_keys, "thr_find_all_keys", 0}
+};
+
+static PSI_file_info all_aria_files[]=
+{
+ { &key_file_translog, "translog", 0},
+ { &key_file_kfile, "MAI", 0},
+ { &key_file_dfile, "MAD", 0},
+ { &key_file_control, "control", PSI_FLAG_GLOBAL}
+};
+
+
+static void init_aria_psi_keys(void)
+{
+ const char* category= "aria";
+ int count;
+
+ if (PSI_server == NULL)
+ return;
+
+ count= array_elements(all_aria_mutexes);
+ PSI_server->register_mutex(category, all_aria_mutexes, count);
+
+ count= array_elements(all_aria_rwlocks);
+ PSI_server->register_rwlock(category, all_aria_rwlocks, count);
+
+ count= array_elements(all_aria_conds);
+ PSI_server->register_cond(category, all_aria_conds, count);
+
+ count= array_elements(all_aria_threads);
+ PSI_server->register_thread(category, all_aria_threads, count);
+
+ count= array_elements(all_aria_files);
+ PSI_server->register_file(category, all_aria_files, count);
+}
+#else
+#define init_aria_psi_keys() /* no-op */
+#endif /* HAVE_PSI_INTERFACE */
+
/*****************************************************************************
** MARIA tables
*****************************************************************************/
@@ -906,7 +993,7 @@ int ha_maria::net_read_dump(NET * net)
int data_fd= file->dfile.file;
int error= 0;
- my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
+ mysql_file_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
for (;;)
{
ulong packet_len= my_net_read(net);
@@ -918,7 +1005,7 @@ int ha_maria::net_read_dump(NET * net)
error= -1;
goto err;
}
- if (my_write(data_fd, (uchar *) net->read_pos, (uint) packet_len,
+ if (mysql_file_write(data_fd, (uchar *) net->read_pos, (uint) packet_len,
MYF(MY_WME | MY_FNABP)))
{
error= errno;
@@ -942,10 +1029,10 @@ int ha_maria::dump(THD * thd, int fd)
return ENOMEM;
int error= 0;
- my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
+ mysql_file_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
for (; bytes_to_read > 0;)
{
- size_t bytes= my_read(data_fd, buf, block_size, MYF(MY_WME));
+ size_t bytes= mysql_file_read(data_fd, buf, block_size, MYF(MY_WME));
if (bytes == MY_FILE_ERROR)
{
error= errno;
@@ -954,7 +1041,7 @@ int ha_maria::dump(THD * thd, int fd)
if (fd >= 0)
{
- if (my_write(fd, buf, bytes, MYF(MY_WME | MY_FNABP)))
+ if (mysql_file_write(fd, buf, bytes, MYF(MY_WME | MY_FNABP)))
{
error= errno ? errno : EPIPE;
goto err;
@@ -1156,7 +1243,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
(param.testflag & T_STATISTICS) || maria_is_crashed(file))
{
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
DBUG_PRINT("info", ("Reseting crashed state"));
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR | STATE_IN_REPAIR);
@@ -1164,7 +1251,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
error= maria_update_state_info(&param, file,
UPDATE_TIME | UPDATE_OPEN_COUNT |
UPDATE_STAT);
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_CONST);
}
@@ -1213,9 +1300,9 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt)
error= maria_chk_key(&param, file);
if (!error)
{
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
error= maria_update_state_info(&param, file, UPDATE_STAT);
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
}
else if (!maria_is_crashed(file) && !thd->killed)
maria_mark_crashed(file);
@@ -1300,9 +1387,9 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
if (!error)
{
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
maria_update_state_info(&param, file, UPDATE_TIME | UPDATE_OPEN_COUNT);
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
}
return error;
}
@@ -1459,7 +1546,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
}
}
thd_proc_info(thd, "Saving state");
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (!error)
{
if ((share->state.changed & STATE_CHANGED) || maria_is_crashed(file))
@@ -1500,7 +1587,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
maria_update_state_info(param, file, 0);
}
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
thd_proc_info(thd, old_proc_info);
if (!thd->locked_tables_mode)
maria_lock_database(file, F_UNLCK);
@@ -3064,7 +3151,7 @@ bool maria_show_status(handlerton *hton,
const char error[]= "can't stat";
char object[SHOW_MSG_LEN];
file= translog_filename_by_fileno(i, path);
- if (!(stat= my_stat(file, &stat_buff, MYF(0))))
+ if (!(stat= mysql_file_stat(key_file_translog, file, &stat_buff, MYF(0))))
{
status= error;
status_len= sizeof(error) - 1;
@@ -3119,7 +3206,7 @@ static my_bool translog_callback_delete_all(const char *directory,
{
char complete_name[FN_REFLEN];
fn_format(complete_name, filename, directory, "", MYF(MY_UNPACK_FILENAME));
- return my_delete(complete_name, MYF(MY_WME));
+ return mysql_file_delete(key_file_translog, complete_name, MYF(MY_WME));
}
diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c
index 83e0d276417..fb12ecdbe3b 100644
--- a/storage/maria/ma_bitmap.c
+++ b/storage/maria/ma_bitmap.c
@@ -242,8 +242,10 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file)
bitmap->sizes[6]= max_page_size - max_page_size * 80 / 100;
bitmap->sizes[7]= 0;
- pthread_mutex_init(&share->bitmap.bitmap_lock, MY_MUTEX_INIT_SLOW);
- pthread_cond_init(&share->bitmap.bitmap_cond, 0);
+ mysql_mutex_init(key_SHARE_BITMAP_lock,
+ &share->bitmap.bitmap_lock, MY_MUTEX_INIT_SLOW);
+ mysql_cond_init(key_SHARE_BITMAP_cond,
+ &share->bitmap.bitmap_cond, 0);
_ma_bitmap_reset_cache(share);
@@ -267,9 +269,9 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file)
my_bool _ma_bitmap_end(MARIA_SHARE *share)
{
my_bool res= _ma_bitmap_flush(share);
- safe_mutex_assert_owner(&share->close_lock);
- pthread_mutex_destroy(&share->bitmap.bitmap_lock);
- pthread_cond_destroy(&share->bitmap.bitmap_cond);
+ mysql_mutex_assert_owner(&share->close_lock);
+ mysql_mutex_destroy(&share->bitmap.bitmap_lock);
+ mysql_cond_destroy(&share->bitmap.bitmap_cond);
delete_dynamic(&share->bitmap.pinned_pages);
my_free(share->bitmap.map);
share->bitmap.map= 0;
@@ -309,13 +311,13 @@ my_bool _ma_bitmap_flush(MARIA_SHARE *share)
DBUG_ENTER("_ma_bitmap_flush");
if (share->bitmap.changed)
{
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
if (share->bitmap.changed)
{
res= write_changed_bitmap(share, &share->bitmap);
share->bitmap.changed= 0;
}
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
}
DBUG_RETURN(res);
}
@@ -353,7 +355,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share)
my_bool res= 0;
MARIA_FILE_BITMAP *bitmap= &share->bitmap;
DBUG_ENTER("_ma_bitmap_flush_all");
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ mysql_mutex_lock(&bitmap->bitmap_lock);
if (bitmap->changed || bitmap->changed_not_flushed)
{
bitmap->flush_all_requested++;
@@ -361,7 +363,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share)
while (bitmap->non_flushable > 0)
{
DBUG_PRINT("info", ("waiting for bitmap to be flushable"));
- pthread_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
+ mysql_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
}
#endif
DBUG_ASSERT(bitmap->flush_all_requested == 1);
@@ -399,9 +401,9 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share)
become false, wake them up.
*/
DBUG_PRINT("info", ("bitmap flusher waking up others"));
- pthread_cond_broadcast(&bitmap->bitmap_cond);
+ mysql_cond_broadcast(&bitmap->bitmap_cond);
}
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
DBUG_RETURN(res);
}
@@ -429,19 +431,19 @@ void _ma_bitmap_lock(MARIA_SHARE *share)
if (!share->now_transactional)
DBUG_VOID_RETURN;
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ mysql_mutex_lock(&bitmap->bitmap_lock);
bitmap->flush_all_requested++;
while (bitmap->non_flushable)
{
DBUG_PRINT("info", ("waiting for bitmap to be flushable"));
- pthread_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
+ mysql_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
}
/*
Ensure that _ma_bitmap_flush_all() and _ma_bitmap_lock() are blocked.
ma_bitmap_flushable() is blocked thanks to 'flush_all_requested'.
*/
bitmap->non_flushable= 1;
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
DBUG_VOID_RETURN;
}
@@ -461,11 +463,11 @@ void _ma_bitmap_unlock(MARIA_SHARE *share)
DBUG_VOID_RETURN;
DBUG_ASSERT(bitmap->flush_all_requested > 0 && bitmap->non_flushable == 1);
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ mysql_mutex_lock(&bitmap->bitmap_lock);
bitmap->flush_all_requested--;
bitmap->non_flushable= 0;
- pthread_mutex_unlock(&bitmap->bitmap_lock);
- pthread_cond_broadcast(&bitmap->bitmap_cond);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_cond_broadcast(&bitmap->bitmap_cond);
DBUG_VOID_RETURN;
}
@@ -1768,7 +1770,7 @@ my_bool _ma_bitmap_find_place(MARIA_HA *info, MARIA_ROW *row,
info->bitmap_blocks.elements= ELEMENTS_RESERVED_FOR_MAIN_PART;
max_page_size= (share->block_size - PAGE_OVERHEAD_SIZE);
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
if (row->total_length <= max_page_size)
{
@@ -1830,7 +1832,7 @@ end:
res= 0;
abort:
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
DBUG_RETURN(res);
}
@@ -1874,7 +1876,7 @@ my_bool _ma_bitmap_find_new_place(MARIA_HA *info, MARIA_ROW *row,
row->extents_count= 0;
info->bitmap_blocks.elements= ELEMENTS_RESERVED_FOR_MAIN_PART;
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
/*
First allocate all blobs (so that we can find out the needed size for
@@ -1926,7 +1928,7 @@ end:
res= 0;
abort:
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
DBUG_RETURN(res);
}
@@ -2067,7 +2069,7 @@ my_bool _ma_bitmap_reset_full_page_bits(MARIA_HA *info,
uchar *data;
DBUG_ENTER("_ma_bitmap_reset_full_page_bits");
DBUG_PRINT("enter", ("page: %lu page_count: %u", (ulong) page, page_count));
- safe_mutex_assert_owner(&info->s->bitmap.bitmap_lock);
+ mysql_mutex_assert_owner(&info->s->bitmap.bitmap_lock);
bitmap_page= page - page % bitmap->pages_covered;
DBUG_ASSERT(page != bitmap_page);
@@ -2145,7 +2147,7 @@ my_bool _ma_bitmap_set_full_page_bits(MARIA_HA *info,
uchar *data;
DBUG_ENTER("_ma_bitmap_set_full_page_bits");
DBUG_PRINT("enter", ("page: %lu page_count: %u", (ulong) page, page_count));
- safe_mutex_assert_owner(&info->s->bitmap.bitmap_lock);
+ mysql_mutex_assert_owner(&info->s->bitmap.bitmap_lock);
bitmap_page= page - page % bitmap->pages_covered;
if (page == bitmap_page ||
@@ -2234,7 +2236,7 @@ void _ma_bitmap_flushable(MARIA_HA *info, int non_flushable_inc)
DBUG_VOID_RETURN;
bitmap= &share->bitmap;
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ mysql_mutex_lock(&bitmap->bitmap_lock);
if (non_flushable_inc == -1)
{
@@ -2251,11 +2253,11 @@ void _ma_bitmap_flushable(MARIA_HA *info, int non_flushable_inc)
if (unlikely(bitmap->flush_all_requested))
{
DBUG_PRINT("info", ("bitmap flushable waking up flusher"));
- pthread_cond_broadcast(&bitmap->bitmap_cond);
+ mysql_cond_broadcast(&bitmap->bitmap_cond);
}
}
DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable));
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
info->non_flushable_state= 0;
DBUG_VOID_RETURN;
}
@@ -2275,11 +2277,11 @@ void _ma_bitmap_flushable(MARIA_HA *info, int non_flushable_inc)
here.
*/
DBUG_PRINT("info", ("waiting for bitmap flusher"));
- pthread_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
+ mysql_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
}
bitmap->non_flushable++;
DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable));
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
info->non_flushable_state= 1;
DBUG_VOID_RETURN;
}
@@ -2329,7 +2331,7 @@ my_bool _ma_bitmap_release_unused(MARIA_HA *info, MARIA_BITMAP_BLOCKS *blocks)
*/
current_bitmap_value= FULL_HEAD_PAGE;
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ mysql_mutex_lock(&bitmap->bitmap_lock);
/* First handle head block */
if (block->used & BLOCKUSED_USED)
@@ -2409,17 +2411,17 @@ my_bool _ma_bitmap_release_unused(MARIA_HA *info, MARIA_BITMAP_BLOCKS *blocks)
if (unlikely(bitmap->flush_all_requested))
{
DBUG_PRINT("info", ("bitmap flushable waking up flusher"));
- pthread_cond_broadcast(&bitmap->bitmap_cond);
+ mysql_cond_broadcast(&bitmap->bitmap_cond);
}
}
}
DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable));
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
DBUG_RETURN(0);
err:
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
DBUG_RETURN(1);
}
@@ -2448,7 +2450,7 @@ my_bool _ma_bitmap_free_full_pages(MARIA_HA *info, const uchar *extents,
MARIA_FILE_BITMAP *bitmap= &info->s->bitmap;
DBUG_ENTER("_ma_bitmap_free_full_pages");
- pthread_mutex_lock(&bitmap->bitmap_lock);
+ mysql_mutex_lock(&bitmap->bitmap_lock);
for (; count--; extents+= ROW_EXTENT_SIZE)
{
pgcache_page_no_t page= uint5korr(extents);
@@ -2462,12 +2464,12 @@ my_bool _ma_bitmap_free_full_pages(MARIA_HA *info, const uchar *extents,
page_count, PAGECACHE_LOCK_WRITE, 1) ||
_ma_bitmap_reset_full_page_bits(info, bitmap, page, page_count))
{
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
DBUG_RETURN(1);
}
}
}
- pthread_mutex_unlock(&bitmap->bitmap_lock);
+ mysql_mutex_unlock(&bitmap->bitmap_lock);
DBUG_RETURN(0);
}
@@ -2497,12 +2499,12 @@ my_bool _ma_bitmap_set(MARIA_HA *info, pgcache_page_no_t page, my_bool head,
DBUG_PRINT("enter", ("page: %lu head: %d empty_space: %u",
(ulong) page, head, empty_space));
- pthread_mutex_lock(&info->s->bitmap.bitmap_lock);
+ mysql_mutex_lock(&info->s->bitmap.bitmap_lock);
bits= (head ?
_ma_free_size_to_head_pattern(bitmap, empty_space) :
free_size_to_tail_pattern(bitmap, empty_space));
res= set_page_bits(info, bitmap, page, bits);
- pthread_mutex_unlock(&info->s->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&info->s->bitmap.bitmap_lock);
DBUG_RETURN(res);
}
@@ -2619,8 +2621,8 @@ int _ma_bitmap_create_first(MARIA_SHARE *share)
*/
int4store(marker, MARIA_NO_CRC_BITMAP_PAGE);
- if (my_chsize(file, block_size - sizeof(marker),
- 0, MYF(MY_WME)) ||
+ if (mysql_file_chsize(file, block_size - sizeof(marker),
+ 0, MYF(MY_WME)) ||
my_pwrite(file, marker, sizeof(marker),
block_size - sizeof(marker),
MYF(MY_NABP | MY_WME)))
diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c
index df5a16d7efd..1c0e6b88d89 100644
--- a/storage/maria/ma_blockrec.c
+++ b/storage/maria/ma_blockrec.c
@@ -440,9 +440,9 @@ my_bool _ma_once_end_block_record(MARIA_SHARE *share)
becoming unknown to Checkpoint.
*/
if (share->now_transactional &&
- my_sync(share->bitmap.file.file, MYF(MY_WME)))
+ mysql_file_sync(share->bitmap.file.file, MYF(MY_WME)))
res= 1;
- if (my_close(share->bitmap.file.file, MYF(MY_WME)))
+ if (mysql_file_close(share->bitmap.file.file, MYF(MY_WME)))
res= 1;
/*
Trivial assignment to guard against multiple invocations
@@ -2367,10 +2367,10 @@ static my_bool extent_to_bitmap_blocks(MARIA_HA *info,
else
{
my_bool res;
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
res= _ma_bitmap_set_full_page_bits(info, &share->bitmap,
block->page, page_count);
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
if (res)
DBUG_RETURN(1);
block->used= BLOCKUSED_USED;
@@ -2532,10 +2532,10 @@ static my_bool free_full_page_range(MARIA_HA *info, pgcache_page_no_t page,
log_data, NULL))
res= 1;
}
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
if (_ma_bitmap_reset_full_page_bits(info, &share->bitmap, page, count))
res= 1;
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
DBUG_RETURN(res);
}
@@ -6518,10 +6518,10 @@ uint _ma_apply_redo_free_blocks(MARIA_HA *info,
DBUG_PRINT("info", ("page: %lu pages: %u", (long) page, page_range));
/** @todo leave bitmap lock to the bitmap code... */
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
res= _ma_bitmap_reset_full_page_bits(info, &share->bitmap, start_page,
page_range);
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
if (res)
{
_ma_mark_file_crashed(share);
@@ -6600,9 +6600,9 @@ uint _ma_apply_redo_free_head_or_tail(MARIA_HA *info, LSN lsn,
push_dynamic(&info->pinned_pages, (void*) &page_link);
}
/** @todo leave bitmap lock to the bitmap code... */
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
res= _ma_bitmap_reset_full_page_bits(info, &share->bitmap, page, 1);
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
if (res)
goto err;
DBUG_RETURN(0);
@@ -6795,10 +6795,10 @@ uint _ma_apply_redo_insert_row_blobs(MARIA_HA *info,
goto err;
}
/** @todo leave bitmap lock to the bitmap code... */
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
res= _ma_bitmap_set_full_page_bits(info, &share->bitmap, start_page,
page_range);
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
if (res)
goto err;
}
diff --git a/storage/maria/ma_cache.c b/storage/maria/ma_cache.c
index 82b5ddd8047..36dfe7cbd54 100644
--- a/storage/maria/ma_cache.c
+++ b/storage/maria/ma_cache.c
@@ -49,7 +49,7 @@ my_bool _ma_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos,
if ((my_off_t) read_length > (my_off_t) (info->pos_in_file-pos))
read_length=(uint) (info->pos_in_file-pos);
info->seek_not_done=1;
- if (my_pread(info->file,buff,read_length,pos,MYF(MY_NABP)))
+ if (mysql_file_pread(info->file,buff,read_length,pos,MYF(MY_NABP)))
DBUG_RETURN(1);
if (!(length-=read_length))
DBUG_RETURN(0);
@@ -88,7 +88,7 @@ my_bool _ma_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos,
else
{
info->seek_not_done=1;
- if ((read_length=my_pread(info->file,buff,length,pos,MYF(0))) == length)
+ if ((read_length=mysql_file_pread(info->file,buff,length,pos,MYF(0))) == length)
DBUG_RETURN(0);
}
if (!(flag & READING_HEADER) || (int) read_length == -1 ||
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index 84db7cc395a..c6cff8ecd68 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -226,7 +226,7 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info,
printf(" %9s",llstr(next_link,buff));
if (next_link >= share->state.state.data_file_length)
goto wrong;
- if (my_pread(info->dfile.file, (uchar*) buff, delete_link_length,
+ if (mysql_file_pread(info->dfile.file, (uchar*) buff, delete_link_length,
next_link,MYF(MY_NABP)))
{
if (test_flag & T_VERBOSE) puts("");
@@ -399,7 +399,7 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
FLUSH_FORCE_WRITE, FLUSH_FORCE_WRITE)))
_ma_check_print_error(param, "Failed to flush data or index file");
- size= my_seek(share->kfile.file, 0L, MY_SEEK_END, MYF(MY_THREADSAFE));
+ size= mysql_file_seek(share->kfile.file, 0L, MY_SEEK_END, MYF(MY_THREADSAFE));
if ((skr=(my_off_t) share->state.state.key_file_length) != size)
{
/* Don't give error if file generated by mariapack */
@@ -423,7 +423,7 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
llstr(share->state.state.key_file_length,buff),
llstr(share->base.max_key_file_length-1,buff));
- size= my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0));
+ size= mysql_file_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0));
skr=(my_off_t) share->state.state.data_file_length;
if (share->options & HA_OPTION_COMPRESS_RECORD)
skr+= MEMMAP_EXTRA_MARGIN;
@@ -671,7 +671,7 @@ static int chk_index_down(HA_CHECK *param, MARIA_HA *info,
{
/* purecov: begin tested */
/* Give it a chance to fit in the real file size. */
- my_off_t max_length= my_seek(info->s->kfile.file, 0L, MY_SEEK_END,
+ my_off_t max_length= mysql_file_seek(info->s->kfile.file, 0L, MY_SEEK_END,
MYF(MY_THREADSAFE));
_ma_check_print_error(param, "Invalid key block position: %s "
"key block size: %u file_length: %s",
@@ -2315,7 +2315,7 @@ static int initialize_variables_for_repair(HA_CHECK *param,
return 1;
/* calculate max_records */
- sort_info->filelength= my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0));
+ sort_info->filelength= mysql_file_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0));
if ((param->testflag & T_CREATE_MISSING_KEYS) ||
sort_info->org_data_file_type == COMPRESSED_RECORD)
sort_info->max_records= share->state.state.records;
@@ -2536,7 +2536,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
if (!rep_quick)
{
/* Get real path for data file */
- if ((new_file= my_create(fn_format(param->temp_filename,
+ if ((new_file= mysql_file_create(key_file_dfile, fn_format(param->temp_filename,
share->data_file_name.str, "",
DATA_TMP_EXT, 2+4),
0,param->tmpfile_createflag,
@@ -2681,7 +2681,8 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
{
fputs(" \r",stdout); fflush(stdout);
}
- if (my_chsize(share->kfile.file, share->state.state.key_file_length, 0, MYF(0)))
+ if (mysql_file_chsize(share->kfile.file,
+ share->state.state.key_file_length, 0, MYF(0)))
{
_ma_check_print_warning(param,
"Can't change size of indexfile, error: %d",
@@ -2740,7 +2741,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
/* Replace the actual file with the temporary file */
if (new_file >= 0)
- my_close(new_file, MYF(MY_WME));
+ mysql_file_close(new_file, MYF(MY_WME));
new_file= -1;
change_data_file_descriptor(info, -1);
if (maria_change_to_newfile(share->data_file_name.str, MARIA_NAME_DEXT,
@@ -2798,8 +2799,8 @@ err:
}
if (new_file >= 0)
{
- my_close(new_file,MYF(0));
- my_delete(param->temp_filename, MYF(MY_WME));
+ mysql_file_close(new_file,MYF(0));
+ mysql_file_delete(key_file_dfile, param->temp_filename, MYF(MY_WME));
}
maria_mark_crashed_on_repair(info);
}
@@ -3011,7 +3012,7 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
/* Get real path for index file */
fn_format(param->temp_filename,name,"", MARIA_NAME_IEXT,2+4+32);
- if ((new_file=my_create(fn_format(param->temp_filename,param->temp_filename,
+ if ((new_file=mysql_file_create(key_file_kfile, fn_format(param->temp_filename,param->temp_filename,
"", INDEX_TMP_EXT,2+4),
0,param->tmpfile_createflag,MYF(0))) <= 0)
{
@@ -3054,11 +3055,11 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
/* Put same locks as old file */
share->r_locks= share->w_locks= share->tot_locks= 0;
(void) _ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
- pthread_mutex_lock(&share->intern_lock);
- my_close(share->kfile.file, MYF(MY_WME));
+ mysql_mutex_lock(&share->intern_lock);
+ mysql_file_close(share->kfile.file, MYF(MY_WME));
share->kfile.file = -1;
- pthread_mutex_unlock(&share->intern_lock);
- my_close(new_file, MYF(MY_WME));
+ mysql_mutex_unlock(&share->intern_lock);
+ mysql_file_close(new_file, MYF(MY_WME));
if (maria_change_to_newfile(share->index_file_name.str, MARIA_NAME_IEXT,
INDEX_TMP_EXT, sync_dir) ||
_ma_open_keyfile(share))
@@ -3091,9 +3092,9 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
DBUG_RETURN(0);
err:
- my_close(new_file, MYF(MY_WME));
+ mysql_file_close(new_file, MYF(MY_WME));
err2:
- my_delete(param->temp_filename,MYF(MY_WME));
+ mysql_file_delete(key_file_dfile, param->temp_filename,MYF(MY_WME));
DBUG_RETURN(-1);
} /* maria_sort_index */
@@ -3526,16 +3527,16 @@ int maria_filecopy(HA_CHECK *param, File to,File from,my_off_t start,
buff=tmp_buff; buff_length=IO_SIZE;
}
- my_seek(from, start, MY_SEEK_SET,MYF(0));
+ mysql_file_seek(from, start, MY_SEEK_SET,MYF(0));
while (length > buff_length)
{
- if (my_read(from, buff, buff_length, MYF(MY_NABP)) ||
- my_write(to, buff, buff_length, param->myf_rw))
+ if (mysql_file_read(from, buff, buff_length, MYF(MY_NABP)) ||
+ mysql_file_write(to, buff, buff_length, param->myf_rw))
goto err;
length-= buff_length;
}
- if (my_read(from, buff, (size_t) length,MYF(MY_NABP)) ||
- my_write(to, buff, (size_t) length,param->myf_rw))
+ if (mysql_file_read(from, buff, (size_t) length,MYF(MY_NABP)) ||
+ mysql_file_write(to, buff, (size_t) length,param->myf_rw))
goto err;
if (buff != tmp_buff)
my_free(buff);
@@ -3609,7 +3610,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
if (!rep_quick)
{
/* Get real path for data file */
- if ((new_file=my_create(fn_format(param->temp_filename,
+ if ((new_file=mysql_file_create(key_file_dfile, fn_format(param->temp_filename,
share->data_file_name.str, "",
DATA_TMP_EXT, 2+4),
0,param->tmpfile_createflag,
@@ -3871,7 +3872,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
/* Replace the actual file with the temporary file */
if (new_file >= 0)
{
- my_close(new_file, MYF(MY_WME));
+ mysql_file_close(new_file, MYF(MY_WME));
new_file= -1;
}
change_data_file_descriptor(info, -1);
@@ -3929,7 +3930,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
skr=share->base.reloc*share->base.min_pack_length;
#endif
if (skr != sort_info.filelength)
- if (my_chsize(info->dfile.file, skr, 0, MYF(0)))
+ if (mysql_file_chsize(info->dfile.file, skr, 0, MYF(0)))
_ma_check_print_warning(param,
"Can't change size of datafile, error: %d",
my_errno);
@@ -3938,8 +3939,8 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
if (param->testflag & T_CALC_CHECKSUM)
share->state.state.checksum=param->glob_crc;
- if (my_chsize(share->kfile.file, share->state.state.key_file_length, 0,
- MYF(0)))
+ if (mysql_file_chsize(share->kfile.file,
+ share->state.state.key_file_length, 0, MYF(0)))
_ma_check_print_warning(param,
"Can't change size of indexfile, error: %d",
my_errno);
@@ -3979,8 +3980,8 @@ err:
}
if (new_file >= 0)
{
- my_close(new_file, MYF(0));
- my_delete(param->temp_filename, MYF(MY_WME));
+ mysql_file_close(new_file, MYF(0));
+ mysql_file_delete(key_file_dfile, param->temp_filename, MYF(MY_WME));
}
maria_mark_crashed_on_repair(info);
}
@@ -4139,8 +4140,8 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
DBUG_PRINT("info", ("is quick repair: %d", (int) rep_quick));
/* Initialize pthread structures before goto err. */
- pthread_mutex_init(&sort_info.mutex, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&sort_info.cond, 0);
+ mysql_mutex_init(key_SORT_INFO_mutex, &sort_info.mutex, MY_MUTEX_INIT_FAST);
+ mysql_cond_init(key_SORT_INFO_cond, &sort_info.cond, 0);
if (!(sort_info.key_block=
alloc_key_blocks(param, (uint) param->sort_key_blocks,
@@ -4165,7 +4166,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
if (!rep_quick)
{
/* Get real path for data file */
- if ((new_file= my_create(fn_format(param->temp_filename,
+ if ((new_file= mysql_file_create(key_file_dfile, fn_format(param->temp_filename,
share->data_file_name.str, "",
DATA_TMP_EXT,
2+4),
@@ -4310,7 +4311,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
goto err;
sort_info.got_error=0;
- pthread_mutex_lock(&sort_info.mutex);
+ mysql_mutex_lock(&sort_info.mutex);
/*
Initialize the I/O cache share for use with the read caches and, in
@@ -4358,9 +4359,9 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
#else
param->sort_buffer_length*sort_param[i].key_length/total_key_length;
#endif
- if (pthread_create(&sort_param[i].thr, &thr_attr,
- _ma_thr_find_all_keys,
- (void *) (sort_param+i)))
+ if (mysql_thread_create(key_thread_find_all_keys,
+ &sort_param[i].thr, &thr_attr,
+ _ma_thr_find_all_keys, (void *) (sort_param+i)))
{
_ma_check_print_error(param,"Cannot start a repair thread");
/* Cleanup: Detach from the share. Avoid others to be blocked. */
@@ -4376,8 +4377,8 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
/* waiting for all threads to finish */
while (sort_info.threads_running)
- pthread_cond_wait(&sort_info.cond, &sort_info.mutex);
- pthread_mutex_unlock(&sort_info.mutex);
+ mysql_cond_wait(&sort_info.cond, &sort_info.mutex);
+ mysql_mutex_unlock(&sort_info.mutex);
if ((got_error= _ma_thr_write_keys(sort_param)))
{
@@ -4415,7 +4416,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
Exchange the data file descriptor of the table, so that we use the
new file from now on.
*/
- my_close(info->dfile.file, MYF(0));
+ mysql_file_close(info->dfile.file, MYF(0));
info->dfile.file= new_file;
share->pack.header_length=(ulong) new_header_length;
}
@@ -4443,7 +4444,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
skr=share->base.reloc*share->base.min_pack_length;
#endif
if (skr != sort_info.filelength)
- if (my_chsize(info->dfile.file, skr, 0, MYF(0)))
+ if (mysql_file_chsize(info->dfile.file, skr, 0, MYF(0)))
_ma_check_print_warning(param,
"Can't change size of datafile, error: %d",
my_errno);
@@ -4451,8 +4452,8 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
if (param->testflag & T_CALC_CHECKSUM)
share->state.state.checksum=param->glob_crc;
- if (my_chsize(share->kfile.file, share->state.state.key_file_length, 0,
- MYF(0)))
+ if (mysql_file_chsize(share->kfile.file,
+ share->state.state.key_file_length, 0, MYF(0)))
_ma_check_print_warning(param,
"Can't change size of indexfile, error: %d",
my_errno);
@@ -4496,7 +4497,7 @@ err:
/* Replace the actual file with the temporary file */
if (new_file >= 0)
{
- my_close(new_file,MYF(0));
+ mysql_file_close(new_file,MYF(0));
info->dfile.file= new_file= -1;
if (maria_change_to_newfile(share->data_file_name.str, MARIA_NAME_DEXT,
DATA_TMP_EXT,
@@ -4514,8 +4515,8 @@ err:
(void)_ma_flush_table_files_before_swap(param, info);
if (new_file >= 0)
{
- my_close(new_file,MYF(0));
- my_delete(param->temp_filename, MYF(MY_WME));
+ mysql_file_close(new_file,MYF(0));
+ mysql_file_delete(key_file_dfile, param->temp_filename, MYF(MY_WME));
if (info->dfile.file == new_file)
info->dfile.file= -1;
}
@@ -4528,8 +4529,8 @@ err:
share->state.changed&= ~(STATE_NOT_OPTIMIZED_ROWS | STATE_NOT_ZEROFILLED |
STATE_NOT_MOVABLE);
- pthread_cond_destroy (&sort_info.cond);
- pthread_mutex_destroy(&sort_info.mutex);
+ mysql_cond_destroy (&sort_info.cond);
+ mysql_mutex_destroy(&sort_info.mutex);
/* If caller had disabled logging it's not up to us to re-enable it */
if (reenable_logging)
@@ -5824,10 +5825,10 @@ int maria_test_if_almost_full(MARIA_HA *info)
if (share->options & HA_OPTION_COMPRESS_RECORD)
return 0;
- return my_seek(share->kfile.file, 0L, MY_SEEK_END,
+ return mysql_file_seek(share->kfile.file, 0L, MY_SEEK_END,
MYF(MY_THREADSAFE))/10*9 >
(my_off_t) share->base.max_key_file_length ||
- my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0)) / 10 * 9 >
+ mysql_file_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0)) / 10 * 9 >
(my_off_t) share->base.max_data_file_length;
}
@@ -5921,7 +5922,7 @@ int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename)
keyseg+=u_ptr->keysegs+1;
}
- file_length=(ulonglong) my_seek(info.dfile.file, 0L, MY_SEEK_END, MYF(0));
+ file_length=(ulonglong) mysql_file_seek(info.dfile.file, 0L, MY_SEEK_END, MYF(0));
if (share.options & HA_OPTION_COMPRESS_RECORD)
share.base.records=max_records=info.state->records;
else if (share.base.min_pack_length)
@@ -6430,7 +6431,7 @@ static void restore_data_file_type(MARIA_SHARE *share)
static void change_data_file_descriptor(MARIA_HA *info, File new_file)
{
- my_close(info->dfile.file, MYF(MY_WME));
+ mysql_file_close(info->dfile.file, MYF(MY_WME));
info->dfile.file= info->s->bitmap.file.file= new_file;
_ma_bitmap_reset_cache(info->s);
}
diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c
index 7a0c89b1a15..6ced2976c29 100644
--- a/storage/maria/ma_checkpoint.c
+++ b/storage/maria/ma_checkpoint.c
@@ -41,9 +41,9 @@
/** @brief type of checkpoint currently running */
static CHECKPOINT_LEVEL checkpoint_in_progress= CHECKPOINT_NONE;
/** @brief protects checkpoint_in_progress */
-static pthread_mutex_t LOCK_checkpoint;
+static mysql_mutex_t LOCK_checkpoint;
/** @brief for killing the background checkpoint thread */
-static pthread_cond_t COND_checkpoint;
+static mysql_cond_t COND_checkpoint;
/** @brief control structure for checkpoint background thread */
static MA_SERVICE_THREAD_CONTROL checkpoint_control=
{THREAD_DEAD, FALSE, &LOCK_checkpoint, &COND_checkpoint};
@@ -109,7 +109,7 @@ int ma_checkpoint_execute(CHECKPOINT_LEVEL level, my_bool no_wait)
DBUG_ASSERT(level > CHECKPOINT_NONE);
/* look for already running checkpoints */
- pthread_mutex_lock(&LOCK_checkpoint);
+ mysql_mutex_lock(&LOCK_checkpoint);
while (checkpoint_in_progress != CHECKPOINT_NONE)
{
if (no_wait && (checkpoint_in_progress >= level))
@@ -119,18 +119,18 @@ int ma_checkpoint_execute(CHECKPOINT_LEVEL level, my_bool no_wait)
smarter to flush pages instead of waiting here while the other thread
finishes its checkpoint).
*/
- pthread_mutex_unlock(&LOCK_checkpoint);
+ mysql_mutex_unlock(&LOCK_checkpoint);
goto end;
}
- pthread_cond_wait(&COND_checkpoint, &LOCK_checkpoint);
+ mysql_cond_wait(&COND_checkpoint, &LOCK_checkpoint);
}
checkpoint_in_progress= level;
- pthread_mutex_unlock(&LOCK_checkpoint);
+ mysql_mutex_unlock(&LOCK_checkpoint);
/* from then on, we are sure to be and stay the only checkpointer */
result= really_execute_checkpoint();
- pthread_cond_broadcast(&COND_checkpoint);
+ mysql_cond_broadcast(&COND_checkpoint);
end:
DBUG_RETURN(result);
}
@@ -291,11 +291,11 @@ err:
end:
for (i= 0; i < (sizeof(record_pieces)/sizeof(record_pieces[0])); i++)
my_free(record_pieces[i].str);
- pthread_mutex_lock(&LOCK_checkpoint);
+ mysql_mutex_lock(&LOCK_checkpoint);
checkpoint_in_progress= CHECKPOINT_NONE;
checkpoints_total++;
checkpoints_ok_total+= !error;
- pthread_mutex_unlock(&LOCK_checkpoint);
+ mysql_mutex_unlock(&LOCK_checkpoint);
DBUG_RETURN(error);
}
@@ -331,8 +331,9 @@ int ma_checkpoint_init(ulong interval)
else if (interval > 0)
{
compile_time_assert(sizeof(void *) >= sizeof(ulong));
- if (!(res= pthread_create(&th, NULL, ma_checkpoint_background,
- (void *)interval)))
+ if (!(res= mysql_thread_create(key_thread_checkpoint,
+ &th, NULL, ma_checkpoint_background,
+ (void *)interval)))
{
/* thread lives, will have to be killed */
checkpoint_control.status= THREAD_RUNNING;
@@ -355,7 +356,7 @@ static void flush_all_tables(int what_to_flush)
{
int res= 0;
LIST *pos; /**< to iterate over open tables */
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
for (pos= maria_open_list; pos; pos= pos->next)
{
MARIA_HA *info= (MARIA_HA*)pos->data;
@@ -382,7 +383,7 @@ static void flush_all_tables(int what_to_flush)
}
DBUG_ASSERT(res == 0);
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
}
#endif
@@ -745,7 +746,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
LINT_INIT(state_copies_horizon);
/* let's make a list of distinct shares */
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
for (nb= 0, pos= maria_open_list; pos; pos= pos->next)
{
MARIA_HA *info= (MARIA_HA*)pos->data;
@@ -794,7 +795,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
}
DBUG_ASSERT(i == nb);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
DBUG_PRINT("info",("found %u table shares", nb));
str->length=
@@ -935,8 +936,8 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
intern_lock in the middle of manipulating the table. Serializing us and
maria_close() should help avoid problems.
*/
- pthread_mutex_lock(&share->close_lock);
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->close_lock);
+ mysql_mutex_lock(&share->intern_lock);
/*
Tables in a normal state have their two file descriptors open.
In some rare cases like REPAIR, some descriptor may be closed or even
@@ -1032,7 +1033,7 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
otherwise this would deadlock with allocate_and_write_block_record()
calling _ma_set_share_data_file_length()
*/
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
if (!ignore_share)
{
@@ -1064,16 +1065,16 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
and so this assertion should be true:
*/
DBUG_ASSERT(ignore_share);
- pthread_mutex_destroy(&share->intern_lock);
- pthread_mutex_unlock(&share->close_lock);
- pthread_mutex_destroy(&share->close_lock);
+ mysql_mutex_destroy(&share->intern_lock);
+ mysql_mutex_unlock(&share->close_lock);
+ mysql_mutex_destroy(&share->close_lock);
my_free(share);
}
else
{
/* share goes back to normal state */
share->in_checkpoint= 0;
- pthread_mutex_unlock(&share->close_lock);
+ mysql_mutex_unlock(&share->close_lock);
}
/*
@@ -1146,8 +1147,8 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
per second, so if you have touched 1000 files it's 7 seconds).
*/
sync_error|=
- my_sync(dfile.file, MYF(MY_WME | MY_IGNORE_BADFD)) |
- my_sync(kfile.file, MYF(MY_WME | MY_IGNORE_BADFD));
+ mysql_file_sync(dfile.file, MYF(MY_WME | MY_IGNORE_BADFD)) |
+ mysql_file_sync(kfile.file, MYF(MY_WME | MY_IGNORE_BADFD));
/*
in case of error, we continue because writing other tables to disk is
still useful.
@@ -1172,14 +1173,14 @@ err:
if (unlikely(unmark_tables))
{
/* maria_close() uses THR_LOCK_maria from start to end */
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
for (i= 0; i < nb; i++)
{
MARIA_SHARE *share= distinct_shares[i];
if (share->in_checkpoint & MARIA_CHECKPOINT_SHOULD_FREE_ME)
{
/* maria_close() left us to free the share */
- pthread_mutex_destroy(&share->intern_lock);
+ mysql_mutex_destroy(&share->intern_lock);
my_free(share);
}
else
@@ -1188,7 +1189,7 @@ err:
share->in_checkpoint= 0;
}
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
}
my_free(distinct_shares);
my_free(state_copies);
diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c
index 0a36e52e4ae..88d63252693 100644
--- a/storage/maria/ma_close.c
+++ b/storage/maria/ma_close.c
@@ -35,7 +35,7 @@ int maria_close(register MARIA_HA *info)
/* Check that we have unlocked key delete-links properly */
DBUG_ASSERT(info->key_del_used == 0);
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
if (info->lock_type == F_EXTRA_LCK)
info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */
@@ -47,8 +47,8 @@ int maria_close(register MARIA_HA *info)
if (maria_lock_database(info,F_UNLCK))
error=my_errno;
}
- pthread_mutex_lock(&share->close_lock);
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->close_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (share->options & HA_OPTION_READ_ONLY_DATA)
{
@@ -108,19 +108,19 @@ int maria_close(register MARIA_HA *info)
File must be synced as it is going out of the maria_open_list and so
becoming unknown to future Checkpoints.
*/
- if (share->now_transactional && my_sync(share->kfile.file, MYF(MY_WME)))
+ if (share->now_transactional && mysql_file_sync(share->kfile.file, MYF(MY_WME)))
error= my_errno;
- if (my_close(share->kfile.file, MYF(0)))
+ if (mysql_file_close(share->kfile.file, MYF(0)))
error= my_errno;
}
thr_lock_delete(&share->lock);
- (void) pthread_mutex_destroy(&share->key_del_lock);
+ (void) mysql_mutex_destroy(&share->key_del_lock);
{
int i,keys;
keys = share->state.header.keys;
- rwlock_destroy(&share->mmap_lock);
+ mysql_rwlock_destroy(&share->mmap_lock);
for(i=0; i<keys; i++) {
- rwlock_destroy(&share->keyinfo[i].root_lock);
+ mysql_rwlock_destroy(&share->keyinfo[i].root_lock);
}
}
DBUG_ASSERT(share->now_transactional == share->base.born_transactional);
@@ -136,9 +136,9 @@ int maria_close(register MARIA_HA *info)
We have to unlock share->intern_lock then lock it after
LOCK_trn_list (trnman_lock()) to avoid dead locks.
*/
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
_ma_remove_not_visible_states_with_lock(share, TRUE);
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (share->in_checkpoint & MARIA_CHECKPOINT_LOOKS_AT_ME)
{
@@ -168,14 +168,14 @@ int maria_close(register MARIA_HA *info)
share->state_history= 0;
}
}
- pthread_mutex_unlock(&THR_LOCK_maria);
- pthread_mutex_unlock(&share->intern_lock);
- pthread_mutex_unlock(&share->close_lock);
+ mysql_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->close_lock);
if (share_can_be_freed)
{
- (void) pthread_mutex_destroy(&share->intern_lock);
- (void) pthread_mutex_destroy(&share->close_lock);
- (void) pthread_cond_destroy(&share->key_del_cond);
+ (void) mysql_mutex_destroy(&share->intern_lock);
+ (void) mysql_mutex_destroy(&share->close_lock);
+ (void) mysql_cond_destroy(&share->key_del_cond);
my_free(share);
/*
If share cannot be freed, it's because checkpoint has previously
@@ -190,7 +190,7 @@ int maria_close(register MARIA_HA *info)
This is outside of mutex so would confuse a concurrent
Checkpoint. Fortunately in BLOCK_RECORD we close earlier under mutex.
*/
- if (my_close(info->dfile.file, MYF(0)))
+ if (mysql_file_close(info->dfile.file, MYF(0)))
error= my_errno;
}
diff --git a/storage/maria/ma_control_file.c b/storage/maria/ma_control_file.c
index 6f9018885e9..2fa3e6ed18e 100644
--- a/storage/maria/ma_control_file.c
+++ b/storage/maria/ma_control_file.c
@@ -148,9 +148,8 @@ static CONTROL_FILE_ERROR create_control_file(const char *name,
uchar buffer[CF_CREATE_TIME_TOTAL_SIZE];
DBUG_ENTER("maria_create_control_file");
- if ((control_file_fd= my_create(name, 0,
- open_flags,
- MYF(MY_SYNC_DIR | MY_WME))) < 0)
+ if ((control_file_fd= mysql_file_create(key_file_control, name, 0,
+ open_flags, MYF(MY_SYNC_DIR | MY_WME))) < 0)
DBUG_RETURN(CONTROL_FILE_UNKNOWN_ERROR);
/* Reset variables, as we are creating the file */
@@ -318,7 +317,8 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
/* Otherwise, file exists */
- if ((control_file_fd= my_open(name, open_flags, MYF(MY_WME))) < 0)
+ if ((control_file_fd= mysql_file_open(key_file_control, name,
+ open_flags, MYF(MY_WME))) < 0)
{
errmsg= "Can't open file";
goto err;
@@ -330,7 +330,7 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
goto err;
}
- file_size= my_seek(control_file_fd, 0, SEEK_END, MYF(MY_WME));
+ file_size= mysql_file_seek(control_file_fd, 0, SEEK_END, MYF(MY_WME));
if (file_size == MY_FILEPOS_ERROR)
{
errmsg= "Can't read size";
@@ -362,7 +362,7 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
goto err;
}
- if (my_pread(control_file_fd, buffer, (size_t)file_size, 0, MYF(MY_FNABP)))
+ if (mysql_file_pread(control_file_fd, buffer, (size_t)file_size, 0, MYF(MY_FNABP)))
{
errmsg= "Can't read file";
goto err;
@@ -544,7 +544,7 @@ int ma_control_file_write_and_force(LSN last_checkpoint_lsn_arg,
if (my_pwrite(control_file_fd, buffer, cf_changeable_size,
cf_create_time_size, MYF(MY_FNABP | MY_WME)) ||
- (!no_need_sync && my_sync(control_file_fd, MYF(MY_WME))))
+ (!no_need_sync && mysql_file_sync(control_file_fd, MYF(MY_WME))))
DBUG_RETURN(1);
last_checkpoint_lsn= last_checkpoint_lsn_arg;
@@ -577,9 +577,9 @@ int ma_control_file_end(void)
MYF(MY_SEEK_NOT_DONE | MY_FORCE_LOCK));
#endif
- close_error= my_close(control_file_fd, MYF(MY_WME));
+ close_error= mysql_file_close(control_file_fd, MYF(MY_WME));
/*
- As my_close() frees structures even if close() fails, we do the same,
+ As mysql_file_close() frees structures even if close() fails, we do the same,
i.e. we mark the file as closed in all cases.
*/
control_file_fd= -1;
diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c
index d544e019932..467c977da07 100644
--- a/storage/maria/ma_create.c
+++ b/storage/maria/ma_create.c
@@ -774,7 +774,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
if (! (flags & HA_DONT_TOUCH_DATA))
share.state.create_time= time((time_t*) 0);
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
/*
NOTE: For test_if_reopen() we need a real path name. Hence we need
@@ -848,8 +848,9 @@ int maria_create(const char *name, enum data_file_type datafile_type,
goto err;
}
- if ((file= my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
- MYF(MY_WME|create_flag))) < 0)
+ if ((file= mysql_file_create_with_symlink(key_file_kfile, linkname_ptr,
+ filename, 0, create_mode,
+ MYF(MY_WME|create_flag))) < 0)
goto err;
errpos=1;
@@ -860,7 +861,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
goto err;
DBUG_PRINT("info", ("base_pos: %d base_info_size: %d",
base_pos, MARIA_BASE_INFO_SIZE));
- DBUG_ASSERT(my_tell(file,MYF(0)) == base_pos+ MARIA_BASE_INFO_SIZE);
+ DBUG_ASSERT(mysql_file_tell(file,MYF(0)) == base_pos+ MARIA_BASE_INFO_SIZE);
/* Write key and keyseg definitions */
DBUG_PRINT("info", ("write key and keyseg definitions"));
@@ -984,7 +985,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
if (_ma_column_nr_write(file, column_array, columns))
goto err;
- if ((kfile_size_before_extension= my_tell(file,MYF(0))) == MY_FILEPOS_ERROR)
+ if ((kfile_size_before_extension= mysql_file_tell(file,MYF(0))) == MY_FILEPOS_ERROR)
goto err;
#ifndef DBUG_OFF
if (kfile_size_before_extension != info_length)
@@ -1008,7 +1009,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
/* we are needing maybe 64 kB, so don't use the stack */
log_data= my_malloc(log_array[TRANSLOG_INTERNAL_PARTS + 1].length, MYF(0));
if ((log_data == NULL) ||
- my_pread(file, 1 + 2 + 2 + log_data,
+ mysql_file_pread(file, 1 + 2 + 2 + log_data,
(size_t) kfile_size_before_extension, 0, MYF(MY_NABP)))
goto err;
/*
@@ -1124,8 +1125,9 @@ int maria_create(const char *name, enum data_file_type datafile_type,
create_flag= (flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
if ((dfile=
- my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
- MYF(MY_WME | create_flag | sync_dir))) < 0)
+ mysql_file_create_with_symlink(key_file_dfile, linkname_ptr,
+ filename, 0, create_mode,
+ MYF(MY_WME | create_flag | sync_dir))) < 0)
goto err;
errpos=3;
@@ -1136,50 +1138,53 @@ int maria_create(const char *name, enum data_file_type datafile_type,
/* Enlarge files */
DBUG_PRINT("info", ("enlarge to keystart: %lu",
(ulong) share.base.keystart));
- if (my_chsize(file,(ulong) share.base.keystart,0,MYF(0)))
+ if (mysql_file_chsize(file,(ulong) share.base.keystart,0,MYF(0)))
goto err;
- if (sync_dir && my_sync(file, MYF(0)))
+ if (sync_dir && mysql_file_sync(file, MYF(0)))
goto err;
if (! (flags & HA_DONT_TOUCH_DATA))
{
#ifdef USE_RELOC
- if (my_chsize(dfile,share.base.min_pack_length*ci->reloc_rows,0,MYF(0)))
+ if (mysql_file_chsize(key_file_dfile, dfile,
+ share.base.min_pack_length*ci->reloc_rows,0,MYF(0)))
goto err;
#endif
- if (sync_dir && my_sync(dfile, MYF(0)))
+ if (sync_dir && mysql_file_sync(dfile, MYF(0)))
goto err;
- if (my_close(dfile,MYF(0)))
+ if (mysql_file_close(dfile,MYF(0)))
goto err;
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
res= 0;
my_free((char*) rec_per_key_part);
errpos=0;
- if (my_close(file,MYF(0)))
+ if (mysql_file_close(file,MYF(0)))
res= my_errno;
DBUG_RETURN(res);
err:
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
err_no_lock:
save_errno=my_errno;
switch (errpos) {
case 3:
- my_close(dfile, MYF(0));
+ mysql_file_close(dfile, MYF(0));
/* fall through */
case 2:
if (! (flags & HA_DONT_TOUCH_DATA))
- my_delete_with_symlink(fn_format(filename,name,"",MARIA_NAME_DEXT,
+ mysql_file_delete_with_symlink(key_file_dfile,
+ fn_format(filename,name,"",MARIA_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT),
sync_dir);
/* fall through */
case 1:
- my_close(file, MYF(0));
+ mysql_file_close(file, MYF(0));
if (! (flags & HA_DONT_TOUCH_DATA))
- my_delete_with_symlink(fn_format(filename,name,"",MARIA_NAME_IEXT,
+ mysql_file_delete_with_symlink(key_file_kfile,
+ fn_format(filename,name,"",MARIA_NAME_IEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT),
sync_dir);
}
@@ -1320,10 +1325,10 @@ int _ma_update_state_lsns(MARIA_SHARE *share, LSN lsn, TrID create_trid,
my_bool do_sync, my_bool update_create_rename_lsn)
{
int res;
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
res= _ma_update_state_lsns_sub(share, lsn, create_trid, do_sync,
update_create_rename_lsn);
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
return res;
}
@@ -1412,7 +1417,7 @@ int _ma_update_state_lsns_sub(MARIA_SHARE *share, LSN lsn, TrID create_trid,
my_pwrite(file, trid_buff, sizeof(trid_buff),
sizeof(share->state.header) +
MARIA_FILE_CREATE_TRID_OFFSET, MYF(MY_NABP)) ||
- (do_sync && my_sync(file, MYF(0))));
+ (do_sync && mysql_file_sync(file, MYF(0))));
}
#if (_MSC_VER == 1310)
#pragma optimize("",on)
diff --git a/storage/maria/ma_dbug.c b/storage/maria/ma_dbug.c
index c8c928dd097..ed6f79ddf92 100644
--- a/storage/maria/ma_dbug.c
+++ b/storage/maria/ma_dbug.c
@@ -179,7 +179,7 @@ my_bool _ma_check_table_is_closed(const char *name, const char *where)
DBUG_ENTER("_ma_check_table_is_closed");
(void) fn_format(filename,name,"",MARIA_NAME_IEXT,4+16+32);
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
for (pos=maria_open_list ; pos ; pos=pos->next)
{
MARIA_HA *info=(MARIA_HA*) pos->data;
@@ -190,12 +190,12 @@ my_bool _ma_check_table_is_closed(const char *name, const char *where)
{
fprintf(stderr,"Warning: Table: %s is open on %s\n", name,where);
DBUG_PRINT("warning",("Table: %s is open on %s", name,where));
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
DBUG_RETURN(1);
}
}
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
DBUG_RETURN(0);
}
#endif /* EXTRA_DEBUG */
diff --git a/storage/maria/ma_delete_all.c b/storage/maria/ma_delete_all.c
index 940d4d00987..3716e679bb1 100644
--- a/storage/maria/ma_delete_all.c
+++ b/storage/maria/ma_delete_all.c
@@ -98,8 +98,8 @@ int maria_delete_all_rows(MARIA_HA *info)
if (_ma_flush_table_files(info, MARIA_FLUSH_DATA|MARIA_FLUSH_INDEX,
FLUSH_IGNORE_CHANGED, FLUSH_IGNORE_CHANGED) ||
- my_chsize(info->dfile.file, 0, 0, MYF(MY_WME)) ||
- my_chsize(share->kfile.file, share->base.keystart, 0, MYF(MY_WME)))
+ mysql_file_chsize(info->dfile.file, 0, 0, MYF(MY_WME)) ||
+ mysql_file_chsize(share->kfile.file, share->base.keystart, 0, MYF(MY_WME)))
goto err;
if (_ma_initialize_data_file(share, info->dfile.file))
diff --git a/storage/maria/ma_delete_table.c b/storage/maria/ma_delete_table.c
index 0237bb884c5..f8b7eefb4ad 100644
--- a/storage/maria/ma_delete_table.c
+++ b/storage/maria/ma_delete_table.c
@@ -94,14 +94,11 @@ int maria_delete_table(const char *name)
}
fn_format(from,name,"",MARIA_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
- if (my_delete_with_symlink(from, MYF(MY_WME | sync_dir)))
+ if (mysql_file_delete_with_symlink(key_file_kfile, from,
+ MYF(MY_WME | sync_dir)))
DBUG_RETURN(my_errno);
fn_format(from,name,"",MARIA_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
-#ifdef USE_RAID
- if (raid_type)
- DBUG_RETURN(my_raid_delete(from, raid_chunks, MYF(MY_WME | sync_dir)) ?
- my_errno : 0);
-#endif
- DBUG_RETURN(my_delete_with_symlink(from, MYF(MY_WME | sync_dir)) ?
+ DBUG_RETURN(mysql_file_delete_with_symlink(key_file_dfile,
+ from, MYF(MY_WME | sync_dir)) ?
my_errno : 0);
}
diff --git a/storage/maria/ma_dynrec.c b/storage/maria/ma_dynrec.c
index 7fe0a97fa46..60423507792 100644
--- a/storage/maria/ma_dynrec.c
+++ b/storage/maria/ma_dynrec.c
@@ -135,7 +135,7 @@ size_t _ma_mmap_pread(MARIA_HA *info, uchar *Buffer,
{
DBUG_PRINT("info", ("maria_read with mmap %d\n", info->dfile.file));
if (info->s->lock_key_trees)
- rw_rdlock(&info->s->mmap_lock);
+ mysql_rwlock_rdlock(&info->s->mmap_lock);
/*
The following test may fail in the following cases:
@@ -148,14 +148,14 @@ size_t _ma_mmap_pread(MARIA_HA *info, uchar *Buffer,
{
memcpy(Buffer, info->s->file_map + offset, Count);
if (info->s->lock_key_trees)
- rw_unlock(&info->s->mmap_lock);
+ mysql_rwlock_unlock(&info->s->mmap_lock);
return 0;
}
else
{
if (info->s->lock_key_trees)
- rw_unlock(&info->s->mmap_lock);
- return my_pread(info->dfile.file, Buffer, Count, offset, MyFlags);
+ mysql_rwlock_unlock(&info->s->mmap_lock);
+ return mysql_file_pread(info->dfile.file, Buffer, Count, offset, MyFlags);
}
}
@@ -165,7 +165,7 @@ size_t _ma_mmap_pread(MARIA_HA *info, uchar *Buffer,
size_t _ma_nommap_pread(MARIA_HA *info, uchar *Buffer,
size_t Count, my_off_t offset, myf MyFlags)
{
- return my_pread(info->dfile.file, Buffer, Count, offset, MyFlags);
+ return mysql_file_pread(info->dfile.file, Buffer, Count, offset, MyFlags);
}
@@ -190,7 +190,7 @@ size_t _ma_mmap_pwrite(MARIA_HA *info, const uchar *Buffer,
{
DBUG_PRINT("info", ("maria_write with mmap %d\n", info->dfile.file));
if (info->s->lock_key_trees)
- rw_rdlock(&info->s->mmap_lock);
+ mysql_rwlock_rdlock(&info->s->mmap_lock);
/*
The following test may fail in the following cases:
@@ -203,14 +203,14 @@ size_t _ma_mmap_pwrite(MARIA_HA *info, const uchar *Buffer,
{
memcpy(info->s->file_map + offset, Buffer, Count);
if (info->s->lock_key_trees)
- rw_unlock(&info->s->mmap_lock);
+ mysql_rwlock_unlock(&info->s->mmap_lock);
return 0;
}
else
{
info->s->nonmmaped_inserts++;
if (info->s->lock_key_trees)
- rw_unlock(&info->s->mmap_lock);
+ mysql_rwlock_unlock(&info->s->mmap_lock);
return my_pwrite(info->dfile.file, Buffer, Count, offset, MyFlags);
}
@@ -1682,7 +1682,7 @@ static my_bool _ma_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
while (length > IO_SIZE*2)
{
- if (my_pread(file,temp_buff,next_length,filepos, MYF(MY_NABP)) ||
+ if (mysql_file_pread(file,temp_buff,next_length,filepos, MYF(MY_NABP)) ||
memcmp(buff, temp_buff, next_length))
goto err;
filepos+=next_length;
@@ -1690,7 +1690,7 @@ static my_bool _ma_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
length-= next_length;
next_length=IO_SIZE*2;
}
- if (my_pread(file,temp_buff,length,filepos,MYF(MY_NABP)))
+ if (mysql_file_pread(file,temp_buff,length,filepos,MYF(MY_NABP)))
goto err;
DBUG_RETURN(memcmp(buff, temp_buff, length) != 0);
err:
@@ -1864,7 +1864,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
flush_io_cache(&info->rec_cache))
goto err;
/* VOID(my_seek(info->dfile.file, filepos, MY_SEEK_SET, MYF(0))); */
- if (my_read(info->dfile.file, to, block_info.data_len, MYF(MY_NABP)))
+ if (mysql_file_read(info->dfile.file, to, block_info.data_len, MYF(MY_NABP)))
{
if (my_errno == HA_ERR_FILE_TOO_SHORT)
my_errno= HA_ERR_WRONG_IN_RECORD; /* Unexpected end of file */
@@ -1915,8 +1915,8 @@ uint _ma_get_block_info(MARIA_BLOCK_INFO *info, File file, my_off_t filepos)
pointer set to the end of the header after this function.
my_pread() may leave the file pointer untouched.
*/
- my_seek(file,filepos,MY_SEEK_SET,MYF(0));
- if (my_read(file, header, sizeof(info->header),MYF(0)) !=
+ mysql_file_seek(file,filepos,MY_SEEK_SET,MYF(0));
+ if (mysql_file_read(file, header, sizeof(info->header),MYF(0)) !=
sizeof(info->header))
goto err;
}
diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c
index 7a30b613ea5..d5c698e2087 100644
--- a/storage/maria/ma_extra.c
+++ b/storage/maria/ma_extra.c
@@ -80,17 +80,17 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if ((share->options & HA_OPTION_COMPRESS_RECORD))
{
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (_ma_memmap_file(info))
{
/* We don't nead MADV_SEQUENTIAL if small file */
madvise((char*) share->file_map, share->state.state.data_file_length,
share->state.state.data_file_length <= RECORD_CACHE_SIZE*16 ?
MADV_RANDOM : MADV_SEQUENTIAL);
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
break;
}
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
}
#endif
if (info->opt_flag & WRITE_CACHE_USED)
@@ -232,10 +232,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
break;
case HA_EXTRA_NO_KEYS:
/* we're going to modify pieces of the state, stall Checkpoint */
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (info->lock_type == F_UNLCK)
{
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
error= 1; /* Not possibly if not lock */
break;
}
@@ -276,7 +276,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO);
}
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
break;
case HA_EXTRA_FORCE_REOPEN:
/*
@@ -290,19 +290,19 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
FLUSH_FORCE_WRITE, FLUSH_FORCE_WRITE);
if (!error && share->changed)
{
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (!(error= _ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET|
MA_STATE_INFO_WRITE_FULL_INFO)))
share->changed= 0;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
}
- pthread_mutex_lock(&THR_LOCK_maria);
- pthread_mutex_lock(&share->intern_lock); /* protect against Checkpoint */
+ mysql_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&share->intern_lock); /* protect against Checkpoint */
/* this makes the share not be re-used next time the table is opened */
share->last_version= 0L; /* Impossible version */
- pthread_mutex_unlock(&share->intern_lock);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&THR_LOCK_maria);
break;
case HA_EXTRA_PREPARE_FOR_DROP:
/* Signals about intent to delete this table */
@@ -315,7 +315,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
{
my_bool do_flush= test(function != HA_EXTRA_PREPARE_FOR_DROP);
enum flush_type type;
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
/*
This share, to have last_version=0, needs to save all its data/index
blocks to disk if this is not for a DROP TABLE. Otherwise they would be
@@ -336,7 +336,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
call it as in that case the automatic repair on open will add
the missing index entries
*/
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (share->kfile.file >= 0 && function != HA_EXTRA_PREPARE_FOR_DROP)
_ma_decrement_open_count(info);
if (info->trn)
@@ -368,7 +368,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
_ma_state_info_write(share,
MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET |
MA_STATE_INFO_WRITE_FULL_INFO)) ||
- my_sync(share->kfile.file, MYF(0)))
+ mysql_file_sync(share->kfile.file, MYF(0)))
error= my_errno;
else
share->changed= 0;
@@ -382,23 +382,23 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (share->data_file_type == BLOCK_RECORD &&
share->bitmap.file.file >= 0)
{
- if (do_flush && my_sync(share->bitmap.file.file, MYF(0)))
+ if (do_flush && mysql_file_sync(share->bitmap.file.file, MYF(0)))
error= my_errno;
}
/* For protection against Checkpoint, we set under intern_lock: */
share->last_version= 0L; /* Impossible version */
- pthread_mutex_unlock(&share->intern_lock);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&THR_LOCK_maria);
break;
}
case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE:
if (info->trn)
{
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
_ma_remove_table_from_trnman(share, info->trn);
/* Ensure we don't point to the deleted data in trn */
info->state= info->state_start= &share->state.state;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
}
break;
case HA_EXTRA_FLUSH:
@@ -442,7 +442,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
#ifdef HAVE_MMAP
if (block_records)
break; /* Not supported */
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
/*
Memory map the data file if it is not already mapped. It is safe
to memory map a file while other threads are using file I/O on it.
@@ -463,13 +463,13 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
share->file_write= _ma_mmap_pwrite;
}
}
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
#endif
break;
case HA_EXTRA_MARK_AS_LOG_TABLE:
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
share->is_log_table= TRUE;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
break;
case HA_EXTRA_KEY_CACHE:
case HA_EXTRA_NO_KEY_CACHE:
@@ -564,8 +564,8 @@ int maria_reset(MARIA_HA *info)
int _ma_sync_table_files(const MARIA_HA *info)
{
- return (my_sync(info->dfile.file, MYF(MY_WME)) ||
- my_sync(info->s->kfile.file, MYF(MY_WME)));
+ return (mysql_file_sync(info->dfile.file, MYF(MY_WME)) ||
+ mysql_file_sync(info->s->kfile.file, MYF(MY_WME)));
}
@@ -614,9 +614,9 @@ int _ma_flush_table_files(MARIA_HA *info, uint flush_data_or_index,
}
else
{
- pthread_mutex_lock(&share->bitmap.bitmap_lock);
+ mysql_mutex_lock(&share->bitmap.bitmap_lock);
share->bitmap.changed= 0;
- pthread_mutex_unlock(&share->bitmap.bitmap_lock);
+ mysql_mutex_unlock(&share->bitmap.bitmap_lock);
}
if (flush_pagecache_blocks(share->pagecache, &info->dfile,
flush_type_for_data))
diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c
index 6392da31298..361ee41f2c8 100644
--- a/storage/maria/ma_info.c
+++ b/storage/maria/ma_info.c
@@ -42,10 +42,10 @@ int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag)
DBUG_RETURN(0); /* Compatible with ISAM */
if (!(flag & HA_STATUS_NO_LOCK))
{
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
_ma_readinfo(info,F_RDLCK,0);
fast_ma_writeinfo(info);
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
}
if (flag & HA_STATUS_VARIABLE)
{
diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c
index af35bf37865..c3d52fc64e0 100644
--- a/storage/maria/ma_init.c
+++ b/storage/maria/ma_init.c
@@ -66,7 +66,7 @@ int maria_init(void)
if (!maria_inited)
{
maria_inited= TRUE;
- pthread_mutex_init(&THR_LOCK_maria,MY_MUTEX_INIT_SLOW);
+ mysql_mutex_init(key_THR_LOCK_maria, &THR_LOCK_maria, MY_MUTEX_INIT_SLOW);
_ma_init_block_record_data();
trnman_end_trans_hook= _ma_trnman_end_trans_hook;
maria_create_trn_hook= dummy_maria_create_trn_hook;
@@ -108,7 +108,7 @@ void maria_end(void)
end_pagecache(maria_log_pagecache, TRUE);
end_pagecache(maria_pagecache, TRUE);
ma_control_file_end();
- pthread_mutex_destroy(&THR_LOCK_maria);
+ mysql_mutex_destroy(&THR_LOCK_maria);
my_hash_free(&maria_stored_state);
}
}
@@ -166,7 +166,8 @@ my_bool maria_upgrade()
char old_logname[FN_REFLEN], new_logname[FN_REFLEN];
fn_format(old_logname, file, maria_data_root, "", MYF(0));
fn_format(new_logname, file+1, maria_data_root, "", MYF(0));
- if (my_rename(old_logname, new_logname, MYF(MY_WME)))
+ if (mysql_file_rename(key_file_translog, old_logname,
+ new_logname, MYF(MY_WME)))
{
my_dirend(dir);
DBUG_RETURN(1);
@@ -176,7 +177,7 @@ my_bool maria_upgrade()
my_dirend(dir);
fn_format(new_name, CONTROL_FILE_BASE_NAME, maria_data_root, "", MYF(0));
- if (my_rename(name, new_name, MYF(MY_WME)))
+ if (mysql_file_rename(key_file_control, name, new_name, MYF(MY_WME)))
DBUG_RETURN(1);
}
DBUG_RETURN(0);
diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c
index abd7253e77a..bc85ad025ff 100644
--- a/storage/maria/ma_key_recover.c
+++ b/storage/maria/ma_key_recover.c
@@ -131,7 +131,7 @@ my_bool _ma_write_clr(MARIA_HA *info, LSN undo_lsn,
(first intern_lock then transactional log buffer lock)
*/
if (undo_type == LOGREC_UNDO_BULK_INSERT)
- pthread_mutex_lock(&info->s->intern_lock);
+ mysql_mutex_lock(&info->s->intern_lock);
res= translog_write_record(res_lsn, LOGREC_CLR_END,
info->trn, info,
@@ -140,7 +140,7 @@ my_bool _ma_write_clr(MARIA_HA *info, LSN undo_lsn,
TRANSLOG_INTERNAL_PARTS + 1, log_array,
log_data + LSN_STORE_SIZE, &msg);
if (undo_type == LOGREC_UNDO_BULK_INSERT)
- pthread_mutex_unlock(&info->s->intern_lock);
+ mysql_mutex_unlock(&info->s->intern_lock);
DBUG_RETURN(res);
}
@@ -190,7 +190,7 @@ my_bool write_hook_for_clr_end(enum translog_record_type type
case LOGREC_UNDO_KEY_DELETE:
break;
case LOGREC_UNDO_BULK_INSERT:
- safe_mutex_assert_owner(&share->intern_lock);
+ mysql_mutex_assert_owner(&share->intern_lock);
error= (maria_enable_indexes(tbl_info) ||
/* we enabled indices, need '2' below */
_ma_state_info_write(share,
@@ -1388,19 +1388,19 @@ my_bool _ma_lock_key_del(MARIA_HA *info, my_bool insert_at_end)
*/
if (info->key_del_used != 1)
{
- pthread_mutex_lock(&share->key_del_lock);
+ mysql_mutex_lock(&share->key_del_lock);
if (share->state.key_del == HA_OFFSET_ERROR && insert_at_end)
{
- pthread_mutex_unlock(&share->key_del_lock);
+ mysql_mutex_unlock(&share->key_del_lock);
info->key_del_used= 2; /* insert-with-append */
return 1;
}
while (share->key_del_used)
- pthread_cond_wait(&share->key_del_cond, &share->key_del_lock);
+ mysql_cond_wait(&share->key_del_cond, &share->key_del_lock);
info->key_del_used= 1;
share->key_del_used= 1;
share->key_del_current= share->state.key_del;
- pthread_mutex_unlock(&share->key_del_lock);
+ mysql_mutex_unlock(&share->key_del_lock);
}
return share->key_del_current == HA_OFFSET_ERROR;
}
@@ -1420,11 +1420,11 @@ void _ma_unlock_key_del(MARIA_HA *info)
if (info->key_del_used == 1) /* Ignore insert-with-append */
{
MARIA_SHARE *share= info->s;
- pthread_mutex_lock(&share->key_del_lock);
+ mysql_mutex_lock(&share->key_del_lock);
share->key_del_used= 0;
share->state.key_del= share->key_del_current;
- pthread_mutex_unlock(&share->key_del_lock);
- pthread_cond_signal(&share->key_del_cond);
+ mysql_mutex_unlock(&share->key_del_lock);
+ mysql_cond_signal(&share->key_del_cond);
}
info->key_del_used= 0;
}
diff --git a/storage/maria/ma_keycache.c b/storage/maria/ma_keycache.c
index 39fc7d421ae..ef893d076bd 100644
--- a/storage/maria/ma_keycache.c
+++ b/storage/maria/ma_keycache.c
@@ -97,7 +97,7 @@ int maria_assign_to_pagecache(MARIA_HA *info,
ensure that setting the key cache and changing the multi_pagecache
is done atomicly
*/
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
/*
Tell all threads to use the new key cache
This should be seen at the lastes for the next call to an maria function.
@@ -109,7 +109,7 @@ int maria_assign_to_pagecache(MARIA_HA *info,
share->unique_file_name.length,
share->pagecache))
error= my_errno;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
DBUG_RETURN(error);
}
@@ -144,7 +144,7 @@ void maria_change_pagecache(PAGECACHE *old_pagecache,
/*
Lock list to ensure that no one can close the table while we manipulate it
*/
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
for (pos=maria_open_list ; pos ; pos=pos->next)
{
MARIA_HA *info= (MARIA_HA*) pos->data;
@@ -159,6 +159,6 @@ void maria_change_pagecache(PAGECACHE *old_pagecache,
open a new table that will be associted with the old key cache
*/
multi_pagecache_change(old_pagecache, new_pagecache);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
DBUG_VOID_RETURN;
}
diff --git a/storage/maria/ma_locking.c b/storage/maria/ma_locking.c
index 534acc9ddfa..8d2d3c0ad6e 100644
--- a/storage/maria/ma_locking.c
+++ b/storage/maria/ma_locking.c
@@ -47,7 +47,7 @@ int maria_lock_database(MARIA_HA *info, int lock_type)
}
error=0;
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (share->kfile.file >= 0) /* May only be false on windows */
{
switch (lock_type) {
@@ -97,11 +97,11 @@ int maria_lock_database(MARIA_HA *info, int lock_type)
(share->nonmmaped_inserts > MAX_NONMAPPED_INSERTS))
{
if (share->lock_key_trees)
- rw_wrlock(&share->mmap_lock);
+ mysql_rwlock_wrlock(&share->mmap_lock);
_ma_remap_file(info, share->state.state.data_file_length);
share->nonmmaped_inserts= 0;
if (share->lock_key_trees)
- rw_unlock(&share->mmap_lock);
+ mysql_rwlock_unlock(&share->mmap_lock);
}
#endif
#ifdef EXTERNAL_LOCKING
@@ -238,7 +238,7 @@ int maria_lock_database(MARIA_HA *info, int lock_type)
}
}
#endif
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
DBUG_RETURN(error);
} /* maria_lock_database */
@@ -399,7 +399,7 @@ int _ma_mark_file_changed(MARIA_HA *info)
if (_MA_ALREADY_MARKED_FILE_CHANGED)
DBUG_RETURN(0);
- pthread_mutex_lock(&share->intern_lock); /* recheck under mutex */
+ mysql_mutex_lock(&share->intern_lock); /* recheck under mutex */
if (! _MA_ALREADY_MARKED_FILE_CHANGED)
{
share->state.changed|=(STATE_CHANGED | STATE_NOT_ANALYZED |
@@ -445,7 +445,7 @@ int _ma_mark_file_changed(MARIA_HA *info)
}
error= 0;
err:
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
DBUG_RETURN(error);
#undef _MA_ALREADY_MARKED_FILE_CHANGED
}
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index aa3db662c48..98818e9f4f1 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -21,14 +21,14 @@
#include "ma_servicethread.h"
/*
- On Windows, neither my_open() nor my_sync() work for directories.
+ On Windows, neither my_open() nor mysql_file_sync() work for directories.
Also there is no need to flush filesystem changes ,i.e to sync()
directories.
*/
#ifdef __WIN__
#define sync_dir(A,B) 0
#else
-#define sync_dir(A,B) my_sync(A,B)
+#define sync_dir(A,B) mysql_file_sync(A,B)
#endif
/**
@@ -49,9 +49,9 @@
#endif
/** @brief protects checkpoint_in_progress */
-static pthread_mutex_t LOCK_soft_sync;
+static mysql_mutex_t LOCK_soft_sync;
/** @brief for killing the background checkpoint thread */
-static pthread_cond_t COND_soft_sync;
+static mysql_cond_t COND_soft_sync;
/** @brief control structure for checkpoint background thread */
static MA_SERVICE_THREAD_CONTROL soft_sync_control=
{THREAD_DEAD, FALSE, &LOCK_soft_sync, &COND_soft_sync};
@@ -155,7 +155,7 @@ struct st_translog_buffer
/* File handler for this buffer */
TRANSLOG_FILE *file;
/* Threads which are waiting for buffer filling/freeing */
- pthread_cond_t waiting_filling_buffer;
+ mysql_cond_t waiting_filling_buffer;
/* Number of records which are in copy progress */
uint copy_to_buffer_in_progress;
/* list of waiting buffer ready threads */
@@ -190,7 +190,7 @@ struct st_translog_buffer
Because of above and number of buffers equal 5 we can't get dead lock (it is
impossible to get all 5 buffers locked simultaneously).
*/
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
/*
Some thread is going to close the buffer and it should be
done only by that thread
@@ -208,7 +208,7 @@ struct st_translog_buffer
(we have to keep it in this buffer to lock buffers only in one direction).
*/
TRANSLOG_ADDRESS prev_sent_to_disk;
- pthread_cond_t prev_sent_to_disk_cond;
+ mysql_cond_t prev_sent_to_disk_cond;
};
@@ -283,7 +283,7 @@ struct st_translog_descriptor
/* min/max number of file in the array */
uint32 max_file, min_file;
/* the opened files list guard */
- rw_lock_t open_files_lock;
+ mysql_rwlock_t open_files_lock;
/*
File descriptor of the directory where we store log files for syncing
@@ -295,7 +295,7 @@ struct st_translog_descriptor
/* Mask where 1 in position N mean that buffer N is not flushed */
dirty_buffer_mask_t dirty_buffer_mask;
/* The above variable protection */
- pthread_mutex_t dirty_buffer_mask_lock;
+ mysql_mutex_t dirty_buffer_mask_lock;
/*
horizon - visible end of the log (here is absolute end of the log:
position where next chunk can start
@@ -321,23 +321,23 @@ struct st_translog_descriptor
/* All what is after this address is not sent to disk yet */
TRANSLOG_ADDRESS in_buffers_only;
/* protection of sent_to_disk and in_buffers_only */
- pthread_mutex_t sent_to_disk_lock;
+ mysql_mutex_t sent_to_disk_lock;
/*
Protect flushed (see above) and for flush serialization (will
be removed in v1.5
*/
- pthread_mutex_t log_flush_lock;
- pthread_cond_t log_flush_cond;
- pthread_cond_t new_goal_cond;
+ mysql_mutex_t log_flush_lock;
+ mysql_cond_t log_flush_cond;
+ mysql_cond_t new_goal_cond;
/* Protects changing of headers of finished files (max_lsn) */
- pthread_mutex_t file_header_lock;
+ mysql_mutex_t file_header_lock;
/*
Sorted array (with protection) of files where we started writing process
and so we can't give last LSN yet
*/
- pthread_mutex_t unfinished_files_lock;
+ mysql_mutex_t unfinished_files_lock;
DYNAMIC_ARRAY unfinished_files;
/*
@@ -348,7 +348,7 @@ struct st_translog_descriptor
/* Purger data: minimum file in the log (or 0 if unknown) */
uint32 min_file_number;
/* Protect purger from many calls and it's data */
- pthread_mutex_t purger_lock;
+ mysql_mutex_t purger_lock;
/* last low water mark checked */
LSN last_lsn_checked;
/**
@@ -444,9 +444,9 @@ LOG_DESC log_record_type_descriptor[LOGREC_NUMBER_OF_TYPES];
#ifndef DBUG_OFF
#define translog_buffer_lock_assert_owner(B) \
- safe_mutex_assert_owner(&(B)->mutex)
+ mysql_mutex_assert_owner(&(B)->mutex)
#define translog_lock_assert_owner() \
- safe_mutex_assert_owner(&log_descriptor.bc.buffer->mutex)
+ mysql_mutex_assert_owner(&log_descriptor.bc.buffer->mutex)
void translog_lock_handler_assert_owner()
{
translog_lock_assert_owner();
@@ -937,8 +937,9 @@ static File create_logfile_by_number_no_cache(uint32 file_no)
DBUG_RETURN(-1);
/* TODO: add O_DIRECT to open flags (when buffer is aligned) */
- if ((file= my_create(translog_filename_by_fileno(file_no, path),
- 0, O_BINARY | O_RDWR, MYF(MY_WME))) < 0)
+ if ((file= mysql_file_create(key_file_translog,
+ translog_filename_by_fileno(file_no, path),
+ 0, O_BINARY | O_RDWR, MYF(MY_WME))) < 0)
{
DBUG_PRINT("error", ("Error %d during creating file '%s'", errno, path));
translog_stop_writing();
@@ -973,9 +974,10 @@ static File open_logfile_by_number_no_cache(uint32 file_no)
/* TODO: add O_DIRECT to open flags (when buffer is aligned) */
/* TODO: use my_create() */
- if ((file= my_open(translog_filename_by_fileno(file_no, path),
- log_descriptor.open_flags,
- MYF(MY_WME))) < 0)
+ if ((file= mysql_file_open(key_file_translog,
+ translog_filename_by_fileno(file_no, path),
+ log_descriptor.open_flags,
+ MYF(MY_WME))) < 0)
{
DBUG_PRINT("error", ("Error %d during opening file '%s'", errno, path));
DBUG_RETURN(-1);
@@ -998,12 +1000,12 @@ static TRANSLOG_FILE *get_logfile_by_number(uint32 file_no)
{
TRANSLOG_FILE *file;
DBUG_ENTER("get_logfile_by_number");
- rw_rdlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_rdlock(&log_descriptor.open_files_lock);
if (log_descriptor.max_file - file_no >=
log_descriptor.open_files.elements)
{
DBUG_PRINT("info", ("File #%u is not opened", file_no));
- rw_unlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_unlock(&log_descriptor.open_files_lock);
DBUG_RETURN(NULL);
}
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
@@ -1013,7 +1015,7 @@ static TRANSLOG_FILE *get_logfile_by_number(uint32 file_no)
file= *dynamic_element(&log_descriptor.open_files,
log_descriptor.max_file - file_no, TRANSLOG_FILE **);
- rw_unlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_unlock(&log_descriptor.open_files_lock);
DBUG_PRINT("info", ("File 0x%lx File no: %lu, File handler: %d",
(ulong)file, (ulong)file_no,
(file ? file->handler.file : -1)));
@@ -1032,7 +1034,7 @@ static TRANSLOG_FILE *get_current_logfile()
{
TRANSLOG_FILE *file;
DBUG_ENTER("get_current_logfile");
- rw_rdlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_rdlock(&log_descriptor.open_files_lock);
DBUG_PRINT("info", ("max_file: %lu min_file: %lu open_files: %lu",
(ulong) log_descriptor.max_file,
(ulong) log_descriptor.min_file,
@@ -1040,7 +1042,7 @@ static TRANSLOG_FILE *get_current_logfile()
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
file= *dynamic_element(&log_descriptor.open_files, 0, TRANSLOG_FILE **);
- rw_unlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_unlock(&log_descriptor.open_files_lock);
DBUG_RETURN(file);
}
@@ -1138,7 +1140,7 @@ static my_bool translog_max_lsn_to_header(File file, LSN lsn)
LSN_STORE_SIZE,
(LOG_HEADER_DATA_SIZE - LSN_STORE_SIZE),
log_write_flags) != 0 ||
- my_sync(file, MYF(MY_WME)) != 0);
+ mysql_file_sync(file, MYF(MY_WME)) != 0);
/*
We should not increase counter in case of error above, but it is so
unlikely that we can ignore this case
@@ -1212,7 +1214,7 @@ my_bool translog_read_file_header(LOGHANDLER_FILE_INFO *desc, File file)
uchar page_buff[LOG_HEADER_DATA_SIZE];
DBUG_ENTER("translog_read_file_header");
- if (my_pread(file, page_buff,
+ if (mysql_file_pread(file, page_buff,
sizeof(page_buff), 0, MYF(MY_FNABP | MY_WME)))
{
DBUG_PRINT("info", ("log read fail error: %d", my_errno));
@@ -1270,7 +1272,7 @@ static my_bool translog_set_lsn_for_files(uint32 from_file, uint32 to_file,
translog_unlock();
/* Checks finished files if they are */
- pthread_mutex_lock(&log_descriptor.file_header_lock);
+ mysql_mutex_lock(&log_descriptor.file_header_lock);
for (file= from_file; file <= to_file; file++)
{
LOGHANDLER_FILE_INFO info;
@@ -1282,13 +1284,13 @@ static my_bool translog_set_lsn_for_files(uint32 from_file, uint32 to_file,
((translog_read_file_header(&info, fd) ||
(cmp_translog_addr(lsn, info.max_lsn) > 0 &&
translog_max_lsn_to_header(fd, lsn))) |
- my_close(fd, MYF(MY_WME))))
+ mysql_file_close(fd, MYF(MY_WME))))
{
translog_stop_writing();
DBUG_RETURN(1);
}
}
- pthread_mutex_unlock(&log_descriptor.file_header_lock);
+ mysql_mutex_unlock(&log_descriptor.file_header_lock);
DBUG_RETURN(0);
}
@@ -1317,7 +1319,7 @@ static void translog_mark_file_unfinished(uint32 file)
DBUG_PRINT("enter", ("file: %lu", (ulong) file));
fc.file= file; fc.counter= 1;
- pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
+ mysql_mutex_lock(&log_descriptor.unfinished_files_lock);
if (log_descriptor.unfinished_files.elements == 0)
{
@@ -1368,7 +1370,7 @@ static void translog_mark_file_unfinished(uint32 file)
place + 1, struct st_file_counter *),
&fc, sizeof(struct st_file_counter));
end:
- pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ mysql_mutex_unlock(&log_descriptor.unfinished_files_lock);
DBUG_VOID_RETURN;
}
@@ -1388,7 +1390,7 @@ static void translog_mark_file_finished(uint32 file)
LINT_INIT(fc_ptr);
- pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
+ mysql_mutex_lock(&log_descriptor.unfinished_files_lock);
DBUG_ASSERT(log_descriptor.unfinished_files.elements > 0);
for (i= 0;
@@ -1406,7 +1408,7 @@ static void translog_mark_file_finished(uint32 file)
if (! --fc_ptr->counter)
delete_dynamic_element(&log_descriptor.unfinished_files, i);
- pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ mysql_mutex_unlock(&log_descriptor.unfinished_files_lock);
DBUG_VOID_RETURN;
}
@@ -1430,7 +1432,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file)
DBUG_ASSERT(translog_status == TRANSLOG_OK ||
translog_status == TRANSLOG_READONLY);
- pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
+ mysql_mutex_lock(&log_descriptor.unfinished_files_lock);
/* find file with minimum file number "in progress" */
if (log_descriptor.unfinished_files.elements > 0)
@@ -1440,7 +1442,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file)
0, struct st_file_counter *);
limit= fc_ptr->file; /* minimal file number "in progress" */
}
- pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ mysql_mutex_unlock(&log_descriptor.unfinished_files_lock);
/*
if there is no "in progress file" then unfinished file is in progress
@@ -1464,7 +1466,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file)
fd= open_logfile_by_number_no_cache(file);
if ((fd < 0) ||
- (translog_read_file_header(&info, fd) | my_close(fd, MYF(MY_WME))))
+ (translog_read_file_header(&info, fd) | mysql_file_close(fd, MYF(MY_WME))))
{
DBUG_PRINT("error", ("Can't read file header"));
DBUG_RETURN(LSN_ERROR);
@@ -1507,7 +1509,8 @@ static my_bool translog_buffer_init(struct st_translog_buffer *buffer, int num)
buffer->size= 0;
buffer->skipped_data= 0;
/* cond of thread which is waiting for buffer filling */
- if (pthread_cond_init(&buffer->waiting_filling_buffer, 0))
+ if (mysql_cond_init(key_TRANSLOG_BUFFER_waiting_filling_buffer,
+ &buffer->waiting_filling_buffer, 0))
DBUG_RETURN(1);
/* Number of records which are in copy progress */
buffer->copy_to_buffer_in_progress= 0;
@@ -1527,8 +1530,10 @@ static my_bool translog_buffer_init(struct st_translog_buffer *buffer, int num)
possible problems which include this mutexes.
*/
- if (pthread_mutex_init(&buffer->mutex, MY_MUTEX_INIT_FAST) ||
- pthread_cond_init(&buffer->prev_sent_to_disk_cond, 0))
+ if (mysql_mutex_init(key_TRANSLOG_BUFFER_mutex,
+ &buffer->mutex, MY_MUTEX_INIT_FAST) ||
+ mysql_cond_init(key_TRANSLOG_BUFFER_prev_sent_to_disk_cond,
+ &buffer->prev_sent_to_disk_cond, 0))
DBUG_RETURN(1);
buffer->is_closing_buffer= 0;
buffer->prev_sent_to_disk= LSN_IMPOSSIBLE;
@@ -1559,10 +1564,10 @@ static my_bool translog_close_log_file(TRANSLOG_FILE *file)
*/
if (!file->is_sync)
{
- rc= my_sync(file->handler.file, MYF(MY_WME));
+ rc= mysql_file_sync(file->handler.file, MYF(MY_WME));
translog_syncs++;
}
- rc|= my_close(file->handler.file, MYF(MY_WME));
+ rc|= mysql_file_close(file->handler.file, MYF(MY_WME));
my_free(file);
return test(rc);
}
@@ -1633,7 +1638,7 @@ static my_bool translog_create_new_file()
if (translog_max_lsn_to_header(old->handler.file, log_descriptor.max_lsn))
goto error;
- rw_wrlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_wrlock(&log_descriptor.open_files_lock);
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
DBUG_ASSERT(file_no == log_descriptor.max_file + 1);
@@ -1659,7 +1664,7 @@ static my_bool translog_create_new_file()
set_dynamic(&log_descriptor.open_files, (uchar*)&file, 0);
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
- rw_unlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_unlock(&log_descriptor.open_files_lock);
DBUG_PRINT("info", ("file_no: %lu", (ulong)file_no));
@@ -1677,7 +1682,7 @@ static my_bool translog_create_new_file()
DBUG_RETURN(0);
error_lock:
- rw_unlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_unlock(&log_descriptor.open_files_lock);
error:
translog_stop_writing();
DBUG_RETURN(1);
@@ -1701,7 +1706,7 @@ static void translog_buffer_lock(struct st_translog_buffer *buffer)
DBUG_PRINT("enter",
("Lock buffer #%u: (0x%lx)", (uint) buffer->buffer_no,
(ulong) buffer));
- pthread_mutex_lock(&buffer->mutex);
+ mysql_mutex_lock(&buffer->mutex);
DBUG_VOID_RETURN;
}
@@ -1724,7 +1729,7 @@ static void translog_buffer_unlock(struct st_translog_buffer *buffer)
DBUG_PRINT("enter", ("Unlock buffer... #%u (0x%lx)",
(uint) buffer->buffer_no, (ulong) buffer));
- pthread_mutex_unlock(&buffer->mutex);
+ mysql_mutex_unlock(&buffer->mutex);
DBUG_VOID_RETURN;
}
@@ -1985,7 +1990,7 @@ static void translog_wait_for_closing(struct st_translog_buffer *buffer)
DBUG_PRINT("info", ("wait for writers... buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
DBUG_ASSERT(buffer->file != NULL);
- pthread_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
+ mysql_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
DBUG_PRINT("info", ("wait for writers done buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
}
@@ -2017,7 +2022,7 @@ static void translog_wait_for_writers(struct st_translog_buffer *buffer)
DBUG_PRINT("info", ("wait for writers... buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
DBUG_ASSERT(buffer->file != NULL);
- pthread_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
+ mysql_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
DBUG_PRINT("info", ("wait for writers done buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
}
@@ -2061,7 +2066,7 @@ static void translog_wait_for_buffer_free(struct st_translog_buffer *buffer)
{
DBUG_PRINT("info", ("wait for writers... buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
- pthread_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
+ mysql_cond_wait(&buffer->waiting_filling_buffer, &buffer->mutex);
DBUG_PRINT("info", ("wait for writers done. buffer: #%u 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer));
}
@@ -2135,9 +2140,9 @@ static void translog_start_buffer(struct st_translog_buffer *buffer,
cursor->chaser, (ulong) cursor->buffer->size,
(ulong) (cursor->ptr - cursor->buffer->buffer)));
translog_check_cursor(cursor);
- pthread_mutex_lock(&log_descriptor.dirty_buffer_mask_lock);
+ mysql_mutex_lock(&log_descriptor.dirty_buffer_mask_lock);
log_descriptor.dirty_buffer_mask|= (1 << buffer->buffer_no);
- pthread_mutex_unlock(&log_descriptor.dirty_buffer_mask_lock);
+ mysql_mutex_unlock(&log_descriptor.dirty_buffer_mask_lock);
DBUG_VOID_RETURN;
}
@@ -2244,7 +2249,7 @@ static void translog_set_sent_to_disk(struct st_translog_buffer *buffer)
TRANSLOG_ADDRESS in_buffers= buffer->next_buffer_offset;
DBUG_ENTER("translog_set_sent_to_disk");
- pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_lock(&log_descriptor.sent_to_disk_lock);
DBUG_PRINT("enter", ("lsn: (%lu,0x%lx) in_buffers: (%lu,0x%lx) "
"in_buffers_only: (%lu,0x%lx) start: (%lu,0x%lx) "
"sent_to_disk: (%lu,0x%lx)",
@@ -2267,7 +2272,7 @@ static void translog_set_sent_to_disk(struct st_translog_buffer *buffer)
log_descriptor.in_buffers_only= in_buffers;
DBUG_PRINT("info", ("set new in_buffers_only"));
}
- pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_unlock(&log_descriptor.sent_to_disk_lock);
DBUG_VOID_RETURN;
}
@@ -2284,7 +2289,7 @@ static void translog_set_sent_to_disk(struct st_translog_buffer *buffer)
static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers)
{
DBUG_ENTER("translog_set_only_in_buffers");
- pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_lock(&log_descriptor.sent_to_disk_lock);
DBUG_PRINT("enter", ("in_buffers: (%lu,0x%lx) "
"in_buffers_only: (%lu,0x%lx)",
LSN_IN_PARTS(in_buffers),
@@ -2297,7 +2302,7 @@ static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers)
log_descriptor.in_buffers_only= in_buffers;
DBUG_PRINT("info", ("set new in_buffers_only"));
}
- pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_unlock(&log_descriptor.sent_to_disk_lock);
DBUG_VOID_RETURN;
}
@@ -2316,9 +2321,9 @@ static TRANSLOG_ADDRESS translog_only_in_buffers()
{
register TRANSLOG_ADDRESS addr;
DBUG_ENTER("translog_only_in_buffers");
- pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_lock(&log_descriptor.sent_to_disk_lock);
addr= log_descriptor.in_buffers_only;
- pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_unlock(&log_descriptor.sent_to_disk_lock);
DBUG_RETURN(addr);
}
@@ -2337,10 +2342,10 @@ static LSN translog_get_sent_to_disk()
{
register LSN lsn;
DBUG_ENTER("translog_get_sent_to_disk");
- pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_lock(&log_descriptor.sent_to_disk_lock);
lsn= log_descriptor.sent_to_disk;
DBUG_PRINT("info", ("sent to disk up to (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
- pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_unlock(&log_descriptor.sent_to_disk_lock);
DBUG_RETURN(lsn);
}
@@ -2566,7 +2571,7 @@ my_bool translog_prev_buffer_flush_wait(struct st_translog_buffer *buffer)
if (buffer->prev_buffer_offset != buffer->prev_sent_to_disk)
{
do {
- pthread_cond_wait(&buffer->prev_sent_to_disk_cond, &buffer->mutex);
+ mysql_cond_wait(&buffer->prev_sent_to_disk_cond, &buffer->mutex);
if (buffer->file != file || buffer->offset != offset ||
buffer->ver != ver)
{
@@ -2709,7 +2714,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer)
translog_buffer_lock(next_buffer);
next_buffer->prev_sent_to_disk= buffer->offset;
translog_buffer_unlock(next_buffer);
- pthread_cond_broadcast(&next_buffer->prev_sent_to_disk_cond);
+ mysql_cond_broadcast(&next_buffer->prev_sent_to_disk_cond);
}
else
{
@@ -2725,10 +2730,10 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer)
buffer->file= NULL;
buffer->overlay= 0;
buffer->ver++;
- pthread_mutex_lock(&log_descriptor.dirty_buffer_mask_lock);
+ mysql_mutex_lock(&log_descriptor.dirty_buffer_mask_lock);
log_descriptor.dirty_buffer_mask&= ~(1 << buffer->buffer_no);
- pthread_mutex_unlock(&log_descriptor.dirty_buffer_mask_lock);
- pthread_cond_broadcast(&buffer->waiting_filling_buffer);
+ mysql_mutex_unlock(&log_descriptor.dirty_buffer_mask_lock);
+ mysql_cond_broadcast(&buffer->waiting_filling_buffer);
DBUG_RETURN(0);
}
@@ -3264,7 +3269,7 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
requested log file have to be opened and can't be freed after
returning pointer on it (file_size).
*/
- file_size= my_seek(file->handler.file, 0, SEEK_END, MYF(0));
+ file_size= mysql_file_seek(file->handler.file, 0, SEEK_END, MYF(0));
}
else
{
@@ -3273,16 +3278,17 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
when files are not opened.
*/
File fd;
- if ((fd= my_open(translog_filename_by_fileno(file_no, path),
- O_RDONLY, (no_errors ? MYF(0) : MYF(MY_WME)))) < 0)
+ if ((fd= mysql_file_open(key_file_translog,
+ translog_filename_by_fileno(file_no, path),
+ O_RDONLY, (no_errors ? MYF(0) : MYF(MY_WME)))) < 0)
{
my_errno= errno;
DBUG_PRINT("error", ("Error %d during opening file #%d",
errno, file_no));
DBUG_RETURN(1);
}
- file_size= my_seek(fd, 0, SEEK_END, MYF(0));
- my_close(fd, MYF(0));
+ file_size= mysql_file_seek(fd, 0, SEEK_END, MYF(0));
+ mysql_file_close(fd, MYF(0));
}
DBUG_PRINT("info", ("File size: %s", llstr(file_size, buff)));
if (file_size == MY_FILEPOS_ERROR)
@@ -3418,7 +3424,8 @@ static my_bool translog_truncate_log(TRANSLOG_ADDRESS addr)
DBUG_ASSERT(cmp_translog_addr(addr, log_descriptor.horizon) < 0);
/* remove files between the address and horizon */
for (i= LSN_FILE_NO(addr) + 1; i <= LSN_FILE_NO(log_descriptor.horizon); i++)
- if (my_delete(translog_filename_by_fileno(i, path), MYF(MY_WME)))
+ if (mysql_file_delete(key_file_translog,
+ translog_filename_by_fileno(i, path), MYF(MY_WME)))
{
translog_unlock();
DBUG_RETURN(1);
@@ -3432,12 +3439,12 @@ static my_bool translog_truncate_log(TRANSLOG_ADDRESS addr)
page_rest= next_page_offset - LSN_OFFSET(addr);
memset(page_buff, TRANSLOG_FILLER, page_rest);
rc= ((fd= open_logfile_by_number_no_cache(LSN_FILE_NO(addr))) < 0 ||
- ((my_chsize(fd, next_page_offset, TRANSLOG_FILLER, MYF(MY_WME)) ||
+ ((mysql_file_chsize(fd, next_page_offset, TRANSLOG_FILLER, MYF(MY_WME)) ||
(page_rest && my_pwrite(fd, page_buff, page_rest, LSN_OFFSET(addr),
log_write_flags)) ||
- my_sync(fd, MYF(MY_WME)))));
+ mysql_file_sync(fd, MYF(MY_WME)))));
translog_syncs++;
- rc|= (fd > 0 && my_close(fd, MYF(MY_WME)));
+ rc|= (fd > 0 && mysql_file_close(fd, MYF(MY_WME)));
if (sync_log_dir >= TRANSLOG_SYNC_DIR_ALWAYS)
{
rc|= sync_dir(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD));
@@ -3621,22 +3628,24 @@ my_bool translog_init_with_table(const char *directory,
log_descriptor.open_flags= O_BINARY | O_RDONLY;
else
log_descriptor.open_flags= O_BINARY | O_RDWR;
- if (pthread_mutex_init(&log_descriptor.sent_to_disk_lock,
- MY_MUTEX_INIT_FAST) ||
- pthread_mutex_init(&log_descriptor.file_header_lock,
- MY_MUTEX_INIT_FAST) ||
- pthread_mutex_init(&log_descriptor.unfinished_files_lock,
- MY_MUTEX_INIT_FAST) ||
- pthread_mutex_init(&log_descriptor.purger_lock,
- MY_MUTEX_INIT_FAST) ||
- pthread_mutex_init(&log_descriptor.log_flush_lock,
- MY_MUTEX_INIT_FAST) ||
- pthread_mutex_init(&log_descriptor.dirty_buffer_mask_lock,
- MY_MUTEX_INIT_FAST) ||
- pthread_cond_init(&log_descriptor.log_flush_cond, 0) ||
- pthread_cond_init(&log_descriptor.new_goal_cond, 0) ||
- my_rwlock_init(&log_descriptor.open_files_lock,
- NULL) ||
+ if (mysql_mutex_init(key_TRANSLOG_BUFFER_mutex,
+ &log_descriptor.sent_to_disk_lock, MY_MUTEX_INIT_FAST) ||
+ mysql_mutex_init(key_TRANSLOG_DESCRIPTOR_file_header_lock,
+ &log_descriptor.file_header_lock, MY_MUTEX_INIT_FAST) ||
+ mysql_mutex_init(key_TRANSLOG_DESCRIPTOR_unfinished_files_lock,
+ &log_descriptor.unfinished_files_lock, MY_MUTEX_INIT_FAST) ||
+ mysql_mutex_init(key_TRANSLOG_DESCRIPTOR_purger_lock,
+ &log_descriptor.purger_lock, MY_MUTEX_INIT_FAST) ||
+ mysql_mutex_init(key_TRANSLOG_DESCRIPTOR_log_flush_lock,
+ &log_descriptor.log_flush_lock, MY_MUTEX_INIT_FAST) ||
+ mysql_mutex_init(key_TRANSLOG_DESCRIPTOR_dirty_buffer_mask_lock,
+ &log_descriptor.dirty_buffer_mask_lock, MY_MUTEX_INIT_FAST) ||
+ mysql_cond_init(key_TRANSLOG_DESCRIPTOR_log_flush_cond,
+ &log_descriptor.log_flush_cond, 0) ||
+ mysql_cond_init(key_TRANSLOG_DESCRIPTOR_new_goal_cond,
+ &log_descriptor.new_goal_cond, 0) ||
+ mysql_rwlock_init(key_TRANSLOG_DESCRIPTOR_open_files_lock,
+ &log_descriptor.open_files_lock) ||
my_init_dynamic_array(&log_descriptor.open_files,
sizeof(TRANSLOG_FILE*), 10, 10) ||
my_init_dynamic_array(&log_descriptor.unfinished_files,
@@ -3798,7 +3807,7 @@ my_bool translog_init_with_table(const char *directory,
if (file == NULL ||
(file->handler.file=
open_logfile_by_number_no_cache(i)) < 0 ||
- my_seek(file->handler.file, 0, SEEK_END, MYF(0)) >=
+ mysql_file_seek(file->handler.file, 0, SEEK_END, MYF(0)) >=
ULL(0xffffffff))
{
int j;
@@ -3807,7 +3816,7 @@ my_bool translog_init_with_table(const char *directory,
TRANSLOG_FILE *el=
*dynamic_element(&log_descriptor.open_files, j,
TRANSLOG_FILE **);
- my_close(el->handler.file, MYF(MY_WME));
+ mysql_file_close(el->handler.file, MYF(MY_WME));
my_free(el);
}
if (file)
@@ -4238,8 +4247,8 @@ static void translog_buffer_destroy(struct st_translog_buffer *buffer)
translog_buffer_unlock(buffer);
}
DBUG_PRINT("info", ("Destroy mutex: 0x%lx", (ulong) &buffer->mutex));
- pthread_mutex_destroy(&buffer->mutex);
- pthread_cond_destroy(&buffer->waiting_filling_buffer);
+ mysql_mutex_destroy(&buffer->mutex);
+ mysql_cond_destroy(&buffer->waiting_filling_buffer);
DBUG_VOID_RETURN;
}
@@ -4281,20 +4290,20 @@ void translog_destroy()
/* close files */
while ((file= (TRANSLOG_FILE **)pop_dynamic(&log_descriptor.open_files)))
translog_close_log_file(*file);
- pthread_mutex_destroy(&log_descriptor.sent_to_disk_lock);
- pthread_mutex_destroy(&log_descriptor.file_header_lock);
- pthread_mutex_destroy(&log_descriptor.unfinished_files_lock);
- pthread_mutex_destroy(&log_descriptor.purger_lock);
- pthread_mutex_destroy(&log_descriptor.log_flush_lock);
- pthread_mutex_destroy(&log_descriptor.dirty_buffer_mask_lock);
- pthread_cond_destroy(&log_descriptor.log_flush_cond);
- pthread_cond_destroy(&log_descriptor.new_goal_cond);
- rwlock_destroy(&log_descriptor.open_files_lock);
+ mysql_mutex_destroy(&log_descriptor.sent_to_disk_lock);
+ mysql_mutex_destroy(&log_descriptor.file_header_lock);
+ mysql_mutex_destroy(&log_descriptor.unfinished_files_lock);
+ mysql_mutex_destroy(&log_descriptor.purger_lock);
+ mysql_mutex_destroy(&log_descriptor.log_flush_lock);
+ mysql_mutex_destroy(&log_descriptor.dirty_buffer_mask_lock);
+ mysql_cond_destroy(&log_descriptor.log_flush_cond);
+ mysql_cond_destroy(&log_descriptor.new_goal_cond);
+ mysql_rwlock_destroy(&log_descriptor.open_files_lock);
delete_dynamic(&log_descriptor.open_files);
delete_dynamic(&log_descriptor.unfinished_files);
if (log_descriptor.directory_fd >= 0)
- my_close(log_descriptor.directory_fd, MYF(MY_WME));
+ mysql_file_close(log_descriptor.directory_fd, MYF(MY_WME));
my_atomic_rwlock_destroy(&LOCK_id_to_share);
if (id_to_share != NULL)
my_free(id_to_share + 1);
@@ -4586,7 +4595,7 @@ static void translog_buffer_decrease_writers(struct st_translog_buffer *buffer)
(uint) buffer->buffer_no, (ulong) buffer,
buffer->copy_to_buffer_in_progress));
if (buffer->copy_to_buffer_in_progress == 0)
- pthread_cond_broadcast(&buffer->waiting_filling_buffer);
+ mysql_cond_broadcast(&buffer->waiting_filling_buffer);
DBUG_VOID_RETURN;
}
@@ -7639,7 +7648,7 @@ static void translog_force_current_buffer_to_finish()
old_buffer->is_closing_buffer= 0;
DBUG_PRINT("enter", ("Buffer #%u 0x%lx is_closing_buffer cleared",
(uint) old_buffer->buffer_no, (ulong) old_buffer));
- pthread_cond_broadcast(&old_buffer->waiting_filling_buffer);
+ mysql_cond_broadcast(&old_buffer->waiting_filling_buffer);
if (left)
{
@@ -7678,9 +7687,9 @@ void translog_flush_wait_for_end(LSN lsn)
{
DBUG_ENTER("translog_flush_wait_for_end");
DBUG_PRINT("enter", ("LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
- safe_mutex_assert_owner(&log_descriptor.log_flush_lock);
+ mysql_mutex_assert_owner(&log_descriptor.log_flush_lock);
while (cmp_translog_addr(log_descriptor.flushed, lsn) < 0)
- pthread_cond_wait(&log_descriptor.log_flush_cond,
+ mysql_cond_wait(&log_descriptor.log_flush_cond,
&log_descriptor.log_flush_lock);
DBUG_VOID_RETURN;
}
@@ -7698,16 +7707,16 @@ void translog_flush_set_new_goal_and_wait(TRANSLOG_ADDRESS lsn)
int flush_no= log_descriptor.flush_no;
DBUG_ENTER("translog_flush_set_new_goal_and_wait");
DBUG_PRINT("enter", ("LSN: (%lu,0x%lx)", LSN_IN_PARTS(lsn)));
- safe_mutex_assert_owner(&log_descriptor.log_flush_lock);
+ mysql_mutex_assert_owner(&log_descriptor.log_flush_lock);
if (cmp_translog_addr(lsn, log_descriptor.next_pass_max_lsn) > 0)
{
log_descriptor.next_pass_max_lsn= lsn;
log_descriptor.max_lsn_requester= pthread_self();
- pthread_cond_broadcast(&log_descriptor.new_goal_cond);
+ mysql_cond_broadcast(&log_descriptor.new_goal_cond);
}
while (flush_no == log_descriptor.flush_no)
{
- pthread_cond_wait(&log_descriptor.log_flush_cond,
+ mysql_cond_wait(&log_descriptor.log_flush_cond,
&log_descriptor.log_flush_lock);
}
DBUG_VOID_RETURN;
@@ -7746,7 +7755,7 @@ static my_bool translog_sync_files(uint32 min, uint32 max,
DBUG_ASSERT(file != NULL);
if (!file->is_sync)
{
- if (my_sync(file->handler.file, MYF(MY_WME)))
+ if (mysql_file_sync(file->handler.file, MYF(MY_WME)))
{
rc= 1;
translog_stop_writing();
@@ -7937,12 +7946,12 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn)
LINT_INIT(sent_to_disk);
LINT_INIT(flush_interval);
- pthread_mutex_lock(&log_descriptor.log_flush_lock);
+ mysql_mutex_lock(&log_descriptor.log_flush_lock);
DBUG_PRINT("info", ("Everything is flushed up to (%lu,0x%lx)",
LSN_IN_PARTS(log_descriptor.flushed)));
if (cmp_translog_addr(log_descriptor.flushed, lsn) >= 0)
{
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ mysql_mutex_unlock(&log_descriptor.log_flush_lock);
DBUG_RETURN(0);
}
if (log_descriptor.flush_in_progress)
@@ -7960,7 +7969,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn)
waiting then acquire it again
*/
translog_flush_wait_for_end(lsn);
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ mysql_mutex_unlock(&log_descriptor.log_flush_lock);
DBUG_RETURN(0);
}
log_descriptor.next_pass_max_lsn= LSN_IMPOSSIBLE;
@@ -7969,7 +7978,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn)
flush_horizon= log_descriptor.previous_flush_horizon;
DBUG_PRINT("info", ("flush_in_progress is set, flush_horizon: (%lu,0x%lx)",
LSN_IN_PARTS(flush_horizon)));
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ mysql_mutex_unlock(&log_descriptor.log_flush_lock);
hgroup_commit_at_start= hard_group_commit;
if (hgroup_commit_at_start)
@@ -7980,7 +7989,7 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn)
{
DBUG_PRINT("info", ("everything is flushed"));
translog_unlock();
- pthread_mutex_lock(&log_descriptor.log_flush_lock);
+ mysql_mutex_lock(&log_descriptor.log_flush_lock);
goto out;
}
@@ -7994,20 +8003,20 @@ my_bool translog_flush(TRANSLOG_ADDRESS lsn)
retest:
/*
- We do not check time here because pthread_mutex_lock rarely takes
+ We do not check time here because mysql_mutex_lock rarely takes
a lot of time so we can sacrifice a bit precision to performance
(taking into account that my_micro_time() might be expensive call).
*/
if (flush_interval == 0)
break; /* flush pass is ended */
- pthread_mutex_lock(&log_descriptor.log_flush_lock);
+ mysql_mutex_lock(&log_descriptor.log_flush_lock);
if (log_descriptor.next_pass_max_lsn == LSN_IMPOSSIBLE)
{
if (flush_interval == 0 ||
(time_spent= (my_micro_time() - flush_start)) >= flush_interval)
{
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ mysql_mutex_unlock(&log_descriptor.log_flush_lock);
break;
}
DBUG_PRINT("info", ("flush waits: %llu interval: %llu spent: %llu",
@@ -8015,10 +8024,10 @@ retest:
flush_interval, time_spent));
/* wait time or next goal */
set_timespec_nsec(abstime, flush_interval - time_spent);
- pthread_cond_timedwait(&log_descriptor.new_goal_cond,
+ mysql_cond_timedwait(&log_descriptor.new_goal_cond,
&log_descriptor.log_flush_lock,
&abstime);
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ mysql_mutex_unlock(&log_descriptor.log_flush_lock);
DBUG_PRINT("info", ("retest conditions"));
goto retest;
}
@@ -8030,7 +8039,7 @@ retest:
log_descriptor.max_lsn_requester= pthread_self();
DBUG_PRINT("info", ("flush took next goal: (%lu,0x%lx)",
LSN_IN_PARTS(lsn)));
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
+ mysql_mutex_unlock(&log_descriptor.log_flush_lock);
/* next flush pass */
DBUG_PRINT("info", ("next flush pass"));
@@ -8056,7 +8065,7 @@ retest:
TRANSLOG_PAGE_SIZE)))))
{
sent_to_disk= LSN_IMPOSSIBLE;
- pthread_mutex_lock(&log_descriptor.log_flush_lock);
+ mysql_mutex_lock(&log_descriptor.log_flush_lock);
goto out;
}
/* keep values for soft sync() and forced sync() actual */
@@ -8074,7 +8083,7 @@ retest:
DBUG_ASSERT(flush_horizon <= log_descriptor.horizon);
- pthread_mutex_lock(&log_descriptor.log_flush_lock);
+ mysql_mutex_lock(&log_descriptor.log_flush_lock);
log_descriptor.previous_flush_horizon= flush_horizon;
out:
if (sent_to_disk != LSN_IMPOSSIBLE)
@@ -8082,8 +8091,8 @@ out:
log_descriptor.flush_in_progress= 0;
log_descriptor.flush_no++;
DBUG_PRINT("info", ("flush_in_progress is dropped"));
- pthread_mutex_unlock(&log_descriptor.log_flush_lock);
- pthread_cond_broadcast(&log_descriptor.log_flush_cond);
+ mysql_mutex_unlock(&log_descriptor.log_flush_lock);
+ mysql_cond_broadcast(&log_descriptor.log_flush_cond);
DBUG_RETURN(rc);
}
@@ -8114,7 +8123,7 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn)
*/
DBUG_ASSERT(share->data_file_type == BLOCK_RECORD);
/* re-check under mutex to avoid having 2 ids for the same share */
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (unlikely(share->id == 0))
{
LSN lsn;
@@ -8162,11 +8171,11 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn)
sizeof(log_array)/sizeof(log_array[0]),
log_array, log_data, NULL)))
{
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
return 1;
}
}
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
return 0;
}
@@ -8189,7 +8198,7 @@ void translog_deassign_id_from_share(MARIA_SHARE *share)
happening. But a Checkpoint may be reading share->id, so we require this
mutex:
*/
- safe_mutex_assert_owner(&share->intern_lock);
+ mysql_mutex_assert_owner(&share->intern_lock);
my_atomic_rwlock_rdlock(&LOCK_id_to_share);
my_atomic_storeptr((void **)&id_to_share[share->id], 0);
my_atomic_rwlock_rdunlock(&LOCK_id_to_share);
@@ -8223,8 +8232,9 @@ my_bool translog_is_file(uint file_no)
{
MY_STAT stat_buff;
char path[FN_REFLEN];
- return (test(my_stat(translog_filename_by_fileno(file_no, path),
- &stat_buff, MYF(0))));
+ return (test(mysql_file_stat(key_file_translog,
+ translog_filename_by_fileno(file_no, path),
+ &stat_buff, MYF(0))));
}
@@ -8243,14 +8253,14 @@ static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected)
uint min_file= 0, max_file;
DBUG_ENTER("translog_first_file");
if (!is_protected)
- pthread_mutex_lock(&log_descriptor.purger_lock);
+ mysql_mutex_lock(&log_descriptor.purger_lock);
if (log_descriptor.min_file_number &&
translog_is_file(log_descriptor.min_file_number))
{
DBUG_PRINT("info", ("cached %lu",
(ulong) log_descriptor.min_file_number));
if (!is_protected)
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ mysql_mutex_unlock(&log_descriptor.purger_lock);
DBUG_RETURN(log_descriptor.min_file_number);
}
@@ -8271,7 +8281,7 @@ static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected)
}
log_descriptor.min_file_number= max_file;
if (!is_protected)
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ mysql_mutex_unlock(&log_descriptor.purger_lock);
DBUG_PRINT("info", ("first file :%lu", (ulong) max_file));
DBUG_ASSERT(max_file >= 1);
DBUG_RETURN(max_file);
@@ -8470,7 +8480,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
DBUG_PRINT("info", ("last_need_file set to %lu", (ulong)last_need_file));
}
- pthread_mutex_lock(&log_descriptor.purger_lock);
+ mysql_mutex_lock(&log_descriptor.purger_lock);
DBUG_PRINT("info", ("last_lsn_checked file: %lu:",
(ulong) log_descriptor.last_lsn_checked));
if (LSN_FILE_NO(log_descriptor.last_lsn_checked) < last_need_file)
@@ -8502,7 +8512,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
if (i >= log_descriptor.min_file)
{
TRANSLOG_FILE *file;
- rw_wrlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_wrlock(&log_descriptor.open_files_lock);
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
DBUG_ASSERT(log_descriptor.min_file == i);
@@ -8512,14 +8522,15 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
log_descriptor.min_file++;
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements);
- rw_unlock(&log_descriptor.open_files_lock);
+ mysql_rwlock_unlock(&log_descriptor.open_files_lock);
translog_close_log_file(file);
}
if (log_purge_type == TRANSLOG_PURGE_IMMIDIATE)
{
char path[FN_REFLEN], *file_name;
file_name= translog_filename_by_fileno(i, path);
- rc= test(my_delete(file_name, MYF(MY_WME)));
+ rc= test(mysql_file_delete(key_file_translog,
+ file_name, MYF(MY_WME)));
}
}
if (unlikely(rc == 1))
@@ -8528,7 +8539,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
log_descriptor.min_need_file= i;
}
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ mysql_mutex_unlock(&log_descriptor.purger_lock);
DBUG_RETURN(rc);
}
@@ -8565,12 +8576,12 @@ my_bool translog_purge_at_flush()
DBUG_RETURN(0);
}
- pthread_mutex_lock(&log_descriptor.purger_lock);
+ mysql_mutex_lock(&log_descriptor.purger_lock);
if (unlikely(log_descriptor.min_need_file == 0))
{
DBUG_PRINT("info", ("No info about min need file => exit"));
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ mysql_mutex_unlock(&log_descriptor.purger_lock);
DBUG_RETURN(0);
}
@@ -8581,10 +8592,11 @@ my_bool translog_purge_at_flush()
char path[FN_REFLEN], *file_name;
DBUG_PRINT("info", ("purge file %lu\n", (ulong) i));
file_name= translog_filename_by_fileno(i, path);
- rc= test(my_delete(file_name, MYF(MY_WME)));
+ rc= test(mysql_file_delete(key_file_translog,
+ file_name, MYF(MY_WME)));
}
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ mysql_mutex_unlock(&log_descriptor.purger_lock);
DBUG_RETURN(rc);
}
@@ -8614,9 +8626,9 @@ uint32 translog_get_first_file(TRANSLOG_ADDRESS horizon)
uint32 translog_get_first_needed_file()
{
uint32 file_no;
- pthread_mutex_lock(&log_descriptor.purger_lock);
+ mysql_mutex_lock(&log_descriptor.purger_lock);
file_no= log_descriptor.min_need_file;
- pthread_mutex_unlock(&log_descriptor.purger_lock);
+ mysql_mutex_unlock(&log_descriptor.purger_lock);
return file_no;
}
@@ -8835,7 +8847,8 @@ int translog_soft_sync_start(void)
soft_need_sync= 1;
if (!(res= ma_service_thread_control_init(&soft_sync_control)))
- if (!(res= pthread_create(&th, NULL, ma_soft_sync_background, NULL)))
+ if (!(res= mysql_thread_create(key_thread_soft_sync,
+ &th, NULL, ma_soft_sync_background, NULL)))
soft_sync_control.status= THREAD_RUNNING;
DBUG_RETURN(res);
}
@@ -9272,7 +9285,7 @@ int main(int argc, char **argv)
opt_file, my_errno);
goto err;
}
- if (my_seek(handler, opt_offset, SEEK_SET, MYF(MY_WME)) !=
+ if (mysql_file_seek(handler, opt_offset, SEEK_SET, MYF(MY_WME)) !=
opt_offset)
{
fprintf(stderr, "Can't set position %lld file: '%s' errno: %d\n",
@@ -9283,7 +9296,7 @@ int main(int argc, char **argv)
opt_pages;
opt_offset+= TRANSLOG_PAGE_SIZE, opt_pages--)
{
- if (my_pread(handler, buffer, TRANSLOG_PAGE_SIZE, opt_offset,
+ if (mysql_file_pread(handler, buffer, TRANSLOG_PAGE_SIZE, opt_offset,
MYF(MY_NABP)))
{
if (my_errno == HA_ERR_FILE_TOO_SHORT)
diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c
index 1a341110125..0784a567b45 100644
--- a/storage/maria/ma_open.c
+++ b/storage/maria/ma_open.c
@@ -162,7 +162,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, const char *name,
goto err;
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
info.read_record= share->read_record;
share->reopen++;
share->write_flag=MYF(MY_NABP | MY_WAIT_IF_FULL);
@@ -189,7 +189,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, const char *name,
}
info.state_start= info.state; /* Initial values */
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
/* Allocate buffer for one record */
/* prerequisites: info->rec_buffer == 0 && info->rec_buff_size == 0 */
@@ -221,7 +221,7 @@ err:
/* fall through */
case 5:
if (data_file < 0)
- my_close(info.dfile.file, MYF(0));
+ mysql_file_close(info.dfile.file, MYF(0));
break;
}
my_errno=save_errno;
@@ -234,11 +234,11 @@ err:
MARIA_HA *maria_clone(MARIA_SHARE *share, int mode)
{
MARIA_HA *new_info;
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
new_info= maria_clone_internal(share, NullS, mode,
share->data_file_type == BLOCK_RECORD ?
share->bitmap.file.file : -1);
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
return new_info;
}
@@ -287,7 +287,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
DBUG_RETURN(0);
}
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
old_info= 0;
if ((open_flags & HA_OPEN_COPY) ||
!(old_info=_ma_test_if_reopen(name_buff)))
@@ -305,16 +305,18 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
my_errno= HA_ERR_CRASHED;
goto err;
});
- if ((kfile=my_open(name_buff,(open_mode=O_RDWR) | O_SHARE,MYF(0))) < 0)
+ if ((kfile=mysql_file_open(key_file_kfile, name_buff,
+ (open_mode=O_RDWR) | O_SHARE,MYF(0))) < 0)
{
if ((errno != EROFS && errno != EACCES) ||
mode != O_RDONLY ||
- (kfile=my_open(name_buff,(open_mode=O_RDONLY) | O_SHARE,MYF(0))) < 0)
+ (kfile=mysql_file_open(key_file_kfile, name_buff,
+ (open_mode=O_RDONLY) | O_SHARE,MYF(0))) < 0)
goto err;
}
share->mode=open_mode;
errpos= 1;
- if (my_pread(kfile,share->state.header.file_version, head_length, 0,
+ if (mysql_file_pread(kfile,share->state.header.file_version, head_length, 0,
MYF(MY_NABP)))
{
my_errno= HA_ERR_NOT_A_TABLE;
@@ -381,7 +383,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
end_pos=disk_cache+info_length;
errpos= 3;
- if (my_pread(kfile, disk_cache, info_length, 0L, MYF(MY_NABP)))
+ if (mysql_file_pread(kfile, disk_cache, info_length, 0L, MYF(MY_NABP)))
{
my_errno=HA_ERR_CRASHED;
goto err;
@@ -536,7 +538,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
&share->open_file_name.str,
share->open_file_name.length+1,
&share->state.key_root,keys*sizeof(my_off_t),
- &share->mmap_lock,sizeof(rw_lock_t),
+ &share->mmap_lock,sizeof(mysql_rwlock_t),
NullS))
goto err;
errpos= 4;
@@ -837,13 +839,17 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
}
}
thr_lock_init(&share->lock);
- pthread_mutex_init(&share->intern_lock, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&share->key_del_lock, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&share->key_del_cond, 0);
- pthread_mutex_init(&share->close_lock, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(key_SHARE_intern_lock,
+ &share->intern_lock, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(key_SHARE_key_del_lock,
+ &share->key_del_lock, MY_MUTEX_INIT_FAST);
+ mysql_cond_init(key_SHARE_key_del_cond, &share->key_del_cond, 0);
+ mysql_mutex_init(key_SHARE_close_lock,
+ &share->close_lock, MY_MUTEX_INIT_FAST);
for (i=0; i<keys; i++)
- my_rwlock_init(&share->keyinfo[i].root_lock, NULL);
- my_rwlock_init(&share->mmap_lock, NULL);
+ mysql_rwlock_init(key_KEYINFO_root_lock,
+ &share->keyinfo[i].root_lock);
+ mysql_rwlock_init(key_SHARE_mmap_lock, &share->mmap_lock);
share->row_is_visible= _ma_row_visible_always;
share->lock.get_status= _ma_reset_update_flag;
@@ -926,7 +932,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
DBUG_PRINT("warning", ("table is crashed: changed: %u",
share->state.changed));
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
DBUG_RETURN(m_info);
err:
@@ -946,7 +952,7 @@ err:
switch (errpos) {
case 5:
if (data_file >= 0)
- my_close(data_file, MYF(0));
+ mysql_file_close(data_file, MYF(0));
if (old_info)
break; /* Don't remove open table */
(*share->once_end)(share);
@@ -958,13 +964,13 @@ err:
my_free(disk_cache);
/* fall through */
case 1:
- my_close(kfile,MYF(0));
+ mysql_file_close(kfile,MYF(0));
/* fall through */
case 0:
default:
break;
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
my_errno= save_errno;
DBUG_RETURN (NULL);
} /* maria_open */
@@ -1220,11 +1226,9 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite)
return 0;
if (pWrite & MA_STATE_INFO_WRITE_LOCK)
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
else if (maria_multi_threaded)
- {
- safe_mutex_assert_owner(&share->intern_lock);
- }
+ mysql_mutex_assert_owner(&share->intern_lock);
if (share->base.born_transactional && translog_status == TRANSLOG_OK &&
!maria_in_recovery)
{
@@ -1239,7 +1243,7 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite)
}
res= _ma_state_info_write_sub(share->kfile.file, &share->state, pWrite);
if (pWrite & MA_STATE_INFO_WRITE_LOCK)
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
share->changed= 0;
return res;
}
@@ -1338,9 +1342,9 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite)
}
res= (pWrite & MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET) ?
- my_pwrite(file, buff, (size_t) (ptr-buff), 0L,
+ mysql_file_pwrite(file, buff, (size_t) (ptr-buff), 0L,
MYF(MY_NABP | MY_THREADSAFE)) :
- my_write(file, buff, (size_t) (ptr-buff),
+ mysql_file_write(file, buff, (size_t) (ptr-buff),
MYF(MY_NABP));
DBUG_RETURN(res != 0);
}
@@ -1422,7 +1426,7 @@ uint _ma_state_info_read_dsk(File file __attribute__((unused)),
DBUG_ASSERT(state->create_rename_lsn == LSN_IMPOSSIBLE);
if (!maria_single_user)
{
- if (my_pread(file, buff, state->state_length, 0L, MYF(MY_NABP)))
+ if (mysql_file_pread(file, buff, state->state_length, 0L, MYF(MY_NABP)))
return 1;
_ma_state_info_read(buff, state);
}
@@ -1477,7 +1481,7 @@ uint _ma_base_info_write(File file, MARIA_BASE_INFO *base)
*ptr++= base->extra_alloc_procent;
bzero(ptr,16); ptr+= 16; /* extra */
DBUG_ASSERT((ptr - buff) == MARIA_BASE_INFO_SIZE);
- return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
+ return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
}
@@ -1539,7 +1543,7 @@ my_bool _ma_keydef_write(File file, MARIA_KEYDEF *keydef)
mi_int2store(ptr,keydef->keylength); ptr+= 2;
mi_int2store(ptr,keydef->minlength); ptr+= 2;
mi_int2store(ptr,keydef->maxlength); ptr+= 2;
- return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
+ return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
}
uchar *_ma_keydef_read(uchar *ptr, MARIA_KEYDEF *keydef)
@@ -1582,7 +1586,7 @@ my_bool _ma_keyseg_write(File file, const HA_KEYSEG *keyseg)
mi_int4store(ptr, pos);
ptr+=4;
- return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
+ return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
}
@@ -1622,7 +1626,7 @@ my_bool _ma_uniquedef_write(File file, MARIA_UNIQUEDEF *def)
*ptr++= (uchar) def->key;
*ptr++ = (uchar) def->null_are_equal;
- return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
+ return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
}
uchar *_ma_uniquedef_read(uchar *ptr, MARIA_UNIQUEDEF *def)
@@ -1653,7 +1657,7 @@ my_bool _ma_columndef_write(File file, MARIA_COLUMNDEF *columndef)
(*ptr++)= columndef->null_bit;
(*ptr++)= columndef->empty_bit;
ptr[0]= ptr[1]= ptr[2]= ptr[3]= 0; ptr+= 4; /* For future */
- return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
+ return mysql_file_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
}
uchar *_ma_columndef_read(uchar *ptr, MARIA_COLUMNDEF *columndef)
@@ -1681,7 +1685,7 @@ my_bool _ma_column_nr_write(File file, uint16 *offsets, uint columns)
return 1;
for (ptr= buff, end= ptr + size; ptr < end ; ptr+= 2, offsets++)
int2store(ptr, *offsets);
- res= my_write(file, buff, size, MYF(MY_NABP)) != 0;
+ res= mysql_file_write(file, buff, size, MYF(MY_NABP)) != 0;
my_afree(buff);
return res;
}
@@ -1793,8 +1797,8 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share, const char *org_name,
}
info->dfile.file= share->bitmap.file.file=
- my_open(share->data_file_name.str, share->mode | O_SHARE,
- MYF(MY_WME));
+ mysql_file_open(key_file_dfile, share->data_file_name.str,
+ share->mode | O_SHARE, MYF(MY_WME));
return info->dfile.file >= 0 ? 0 : 1;
}
@@ -1805,11 +1809,12 @@ int _ma_open_keyfile(MARIA_SHARE *share)
Modifications to share->kfile should be under intern_lock to protect
against a concurrent checkpoint.
*/
- pthread_mutex_lock(&share->intern_lock);
- share->kfile.file= my_open(share->unique_file_name.str,
- share->mode | O_SHARE,
+ mysql_mutex_lock(&share->intern_lock);
+ share->kfile.file= mysql_file_open(key_file_kfile,
+ share->unique_file_name.str,
+ share->mode | O_SHARE,
MYF(MY_WME));
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
return (share->kfile.file < 0);
}
diff --git a/storage/maria/ma_packrec.c b/storage/maria/ma_packrec.c
index 00433426cb7..ed4ecd0258d 100644
--- a/storage/maria/ma_packrec.c
+++ b/storage/maria/ma_packrec.c
@@ -184,7 +184,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file,
maria_quick_table_bits=MAX_QUICK_TABLE_BITS;
my_errno=0;
- if (my_read(file, header, sizeof(header), MYF(MY_NABP)))
+ if (mysql_file_read(file, header, sizeof(header), MYF(MY_NABP)))
{
if (!my_errno)
my_errno=HA_ERR_END_OF_FILE;
@@ -252,7 +252,7 @@ static my_bool _ma_read_pack_info(MARIA_SHARE *share, File file,
tmp_buff=share->decode_tables+length;
disk_cache=(uchar*) (tmp_buff+OFFSET_TABLE_SIZE);
- if (my_read(file,disk_cache,
+ if (mysql_file_read(file,disk_cache,
(uint) (share->pack.header_length-sizeof(header)),
MYF(MY_NABP)))
goto err2;
@@ -752,7 +752,7 @@ int _ma_read_pack_record(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS filepos)
&info->rec_buff, &info->rec_buff_size, file,
filepos))
goto err;
- if (my_read(file, info->rec_buff + block_info.offset ,
+ if (mysql_file_read(file, info->rec_buff + block_info.offset ,
block_info.rec_len - block_info.offset, MYF(MY_NABP)))
goto panic;
info->update|= HA_STATE_AKTIV;
@@ -1385,7 +1385,7 @@ int _ma_read_rnd_pack_record(MARIA_HA *info,
}
else
{
- if (my_read(info->dfile.file, info->rec_buff + block_info.offset,
+ if (mysql_file_read(info->dfile.file, info->rec_buff + block_info.offset,
block_info.rec_len-block_info.offset,
MYF(MY_NABP)))
goto err;
@@ -1420,8 +1420,8 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
We can't use my_pread() here because _ma_read_rnd_pack_record assumes
position is ok
*/
- my_seek(file,filepos,MY_SEEK_SET,MYF(0));
- if (my_read(file, header,ref_length,MYF(MY_NABP)))
+ mysql_file_seek(file,filepos,MY_SEEK_SET,MYF(0));
+ if (mysql_file_read(file, header,ref_length,MYF(MY_NABP)))
return BLOCK_FATAL_ERROR;
DBUG_DUMP("header", header, ref_length);
}
@@ -1546,7 +1546,7 @@ my_bool _ma_memmap_file(MARIA_HA *info)
if (!info->s->file_map)
{
- if (my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0)) <
+ if (mysql_file_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0)) <
share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN)
{
DBUG_PRINT("warning",("File isn't extended for memmap"));
diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c
index a4423133270..6cca2fed559 100644
--- a/storage/maria/ma_page.c
+++ b/storage/maria/ma_page.c
@@ -394,18 +394,18 @@ my_off_t _ma_new(register MARIA_HA *info, int level,
if (_ma_lock_key_del(info, 1))
{
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
pos= share->state.state.key_file_length;
if (pos >= share->base.max_key_file_length - block_size)
{
my_errno=HA_ERR_INDEX_FILE_FULL;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
DBUG_RETURN(HA_OFFSET_ERROR);
}
share->state.state.key_file_length+= block_size;
/* Following is for not transactional tables */
info->state->key_file_length= share->state.state.key_file_length;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
(*page_link)->changed= 0;
(*page_link)->write_lock= PAGECACHE_LOCK_WRITE;
}
diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c
index 5d192f9cfc2..02d98cf1e66 100644
--- a/storage/maria/ma_pagecache.c
+++ b/storage/maria/ma_pagecache.c
@@ -639,7 +639,7 @@ static my_bool pagecache_fwrite(PAGECACHE *pagecache,
flags - MYF() flags
*/
#define pagecache_fread(pagecache, filedesc, buffer, pageno, flags) \
- my_pread((filedesc)->file, buffer, pagecache->block_size, \
+ mysql_file_pread((filedesc)->file, buffer, pagecache->block_size, \
((my_off_t) pageno << pagecache->shift), flags)
@@ -720,7 +720,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
pagecache->disk_blocks= -1;
if (! pagecache->inited)
{
- if (mysql_mutex_init(ma_key_mutex_PAGECACHE_cache_lock,
+ if (mysql_mutex_init(key_PAGECACHE_cache_lock,
&pagecache->cache_lock, MY_MUTEX_INIT_FAST) ||
my_hash_init(&pagecache->files_in_flush, &my_charset_bin, 32,
offsetof(struct st_file_in_flush, file),
diff --git a/storage/maria/ma_panic.c b/storage/maria/ma_panic.c
index a86563f31fb..f3380e9b68e 100644
--- a/storage/maria/ma_panic.c
+++ b/storage/maria/ma_panic.c
@@ -45,7 +45,7 @@ int maria_panic(enum ha_panic_function flag)
if (!maria_inited)
DBUG_RETURN(0);
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
for (list_element=maria_open_list ; list_element ; list_element=next_open)
{
next_open=list_element->next; /* Save if close */
@@ -57,10 +57,10 @@ int maria_panic(enum ha_panic_function flag)
happen in MySQL), as we release the mutex, the list may change and so
we may crash.
*/
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
if (maria_close(info))
error=my_errno;
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
break;
case HA_PANIC_WRITE: /* Do this to free databases */
#ifdef CANT_OPEN_FILES_TWICE
@@ -87,9 +87,9 @@ int maria_panic(enum ha_panic_function flag)
error=my_errno;
}
#ifdef CANT_OPEN_FILES_TWICE
- if (info->s->kfile.file >= 0 && my_close(info->s->kfile.file, MYF(0)))
+ if (info->s->kfile.file >= 0 && mysql_file_close(info->s->kfile.file, MYF(0)))
error = my_errno;
- if (info->dfile.file >= 0 && my_close(info->dfile.file, MYF(0)))
+ if (info->dfile.file >= 0 && mysql_file_close(info->dfile.file, MYF(0)))
error = my_errno;
info->s->kfile.file= info->dfile.file= -1;/* Files aren't open anymore */
break;
@@ -102,19 +102,18 @@ int maria_panic(enum ha_panic_function flag)
if (share->kfile.file < 0)
{
- if ((share->kfile.file= my_open(fn_format(name_buff,
- info->filename, "",
- N_NAME_IEXT,4),
- info->mode,
- MYF(MY_WME))) < 0)
+ if ((share->kfile.file= mysql_file_open(key_file_kfile,
+ fn_format(name_buff, info->filename, "",
+ N_NAME_IEXT,4),
+ info->mode, MYF(MY_WME))) < 0)
error = my_errno;
}
if (info->dfile.file < 0)
{
- if ((info->dfile.file= my_open(fn_format(name_buff, info->filename,
- "", N_NAME_DEXT, 4),
- info->mode,
- MYF(MY_WME))) < 0)
+ if ((info->dfile.file= mysql_file_open(key_file_dfile,
+ fn_format(name_buff, info->filename,
+ "", N_NAME_DEXT, 4),
+ info->mode, MYF(MY_WME))) < 0)
error = my_errno;
info->rec_cache.file= info->dfile.file;
}
@@ -131,7 +130,7 @@ int maria_panic(enum ha_panic_function flag)
break;
}
}
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
if (flag == HA_PANIC_CLOSE)
maria_end();
if (!error)
diff --git a/storage/maria/ma_range.c b/storage/maria/ma_range.c
index 5dc4e3a9959..bb72c10bba7 100644
--- a/storage/maria/ma_range.c
+++ b/storage/maria/ma_range.c
@@ -60,7 +60,7 @@ ha_rows maria_records_in_range(MARIA_HA *info, int inx, key_range *min_key,
info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED);
keyinfo= share->keyinfo + inx;
if (share->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ mysql_rwlock_rdlock(&keyinfo->root_lock);
switch (keyinfo->key_alg) {
#ifdef HAVE_RTREE_KEYS
@@ -109,7 +109,7 @@ ha_rows maria_records_in_range(MARIA_HA *info, int inx, key_range *min_key,
}
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
fast_ma_writeinfo(info);
/**
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index b473bb14995..4e1e3dd0608 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -864,15 +864,16 @@ prototype_redo_exec_hook(REDO_CREATE_TABLE)
linkname_ptr= NULL;
create_flag= MY_DELETE_OLD;
tprint(tracef, "Table '%s' creating as '%s'\n", name, filename);
- if ((kfile= my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
- MYF(MY_WME|create_flag))) < 0)
+ if ((kfile= mysql_file_create_with_symlink(key_file_kfile, linkname_ptr,
+ filename, 0, create_mode,
+ MYF(MY_WME|create_flag))) < 0)
{
eprint(tracef, "Failed to create index file");
goto end;
}
if (my_pwrite(kfile, kfile_header,
kfile_size_before_extension, 0, MYF(MY_NABP|MY_WME)) ||
- my_chsize(kfile, keystart, 0, MYF(MY_WME)))
+ mysql_file_chsize(kfile, keystart, 0, MYF(MY_WME)))
{
eprint(tracef, "Failed to write to index file");
goto end;
@@ -884,9 +885,10 @@ prototype_redo_exec_hook(REDO_CREATE_TABLE)
linkname_ptr= NULL;
create_flag=MY_DELETE_OLD;
if (((dfile=
- my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
- MYF(MY_WME | create_flag))) < 0) ||
- my_close(dfile, MYF(MY_WME)))
+ mysql_file_create_with_symlink(key_file_dfile, linkname_ptr,
+ filename, 0, create_mode,
+ MYF(MY_WME | create_flag))) < 0) ||
+ mysql_file_close(dfile, MYF(MY_WME)))
{
eprint(tracef, "Failed to create data file");
goto end;
@@ -907,7 +909,7 @@ prototype_redo_exec_hook(REDO_CREATE_TABLE)
error= 0;
end:
if (kfile >= 0)
- error|= my_close(kfile, MYF(MY_WME));
+ error|= mysql_file_close(kfile, MYF(MY_WME));
if (info != NULL)
error|= maria_close(info);
DBUG_RETURN(error);
@@ -1387,8 +1389,8 @@ static int new_table(uint16 sid, const char *name, LSN lsn_of_file_id)
/* don't log any records for this work */
_ma_tmp_disable_logging_for_table(info, FALSE);
/* execution of some REDO records relies on data_file_length */
- dfile_len= my_seek(info->dfile.file, 0, SEEK_END, MYF(MY_WME));
- kfile_len= my_seek(info->s->kfile.file, 0, SEEK_END, MYF(MY_WME));
+ dfile_len= mysql_file_seek(info->dfile.file, 0, SEEK_END, MYF(MY_WME));
+ kfile_len= mysql_file_seek(info->s->kfile.file, 0, SEEK_END, MYF(MY_WME));
if ((dfile_len == MY_FILEPOS_ERROR) ||
(kfile_len == MY_FILEPOS_ERROR))
{
@@ -3341,7 +3343,7 @@ static int close_all_tables(void)
TRANSLOG_ADDRESS addr;
DBUG_ENTER("close_all_tables");
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
if (maria_open_list == NULL)
goto end;
tprint(tracef, "Closing all tables\n");
@@ -3372,7 +3374,7 @@ static int close_all_tables(void)
break;
next_open= list_element->next;
info= (MARIA_HA*)list_element->data;
- pthread_mutex_unlock(&THR_LOCK_maria); /* ok, UNDO phase not online yet */
+ mysql_mutex_unlock(&THR_LOCK_maria); /* ok, UNDO phase not online yet */
/*
Tables which we see here are exactly those which were open at time of
crash. They might have open_count>0 as Checkpoint maybe flushed their
@@ -3387,10 +3389,10 @@ static int close_all_tables(void)
}
prepare_table_for_close(info, addr);
error|= maria_close(info);
- pthread_mutex_lock(&THR_LOCK_maria);
+ mysql_mutex_lock(&THR_LOCK_maria);
}
end:
- pthread_mutex_unlock(&THR_LOCK_maria);
+ mysql_mutex_unlock(&THR_LOCK_maria);
DBUG_RETURN(error);
}
diff --git a/storage/maria/ma_rename.c b/storage/maria/ma_rename.c
index 380f3da3c46..7db397617d4 100644
--- a/storage/maria/ma_rename.c
+++ b/storage/maria/ma_rename.c
@@ -107,18 +107,14 @@ int maria_rename(const char *old_name, const char *new_name)
fn_format(from,old_name,"",MARIA_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
fn_format(to,new_name,"",MARIA_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
- if (my_rename_with_symlink(from, to, MYF(MY_WME | sync_dir)))
+ if (mysql_file_rename_with_symlink(key_file_kfile, from, to,
+ MYF(MY_WME | sync_dir)))
DBUG_RETURN(my_errno);
fn_format(from,old_name,"",MARIA_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
fn_format(to,new_name,"",MARIA_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
-#ifdef USE_RAID
- if (raid_type)
- data_file_rename_error= my_raid_rename(from, to, raid_chunks,
- MYF(MY_WME | sync_dir));
- else
-#endif
- data_file_rename_error=
- my_rename_with_symlink(from, to, MYF(MY_WME | sync_dir));
+ data_file_rename_error=
+ mysql_file_rename_with_symlink(key_file_dfile, from, to,
+ MYF(MY_WME | sync_dir));
if (data_file_rename_error)
{
/*
@@ -128,7 +124,8 @@ int maria_rename(const char *old_name, const char *new_name)
data_file_rename_error= my_errno;
fn_format(from, old_name, "", MARIA_NAME_IEXT, MYF(MY_UNPACK_FILENAME|MY_APPEND_EXT));
fn_format(to, new_name, "", MARIA_NAME_IEXT, MYF(MY_UNPACK_FILENAME|MY_APPEND_EXT));
- my_rename_with_symlink(to, from, MYF(MY_WME | sync_dir));
+ mysql_file_rename_with_symlink(key_file_kfile, to, from,
+ MYF(MY_WME | sync_dir));
}
DBUG_RETURN(data_file_rename_error);
diff --git a/storage/maria/ma_rkey.c b/storage/maria/ma_rkey.c
index 24b275d0ba6..3df7f1b9941 100644
--- a/storage/maria/ma_rkey.c
+++ b/storage/maria/ma_rkey.c
@@ -80,7 +80,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data,
if (fast_ma_readinfo(info))
goto err;
if (share->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ mysql_rwlock_rdlock(&keyinfo->root_lock);
nextflag= maria_read_vec[search_flag] | key.flag;
if (search_flag != HA_READ_KEY_EXACT ||
@@ -165,7 +165,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data,
}
}
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
if (info->cur_row.lastpos == HA_OFFSET_ERROR || (icp_res != 1))
{
diff --git a/storage/maria/ma_rnext.c b/storage/maria/ma_rnext.c
index bdba5ff3a17..9142921dbb5 100644
--- a/storage/maria/ma_rnext.c
+++ b/storage/maria/ma_rnext.c
@@ -44,7 +44,7 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx)
DBUG_RETURN(my_errno);
keyinfo= share->keyinfo + inx;
if (share->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ mysql_rwlock_rdlock(&keyinfo->root_lock);
changed= _ma_test_if_changed(info);
if (!flag)
{
@@ -102,7 +102,7 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx)
}
}
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
/* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
diff --git a/storage/maria/ma_rnext_same.c b/storage/maria/ma_rnext_same.c
index f67a76a366f..5822e8787e1 100644
--- a/storage/maria/ma_rnext_same.c
+++ b/storage/maria/ma_rnext_same.c
@@ -41,7 +41,7 @@ int maria_rnext_same(MARIA_HA *info, uchar *buf)
keyinfo= info->s->keyinfo+inx;
if (info->s->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ mysql_rwlock_rdlock(&keyinfo->root_lock);
switch (keyinfo->key_alg) {
#ifdef HAVE_RTREE_KEYS
@@ -87,7 +87,7 @@ int maria_rnext_same(MARIA_HA *info, uchar *buf)
}
}
if (info->s->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
/* Don't clear if database-changed */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_NEXT_FOUND | HA_STATE_RNEXT_SAME;
diff --git a/storage/maria/ma_rprev.c b/storage/maria/ma_rprev.c
index b9f46d7c405..f64e875c2ba 100644
--- a/storage/maria/ma_rprev.c
+++ b/storage/maria/ma_rprev.c
@@ -42,7 +42,7 @@ int maria_rprev(MARIA_HA *info, uchar *buf, int inx)
keyinfo= share->keyinfo + inx;
changed= _ma_test_if_changed(info);
if (share->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ mysql_rwlock_rdlock(&keyinfo->root_lock);
if (!flag)
error= _ma_search_last(info, keyinfo, share->state.key_root[inx]);
else if (!changed)
@@ -65,7 +65,7 @@ int maria_rprev(MARIA_HA *info, uchar *buf, int inx)
}
}
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
info->update|= HA_STATE_PREV_FOUND;
if (error)
diff --git a/storage/maria/ma_rsame.c b/storage/maria/ma_rsame.c
index 9ddd487a8a3..c20faf965b4 100644
--- a/storage/maria/ma_rsame.c
+++ b/storage/maria/ma_rsame.c
@@ -62,11 +62,11 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx)
info->cur_row.lastpos,
info->cur_row.trid);
if (info->s->lock_key_trees)
- rw_rdlock(&keyinfo->root_lock);
+ mysql_rwlock_rdlock(&keyinfo->root_lock);
_ma_search(info, &info->last_key, SEARCH_SAME,
info->s->state.key_root[inx]);
if (info->s->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
}
if (!(*info->read_record)(info, record, info->cur_row.lastpos))
diff --git a/storage/maria/ma_servicethread.c b/storage/maria/ma_servicethread.c
index a8099c998e9..06abaa88ea1 100644
--- a/storage/maria/ma_servicethread.c
+++ b/storage/maria/ma_servicethread.c
@@ -18,8 +18,10 @@ int ma_service_thread_control_init(MA_SERVICE_THREAD_CONTROL *control)
DBUG_PRINT("init", ("control 0x%lx", (ulong) control));
control->inited= TRUE;
control->status= THREAD_DEAD; /* not yet born == dead */
- res= (pthread_mutex_init(control->LOCK_control, MY_MUTEX_INIT_SLOW) ||
- pthread_cond_init(control->COND_control, 0));
+ res= (mysql_mutex_init(key_SERVICE_THREAD_CONTROL_lock,
+ control->LOCK_control, MY_MUTEX_INIT_SLOW) ||
+ mysql_cond_init(key_SERVICE_THREAD_CONTROL_cond,
+ control->COND_control, 0));
DBUG_PRINT("info", ("init: %s", (res ? "Error" : "OK")));
DBUG_RETURN(res);
}
@@ -41,7 +43,7 @@ void ma_service_thread_control_end(MA_SERVICE_THREAD_CONTROL *control)
DBUG_ENTER("ma_service_thread_control_end");
DBUG_PRINT("init", ("control 0x%lx", (ulong) control));
DBUG_ASSERT(control->inited);
- pthread_mutex_lock(control->LOCK_control);
+ mysql_mutex_lock(control->LOCK_control);
if (control->status != THREAD_DEAD) /* thread was started OK */
{
DBUG_PRINT("info",("killing Maria background thread"));
@@ -49,15 +51,15 @@ void ma_service_thread_control_end(MA_SERVICE_THREAD_CONTROL *control)
do /* and wait for it to be dead */
{
/* wake it up if it was in a sleep */
- pthread_cond_broadcast(control->COND_control);
+ mysql_cond_broadcast(control->COND_control);
DBUG_PRINT("info",("waiting for Maria background thread to die"));
- pthread_cond_wait(control->COND_control, control->LOCK_control);
+ mysql_cond_wait(control->COND_control, control->LOCK_control);
}
while (control->status != THREAD_DEAD);
}
- pthread_mutex_unlock(control->LOCK_control);
- pthread_mutex_destroy(control->LOCK_control);
- pthread_cond_destroy(control->COND_control);
+ mysql_mutex_unlock(control->LOCK_control);
+ mysql_mutex_destroy(control->LOCK_control);
+ mysql_cond_destroy(control->COND_control);
control->inited= FALSE;
DBUG_VOID_RETURN;
}
@@ -81,29 +83,29 @@ my_bool my_service_thread_sleep(MA_SERVICE_THREAD_CONTROL *control,
my_bool res= FALSE;
DBUG_ENTER("my_service_thread_sleep");
DBUG_PRINT("init", ("control 0x%lx", (ulong) control));
- pthread_mutex_lock(control->LOCK_control);
+ mysql_mutex_lock(control->LOCK_control);
if (control->status == THREAD_DYING)
{
- pthread_mutex_unlock(control->LOCK_control);
+ mysql_mutex_unlock(control->LOCK_control);
DBUG_RETURN(TRUE);
}
#if 0 /* good for testing, to do a lot of checkpoints, finds a lot of bugs */
- pthread_mutex_unlock(&control->LOCK_control);
+ mysql_mutex_unlock(&control->LOCK_control);
my_sleep(100000); /* a tenth of a second */
- pthread_mutex_lock(&control->LOCK_control);
+ mysql_mutex_lock(&control->LOCK_control);
#else
/* To have a killable sleep, we use timedwait like our SQL GET_LOCK() */
DBUG_PRINT("info", ("sleeping %llu nano seconds", sleep_time));
if (sleep_time)
{
set_timespec_nsec(abstime, sleep_time);
- pthread_cond_timedwait(control->COND_control,
+ mysql_cond_timedwait(control->COND_control,
control->LOCK_control, &abstime);
}
#endif
if (control->status == THREAD_DYING)
res= TRUE;
- pthread_mutex_unlock(control->LOCK_control);
+ mysql_mutex_unlock(control->LOCK_control);
DBUG_RETURN(res);
}
@@ -118,17 +120,17 @@ void my_service_thread_signal_end(MA_SERVICE_THREAD_CONTROL *control)
{
DBUG_ENTER("my_service_thread_signal_end");
DBUG_PRINT("init", ("control 0x%lx", (ulong) control));
- pthread_mutex_lock(control->LOCK_control);
+ mysql_mutex_lock(control->LOCK_control);
control->status = THREAD_DEAD; /* indicate that we are dead */
/*
wake up ma_service_thread_control_end which may be waiting for
our death
*/
- pthread_cond_broadcast(control->COND_control);
+ mysql_cond_broadcast(control->COND_control);
/*
broadcast was inside unlock because ma_service_thread_control_end
destroys mutex
*/
- pthread_mutex_unlock(control->LOCK_control);
+ mysql_mutex_unlock(control->LOCK_control);
DBUG_VOID_RETURN;
}
diff --git a/storage/maria/ma_servicethread.h b/storage/maria/ma_servicethread.h
index 153ff9ebd14..246e2302d0f 100644
--- a/storage/maria/ma_servicethread.h
+++ b/storage/maria/ma_servicethread.h
@@ -9,9 +9,9 @@ typedef struct st_ma_service_thread_control
/** if thread module was inited or not */
my_bool inited;
/** for killing the background thread */
- pthread_mutex_t *LOCK_control;
+ mysql_mutex_t *LOCK_control;
/** for killing the background thread */
- pthread_cond_t *COND_control;
+ mysql_cond_t *COND_control;
} MA_SERVICE_THREAD_CONTROL;
diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c
index c40e4ed6fed..0a4259d0cb3 100644
--- a/storage/maria/ma_sort.c
+++ b/storage/maria/ma_sort.c
@@ -482,10 +482,10 @@ ok:
if (sort_param->read_cache.share)
remove_io_thread(&sort_param->read_cache);
- pthread_mutex_lock(&sort_param->sort_info->mutex);
+ mysql_mutex_lock(&sort_param->sort_info->mutex);
if (!--sort_param->sort_info->threads_running)
- pthread_cond_signal(&sort_param->sort_info->cond);
- pthread_mutex_unlock(&sort_param->sort_info->mutex);
+ mysql_cond_signal(&sort_param->sort_info->cond);
+ mysql_mutex_unlock(&sort_param->sort_info->mutex);
DBUG_PRINT("exit", ("======== ending thread ========"));
}
my_thread_end();
@@ -833,7 +833,7 @@ static uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
{
- if (my_pread(fromfile->file, buffpek->base,
+ if (mysql_file_pread(fromfile->file, buffpek->base,
(length= sort_length*count),buffpek->file_pos,MYF_RW))
return((uint) -1); /* purecov: inspected */
buffpek->key=buffpek->base;
@@ -858,11 +858,11 @@ static uint read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
for (idx=1;idx<=count;idx++)
{
uint16 length_of_key;
- if (my_pread(fromfile->file,(uchar*)&length_of_key,sizeof(length_of_key),
+ if (mysql_file_pread(fromfile->file,(uchar*)&length_of_key,sizeof(length_of_key),
buffpek->file_pos,MYF_RW))
return((uint) -1);
buffpek->file_pos+=sizeof(length_of_key);
- if (my_pread(fromfile->file, buffp, length_of_key,
+ if (mysql_file_pread(fromfile->file, buffp, length_of_key,
buffpek->file_pos,MYF_RW))
return((uint) -1);
buffpek->file_pos+=length_of_key;
diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c
index 49ba5da6460..ca698bc7245 100644
--- a/storage/maria/ma_state.c
+++ b/storage/maria/ma_state.c
@@ -82,7 +82,7 @@ my_bool _ma_setup_live_state(MARIA_HA *info)
trn->used_tables= tables;
tables->share= share;
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
share->in_trans++;
DBUG_PRINT("info", ("share: 0x%lx in_trans: %d",
(ulong) share, share->in_trans));
@@ -98,7 +98,7 @@ my_bool _ma_setup_live_state(MARIA_HA *info)
*/
while (trn->trid <= history->trid)
history= history->next;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
/* The current item can't be deleted as it's the first one visible for us */
tables->state_start= tables->state_current= history->state;
tables->state_current.changed= tables->state_current.no_transid= 0;
@@ -215,10 +215,10 @@ void _ma_remove_not_visible_states_with_lock(MARIA_SHARE *share,
if ((is_lock_trman= trman_is_inited()))
trnman_lock();
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
share->state_history= _ma_remove_not_visible_states(share->state_history,
all, 1);
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
if (is_lock_trman)
trnman_unlock();
}
@@ -444,7 +444,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit,
{
MARIA_STATE_HISTORY *history;
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
/* We only have to update history state if something changed */
if (tables->state_current.changed)
@@ -476,7 +476,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit,
{
/* purecov: begin inspected */
error= 1;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
my_free(tables);
continue;
/* purecov: end */
@@ -512,7 +512,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit,
}
}
share->in_trans--;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
}
else
{
@@ -521,9 +521,9 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit,
We need to keep share->in_trans correct in the debug library
because of the assert in maria_close()
*/
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
share->in_trans--;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
#endif
}
my_free(tables);
@@ -550,7 +550,7 @@ void _ma_remove_table_from_trnman(MARIA_SHARE *share, TRN *trn)
DBUG_PRINT("enter", ("share: 0x%lx in_trans: %d",
(ulong) share, share->in_trans));
- safe_mutex_assert_owner(&share->intern_lock);
+ mysql_mutex_assert_owner(&share->intern_lock);
for (prev= (MARIA_USED_TABLES**) (char*) &trn->used_tables, tables= *prev;
tables;
@@ -712,10 +712,10 @@ void maria_versioning(MARIA_HA *info, my_bool versioning)
void _ma_set_share_data_file_length(MARIA_SHARE *share, ulonglong new_length)
{
- pthread_mutex_lock(&share->intern_lock);
+ mysql_mutex_lock(&share->intern_lock);
if (share->state.state.data_file_length < new_length)
share->state.state.data_file_length= new_length;
- pthread_mutex_unlock(&share->intern_lock);
+ mysql_mutex_unlock(&share->intern_lock);
}
diff --git a/storage/maria/ma_static.c b/storage/maria/ma_static.c
index ea911ac4a8a..19f7cfa4ea2 100644
--- a/storage/maria/ma_static.c
+++ b/storage/maria/ma_static.c
@@ -38,7 +38,7 @@ my_bool maria_delay_key_write= 0, maria_page_checksums= 1;
my_bool maria_inited= FALSE;
my_bool maria_in_ha_maria= FALSE; /* If used from ha_maria or not */
my_bool maria_recovery_changed_data= 0, maria_recovery_verbose= 0;
-pthread_mutex_t THR_LOCK_maria;
+mysql_mutex_t THR_LOCK_maria;
#ifdef DONT_USE_RW_LOCKS
ulong maria_concurrent_insert= 0;
#else
@@ -109,23 +109,36 @@ static int always_valid(const char *filename __attribute__((unused)))
int (*maria_test_invalid_symlink)(const char *filename)= always_valid;
#ifdef HAVE_PSI_INTERFACE
-PSI_mutex_key ma_key_mutex_PAGECACHE_cache_lock;
-static PSI_mutex_info all_mutexes[]=
-{
- { &ma_key_mutex_PAGECACHE_cache_lock, "PAGECACHE::cache_lock", 0}
-};
-
-void init_aria_psi_keys()
-{
- const char* category= "aria";
- int count;
-
- if (PSI_server == NULL)
- return;
+PSI_mutex_key key_SHARE_BITMAP_lock, key_SORT_INFO_mutex,
+ key_THR_LOCK_maria, key_TRANSLOG_BUFFER_mutex,
+ key_LOCK_soft_sync,
+ key_TRANSLOG_DESCRIPTOR_dirty_buffer_mask_lock,
+ key_TRANSLOG_DESCRIPTOR_sent_to_disk_lock,
+ key_TRANSLOG_DESCRIPTOR_log_flush_lock,
+ key_TRANSLOG_DESCRIPTOR_file_header_lock,
+ key_TRANSLOG_DESCRIPTOR_unfinished_files_lock,
+ key_TRANSLOG_DESCRIPTOR_purger_lock,
+ key_SHARE_intern_lock, key_SHARE_key_del_lock,
+ key_SHARE_close_lock, key_PAGECACHE_cache_lock,
+ key_SERVICE_THREAD_CONTROL_lock,
+ key_LOCK_trn_list, key_TRN_state_lock;
+
+PSI_cond_key key_SHARE_key_del_cond, key_SERVICE_THREAD_CONTROL_cond,
+ key_SORT_INFO_cond, key_SHARE_BITMAP_cond,
+ key_COND_soft_sync, key_TRANSLOG_BUFFER_waiting_filling_buffer,
+ key_TRANSLOG_BUFFER_prev_sent_to_disk_cond,
+ key_TRANSLOG_DESCRIPTOR_log_flush_cond,
+ key_TRANSLOG_DESCRIPTOR_new_goal_cond;
+
+PSI_rwlock_key key_KEYINFO_root_lock, key_SHARE_mmap_lock,
+ key_TRANSLOG_DESCRIPTOR_open_files_lock;
+
+PSI_thread_key key_thread_checkpoint, key_thread_find_all_keys,
+ key_thread_soft_sync;
+
+PSI_file_key key_file_translog, key_file_kfile, key_file_dfile,
+ key_file_control;
- count= array_elements(all_mutexes);
- PSI_server->register_mutex(category, all_mutexes, count);
-}
#endif /* HAVE_PSI_INTERFACE */
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index b52c00ec91a..9fdbc9e8a98 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -161,7 +161,7 @@ int maria_write(MARIA_HA *info, uchar *record)
is_tree_inited(&info->bulk_insert[i])));
if (local_lock_tree)
{
- rw_wrlock(&keyinfo->root_lock);
+ mysql_rwlock_wrlock(&keyinfo->root_lock);
keyinfo->version++;
}
if (keyinfo->flag & HA_FULLTEXT )
@@ -169,7 +169,7 @@ int maria_write(MARIA_HA *info, uchar *record)
if (_ma_ft_add(info,i, buff,record,filepos))
{
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
}
@@ -196,7 +196,7 @@ int maria_write(MARIA_HA *info, uchar *record)
if (info->dup_key_trid == info->trn->trid ||
my_errno != HA_ERR_FOUND_DUPP_KEY)
{
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
goto err;
}
/* Different TrIDs: table must be transactional */
@@ -219,11 +219,11 @@ int maria_write(MARIA_HA *info, uchar *record)
if (!blocker || blocker->commit_trid != ~(TrID)0)
{ /* committed */
if (blocker)
- pthread_mutex_unlock(& blocker->state_lock);
- rw_unlock(&keyinfo->root_lock);
+ mysql_mutex_unlock(& blocker->state_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
goto err;
}
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
{
/* running. now we wait */
WT_RESOURCE_ID rc;
@@ -236,7 +236,7 @@ int maria_write(MARIA_HA *info, uchar *record)
res= wt_thd_will_wait_for(info->trn->wt, blocker->wt, & rc);
if (res != WT_OK)
{
- pthread_mutex_unlock(& blocker->state_lock);
+ mysql_mutex_unlock(& blocker->state_lock);
my_errno= HA_ERR_LOCK_DEADLOCK;
goto err;
}
@@ -246,7 +246,7 @@ int maria_write(MARIA_HA *info, uchar *record)
res= wt_thd_cond_timedwait(info->trn->wt, & blocker->state_lock);
proc_info_hook(0, old_proc_info, __func__, __FILE__, __LINE__);
- pthread_mutex_unlock(& blocker->state_lock);
+ mysql_mutex_unlock(& blocker->state_lock);
if (res != WT_OK)
{
my_errno= res == WT_TIMEOUT ? HA_ERR_LOCK_WAIT_TIMEOUT
@@ -254,7 +254,7 @@ int maria_write(MARIA_HA *info, uchar *record)
goto err;
}
}
- rw_wrlock(&keyinfo->root_lock);
+ mysql_rwlock_wrlock(&keyinfo->root_lock);
#ifndef MARIA_CANNOT_ROLLBACK
keyinfo->version++;
#endif
@@ -265,7 +265,7 @@ int maria_write(MARIA_HA *info, uchar *record)
info->update&= ~HA_STATE_RNEXT_SAME;
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
}
}
if (share->calc_write_checksum)
@@ -347,7 +347,7 @@ err:
is_tree_inited(&info->bulk_insert[i])));
keyinfo= share->keyinfo + i;
if (local_lock_tree)
- rw_wrlock(&keyinfo->root_lock);
+ mysql_rwlock_wrlock(&keyinfo->root_lock);
/**
@todo RECOVERY BUG
The key deletes below should generate CLR_ENDs
@@ -357,7 +357,7 @@ err:
if (_ma_ft_del(info,i,buff,record,filepos))
{
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
break;
}
}
@@ -369,12 +369,12 @@ err:
filepos, info->trn->trid)))
{
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
break;
}
}
if (local_lock_tree)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
}
}
}
@@ -1671,7 +1671,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
case free_init:
if (share->lock_key_trees)
{
- rw_wrlock(&keyinfo->root_lock);
+ mysql_rwlock_wrlock(&keyinfo->root_lock);
keyinfo->version++;
}
return 0;
@@ -1692,7 +1692,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
return _ma_ck_write_btree(param->info, &tmp_key);
case free_end:
if (share->lock_key_trees)
- rw_unlock(&keyinfo->root_lock);
+ mysql_rwlock_unlock(&keyinfo->root_lock);
return 0;
}
return 1;
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index aa8af02ca17..ef65a9eb3af 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -26,6 +26,7 @@
#include "ma_control_file.h"
#include "ma_state.h"
#include <waiting_threads.h>
+#include <mysql/psi/mysql_file.h>
/* For testing recovery */
#ifdef TO_BE_REMOVED
@@ -246,8 +247,8 @@ typedef struct st_maria_file_bitmap
uint non_flushable; /**< 0 if bitmap and log are in sync */
PAGECACHE_FILE file; /* datafile where bitmap is stored */
- pthread_mutex_t bitmap_lock;
- pthread_cond_t bitmap_cond; /**< When bitmap becomes flushable */
+ mysql_mutex_t bitmap_lock;
+ mysql_cond_t bitmap_cond; /**< When bitmap becomes flushable */
/* Constants, allocated when initiating bitmaps */
uint sizes[8]; /* Size per bit combination */
uint total_size; /* Total usable size of bitmap page */
@@ -395,20 +396,20 @@ typedef struct st_maria_share
versioning information (like in_trans, state_history).
@todo find the exhaustive list.
*/
- pthread_mutex_t intern_lock;
- pthread_mutex_t key_del_lock;
- pthread_cond_t key_del_cond;
+ mysql_mutex_t intern_lock;
+ mysql_mutex_t key_del_lock;
+ mysql_cond_t key_del_cond;
/**
_Always_ held while closing table; prevents checkpoint from looking at
structures freed during closure (like bitmap). If you need close_lock and
intern_lock, lock them in this order.
*/
- pthread_mutex_t close_lock;
+ mysql_mutex_t close_lock;
my_off_t mmaped_length;
uint nonmmaped_inserts; /* counter of writing in
non-mmaped area */
MARIA_FILE_BITMAP bitmap;
- rw_lock_t mmap_lock;
+ mysql_rwlock_t mmap_lock;
LSN lsn_of_file_id; /**< LSN of its last LOGREC_FILE_ID */
} MARIA_SHARE;
@@ -764,7 +765,7 @@ struct st_maria_handler
#define MARIA_UNIQUE_HASH_TYPE HA_KEYTYPE_ULONG_INT
#define maria_unique_store(A,B) mi_int4store((A),(B))
-extern pthread_mutex_t THR_LOCK_maria;
+extern mysql_mutex_t THR_LOCK_maria;
#ifdef DONT_USE_RW_LOCKS
#define rw_wrlock(A) {}
#define rw_rdlock(A) {}
@@ -795,6 +796,39 @@ extern my_bool maria_recovery_verbose;
extern HASH maria_stored_state;
extern int (*maria_create_trn_hook)(MARIA_HA *);
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_SHARE_BITMAP_lock, key_SORT_INFO_mutex,
+ key_THR_LOCK_maria, key_TRANSLOG_BUFFER_mutex,
+ key_LOCK_soft_sync,
+ key_TRANSLOG_DESCRIPTOR_dirty_buffer_mask_lock,
+ key_TRANSLOG_DESCRIPTOR_sent_to_disk_lock,
+ key_TRANSLOG_DESCRIPTOR_log_flush_lock,
+ key_TRANSLOG_DESCRIPTOR_file_header_lock,
+ key_TRANSLOG_DESCRIPTOR_unfinished_files_lock,
+ key_TRANSLOG_DESCRIPTOR_purger_lock,
+ key_SHARE_intern_lock, key_SHARE_key_del_lock,
+ key_SHARE_close_lock,
+ key_SERVICE_THREAD_CONTROL_lock,
+ key_PAGECACHE_cache_lock;
+
+extern PSI_cond_key key_SHARE_key_del_cond, key_SERVICE_THREAD_CONTROL_cond,
+ key_SORT_INFO_cond, key_SHARE_BITMAP_cond,
+ key_COND_soft_sync, key_TRANSLOG_BUFFER_waiting_filling_buffer,
+ key_TRANSLOG_BUFFER_prev_sent_to_disk_cond,
+ key_TRANSLOG_DESCRIPTOR_log_flush_cond,
+ key_TRANSLOG_DESCRIPTOR_new_goal_cond;
+
+extern PSI_rwlock_key key_KEYINFO_root_lock, key_SHARE_mmap_lock,
+ key_TRANSLOG_DESCRIPTOR_open_files_lock;
+
+extern PSI_thread_key key_thread_checkpoint, key_thread_find_all_keys,
+ key_thread_soft_sync;
+
+extern PSI_file_key key_file_translog, key_file_kfile, key_file_dfile,
+ key_file_control;
+
+#endif
+
/* This is used by _ma_calc_xxx_key_length och _ma_store_key */
typedef struct st_maria_s_param
{
@@ -1250,17 +1284,3 @@ extern void ma_set_index_cond_func(MARIA_HA *info, index_cond_func_t func,
void *func_arg);
int ma_check_index_cond(register MARIA_HA *info, uint keynr, uchar *record);
-#ifdef HAVE_PSI_INTERFACE
-extern PSI_mutex_key ma_key_mutex_PAGECACHE_cache_lock;
-
-//extern PSI_rwlock_key mi_key_rwlock_MYISAM_SHARE_key_root_lock;
-
-//extern PSI_cond_key mi_key_cond_MI_SORT_INFO_cond;
-
-//extern PSI_file_key mi_key_file_datatmp;
-
-//extern PSI_thread_key mi_key_thread_find_all_keys;
-
-void init_aria_psi_keys();
-#endif /* HAVE_PSI_INTERFACE */
-
diff --git a/storage/maria/tablockman.c b/storage/maria/tablockman.c
index 8e664b261e9..e4fede54425 100644
--- a/storage/maria/tablockman.c
+++ b/storage/maria/tablockman.c
@@ -280,7 +280,7 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo,
DBUG_ASSERT(lo->waiting_for == 0);
DBUG_ASSERT(lo->waiting_for_loid == 0);
- pthread_mutex_lock(& table->mutex);
+ mysql_mutex_lock(& table->mutex);
/* do we already have a lock on this resource ? */
old= find_by_loid(table, lo->loid);
@@ -296,16 +296,16 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo,
}
/* no, placing a new lock. first - take a free lock structure from the pool */
- pthread_mutex_lock(& lm->pool_mutex);
+ mysql_mutex_lock(& lm->pool_mutex);
new= lm->pool;
if (new)
{
lm->pool= new->next;
- pthread_mutex_unlock(& lm->pool_mutex);
+ mysql_mutex_unlock(& lm->pool_mutex);
}
else
{
- pthread_mutex_unlock(& lm->pool_mutex);
+ mysql_mutex_unlock(& lm->pool_mutex);
new= (TABLE_LOCK *)my_malloc(sizeof(*new), MYF(MY_WME));
if (unlikely(!new))
{
@@ -441,13 +441,13 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo,
and we must release table's mutex.
note that blocker's mutex is locked _before_ table's mutex is released
*/
- pthread_mutex_lock(wait_for->mutex);
- pthread_mutex_unlock(& table->mutex);
+ mysql_mutex_lock(wait_for->mutex);
+ mysql_mutex_unlock(& table->mutex);
/* now really wait */
i= pthread_cond_timedwait(wait_for->cond, wait_for->mutex, & timeout);
- pthread_mutex_unlock(wait_for->mutex);
+ mysql_mutex_unlock(wait_for->mutex);
if (i == ETIMEDOUT || i == ETIME)
{
@@ -456,7 +456,7 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo,
goto ret2;
}
- pthread_mutex_lock(& table->mutex);
+ mysql_mutex_lock(& table->mutex);
/* ... and repeat from the beginning */
}
@@ -491,7 +491,7 @@ tablockman_getlock(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo,
res= getlock_result[lock][lock];
ret:
- pthread_mutex_unlock(& table->mutex);
+ mysql_mutex_unlock(& table->mutex);
ret2:
DBUG_ASSERT(res);
return res;
@@ -518,7 +518,7 @@ void tablockman_release_locks(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo)
if ((lock= lo->waiting_lock))
{
DBUG_ASSERT(lock->loid == lo->loid);
- pthread_mutex_lock(& lock->table->mutex);
+ mysql_mutex_lock(& lock->table->mutex);
remove_from_wait_queue(lock, lock->table);
/*
@@ -542,13 +542,13 @@ void tablockman_release_locks(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo)
if (lock->next &&
lock_compatibility_matrix[lock->next->lock_type][lock->lock_type])
{
- pthread_mutex_lock(lo->waiting_for->mutex);
+ mysql_mutex_lock(lo->waiting_for->mutex);
pthread_cond_broadcast(lo->waiting_for->cond);
- pthread_mutex_unlock(lo->waiting_for->mutex);
+ mysql_mutex_unlock(lo->waiting_for->mutex);
}
lo->waiting_for= 0;
lo->waiting_for_loid= 0;
- pthread_mutex_unlock(& lock->table->mutex);
+ mysql_mutex_unlock(& lock->table->mutex);
lock->next= local_pool;
local_pool= lock;
@@ -559,14 +559,14 @@ void tablockman_release_locks(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo)
while (lock)
{
TABLE_LOCK *cur= lock;
- pthread_mutex_t *mutex= & lock->table->mutex;
+ mysql_mutex_t *mutex= & lock->table->mutex;
DBUG_ASSERT(cur->loid == lo->loid);
DBUG_ASSERT(lock != lock->next_in_lo);
lock= lock->next_in_lo;
/* TODO ? group locks by table to reduce the number of mutex locks */
- pthread_mutex_lock(mutex);
+ mysql_mutex_lock(mutex);
my_hash_delete(& cur->table->latest_locks, (uchar *)cur);
if (cur->prev)
@@ -579,7 +579,7 @@ void tablockman_release_locks(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo)
cur->next= local_pool;
local_pool= cur;
- pthread_mutex_unlock(mutex);
+ mysql_mutex_unlock(mutex);
}
lo->waiting_lock= lo->active_locks= 0;
@@ -588,15 +588,15 @@ void tablockman_release_locks(TABLOCKMAN *lm, TABLE_LOCK_OWNER *lo)
okay, all locks released. now signal that we're leaving,
in case somebody's waiting for it
*/
- pthread_mutex_lock(lo->mutex);
+ mysql_mutex_lock(lo->mutex);
pthread_cond_broadcast(lo->cond);
- pthread_mutex_unlock(lo->mutex);
+ mysql_mutex_unlock(lo->mutex);
/* and push all freed locks to the lockman's pool */
- pthread_mutex_lock(& lm->pool_mutex);
+ mysql_mutex_lock(& lm->pool_mutex);
local_pool_end->next= lm->pool;
lm->pool= local_pool;
- pthread_mutex_unlock(& lm->pool_mutex);
+ mysql_mutex_unlock(& lm->pool_mutex);
}
void tablockman_init(TABLOCKMAN *lm, loid_to_tlo_func *func, uint timeout)
@@ -604,7 +604,7 @@ void tablockman_init(TABLOCKMAN *lm, loid_to_tlo_func *func, uint timeout)
lm->pool= 0;
lm->loid_to_tlo= func;
lm->lock_timeout= timeout;
- pthread_mutex_init(& lm->pool_mutex, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(& lm->pool_mutex, MY_MUTEX_INIT_FAST);
my_getsystime(); /* ensure that my_getsystime() is initialized */
}
@@ -616,7 +616,7 @@ void tablockman_destroy(TABLOCKMAN *lm)
lm->pool= tmp->next;
my_free(tmp);
}
- pthread_mutex_destroy(& lm->pool_mutex);
+ mysql_mutex_destroy(& lm->pool_mutex);
}
/*
@@ -629,7 +629,7 @@ void tablockman_destroy(TABLOCKMAN *lm)
void tablockman_init_locked_table(LOCKED_TABLE *lt, int initial_hash_size)
{
bzero(lt, sizeof(*lt));
- pthread_mutex_init(& lt->mutex, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(& lt->mutex, MY_MUTEX_INIT_FAST);
my_hash_init(& lt->latest_locks, & my_charset_bin, initial_hash_size,
offsetof(TABLE_LOCK, loid),
sizeof(((TABLE_LOCK*)0)->loid), 0, 0, 0);
@@ -646,7 +646,7 @@ void tablockman_destroy_locked_table(LOCKED_TABLE *lt)
DBUG_ASSERT(lt->active_locks[i] == 0);
my_hash_free(& lt->latest_locks);
- pthread_mutex_destroy(& lt->mutex);
+ mysql_mutex_destroy(& lt->mutex);
}
#ifdef EXTRA_DEBUG
diff --git a/storage/maria/tablockman.h b/storage/maria/tablockman.h
index e33d1aa44e8..0ccf92aa0a3 100644
--- a/storage/maria/tablockman.h
+++ b/storage/maria/tablockman.h
@@ -51,12 +51,12 @@ typedef struct st_table_lock_owner {
TABLE_LOCK *waiting_lock; /* waiting lock (one lock only) */
struct st_table_lock_owner *waiting_for; /* transaction we're waiting for */
pthread_cond_t *cond; /* transactions waiting for us, wait on 'cond' */
- pthread_mutex_t *mutex; /* mutex is required to use 'cond' */
+ mysql_mutex_t *mutex; /* mutex is required to use 'cond' */
uint16 loid, waiting_for_loid; /* Lock Owner IDentifier */
} TABLE_LOCK_OWNER;
typedef struct st_locked_table {
- pthread_mutex_t mutex; /* mutex for everything below */
+ mysql_mutex_t mutex; /* mutex for everything below */
HASH latest_locks; /* latest locks in a hash */
TABLE_LOCK *active_locks[LOCK_TYPES]; /* dl-list of locks per type */
TABLE_LOCK *wait_queue_in, *wait_queue_out; /* wait deque (double-end queue)*/
@@ -65,7 +65,7 @@ typedef struct st_locked_table {
typedef TABLE_LOCK_OWNER *loid_to_tlo_func(uint16);
typedef struct {
- pthread_mutex_t pool_mutex;
+ mysql_mutex_t pool_mutex;
TABLE_LOCK *pool; /* lifo pool of free locks */
uint lock_timeout; /* lock timeout in milliseconds */
loid_to_tlo_func *loid_to_tlo; /* for mapping loid to TABLE_LOCK_OWNER */
diff --git a/storage/maria/trnman.c b/storage/maria/trnman.c
index 4a0088a2617..0f02976dbb4 100644
--- a/storage/maria/trnman.c
+++ b/storage/maria/trnman.c
@@ -45,7 +45,7 @@ static TrID global_trid_generator;
static TrID trid_min_read_from= MAX_TRID;
/* the mutex for everything above */
-static pthread_mutex_t LOCK_trn_list;
+static mysql_mutex_t LOCK_trn_list;
/* LIFO pool of unused TRN structured for reuse */
static TRN *pool;
@@ -185,8 +185,8 @@ int trnman_init(TrID initial_trid)
trid_min_read_from= initial_trid;
lf_hash_init(&trid_to_trn, sizeof(TRN*), LF_HASH_UNIQUE,
0, 0, trn_get_hash_key, 0);
- DBUG_PRINT("info", ("pthread_mutex_init LOCK_trn_list"));
- pthread_mutex_init(&LOCK_trn_list, MY_MUTEX_INIT_FAST);
+ DBUG_PRINT("info", ("mysql_mutex_init LOCK_trn_list"));
+ mysql_mutex_init(key_LOCK_trn_list, &LOCK_trn_list, MY_MUTEX_INIT_FAST);
my_atomic_rwlock_init(&LOCK_short_trid_to_trn);
my_atomic_rwlock_init(&LOCK_pool);
@@ -216,12 +216,12 @@ void trnman_destroy()
TRN *trn= pool;
pool= pool->next;
DBUG_ASSERT(trn->wt == NULL);
- pthread_mutex_destroy(&trn->state_lock);
+ mysql_mutex_destroy(&trn->state_lock);
my_free(trn);
}
lf_hash_destroy(&trid_to_trn);
- DBUG_PRINT("info", ("pthread_mutex_destroy LOCK_trn_list"));
- pthread_mutex_destroy(&LOCK_trn_list);
+ DBUG_PRINT("info", ("mysql_mutex_destroy LOCK_trn_list"));
+ mysql_mutex_destroy(&LOCK_trn_list);
my_atomic_rwlock_destroy(&LOCK_short_trid_to_trn);
my_atomic_rwlock_destroy(&LOCK_pool);
my_free(short_trid_to_active_trn+1);
@@ -240,8 +240,8 @@ static TrID new_trid()
{
DBUG_ENTER("new_trid");
DBUG_ASSERT(global_trid_generator < 0xffffffffffffLL);
- DBUG_PRINT("info", ("safe_mutex_assert_owner LOCK_trn_list"));
- safe_mutex_assert_owner(&LOCK_trn_list);
+ DBUG_PRINT("info", ("mysql_mutex_assert_owner LOCK_trn_list"));
+ mysql_mutex_assert_owner(&LOCK_trn_list);
DBUG_RETURN(++global_trid_generator);
}
@@ -293,8 +293,8 @@ TRN *trnman_new_trn(WT_THD *wt)
mutex.
*/
- DBUG_PRINT("info", ("pthread_mutex_lock LOCK_trn_list"));
- pthread_mutex_lock(&LOCK_trn_list);
+ DBUG_PRINT("info", ("mysql_mutex_lock LOCK_trn_list"));
+ mysql_mutex_lock(&LOCK_trn_list);
/* Allocating a new TRN structure */
tmp.trn= pool;
@@ -320,19 +320,19 @@ TRN *trnman_new_trn(WT_THD *wt)
trn= (TRN *)my_malloc(sizeof(TRN), MYF(MY_WME | MY_ZEROFILL));
if (unlikely(!trn))
{
- DBUG_PRINT("info", ("pthread_mutex_unlock LOCK_trn_list"));
- pthread_mutex_unlock(&LOCK_trn_list);
+ DBUG_PRINT("info", ("mysql_mutex_unlock LOCK_trn_list"));
+ mysql_mutex_unlock(&LOCK_trn_list);
return 0;
}
trnman_allocated_transactions++;
- pthread_mutex_init(&trn->state_lock, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(key_TRN_state_lock, &trn->state_lock, MY_MUTEX_INIT_FAST);
}
trn->wt= wt;
trn->pins= lf_hash_get_pins(&trid_to_trn);
if (!trn->pins)
{
trnman_free_trn(trn);
- pthread_mutex_unlock(&LOCK_trn_list);
+ mysql_mutex_unlock(&LOCK_trn_list);
return 0;
}
@@ -346,8 +346,8 @@ TRN *trnman_new_trn(WT_THD *wt)
trn->prev= active_list_max.prev;
active_list_max.prev= trn->prev->next= trn;
trid_min_read_from= active_list_min.next->min_read_from;
- DBUG_PRINT("info", ("pthread_mutex_unlock LOCK_trn_list"));
- pthread_mutex_unlock(&LOCK_trn_list);
+ DBUG_PRINT("info", ("mysql_mutex_unlock LOCK_trn_list"));
+ mysql_mutex_unlock(&LOCK_trn_list);
if (unlikely(!trn->min_read_from))
{
@@ -370,9 +370,9 @@ TRN *trnman_new_trn(WT_THD *wt)
only after the following function TRN is considered initialized,
so it must be done the last
*/
- pthread_mutex_lock(&trn->state_lock);
+ mysql_mutex_lock(&trn->state_lock);
trn->short_id= get_short_trid(trn);
- pthread_mutex_unlock(&trn->state_lock);
+ mysql_mutex_unlock(&trn->state_lock);
res= lf_hash_insert(&trid_to_trn, trn->pins, &trn);
DBUG_ASSERT(res <= 0);
@@ -417,9 +417,9 @@ my_bool trnman_end_trn(TRN *trn, my_bool commit)
/* if a rollback, all UNDO records should have been executed */
DBUG_ASSERT(commit || trn->undo_lsn == 0);
DBUG_ASSERT(trn != &dummy_transaction_object);
- DBUG_PRINT("info", ("pthread_mutex_lock LOCK_trn_list"));
+ DBUG_PRINT("info", ("mysql_mutex_lock LOCK_trn_list"));
- pthread_mutex_lock(&LOCK_trn_list);
+ mysql_mutex_lock(&LOCK_trn_list);
/* remove from active list */
trn->next->prev= trn->prev;
@@ -451,11 +451,11 @@ my_bool trnman_end_trn(TRN *trn, my_bool commit)
}
}
- pthread_mutex_lock(&trn->state_lock);
+ mysql_mutex_lock(&trn->state_lock);
if (commit)
trn->commit_trid= global_trid_generator;
wt_thd_release_self(trn);
- pthread_mutex_unlock(&trn->state_lock);
+ mysql_mutex_unlock(&trn->state_lock);
/*
if transaction is committed and it was not the only active transaction -
@@ -480,8 +480,8 @@ my_bool trnman_end_trn(TRN *trn, my_bool commit)
res= -1;
trnman_active_transactions--;
- DBUG_PRINT("info", ("pthread_mutex_unlock LOCK_trn_list"));
- pthread_mutex_unlock(&LOCK_trn_list);
+ DBUG_PRINT("info", ("mysql_mutex_unlock LOCK_trn_list"));
+ mysql_mutex_unlock(&LOCK_trn_list);
/*
the rest is done outside of a critical section
@@ -535,9 +535,9 @@ static void trnman_free_trn(TRN *trn)
*/
union { TRN *trn; void *v; } tmp;
- pthread_mutex_lock(&trn->state_lock);
+ mysql_mutex_lock(&trn->state_lock);
trn->short_id= 0;
- pthread_mutex_unlock(&trn->state_lock);
+ mysql_mutex_unlock(&trn->state_lock);
tmp.trn= pool;
@@ -627,11 +627,11 @@ TRN *trnman_trid_to_trn(TRN *trn, TrID trid)
return 0; /* no luck */
/* we've found something */
- pthread_mutex_lock(&(*found)->state_lock);
+ mysql_mutex_lock(&(*found)->state_lock);
if ((*found)->short_id == 0)
{
- pthread_mutex_unlock(&(*found)->state_lock);
+ mysql_mutex_unlock(&(*found)->state_lock);
lf_hash_search_unpin(trn->pins);
return 0; /* but it was a ghost */
}
@@ -688,7 +688,7 @@ my_bool trnman_collect_transactions(LEX_STRING *str_act, LEX_STRING *str_com,
/* validate the use of read_non_atomic() in general: */
compile_time_assert((sizeof(LSN) == 8) && (sizeof(LSN_WITH_FLAGS) == 8));
- pthread_mutex_lock(&LOCK_trn_list);
+ mysql_mutex_lock(&LOCK_trn_list);
str_act->length= 2 + /* number of active transactions */
LSN_STORE_SIZE + /* minimum of their rec_lsn */
TRANSID_SIZE + /* current TrID generator value */
@@ -718,9 +718,9 @@ my_bool trnman_collect_transactions(LEX_STRING *str_act, LEX_STRING *str_com,
{
uint sid;
LSN rec_lsn, undo_lsn, first_undo_lsn;
- pthread_mutex_lock(&trn->state_lock);
+ mysql_mutex_lock(&trn->state_lock);
sid= trn->short_id;
- pthread_mutex_unlock(&trn->state_lock);
+ mysql_mutex_unlock(&trn->state_lock);
if (sid == 0)
{
/*
@@ -814,7 +814,7 @@ my_bool trnman_collect_transactions(LEX_STRING *str_act, LEX_STRING *str_com,
err:
error= 1;
end:
- pthread_mutex_unlock(&LOCK_trn_list);
+ mysql_mutex_unlock(&LOCK_trn_list);
DBUG_RETURN(error);
}
@@ -872,10 +872,10 @@ TrID trnman_get_min_trid()
TrID trnman_get_min_safe_trid()
{
TrID trid;
- pthread_mutex_lock(&LOCK_trn_list);
+ mysql_mutex_lock(&LOCK_trn_list);
trid= min(active_list_min.next->min_read_from,
global_trid_generator);
- pthread_mutex_unlock(&LOCK_trn_list);
+ mysql_mutex_unlock(&LOCK_trn_list);
return trid;
}
@@ -889,9 +889,9 @@ TrID trnman_get_max_trid()
TrID id;
if (short_trid_to_active_trn == NULL)
return 0;
- pthread_mutex_lock(&LOCK_trn_list);
+ mysql_mutex_lock(&LOCK_trn_list);
id= global_trid_generator;
- pthread_mutex_unlock(&LOCK_trn_list);
+ mysql_mutex_unlock(&LOCK_trn_list);
return id;
}
@@ -917,8 +917,8 @@ my_bool trnman_exists_active_transactions(TrID min_id, TrID max_id,
my_bool ret= 0;
if (!trnman_is_locked)
- pthread_mutex_lock(&LOCK_trn_list);
- safe_mutex_assert_owner(&LOCK_trn_list);
+ mysql_mutex_lock(&LOCK_trn_list);
+ mysql_mutex_assert_owner(&LOCK_trn_list);
for (trn= active_list_min.next; trn != &active_list_max; trn= trn->next)
{
/*
@@ -944,7 +944,7 @@ my_bool trnman_exists_active_transactions(TrID min_id, TrID max_id,
}
}
if (!trnman_is_locked)
- pthread_mutex_unlock(&LOCK_trn_list);
+ mysql_mutex_unlock(&LOCK_trn_list);
return ret;
}
@@ -955,7 +955,7 @@ my_bool trnman_exists_active_transactions(TrID min_id, TrID max_id,
void trnman_lock()
{
- pthread_mutex_lock(&LOCK_trn_list);
+ mysql_mutex_lock(&LOCK_trn_list);
}
@@ -965,7 +965,7 @@ void trnman_lock()
void trnman_unlock()
{
- pthread_mutex_unlock(&LOCK_trn_list);
+ mysql_mutex_unlock(&LOCK_trn_list);
}
diff --git a/storage/maria/trnman.h b/storage/maria/trnman.h
index afe01d4ad10..f28345908f2 100644
--- a/storage/maria/trnman.h
+++ b/storage/maria/trnman.h
@@ -45,7 +45,7 @@ struct st_ma_transaction
{
LF_PINS *pins;
WT_THD *wt;
- pthread_mutex_t state_lock;
+ mysql_mutex_t state_lock;
void *used_tables; /**< Tables used by transaction */
TRN *next, *prev;
TrID trid, min_read_from, commit_trid;
@@ -61,6 +61,10 @@ struct st_ma_transaction
extern WT_RESOURCE_TYPE ma_rc_dup_unique;
+#ifdef HAVE_PSI_INTERFACE
+extern PSI_mutex_key key_LOCK_trn_list, key_TRN_state_lock;
+#endif
+
C_MODE_END
#endif