mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 18:20:07 +01:00
MDEV-11264 Fix DeviceIoControl() usage in innodb.
As documented in MSDN, DeviceIoControl() needs valid (not NULL) OVERLAPPED parameter, for files opened with for OVERLAPPED access.
This commit is contained in:
parent
b61700c221
commit
a1b6128ded
1 changed files with 14 additions and 9 deletions
|
@ -6423,22 +6423,27 @@ os_file_trim(
|
|||
flt.Ranges[0].Offset = off;
|
||||
flt.Ranges[0].Length = trim_len;
|
||||
|
||||
OVERLAPPED overlapped = { 0 };
|
||||
overlapped.hEvent = win_get_syncio_event();
|
||||
BOOL ret = DeviceIoControl(slot->file, FSCTL_FILE_LEVEL_TRIM,
|
||||
&flt, sizeof(flt), NULL, NULL, NULL, NULL);
|
||||
|
||||
&flt, sizeof(flt), NULL, NULL, NULL, &overlapped);
|
||||
DWORD tmp;
|
||||
if (ret) {
|
||||
ret = GetOverlappedResult(slot->file, &overlapped, &tmp, FALSE);
|
||||
}
|
||||
else if (GetLastError() == ERROR_IO_PENDING) {
|
||||
ret = GetOverlappedResult(slot->file, &overlapped, &tmp, TRUE);
|
||||
}
|
||||
if (!ret) {
|
||||
DWORD last_error = GetLastError();
|
||||
/* After first failure do not try to trim again */
|
||||
os_fallocate_failed = true;
|
||||
srv_use_trim = FALSE;
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr,
|
||||
" InnoDB: Warning: fallocate call failed with error.\n"
|
||||
" InnoDB: start: %lu len: %lu payload: %lu\n"
|
||||
" InnoDB: Disabling fallocate for now.\n", off, trim_len, len);
|
||||
|
||||
os_file_handle_error_no_exit(slot->name,
|
||||
" DeviceIOControl(FSCTL_FILE_LEVEL_TRIM) ",
|
||||
FALSE, __FILE__, __LINE__);
|
||||
fprintf(stderr,
|
||||
" InnoDB: Warning: DeviceIoControl(FSCTL_FILE_LEVEL_TRIM) call failed with error %u%s. Disabling trimming.\n",
|
||||
last_error, last_error == ERROR_NOT_SUPPORTED ? "(ERROR_NOT_SUPPORTED)" : "");
|
||||
|
||||
if (slot->write_size) {
|
||||
*slot->write_size = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue