Commit 22b6d848 authored by Sergei Golubchik's avatar Sergei Golubchik

perfschema file instrumentation related changes

parent 7c58e97b
......@@ -508,6 +508,8 @@ typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
extern my_error_reporter my_charset_error_reporter;
extern PSI_file_key key_file_io_cache;
/* inline functions for mf_iocache */
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
......@@ -800,6 +802,10 @@ my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,
enum cache_type type,my_off_t seek_offset,
my_bool use_async_io, myf cache_myflags);
extern int init_io_cache_ext(IO_CACHE *info, File file, size_t cachesize,
enum cache_type type, my_off_t seek_offset,
pbool use_async_io, myf cache_myflags,
PSI_file_key file_key);
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
my_off_t seek_offset, my_bool use_async_io,
my_bool clear_cache);
......
......@@ -55,6 +55,9 @@
static void my_aiowait(my_aio_result *result);
#endif
#include <errno.h>
#include "mysql/psi/mysql_file.h"
PSI_file_key key_file_io_cache;
#define lock_append_buffer(info) \
mysql_mutex_lock(&(info)->append_buffer_lock)
......@@ -131,7 +134,7 @@ init_functions(IO_CACHE* info)
Initialize an IO_CACHE object
SYNOPSOS
init_io_cache()
init_io_cache_ext()
info cache handler to initialize
file File that should be associated to to the handler
If == -1 then real_open_cached_file()
......@@ -144,20 +147,22 @@ init_functions(IO_CACHE* info)
cache_myflags Bitmap of different flags
MY_WME | MY_FAE | MY_NABP | MY_FNABP |
MY_DONT_CHECK_FILESIZE
file_key Instrumented file key for temporary cache file
RETURN
0 ok
# error
*/
int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
enum cache_type type, my_off_t seek_offset,
my_bool use_async_io, myf cache_myflags)
int init_io_cache_ext(IO_CACHE *info, File file, size_t cachesize,
enum cache_type type, my_off_t seek_offset,
pbool use_async_io, myf cache_myflags,
PSI_file_key file_key)
{
size_t min_cache;
my_off_t pos;
my_off_t end_of_file= ~(my_off_t) 0;
DBUG_ENTER("init_io_cache");
DBUG_ENTER("init_io_cache_ext");
DBUG_PRINT("enter",("cache:%p type: %d pos: %llu",
info, (int) type, (ulonglong) seek_offset));
......@@ -260,7 +265,7 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
}
}
DBUG_PRINT("info",("init_io_cache: cachesize = %lu", (ulong) cachesize));
DBUG_PRINT("info",("init_io_cache_ext: cachesize = %lu", (ulong) cachesize));
info->read_length=info->buffer_length=cachesize;
info->myflags=cache_myflags & ~(MY_NABP | MY_FNABP);
info->request_pos= info->read_pos= info->write_pos = info->buffer;
......@@ -301,9 +306,15 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
info->inited=info->aio_result.pending=0;
#endif
DBUG_RETURN(0);
} /* init_io_cache */
}
int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
enum cache_type type, my_off_t seek_offset,
my_bool use_async_io, myf cache_myflags)
{
return init_io_cache_ext(info, file, cachesize, type, seek_offset,
use_async_io, cache_myflags, key_file_io_cache);
}
/*
Initialize the slave IO_CACHE to read the same file (and data)
......
......@@ -2413,8 +2413,8 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, const char **errmsg)
*errmsg = "Could not open log file";
goto err;
}
if (init_io_cache(log, file, (size_t)binlog_file_cache_size, READ_CACHE, 0, 0,
MYF(MY_WME|MY_DONT_CHECK_FILESIZE)))
if (init_io_cache_ext(log, file, (size_t)binlog_file_cache_size, READ_CACHE,
0, 0, MYF(MY_WME|MY_DONT_CHECK_FILESIZE), key_file_binlog_cache))
{
sql_print_error("Failed to create a cache on log (file '%s')",
log_file_name);
......@@ -3393,10 +3393,11 @@ bool MYSQL_BIN_LOG::open_index_file(const char *index_file_name_arg,
O_RDWR | O_CREAT | O_BINARY | O_CLOEXEC,
MYF(MY_WME))) < 0 ||
mysql_file_sync(index_file_nr, MYF(MY_WME)) ||
init_io_cache(&index_file, index_file_nr,
init_io_cache_ext(&index_file, index_file_nr,
IO_SIZE, WRITE_CACHE,
mysql_file_seek(index_file_nr, 0L, MY_SEEK_END, MYF(0)),
0, MYF(MY_WME | MY_WAIT_IF_FULL)) ||
0, MYF(MY_WME | MY_WAIT_IF_FULL),
m_key_file_log_index_cache) ||
DBUG_EVALUATE_IF("fault_injection_openning_index", 1, 0))
{
/*
......
......@@ -420,9 +420,9 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
/** The instrumentation key to use for @ COND_bin_log_updated */
PSI_cond_key m_key_bin_log_update;
/** The instrumentation key to use for opening the log file. */
PSI_file_key m_key_file_log;
PSI_file_key m_key_file_log, m_key_file_log_cache;
/** The instrumentation key to use for opening the log index file. */
PSI_file_key m_key_file_log_index;
PSI_file_key m_key_file_log_index, m_key_file_log_index_cache;
PSI_cond_key m_key_COND_queue_busy;
/** The instrumentation key to use for LOCK_binlog_end_pos. */
......@@ -674,7 +674,9 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
PSI_cond_key key_relay_log_update,
PSI_cond_key key_bin_log_update,
PSI_file_key key_file_log,
PSI_file_key key_file_log_cache,
PSI_file_key key_file_log_index,
PSI_file_key key_file_log_index_cache,
PSI_cond_key key_COND_queue_busy,
PSI_mutex_key key_LOCK_binlog_end_pos)
{
......@@ -682,7 +684,9 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
m_key_relay_log_update= key_relay_log_update;
m_key_bin_log_update= key_bin_log_update;
m_key_file_log= key_file_log;
m_key_file_log_cache= key_file_log_cache;
m_key_file_log_index= key_file_log_index;
m_key_file_log_index_cache= key_file_log_index_cache;
m_key_COND_queue_busy= key_COND_queue_busy;
m_key_LOCK_binlog_end_pos= key_LOCK_binlog_end_pos;
}
......
......@@ -1105,7 +1105,8 @@ static PSI_thread_info all_server_threads[]=
PSI_file_key key_file_map;
#endif /* HAVE_MMAP */
PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
PSI_file_key key_file_binlog, key_file_binlog_cache, key_file_binlog_index,
key_file_binlog_index_cache, key_file_casetest,
key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
......@@ -1113,7 +1114,8 @@ PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
key_file_trg, key_file_trn, key_file_init;
PSI_file_key key_file_query_log, key_file_slow_log;
PSI_file_key key_file_relaylog, key_file_relaylog_index;
PSI_file_key key_file_relaylog, key_file_relaylog_index,
key_file_relaylog_cache, key_file_relaylog_index_cache;
PSI_file_key key_file_binlog_state;
#endif /* HAVE_PSI_INTERFACE */
......@@ -3794,7 +3796,9 @@ static int init_common_variables()
key_BINLOG_COND_relay_log_updated,
key_BINLOG_COND_bin_log_updated,
key_file_binlog,
key_file_binlog_cache,
key_file_binlog_index,
key_file_binlog_index_cache,
key_BINLOG_COND_queue_busy,
key_LOCK_binlog_end_pos);
#endif
......@@ -9112,9 +9116,14 @@ static PSI_file_info all_server_files[]=
{ &key_file_map, "map", 0},
#endif /* HAVE_MMAP */
{ &key_file_binlog, "binlog", 0},
{ &key_file_binlog_cache, "binlog_cache", 0},
{ &key_file_binlog_index, "binlog_index", 0},
{ &key_file_binlog_index_cache, "binlog_index_cache", 0},
{ &key_file_relaylog, "relaylog", 0},
{ &key_file_relaylog_cache, "relaylog_cache", 0},
{ &key_file_relaylog_index, "relaylog_index", 0},
{ &key_file_relaylog_index_cache, "relaylog_index_cache", 0},
{ &key_file_io_cache, "io_cache", 0},
{ &key_file_casetest, "casetest", 0},
{ &key_file_dbopt, "dbopt", 0},
{ &key_file_des_key_file, "des_key_file", 0},
......
......@@ -390,7 +390,8 @@ extern PSI_thread_key key_thread_delayed_insert,
key_thread_one_connection, key_thread_signal_hand,
key_thread_slave_background, key_rpl_parallel_thread;
extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
extern PSI_file_key key_file_binlog, key_file_binlog_cache,
key_file_binlog_index, key_file_binlog_index_cache, key_file_casetest,
key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
......@@ -398,7 +399,8 @@ extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
key_file_trg, key_file_trn, key_file_init;
extern PSI_file_key key_file_query_log, key_file_slow_log;
extern PSI_file_key key_file_relaylog, key_file_relaylog_index;
extern PSI_file_key key_file_relaylog, key_file_relaylog_index,
key_file_relaylog_cache, key_file_relaylog_index_cache;
extern PSI_socket_key key_socket_tcpip, key_socket_unix,
key_socket_client_connection;
extern PSI_file_key key_file_binlog_state;
......
......@@ -73,7 +73,9 @@ Relay_log_info::Relay_log_info(bool is_slave_recovery)
key_RELAYLOG_COND_relay_log_updated,
key_RELAYLOG_COND_bin_log_updated,
key_file_relaylog,
key_file_relaylog_cache,
key_file_relaylog_index,
key_file_relaylog_index_cache,
key_RELAYLOG_COND_queue_busy,
key_LOCK_relaylog_end_pos);
#endif
......
......@@ -644,10 +644,12 @@ do { \
register_pfs_file_open_begin(state, locker, key, op, name, \
src_file, src_line) \
# define register_pfs_file_rename_end(locker, result) \
# define register_pfs_file_rename_end(locker, from, to, result) \
do { \
if (locker != NULL) { \
PSI_FILE_CALL(end_file_open_wait)(locker, result); \
if (locker != NULL) { \
PSI_FILE_CALL( \
end_file_rename_wait)( \
locker, from, to, result); \
} \
} while (0)
......
......@@ -433,13 +433,13 @@ pfs_os_file_rename_func(
PSI_file_locker_state state;
struct PSI_file_locker* locker = NULL;
register_pfs_file_open_begin(
register_pfs_file_rename_begin(
&state, locker, key, PSI_FILE_RENAME, newpath,
src_file, src_line);
bool result = os_file_rename_func(oldpath, newpath);
register_pfs_file_rename_end(locker, 0);
register_pfs_file_rename_end(locker, oldpath, newpath, !result);
return(result);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment