MDEV-21382 fix compilation without perfschema plugin

This commit is contained in:
Eugene Kosov 2020-01-08 22:53:03 +07:00
commit 3a3605f4b1
2 changed files with 25 additions and 8 deletions

View file

@ -1141,6 +1141,9 @@ to original un-instrumented file I/O APIs */
# define os_file_flush(file) os_file_flush_func(file)
#define os_file_flush_data(file) \
pfs_os_file_flush_data_func(file, __FILE__, __LINE__)
# define os_file_rename(key, oldpath, newpath) \
os_file_rename_func(oldpath, newpath)
@ -1220,6 +1223,14 @@ bool
os_file_flush_func(
os_file_t file);
/** NOTE! Use the corresponding macro os_file_flush_data(), not directly this
function!
Flushes only(!) data (excluding metadata) from OS page cache of a given file to
the disk.
@param[in] file handle to a file
@return true if success */
bool os_file_flush_data_func(os_file_t file);
/** Retrieves the last error number if an error occurs in a file io function.
The number should be retrieved before any other OS calls (because they may
overwrite the error number). If the number is not known to this program,

View file

@ -4615,6 +4615,18 @@ os_normalize_path(
}
}
bool os_file_flush_data_func(os_file_t file) {
#ifdef _WIN32
return os_file_flush_func(file);
#else
bool success= fdatasync(file) != -1;
if (!success) {
ib::error() << "fdatasync() errno: " << errno;
}
return success;
#endif
}
bool pfs_os_file_flush_data_func(pfs_os_file_t file, const char *src_file,
uint src_line)
{
@ -4624,14 +4636,8 @@ bool pfs_os_file_flush_data_func(pfs_os_file_t file, const char *src_file,
register_pfs_file_io_begin(&state, locker, file, 0, PSI_FILE_SYNC, src_file,
src_line);
#ifdef _WIN32
bool result= os_file_flush_func(file);
#else
bool result= true;
if (fdatasync(file) == -1)
ib::error() << "fdatasync() errno: " << errno;
#endif
bool success= os_file_flush_data_func(file);
register_pfs_file_io_end(locker, 0);
return result;
return success;
}