VirtualBox

source: vbox/trunk/src/VBox/VMM/PDMAsyncCompletionFileInternal.h@ 25414

Last change on this file since 25414 was 25147, checked in by vboxsync, 15 years ago

AsyncCompletion/Cache: Complete all pending writes before completing a flush

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.9 KB
Line 
1/* $Id: PDMAsyncCompletionFileInternal.h 25147 2009-12-02 13:42:32Z vboxsync $ */
2/** @file
3 * PDM Async I/O - Transport data asynchronous in R3 using EMT.
4 */
5
6/*
7 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ___PDMAsyncCompletionFileInternal_h
23#define ___PDMAsyncCompletionFileInternal_h
24
25#include <VBox/cfgm.h>
26#include <VBox/stam.h>
27#include <iprt/types.h>
28#include <iprt/file.h>
29#include <iprt/thread.h>
30#include <iprt/semaphore.h>
31#include <iprt/critsect.h>
32#include <iprt/avl.h>
33
34#include "PDMAsyncCompletionInternal.h"
35
36/** Enable the 2Q cache alogrithm. */
37#define VBOX_WITH_2Q_CACHE 1
38
39/** @todo: Revise the caching of tasks. We have currently four caches:
40 * Per endpoint task cache
41 * Per class cache
42 * Per endpoint task segment cache
43 * Per class task segment cache
44 *
45 * We could use the RT heap for this probably or extend MMR3Heap (uses RTMemAlloc
46 * instead of managing larger blocks) to have this global for the whole VM.
47 */
48
49RT_C_DECLS_BEGIN
50
51/**
52 * A few forward declerations.
53 */
54typedef struct PDMASYNCCOMPLETIONENDPOINTFILE *PPDMASYNCCOMPLETIONENDPOINTFILE;
55/** Pointer to a request segment. */
56typedef struct PDMACTASKFILE *PPDMACTASKFILE;
57/** Pointer to the endpoint class data. */
58typedef struct PDMASYNCCOMPLETIONTASKFILE *PPDMASYNCCOMPLETIONTASKFILE;
59/** Pointer to a cache LRU list. */
60typedef struct PDMACFILELRULIST *PPDMACFILELRULIST;
61/** Pointer to the global cache structure. */
62typedef struct PDMACFILECACHEGLOBAL *PPDMACFILECACHEGLOBAL;
63
64/**
65 * Blocking event types.
66 */
67typedef enum PDMACEPFILEAIOMGRBLOCKINGEVENT
68{
69 /** Invalid tye */
70 PDMACEPFILEAIOMGRBLOCKINGEVENT_INVALID = 0,
71 /** An endpoint is added to the manager. */
72 PDMACEPFILEAIOMGRBLOCKINGEVENT_ADD_ENDPOINT,
73 /** An endpoint is removed from the manager. */
74 PDMACEPFILEAIOMGRBLOCKINGEVENT_REMOVE_ENDPOINT,
75 /** An endpoint is about to be closed. */
76 PDMACEPFILEAIOMGRBLOCKINGEVENT_CLOSE_ENDPOINT,
77 /** The manager is requested to terminate */
78 PDMACEPFILEAIOMGRBLOCKINGEVENT_SHUTDOWN,
79 /** The manager is requested to suspend */
80 PDMACEPFILEAIOMGRBLOCKINGEVENT_SUSPEND,
81 /** The manager is requested to resume */
82 PDMACEPFILEAIOMGRBLOCKINGEVENT_RESUME,
83 /** 32bit hack */
84 PDMACEPFILEAIOMGRBLOCKINGEVENT_32BIT_HACK = 0x7fffffff
85} PDMACEPFILEAIOMGRBLOCKINGEVENT;
86
87/**
88 * States of the I/O manager.
89 */
90typedef enum PDMACEPFILEMGRSTATE
91{
92 /** Invalid state. */
93 PDMACEPFILEMGRSTATE_INVALID = 0,
94 /** Normal running state accepting new requests
95 * and processing them.
96 */
97 PDMACEPFILEMGRSTATE_RUNNING,
98 /** Fault state - not accepting new tasks for endpoints but waiting for
99 * remaining ones to finish.
100 */
101 PDMACEPFILEMGRSTATE_FAULT,
102 /** Suspending state - not accepting new tasks for endpoints but waiting
103 * for remaining ones to finish.
104 */
105 PDMACEPFILEMGRSTATE_SUSPENDING,
106 /** Shutdown state - not accepting new tasks for endpoints but waiting
107 * for remaining ones to finish.
108 */
109 PDMACEPFILEMGRSTATE_SHUTDOWN,
110 /** 32bit hack */
111 PDMACEPFILEMGRSTATE_32BIT_HACK = 0x7fffffff
112} PDMACEPFILEMGRSTATE;
113
114/**
115 * State of a async I/O manager.
116 */
117typedef struct PDMACEPFILEMGR
118{
119 /** Next Aio manager in the list. */
120 R3PTRTYPE(struct PDMACEPFILEMGR *) pNext;
121 /** Previous Aio manager in the list. */
122 R3PTRTYPE(struct PDMACEPFILEMGR *) pPrev;
123 /** Current state of the manager. */
124 PDMACEPFILEMGRSTATE enmState;
125 /** Event semaphore the manager sleeps on when waiting for new requests. */
126 RTSEMEVENT EventSem;
127 /** Flag whether the thread waits in the event semaphore. */
128 volatile bool fWaitingEventSem;
129 /** Flag whether this manager uses the failsafe method. */
130 bool fFailsafe;
131 /** Thread data */
132 RTTHREAD Thread;
133 /** The async I/O context for this manager. */
134 RTFILEAIOCTX hAioCtx;
135 /** Flag whether the I/O manager was woken up. */
136 volatile bool fWokenUp;
137 /** List of endpoints assigned to this manager. */
138 R3PTRTYPE(PPDMASYNCCOMPLETIONENDPOINTFILE) pEndpointsHead;
139 /** Number of endpoints assigned to the manager. */
140 unsigned cEndpoints;
141 /** Number of requests active currently. */
142 unsigned cRequestsActive;
143 /** Pointer to an array of free async I/O request handles. */
144 RTFILEAIOREQ *pahReqsFree;
145 /** Next free position for a free request handle. */
146 unsigned iFreeEntryNext;
147 /** Position of the next free task handle */
148 unsigned iFreeReqNext;
149 /** Size of the array. */
150 unsigned cReqEntries;
151 /** Critical section protecting the blocking event handling. */
152 RTCRITSECT CritSectBlockingEvent;
153 /** Event sempahore for blocking external events.
154 * The caller waits on it until the async I/O manager
155 * finished processing the event. */
156 RTSEMEVENT EventSemBlock;
157 /** Flag whether a blocking event is pending and needs
158 * processing by the I/O manager. */
159 volatile bool fBlockingEventPending;
160 /** Blocking event type */
161 volatile PDMACEPFILEAIOMGRBLOCKINGEVENT enmBlockingEvent;
162 /** Event type data */
163 union
164 {
165 /** Add endpoint event. */
166 struct
167 {
168 /** The endpoint to be added */
169 volatile PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint;
170 } AddEndpoint;
171 /** Remove endpoint event. */
172 struct
173 {
174 /** The endpoint to be removed */
175 volatile PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint;
176 } RemoveEndpoint;
177 /** Close endpoint event. */
178 struct
179 {
180 /** The endpoint to be closed */
181 volatile PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint;
182 } CloseEndpoint;
183 } BlockingEventData;
184} PDMACEPFILEMGR;
185/** Pointer to a async I/O manager state. */
186typedef PDMACEPFILEMGR *PPDMACEPFILEMGR;
187/** Pointer to a async I/O manager state pointer. */
188typedef PPDMACEPFILEMGR *PPPDMACEPFILEMGR;
189
190/**
191 * Data for one request segment waiting for cache entry.
192 */
193typedef struct PDMACFILETASKSEG
194{
195 /** Next task segment in the list. */
196 struct PDMACFILETASKSEG *pNext;
197 /** Task this segment is for. */
198 PPDMASYNCCOMPLETIONTASKFILE pTask;
199 /** Offset into the cache entry buffer to start reading from. */
200 uint32_t uBufOffset;
201 /** Number of bytes to transfer. */
202 size_t cbTransfer;
203 /** Pointer to the buffer. */
204 void *pvBuf;
205 /** Flag whether this entry writes data to the cache. */
206 bool fWrite;
207} PDMACFILETASKSEG, *PPDMACFILETASKSEG;
208
209/**
210 * A cache entry
211 */
212typedef struct PDMACFILECACHEENTRY
213{
214 /** The AVL entry data. */
215 AVLRFOFFNODECORE Core;
216 /** Pointer to the previous element. Used in one of the LRU lists.*/
217 struct PDMACFILECACHEENTRY *pPrev;
218 /** Pointer to the next element. Used in one of the LRU lists.*/
219 struct PDMACFILECACHEENTRY *pNext;
220 /** Pointer to the list the entry is in. */
221 PPDMACFILELRULIST pList;
222 /** Pointer to the global cache structure. */
223 PPDMACFILECACHEGLOBAL pCache;
224 /** Endpoint the entry belongs to. */
225 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint;
226 /** Flags for this entry. Combinations of PDMACFILECACHE_* #defines */
227 uint32_t fFlags;
228 /** Reference counter. Prevents eviction of the entry if > 0. */
229 volatile uint32_t cRefs;
230 /** Size of the entry. */
231 size_t cbData;
232 /** Pointer to the memory containing the data. */
233 uint8_t *pbData;
234 /** Pointer to the buffer replacing the current one
235 * if the deprecated flag is set. */
236 uint8_t *pbDataReplace;
237 /** Head of list of tasks waiting for this one to finish. */
238 PPDMACFILETASKSEG pWaitingHead;
239 /** Tail of list of tasks waiting for this one to finish. */
240 PPDMACFILETASKSEG pWaitingTail;
241} PDMACFILECACHEENTRY, *PPDMACFILECACHEENTRY;
242/** I/O is still in progress for this entry. This entry is not evictable. */
243#define PDMACFILECACHE_ENTRY_IO_IN_PROGRESS RT_BIT(0)
244/** Entry is locked and thus not evictable. */
245#define PDMACFILECACHE_ENTRY_LOCKED RT_BIT(1)
246/** Entry is dirty */
247#define PDMACFILECACHE_ENTRY_IS_DIRTY RT_BIT(2)
248/** The current buffer used for the entry is deprecated.
249 * The new one is available and will be replaced as soon as the file update
250 * completed.
251 */
252#define PDMACFILECACHE_ENTRY_IS_DEPRECATED RT_BIT(3)
253/** Entry is not evictable. */
254#define PDMACFILECACHE_NOT_EVICTABLE (PDMACFILECACHE_ENTRY_LOCKED | PDMACFILECACHE_IO_IN_PROGRESS | PDMACFILECACHE_ENTRY_IS_DEPRECATED)
255
256/**
257 * LRU list data
258 */
259typedef struct PDMACFILELRULIST
260{
261 /** Head of the list. */
262 PPDMACFILECACHEENTRY pHead;
263 /** Tail of the list. */
264 PPDMACFILECACHEENTRY pTail;
265 /** Number of bytes cached in the list. */
266 uint32_t cbCached;
267} PDMACFILELRULIST;
268
269/**
270 * Global cache data.
271 */
272typedef struct PDMACFILECACHEGLOBAL
273{
274 /** Maximum size of the cache in bytes. */
275 uint32_t cbMax;
276 /** Current size of the cache in bytes. */
277 uint32_t cbCached;
278 /** Critical section protecting the cache. */
279 RTCRITSECT CritSect;
280#ifdef VBOX_WITH_2Q_CACHE
281 uint32_t cbRecentlyUsedInMax;
282 uint32_t cbRecentlyUsedOutMax;
283 PDMACFILELRULIST LruRecentlyUsedIn;
284 PDMACFILELRULIST LruRecentlyUsedOut;
285 PDMACFILELRULIST LruFrequentlyUsed;
286#else
287 /** Adaption parameter (p) */
288 uint32_t uAdaptVal;
289 /** LRU list for recently used entries (T1) */
290 PDMACFILELRULIST LruRecentlyUsed;
291 /** LRU list for frequently used entries (T2) */
292 PDMACFILELRULIST LruFrequentlyUsed;
293 /** LRU list for recently evicted entries (B1) */
294 PDMACFILELRULIST LruRecentlyGhost;
295 /** LRU list for evicted entries from T2 (B2) */
296 PDMACFILELRULIST LruFrequentlyGhost;
297#endif
298#ifdef VBOX_WITH_STATISTICS
299 /** Hit counter. */
300 STAMCOUNTER cHits;
301 /** Partial hit counter. */
302 STAMCOUNTER cPartialHits;
303 /** Miss counter. */
304 STAMCOUNTER cMisses;
305 /** Bytes read from cache. */
306 STAMCOUNTER StatRead;
307 /** Bytes written to the cache. */
308 STAMCOUNTER StatWritten;
309 /** Time spend to get an entry in the AVL tree. */
310 STAMPROFILEADV StatTreeGet;
311 /** Time spend to insert an entry in the AVL tree. */
312 STAMPROFILEADV StatTreeInsert;
313 /** Time spend to remove an entry in the AVL tree. */
314 STAMPROFILEADV StatTreeRemove;
315 /** Number of times a buffer could be reused. */
316 STAMCOUNTER StatBuffersReused;
317#endif
318} PDMACFILECACHEGLOBAL;
319
320/**
321 * Per endpoint cache data.
322 */
323typedef struct PDMACFILEENDPOINTCACHE
324{
325 /** AVL tree managing cache entries. */
326 PAVLRFOFFTREE pTree;
327 /** R/W semaphore protecting cached entries for this endpoint. */
328 RTSEMRW SemRWEntries;
329 /** Pointer to the gobal cache data */
330 PPDMACFILECACHEGLOBAL pCache;
331 /** Number of writes outstanding. */
332 volatile uint32_t cWritesOutstanding;
333 /** Handle of the flush request if one is active */
334 volatile PPDMASYNCCOMPLETIONTASKFILE pTaskFlush;
335#ifdef VBOX_WITH_STATISTICS
336 /** Number of times a write was deferred because the cache entry was still in progress */
337 STAMCOUNTER StatWriteDeferred;
338#endif
339} PDMACFILEENDPOINTCACHE, *PPDMACFILEENDPOINTCACHE;
340
341/**
342 * Global data for the file endpoint class.
343 */
344typedef struct PDMASYNCCOMPLETIONEPCLASSFILE
345{
346 /** Common data. */
347 PDMASYNCCOMPLETIONEPCLASS Core;
348 /** Flag whether we use the failsafe method. */
349 bool fFailsafe;
350 /** Flag whether the file data cache is enabled. */
351 bool fCacheEnabled;
352 /** Flag whether the host cache should be used too. */
353 bool fHostCacheEnabled;
354 /** Critical section protecting the list of async I/O managers. */
355 RTCRITSECT CritSect;
356 /** Pointer to the head of the async I/O managers. */
357 R3PTRTYPE(PPDMACEPFILEMGR) pAioMgrHead;
358 /** Number of async I/O managers currently running. */
359 unsigned cAioMgrs;
360 /** Maximum number of segments to cache per endpoint */
361 unsigned cTasksCacheMax;
362 /** Maximum number of simultaneous outstandingrequests. */
363 uint32_t cReqsOutstandingMax;
364 /** Bitmask for checking the alignment of a buffer. */
365 RTR3UINTPTR uBitmaskAlignment;
366 /** Global cache data. */
367 PDMACFILECACHEGLOBAL Cache;
368 /** Flag whether the out of resources warning was printed already. */
369 bool fOutOfResourcesWarningPrinted;
370} PDMASYNCCOMPLETIONEPCLASSFILE;
371/** Pointer to the endpoint class data. */
372typedef PDMASYNCCOMPLETIONEPCLASSFILE *PPDMASYNCCOMPLETIONEPCLASSFILE;
373
374typedef enum PDMACEPFILEBLOCKINGEVENT
375{
376 /** The invalid event type */
377 PDMACEPFILEBLOCKINGEVENT_INVALID = 0,
378 /** A task is about to be canceled */
379 PDMACEPFILEBLOCKINGEVENT_CANCEL,
380 /** Usual 32bit hack */
381 PDMACEPFILEBLOCKINGEVENT_32BIT_HACK = 0x7fffffff
382} PDMACEPFILEBLOCKINGEVENT;
383
384/**
385 * States of the endpoint.
386 */
387typedef enum PDMASYNCCOMPLETIONENDPOINTFILESTATE
388{
389 /** Invalid state. */
390 PDMASYNCCOMPLETIONENDPOINTFILESTATE_INVALID = 0,
391 /** Normal running state accepting new requests
392 * and processing them.
393 */
394 PDMASYNCCOMPLETIONENDPOINTFILESTATE_ACTIVE,
395 /** The endpoint is about to be closed - not accepting new tasks for endpoints but waiting for
396 * remaining ones to finish.
397 */
398 PDMASYNCCOMPLETIONENDPOINTFILESTATE_CLOSING,
399 /** Removing from current I/O manager state - not processing new tasks for endpoints but waiting
400 * for remaining ones to finish.
401 */
402 PDMASYNCCOMPLETIONENDPOINTFILESTATE_REMOVING,
403 /** The current endpoint will be migrated to another I/O manager. */
404 PDMASYNCCOMPLETIONENDPOINTFILESTATE_MIGRATING,
405 /** 32bit hack */
406 PDMASYNCCOMPLETIONENDPOINTFILESTATE_32BIT_HACK = 0x7fffffff
407} PDMASYNCCOMPLETIONENDPOINTFILESTATE;
408
409/**
410 * Data for the file endpoint.
411 */
412typedef struct PDMASYNCCOMPLETIONENDPOINTFILE
413{
414 /** Common data. */
415 PDMASYNCCOMPLETIONENDPOINT Core;
416 /** Current state of the endpoint. */
417 PDMASYNCCOMPLETIONENDPOINTFILESTATE enmState;
418 /** async I/O manager this endpoint is assigned to. */
419 R3PTRTYPE(volatile PPDMACEPFILEMGR) pAioMgr;
420 /** Flags for opening the file. */
421 unsigned fFlags;
422 /** File handle. */
423 RTFILE File;
424 /** Size of the underlying file.
425 * Updated while data is appended. */
426 volatile uint64_t cbFile;
427 /** Flag whether caching is enabled for this file. */
428 bool fCaching;
429 /** Flag whether the file was opened readonly. */
430 bool fReadonly;
431 /** List of new tasks. */
432 R3PTRTYPE(volatile PPDMACTASKFILE) pTasksNewHead;
433
434 /** Head of the small cache for allocated task segments for exclusive
435 * use by this endpoint. */
436 R3PTRTYPE(volatile PPDMACTASKFILE) pTasksFreeHead;
437 /** Tail of the small cache for allocated task segments for exclusive
438 * use by this endpoint. */
439 R3PTRTYPE(volatile PPDMACTASKFILE) pTasksFreeTail;
440 /** Number of elements in the cache. */
441 volatile uint32_t cTasksCached;
442
443 /** Cache of endpoint data. */
444 PDMACFILEENDPOINTCACHE DataCache;
445
446 /** Flag whether a flush request is currently active */
447 PPDMACTASKFILE pFlushReq;
448
449 /** Event sempahore for blocking external events.
450 * The caller waits on it until the async I/O manager
451 * finished processing the event. */
452 RTSEMEVENT EventSemBlock;
453 /** Flag whether a blocking event is pending and needs
454 * processing by the I/O manager. */
455 bool fBlockingEventPending;
456 /** Blocking event type */
457 PDMACEPFILEBLOCKINGEVENT enmBlockingEvent;
458
459#ifdef VBOX_WITH_STATISTICS
460 /** Time spend in a read. */
461 STAMPROFILEADV StatRead;
462 /** Time spend in a write. */
463 STAMPROFILEADV StatWrite;
464#endif
465
466 /** Additional data needed for the event types. */
467 union
468 {
469 /** Cancelation event. */
470 struct
471 {
472 /** The task to cancel. */
473 PPDMACTASKFILE pTask;
474 } Cancel;
475 } BlockingEventData;
476 /** Data for exclusive use by the assigned async I/O manager. */
477 struct
478 {
479 /** Pointer to the next endpoint assigned to the manager. */
480 R3PTRTYPE(PPDMASYNCCOMPLETIONENDPOINTFILE) pEndpointNext;
481 /** Pointer to the previous endpoint assigned to the manager. */
482 R3PTRTYPE(PPDMASYNCCOMPLETIONENDPOINTFILE) pEndpointPrev;
483 /** List of pending requests (not submitted due to usage restrictions
484 * or a pending flush request) */
485 R3PTRTYPE(PPDMACTASKFILE) pReqsPendingHead;
486 /** Tail of pending requests. */
487 R3PTRTYPE(PPDMACTASKFILE) pReqsPendingTail;
488 /** Number of requests currently being processed for this endpoint
489 * (excluded flush requests). */
490 unsigned cRequestsActive;
491 /** Number of requests processed during the last second. */
492 unsigned cReqsPerSec;
493 /** Current number of processed requests for the current update period. */
494 unsigned cReqsProcessed;
495 /** Flag whether the endpoint is about to be moved to another manager. */
496 bool fMoving;
497 /** Destination I/O manager. */
498 PPDMACEPFILEMGR pAioMgrDst;
499 } AioMgr;
500} PDMASYNCCOMPLETIONENDPOINTFILE;
501/** Pointer to the endpoint class data. */
502typedef PDMASYNCCOMPLETIONENDPOINTFILE *PPDMASYNCCOMPLETIONENDPOINTFILE;
503
504/** Request completion function */
505typedef DECLCALLBACK(void) FNPDMACTASKCOMPLETED(PPDMACTASKFILE pTask, void *pvUser);
506/** Pointer to a request completion function. */
507typedef FNPDMACTASKCOMPLETED *PFNPDMACTASKCOMPLETED;
508
509/**
510 * Transfer type.
511 */
512typedef enum PDMACTASKFILETRANSFER
513{
514 /** Invalid. */
515 PDMACTASKFILETRANSFER_INVALID = 0,
516 /** Read transfer. */
517 PDMACTASKFILETRANSFER_READ,
518 /** Write transfer. */
519 PDMACTASKFILETRANSFER_WRITE,
520 /** Flush transfer. */
521 PDMACTASKFILETRANSFER_FLUSH
522} PDMACTASKFILETRANSFER;
523
524/**
525 * Data of a request.
526 */
527typedef struct PDMACTASKFILE
528{
529 /** next task in the list. */
530 struct PDMACTASKFILE *pNext;
531 /** Endpoint */
532 PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint;
533 /** Transfer type. */
534 PDMACTASKFILETRANSFER enmTransferType;
535 /** Start offset */
536 RTFOFF Off;
537 /** Data segment. */
538 PDMDATASEG DataSeg;
539 /** Flag whether this segment uses a bounce buffer
540 * because the provided buffer doesn't meet host requirements. */
541 bool fBounceBuffer;
542 /** Pointer to the used bounce buffer if any. */
543 void *pvBounceBuffer;
544 /** Start offset in the bounce buffer to copy from. */
545 uint32_t uBounceBufOffset;
546 /** Flag whether this is a prefetch request. */
547 bool fPrefetch;
548 /** Completion function to call on completion. */
549 PFNPDMACTASKCOMPLETED pfnCompleted;
550 /** User data */
551 void *pvUser;
552} PDMACTASKFILE;
553
554/**
555 * Per task data.
556 */
557typedef struct PDMASYNCCOMPLETIONTASKFILE
558{
559 /** Common data. */
560 PDMASYNCCOMPLETIONTASK Core;
561 /** Number of bytes to transfer until this task completes. */
562 volatile int32_t cbTransferLeft;
563 /** Flag whether the task completed. */
564 volatile bool fCompleted;
565} PDMASYNCCOMPLETIONTASKFILE;
566
567int pdmacFileAioMgrFailsafe(RTTHREAD ThreadSelf, void *pvUser);
568int pdmacFileAioMgrNormal(RTTHREAD ThreadSelf, void *pvUser);
569
570int pdmacFileAioMgrNormalInit(PPDMACEPFILEMGR pAioMgr);
571void pdmacFileAioMgrNormalDestroy(PPDMACEPFILEMGR pAioMgr);
572
573int pdmacFileAioMgrCreate(PPDMASYNCCOMPLETIONEPCLASSFILE pEpClass, PPPDMACEPFILEMGR ppAioMgr, bool fFailsafe);
574
575int pdmacFileAioMgrAddEndpoint(PPDMACEPFILEMGR pAioMgr, PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint);
576
577PPDMACTASKFILE pdmacFileEpGetNewTasks(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint);
578PPDMACTASKFILE pdmacFileTaskAlloc(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint);
579void pdmacFileTaskFree(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint,
580 PPDMACTASKFILE pTask);
581
582int pdmacFileEpAddTask(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, PPDMACTASKFILE pTask);
583
584void pdmacFileEpTaskCompleted(PPDMACTASKFILE pTask, void *pvUser);
585
586int pdmacFileCacheInit(PPDMASYNCCOMPLETIONEPCLASSFILE pClassFile, PCFGMNODE pCfgNode);
587void pdmacFileCacheDestroy(PPDMASYNCCOMPLETIONEPCLASSFILE pClassFile);
588int pdmacFileEpCacheInit(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, PPDMASYNCCOMPLETIONEPCLASSFILE pClassFile);
589void pdmacFileEpCacheDestroy(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint);
590
591int pdmacFileEpCacheRead(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, PPDMASYNCCOMPLETIONTASKFILE pTask,
592 RTFOFF off, PCPDMDATASEG paSegments, size_t cSegments,
593 size_t cbRead);
594int pdmacFileEpCacheWrite(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, PPDMASYNCCOMPLETIONTASKFILE pTask,
595 RTFOFF off, PCPDMDATASEG paSegments, size_t cSegments,
596 size_t cbWrite);
597int pdmacFileEpCacheFlush(PPDMASYNCCOMPLETIONENDPOINTFILE pEndpoint, PPDMASYNCCOMPLETIONTASKFILE pTask);
598
599RT_C_DECLS_END
600
601#endif
602
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use