Added reporting of fsync to THD wait interface
This commit is contained in:
parent
8fbf0e8817
commit
c0854c3e17
@ -633,6 +633,8 @@ extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
|
|||||||
extern int my_fclose(FILE *fd,myf MyFlags);
|
extern int my_fclose(FILE *fd,myf MyFlags);
|
||||||
extern File my_fileno(FILE *fd);
|
extern File my_fileno(FILE *fd);
|
||||||
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
|
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
|
||||||
|
void thr_set_sync_wait_callback(void (*before_sync)(void),
|
||||||
|
void (*after_sync)(void));
|
||||||
extern int my_sync(File fd, myf my_flags);
|
extern int my_sync(File fd, myf my_flags);
|
||||||
extern int my_sync_dir(const char *dir_name, myf my_flags);
|
extern int my_sync_dir(const char *dir_name, myf my_flags);
|
||||||
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
|
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
|
||||||
|
@ -42,7 +42,8 @@ typedef enum _thd_wait_type_e {
|
|||||||
THD_WAIT_USER_LOCK= 7,
|
THD_WAIT_USER_LOCK= 7,
|
||||||
THD_WAIT_BINLOG= 8,
|
THD_WAIT_BINLOG= 8,
|
||||||
THD_WAIT_GROUP_COMMIT= 9,
|
THD_WAIT_GROUP_COMMIT= 9,
|
||||||
THD_WAIT_LAST= 10
|
THD_WAIT_SYNC= 10,
|
||||||
|
THD_WAIT_LAST= 11
|
||||||
} thd_wait_type;
|
} thd_wait_type;
|
||||||
extern struct thd_wait_service_st {
|
extern struct thd_wait_service_st {
|
||||||
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
||||||
|
@ -42,7 +42,8 @@ typedef enum _thd_wait_type_e {
|
|||||||
THD_WAIT_USER_LOCK= 7,
|
THD_WAIT_USER_LOCK= 7,
|
||||||
THD_WAIT_BINLOG= 8,
|
THD_WAIT_BINLOG= 8,
|
||||||
THD_WAIT_GROUP_COMMIT= 9,
|
THD_WAIT_GROUP_COMMIT= 9,
|
||||||
THD_WAIT_LAST= 10
|
THD_WAIT_SYNC= 10,
|
||||||
|
THD_WAIT_LAST= 11
|
||||||
} thd_wait_type;
|
} thd_wait_type;
|
||||||
extern struct thd_wait_service_st {
|
extern struct thd_wait_service_st {
|
||||||
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
void (*thd_wait_begin_func)(void*, thd_wait_type);
|
||||||
|
@ -73,7 +73,8 @@ typedef enum _thd_wait_type_e {
|
|||||||
THD_WAIT_USER_LOCK= 7,
|
THD_WAIT_USER_LOCK= 7,
|
||||||
THD_WAIT_BINLOG= 8,
|
THD_WAIT_BINLOG= 8,
|
||||||
THD_WAIT_GROUP_COMMIT= 9,
|
THD_WAIT_GROUP_COMMIT= 9,
|
||||||
THD_WAIT_LAST= 10
|
THD_WAIT_SYNC= 10,
|
||||||
|
THD_WAIT_LAST= 11
|
||||||
} thd_wait_type;
|
} thd_wait_type;
|
||||||
|
|
||||||
extern struct thd_wait_service_st {
|
extern struct thd_wait_service_st {
|
||||||
|
@ -17,6 +17,16 @@
|
|||||||
#include "mysys_err.h"
|
#include "mysys_err.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
static void (*before_sync_wait)(void)= 0;
|
||||||
|
static void (*after_sync_wait)(void)= 0;
|
||||||
|
|
||||||
|
void thr_set_sync_wait_callback(void (*before_wait)(void),
|
||||||
|
void (*after_wait)(void))
|
||||||
|
{
|
||||||
|
before_sync_wait= before_wait;
|
||||||
|
after_sync_wait= after_wait;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sync data in file to disk
|
Sync data in file to disk
|
||||||
|
|
||||||
@ -48,6 +58,8 @@ int my_sync(File fd, myf my_flags)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
if (before_sync_wait)
|
||||||
|
(*before_sync_wait)();
|
||||||
#if defined(F_FULLFSYNC)
|
#if defined(F_FULLFSYNC)
|
||||||
/*
|
/*
|
||||||
In Mac OS X >= 10.3 this call is safer than fsync() (it forces the
|
In Mac OS X >= 10.3 this call is safer than fsync() (it forces the
|
||||||
@ -75,6 +87,8 @@ int my_sync(File fd, myf my_flags)
|
|||||||
int er= errno;
|
int er= errno;
|
||||||
if (!(my_errno= er))
|
if (!(my_errno= er))
|
||||||
my_errno= -1; /* Unknown error */
|
my_errno= -1; /* Unknown error */
|
||||||
|
if (after_sync_wait)
|
||||||
|
(*after_sync_wait)();
|
||||||
if ((my_flags & MY_IGNORE_BADFD) &&
|
if ((my_flags & MY_IGNORE_BADFD) &&
|
||||||
(er == EBADF || er == EINVAL || er == EROFS))
|
(er == EBADF || er == EINVAL || er == EROFS))
|
||||||
{
|
{
|
||||||
@ -84,6 +98,11 @@ int my_sync(File fd, myf my_flags)
|
|||||||
else if (my_flags & MY_WME)
|
else if (my_flags & MY_WME)
|
||||||
my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), my_filename(fd), my_errno);
|
my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), my_filename(fd), my_errno);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (after_sync_wait)
|
||||||
|
(*after_sync_wait)();
|
||||||
|
}
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
} /* my_sync */
|
} /* my_sync */
|
||||||
|
|
||||||
|
@ -80,12 +80,21 @@ scheduler_functions *thread_scheduler= NULL;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**@{*/
|
/**@{*/
|
||||||
static void scheduler_wait_begin(void) {
|
static void scheduler_wait_lock_begin(void) {
|
||||||
MYSQL_CALLBACK(thread_scheduler,
|
MYSQL_CALLBACK(thread_scheduler,
|
||||||
thd_wait_begin, (current_thd, THD_WAIT_TABLE_LOCK));
|
thd_wait_begin, (current_thd, THD_WAIT_TABLE_LOCK));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scheduler_wait_end(void) {
|
static void scheduler_wait_lock_end(void) {
|
||||||
|
MYSQL_CALLBACK(thread_scheduler, thd_wait_end, (current_thd));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void scheduler_wait_sync_begin(void) {
|
||||||
|
MYSQL_CALLBACK(thread_scheduler,
|
||||||
|
thd_wait_begin, (current_thd, THD_WAIT_TABLE_LOCK));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void scheduler_wait_sync_end(void) {
|
||||||
MYSQL_CALLBACK(thread_scheduler, thd_wait_end, (current_thd));
|
MYSQL_CALLBACK(thread_scheduler, thd_wait_end, (current_thd));
|
||||||
}
|
}
|
||||||
/**@}*/
|
/**@}*/
|
||||||
@ -98,7 +107,10 @@ static void scheduler_wait_end(void) {
|
|||||||
mysqld.cc, so this init function will always be called.
|
mysqld.cc, so this init function will always be called.
|
||||||
*/
|
*/
|
||||||
static void scheduler_init() {
|
static void scheduler_init() {
|
||||||
thr_set_lock_wait_callback(scheduler_wait_begin, scheduler_wait_end);
|
thr_set_lock_wait_callback(scheduler_wait_lock_begin,
|
||||||
|
scheduler_wait_lock_end);
|
||||||
|
thr_set_sync_wait_callback(scheduler_wait_sync_begin,
|
||||||
|
scheduler_wait_sync_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user