snapuserd: Refactor how buffers are managed.
Currently all I/O is processed through BufferSink. However, the allocation of buffers is implicit in low-level helper functions, which have no knowledge of how much data will actually be sent. As a result, "allocation of buffers" and "tracking of how many bytes were written" is disjoint. This will make it very difficult to break dependence on dm-user, without a much more complex API. This patch refactors how BufferSink is used. First, GetPayloadBuffer has been deprecated in favor of AcquireBuffer. AcquireBuffer performs both allocation and write tracking. The number of bytes written is not necessarily the number of bytes allocated, and the new API allows for this. The "Process" helpers now take in an explicit buffer, and their callers are responsible for allocating a buffer. This allows for ReadUnalignedSector to have proper buffer offset tracking. Because write tracking is now accurate, no explicit size needs to be passed to WriteDmUserPayload. It can simply read the current watermark in BufferSink. This patch also removes XorSink, since its dependence on BufferSink made this change more difficult. Bug: 288273605 Test: snapuserd_test Change-Id: Id9ca5044f9c0386f351b250349793b6b276b01b7
Loading
Please register or sign in to comment