mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
Kernel: Merge NVME Queue complete_current_request implementations
Most of the actual logic is identical, with the only real difference being that one wraps it with an async work item. Merge the implementations to reduce duplications (which will also require the fixes in the next commits to only be done once).
This commit is contained in:
parent
4fbc701721
commit
a957907f4b
5 changed files with 40 additions and 72 deletions
|
@ -30,38 +30,4 @@ void NVMePollQueue::submit_sqe(NVMeSubmission& sub)
|
|||
}
|
||||
}
|
||||
|
||||
void NVMePollQueue::complete_current_request(u16 cmdid, u16 status)
|
||||
{
|
||||
SpinlockLocker lock(m_request_lock);
|
||||
auto& request_pdu = m_requests.get(cmdid).release_value();
|
||||
auto current_request = request_pdu.request;
|
||||
AsyncDeviceRequest::RequestResult req_result = AsyncDeviceRequest::Success;
|
||||
|
||||
ScopeGuard guard = [req_result, status, &request_pdu] {
|
||||
if (request_pdu.request)
|
||||
request_pdu.request->complete(req_result);
|
||||
if (request_pdu.end_io_handler)
|
||||
request_pdu.end_io_handler(status);
|
||||
request_pdu.clear();
|
||||
};
|
||||
|
||||
// There can be submission without any request associated with it such as with
|
||||
// admin queue commands during init. If there is no request, we are done
|
||||
if (!current_request)
|
||||
return;
|
||||
|
||||
if (status) {
|
||||
req_result = AsyncBlockDeviceRequest::Failure;
|
||||
return;
|
||||
}
|
||||
|
||||
if (current_request->request_type() == AsyncBlockDeviceRequest::RequestType::Read) {
|
||||
if (auto result = current_request->write_to_buffer(current_request->buffer(), m_rw_dma_region->vaddr().as_ptr(), current_request->buffer_size()); result.is_error()) {
|
||||
req_result = AsyncBlockDeviceRequest::MemoryFault;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue