Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-11264

Windows : incorrect use of DeviceIoControl in os_file_trim

Details

    • 10.1.24

    Attachments

      Activity

        os_file_trim implements TRIM on Windows with DeviceIoControl(FSCTL_FILE_LEVEL_TRIM).

        However is does not use DeviceIoControl correctly - since file is opened asynchronously, DeviceIoControl needs to be async as well - it to be passed valid OVERLAPPED as the last parameter.

        MSDN says in the documentation of DeviceIoControl - https://msdn.microsoft.com/en-us/library/windows/desktop/aa363216(v=vs.85).aspx

        "If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.

        If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.

        wlad Vladislav Vaintroub added a comment - os_file_trim implements TRIM on Windows with DeviceIoControl(FSCTL_FILE_LEVEL_TRIM). However is does not use DeviceIoControl correctly - since file is opened asynchronously, DeviceIoControl needs to be async as well - it to be passed valid OVERLAPPED as the last parameter. MSDN says in the documentation of DeviceIoControl - https://msdn.microsoft.com/en-us/library/windows/desktop/aa363216(v=vs.85).aspx "If hDevice was opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored. If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.

        People

          wlad Vladislav Vaintroub
          wlad Vladislav Vaintroub
          Votes:
          0 Vote for this issue
          Watchers:
          2 Start watching this issue

          Dates

            Created:
            Updated:
            Resolved:

            Git Integration

              Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.