Commit 3dd7b0a8 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Remove OS_FILE_ON_ERROR_NO_EXIT

Ever since commit 412ee033
or commit a440d6ed
InnoDB should generally not abort when failing to open or create files.
In Datafile::open_or_create() we had failed to set the flag
to avoid abort() on failure, but everywhere else we were setting it.

We may still call abort() via os_file_handle_error().

Reviewed by: Vladislav Vaintroub
parent 7f7329f0
......@@ -1900,8 +1900,7 @@ inline void log_t::write_checkpoint(lsn_t end_lsn) noexcept
ut_ad(!log.is_opened());
bool success;
log.m_file=
os_file_create_func(get_log_file_path().c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
os_file_create_func(get_log_file_path().c_str(), OS_FILE_OPEN,
OS_FILE_NORMAL, OS_LOG_FILE, false, &success);
ut_a(success);
ut_a(log.is_opened());
......
......@@ -361,8 +361,7 @@ static bool fil_node_open_file_low(fil_node_t *node)
bool success;
node->handle= os_file_create(innodb_data_file_key, node->name,
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_OPEN_RAW : OS_FILE_OPEN,
OS_FILE_AIO, type,
srv_read_only_mode, &success);
......@@ -1922,7 +1921,7 @@ fil_ibd_create(
file = os_file_create(
innodb_data_file_key, path,
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_CREATE,
OS_FILE_AIO, type, srv_read_only_mode, &success);
if (!success) {
......
......@@ -109,22 +109,21 @@ struct pfs_os_file_t
/** Options for os_file_create_func @{ */
enum os_file_create_t {
OS_FILE_OPEN = 51, /*!< to open an existing file (if
doesn't exist, error) */
OS_FILE_CREATE, /*!< to create new file (if
exists, error) */
OS_FILE_OPEN_RAW, /*!< to open a raw device or disk
partition */
OS_FILE_OPEN_RETRY, /*!< open with retry */
/** Flags that can be combined with the above values. Please ensure
that the above values stay below 128. */
OS_FILE_ON_ERROR_NO_EXIT = 128, /*!< do not exit on unknown errors */
OS_FILE_ON_ERROR_SILENT = 256 /*!< don't print diagnostic messages to
the log unless it is a fatal error,
this flag is only used if
ON_ERROR_NO_EXIT is set */
/** create a new file */
OS_FILE_CREATE= 0,
/** open an existing file */
OS_FILE_OPEN,
/** retry opening an existing file */
OS_FILE_OPEN_RETRY,
/** open a raw block device */
OS_FILE_OPEN_RAW,
/** do not display diagnostic messages */
OS_FILE_ON_ERROR_SILENT= 4,
OS_FILE_CREATE_SILENT= OS_FILE_CREATE | OS_FILE_ON_ERROR_SILENT,
OS_FILE_OPEN_SILENT= OS_FILE_OPEN | OS_FILE_ON_ERROR_SILENT,
OS_FILE_OPEN_RETRY_SILENT= OS_FILE_OPEN_RETRY | OS_FILE_ON_ERROR_SILENT
};
static const ulint OS_FILE_READ_ONLY = 333;
......@@ -346,7 +345,7 @@ A simple function to open or create a file.
pfs_os_file_t
os_file_create_simple_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success);
......@@ -355,7 +354,7 @@ os_file_create_simple_func(
os_file_create_simple_no_error_handling(), not directly this function!
A simple function to open or create a file.
@param[in] name name of the file or path as a null-terminated string
@param[in] create_mode create mode
@param[in] create_mode OS_FILE_CREATE or OS_FILE_OPEN
@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option
is used by a backup program reading the file
......@@ -366,7 +365,7 @@ A simple function to open or create a file.
pfs_os_file_t
os_file_create_simple_no_error_handling_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success)
......@@ -400,7 +399,7 @@ Opens an existing file or creates a new.
pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint purpose,
ulint type,
bool read_only,
......@@ -598,7 +597,7 @@ pfs_os_file_t
pfs_os_file_create_simple_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success,
......@@ -614,7 +613,7 @@ monitor file creation/open.
@param[in] key Performance Schema Key
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] create_mode OS_FILE_CREATE or OS_FILE_OPEN
@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option is
used by a backup program reading the file
......@@ -629,7 +628,7 @@ pfs_os_file_t
pfs_os_file_create_simple_no_error_handling_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success,
......@@ -662,7 +661,7 @@ pfs_os_file_t
pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint purpose,
ulint type,
bool read_only,
......
......@@ -45,7 +45,7 @@ pfs_os_file_t
pfs_os_file_create_simple_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success,
......@@ -80,7 +80,7 @@ monitor file creation/open.
@param[in] key Performance Schema Key
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] create_mode OS_FILE_CREATE or OS_FILE_OPEN
@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option is
used by a backup program reading the file
......@@ -95,7 +95,7 @@ pfs_os_file_t
pfs_os_file_create_simple_no_error_handling_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success,
......@@ -146,7 +146,7 @@ pfs_os_file_t
pfs_os_file_create_func(
mysql_pfs_key_t key,
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint purpose,
ulint type,
bool read_only,
......
......@@ -466,8 +466,7 @@ log_t::resize_start_status log_t::resize_start(os_offset_t size) noexcept
resize_lsn.store(1, std::memory_order_relaxed);
resize_target= 0;
resize_log.m_file=
os_file_create_func(path.c_str(),
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT,
os_file_create_func(path.c_str(), OS_FILE_CREATE,
OS_FILE_NORMAL, OS_LOG_FILE, false, &success);
if (success)
{
......
......@@ -844,8 +844,7 @@ static struct
inside recv_sys_t::recover_deferred(). */
bool success;
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_CREATE_SILENT,
OS_FILE_AIO, OS_DATA_FILE, false, &success);
}
space->add(filename, handle, size, false, false);
......@@ -1714,7 +1713,7 @@ dberr_t recv_sys_t::find_checkpoint()
std::string path{get_log_file_path()};
bool success;
os_file_t file{os_file_create_func(path.c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_OPEN,
OS_FILE_NORMAL, OS_LOG_FILE,
srv_read_only_mode, &success)};
if (file == OS_FILE_CLOSED)
......@@ -1744,8 +1743,7 @@ dberr_t recv_sys_t::find_checkpoint()
{
path= get_log_file_path(LOG_FILE_NAME_PREFIX).append(std::to_string(i));
file= os_file_create_func(path.c_str(),
OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT |
OS_FILE_ON_ERROR_SILENT,
OS_FILE_OPEN_SILENT,
OS_FILE_NORMAL, OS_LOG_FILE, true, &success);
if (file == OS_FILE_CLOSED)
break;
......
......@@ -200,17 +200,10 @@ os_file_handle_error_cond_exit(
bool on_error_silent);
/** Does error handling when a file operation fails.
@param[in] name name of a file or NULL
@param[in] operation operation name that failed
@return true if we should retry the operation */
static
bool
os_file_handle_error(
const char* name,
const char* operation)
@param operation name of operation that failed */
static void os_file_handle_error(const char *operation)
{
/* Exit in case of unknown error */
return(os_file_handle_error_cond_exit(name, operation, true, false));
os_file_handle_error_cond_exit(nullptr, operation, true, false);
}
/** Does error handling when a file operation fails.
......@@ -942,7 +935,7 @@ os_file_flush_func(
ib::error() << "The OS said file flush did not succeed";
os_file_handle_error(NULL, "flush");
os_file_handle_error("flush");
/* It is a fatal error if a file flush does not succeed, because then
the database can get corrupt on disk */
......@@ -965,7 +958,7 @@ A simple function to open or create a file.
pfs_os_file_t
os_file_create_simple_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success)
......@@ -976,23 +969,14 @@ os_file_create_simple_func(
int create_flag = O_RDONLY | O_CLOEXEC;
ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT));
ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT));
if (read_only) {
} else if (create_mode == OS_FILE_OPEN) {
if (access_type != OS_FILE_READ_ONLY) {
create_flag = O_RDWR | O_CLOEXEC;
}
} else if (create_mode == OS_FILE_CREATE) {
create_flag = O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC;
} else {
ib::error()
<< "Unknown file create mode ("
<< create_mode
<< " for file '" << name << "'";
return(OS_FILE_CLOSED);
ut_ad(create_mode == OS_FILE_OPEN);
if (access_type != OS_FILE_READ_ONLY) {
create_flag = O_RDWR | O_CLOEXEC;
}
}
bool retry;
......@@ -1025,10 +1009,10 @@ os_file_create_simple_func(
}
#endif
*success = false;
retry = os_file_handle_error(
retry = os_file_handle_error_no_exit(
name,
create_mode == OS_FILE_OPEN
? "open" : "create");
create_mode == OS_FILE_CREATE
? "create" : "open", false);
} else {
*success = true;
retry = false;
......@@ -1154,48 +1138,34 @@ Opens an existing file or creates a new.
pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint purpose,
ulint type,
bool read_only,
bool* success)
{
bool on_error_no_exit;
bool on_error_silent;
*success = false;
DBUG_EXECUTE_IF(
"ib_create_table_fail_disk_full",
*success = false;
errno = ENOSPC;
return(OS_FILE_CLOSED);
);
int create_flag;
on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT
? true : false;
on_error_silent = create_mode & OS_FILE_ON_ERROR_SILENT
? true : false;
create_mode &= ulint(~(OS_FILE_ON_ERROR_NO_EXIT
| OS_FILE_ON_ERROR_SILENT));
if (read_only) {
create_flag = O_RDONLY | O_CLOEXEC;
} else if (create_mode == OS_FILE_OPEN
|| create_mode == OS_FILE_OPEN_RAW
|| create_mode == OS_FILE_OPEN_RETRY) {
create_flag = O_RDWR | O_CLOEXEC;
} else if (create_mode == OS_FILE_CREATE) {
} else if (create_mode == OS_FILE_CREATE
|| create_mode == OS_FILE_CREATE_SILENT) {
create_flag = O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC;
} else {
ib::error()
<< "Unknown file create mode (" << create_mode << ")"
<< " for file '" << name << "'";
return(OS_FILE_CLOSED);
ut_ad(create_mode == OS_FILE_OPEN
|| create_mode == OS_FILE_OPEN_SILENT
|| create_mode == OS_FILE_OPEN_RETRY
|| create_mode == OS_FILE_OPEN_RETRY_SILENT
|| create_mode == OS_FILE_OPEN_RAW);
create_flag = O_RDWR | O_CLOEXEC;
}
#ifdef O_DIRECT
......@@ -1219,10 +1189,14 @@ os_file_create_func(
} else if (log_sys.log_buffered) {
skip_o_direct:
os_file_log_buffered();
} else if (create_mode != OS_FILE_CREATE && !log_sys.is_opened()) {
} else if (create_mode != OS_FILE_CREATE
&& create_mode != OS_FILE_CREATE_SILENT
&& !log_sys.is_opened()) {
if (stat(name, &st)) {
if (errno == ENOENT) {
if (on_error_silent) goto not_found;
if (create_mode & OS_FILE_ON_ERROR_SILENT) {
goto not_found;
}
sql_print_error(
"InnoDB: File %s was not found", name);
goto not_found;
......@@ -1256,9 +1230,8 @@ os_file_create_func(
}
os_file_t file;
bool retry;
do {
for (;;) {
file = open(name, create_flag | direct_flag, os_innodb_umask);
if (file == -1) {
......@@ -1270,34 +1243,26 @@ os_file_create_func(
os_file_log_buffered();
}
# endif
if (create_mode == OS_FILE_CREATE) {
if (create_mode == OS_FILE_CREATE
|| create_mode == OS_FILE_CREATE_SILENT) {
/* Linux may create the file
before rejecting the O_DIRECT. */
unlink(name);
}
retry = true;
continue;
}
#endif
const char* operation;
operation = (create_mode == OS_FILE_CREATE
&& !read_only) ? "create" : "open";
*success = false;
if (on_error_no_exit) {
retry = os_file_handle_error_no_exit(
name, operation, on_error_silent);
} else {
retry = os_file_handle_error(name, operation);
if (!os_file_handle_error_no_exit(
name, (create_flag & O_CREAT)
? "create" : "open",
create_mode & OS_FILE_ON_ERROR_SILENT)) {
break;
}
} else {
*success = true;
retry = false;
break;
}
} while (retry);
}
if (!*success) {
#ifdef __linux__
......@@ -1307,8 +1272,7 @@ os_file_create_func(
}
#ifdef __linux__
if (!read_only && create_mode == OS_FILE_CREATE
&& type == OS_LOG_FILE) {
if ((create_flag & O_CREAT) && type == OS_LOG_FILE) {
if (fstat(file, &st) || !os_file_log_maybe_unbuffered(st)) {
os_file_log_buffered();
} else {
......@@ -1324,7 +1288,8 @@ os_file_create_func(
&& !my_disable_locking
&& os_file_lock(file, name)) {
if (create_mode == OS_FILE_OPEN_RETRY) {
if (create_mode == OS_FILE_OPEN_RETRY
|| create_mode == OS_FILE_OPEN_RETRY_SILENT) {
ib::info()
<< "Retrying to lock the first data file";
......@@ -1355,7 +1320,7 @@ os_file_create_simple_no_error_handling(), not directly this function!
A simple function to open or create a file.
@param[in] name name of the file or path as a null-terminated
string
@param[in] create_mode create mode
@param[in] create_mode OS_FILE_CREATE or OS_FILE_OPEN
@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option
is used by a backup program reading the file
......@@ -1366,7 +1331,7 @@ A simple function to open or create a file.
pfs_os_file_t
os_file_create_simple_no_error_handling_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success)
......@@ -1374,30 +1339,19 @@ os_file_create_simple_no_error_handling_func(
os_file_t file;
int create_flag = O_RDONLY | O_CLOEXEC;
ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT));
ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT));
*success = false;
if (read_only) {
} else if (create_mode == OS_FILE_OPEN) {
} else if (create_mode == OS_FILE_CREATE) {
create_flag = O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC;
} else {
ut_ad(create_mode == OS_FILE_OPEN);
if (access_type != OS_FILE_READ_ONLY) {
ut_a(access_type == OS_FILE_READ_WRITE
|| access_type == OS_FILE_READ_ALLOW_DELETE);
create_flag = O_RDWR;
}
} else if (create_mode == OS_FILE_CREATE) {
create_flag = O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC;
} else {
ib::error()
<< "Unknown file create mode "
<< create_mode << " for file '" << name << "'";
return(OS_FILE_CLOSED);
}
file = open(name, create_flag, os_innodb_umask);
......@@ -1520,7 +1474,7 @@ bool os_file_close_func(os_file_t file)
if (!ret)
return true;
os_file_handle_error(NULL, "close");
os_file_handle_error("close");
return false;
}
......@@ -1793,7 +1747,7 @@ bool os_file_flush_func(os_file_t file)
if (srv_start_raw_disk_in_use && GetLastError() == ERROR_INVALID_FUNCTION)
return true;
os_file_handle_error(nullptr, "flush");
os_file_handle_error("flush");
/* It is a fatal error if a file flush does not succeed, because then
the database can get corrupt on disk */
......@@ -1907,7 +1861,7 @@ A simple function to open or create a file.
pfs_os_file_t
os_file_create_simple_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success)
......@@ -1916,65 +1870,31 @@ os_file_create_simple_func(
*success = false;
DWORD access;
DWORD access = GENERIC_READ;
DWORD create_flag;
DWORD attributes = 0;
ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT));
ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT));
ut_ad(srv_operation == SRV_OPERATION_NORMAL);
if (create_mode == OS_FILE_OPEN) {
if (read_only || create_mode == OS_FILE_OPEN) {
create_flag = OPEN_EXISTING;
} else if (read_only) {
create_flag = OPEN_EXISTING;
} else if (create_mode == OS_FILE_CREATE) {
create_flag = CREATE_NEW;
} else {
ib::error()
<< "Unknown file create mode ("
<< create_mode << ") for file '"
<< name << "'";
return(OS_FILE_CLOSED);
ut_ad(create_mode == OS_FILE_CREATE);
create_flag = CREATE_NEW;
}
if (access_type == OS_FILE_READ_ONLY) {
access = GENERIC_READ;
} else if (read_only) {
ib::info()
<< "Read only mode set. Unable to"
" open file '" << name << "' in RW mode, "
<< "trying RO mode";
access = GENERIC_READ;
} else if (access_type == OS_FILE_READ_WRITE) {
access = GENERIC_READ | GENERIC_WRITE;
} else {
ib::error()
<< "Unknown file access type (" << access_type << ") "
"for file '" << name << "'";
return(OS_FILE_CLOSED);
ut_ad(access_type == OS_FILE_READ_WRITE);
access = GENERIC_READ | GENERIC_WRITE;
}
bool retry;
do {
for (;;) {
/* Use default security attributes and no template file. */
file = CreateFile(
......@@ -1982,22 +1902,18 @@ os_file_create_simple_func(
FILE_SHARE_READ | FILE_SHARE_DELETE,
my_win_file_secattr(), create_flag, attributes, NULL);
if (file == INVALID_HANDLE_VALUE) {
*success = false;
retry = os_file_handle_error(
name, create_mode == OS_FILE_OPEN ?
"open" : "create");
} else {
retry = false;
if (file != INVALID_HANDLE_VALUE) {
*success = true;
break;
}
} while (retry);
if (!os_file_handle_error_no_exit(name,
create_flag == CREATE_NEW
? "create" : "open",
false)) {
break;
}
}
return(file);
}
......@@ -2066,16 +1982,13 @@ Opens an existing file or creates a new.
pfs_os_file_t
os_file_create_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint purpose,
ulint type,
bool read_only,
bool* success)
{
os_file_t file;
bool retry;
bool on_error_no_exit;
bool on_error_silent;
*success = false;
......@@ -2086,50 +1999,30 @@ os_file_create_func(
return(OS_FILE_CLOSED);
);
DWORD create_flag;
DWORD create_flag = OPEN_EXISTING;
DWORD share_mode = read_only
? FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
: FILE_SHARE_READ | FILE_SHARE_DELETE;
on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT
? true : false;
on_error_silent = create_mode & OS_FILE_ON_ERROR_SILENT
? true : false;
create_mode &= ~(OS_FILE_ON_ERROR_NO_EXIT | OS_FILE_ON_ERROR_SILENT);
if (create_mode == OS_FILE_OPEN_RAW) {
switch (create_mode) {
case OS_FILE_OPEN_RAW:
ut_a(!read_only);
/* On Windows Physical devices require admin privileges and
have to have the write-share mode set. See the remarks
section for the CreateFile() function documentation in MSDN. */
share_mode |= FILE_SHARE_WRITE;
create_flag = OPEN_EXISTING;
} else if (create_mode == OS_FILE_OPEN
|| create_mode == OS_FILE_OPEN_RETRY) {
create_flag = OPEN_EXISTING;
} else if (read_only) {
create_flag = OPEN_EXISTING;
} else if (create_mode == OS_FILE_CREATE) {
break;
case OS_FILE_CREATE_SILENT:
case OS_FILE_CREATE:
create_flag = CREATE_NEW;
} else {
ib::error()
<< "Unknown file create mode (" << create_mode << ") "
<< " for file '" << name << "'";
return(OS_FILE_CLOSED);
break;
default:
ut_ad(create_mode == OS_FILE_OPEN
|| create_mode == OS_FILE_OPEN_SILENT
|| create_mode == OS_FILE_OPEN_RETRY_SILENT
|| create_mode == OS_FILE_OPEN_RETRY);
break;
}
DWORD attributes = (purpose == OS_FILE_AIO && srv_use_native_aio)
......@@ -2187,18 +2080,11 @@ os_file_create_func(
break;
}
operation = (create_mode == OS_FILE_CREATE && !read_only) ?
"create" : "open";
operation = create_flag == CREATE_NEW ? "create" : "open";
if (on_error_no_exit) {
retry = os_file_handle_error_no_exit(
name, operation, on_error_silent);
}
else {
retry = os_file_handle_error(name, operation);
}
if (!retry) {
if (!os_file_handle_error_no_exit(name, operation,
create_mode
& OS_FILE_ON_ERROR_SILENT)) {
break;
}
}
......@@ -2225,79 +2111,42 @@ A simple function to open or create a file.
pfs_os_file_t
os_file_create_simple_no_error_handling_func(
const char* name,
ulint create_mode,
os_file_create_t create_mode,
ulint access_type,
bool read_only,
bool* success)
{
os_file_t file;
*success = false;
DWORD access;
DWORD create_flag;
DWORD access = GENERIC_READ;
DWORD create_flag = OPEN_EXISTING;
DWORD attributes = 0;
DWORD share_mode = read_only
? FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
: FILE_SHARE_READ | FILE_SHARE_DELETE;
DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE;
ut_a(name);
ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT));
ut_a(!(create_mode & OS_FILE_ON_ERROR_NO_EXIT));
if (create_mode == OS_FILE_OPEN) {
create_flag = OPEN_EXISTING;
} else if (read_only) {
create_flag = OPEN_EXISTING;
} else if (create_mode == OS_FILE_CREATE) {
create_flag = CREATE_NEW;
} else {
ib::error()
<< "Unknown file create mode (" << create_mode << ") "
<< " for file '" << name << "'";
return(OS_FILE_CLOSED);
}
if (access_type == OS_FILE_READ_ONLY) {
access = GENERIC_READ;
} else if (read_only) {
access = GENERIC_READ;
} else if (access_type == OS_FILE_READ_WRITE) {
access = GENERIC_READ | GENERIC_WRITE;
} else if (access_type == OS_FILE_READ_ALLOW_DELETE) {
ut_a(!read_only);
access = GENERIC_READ;
/*!< A backup program has to give mysqld the maximum
freedom to do what it likes with the file */
share_mode |= FILE_SHARE_DELETE | FILE_SHARE_WRITE
| FILE_SHARE_READ;
if (read_only) {
share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE
| FILE_SHARE_DELETE;
} else {
if (create_mode == OS_FILE_CREATE) {
create_flag = CREATE_NEW;
} else {
ut_ad(create_mode == OS_FILE_OPEN);
}
ib::error()
<< "Unknown file access type (" << access_type << ") "
<< "for file '" << name << "'";
return(OS_FILE_CLOSED);
switch (access_type) {
case OS_FILE_READ_ONLY: break;
case OS_FILE_READ_WRITE:
access = GENERIC_READ | GENERIC_WRITE;
break;
default:
ut_ad(access_type == OS_FILE_READ_ALLOW_DELETE);
/* A backup program has to give mariadbd the maximum
freedom to do what it likes with the file */
share_mode |= FILE_SHARE_DELETE | FILE_SHARE_WRITE
| FILE_SHARE_READ;
}
}
file = CreateFile((LPCTSTR) name,
......@@ -2465,7 +2314,7 @@ bool os_file_close_func(os_file_t file)
ut_ad(file);
if (!CloseHandle(file))
{
os_file_handle_error(NULL, "close");
os_file_handle_error("close");
return false;
}
......@@ -2903,8 +2752,8 @@ os_file_read_func(
if (ulint(n_bytes) == n || err != DB_SUCCESS)
return err;
os_file_handle_error_cond_exit(type.node ? type.node->name : nullptr, "read",
false, false);
os_file_handle_error_no_exit(type.node ? type.node->name : nullptr, "read",
false);
sql_print_error("InnoDB: Tried to read %zu bytes at offset %llu"
" of file %s, but was only able to read %zd",
n, offset, type.node ? type.node->name : "(unknown)",
......@@ -3791,8 +3640,9 @@ dberr_t os_aio(const IORequest &type, void *buf, os_offset_t offset, size_t n)
if (srv_thread_pool->submit_io(cb)) {
slots->release(cb);
os_file_handle_error(type.node->name, type.is_read()
? "aio read" : "aio write");
os_file_handle_error_no_exit(type.node->name, type.is_read()
? "aio read" : "aio write",
false);
err = DB_IO_ERROR;
type.node->space->release();
}
......
......@@ -201,7 +201,7 @@ static dberr_t create_log_file(bool create_new_db, lsn_t lsn)
bool ret;
os_file_t file{
os_file_create_func(logfile0.c_str(),
OS_FILE_CREATE | OS_FILE_ON_ERROR_NO_EXIT,
OS_FILE_CREATE,
OS_FILE_NORMAL, OS_LOG_FILE, false, &ret)
};
......@@ -632,9 +632,8 @@ static uint32_t srv_undo_tablespace_open(bool create, const char* name,
}
}
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,
pfs_os_file_t fh= os_file_create(innodb_data_file_key, name,
OS_FILE_OPEN_SILENT,
OS_FILE_AIO, OS_DATA_FILE,
srv_read_only_mode, &success);
......@@ -731,9 +730,7 @@ srv_check_undo_redo_logs_exists()
fh = os_file_create_func(
name,
OS_FILE_OPEN_RETRY
| OS_FILE_ON_ERROR_NO_EXIT
| OS_FILE_ON_ERROR_SILENT,
OS_FILE_OPEN_RETRY_SILENT,
OS_FILE_NORMAL,
OS_DATA_FILE,
srv_read_only_mode,
......@@ -755,8 +752,7 @@ srv_check_undo_redo_logs_exists()
auto logfilename = get_log_file_path();
fh = os_file_create_func(logfilename.c_str(),
OS_FILE_OPEN_RETRY | OS_FILE_ON_ERROR_NO_EXIT
| OS_FILE_ON_ERROR_SILENT,
OS_FILE_OPEN_RETRY_SILENT,
OS_FILE_NORMAL, OS_LOG_FILE,
srv_read_only_mode, &ret);
......
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