PBlock is minimalistic protocol for serving random-access files using streams.
pblock-srv
- serve a file using pblock stream- should be renamed to
pblock-file
?
- should be renamed to
pblock-read
- read range from pblock stream and print to outputpblock-write
- write to pblock connection at specified offsetpblock-bd
- attach pblock stream as local blok device
Tools in progress:
pblock-mix
- mix many files like in overlay-fs
Tools intended:
pblock-mem
/pblock-exec
/pblock-ld
- map pblock into memory of child processpblock-cp
- copy data from one pblock to anotherpblock-swap
- swap data between to pblockspblock-server
- serve pblock connection over TCP or UNIX domain socket (This will allow for connecting multiple times to single pblock)pblock-hub
- likepblock-server
but works on pipes and client count is fixed in single run (Possibly may be integrated withpblock-mix
?)pblock-mount
- mount stream using fuse interface (Possibly not needed as there ispblock-bd
?)pblock-http
- http(s) (using byte ranges) to pblock stream interface- compression/decompression commnand maybe?
pblock-sniff
- (sniffs only one side of a connection?)pblock-mirror
- parallel usage of multiple underlying pblocks like in RAID-1. (Possibly may be integrated withpblock-mix
?)pblock-cache
- ??? Not sure if possible, necessary and in-good-taste. Don't know how to inalidate cache.pblock-rw
- route READ and WRITE segments to different connections (Possibly may be integrated withpblock-mix
?)
v0.2
- PBlock connection allows for acces to single file.
- PBlock interface works on top of pair of ordered, reliable, unidirectional byte streams.
- PBlock should be minimal and simple. Simple both to understand its operation and to code its implementations.
- Files are infinite, 0-based byte sequences. We have no notion of file size nor of "missing/unset blocks".
- Access to files is transactional. In each transaction one can atomicaly write and read file in many locations, not necessarily coherent.
- PBlock interface should integrate well with zero-copy kernel interfaces like
sendfile()
system call. This will ensure space for performance improvement, especialy in large file-mangling pipelines. - Implementation of multiple readers/single writer locking for transactions should be possible. (This is currently not satisfied, I think.)
- Some obvious things:
- For large transfers PBlock interface shouldn't add much overhead.
No handshaking - this step should be performed by other, speclialized protocol (for example multistream).
No options negotiation - because flags are just unstructural approach to use one codebase for many things.
Just establish your connection and roll.
- Each half of connection is composed of segment objects.
- Each segment has (in order)
- type (byte
r
,w
orc
),r
segments are used to request data rangesw
segments are used to transmit datac
segments commits pending operations
- if type is
r
orw
: offset varint - if type is
r
orw
: length varint - if type is
w
: payload - blob with sizelength
- type (byte
- Client requests atomic reads and writes with
r
andw
segments, then commits transaction withc
segment. - Server processes segments in order and confirms finished atomic actions with
c
segment.- For every
r
segment it must respond withw
segment (with exact same offset and length). - For every
w
segment it performs writes according to is internal semantics.
- For every
There is no such thing as pblock protocol shutdown. Pblock, once initiated, will remain forever.
Yea, thats theory. Adding termination steps will make protocol unnecesarily complex, and we can't rely on underlying streams termination, because they don't have to be closable. Also, adding "stream closability" to axioms is unnecessary assumption.
In practice many streams are closable (UNIX pipes, TCP, ...). When writing implementation for such streams one can do this logic:
- Client can close it's writing stream after each sent segment. This is ok because server can't request any reaction from client, so client won't be needing to write any data.
- Server, after handling all segments, can surely close its writing stream, because client won't be sending anything more. Server knows, that client won't be sending anything more when EOS is detected on client->server stream.