Commit 3a3605f4 authored by Eugene Kosov's avatar Eugene Kosov

MDEV-21382 fix compilation without perfschema plugin

parent 9cd6b230
...@@ -1141,6 +1141,9 @@ to original un-instrumented file I/O APIs */ ...@@ -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(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) \ # define os_file_rename(key, oldpath, newpath) \
os_file_rename_func(oldpath, newpath) os_file_rename_func(oldpath, newpath)
...@@ -1220,6 +1223,14 @@ bool ...@@ -1220,6 +1223,14 @@ bool
os_file_flush_func( os_file_flush_func(
os_file_t file); 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. /** 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 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, overwrite the error number). If the number is not known to this program,
......
...@@ -4615,6 +4615,18 @@ os_normalize_path( ...@@ -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, bool pfs_os_file_flush_data_func(pfs_os_file_t file, const char *src_file,
uint src_line) uint src_line)
{ {
...@@ -4624,14 +4636,8 @@ bool pfs_os_file_flush_data_func(pfs_os_file_t file, const char *src_file, ...@@ -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, register_pfs_file_io_begin(&state, locker, file, 0, PSI_FILE_SYNC, src_file,
src_line); src_line);
#ifdef _WIN32 bool success= os_file_flush_data_func(file);
bool result= os_file_flush_func(file);
#else
bool result= true;
if (fdatasync(file) == -1)
ib::error() << "fdatasync() errno: " << errno;
#endif
register_pfs_file_io_end(locker, 0); register_pfs_file_io_end(locker, 0);
return result; return success;
} }
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