21VOID CALLBACK IoCompletionRoutine(DWORD dwErrorCode,
22 DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)
25 struct aiocb *aiocbp = (
struct aiocb *) lpOverlapped->hEvent;
27 aiocbp->aio_sigevent.sigev_notify = dwErrorCode;
28 aiocbp->aio_sigevent.sigev_signo = dwNumberOfBytesTransfered;
29 debugs(81, 7,
"AIO operation complete: errorcode=" << dwErrorCode <<
" nbytes=" << dwNumberOfBytesTransfered);
33int aio_read(
struct aiocb *aiocbp)
35 LPOVERLAPPED Overlapped;
36 BOOL IoOperationStatus;
39 Overlapped = (LPOVERLAPPED)
xcalloc(1,
sizeof(OVERLAPPED));
46#if _FILE_OFFSET_BITS==64
48 Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL);
50 Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL);
54 Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000);
56 Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000);
61 Overlapped->Offset = aiocbp->aio_offset;
63 Overlapped->OffsetHigh = 0;
67 Overlapped->hEvent = aiocbp;
69 aiocbp->aio_sigevent.sigev_notify = EINPROGRESS;
71 aiocbp->aio_sigevent.sigev_signo = -1;
73 IoOperationStatus = ReadFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes),
80 if (!IoOperationStatus) {
81 errno = GetLastError();
92int aio_read64(
struct aiocb64 *aiocbp)
94 LPOVERLAPPED Overlapped;
95 BOOL IoOperationStatus;
98 Overlapped = (LPOVERLAPPED)
xcalloc(1,
sizeof(OVERLAPPED));
106 Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL);
108 Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL);
112 Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000);
114 Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000);
118 Overlapped->hEvent = aiocbp;
120 aiocbp->aio_sigevent.sigev_notify = EINPROGRESS;
122 aiocbp->aio_sigevent.sigev_signo = -1;
124 IoOperationStatus = ReadFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes),
128 IoCompletionRoutine);
131 if (!IoOperationStatus) {
132 errno = GetLastError();
143int aio_write(
struct aiocb *aiocbp)
145 LPOVERLAPPED Overlapped;
146 BOOL IoOperationStatus;
149 Overlapped = (LPOVERLAPPED)
xcalloc(1,
sizeof(OVERLAPPED));
156#if _FILE_OFFSET_BITS==64
158 Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL);
160 Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL);
164 Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000);
166 Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000);
171 Overlapped->Offset = aiocbp->aio_offset;
173 Overlapped->OffsetHigh = 0;
177 Overlapped->hEvent = aiocbp;
179 aiocbp->aio_sigevent.sigev_notify = EINPROGRESS;
181 aiocbp->aio_sigevent.sigev_signo = -1;
183 IoOperationStatus = WriteFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes),
187 IoCompletionRoutine);
190 if (!IoOperationStatus) {
191 errno = GetLastError();
202int aio_write64(
struct aiocb64 *aiocbp)
204 LPOVERLAPPED Overlapped;
205 BOOL IoOperationStatus;
208 Overlapped = (LPOVERLAPPED)
xcalloc(1,
sizeof(OVERLAPPED));
216 Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000LL);
218 Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000LL);
222 Overlapped->Offset = (DWORD) (aiocbp->aio_offset % 0x100000000);
224 Overlapped->OffsetHigh = (DWORD) (aiocbp->aio_offset / 0x100000000);
228 Overlapped->hEvent = aiocbp;
230 aiocbp->aio_sigevent.sigev_notify = EINPROGRESS;
232 aiocbp->aio_sigevent.sigev_signo = -1;
234 IoOperationStatus = WriteFileEx((HANDLE)_get_osfhandle(aiocbp->aio_fildes),
238 IoCompletionRoutine);
241 if (!IoOperationStatus) {
242 errno = GetLastError();
253int aio_error(
const struct aiocb * aiocbp)
255 return aiocbp->aio_sigevent.sigev_notify;
258int aio_error64(
const struct aiocb64 * aiocbp)
260 return aiocbp->aio_sigevent.sigev_notify;
263int aio_open(
const char *path,
int mode)
266 DWORD dwCreationDisposition;
267 DWORD dwDesiredAccess;
278 dwDesiredAccess = GENERIC_WRITE;
280 dwDesiredAccess = (mode & O_RDONLY) ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE;
283 dwCreationDisposition = CREATE_ALWAYS;
285 dwCreationDisposition = (mode & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING;
287 if ((hndl = CreateFile(path,
291 dwCreationDisposition,
292 FILE_FLAG_OVERLAPPED,
294 )) != INVALID_HANDLE_VALUE) {
296 fd = _open_osfhandle((
long) hndl, 0);
300 errno = GetLastError();
307void aio_close(
int fd)
309 CloseHandle((HANDLE)_get_osfhandle(fd));
314ssize_t aio_return(
struct aiocb * aiocbp)
316 return aiocbp->aio_sigevent.sigev_signo;
319ssize_t aio_return64(
struct aiocb64 * aiocbp)
322 return aiocbp->aio_sigevent.sigev_signo;
struct StatCounters::@130 syscalls
struct StatCounters::@130::@134 disk
void fd_open(const int fd, unsigned int, const char *description)
void fd_close(const int fd)
void commSetCloseOnExec(int fd)
#define debugs(SECTION, LEVEL, CONTENT)
void * xcalloc(size_t n, size_t sz)