MDEV-35171 OS_FILE_NORMAL and OS_FILE_AIO are misleading

Removed 'purpose' parameter from os_file_create() and related functions.
Always use FILE_FLAG_OVERLAPPED when opening Windows files.

No performance regression was measured, nor there is any measurable
improvement.
This commit is contained in:
Vladislav Vaintroub 2024-10-21 12:37:29 +02:00
parent 7701ccb72d
commit e8db5c8760
9 changed files with 16 additions and 80 deletions

View file

@ -3953,7 +3953,7 @@ static dberr_t xb_assign_undo_space_start()
ulint fsp_flags;
file = os_file_create(0, srv_sys_space.first_datafile()->filepath(),
OS_FILE_OPEN, OS_FILE_NORMAL, OS_DATA_FILE, true, &ret);
OS_FILE_OPEN, OS_DATA_FILE, true, &ret);
if (!ret) {
msg("Error opening %s", srv_sys_space.first_datafile()->filepath());

View file

@ -389,7 +389,7 @@ static bool fil_node_open_file_low(fil_node_t *node, const byte *page,
node->is_raw_disk
? OS_FILE_OPEN_RAW | OS_FILE_ON_ERROR_NO_EXIT
: OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_AIO, type,
type,
srv_read_only_mode, &success);
if (success && node->is_open())
@ -1999,7 +1999,7 @@ fil_ibd_create(
file = os_file_create(
innodb_data_file_key, path,
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_AIO, type, srv_read_only_mode, &success);
type, srv_read_only_mode, &success);
if (!success) {
/* The following call will print an error message */

View file

@ -53,7 +53,7 @@ Datafile::open_or_create(bool read_only_mode)
m_handle = os_file_create(
innodb_data_file_key, m_filepath, m_open_flags,
OS_FILE_NORMAL, OS_DATA_FILE, read_only_mode, &success);
OS_DATA_FILE, read_only_mode, &success);
if (!success) {
m_last_os_error = os_file_get_last_error(true);

View file

@ -145,9 +145,6 @@ static const ulint OS_FILE_READ_WRITE = 444;
/** Used by MySQLBackup */
static const ulint OS_FILE_READ_ALLOW_DELETE = 555;
/* Options for file_create */
static const ulint OS_FILE_AIO = 61;
static const ulint OS_FILE_NORMAL = 62;
/* @} */
/** Types for file create @{ */
@ -409,12 +406,6 @@ Opens an existing file or creates a new.
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] purpose OS_FILE_AIO, if asynchronous, non-buffered I/O
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_..
and srv_.. variables whether we really use
async I/O or unbuffered I/O: look in the
function source code for the exact rules
@param[in] type OS_DATA_FILE or OS_LOG_FILE
@param[in] read_only if true read only mode checks are enforced
@param[in] success true if succeeded
@ -424,7 +415,6 @@ pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
ulint purpose,
ulint type,
bool read_only,
bool* success)
@ -564,9 +554,9 @@ os_file_write
The wrapper functions have the prefix of "innodb_". */
# define os_file_create(key, name, create, purpose, type, read_only, \
# define os_file_create(key, name, create, type, read_only, \
success) \
pfs_os_file_create_func(key, name, create, purpose, type, \
pfs_os_file_create_func(key, name, create, type, \
read_only, success, __FILE__, __LINE__)
# define os_file_create_simple(key, name, create, access, \
@ -669,12 +659,6 @@ Add instrumentation to monitor file creation/open.
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] purpose OS_FILE_AIO, if asynchronous, non-buffered I/O
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_..
and srv_.. variables whether we really use
async I/O or unbuffered I/O: look in the
function source code for the exact rules
@param[in] read_only if true read only mode checks are enforced
@param[out] success true if succeeded
@param[in] src_file file name where func invoked
@ -687,7 +671,6 @@ pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
ulint purpose,
ulint type,
bool read_only,
bool* success,
@ -837,9 +820,9 @@ pfs_os_file_delete_if_exists_func(
/* If UNIV_PFS_IO is not defined, these I/O APIs point
to original un-instrumented file I/O APIs */
# define os_file_create(key, name, create, purpose, type, read_only, \
# define os_file_create(key, name, create, type, read_only, \
success) \
os_file_create_func(name, create, purpose, type, read_only, \
os_file_create_func(name, create, type, read_only, \
success)
# define os_file_create_simple(key, name, create_mode, access, \

View file

@ -129,12 +129,6 @@ Add instrumentation to monitor file creation/open.
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] purpose OS_FILE_AIO, if asynchronous, non-buffered I/O
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_..
and srv_.. variables whether we really us
async I/O or unbuffered I/O: look in the
function source code for the exact rules
@param[in] read_only if true read only mode checks are enforced
@param[out] success true if succeeded
@param[in] src_file file name where func invoked
@ -147,7 +141,6 @@ pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
ulint purpose,
ulint type,
bool read_only,
bool* success,
@ -165,7 +158,7 @@ pfs_os_file_create_func(
name, src_file, src_line);
pfs_os_file_t file = os_file_create_func(
name, create_mode, purpose, type, read_only, success);
name, create_mode, type, read_only, success);
register_pfs_file_open_end(locker, file,
(*success == TRUE ? success : 0));

View file

@ -252,7 +252,7 @@ dberr_t file_os_io::open(const char *path, bool read_only) noexcept
bool success;
auto tmp_fd= os_file_create(
innodb_log_file_key, path, OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_NORMAL, OS_LOG_FILE, read_only, &success);
OS_LOG_FILE, read_only, &success);
if (!success)
return DB_ERROR;

View file

@ -858,7 +858,7 @@ processed:
handle= os_file_create(innodb_data_file_key, filename,
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT |
OS_FILE_ON_ERROR_SILENT,
OS_FILE_AIO, OS_DATA_FILE, false, &success);
OS_DATA_FILE, false, &success);
}
space->add(filename, handle, size, false, false);
space->recv_size= it->second.size;

View file

@ -1106,12 +1106,6 @@ Opens an existing file or creates a new.
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] purpose OS_FILE_AIO, if asynchronous, non-buffered I/O
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_..
and srv_.. variables whether we really use async
I/O or unbuffered I/O: look in the function
source code for the exact rules
@param[in] type OS_DATA_FILE or OS_LOG_FILE
@param[in] read_only true, if read only checks should be enforcedm
@param[in] success true if succeeded
@ -1121,7 +1115,6 @@ pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
ulint purpose,
ulint type,
bool read_only,
bool* success)
@ -1189,7 +1182,6 @@ os_file_create_func(
ut_a(type == OS_LOG_FILE || type == OS_DATA_FILE);
#endif
ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL);
/* We let O_DSYNC only affect log files */
@ -2032,12 +2024,6 @@ Opens an existing file or creates a new.
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] purpose OS_FILE_AIO, if asynchronous, non-buffered I/O
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_..
and srv_.. variables whether we really use async
I/O or unbuffered I/O: look in the function
source code for the exact rules
@param[in] type OS_DATA_FILE or OS_LOG_FILE
@param[in] success true if succeeded
@return handle to the file, not defined if error, error number
@ -2046,7 +2032,6 @@ pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
ulint purpose,
ulint type,
bool read_only,
bool* success)
@ -2115,31 +2100,7 @@ os_file_create_func(
return(OS_FILE_CLOSED);
}
DWORD attributes = 0;
if (purpose == OS_FILE_AIO) {
#ifdef WIN_ASYNC_IO
/* If specified, use asynchronous (overlapped) io and no
buffering of writes in the OS */
if (srv_use_native_aio) {
attributes |= FILE_FLAG_OVERLAPPED;
}
#endif /* WIN_ASYNC_IO */
} else if (purpose == OS_FILE_NORMAL) {
/* Use default setting. */
} else {
ib::error()
<< "Unknown purpose flag (" << purpose << ") "
<< "while opening file '" << name << "'";
return(OS_FILE_CLOSED);
}
DWORD attributes= FILE_FLAG_OVERLAPPED;
if (type == OS_LOG_FILE) {
/* There is not reason to use buffered write to logs.*/

View file

@ -260,7 +260,7 @@ static dberr_t create_log_file(bool create_new_db, lsn_t lsn,
bool ret;
pfs_os_file_t file = os_file_create(
innodb_log_file_key, logfile0.c_str(),
OS_FILE_CREATE|OS_FILE_ON_ERROR_NO_EXIT, OS_FILE_NORMAL,
OS_FILE_CREATE|OS_FILE_ON_ERROR_NO_EXIT,
OS_LOG_FILE, srv_read_only_mode, &ret);
if (!ret) {
@ -383,7 +383,7 @@ static dberr_t srv_undo_tablespace_create(const char* name)
innodb_data_file_key,
name,
srv_read_only_mode ? OS_FILE_OPEN : OS_FILE_CREATE,
OS_FILE_NORMAL, OS_DATA_FILE, srv_read_only_mode, &ret);
OS_DATA_FILE, srv_read_only_mode, &ret);
if (!ret) {
if (os_file_get_last_error(false) != OS_FILE_ALREADY_EXISTS
@ -500,7 +500,7 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i)
pfs_os_file_t fh= os_file_create(innodb_data_file_key, name, OS_FILE_OPEN |
OS_FILE_ON_ERROR_NO_EXIT |
OS_FILE_ON_ERROR_SILENT,
OS_FILE_AIO, OS_DATA_FILE,
OS_DATA_FILE,
srv_read_only_mode, &success);
if (!success)
@ -621,7 +621,6 @@ srv_check_undo_redo_logs_exists()
OS_FILE_OPEN_RETRY
| OS_FILE_ON_ERROR_NO_EXIT
| OS_FILE_ON_ERROR_SILENT,
OS_FILE_NORMAL,
OS_DATA_FILE,
srv_read_only_mode,
&ret);
@ -644,7 +643,7 @@ srv_check_undo_redo_logs_exists()
fh = os_file_create(innodb_log_file_key, logfilename.c_str(),
OS_FILE_OPEN_RETRY | OS_FILE_ON_ERROR_NO_EXIT
| OS_FILE_ON_ERROR_SILENT,
OS_FILE_NORMAL, OS_LOG_FILE, srv_read_only_mode,
OS_LOG_FILE, srv_read_only_mode,
&ret);
if (ret) {