On Tue, Aug 12, 2025 at 11:22 PM Nazir Bilal Yavuz <byavu...@gmail.com> wrote: > Unfortunately this doesn't work. We need to handle backwards I/O > combining in the StartReadBuffersImpl() function too as buffer indexes > won't have correct blocknums. Also, I think buffer forwarding of split > backwards I/O should be handled in a couple of places.
Perhaps there could be a flag pending_read_backwards that can only become set with pending_read_nblocks goes from 1 to 2, and then a new flag stream->ios[x].backwards (in struct InProgressIO) that is set in read_stream_start_pending_read(). Then immediately after WaitReadBuffers(), we reverse the buffers it returned in place if that flag was set. Oh, I see, you were imagining a flag READ_BUFFERS_REVERSE that tells WaitReadBuffers() to do that internally. Hmm. Either way I don't think you need to consider the forwarded buffers because they will be reversed during a later call that includes them in *nblocks (output value), no?