IORequest: Correct major oversight in finished callback API.
The IORequest internally likes to deal with transferEndOffset not transferredBytes because of sub-requests potentially being prepared all at once (in some paths in the I/O scheduler), thus fTransferSize can get incremented in Advance() before we have actually executed that transfer. But external consumers much prefer just knowing transferredBytes not transferEndOffset. And many of them actually named their variables that (or "bytesTransferred") and just passed the transferEndOffset through to variables with that name! That's obviously wrong, and it's surprising it wasn't discovered before now. The problem was uncovered by repeated KDLs in PrecacheIO. That method used the "bytesTransferred" value as a count of pages transferred, which would then run past the end of the array if the transfer start offset was not 0 (which the majority of the time it would be, since this method gets called on the first mmap() of a file, probably before any pages are read in.) Most other consumers of this API did not check the value, it seems, or otherwise had some mitigating factor that prevented it from causing more problems. An exception is the page code, which may have spuriously considered writes as successful when they really weren't. May fix some of the "invalid concurrent access to page" KDLs.
This commit is contained in:
@@ -302,10 +302,10 @@ public:
|
||||
bool partialTransfer,
|
||||
generic_size_t bytesTransferred) = 0;
|
||||
|
||||
static status_t IORequestCallback(void* data,
|
||||
static void IORequestCallback(void* data,
|
||||
io_request* request, status_t status,
|
||||
bool partialTransfer,
|
||||
generic_size_t transferEndOffset);
|
||||
generic_size_t bytesTransferred);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user