The entry block
The block service: the device service of one virtio block device (virtio 1.x over PCI, the "modern" interface). It serves the block contract (src/library/modus/contract/block) to one client, through the block ring that the root service gives to both.
It has one device and nothing else: the registers of the device, one message interrupt, memory for the queue, the machine with the right Physical only, and a copy of the configuration of the device. The root service found the device, enabled it and set its interrupt (src/library/modus/pci). The kernel has no code for this device: the code that knows a device is a module: a service or a library. The code that each virtio device service shares is in src/library/modus/virtio.
The device reads and writes the data region of the client: the kernel is not on the path of the data, so data moves with no kernel entry. The service enters the kernel to wait, and to wake its client; one entry serves many requests.
What it is for. It shows two things: a disk driver is a process with no right beyond its one device, and the data of a disk moves with no copy and no kernel entry for each block. The process that uses the disk (its client) holds a data region; the client lends it once with Attach, and the device then reads and writes it directly.
Who uses it. The root service starts a block service when it starts a process with a grant of a disk, for the device at the place of that disk on the bus. It gives the block ring to that one client, and takes the device back when the block service stops:
- the data disk, to the storage service (the grant Data_Disk);
- the disk of the measures, to the process
disk(the grant Scratch_Disk).
No other process can name the device or the ring.
The commands of the block ring (src/library/modus/contract/block), each answered by one completion with the same tag:
Attach: take the data region of the client.Info: the count of blocks of 4096 bytes, the most blocks of one request (64), and 1 if the disk has a cache for writes.Read,Write: a run of blocks, between the disk and a place of the data region.Flush: the writes before it are on the disk when it completes.Statistics: the requests done, the blocks moved, the kernel entries and the interrupts of the service, for a measure.
A refusal gives a status and the values of an error record.
What a reader sees. No window: the line block: ok, <count> blocks of 4096 bytes, a queue of <size>, <count> requests in flight at most, flush: yes on the log. A failure at the start, a request that the device does not answer by its deadline, and a device that needs a reset write a line at the level error and stop the service.
What it does not prove. It drives virtio under QEMU only. On a machine with no IOMMU the device can reach memory beyond the data region, and only the code of this service keeps it inside; with the IOMMU, the device reaches only the queue and the data region, which this service declares with Memory_Physical . The design of the storage above it is in Storage.
block module with an entry
- Hash
341184ad4100a6754d8796d4f39d30d2113c2feb3429949bc415e446e7a0fbcb- Size
45056 bytes- Exports
0- Imports
0- Imported by
0- License
- MIT
The block service: the device service of one virtio block device (virtio 1.x over PCI, the "modern" interface)
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/system/block |
| Boot image | yes: in the boot image, 45056 bytes in this build |
| Build settings | none: the defaults of the source |
| Imports | none |
| Imported by | none |
Neighbours
It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.
Exports
| Export | What it does |
|---|---|
entry() | starts the device and then serves the block ring, until the machine stops |
entry
entry()
entry starts the device and then serves the block ring, until the machine stops.
What it sets up: the machine handle with the right Physical, the message interrupt, the block ring, and the configuration of the device that the root service copied. It finds the virtio registers, resets the device, agrees on the features (Flush when the device has a cache), and gives it the queue (start). It then writes block: ok, ....
The loop. After each wake:
- 1. It gives a completion for each request that the device finished (
harvest). - 2. While the completion side of the ring keeps a place, it takes the next command: a command that waited for a place in the queue of the device goes first.
Read,WriteandFlushgo to the device (submit); the other commands complete at once. A full queue keeps the command for the next turn. - 3. It tells the device of the new requests, and wakes the client when a completion came.
- 4. It waits for the interrupt of the device, for a new command when it has room for one, and at most until the earliest deadline of a request in flight.
The stop: with no ring, no configuration, or no virtio registers, it writes the reason (block: no block ring) at the level error and stops with Failed. A request that the device does not answer by its deadline (system.ANSWER_BOUND_MILLISECONDS after the device got it), and a device that sets its needs-reset bit, end the service too: each request in flight completes with Device_Error and the record No_Answer of the device, the line says the cause, and the service stops with Failed. Else it never returns.
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/system/block/main.odin:392
Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).
What the root service gives it
| What | Value | As the root service says |
|---|---|---|
| Grants | One block device and the ring of its one client (driver_start). | |
| Other terms of its start grant set | none | |
| Budget that it asks for |
| The working memory: the rest of the pages that the root service gave it by its name, once the tool counts its module and its thread. |
The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).
Write type of the package storage_service
Write :: struct {...}
A type with no comment in its source.
