I presume you are talking about --vfs-cache-mode off
here?
I think that is an interesting idea!
As far as I'm aware though the kernel doesn't actually tell us the mapping between open file handles and reads, it just sends read(offset, size) commands to us. So we have to work that out like you suggested.
What we could do is something like this
- we get a read for offset X - open the file and return data
- we get an read for offset Y which needs seeking
- currently we close the reader and reopen at Y
- instead we open a new reader for this
- we can now read at both places. If a reader is not read for 5 seconds we can close it.
This scheme is remarkably similar to the one I implemented for the new --vfs-cache-mode full
which I'm working on at the moment which you try here if you want - this does exactly that but caches the data on the disk in a sparse file.
https://beta.rclone.org/branch/v1.52.1-082-g017d7a53-vfs-beta/
I like the idea of doing this for the cache mode off too. We'd need a way of telling the async reader not to carry on reading ahead until it got another read request otherwise this could potentially over read data - that is the only complication I see.