@@ -6423,22 +6423,27 @@ os_file_trim(
6423
6423
flt.Ranges [0 ].Offset = off;
6424
6424
flt.Ranges [0 ].Length = trim_len;
6425
6425
6426
+ OVERLAPPED overlapped = { 0 };
6427
+ overlapped.hEvent = win_get_syncio_event ();
6426
6428
BOOL ret = DeviceIoControl (slot->file , FSCTL_FILE_LEVEL_TRIM,
6427
- &flt, sizeof (flt), NULL , NULL , NULL , NULL );
6428
-
6429
+ &flt, sizeof (flt), NULL , NULL , NULL , &overlapped);
6430
+ DWORD tmp;
6431
+ if (ret) {
6432
+ ret = GetOverlappedResult (slot->file , &overlapped, &tmp, FALSE );
6433
+ }
6434
+ else if (GetLastError () == ERROR_IO_PENDING) {
6435
+ ret = GetOverlappedResult (slot->file , &overlapped, &tmp, TRUE );
6436
+ }
6429
6437
if (!ret) {
6438
+ DWORD last_error = GetLastError ();
6430
6439
/* After first failure do not try to trim again */
6431
6440
os_fallocate_failed = true ;
6432
6441
srv_use_trim = FALSE ;
6433
6442
ut_print_timestamp (stderr);
6434
- fprintf (stderr,
6435
- " InnoDB: Warning: fallocate call failed with error.\n "
6436
- " InnoDB: start: %lu len: %lu payload: %lu\n "
6437
- " InnoDB: Disabling fallocate for now.\n " , off, trim_len, len);
6438
6443
6439
- os_file_handle_error_no_exit (slot-> name ,
6440
- " DeviceIOControl (FSCTL_FILE_LEVEL_TRIM) " ,
6441
- FALSE , __FILE__, __LINE__ );
6444
+ fprintf (stderr ,
6445
+ " InnoDB: Warning: DeviceIoControl (FSCTL_FILE_LEVEL_TRIM) call failed with error %u%s. Disabling trimming. \n " ,
6446
+ last_error, last_error == ERROR_NOT_SUPPORTED ? " (ERROR_NOT_SUPPORTED) " : " " );
6442
6447
6443
6448
if (slot->write_size ) {
6444
6449
*slot->write_size = 0 ;
0 commit comments