From aa133b1d8beb8ab1e70b532c59b577e4856970fb Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Sun, 29 Nov 2026 19:53:13 -0800 Subject: [PATCH 01/20] block: add a device-mapper core and targets page Explain how a mapped device is built from a table of ranges, how a table is loaded, suspended, swapped and resumed, and how a bio is cloned, mapped and completed. Cover the linear, thin-provisioning and cache targets, and the history of request-based DM, thin provisioning and the cache target. --- docs/block/README.md | 8 +- docs/block/device-mapper.md | 595 ++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 3 files changed, 601 insertions(+), 3 deletions(-) create mode 100644 docs/block/device-mapper.md diff --git a/docs/block/README.md b/docs/block/README.md index 7f659e9b..8a32b59a 100644 --- a/docs/block/README.md +++ b/docs/block/README.md @@ -49,9 +49,10 @@ The relevant directories are `block/` (core, blk-mq, schedulers), `drivers/nvme/ 5. **[I/O Schedulers](io-schedulers.md)** — BFQ, mq-deadline, and Kyber: what each optimizes for 6. **[Block Cgroup (I/O Control)](blk-cgroup.md)** — dividing a device's bandwidth between cgroups 7. **[NVMe Driver](nvme.md)** — how a real modern driver plugs into blk-mq via submission/completion queues -8. **[Device Mapper: dm-verity](dm-verity.md)** — stacking a virtual block device for integrity verification -9. **[Observability](block-observability.md)** — seeing what the block layer is doing, from counters to blktrace -10. **[War Stories](war-stories.md)** — real block-layer bugs and what they taught +8. **[Device Mapper: Core and Targets](device-mapper.md)** — how a virtual block device is built from a table, with the linear, thin and cache targets +9. **[Device Mapper: dm-verity](dm-verity.md)** — stacking a virtual block device for integrity verification +10. **[Observability](block-observability.md)** — seeing what the block layer is doing, from counters to blktrace +11. **[War Stories](war-stories.md)** — real block-layer bugs and what they taught ### What you'll learn @@ -73,6 +74,7 @@ The relevant directories are `block/` (core, blk-mq, schedulers), `drivers/nvme/ | [I/O Schedulers](io-schedulers.md) | BFQ, mq-deadline, and Kyber | | [Block Cgroup (I/O Control)](blk-cgroup.md) | Dividing device bandwidth per cgroup (`io.max` / `io.weight` / `io.latency`) | | [NVMe Driver](nvme.md) | PCIe SSD architecture, submission/completion queues, blk-mq integration | +| [Device Mapper: Core and Targets](device-mapper.md) | Tables, the bio path, suspend and swap, and the linear, thin-provisioning and cache targets | | [Device Mapper: dm-verity](dm-verity.md) | Merkle-tree block integrity verification (Android, ChromeOS) | | [Observability](block-observability.md) | `/proc/diskstats`, `blktrace`, and BPF for block I/O | | [War Stories](war-stories.md) | Real block-layer incidents and their lessons | diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md new file mode 100644 index 00000000..bee12723 --- /dev/null +++ b/docs/block/device-mapper.md @@ -0,0 +1,595 @@ +# Device Mapper: The Core and Three Targets + +> How the kernel builds a virtual block device from a table of ranges, and what the linear, thin-provisioning and cache targets do with it + +Source links point at Linux v7.4-rc5, the tree this page was checked against. Release numbers are mainline releases. Dates are author dates for commits and the dates shown on the page for LWN postings. + +## What it is + +A device-mapper device is a block device whose I/O is handled by the device-mapper core instead of a hardware driver. What the device does with an I/O is set by its *table*: a list of ranges of the device's sectors, each handled by a *target*. A range is added with a start, a length, a target type name and a parameter string ([`dm_table_add_target()`][dmt686]), and the target's constructor receives the parameters split into arguments ([dm-table.c:759-765][dmt759]). + +``` + mapped device (one gendisk, one table) + ┌─────────────────────┬───────────────────────────────┐ + │ sectors 0 - 999 │ sectors 1000 - 4999 │ + │ target: linear │ target: linear │ + │ /dev/sda, offset 0 │ /dev/sdb, offset 2048 │ + └─────────────────────┴───────────────────────────────┘ +``` + +The diagram is an illustrative table; both ranges use the [`linear` target](#linear-the-smallest-target). + +A device is either *bio-based* or *request-based* (see [below](#bio-based-and-request-based-devices)). A bio-based device gets `dm_submit_bio()` as its `.submit_bio` ([dm.c:3813][dm3813]); a request-based device gets a different set of operations ([dm.c:2624][dm2624]) that has no `.submit_bio` ([dm.c:3825-3832][dm3825]). Unless a section says otherwise, this page describes bio-based devices. + +[dm-verity](dm-verity.md) and [dm-crypt](../security/dm-crypt.md) are other targets and have their own pages. This page covers the core and three targets that show its range. + +!!! info "Terms used on this page" + - **bio**: the block layer's I/O descriptor; see [bio and request structures](bio-request.md). + - **clone**: a copy of a bio made by the core for one target, from `bio_alloc_clone()` ([dm.c:626][dm626]). + - **flush and FUA**: `REQ_PREFLUSH` is a "request for cache flush" ([blk_types.h:401][blk401]) and `REQ_FUA` is "forced unit access" ([blk_types.h:400][blk400]). `op_is_flush()` is true for either ([blk_types.h:477-480][blk477]). + - **`REQ_NOWAIT` and read-ahead**: `REQ_NOWAIT` means "Don't wait if request will block" ([blk_types.h:404][blk404]); `REQ_RAHEAD` means "read ahead, can fail anytime" ([blk_types.h:402][blk402]). + - **SRCU**: a read-side locking scheme whose readers may sleep; see [SRCU](../locking/srcu.md). The core uses it to find out when no thread is still using an old table. + - **gendisk**: the kernel's structure for a disk; each mapped device owns one ([dm-core.h:78][core78]). + +The core keeps its own structures private. The header says that targets "must _not_ deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). + +## The control interface + +Userspace manages devices through a misc device whose node is `mapper/control` ([dm-ioctl.c:2299-2302][ioc2299]). The commands are a table of ioctl handlers ([dm-ioctl.c:1985-2008][ioc1985]). + +| Command | Handler | What the handler does | +|---|---|---| +| `DM_DEV_CREATE` | `dev_create` | Creates the mapped device and adds it to the device hash ([dm-ioctl.c:977-981][ioc977]) | +| `DM_TABLE_LOAD` | `table_load` | Builds a table and stages it as the inactive table ([dm-ioctl.c:1639-1689][ioc1639]) | +| `DM_DEV_SUSPEND` | `dev_suspend` | Suspends the device if `DM_SUSPEND_FLAG` is set, otherwise resumes it ([dm-ioctl.c:1363-1368][ioc1363]) | + +The table also lists commands to remove and rename a device, to read device and table status, to wait for an event, to clear a table, and to send a message to a target. The interface is versioned; the kernel refuses a caller whose major version differs from its own or whose minor version is newer ([dm-ioctl.c:2034-2035][ioc2034], major 4 at [dm-ioctl.h:293][ioh293]). + +## Two tables: load, then swap + +A device with no live table fails the bios submitted to it: `dm_submit_bio()` calls `bio_io_error()` ([dm.c:2086-2090][dm2086]). + +Loading a table does not change the live one. `table_load()` creates a table, adds every target to it with `populate_table()` ([dm-ioctl.c:1639-1645][ioc1639]), and stores it as the device's new, inactive map ([dm-ioctl.c:1687-1689][ioc1687]). A second load replaces a staged table that was never resumed ([dm-ioctl.c:1702-1705][ioc1702]). Completing a table decides its type, builds the sector index, builds the crypto profile and allocates the memory pools for clones ([`dm_table_complete()`][dmt1521]). + +The swap happens on resume. When a table is staged, `do_resume()` suspends the device if it is not already suspended ([dm-ioctl.c:1284-1286][ioc1284]), calls `dm_swap_table()` ([dm-ioctl.c:1311][ioc1311]), and then resumes it ([dm-ioctl.c:1331-1333][ioc1331]). With no staged table it only resumes ([dm-ioctl.c:1274][ioc1274]). + +```mermaid +flowchart LR + L["DM_TABLE_LOAD
build table, run each target's ctr
stage as inactive
live table unchanged"] + S["suspend
presuspend hooks
freeze filesystem (optional)
block new bios, wait for in-flight bios"] + W["swap
the new table becomes live
wait for readers of the old one"] + R["resume
target resume hooks
replay queued bios"] + L --> S --> W --> R +``` + +**Suspend.** `__dm_suspend()` calls the targets' `presuspend`. If the caller asked for a filesystem freeze and did not ask for no-flush, it then calls `lock_fs()`, which freezes the filesystem on the device ([dm.c:2951][dm2951]) and, per its comment, "flushes I/Os and waits for them to complete" ([dm.c:2996-3010][dm2996], condition at [dm.c:3004][dm3004]; the freeze is skipped when userspace passes `DM_SKIP_LOCKFS_FLAG`, [dm-ioctl.c:1280-1281][ioc1280]). It then sets `DMF_BLOCK_IO_FOR_SUSPEND`, waits with `synchronize_srcu()` for any thread still inside the map path, flushes the device's workqueue, and waits for in-flight I/O to finish ([dm.c:3023-3044][dm3023]). + +!!! note "What happens to bios during a suspend (bio-based)" + While `DMF_BLOCK_IO_FOR_SUSPEND` is set, `dm_submit_bio()` queues ordinary bios on a list. A `REQ_NOWAIT` bio fails with `bio_wouldblock_error()` and a read-ahead bio fails with `bio_io_error()` ([dm.c:2094-2102][dm2094]). A request-based device stops its request queue instead ([dm.c:3031-3034][dm3031]), and the deferred requests wait in that queue ([dm.c:3137][dm3137]). + +**Swap.** `dm_swap_table()` refuses to run unless the device is suspended ([dm.c:2898][dm2898]). It computes the queue limits for the new table ([dm.c:2925-2927][dm2925]); `__bind()` then publishes the table with `rcu_assign_pointer()` and waits for readers of the old one ([dm.c:2534-2539][dm2534]). + +**Resume.** `__dm_resume()` resumes the targets ([dm.c:3125-3130][dm3125]), restarts the queued bios, and unlocks the filesystem ([dm.c:3132-3142][dm3132]). The comment gives the order's reason: "Flushing deferred I/Os must be done after targets are resumed so that mapping of targets can work correctly" ([dm.c:3134-3137][dm3134]). `dm_wq_work()` replays the queue with `submit_bio_noacct()` ([dm.c:2864-2874][dm2864]). + +## The sector index + +A table maps a sector to a target. `dm_table_find_target()` walks an index whose nodes are one cache line wide and hold sector keys ([dm-table.c:30-32][dmt30], [dm-table.c:1581-1599][dmt1581]). A sector past the end of the table returns no target ([dm-table.c:1586-1587][dmt1586]), and the I/O path fails the bio with `BLK_STS_IOERR` ([dm.c:1736-1738][dm1736]). + +`dm_table_add_target()` rejects a range that has zero length ([dm-table.c:704-707][dmt704]) and a range that does not start where the previous one ended ([dm-table.c:754-757][dmt754]). A target type's feature flags add further rules: + +| Feature | Meaning | Where enforced | +|---|---|---| +| `DM_TARGET_SINGLETON` | Must be the only target in a table | [dm-table.c:719-725][dmt719] | +| `DM_TARGET_ALWAYS_WRITEABLE` | Not allowed in a read-only table | [dm-table.c:727-731][dmt727] | +| `DM_TARGET_IMMUTABLE` | Cannot be mixed with other target types in one table | [dm-table.c:733-744][dmt733] | +| `DM_TARGET_IMMUTABLE` | Once a device has it, a later table must use the same type, unless it contains a wildcard target | [dm-ioctl.c:1649-1657][ioc1649] | +| `DM_TARGET_WILDCARD` | May replace any target, even an immutable one | [device-mapper.h:254-258][dmh254] | + +## The I/O path for bio-based devices + +A bio reaches the device through `dm_submit_bio()`, which takes the live table under SRCU ([dm.c:2085][dm2085]) and calls `dm_split_and_process_bio()` ([dm.c:2104][dm2104]). + +``` + bio for the mapped device + │ + ▼ + dm_submit_bio ── no table / suspended ──► error / queue (see above) + │ + ▼ + dm_split_and_process_bio + │ find target for the first sector + │ clone the bio, trimmed to the target boundary + ▼ + __map_bio ──► target->map(clone) + │ + ├─ DM_MAPIO_REMAPPED ───┐ core submits the clone to the lower device + ├─ DM_MAPIO_SUBMITTED ──┤ target owns the clone + │ ▼ + │ (lower device completes the clone) + │ │ + │ ▼ + │ clone_endio ──► target->end_io (optional) + │ │ + │ ▼ + │ last clone done? ──► original bio completes + │ + └─ KILL / REQUEUE ──► clone freed, status recorded on the I/O +``` + +1. **Clone.** `__split_and_process_bio()` finds the target for the current sector ([dm.c:1736][dm1736]) and limits the length to the target's maximum I/O length and the sectors left ([dm.c:1749][dm1749]). `alloc_tio()` supplies the clone: the first one is embedded in the per-I/O structure `dm_io`, later ones come from `bio_alloc_clone()` ([dm.c:620-626][dm620]). The clone's default device is the mapped device itself, so the target must change it before the bio is issued ([dm.c:645-646][dm645]). +2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2051-2058][dm2051]). +3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). +4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The original bio completes when the count of outstanding clones reaches zero ([dm.c:1047-1055][dm1047]). + +What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], values at [device-mapper.h:710-714][dmh710]): + +| Return value | Core's action | +|---|---| +| `DM_MAPIO_REMAPPED` | Submits the clone to the device the target set, with `dm_submit_bio_remap()` | +| `DM_MAPIO_SUBMITTED` | Does nothing more; the target owns the clone and will complete or submit it | +| `DM_MAPIO_REQUEUE` | Frees the clone and records `BLK_STS_DM_REQUEUE` as the I/O's status | +| `DM_MAPIO_KILL` | Frees the clone and records `BLK_STS_IOERR` as the I/O's status | + +!!! warning "`DM_MAPIO_DELAY_REQUEUE` is not a bio-based return value" + The value is defined next to the others, but the switch in `__map_bio()` has no case for it and ends in `BUG()` ([dm.c:1457-1459][dm1457]). The request-based path handles it ([dm-rq.c:412][rq412]). + +**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios` and `num_secure_erase_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then the flush with data goes straight to that device ([dm.c:2018-2039][dm2018]). + +## Bio-based and request-based devices + +A table is bio-based, request-based or DAX bio-based ([device-mapper.h:29-34][dmh29]); DAX is the direct-access variant of bio-based. The type comes from the targets: a table that mixes bio-based and request-based targets is rejected ([dm-table.c:941-944][dmt941]). A request-based table must have a single target ([dm-table.c:981-984][dmt981]). Unless the table has no devices, that target must be immutable ([dm-table.c:986-1000][dmt986]). A device keeps the type of its first table; a later table of a different type is refused, except that a bio-based device may become DAX bio-based ([dm-ioctl.c:1617-1624][ioc1617], [dm-ioctl.c:1666-1671][ioc1666]). + +A request-based target works on `struct request`, through a `clone_and_map_rq` callback ([device-mapper.h:63][dmh63]). The multipath target is the example in the tree. It is a singleton and immutable, implements `clone_and_map_rq` ([dm-mpath.c:2299-2306][mpath2299]) and defaults to request-based; the `queue_mode bio` option makes it bio-based ([dm-mpath.c:240-245][mpath240], [dm-mpath.c:1161-1169][mpath1161]). + +The 2008 posting of the request-based series explains the difference: "Mapping is done in a unit of struct request, instead of struct bio" ([LWN, 2008-09-12][lwn298882]). The commit that enabled request-based DM, `e6ee8c0b767540f59e20da3ced282601db8aa502` ("dm: enable request based option", Linux 2.6.31, 2009-06-22), gives the reason for keeping both: "there are some target drivers which are more fitting to bio-based dm". It also states the limit that is still in the code: request-based DM supports only tables with a single target. + +## The target interface + +A target type is a `struct target_type`: a name, a version, feature flags and a set of callbacks ([device-mapper.h:198-228][dmh198]). Where the core calls them: + +| Callback | Called by the core | +|---|---| +| `ctr` | When the range is added to a table ([dm-table.c:765][dmt765]) | +| `dtr` | When the table is destroyed ([dm-table.c:197-198][dmt197]) | +| `map` | For each bio-based I/O ([dm.c:1435][dm1435]) | +| `end_io` | When the clone completes ([dm.c:1114-1115][dm1114]) | +| `presuspend`, `postsuspend` | Around a suspend ([dm-table.c:2171-2194][dmt2171]) | +| `preresume`, `resume` | While resuming ([dm-table.c:2195-2215][dmt2195]) | + +`status`, `message`, `iterate_devices` and `io_hints` are also members of the struct ([device-mapper.h:215-221][dmh215]). A target's constructor opens the underlying devices with `dm_get_device()` ([device-mapper.h:185-186][dmh185]). Each range has a `struct dm_target` with its `begin`, `len` and optional `max_io_len` ([device-mapper.h:312-321][dmh312]). + +Targets are kept in a list under a read-write semaphore ([dm-target.c:18-19][tgt18]). When the named type is missing, the core runs `request_module("dm-%s", name)` and looks again ([dm-target.c:46-49][tgt46], [dm-target.c:51-58][tgt51]). + +## linear: the smallest target + +A `linear` range is ` ` ([dm-linear.c:28][lin28]): the whole range maps onto one device at a fixed offset. The map function sets the device and adds the offset to the position within the range: + +```c +static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector) +{ + struct linear_c *lc = ti->private; + + return lc->start + dm_target_offset(ti, bi_sector); +} + +int linear_map(struct dm_target *ti, struct bio *bio) +{ + struct linear_c *lc = ti->private; + + bio_set_dev(bio, lc->dev->bdev); + bio->bi_iter.bi_sector = linear_map_sector(ti, bio->bi_iter.bi_sector); + + return DM_MAPIO_REMAPPED; +} +``` + +*Quoted from [dm-linear.c:82-97][lin82].* It returns `DM_MAPIO_REMAPPED`, so the core submits the clone. The constructor asks for one copy each of flush, discard, secure-erase and write-zeroes bios and sets `flush_bypasses_map` ([dm-linear.c:61-65][lin61]). + +## thin provisioning + +Thin provisioning uses two target types ([dm-thin.c:4109-4110][thin4109], [dm-thin.c:4493-4494][thin4493]): + +| | `thin-pool` | `thin` | +|---|---|---| +| Role | Owns the storage: a metadata device and a data device split into blocks | One virtual device carved out of a pool | +| Table line | ` ` and optional features ([dm-thin.c:3274-3284][thin3274]) | Names a pool | +| Features | Singleton, always writeable, immutable ([dm-thin.c:4111-4112][thin4111]) | — | + +The data block size must be at least 64 KB, at most 1 GB, and a multiple of 64 KB ([dm-thin.c:41-46][thin41], [dm-thin.c:3345-3348][thin3345]). According to the commit that added the target, many virtual devices are stored on the same data volume, and snapshots can be taken of snapshots (see [Snapshots](#snapshots)). A pool is managed with messages: `create_thin`, `create_snap`, `delete`, `set_transaction_id`, `reserve_metadata_snap` and `release_metadata_snap` ([dm-thin.c:3855-3871][thin3855]). + +### Metadata + +The file header of the metadata code describes the layout ([dm-thin-metadata.c:20-34][tm20]): + +``` + metadata device + ┌────────────┬─────────────────────┬───────────────────────┬─────────────────────────┐ + │ superblock │ space map: │ btree: │ two-level btree: │ + │ (block 0) │ metadata + data │ thin device id │ (device id, virtual │ + │ │ blocks │ → device details │ block) → block_time │ + └────────────┴─────────────────────┴───────────────────────┴─────────────────────────┘ + block_time = 24-bit time (low bits) + 40-bit data block (high bits) +``` + +The superblock is small enough for an atomic write. The btrees and space maps come from the persistent-data library, which was added in the same release as thin provisioning (`3241b1d3e0aaafbfcd320f4d71ade629728cc4f4`, "dm: add persistent data library", Linux 3.2, 2011-10-31). + +### The path of a bio + +`thin_map()` rebases the sector and calls `thin_bio_map()` ([dm-thin.c:4326-4331][thin4326]), which handles the bio when it can and otherwise hands it to the pool's worker thread ([dm-thin.c:2722][thin2722]). To decide, it takes a *cell* on the virtual block (a lock on that block, held by the first bio that reaches it) and looks the block up without issuing metadata I/O ([dm-thin.c:2754-2758][thin2754]). + +```mermaid +flowchart TD + A["bio for a thin device"] --> B{"flush, FUA
or discard?"} + B -- yes --> W["pool worker"] + B -- no --> C{"look up the
virtual block"} + C -- "mapped, not shared" --> R["remap to the data block
DM_MAPIO_REMAPPED"] + C -- "shared, not mapped,
or lookup would block" --> W + W --> D{"block state"} + D -- "shared, write" --> S["break_sharing:
allocate a block,
copy unless whole-block write"] + D -- "shared, read" --> RR["remap to the shared block"] + D -- "not mapped, read" --> Z["zero-fill, or read
from the external origin"] + D -- "not mapped, write" --> P["allocate a data block"] + P --> Q{"external
origin?"} + Q -- yes --> E["copy from the origin"] + Q -- no --> F["zero the block unless the
write covers all of it"] + S --> M["insert mapping
release held bios"] + E --> M + F --> M +``` + +The anchors for the diagram: + +- Flushes and discards go to the worker ([dm-thin.c:2745-2748][thin2745]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2784-2795][thin2784]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2765-2782][thin2765], [dm-thin.c:2797-2800][thin2797]). +- A write to a shared block breaks the sharing; a read of one is remapped to the shared block ([dm-thin.c:1888-1900][thin1888]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1800-1813][thin1800]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device, or, for a thin device with an external origin, read from the origin ([dm-thin.c:1978-1993][thin1978]). A write allocates a data block ([dm-thin.c:1931][thin1931]), then copies from the origin if there is one ([dm-thin.c:1934-1935][thin1934]); otherwise it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). + +### When metadata reaches disk + +Changes to the mapping sit in an open metadata transaction until `commit()` calls `dm_pool_commit_metadata()` ([dm-thin.c:1490][thin1490]). A bio with a flush or FUA flag that arrives after its thin device has changed the transaction does not go straight down: `issue()` puts it on a list, and one commit serves all bios on the list ([dm-thin.c:735-738][thin735], [dm-thin.c:756-777][thin756]). The comment on a related path says why: "If the bio has the REQ_FUA flag set we must commit the metadata before signaling its completion" ([dm-thin.c:964-966][thin964]). + +The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2387-2388][thin2387], [dm-thin.c:33][thin33], [dm-thin.c:2110-2114][thin2110]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2403-2411][thin2403]). + +### Snapshots + +`create_snap` makes the snapshot's mapping tree by taking another reference to the origin's tree root: "clone the origin, an inc will do" ([dm-thin-metadata.c:1205-1206][tm1205]). It then bumps the pool's time counter and records it as the *snapshotted time* of both devices ([dm-thin-metadata.c:1218-1224][tm1218], [dm-thin-metadata.c:1174-1178][tm1174]). + +A block counts as shared when the time stored with it is older than the device's last snapshot ([dm-thin-metadata.c:1500-1509][tm1500], [dm-thin-metadata.c:1521][tm1521]). + +!!! warning "Quiesce the origin before taking a snapshot" + `thin_bio_map()` has a window between its lookup and snapshot creation. The comment gives the rule that avoids it: "always quiesce the origin before taking the snap" ([dm-thin.c:2767-2776][thin2767]). + +The commit that added thin provisioning (`991d9fa02da0dd1f843dc011376965e0c8c6c9b5`, Linux 3.2, 2011-10-31) says how it differs from the earlier snapshot implementation: "The previous implementation of snapshots did this by chaining together lookup tables, and so performance was O(depth). This new implementation uses a single data structure so we don't get this degradation with depth." + +### Running out of space + +The pool has a mode, ordered from healthy to failed ([dm-thin.c:203-214][thin203]). + +```mermaid +stateDiagram-v2 + direction LR + [*] --> PM_WRITE + PM_WRITE --> PM_OUT_OF_DATA_SPACE: no free data block, even after a commit + PM_OUT_OF_DATA_SPACE --> PM_WRITE: a commit finds free data blocks + PM_WRITE --> PM_OUT_OF_METADATA_SPACE: no free metadata block + PM_WRITE --> PM_READ_ONLY: a metadata operation fails + PM_WRITE --> PM_FAIL: aborting the transaction fails + PM_FAIL --> PM_FAIL: never left +``` + +| Transition | Source | +|---|---| +| `PM_WRITE` → `PM_OUT_OF_DATA_SPACE` | `alloc_data_block()` finds no free block after a commit, or the allocation returns `-ENOSPC` ([dm-thin.c:1545-1547][thin1545], [dm-thin.c:1553-1554][thin1553]) | +| `PM_OUT_OF_DATA_SPACE` → `PM_WRITE` | After a commit, `check_for_data_space()` finds free blocks ([dm-thin.c:1473-1475][thin1473], called from [dm-thin.c:1494-1495][thin1494]) | +| → `PM_OUT_OF_METADATA_SPACE` | `check_for_metadata_space()` finds no free metadata block and the pool is not already read-only ([dm-thin.c:1452-1458][thin1452]) | +| → `PM_READ_ONLY` | A metadata operation failed: the transaction is aborted and the mode set ([dm-thin.c:2657-2663][thin2657]) | +| → `PM_FAIL` | Aborting the transaction, or setting the `needs_check` flag, failed ([dm-thin.c:2646-2654][thin2646]) | +| out of `PM_FAIL` | Never: "we never let the pool move out of the old mode" ([dm-thin.c:2563-2568][thin2563]) | +| to `PM_WRITE` when `needs_check` is set | Refused ([dm-thin.c:2551-2561][thin2551]) | +| `PM_OUT_OF_METADATA_SPACE` → `PM_WRITE` | The source comment says it may switch back on a metadata resize ([dm-thin.c:207-209][thin207]) | + +What each mode does with a bio: + +| Mode | Source comment | Behaviour | +|---|---|---| +| `PM_WRITE` | metadata may be changed | Served normally | +| `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only bio path ([dm-thin.c:2605-2608][thin2605]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | +| `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2583-2590][thin2583]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | +| `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write to a shared or unmapped block is unserviceable and fails ([dm-thin.c:2033-2064][thin2033]) | +| `PM_FAIL` | all I/O fails | Every bio fails ([dm-thin.c:2740-2743][thin2740]) | + +When free data blocks drop to the low water mark the pool raises an event on the device once ([dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2448-2462][dm2448]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2597-2603][thin2597]). + +!!! warning "Held bios can fail after a timeout" + By default, bios held in `PM_OUT_OF_DATA_SPACE` wait at most 60 seconds: `no_space_timeout` is a module parameter and a value of 0 arms no timer ([dm-thin.c:34][thin34], [dm-thin.c:4553][thin4553], [dm-thin.c:2612-2613][thin2612]). When it expires with the pool still out of data space, the pool sets `error_if_no_space` and fails the queued bios with `BLK_STS_NOSPC` ([dm-thin.c:2449-2458][thin2449]). + +## cache + +The `cache` target puts a fast device in front of a slow one. Its table line is ` `, a feature list and a policy with its arguments ([dm-cache-target.c:2026-2043][cache2026]). The kernel documentation says it "aims to improve performance of a block device (eg, a spindle) by dynamically migrating some of its data to a faster, smaller device (eg, an SSD)" ([cache.rst:11-13][cacherst11]) and that it "reuses the metadata library used in the thin-provisioning library" ([cache.rst:20-21][cacherst20]). + +### Three I/O modes + +The comments are at [dm-cache-target.c:255-275][cache255]; the arguments that select the mode are parsed at [dm-cache-target.c:2211-2224][cache2211], and writeback is the default ([dm-cache-target.c:2185][cache2185]). + +| Mode | Where a hit goes | Can the cache hold data newer than the origin? | What the source comment says | +|---|---|---|---| +| writeback | cache | ✓ | "Data is written to cached blocks only. These blocks are marked dirty. If you lose the cache device you will lose data." | +| writethrough | cache; a write to a clean block goes to both devices ([dm-cache-target.c:1746-1748][cache1746]) | ✗ | "Data is written to both cache and origin. Blocks are never dirty." | +| passthrough | origin; a write also invalidates the cache block ([dm-cache-target.c:1738-1744][cache1738]) | ✗ | "Reads and writes always go to the origin. If a write goes to a cached oblock, then the cache block is invalidated." | + +!!! warning "Writeback loses data with the cache device" + In writeback mode the cache can hold the only up-to-date copy of a block. The source comment says so directly: "If you lose the cache device you will lose data" ([dm-cache-target.c:257-260][cache257]). + +### The map path + +`cache_map()` sends bios for the partial block at the end of the origin straight to the origin, because those blocks are not cached ([dm-cache-target.c:2683-2692][cache2683]). It defers discards and flush or FUA bios to a worker ([dm-cache-target.c:2694-2697][cache2694], [dm-cache-target.c:1007-1010][cache1007]). Everything else goes to `map_bio()`, which takes a shared lock on the block and asks the policy about it ([dm-cache-target.c:1666-1698][cache1666]). + +```mermaid +flowchart TD + A["bio for the cache device"] --> B{"past the last
whole origin block?"} + B -- yes --> O1["origin"] + B -- no --> C{"discard, flush
or FUA?"} + C -- yes --> W["worker"] + C -- no --> D{"policy lookup"} + D -- miss --> O2["origin"] + D -- hit --> E{"mode"} + E -- "writeback" --> CA["cache"] + E -- "writethrough" --> F{"write to a
clean block?"} + F -- yes --> BOTH["origin and cache"] + F -- no --> CA + E -- "passthrough" --> G{"write?"} + G -- yes --> INV["invalidate the cache block"] + G -- no --> O3["origin"] +``` + +- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1716-1719][cache1716]). +- **Hit:** as in the table above ([dm-cache-target.c:1738-1751][cache1738]). +- **FUA:** the bio is issued after the metadata commit ([dm-cache-target.c:1758-1766][cache1758]). + +### The policy decides what moves + +The core does not decide what to cache. A policy plug-in is asked about each bio, and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1916-1941][cache1916]). + +The tree registers four policy names: `smq`, `mq`, `cleaner` and `default` ([dm-cache-policy-smq.c:1885-1939][smq1885]). The first three are created by the same function, `__smq_create()`, with different flag arguments ([dm-cache-policy-smq.c:1858-1880][smq1858]); `default` points at the `smq` type through `.real` ([dm-cache-policy-smq.c:1909-1914][smq1909]). + +One shortcut avoids the copy. In writeback mode, a bio to a discarded block or one that writes a whole block is looked up with `policy_lookup_with_work()` ([dm-cache-target.c:1073-1077][cache1073], [dm-cache-target.c:1680-1696][cache1680]). The policy header explains the method: the core "needs the migration immediately though so it knows to do something different with the bio" ([dm-cache-policy.h:60-64][pol60]). The migration then uses `overwrite()` in place of a full copy, falling back to the full copy if the bio is no longer eligible ([dm-cache-target.c:1369-1395][cache1369]). + +The commit that added the target (`c6b4fcbad044e6fffcc75bba160e720eb8d67d17`, "dm: add cache target", Linux 3.9, 2013-03-01) states the design choice: "A plug-in architecture was chosen so that the decisions about which data to migrate and when are delegated to interchangeable tunable policy modules." + +Cache uses version 2 of the bio prison, the structure behind the cells described above ([dm-cache-target.c:9][cache9], [dm-cache-target.c:1083][cache1083]); thin provisioning uses version 1 ([dm-thin.c:9][thin9]). Version 2 came in Linux 4.12 (`742c8fdc31e820503f9267070311d894978d1349`, "dm bio prison v2: new interface for the bio prison", 2016-10-21). + +## Where it came from + +```mermaid +timeline + 2002 : dm-ioctl submitted for review + 2006 : request-based dm RFC + 2009 : request-based dm merged (2.6.31) + 2011 : thin provisioning and persistent-data library (3.2) + 2013 : cache target (3.9) + 2015 : request-based dm on blk-mq (4.1) + 2022 : dm_submit_bio_remap (5.18) +``` + +| When | What | Evidence | +|---|---|---| +| 2002-10-15 | The ioctl interface to device-mapper is posted: "Provide a traditional ioctl based interface to control device-mapper from userland." | [LWN: Device-mapper submission 6/7][lwn12734] | +| 2.6.12 (tag `v2.6.12-rc2`, 2005-04-16, the first commit in the git history) | `dm-linear.c` and `dm-ioctl.c` already exist; `dm-linear.c` carries "Copyright (C) 2001-2003 Sistina Software (UK) Limited." ([dm-linear.c:3][lin3]) | `1da177e4c3f41524e886b7f1b8a0c1fc7321cac2` | +| 2006-12-19 | RFC for request-based DM: "Hook for I/O mapping is at request_fn after merging and sorting by I/O scheduler, instead of make_request_fn." | [LWN: rqbased-dm][lwn215058] | +| 2008-03-19 | The series is reposted for discussion: "Currently, device-mapper (dm) is implemented as a stacking block device at bio level." | [LWN: request stacking and request-based dm-multipath][lwn274292] | +| 2008-09-12, 2008-10-03 | Version 2 (13 patches) and version 3 (8 patches) | [LWN v2][lwn298882], [LWN v3][lwn301919] | +| 2.6.31 (2009-06-22) | Request-based DM is prepared and enabled | `cec47e3d4a861e1d942b3a580d0bbef2700d2bb2`, `e6ee8c0b767540f59e20da3ced282601db8aa502` | +| 3.2 (2011-10-31) | Persistent-data library, then thin provisioning | `3241b1d3e0aaafbfcd320f4d71ade629728cc4f4`, `991d9fa02da0dd1f843dc011376965e0c8c6c9b5` | +| 3.9 (2013-03-01) | `cache` target; the documentation was posted on LWN on 2013-03-04 | `c6b4fcbad044e6fffcc75bba160e720eb8d67d17`, [LWN: cache.txt][lwn540996] | +| 4.0 (2014-12-17) | Requests are allocated in the target when stacking on blk-mq devices; the commit that follows calls this "the first step toward fully utilizing blk-mq in request-based DM" | `e5863d9ad754926e7d3f38b43ac8bd48ef73b097` | +| 4.1 (2015-03-08) | The mapped device's own queue becomes blk-mq: "enables stacking a blk-mq request_queue ontop of the underlying blk-mq device(s)" | `bfebd1cdb497a57757c83f5fbf1a29931591e2a4` | +| 4.12 (2016-10-21) | Bio prison v2 | `742c8fdc31e820503f9267070311d894978d1349` | +| 5.18 (2022-02-17) | `dm_submit_bio_remap()` lets a target that submits clones itself have them accounted when it submits them, if it sets `accounts_remapped_io` | `0fbb4d93b38bce1f8235aacfa37e90ad8f011473` | +| 5.19 (2022-04-12) | Reworked bio splitting and I/O accounting | `7dd76d1feec70a23e1de2b55c0c2a9c592fa8423` | + +The original list postings for the thin-provisioning (2011) and cache (2013) commits are not linked: the commits carry no `Link:` trailer. + +## Further reading + +- [Block Layer Overview](block-overview.md) and [bio and request structures](bio-request.md): the structures a mapped device receives and clones. +- [blk-mq](blk-mq.md): the queues that request-based DM sits on. +- [dm-verity](dm-verity.md) and [dm-crypt](../security/dm-crypt.md): two other targets. +- Kernel documentation: [thin-provisioning.rst][thinrst], [cache.rst][cacherst] and the rest of [Documentation/admin-guide/device-mapper/][dmdocs]. + +[blk400]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n400 +[blk401]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n401 +[blk402]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n402 +[blk404]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n404 +[blk477]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n477 +[cache1007]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1007 +[cache1073]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1073 +[cache1083]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1083 +[cache1369]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1369 +[cache1666]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1666 +[cache1680]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1680 +[cache1716]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1716 +[cache1738]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1738 +[cache1746]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1746 +[cache1758]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1758 +[cache1916]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1916 +[cache2026]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2026 +[cache2185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2185 +[cache2211]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2211 +[cache255]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n255 +[cache257]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n257 +[cache2683]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2683 +[cache2694]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2694 +[cache9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n9 +[cacherst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5 +[cacherst11]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5#n11 +[cacherst20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5#n20 +[core35]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n35 +[core78]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n78 +[dm1047]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1047 +[dm1114]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1114 +[dm1134]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1134 +[dm1147]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1147 +[dm1414]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1414 +[dm1430]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1430 +[dm1435]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1435 +[dm1437]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1437 +[dm1457]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1457 +[dm1736]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1736 +[dm1749]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1749 +[dm2018]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2018 +[dm2051]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2051 +[dm2085]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2085 +[dm2086]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2086 +[dm2094]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2094 +[dm2104]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2104 +[dm2448]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2448 +[dm2534]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2534 +[dm2624]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2624 +[dm2864]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2864 +[dm2898]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2898 +[dm2925]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2925 +[dm2951]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2951 +[dm2996]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2996 +[dm3004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3004 +[dm3023]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3023 +[dm3031]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3031 +[dm3125]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3125 +[dm3132]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3132 +[dm3134]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3134 +[dm3137]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3137 +[dm3813]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3813 +[dm3825]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3825 +[dm620]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n620 +[dm626]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n626 +[dm645]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n645 +[dmdocs]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/?h=v7.4-rc5 +[dmh185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n185 +[dmh198]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n198 +[dmh215]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n215 +[dmh254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n254 +[dmh29]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n29 +[dmh312]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n312 +[dmh331]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n331 +[dmh63]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n63 +[dmh710]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n710 +[dmt1521]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1521 +[dmt1581]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1581 +[dmt1586]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1586 +[dmt197]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n197 +[dmt2171]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n2171 +[dmt2195]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n2195 +[dmt30]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n30 +[dmt686]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n686 +[dmt704]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n704 +[dmt719]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n719 +[dmt727]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n727 +[dmt733]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n733 +[dmt754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n754 +[dmt759]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n759 +[dmt765]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n765 +[dmt941]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n941 +[dmt981]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n981 +[dmt986]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n986 +[ioc1274]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1274 +[ioc1280]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1280 +[ioc1284]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1284 +[ioc1311]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1311 +[ioc1331]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1331 +[ioc1363]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1363 +[ioc1617]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1617 +[ioc1639]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1639 +[ioc1649]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1649 +[ioc1666]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1666 +[ioc1687]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1687 +[ioc1702]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1702 +[ioc1985]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1985 +[ioc2034]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n2034 +[ioc2299]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n2299 +[ioc977]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n977 +[ioh293]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/dm-ioctl.h?h=v7.4-rc5#n293 +[lin28]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n28 +[lin3]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n3 +[lin61]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n61 +[lin82]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n82 +[lwn12734]: https://lwn.net/Articles/12734/ +[lwn215058]: https://lwn.net/Articles/215058/ +[lwn274292]: https://lwn.net/Articles/274292/ +[lwn298882]: https://lwn.net/Articles/298882/ +[lwn301919]: https://lwn.net/Articles/301919/ +[lwn540996]: https://lwn.net/Articles/540996/ +[mpath1161]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.4-rc5#n1161 +[mpath2299]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.4-rc5#n2299 +[mpath240]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.4-rc5#n240 +[pol21]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy.h?h=v7.4-rc5#n21 +[pol60]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy.h?h=v7.4-rc5#n60 +[rq412]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-rq.c?h=v7.4-rc5#n412 +[smq1858]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.4-rc5#n1858 +[smq1885]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.4-rc5#n1885 +[smq1909]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.4-rc5#n1909 +[tgt18]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.4-rc5#n18 +[tgt46]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.4-rc5#n46 +[tgt51]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.4-rc5#n51 +[thin1004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1004 +[thin1335]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1335 +[thin1396]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1396 +[thin1452]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1452 +[thin1473]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1473 +[thin1490]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1490 +[thin1494]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1494 +[thin1501]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1501 +[thin1530]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1530 +[thin1545]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1545 +[thin1553]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1553 +[thin1600]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1600 +[thin1603]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1603 +[thin1614]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1614 +[thin1800]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1800 +[thin1888]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1888 +[thin1931]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1931 +[thin1934]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1934 +[thin1978]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1978 +[thin203]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n203 +[thin2033]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2033 +[thin207]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n207 +[thin2110]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2110 +[thin2387]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2387 +[thin2403]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2403 +[thin2449]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2449 +[thin2551]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2551 +[thin2563]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2563 +[thin2583]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2583 +[thin2597]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2597 +[thin2605]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2605 +[thin2612]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2612 +[thin2646]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2646 +[thin2657]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2657 +[thin2722]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2722 +[thin2740]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2740 +[thin2745]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2745 +[thin2754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2754 +[thin2765]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2765 +[thin2767]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2767 +[thin2784]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2784 +[thin2797]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2797 +[thin3274]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3274 +[thin33]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n33 +[thin3345]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3345 +[thin34]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n34 +[thin3855]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3855 +[thin41]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n41 +[thin4109]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4109 +[thin4111]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4111 +[thin4326]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4326 +[thin4493]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4493 +[thin4553]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4553 +[thin735]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n735 +[thin756]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n756 +[thin9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n9 +[thin964]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n964 +[thinrst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5 +[tm1174]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1174 +[tm1205]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1205 +[tm1218]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1218 +[tm1500]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1500 +[tm1521]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1521 +[tm20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n20 diff --git a/mkdocs.yml b/mkdocs.yml index 657f4207..a93e8d68 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -397,6 +397,7 @@ nav: - I/O Schedulers: block/io-schedulers.md - Block Cgroup (I/O Control): block/blk-cgroup.md - NVMe Driver: block/nvme.md + - Device Mapper (Core and Targets): block/device-mapper.md - dm-verity (Integrity): block/dm-verity.md - War Stories: block/war-stories.md - Observability: block/block-observability.md From 5d7e1a10faa41a97b96256681b245b13a0b45470 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Sun, 29 Nov 2026 20:01:58 -0800 Subject: [PATCH 02/20] block: add pool-mode edges and tighten thin and cache statements Add the transitions out of PM_OUT_OF_METADATA_SPACE and from a table reload, give discards and unshared mapped blocks their own branches in the thin diagram, and scope the thin copy, writethrough and cache-miss statements to what the code does. Correct a few citation ranges. --- docs/block/device-mapper.md | 57 +++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index bee12723..ce6490c1 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -67,7 +67,7 @@ flowchart LR !!! note "What happens to bios during a suspend (bio-based)" While `DMF_BLOCK_IO_FOR_SUSPEND` is set, `dm_submit_bio()` queues ordinary bios on a list. A `REQ_NOWAIT` bio fails with `bio_wouldblock_error()` and a read-ahead bio fails with `bio_io_error()` ([dm.c:2094-2102][dm2094]). A request-based device stops its request queue instead ([dm.c:3031-3034][dm3031]), and the deferred requests wait in that queue ([dm.c:3137][dm3137]). -**Swap.** `dm_swap_table()` refuses to run unless the device is suspended ([dm.c:2898][dm2898]). It computes the queue limits for the new table ([dm.c:2925-2927][dm2925]); `__bind()` then publishes the table with `rcu_assign_pointer()` and waits for readers of the old one ([dm.c:2534-2539][dm2534]). +**Swap.** `dm_swap_table()` refuses to run unless the device is suspended ([dm.c:2898][dm2898]). Unless it keeps the existing limits (a table with no data devices, or a noflush suspend of an immutable request-based device), it computes the queue limits for the new table ([dm.c:2909-2927][dm2909]); `__bind()` then publishes the table with `rcu_assign_pointer()` and waits for readers of the old one ([dm.c:2534-2539][dm2534]). **Resume.** `__dm_resume()` resumes the targets ([dm.c:3125-3130][dm3125]), restarts the queued bios, and unlocks the filesystem ([dm.c:3132-3142][dm3132]). The comment gives the order's reason: "Flushing deferred I/Os must be done after targets are resumed so that mapping of targets can work correctly" ([dm.c:3134-3137][dm3134]). `dm_wq_work()` replays the queue with `submit_bio_noacct()` ([dm.c:2864-2874][dm2864]). @@ -151,10 +151,10 @@ A target type is a `struct target_type`: a name, a version, feature flags and a |---|---| | `ctr` | When the range is added to a table ([dm-table.c:765][dmt765]) | | `dtr` | When the table is destroyed ([dm-table.c:197-198][dmt197]) | -| `map` | For each bio-based I/O ([dm.c:1435][dm1435]) | +| `map` | For each clone of a bio-based I/O; `linear` and `stripe` are called directly ([dm.c:1430-1435][dm1430]) | | `end_io` | When the clone completes ([dm.c:1114-1115][dm1114]) | | `presuspend`, `postsuspend` | Around a suspend ([dm-table.c:2171-2194][dmt2171]) | -| `preresume`, `resume` | While resuming ([dm-table.c:2195-2215][dmt2195]) | +| `preresume`, `resume` | While resuming ([dm-table.c:2195-2221][dmt2195]) | `status`, `message`, `iterate_devices` and `io_hints` are also members of the struct ([device-mapper.h:215-221][dmh215]). A target's constructor opens the underlying devices with `dm_get_device()` ([device-mapper.h:185-186][dmh185]). Each range has a `struct dm_target` with its `begin`, `len` and optional `max_io_len` ([device-mapper.h:312-321][dmh312]). @@ -192,8 +192,8 @@ Thin provisioning uses two target types ([dm-thin.c:4109-4110][thin4109], [dm-th | | `thin-pool` | `thin` | |---|---|---| | Role | Owns the storage: a metadata device and a data device split into blocks | One virtual device carved out of a pool | -| Table line | ` ` and optional features ([dm-thin.c:3274-3284][thin3274]) | Names a pool | -| Features | Singleton, always writeable, immutable ([dm-thin.c:4111-4112][thin4111]) | — | +| Table line | ` ` and optional features ([dm-thin.c:3274-3284][thin3274]) | ` [origin_dev]` ([dm-thin.c:4170-4172][thin4172]) | +| Features | Singleton, always writeable, immutable, passes crypto ([dm-thin.c:4111-4112][thin4111]) | Passes crypto ([dm-thin.c:4495][thin4495]) | The data block size must be at least 64 KB, at most 1 GB, and a multiple of 64 KB ([dm-thin.c:41-46][thin41], [dm-thin.c:3345-3348][thin3345]). According to the commit that added the target, many virtual devices are stored on the same data volume, and snapshots can be taken of snapshots (see [Snapshots](#snapshots)). A pool is managed with messages: `create_thin`, `create_snap`, `delete`, `set_transaction_id`, `reserve_metadata_snap` and `release_metadata_snap` ([dm-thin.c:3855-3871][thin3855]). @@ -202,7 +202,7 @@ The data block size must be at least 64 KB, at most 1 GB, and a multiple of 64 K The file header of the metadata code describes the layout ([dm-thin-metadata.c:20-34][tm20]): ``` - metadata device + metadata device (logical components) ┌────────────┬─────────────────────┬───────────────────────┬─────────────────────────┐ │ superblock │ space map: │ btree: │ two-level btree: │ │ (block 0) │ metadata + data │ thin device id │ (device id, virtual │ @@ -211,7 +211,7 @@ The file header of the metadata code describes the layout ([dm-thin-metadata.c:2 block_time = 24-bit time (low bits) + 40-bit data block (high bits) ``` -The superblock is small enough for an atomic write. The btrees and space maps come from the persistent-data library, which was added in the same release as thin provisioning (`3241b1d3e0aaafbfcd320f4d71ade629728cc4f4`, "dm: add persistent data library", Linux 3.2, 2011-10-31). +Only the superblock has a fixed place, block zero; the other structures are allocated from the device by the space maps, which "allocate space linearly from front to back" ([dm-thin-metadata.c:68-69][tm68]). The superblock is small enough for an atomic write. The btrees and space maps come from the persistent-data library, which was added in the same release as thin provisioning (`3241b1d3e0aaafbfcd320f4d71ade629728cc4f4`, "dm: add persistent data library", Linux 3.2, 2011-10-31). ### The path of a bio @@ -224,24 +224,28 @@ flowchart TD B -- no --> C{"look up the
virtual block"} C -- "mapped, not shared" --> R["remap to the data block
DM_MAPIO_REMAPPED"] C -- "shared, not mapped,
or lookup would block" --> W - W --> D{"block state"} + W -- "discard" --> X["process_discard"] + W -- "other bios" --> D{"block state"} + D -- "mapped, not shared" --> R D -- "shared, write" --> S["break_sharing:
allocate a block,
copy unless whole-block write"] D -- "shared, read" --> RR["remap to the shared block"] D -- "not mapped, read" --> Z["zero-fill, or read
from the external origin"] D -- "not mapped, write" --> P["allocate a data block"] P --> Q{"external
origin?"} - Q -- yes --> E["copy from the origin"] + Q -- yes --> E["copy from the origin
(not for a whole-block write;
zeroed past the origin's end)"] Q -- no --> F["zero the block unless the
write covers all of it"] S --> M["insert mapping
release held bios"] E --> M F --> M ``` +A bio can also be held in the cell because another bio already holds it ([dm-thin.c:2755-2756][thin2755]); the diagram leaves that case out. + The anchors for the diagram: - Flushes and discards go to the worker ([dm-thin.c:2745-2748][thin2745]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2784-2795][thin2784]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2765-2782][thin2765], [dm-thin.c:2797-2800][thin2797]). - A write to a shared block breaks the sharing; a read of one is remapped to the shared block ([dm-thin.c:1888-1900][thin1888]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1800-1813][thin1800]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device, or, for a thin device with an external origin, read from the origin ([dm-thin.c:1978-1993][thin1978]). A write allocates a data block ([dm-thin.c:1931][thin1931]), then copies from the origin if there is one ([dm-thin.c:1934-1935][thin1934]); otherwise it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device, or, for a thin device with an external origin, read from the origin ([dm-thin.c:1978-1993][thin1978]). A write allocates a data block ([dm-thin.c:1931][thin1931]), then copies from the origin if there is one ([dm-thin.c:1934-1935][thin1934]), except that a block past the end of the origin is zeroed instead ([dm-thin.c:1415-1426][thin1415]) and the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk @@ -272,6 +276,8 @@ stateDiagram-v2 PM_WRITE --> PM_OUT_OF_DATA_SPACE: no free data block, even after a commit PM_OUT_OF_DATA_SPACE --> PM_WRITE: a commit finds free data blocks PM_WRITE --> PM_OUT_OF_METADATA_SPACE: no free metadata block + PM_OUT_OF_DATA_SPACE --> PM_OUT_OF_METADATA_SPACE: no free metadata block + PM_OUT_OF_METADATA_SPACE --> PM_WRITE: the metadata device is grown PM_WRITE --> PM_READ_ONLY: a metadata operation fails PM_WRITE --> PM_FAIL: aborting the transaction fails PM_FAIL --> PM_FAIL: never left @@ -281,12 +287,15 @@ stateDiagram-v2 |---|---| | `PM_WRITE` → `PM_OUT_OF_DATA_SPACE` | `alloc_data_block()` finds no free block after a commit, or the allocation returns `-ENOSPC` ([dm-thin.c:1545-1547][thin1545], [dm-thin.c:1553-1554][thin1553]) | | `PM_OUT_OF_DATA_SPACE` → `PM_WRITE` | After a commit, `check_for_data_space()` finds free blocks ([dm-thin.c:1473-1475][thin1473], called from [dm-thin.c:1494-1495][thin1494]) | -| → `PM_OUT_OF_METADATA_SPACE` | `check_for_metadata_space()` finds no free metadata block and the pool is not already read-only ([dm-thin.c:1452-1458][thin1452]) | +| → `PM_OUT_OF_METADATA_SPACE` | `check_for_metadata_space()` finds no free metadata block, or cannot read the count, and the pool is not already read-only ([dm-thin.c:1449-1458][thin1449]) | | → `PM_READ_ONLY` | A metadata operation failed: the transaction is aborted and the mode set ([dm-thin.c:2657-2663][thin2657]) | | → `PM_FAIL` | Aborting the transaction, or setting the `needs_check` flag, failed ([dm-thin.c:2646-2654][thin2646]) | | out of `PM_FAIL` | Never: "we never let the pool move out of the old mode" ([dm-thin.c:2563-2568][thin2563]) | | to `PM_WRITE` when `needs_check` is set | Refused ([dm-thin.c:2551-2561][thin2551]) | -| `PM_OUT_OF_METADATA_SPACE` → `PM_WRITE` | The source comment says it may switch back on a metadata resize ([dm-thin.c:207-209][thin207]) | +| `PM_OUT_OF_METADATA_SPACE` → `PM_WRITE` | The pool sets `PM_WRITE` when the metadata device is grown ([dm-thin.c:3537-3538][thin3537]); the source comment says the mode "may switch back to WRITE on metadata resize" ([dm-thin.c:207-209][thin207]) | +| Table reload | `bind_control_target()` sets the mode from the new table's features: `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument ([dm-thin.c:2864-2885][thin2864], [dm-thin.c:2904][thin2904], [dm-thin.c:3178-3179][thin3178]) | + +The diagram shows representative edges. `metadata_operation_failed()` sets `PM_READ_ONLY` whatever the current mode, except that `PM_FAIL` is never left ([dm-thin.c:2657-2663][thin2657], [dm-thin.c:2563-2568][thin2563]), and `commit()` refuses to run only from `PM_OUT_OF_METADATA_SPACE` upward ([dm-thin.c:1487-1488][thin1487]), so a commit can also degrade the pool from `PM_OUT_OF_DATA_SPACE`. What each mode does with a bio: @@ -309,12 +318,12 @@ The `cache` target puts a fast device in front of a slow one. Its table line is ### Three I/O modes -The comments are at [dm-cache-target.c:255-275][cache255]; the arguments that select the mode are parsed at [dm-cache-target.c:2211-2224][cache2211], and writeback is the default ([dm-cache-target.c:2185][cache2185]). +A block that is already dirty, for example from writeback mode, is still written to the cache only ([dm-cache-target.c:1746-1751][cache1746]); only passthrough requires all blocks to be clean before it can be entered ([dm-cache-target.c:2842-2846][cache2842]). The comments are at [dm-cache-target.c:255-275][cache255]; the arguments that select the mode are parsed at [dm-cache-target.c:2211-2224][cache2211], and writeback is the default ([dm-cache-target.c:2185][cache2185]). | Mode | Where a hit goes | Can the cache hold data newer than the origin? | What the source comment says | |---|---|---|---| | writeback | cache | ✓ | "Data is written to cached blocks only. These blocks are marked dirty. If you lose the cache device you will lose data." | -| writethrough | cache; a write to a clean block goes to both devices ([dm-cache-target.c:1746-1748][cache1746]) | ✗ | "Data is written to both cache and origin. Blocks are never dirty." | +| writethrough | cache; a write to a clean block goes to both devices ([dm-cache-target.c:1746-1751][cache1746]) | ✗ for data written in this mode | "Data is written to both cache and origin. Blocks are never dirty." | | passthrough | origin; a write also invalidates the cache block ([dm-cache-target.c:1738-1744][cache1738]) | ✗ | "Reads and writes always go to the origin. If a write goes to a cached oblock, then the cache block is invalidated." | !!! warning "Writeback loses data with the cache device" @@ -332,6 +341,7 @@ flowchart TD C -- yes --> W["worker"] C -- no --> D{"policy lookup"} D -- miss --> O2["origin"] + D -- "miss, and the policy
returns a promotion" --> MG["start a migration
with this bio"] D -- hit --> E{"mode"} E -- "writeback" --> CA["cache"] E -- "writethrough" --> F{"write to a
clean block?"} @@ -342,7 +352,7 @@ flowchart TD G -- no --> O3["origin"] ``` -- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1716-1719][cache1716]). +- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1716-1719][cache1716]). In writeback mode, when the policy returns a promotion for the block, a migration is started with the bio instead ([dm-cache-target.c:1691-1696][cache1691]). - **Hit:** as in the table above ([dm-cache-target.c:1738-1751][cache1738]). - **FUA:** the bio is issued after the metadata commit ([dm-cache-target.c:1758-1766][cache1758]). @@ -407,6 +417,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [cache1369]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1369 [cache1666]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1666 [cache1680]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1680 +[cache1691]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1691 [cache1716]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1716 [cache1738]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1738 [cache1746]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1746 @@ -419,6 +430,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [cache257]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n257 [cache2683]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2683 [cache2694]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2694 +[cache2842]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2842 [cache9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n9 [cacherst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5 [cacherst11]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5#n11 @@ -431,7 +443,6 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [dm1147]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1147 [dm1414]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1414 [dm1430]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1430 -[dm1435]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1435 [dm1437]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1437 [dm1457]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1457 [dm1736]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1736 @@ -447,7 +458,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [dm2624]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2624 [dm2864]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2864 [dm2898]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2898 -[dm2925]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2925 +[dm2909]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2909 [dm2951]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2951 [dm2996]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2996 [dm3004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3004 @@ -532,8 +543,10 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin1004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1004 [thin1335]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1335 [thin1396]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1396 -[thin1452]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1452 +[thin1415]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1415 +[thin1449]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1449 [thin1473]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1473 +[thin1487]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1487 [thin1490]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1490 [thin1494]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1494 [thin1501]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1501 @@ -567,20 +580,27 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin2740]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2740 [thin2745]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2745 [thin2754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2754 +[thin2755]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2755 [thin2765]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2765 [thin2767]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2767 [thin2784]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2784 [thin2797]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2797 +[thin2864]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2864 +[thin2904]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2904 +[thin3178]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3178 [thin3274]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3274 [thin33]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n33 [thin3345]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3345 [thin34]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n34 +[thin3537]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3537 [thin3855]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3855 [thin41]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n41 [thin4109]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4109 [thin4111]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4111 +[thin4172]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4172 [thin4326]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4326 [thin4493]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4493 +[thin4495]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4495 [thin4553]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4553 [thin735]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n735 [thin756]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n756 @@ -593,3 +613,4 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [tm1500]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1500 [tm1521]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1521 [tm20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n20 +[tm68]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n68 From b74fc20dd2221219e7345d8038b5d7120314b1a0 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Sun, 29 Nov 2026 20:07:41 -0800 Subject: [PATCH 03/20] block: add diagrams, worked examples and comparison tables to the device-mapper page Add a map of where a mapped device sits, an object diagram, worked examples for the sector index and for a bio that crosses a target boundary, a snapshot-sharing diagram, a commit-batching sequence, a cache migration flow, a target feature matrix, a side-by-side table of linear, thin and cache, and examples quoted from the kernel documentation. --- docs/block/device-mapper.md | 206 +++++++++++++++++++++++++++++++++++- 1 file changed, 204 insertions(+), 2 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index ce6490c1..231eaa6a 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -4,6 +4,18 @@ Source links point at Linux v7.4-rc5, the tree this page was checked against. Release numbers are mainline releases. Dates are author dates for commits and the dates shown on the page for LWN postings. +**Find your way** + +| To learn | Go to | +|---|---| +| what a table, a target and a mapped device are | [What it is](#what-it-is) | +| how a table is loaded, swapped and resumed | [Two tables: load, then swap](#two-tables-load-then-swap) | +| how one bio becomes clones | [The I/O path](#the-io-path-for-bio-based-devices) | +| what the three targets have in common and where they differ | [The three targets side by side](#the-three-targets-side-by-side) | +| how thin provisioning allocates, snapshots and runs out of space | [thin provisioning](#thin-provisioning), [Running out of space](#running-out-of-space) | +| how the cache decides what to keep | [cache](#cache) | +| where each part came from | [Where it came from](#where-it-came-from) | + ## What it is A device-mapper device is a block device whose I/O is handled by the device-mapper core instead of a hardware driver. What the device does with an I/O is set by its *table*: a list of ranges of the device's sectors, each handled by a *target*. A range is added with a start, a length, a target type name and a parameter string ([`dm_table_add_target()`][dmt686]), and the target's constructor receives the parameters split into arguments ([dm-table.c:759-765][dmt759]). @@ -19,6 +31,37 @@ A device-mapper device is a block device whose I/O is handled by the device-mapp The diagram is an illustrative table; both ranges use the [`linear` target](#linear-the-smallest-target). +!!! example "The same idea in the kernel documentation" + The documentation's example joins two devices. Each line is a start, a length, a target type and its arguments ([linear.rst:28-33][linearrst28]): + + ``` + 0 $size1 linear $1 0 + $size1 $size2 linear $2 0 + ``` + +Where a mapped device sits when a bio arrives: + +``` + any submitter of a bio + │ bio + ▼ + ┌────────────────────────────────┐ + │ mapped device │ dm_submit_bio: finds the target for the + │ (device-mapper core) │ sector and makes a clone of the bio + └───────────────┬────────────────┘ + │ clone + ▼ + ┌────────────────────────────────┐ + │ target: linear, thin, cache... │ map(): sets a device and a sector, or + │ │ takes the clone over + └───────────────┬────────────────┘ + │ remapped clone, submitted with submit_bio_noacct() + ▼ + lower block device(s) +``` + +The steps are the ones in [dm.c:2085-2104][dm2085] (find the table, split and process), [dm.c:1435][dm1435] (the target's `map`) and [dm.c:1386][dm1386] (submit the remapped clone). + A device is either *bio-based* or *request-based* (see [below](#bio-based-and-request-based-devices)). A bio-based device gets `dm_submit_bio()` as its `.submit_bio` ([dm.c:3813][dm3813]); a request-based device gets a different set of operations ([dm.c:2624][dm2624]) that has no `.submit_bio` ([dm.c:3825-3832][dm3825]). Unless a section says otherwise, this page describes bio-based devices. [dm-verity](dm-verity.md) and [dm-crypt](../security/dm-crypt.md) are other targets and have their own pages. This page covers the core and three targets that show its range. @@ -31,6 +74,23 @@ A device is either *bio-based* or *request-based* (see [below](#bio-based-and-re - **SRCU**: a read-side locking scheme whose readers may sleep; see [SRCU](../locking/srcu.md). The core uses it to find out when no thread is still using an old table. - **gendisk**: the kernel's structure for a disk; each mapped device owns one ([dm-core.h:78][core78]). +How the core's objects point at each other: + +```mermaid +flowchart LR + MD["mapped_device
gendisk
deferred bio list"] + T["dm_table
type, index, highs[ ]
targets[ ]"] + TG["dm_target
begin, len
private"] + TT["target_type
ctr, map, end_io, ..."] + DD["dm_dev
bdev, mode"] + MD -- "map (RCU pointer)" --> T + T -- "one per range" --> TG + TG -- "type" --> TT + T -- "devices list" --> DD +``` + +The `mapped_device` holds the table pointer, the disk and the list of bios that arrived during a suspend ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-314][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]). + The core keeps its own structures private. The header says that targets "must _not_ deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). ## The control interface @@ -75,6 +135,18 @@ flowchart LR A table maps a sector to a target. `dm_table_find_target()` walks an index whose nodes are one cache line wide and hold sector keys ([dm-table.c:30-32][dmt30], [dm-table.c:1581-1599][dmt1581]). A sector past the end of the table returns no target ([dm-table.c:1586-1587][dmt1586]), and the I/O path fails the bio with `BLK_STS_IOERR` ([dm.c:1736-1738][dm1736]). +The index keys are the last sector of each range. `dm_table_add_target()` stores `begin + len - 1` in `highs` ([dm-table.c:770][dmt770]), the leaf level of the index is that array ([dm-table.c:1145][dmt1145]), and the lookup takes the first key that is not smaller than the sector ([dm-table.c:1593-1596][dmt1593]). For the table in the first diagram: + +``` + ranges of the table leaf of the index (highs) + targets[0] sectors 0 - 999 highs[0] = 999 + targets[1] sectors 1000 - 4999 highs[1] = 4999 + + lookup of sector 1500: the first key >= 1500 is highs[1], so the target is targets[1] +``` + +A larger table adds levels above the leaf; `dm_table_find_target()` walks `t->depth` of them ([dm-table.c:1589][dmt1589]). + `dm_table_add_target()` rejects a range that has zero length ([dm-table.c:704-707][dmt704]) and a range that does not start where the previous one ended ([dm-table.c:754-757][dmt754]). A target type's feature flags add further rules: | Feature | Meaning | Where enforced | @@ -121,6 +193,18 @@ A bio reaches the device through `dm_submit_bio()`, which takes the live table u 3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). 4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The original bio completes when the count of outstanding clones reaches zero ([dm.c:1047-1055][dm1047]). +**A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2051-2058][dm2051]): + +``` + table: target A sectors 0 - 999 │ target B sectors 1000 - 4999 + bio (illustrative, 400 sectors): sectors 800 - 1199 + + first pass clone for sectors 800 - 999 ──► A.map (limited to the end of A) + the rest, 1000 - 1199, is trimmed and submitted again + second pass clone for sectors 1000 - 1199 ──► B.map + done the original bio completes when both clones have completed +``` + What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], values at [device-mapper.h:710-714][dmh710]): | Return value | Core's action | @@ -160,6 +244,27 @@ A target type is a `struct target_type`: a name, a version, feature flags and a Targets are kept in a list under a read-write semaphore ([dm-target.c:18-19][tgt18]). When the named type is missing, the core runs `request_module("dm-%s", name)` and looks again ([dm-target.c:46-49][tgt46], [dm-target.c:51-58][tgt51]). +The feature flags that the targets on this page set, from their `target_type` definitions: + +| Target | `SINGLETON` | `IMMUTABLE` | `ALWAYS_WRITEABLE` | Source | +|---|---|---|---|---| +| `linear` | ✗ | ✗ | ✗ | [dm-linear.c:202-207][lin202] | +| `thin-pool` | ✓ | ✓ | ✓ | [dm-thin.c:4109-4112][thin4109] | +| `thin` | ✗ | ✗ | ✗ | [dm-thin.c:4493-4495][thin4493] | +| `cache` | ✗ | ✗ | ✗ | [dm-cache-target.c:3563-3578][cache3563] (no `.features`) | +| `multipath` | ✓ | ✓ | ✗ | [dm-mpath.c:2299-2302][mpath2299] | + +The other flags, for example `DM_TARGET_PASSES_CRYPTO` and `DM_TARGET_NOWAIT`, are listed in [device-mapper.h:234-310][dmh234]. + +## The three targets side by side + +| | `linear` | `thin-pool` and `thin` | `cache` | +|---|---|---|---| +| Table line | ` ` ([dm-linear.c:28][lin28]) | pool: ` ` ([dm-thin.c:3274-3277][thin3274]); thin: ` [origin_dev]` ([dm-thin.c:4172][thin4172]) | ` ` ([dm-cache-target.c:2026][cache2026]) | +| Has a metadata device | ✗ | ✓ | ✓ | +| `map` returns | always `DM_MAPIO_REMAPPED` ([dm-linear.c:96][lin96]) | `REMAPPED` for a mapped, unshared block, `SUBMITTED` otherwise ([dm-thin.c:2781-2811][thin2781]) | `REMAPPED`, or `SUBMITTED` when the target takes the bio over ([dm-cache-target.c:1675][cache1675], [dm-cache-target.c:1769][cache1769]) | +| Modes | none | pool modes ([below](#running-out-of-space)) | writeback, writethrough, passthrough ([below](#three-io-modes)) | + ## linear: the smallest target A `linear` range is ` ` ([dm-linear.c:28][lin28]): the whole range maps onto one device at a fixed offset. The map function sets the device and adds the offset to the position within the range: @@ -195,6 +300,20 @@ Thin provisioning uses two target types ([dm-thin.c:4109-4110][thin4109], [dm-th | Table line | ` ` and optional features ([dm-thin.c:3274-3284][thin3274]) | ` [origin_dev]` ([dm-thin.c:4170-4172][thin4172]) | | Features | Singleton, always writeable, immutable, passes crypto ([dm-thin.c:4111-4112][thin4111]) | Passes crypto ([dm-thin.c:4495][thin4495]) | +!!! example "Creating a pool, a thin device and a snapshot, from the kernel documentation" + ``` + dmsetup create pool \ + --table "0 20971520 thin-pool $metadata_dev $data_dev \ + $data_block_size $low_water_mark" + dmsetup message /dev/mapper/pool 0 "create_thin 0" + dmsetup create thin --table "0 2097152 thin /dev/mapper/pool 0" + dmsetup suspend /dev/mapper/thin + dmsetup message /dev/mapper/pool 0 "create_snap 1 0" + dmsetup resume /dev/mapper/thin + ``` + + Sources: pool ([thin-provisioning.rst:104-106][thinrst104]), thin device ([thin-provisioning.rst:165-175][thinrst165]), snapshot ([thin-provisioning.rst:192-194][thinrst192]). + The data block size must be at least 64 KB, at most 1 GB, and a multiple of 64 KB ([dm-thin.c:41-46][thin41], [dm-thin.c:3345-3348][thin3345]). According to the commit that added the target, many virtual devices are stored on the same data volume, and snapshots can be taken of snapshots (see [Snapshots](#snapshots)). A pool is managed with messages: `create_thin`, `create_snap`, `delete`, `set_transaction_id`, `reserve_metadata_snap` and `release_metadata_snap` ([dm-thin.c:3855-3871][thin3855]). ### Metadata @@ -252,16 +371,48 @@ The anchors for the diagram: Changes to the mapping sit in an open metadata transaction until `commit()` calls `dm_pool_commit_metadata()` ([dm-thin.c:1490][thin1490]). A bio with a flush or FUA flag that arrives after its thin device has changed the transaction does not go straight down: `issue()` puts it on a list, and one commit serves all bios on the list ([dm-thin.c:735-738][thin735], [dm-thin.c:756-777][thin756]). The comment on a related path says why: "If the bio has the REQ_FUA flag set we must commit the metadata before signaling its completion" ([dm-thin.c:964-966][thin964]). +```mermaid +sequenceDiagram + participant C as caller + participant W as pool worker + participant L as deferred_flush_bios + participant M as metadata + participant D as data device + C->>W: write with REQ_FUA (flush and FUA bios go to the worker) + W->>L: issue(): the thin device changed this transaction, so queue the bio + Note over L: other flush and FUA bios can join the list + W->>M: process_deferred_bios(): one commit() + M-->>W: committed + W->>C: REQ_PREFLUSH bios complete now + W->>D: other bios are submitted +``` + The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2387-2388][thin2387], [dm-thin.c:33][thin33], [dm-thin.c:2110-2114][thin2110]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2403-2411][thin2403]). ### Snapshots `create_snap` makes the snapshot's mapping tree by taking another reference to the origin's tree root: "clone the origin, an inc will do" ([dm-thin-metadata.c:1205-1206][tm1205]). It then bumps the pool's time counter and records it as the *snapshotted time* of both devices ([dm-thin-metadata.c:1218-1224][tm1218], [dm-thin-metadata.c:1174-1178][tm1174]). -A block counts as shared when the time stored with it is older than the device's last snapshot ([dm-thin-metadata.c:1500-1509][tm1500], [dm-thin-metadata.c:1521][tm1521]). +A block counts as shared when the time stored with it is older than the device's last snapshot ([dm-thin-metadata.c:1500-1509][tm1500], [dm-thin-metadata.c:1521][tm1521]). A new mapping is stored with the pool's current time ([dm-thin-metadata.c:1651][tm1651]). + +``` + create_snap 1 0 pool time goes from 0 to 1 + + device 0 (origin) ──┐ the same tree root R, reference count +1 + device 1 (snapshot) ──┘ both devices now have snapshotted_time = 1 + + vblock 7, on both devices → data block 40, stored with time 0. 0 < 1, so it is shared + + a write to vblock 7 on device 1: + break_sharing allocate data block 41, copy block 40 into it + insert device 1: vblock 7 → block 41, stored with time 1 (1 is not < 1: not shared) + result device 0: vblock 7 → 40 device 1: vblock 7 → 41 +``` + +The numbers are illustrative; the steps are `__create_snap()` ([dm-thin-metadata.c:1205-1224][tm1205]), `break_sharing()` ([dm-thin.c:1800-1813][thin1800]) and the insert in `process_prepared_mapping()` ([dm-thin.c:1009][thin1009]). !!! warning "Quiesce the origin before taking a snapshot" - `thin_bio_map()` has a window between its lookup and snapshot creation. The comment gives the rule that avoids it: "always quiesce the origin before taking the snap" ([dm-thin.c:2767-2776][thin2767]). + `thin_bio_map()` has a window between its lookup and snapshot creation. The comment gives the rule that avoids it: "always quiesce the origin before taking the snap" ([dm-thin.c:2767-2776][thin2767]). The kernel documentation says the same: "you must suspend it before creating the snapshot to avoid corruption. This is NOT enforced at the moment" ([thin-provisioning.rst:186-188][thinrst186]). The commit that added thin provisioning (`991d9fa02da0dd1f843dc011376965e0c8c6c9b5`, Linux 3.2, 2011-10-31) says how it differs from the earlier snapshot implementation: "The previous implementation of snapshots did this by chaining together lookup tables, and so performance was O(depth). This new implementation uses a single data structure so we don't get this degradation with depth." @@ -360,6 +511,24 @@ flowchart TD The core does not decide what to cache. A policy plug-in is asked about each bio, and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1916-1941][cache1916]). +```mermaid +flowchart TD + A["map_bio: policy lookup"] -- "the policy queued background work" --> B["wake the migration worker"] + B --> C["check_migrations: ask the policy for work
promote, demote or writeback"] + C --> D["mg_start: lock the block against writes
reads continue"] + D --> E["copy the data
skipped for a discarded block, or when a demotion
or writeback finds the cache block clean"] + E --> F["upgrade the lock:
block reads and writes"] + F --> G{"operation"} + G -- promote --> H["insert the mapping"] + G -- demote --> I["remove the mapping
and commit"] + G -- writeback --> J["no mapping change"] + H --> K["complete: clear the dirty bit where the code does,
tell the policy, unlock the block, replay held bios"] + I --> K + J --> K +``` + +The anchors: the worker is woken from `map_bio()` ([dm-cache-target.c:1706-1707][cache1706]) and asks the policy for work in `check_migrations()` ([dm-cache-target.c:1916-1941][cache1916]); `mg_lock_writes()` blocks writes and lets reads continue, and locks everything when a whole-block bio is being promoted ([dm-cache-target.c:1410-1418][cache1410]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1355-1359][cache1355]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1332-1336][cache1332]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1252-1303][cache1252], [dm-cache-target.c:1293-1298][cache1293]); `mg_complete()` clears the dirty bit for a promotion without a bio, a demotion and a writeback, tells the policy and replays the bios that waited ([dm-cache-target.c:1187-1235][cache1187]). + The tree registers four policy names: `smq`, `mq`, `cleaner` and `default` ([dm-cache-policy-smq.c:1885-1939][smq1885]). The first three are created by the same function, `__smq_create()`, with different flag arguments ([dm-cache-policy-smq.c:1858-1880][smq1858]); `default` points at the `smq` type through `.real` ([dm-cache-policy-smq.c:1909-1914][smq1909]). One shortcut avoids the copy. In writeback mode, a bio to a discarded block or one that writes a whole block is looked up with `policy_lookup_with_work()` ([dm-cache-target.c:1073-1077][cache1073], [dm-cache-target.c:1680-1696][cache1680]). The policy header explains the method: the core "needs the migration immediately though so it knows to do something different with the bio" ([dm-cache-policy.h:60-64][pol60]). The migration then uses `overwrite()` in place of a full copy, falling back to the full copy if the bio is no longer eligible ([dm-cache-target.c:1369-1395][cache1369]). @@ -414,14 +583,23 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [cache1007]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1007 [cache1073]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1073 [cache1083]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1083 +[cache1187]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1187 +[cache1252]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1252 +[cache1293]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1293 +[cache1332]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1332 +[cache1355]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1355 [cache1369]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1369 +[cache1410]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1410 [cache1666]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1666 +[cache1675]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1675 [cache1680]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1680 [cache1691]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1691 +[cache1706]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1706 [cache1716]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1716 [cache1738]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1738 [cache1746]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1746 [cache1758]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1758 +[cache1769]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1769 [cache1916]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1916 [cache2026]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2026 [cache2185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2185 @@ -431,18 +609,25 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [cache2683]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2683 [cache2694]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2694 [cache2842]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2842 +[cache3563]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n3563 [cache9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n9 [cacherst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5 [cacherst11]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5#n11 [cacherst20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5#n20 +[core189]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n189 [core35]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n35 +[core60]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n60 [core78]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n78 +[core97]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n97 [dm1047]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1047 [dm1114]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1114 [dm1134]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1134 [dm1147]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1147 +[dm1161]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1161 +[dm1386]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1386 [dm1414]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1414 [dm1430]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1430 +[dm1435]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1435 [dm1437]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1437 [dm1457]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1457 [dm1736]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1736 @@ -474,18 +659,24 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [dm626]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n626 [dm645]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n645 [dmdocs]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/?h=v7.4-rc5 +[dmh173]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n173 [dmh185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n185 [dmh198]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n198 [dmh215]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n215 +[dmh234]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n234 [dmh254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n254 [dmh29]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n29 [dmh312]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n312 [dmh331]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n331 +[dmh358]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n358 [dmh63]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n63 [dmh710]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n710 +[dmt1145]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1145 [dmt1521]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1521 [dmt1581]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1581 [dmt1586]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1586 +[dmt1589]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1589 +[dmt1593]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1593 [dmt197]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n197 [dmt2171]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n2171 [dmt2195]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n2195 @@ -498,6 +689,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [dmt754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n754 [dmt759]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n759 [dmt765]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n765 +[dmt770]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n770 [dmt941]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n941 [dmt981]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n981 [dmt986]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n986 @@ -518,10 +710,13 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [ioc2299]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n2299 [ioc977]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n977 [ioh293]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/dm-ioctl.h?h=v7.4-rc5#n293 +[lin202]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n202 [lin28]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n28 [lin3]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n3 [lin61]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n61 [lin82]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n82 +[lin96]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n96 +[linearrst28]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/linear.rst?h=v7.4-rc5#n28 [lwn12734]: https://lwn.net/Articles/12734/ [lwn215058]: https://lwn.net/Articles/215058/ [lwn274292]: https://lwn.net/Articles/274292/ @@ -541,6 +736,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [tgt46]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.4-rc5#n46 [tgt51]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.4-rc5#n51 [thin1004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1004 +[thin1009]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1009 [thin1335]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1335 [thin1396]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1396 [thin1415]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1415 @@ -583,6 +779,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin2755]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2755 [thin2765]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2765 [thin2767]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2767 +[thin2781]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2781 [thin2784]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2784 [thin2797]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2797 [thin2864]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2864 @@ -607,10 +804,15 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n9 [thin964]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n964 [thinrst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5 +[thinrst104]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5#n104 +[thinrst165]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5#n165 +[thinrst186]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5#n186 +[thinrst192]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5#n192 [tm1174]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1174 [tm1205]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1205 [tm1218]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1218 [tm1500]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1500 [tm1521]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1521 +[tm1651]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1651 [tm20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n20 [tm68]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n68 From 2071ee2b58ffe1eda146d0f965faab2f9e1f289b Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Sun, 29 Nov 2026 20:14:47 -0800 Subject: [PATCH 04/20] block: link the device-mapper page's commits and cover the cache overwrite path Link every commit to git.kernel.org, show the cache migration that carries the bio, and correct the object map, snapshot, map-return and table-line statements. Note which list postings are not linked. --- docs/block/device-mapper.md | 90 ++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 32 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 231eaa6a..a8d49a95 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -32,7 +32,7 @@ A device-mapper device is a block device whose I/O is handled by the device-mapp The diagram is an illustrative table; both ranges use the [`linear` target](#linear-the-smallest-target). !!! example "The same idea in the kernel documentation" - The documentation's example joins two devices. Each line is a start, a length, a target type and its arguments ([linear.rst:28-33][linearrst28]): + The documentation's example script joins two devices with this table. Each line is a start, a length, a target type and its arguments ([linear.rst:28-33][linearrst28]): ``` 0 $size1 linear $1 0 @@ -43,11 +43,12 @@ Where a mapped device sits when a bio arrives: ``` any submitter of a bio - │ bio - ▼ + │ bio + ▼ ┌────────────────────────────────┐ - │ mapped device │ dm_submit_bio: finds the target for the - │ (device-mapper core) │ sector and makes a clone of the bio + │ mapped device │ dm_submit_bio, then __split_and_process_bio: + │ (device-mapper core) │ finds the target for the sector, + │ │ makes a clone of the bio └───────────────┬────────────────┘ │ clone ▼ @@ -60,7 +61,7 @@ Where a mapped device sits when a bio arrives: lower block device(s) ``` -The steps are the ones in [dm.c:2085-2104][dm2085] (find the table, split and process), [dm.c:1435][dm1435] (the target's `map`) and [dm.c:1386][dm1386] (submit the remapped clone). +The steps are the ones in [dm.c:2085-2104][dm2085] (find the table, split and process), [dm.c:1736][dm1736] and [dm.c:1767][dm1767] (find the target, allocate the clone), [dm.c:1435][dm1435] (the target's `map`) and [dm.c:1386][dm1386] (submit the remapped clone). A device is either *bio-based* or *request-based* (see [below](#bio-based-and-request-based-devices)). A bio-based device gets `dm_submit_bio()` as its `.submit_bio` ([dm.c:3813][dm3813]); a request-based device gets a different set of operations ([dm.c:2624][dm2624]) that has no `.submit_bio` ([dm.c:3825-3832][dm3825]). Unless a section says otherwise, this page describes bio-based devices. @@ -83,13 +84,13 @@ flowchart LR TG["dm_target
begin, len
private"] TT["target_type
ctr, map, end_io, ..."] DD["dm_dev
bdev, mode"] - MD -- "map (RCU pointer)" --> T + MD -- "map (__rcu pointer,
read under SRCU)" --> T T -- "one per range" --> TG TG -- "type" --> TT - T -- "devices list" --> DD + T -- "devices list
(via dm_dev_internal, dm_dev_ref)" --> DD ``` -The `mapped_device` holds the table pointer, the disk and the list of bios that arrived during a suspend ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-314][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]). +The `mapped_device` holds the table pointer, the disk and the list of bios that arrived during a suspend ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-318][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]); the table's list holds one `dm_dev_internal` per device, which holds a `dm_dev_ref` for each mode the device was opened with ([dm-table.c:397-411][dmt397]). The core keeps its own structures private. The header says that targets "must _not_ deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). @@ -145,7 +146,7 @@ The index keys are the last sector of each range. `dm_table_add_target()` stores lookup of sector 1500: the first key >= 1500 is highs[1], so the target is targets[1] ``` -A larger table adds levels above the leaf; `dm_table_find_target()` walks `t->depth` of them ([dm-table.c:1589][dmt1589]). +A larger table adds levels above the leaf; `dm_table_find_target()` walks all `t->depth` levels, the leaf included ([dm-table.c:1589][dmt1589]). `dm_table_add_target()` rejects a range that has zero length ([dm-table.c:704-707][dmt704]) and a range that does not start where the previous one ended ([dm-table.c:754-757][dmt754]). A target type's feature flags add further rules: @@ -205,6 +206,8 @@ A bio reaches the device through `dm_submit_bio()`, which takes the live table u done the original bio completes when both clones have completed ``` +The original bio waits for the second pass because the first pass takes an extra reference on it with `bio_inc_remaining()` ([dm.c:2057][dm2057]); each pass ends the bio with `bio_endio()` ([dm.c:997][dm997]). + What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], values at [device-mapper.h:710-714][dmh710]): | Return value | Core's action | @@ -225,7 +228,7 @@ A table is bio-based, request-based or DAX bio-based ([device-mapper.h:29-34][dm A request-based target works on `struct request`, through a `clone_and_map_rq` callback ([device-mapper.h:63][dmh63]). The multipath target is the example in the tree. It is a singleton and immutable, implements `clone_and_map_rq` ([dm-mpath.c:2299-2306][mpath2299]) and defaults to request-based; the `queue_mode bio` option makes it bio-based ([dm-mpath.c:240-245][mpath240], [dm-mpath.c:1161-1169][mpath1161]). -The 2008 posting of the request-based series explains the difference: "Mapping is done in a unit of struct request, instead of struct bio" ([LWN, 2008-09-12][lwn298882]). The commit that enabled request-based DM, `e6ee8c0b767540f59e20da3ced282601db8aa502` ("dm: enable request based option", Linux 2.6.31, 2009-06-22), gives the reason for keeping both: "there are some target drivers which are more fitting to bio-based dm". It also states the limit that is still in the code: request-based DM supports only tables with a single target. +The 2008 posting of the request-based series explains the difference: "Mapping is done in a unit of struct request, instead of struct bio" ([LWN, 2008-09-12][lwn298882]). The commit that enabled request-based DM, [`e6ee8c0b7675`][ce6ee8c0b7675] ("dm: enable request based option", Linux 2.6.31, 2009-06-22), gives the reason for keeping both: "there are some target drivers which are more fitting to bio-based dm". It also states the limit that is still in the code: request-based DM supports only tables with a single target. ## The target interface @@ -244,7 +247,7 @@ A target type is a `struct target_type`: a name, a version, feature flags and a Targets are kept in a list under a read-write semaphore ([dm-target.c:18-19][tgt18]). When the named type is missing, the core runs `request_module("dm-%s", name)` and looks again ([dm-target.c:46-49][tgt46], [dm-target.c:51-58][tgt51]). -The feature flags that the targets on this page set, from their `target_type` definitions: +The feature flags that these targets set, from their `target_type` definitions (`multipath` is included for comparison): | Target | `SINGLETON` | `IMMUTABLE` | `ALWAYS_WRITEABLE` | Source | |---|---|---|---|---| @@ -260,9 +263,9 @@ The other flags, for example `DM_TARGET_PASSES_CRYPTO` and `DM_TARGET_NOWAIT`, a | | `linear` | `thin-pool` and `thin` | `cache` | |---|---|---|---| -| Table line | ` ` ([dm-linear.c:28][lin28]) | pool: ` ` ([dm-thin.c:3274-3277][thin3274]); thin: ` [origin_dev]` ([dm-thin.c:4172][thin4172]) | ` ` ([dm-cache-target.c:2026][cache2026]) | +| Table line | ` ` ([dm-linear.c:28][lin28]) | pool: ` ` ([dm-thin.c:3274-3277][thin3274]); thin: ` [origin_dev]` ([dm-thin.c:4172][thin4172]) | ` <#feature args> []* <#policy args> []*` ([dm-cache-target.c:2026-2028][cache2026]) | | Has a metadata device | ✗ | ✓ | ✓ | -| `map` returns | always `DM_MAPIO_REMAPPED` ([dm-linear.c:96][lin96]) | `REMAPPED` for a mapped, unshared block, `SUBMITTED` otherwise ([dm-thin.c:2781-2811][thin2781]) | `REMAPPED`, or `SUBMITTED` when the target takes the bio over ([dm-cache-target.c:1675][cache1675], [dm-cache-target.c:1769][cache1769]) | +| `map` returns | always `DM_MAPIO_REMAPPED` ([dm-linear.c:96][lin96]) | thin: `REMAPPED` only for a mapped, unshared block that is not held in a cell, `SUBMITTED` otherwise ([dm-thin.c:2734-2811][thin2734]); thin-pool: always `REMAPPED` ([dm-thin.c:3450][thin3450]) | `REMAPPED`, or `SUBMITTED` when the target takes the bio over ([dm-cache-target.c:1675][cache1675], [dm-cache-target.c:1769][cache1769]) | | Modes | none | pool modes ([below](#running-out-of-space)) | writeback, writethrough, passthrough ([below](#three-io-modes)) | ## linear: the smallest target @@ -330,7 +333,7 @@ The file header of the metadata code describes the layout ([dm-thin-metadata.c:2 block_time = 24-bit time (low bits) + 40-bit data block (high bits) ``` -Only the superblock has a fixed place, block zero; the other structures are allocated from the device by the space maps, which "allocate space linearly from front to back" ([dm-thin-metadata.c:68-69][tm68]). The superblock is small enough for an atomic write. The btrees and space maps come from the persistent-data library, which was added in the same release as thin provisioning (`3241b1d3e0aaafbfcd320f4d71ade629728cc4f4`, "dm: add persistent data library", Linux 3.2, 2011-10-31). +Only the superblock has a fixed place, block zero; the other structures are allocated from the device by the space maps, which "allocate space linearly from front to back" ([dm-thin-metadata.c:68-69][tm68]). The superblock is small enough for an atomic write. The btrees and space maps come from the persistent-data library, which was added in the same release as thin provisioning ([`3241b1d3e0aa`][c3241b1d3e0aa], "dm: add persistent data library", Linux 3.2, 2011-10-31). ### The path of a bio @@ -404,17 +407,17 @@ A block counts as shared when the time stored with it is older than the device's vblock 7, on both devices → data block 40, stored with time 0. 0 < 1, so it is shared a write to vblock 7 on device 1: - break_sharing allocate data block 41, copy block 40 into it + break_sharing allocate data block 41, copy block 40 into it (no copy if the write covers the whole block) insert device 1: vblock 7 → block 41, stored with time 1 (1 is not < 1: not shared) result device 0: vblock 7 → 40 device 1: vblock 7 → 41 ``` -The numbers are illustrative; the steps are `__create_snap()` ([dm-thin-metadata.c:1205-1224][tm1205]), `break_sharing()` ([dm-thin.c:1800-1813][thin1800]) and the insert in `process_prepared_mapping()` ([dm-thin.c:1009][thin1009]). +The numbers are illustrative; the steps are `__create_snap()` ([dm-thin-metadata.c:1205-1224][tm1205]), `break_sharing()` ([dm-thin.c:1800-1813][thin1800], copy skipped for a whole-block write at [dm-thin.c:1338-1339][thin1338]) and the insert in `process_prepared_mapping()` ([dm-thin.c:1009][thin1009]). !!! warning "Quiesce the origin before taking a snapshot" `thin_bio_map()` has a window between its lookup and snapshot creation. The comment gives the rule that avoids it: "always quiesce the origin before taking the snap" ([dm-thin.c:2767-2776][thin2767]). The kernel documentation says the same: "you must suspend it before creating the snapshot to avoid corruption. This is NOT enforced at the moment" ([thin-provisioning.rst:186-188][thinrst186]). -The commit that added thin provisioning (`991d9fa02da0dd1f843dc011376965e0c8c6c9b5`, Linux 3.2, 2011-10-31) says how it differs from the earlier snapshot implementation: "The previous implementation of snapshots did this by chaining together lookup tables, and so performance was O(depth). This new implementation uses a single data structure so we don't get this degradation with depth." +The commit that added thin provisioning ([`991d9fa02da0`][c991d9fa02da0], Linux 3.2, 2011-10-31) says how it differs from the earlier snapshot implementation: "The previous implementation of snapshots did this by chaining together lookup tables, and so performance was O(depth). This new implementation uses a single data structure so we don't get this degradation with depth." ### Running out of space @@ -525,17 +528,20 @@ flowchart TD H --> K["complete: clear the dirty bit where the code does,
tell the policy, unlock the block, replay held bios"] I --> K J --> K + A -- "writeback mode, and the bio is for a discarded block
or covers a whole block: the policy returns a promotion at once" --> D2["mg_start with the bio:
lock reads and writes"] + D2 --> E2["overwrite(): write the bio
into the cache block"] + E2 --> H ``` -The anchors: the worker is woken from `map_bio()` ([dm-cache-target.c:1706-1707][cache1706]) and asks the policy for work in `check_migrations()` ([dm-cache-target.c:1916-1941][cache1916]); `mg_lock_writes()` blocks writes and lets reads continue, and locks everything when a whole-block bio is being promoted ([dm-cache-target.c:1410-1418][cache1410]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1355-1359][cache1355]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1332-1336][cache1332]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1252-1303][cache1252], [dm-cache-target.c:1293-1298][cache1293]); `mg_complete()` clears the dirty bit for a promotion without a bio, a demotion and a writeback, tells the policy and replays the bios that waited ([dm-cache-target.c:1187-1235][cache1187]). +The anchors: the worker is woken from `map_bio()` when the policy queues work ([dm-cache-target.c:1706-1707][cache1706]), and also by the periodic waker ([dm-cache-target.c:1911][cache1911]); it asks the policy for work in `check_migrations()` ([dm-cache-target.c:1916-1941][cache1916]); `mg_lock_writes()` blocks writes and lets reads continue, and locks reads and writes when the migration carries the bio itself, the bottom branch ([dm-cache-target.c:1410-1418][cache1410], [dm-cache-target.c:1691-1695][cache1691]), which uses `overwrite()` in place of the copy and the lock upgrade ([dm-cache-target.c:1392-1395][cache1392]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1355-1359][cache1355]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1332-1336][cache1332]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1252-1303][cache1252], [dm-cache-target.c:1293-1298][cache1293]); `mg_complete()` clears the dirty bit for a promotion without a bio, a demotion and a writeback, sets it for a promotion that carries a bio and ends that bio, tells the policy and replays the bios that waited ([dm-cache-target.c:1187-1235][cache1187], [dm-cache-target.c:1192-1199][cache1192]). The tree registers four policy names: `smq`, `mq`, `cleaner` and `default` ([dm-cache-policy-smq.c:1885-1939][smq1885]). The first three are created by the same function, `__smq_create()`, with different flag arguments ([dm-cache-policy-smq.c:1858-1880][smq1858]); `default` points at the `smq` type through `.real` ([dm-cache-policy-smq.c:1909-1914][smq1909]). One shortcut avoids the copy. In writeback mode, a bio to a discarded block or one that writes a whole block is looked up with `policy_lookup_with_work()` ([dm-cache-target.c:1073-1077][cache1073], [dm-cache-target.c:1680-1696][cache1680]). The policy header explains the method: the core "needs the migration immediately though so it knows to do something different with the bio" ([dm-cache-policy.h:60-64][pol60]). The migration then uses `overwrite()` in place of a full copy, falling back to the full copy if the bio is no longer eligible ([dm-cache-target.c:1369-1395][cache1369]). -The commit that added the target (`c6b4fcbad044e6fffcc75bba160e720eb8d67d17`, "dm: add cache target", Linux 3.9, 2013-03-01) states the design choice: "A plug-in architecture was chosen so that the decisions about which data to migrate and when are delegated to interchangeable tunable policy modules." +The commit that added the target ([`c6b4fcbad044`][cc6b4fcbad044], "dm: add cache target", Linux 3.9, 2013-03-01) states the design choice: "A plug-in architecture was chosen so that the decisions about which data to migrate and when are delegated to interchangeable tunable policy modules." -Cache uses version 2 of the bio prison, the structure behind the cells described above ([dm-cache-target.c:9][cache9], [dm-cache-target.c:1083][cache1083]); thin provisioning uses version 1 ([dm-thin.c:9][thin9]). Version 2 came in Linux 4.12 (`742c8fdc31e820503f9267070311d894978d1349`, "dm bio prison v2: new interface for the bio prison", 2016-10-21). +Cache uses version 2 of the bio prison, the structure behind the cells described above ([dm-cache-target.c:9][cache9], [dm-cache-target.c:1083][cache1083]); thin provisioning uses version 1 ([dm-thin.c:9][thin9]). Version 2 came in Linux 4.12 ([`742c8fdc31e8`][c742c8fdc31e8], "dm bio prison v2: new interface for the bio prison", 2016-10-21). ## Where it came from @@ -553,20 +559,20 @@ timeline | When | What | Evidence | |---|---|---| | 2002-10-15 | The ioctl interface to device-mapper is posted: "Provide a traditional ioctl based interface to control device-mapper from userland." | [LWN: Device-mapper submission 6/7][lwn12734] | -| 2.6.12 (tag `v2.6.12-rc2`, 2005-04-16, the first commit in the git history) | `dm-linear.c` and `dm-ioctl.c` already exist; `dm-linear.c` carries "Copyright (C) 2001-2003 Sistina Software (UK) Limited." ([dm-linear.c:3][lin3]) | `1da177e4c3f41524e886b7f1b8a0c1fc7321cac2` | +| 2.6.12 (tag `v2.6.12-rc2`, 2005-04-16, the first commit in the git history) | `dm-linear.c` and `dm-ioctl.c` already exist; `dm-linear.c` carries "Copyright (C) 2001-2003 Sistina Software (UK) Limited." ([dm-linear.c:3][lin3]) | [`1da177e4c3f4`][c1da177e4c3f4] | | 2006-12-19 | RFC for request-based DM: "Hook for I/O mapping is at request_fn after merging and sorting by I/O scheduler, instead of make_request_fn." | [LWN: rqbased-dm][lwn215058] | | 2008-03-19 | The series is reposted for discussion: "Currently, device-mapper (dm) is implemented as a stacking block device at bio level." | [LWN: request stacking and request-based dm-multipath][lwn274292] | | 2008-09-12, 2008-10-03 | Version 2 (13 patches) and version 3 (8 patches) | [LWN v2][lwn298882], [LWN v3][lwn301919] | -| 2.6.31 (2009-06-22) | Request-based DM is prepared and enabled | `cec47e3d4a861e1d942b3a580d0bbef2700d2bb2`, `e6ee8c0b767540f59e20da3ced282601db8aa502` | -| 3.2 (2011-10-31) | Persistent-data library, then thin provisioning | `3241b1d3e0aaafbfcd320f4d71ade629728cc4f4`, `991d9fa02da0dd1f843dc011376965e0c8c6c9b5` | -| 3.9 (2013-03-01) | `cache` target; the documentation was posted on LWN on 2013-03-04 | `c6b4fcbad044e6fffcc75bba160e720eb8d67d17`, [LWN: cache.txt][lwn540996] | -| 4.0 (2014-12-17) | Requests are allocated in the target when stacking on blk-mq devices; the commit that follows calls this "the first step toward fully utilizing blk-mq in request-based DM" | `e5863d9ad754926e7d3f38b43ac8bd48ef73b097` | -| 4.1 (2015-03-08) | The mapped device's own queue becomes blk-mq: "enables stacking a blk-mq request_queue ontop of the underlying blk-mq device(s)" | `bfebd1cdb497a57757c83f5fbf1a29931591e2a4` | -| 4.12 (2016-10-21) | Bio prison v2 | `742c8fdc31e820503f9267070311d894978d1349` | -| 5.18 (2022-02-17) | `dm_submit_bio_remap()` lets a target that submits clones itself have them accounted when it submits them, if it sets `accounts_remapped_io` | `0fbb4d93b38bce1f8235aacfa37e90ad8f011473` | -| 5.19 (2022-04-12) | Reworked bio splitting and I/O accounting | `7dd76d1feec70a23e1de2b55c0c2a9c592fa8423` | +| 2.6.31 (2009-06-22) | Request-based DM is prepared and enabled | [`cec47e3d4a86`][ccec47e3d4a86], [`e6ee8c0b7675`][ce6ee8c0b7675] | +| 3.2 (2011-10-31) | Persistent-data library, then thin provisioning | [`3241b1d3e0aa`][c3241b1d3e0aa], [`991d9fa02da0`][c991d9fa02da0] | +| 3.9 (2013-03-01) | `cache` target; the documentation was posted on LWN on 2013-03-04 | [`c6b4fcbad044`][cc6b4fcbad044], [LWN: cache.txt][lwn540996] | +| 4.0 (2014-12-17) | Requests are allocated in the target when stacking on blk-mq devices; the commit that follows calls this "the first step toward fully utilizing blk-mq in request-based DM" | [`e5863d9ad754`][ce5863d9ad754] | +| 4.1 (2015-03-08) | The mapped device's own queue becomes blk-mq: "enables stacking a blk-mq request_queue ontop of the underlying blk-mq device(s)" | [`bfebd1cdb497`][cbfebd1cdb497] | +| 4.12 (2016-10-21) | Bio prison v2 | [`742c8fdc31e8`][c742c8fdc31e8] | +| 5.18 (2022-02-17) | `dm_submit_bio_remap()` lets a target that submits clones itself have them accounted when it submits them, if it sets `accounts_remapped_io` | [`0fbb4d93b38b`][c0fbb4d93b38b] | +| 5.19 (2022-04-12) | Reworked bio splitting and I/O accounting | [`7dd76d1feec7`][c7dd76d1feec7] | -The original list postings for the thin-provisioning (2011) and cache (2013) commits are not linked: the commits carry no `Link:` trailer. +The original list postings for the thin-provisioning (2011) and cache (2013) commits, and for the 2022 `dm_submit_bio_remap()` and bio-splitting patches, are not linked: those commits carry no `Link:` trailer. ## Further reading @@ -584,11 +590,13 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [cache1073]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1073 [cache1083]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1083 [cache1187]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1187 +[cache1192]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1192 [cache1252]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1252 [cache1293]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1293 [cache1332]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1332 [cache1355]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1355 [cache1369]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1369 +[cache1392]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1392 [cache1410]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1410 [cache1666]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1666 [cache1675]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1675 @@ -600,6 +608,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [cache1746]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1746 [cache1758]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1758 [cache1769]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1769 +[cache1911]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1911 [cache1916]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1916 [cache2026]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2026 [cache2185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2185 @@ -632,8 +641,10 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [dm1457]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1457 [dm1736]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1736 [dm1749]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1749 +[dm1767]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1767 [dm2018]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2018 [dm2051]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2051 +[dm2057]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2057 [dm2085]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2085 [dm2086]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2086 [dm2094]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2094 @@ -658,6 +669,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [dm620]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n620 [dm626]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n626 [dm645]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n645 +[dm997]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n997 [dmdocs]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/?h=v7.4-rc5 [dmh173]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n173 [dmh185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n185 @@ -681,6 +693,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [dmt2171]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n2171 [dmt2195]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n2195 [dmt30]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n30 +[dmt397]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n397 [dmt686]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n686 [dmt704]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n704 [dmt719]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n719 @@ -738,6 +751,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin1004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1004 [thin1009]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1009 [thin1335]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1335 +[thin1338]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1338 [thin1396]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1396 [thin1415]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1415 [thin1449]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1449 @@ -773,13 +787,13 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin2646]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2646 [thin2657]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2657 [thin2722]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2722 +[thin2734]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2734 [thin2740]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2740 [thin2745]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2745 [thin2754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2754 [thin2755]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2755 [thin2765]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2765 [thin2767]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2767 -[thin2781]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2781 [thin2784]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2784 [thin2797]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2797 [thin2864]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2864 @@ -789,6 +803,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin33]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n33 [thin3345]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3345 [thin34]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n34 +[thin3450]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3450 [thin3537]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3537 [thin3855]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3855 [thin41]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n41 @@ -816,3 +831,14 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [tm1651]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1651 [tm20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n20 [tm68]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n68 +[c0fbb4d93b38b]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0fbb4d93b38bce1f8235aacfa37e90ad8f011473 +[c1da177e4c3f4]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 +[c3241b1d3e0aa]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3241b1d3e0aaafbfcd320f4d71ade629728cc4f4 +[c742c8fdc31e8]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=742c8fdc31e820503f9267070311d894978d1349 +[c7dd76d1feec7]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7dd76d1feec70a23e1de2b55c0c2a9c592fa8423 +[c991d9fa02da0]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=991d9fa02da0dd1f843dc011376965e0c8c6c9b5 +[cbfebd1cdb497]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bfebd1cdb497a57757c83f5fbf1a29931591e2a4 +[cc6b4fcbad044]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6b4fcbad044e6fffcc75bba160e720eb8d67d17 +[ccec47e3d4a86]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cec47e3d4a861e1d942b3a580d0bbef2700d2bb2 +[ce5863d9ad754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5863d9ad754926e7d3f38b43ac8bd48ef73b097 +[ce6ee8c0b7675]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e6ee8c0b767540f59e20da3ced282601db8aa502 From 5ae94bfc00562c8cba74591b48a3f8f06b74239d Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Sun, 29 Nov 2026 20:26:40 -0800 Subject: [PATCH 05/20] block: pin the device-mapper page to Linux v7.3 Point every source link at the v7.3 release instead of v7.4-rc5. The line numbers are remapped from the diff between the two tags, and the description of the table's device list now matches v7.3, where struct dm_dev_internal holds a reference count and a dm_dev pointer. --- docs/block/device-mapper.md | 633 ++++++++++++++++++------------------ 1 file changed, 317 insertions(+), 316 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index a8d49a95..c395197b 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -2,7 +2,7 @@ > How the kernel builds a virtual block device from a table of ranges, and what the linear, thin-provisioning and cache targets do with it -Source links point at Linux v7.4-rc5, the tree this page was checked against. Release numbers are mainline releases. Dates are author dates for commits and the dates shown on the page for LWN postings. +Source links point at Linux v7.3, the tree this page was checked against. Release numbers are mainline releases. Dates are author dates for commits and the dates shown on the page for LWN postings. **Find your way** @@ -18,7 +18,7 @@ Source links point at Linux v7.4-rc5, the tree this page was checked against. Re ## What it is -A device-mapper device is a block device whose I/O is handled by the device-mapper core instead of a hardware driver. What the device does with an I/O is set by its *table*: a list of ranges of the device's sectors, each handled by a *target*. A range is added with a start, a length, a target type name and a parameter string ([`dm_table_add_target()`][dmt686]), and the target's constructor receives the parameters split into arguments ([dm-table.c:759-765][dmt759]). +A device-mapper device is a block device whose I/O is handled by the device-mapper core instead of a hardware driver. What the device does with an I/O is set by its *table*: a list of ranges of the device's sectors, each handled by a *target*. A range is added with a start, a length, a target type name and a parameter string ([`dm_table_add_target()`][dmt670]), and the target's constructor receives the parameters split into arguments ([dm-table.c:743-749][dmt743]). ``` mapped device (one gendisk, one table) @@ -61,17 +61,17 @@ Where a mapped device sits when a bio arrives: lower block device(s) ``` -The steps are the ones in [dm.c:2085-2104][dm2085] (find the table, split and process), [dm.c:1736][dm1736] and [dm.c:1767][dm1767] (find the target, allocate the clone), [dm.c:1435][dm1435] (the target's `map`) and [dm.c:1386][dm1386] (submit the remapped clone). +The steps are the ones in [dm.c:2080-2099][dm2080] (find the table, split and process), [dm.c:1736][dm1736] and [dm.c:1767][dm1767] (find the target, allocate the clone), [dm.c:1435][dm1435] (the target's `map`) and [dm.c:1386][dm1386] (submit the remapped clone). -A device is either *bio-based* or *request-based* (see [below](#bio-based-and-request-based-devices)). A bio-based device gets `dm_submit_bio()` as its `.submit_bio` ([dm.c:3813][dm3813]); a request-based device gets a different set of operations ([dm.c:2624][dm2624]) that has no `.submit_bio` ([dm.c:3825-3832][dm3825]). Unless a section says otherwise, this page describes bio-based devices. +A device is either *bio-based* or *request-based* (see [below](#bio-based-and-request-based-devices)). A bio-based device gets `dm_submit_bio()` as its `.submit_bio` ([dm.c:3804][dm3804]); a request-based device gets a different set of operations ([dm.c:2610][dm2610]) that has no `.submit_bio` ([dm.c:3816-3823][dm3816]). Unless a section says otherwise, this page describes bio-based devices. [dm-verity](dm-verity.md) and [dm-crypt](../security/dm-crypt.md) are other targets and have their own pages. This page covers the core and three targets that show its range. !!! info "Terms used on this page" - **bio**: the block layer's I/O descriptor; see [bio and request structures](bio-request.md). - **clone**: a copy of a bio made by the core for one target, from `bio_alloc_clone()` ([dm.c:626][dm626]). - - **flush and FUA**: `REQ_PREFLUSH` is a "request for cache flush" ([blk_types.h:401][blk401]) and `REQ_FUA` is "forced unit access" ([blk_types.h:400][blk400]). `op_is_flush()` is true for either ([blk_types.h:477-480][blk477]). - - **`REQ_NOWAIT` and read-ahead**: `REQ_NOWAIT` means "Don't wait if request will block" ([blk_types.h:404][blk404]); `REQ_RAHEAD` means "read ahead, can fail anytime" ([blk_types.h:402][blk402]). + - **flush and FUA**: `REQ_PREFLUSH` is a "request for cache flush" ([blk_types.h:395][blk395]) and `REQ_FUA` is "forced unit access" ([blk_types.h:394][blk394]). `op_is_flush()` is true for either ([blk_types.h:469-472][blk469]). + - **`REQ_NOWAIT` and read-ahead**: `REQ_NOWAIT` means "Don't wait if request will block" ([blk_types.h:398][blk398]); `REQ_RAHEAD` means "read ahead, can fail anytime" ([blk_types.h:396][blk396]). - **SRCU**: a read-side locking scheme whose readers may sleep; see [SRCU](../locking/srcu.md). The core uses it to find out when no thread is still using an old table. - **gendisk**: the kernel's structure for a disk; each mapped device owns one ([dm-core.h:78][core78]). @@ -87,10 +87,10 @@ flowchart LR MD -- "map (__rcu pointer,
read under SRCU)" --> T T -- "one per range" --> TG TG -- "type" --> TT - T -- "devices list
(via dm_dev_internal, dm_dev_ref)" --> DD + T -- "devices list
(via dm_dev_internal)" --> DD ``` -The `mapped_device` holds the table pointer, the disk and the list of bios that arrived during a suspend ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-318][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]); the table's list holds one `dm_dev_internal` per device, which holds a `dm_dev_ref` for each mode the device was opened with ([dm-table.c:397-411][dmt397]). +The `mapped_device` holds the table pointer, the disk and the list of bios that arrived during a suspend ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-318][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]); the table's list holds one `dm_dev_internal` per device, which has a reference count and a pointer to its `dm_dev` ([dm.h:41-45][mdh41], [dm-table.c:388-395][dmt388]). The core keeps its own structures private. The header says that targets "must _not_ deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). @@ -108,9 +108,9 @@ The table also lists commands to remove and rename a device, to read device and ## Two tables: load, then swap -A device with no live table fails the bios submitted to it: `dm_submit_bio()` calls `bio_io_error()` ([dm.c:2086-2090][dm2086]). +A device with no live table fails the bios submitted to it: `dm_submit_bio()` calls `bio_io_error()` ([dm.c:2081-2085][dm2081]). -Loading a table does not change the live one. `table_load()` creates a table, adds every target to it with `populate_table()` ([dm-ioctl.c:1639-1645][ioc1639]), and stores it as the device's new, inactive map ([dm-ioctl.c:1687-1689][ioc1687]). A second load replaces a staged table that was never resumed ([dm-ioctl.c:1702-1705][ioc1702]). Completing a table decides its type, builds the sector index, builds the crypto profile and allocates the memory pools for clones ([`dm_table_complete()`][dmt1521]). +Loading a table does not change the live one. `table_load()` creates a table, adds every target to it with `populate_table()` ([dm-ioctl.c:1639-1645][ioc1639]), and stores it as the device's new, inactive map ([dm-ioctl.c:1687-1689][ioc1687]). A second load replaces a staged table that was never resumed ([dm-ioctl.c:1702-1705][ioc1702]). Completing a table decides its type, builds the sector index, builds the crypto profile and allocates the memory pools for clones ([`dm_table_complete()`][dmt1505]). The swap happens on resume. When a table is staged, `do_resume()` suspends the device if it is not already suspended ([dm-ioctl.c:1284-1286][ioc1284]), calls `dm_swap_table()` ([dm-ioctl.c:1311][ioc1311]), and then resumes it ([dm-ioctl.c:1331-1333][ioc1331]). With no staged table it only resumes ([dm-ioctl.c:1274][ioc1274]). @@ -123,20 +123,20 @@ flowchart LR L --> S --> W --> R ``` -**Suspend.** `__dm_suspend()` calls the targets' `presuspend`. If the caller asked for a filesystem freeze and did not ask for no-flush, it then calls `lock_fs()`, which freezes the filesystem on the device ([dm.c:2951][dm2951]) and, per its comment, "flushes I/Os and waits for them to complete" ([dm.c:2996-3010][dm2996], condition at [dm.c:3004][dm3004]; the freeze is skipped when userspace passes `DM_SKIP_LOCKFS_FLAG`, [dm-ioctl.c:1280-1281][ioc1280]). It then sets `DMF_BLOCK_IO_FOR_SUSPEND`, waits with `synchronize_srcu()` for any thread still inside the map path, flushes the device's workqueue, and waits for in-flight I/O to finish ([dm.c:3023-3044][dm3023]). +**Suspend.** `__dm_suspend()` calls the targets' `presuspend`. If the caller asked for a filesystem freeze and did not ask for no-flush, it then calls `lock_fs()`, which freezes the filesystem on the device ([dm.c:2942][dm2942]) and, per its comment, "flushes I/Os and waits for them to complete" ([dm.c:2987-3001][dm2987], condition at [dm.c:2995][dm2995]; the freeze is skipped when userspace passes `DM_SKIP_LOCKFS_FLAG`, [dm-ioctl.c:1280-1281][ioc1280]). It then sets `DMF_BLOCK_IO_FOR_SUSPEND`, waits with `synchronize_srcu()` for any thread still inside the map path, flushes the device's workqueue, and waits for in-flight I/O to finish ([dm.c:3014-3035][dm3014]). !!! note "What happens to bios during a suspend (bio-based)" - While `DMF_BLOCK_IO_FOR_SUSPEND` is set, `dm_submit_bio()` queues ordinary bios on a list. A `REQ_NOWAIT` bio fails with `bio_wouldblock_error()` and a read-ahead bio fails with `bio_io_error()` ([dm.c:2094-2102][dm2094]). A request-based device stops its request queue instead ([dm.c:3031-3034][dm3031]), and the deferred requests wait in that queue ([dm.c:3137][dm3137]). + While `DMF_BLOCK_IO_FOR_SUSPEND` is set, `dm_submit_bio()` queues ordinary bios on a list. A `REQ_NOWAIT` bio fails with `bio_wouldblock_error()` and a read-ahead bio fails with `bio_io_error()` ([dm.c:2089-2097][dm2089]). A request-based device stops its request queue instead ([dm.c:3022-3025][dm3022]), and the deferred requests wait in that queue ([dm.c:3128][dm3128]). -**Swap.** `dm_swap_table()` refuses to run unless the device is suspended ([dm.c:2898][dm2898]). Unless it keeps the existing limits (a table with no data devices, or a noflush suspend of an immutable request-based device), it computes the queue limits for the new table ([dm.c:2909-2927][dm2909]); `__bind()` then publishes the table with `rcu_assign_pointer()` and waits for readers of the old one ([dm.c:2534-2539][dm2534]). +**Swap.** `dm_swap_table()` refuses to run unless the device is suspended ([dm.c:2889][dm2889]). Unless it keeps the existing limits (a table with no data devices, or a noflush suspend of an immutable request-based device), it computes the queue limits for the new table ([dm.c:2900-2918][dm2900]); `__bind()` then publishes the table with `rcu_assign_pointer()` and waits for readers of the old one ([dm.c:2529-2534][dm2529]). -**Resume.** `__dm_resume()` resumes the targets ([dm.c:3125-3130][dm3125]), restarts the queued bios, and unlocks the filesystem ([dm.c:3132-3142][dm3132]). The comment gives the order's reason: "Flushing deferred I/Os must be done after targets are resumed so that mapping of targets can work correctly" ([dm.c:3134-3137][dm3134]). `dm_wq_work()` replays the queue with `submit_bio_noacct()` ([dm.c:2864-2874][dm2864]). +**Resume.** `__dm_resume()` resumes the targets ([dm.c:3116-3121][dm3116]), restarts the queued bios, and unlocks the filesystem ([dm.c:3123-3133][dm3123]). The comment gives the order's reason: "Flushing deferred I/Os must be done after targets are resumed so that mapping of targets can work correctly" ([dm.c:3125-3128][dm3125]). `dm_wq_work()` replays the queue with `submit_bio_noacct()` ([dm.c:2855-2865][dm2855]). ## The sector index -A table maps a sector to a target. `dm_table_find_target()` walks an index whose nodes are one cache line wide and hold sector keys ([dm-table.c:30-32][dmt30], [dm-table.c:1581-1599][dmt1581]). A sector past the end of the table returns no target ([dm-table.c:1586-1587][dmt1586]), and the I/O path fails the bio with `BLK_STS_IOERR` ([dm.c:1736-1738][dm1736]). +A table maps a sector to a target. `dm_table_find_target()` walks an index whose nodes are one cache line wide and hold sector keys ([dm-table.c:30-32][dmt30], [dm-table.c:1565-1583][dmt1565]). A sector past the end of the table returns no target ([dm-table.c:1570-1571][dmt1570]), and the I/O path fails the bio with `BLK_STS_IOERR` ([dm.c:1736-1738][dm1736]). -The index keys are the last sector of each range. `dm_table_add_target()` stores `begin + len - 1` in `highs` ([dm-table.c:770][dmt770]), the leaf level of the index is that array ([dm-table.c:1145][dmt1145]), and the lookup takes the first key that is not smaller than the sector ([dm-table.c:1593-1596][dmt1593]). For the table in the first diagram: +The index keys are the last sector of each range. `dm_table_add_target()` stores `begin + len - 1` in `highs` ([dm-table.c:754][dmt754]), the leaf level of the index is that array ([dm-table.c:1129][dmt1129]), and the lookup takes the first key that is not smaller than the sector ([dm-table.c:1577-1580][dmt1577]). For the table in the first diagram: ``` ranges of the table leaf of the index (highs) @@ -146,21 +146,21 @@ The index keys are the last sector of each range. `dm_table_add_target()` stores lookup of sector 1500: the first key >= 1500 is highs[1], so the target is targets[1] ``` -A larger table adds levels above the leaf; `dm_table_find_target()` walks all `t->depth` levels, the leaf included ([dm-table.c:1589][dmt1589]). +A larger table adds levels above the leaf; `dm_table_find_target()` walks all `t->depth` levels, the leaf included ([dm-table.c:1573][dmt1573]). -`dm_table_add_target()` rejects a range that has zero length ([dm-table.c:704-707][dmt704]) and a range that does not start where the previous one ended ([dm-table.c:754-757][dmt754]). A target type's feature flags add further rules: +`dm_table_add_target()` rejects a range that has zero length ([dm-table.c:688-691][dmt688]) and a range that does not start where the previous one ended ([dm-table.c:738-741][dmt738]). A target type's feature flags add further rules: | Feature | Meaning | Where enforced | |---|---|---| -| `DM_TARGET_SINGLETON` | Must be the only target in a table | [dm-table.c:719-725][dmt719] | -| `DM_TARGET_ALWAYS_WRITEABLE` | Not allowed in a read-only table | [dm-table.c:727-731][dmt727] | -| `DM_TARGET_IMMUTABLE` | Cannot be mixed with other target types in one table | [dm-table.c:733-744][dmt733] | +| `DM_TARGET_SINGLETON` | Must be the only target in a table | [dm-table.c:703-709][dmt703] | +| `DM_TARGET_ALWAYS_WRITEABLE` | Not allowed in a read-only table | [dm-table.c:711-715][dmt711] | +| `DM_TARGET_IMMUTABLE` | Cannot be mixed with other target types in one table | [dm-table.c:717-728][dmt717] | | `DM_TARGET_IMMUTABLE` | Once a device has it, a later table must use the same type, unless it contains a wildcard target | [dm-ioctl.c:1649-1657][ioc1649] | | `DM_TARGET_WILDCARD` | May replace any target, even an immutable one | [device-mapper.h:254-258][dmh254] | ## The I/O path for bio-based devices -A bio reaches the device through `dm_submit_bio()`, which takes the live table under SRCU ([dm.c:2085][dm2085]) and calls `dm_split_and_process_bio()` ([dm.c:2104][dm2104]). +A bio reaches the device through `dm_submit_bio()`, which takes the live table under SRCU ([dm.c:2080][dm2080]) and calls `dm_split_and_process_bio()` ([dm.c:2099][dm2099]). ``` bio for the mapped device @@ -190,11 +190,11 @@ A bio reaches the device through `dm_submit_bio()`, which takes the live table u ``` 1. **Clone.** `__split_and_process_bio()` finds the target for the current sector ([dm.c:1736][dm1736]) and limits the length to the target's maximum I/O length and the sectors left ([dm.c:1749][dm1749]). `alloc_tio()` supplies the clone: the first one is embedded in the per-I/O structure `dm_io`, later ones come from `bio_alloc_clone()` ([dm.c:620-626][dm620]). The clone's default device is the mapped device itself, so the target must change it before the bio is issued ([dm.c:645-646][dm645]). -2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2051-2058][dm2051]). +2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2046-2053][dm2046]). 3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). 4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The original bio completes when the count of outstanding clones reaches zero ([dm.c:1047-1055][dm1047]). -**A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2051-2058][dm2051]): +**A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2046-2053][dm2046]): ``` table: target A sectors 0 - 999 │ target B sectors 1000 - 4999 @@ -206,7 +206,7 @@ A bio reaches the device through `dm_submit_bio()`, which takes the live table u done the original bio completes when both clones have completed ``` -The original bio waits for the second pass because the first pass takes an extra reference on it with `bio_inc_remaining()` ([dm.c:2057][dm2057]); each pass ends the bio with `bio_endio()` ([dm.c:997][dm997]). +The original bio waits for the second pass because the first pass takes an extra reference on it with `bio_inc_remaining()` ([dm.c:2052][dm2052]); each pass ends the bio with `bio_endio()` ([dm.c:997][dm997]). What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], values at [device-mapper.h:710-714][dmh710]): @@ -220,13 +220,13 @@ What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], va !!! warning "`DM_MAPIO_DELAY_REQUEUE` is not a bio-based return value" The value is defined next to the others, but the switch in `__map_bio()` has no case for it and ends in `BUG()` ([dm.c:1457-1459][dm1457]). The request-based path handles it ([dm-rq.c:412][rq412]). -**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios` and `num_secure_erase_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then the flush with data goes straight to that device ([dm.c:2018-2039][dm2018]). +**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios` and `num_secure_erase_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then the flush with data goes straight to that device ([dm.c:2013-2034][dm2013]). ## Bio-based and request-based devices -A table is bio-based, request-based or DAX bio-based ([device-mapper.h:29-34][dmh29]); DAX is the direct-access variant of bio-based. The type comes from the targets: a table that mixes bio-based and request-based targets is rejected ([dm-table.c:941-944][dmt941]). A request-based table must have a single target ([dm-table.c:981-984][dmt981]). Unless the table has no devices, that target must be immutable ([dm-table.c:986-1000][dmt986]). A device keeps the type of its first table; a later table of a different type is refused, except that a bio-based device may become DAX bio-based ([dm-ioctl.c:1617-1624][ioc1617], [dm-ioctl.c:1666-1671][ioc1666]). +A table is bio-based, request-based or DAX bio-based ([device-mapper.h:29-34][dmh29]); DAX is the direct-access variant of bio-based. The type comes from the targets: a table that mixes bio-based and request-based targets is rejected ([dm-table.c:925-928][dmt925]). A request-based table must have a single target ([dm-table.c:965-968][dmt965]). Unless the table has no devices, that target must be immutable ([dm-table.c:970-984][dmt970]). A device keeps the type of its first table; a later table of a different type is refused, except that a bio-based device may become DAX bio-based ([dm-ioctl.c:1617-1624][ioc1617], [dm-ioctl.c:1666-1671][ioc1666]). -A request-based target works on `struct request`, through a `clone_and_map_rq` callback ([device-mapper.h:63][dmh63]). The multipath target is the example in the tree. It is a singleton and immutable, implements `clone_and_map_rq` ([dm-mpath.c:2299-2306][mpath2299]) and defaults to request-based; the `queue_mode bio` option makes it bio-based ([dm-mpath.c:240-245][mpath240], [dm-mpath.c:1161-1169][mpath1161]). +A request-based target works on `struct request`, through a `clone_and_map_rq` callback ([device-mapper.h:63][dmh63]). The multipath target is the example in the tree. It is a singleton and immutable, implements `clone_and_map_rq` ([dm-mpath.c:2300-2307][mpath2300]) and defaults to request-based; the `queue_mode bio` option makes it bio-based ([dm-mpath.c:240-245][mpath240], [dm-mpath.c:1159-1167][mpath1159]). The 2008 posting of the request-based series explains the difference: "Mapping is done in a unit of struct request, instead of struct bio" ([LWN, 2008-09-12][lwn298882]). The commit that enabled request-based DM, [`e6ee8c0b7675`][ce6ee8c0b7675] ("dm: enable request based option", Linux 2.6.31, 2009-06-22), gives the reason for keeping both: "there are some target drivers which are more fitting to bio-based dm". It also states the limit that is still in the code: request-based DM supports only tables with a single target. @@ -236,12 +236,12 @@ A target type is a `struct target_type`: a name, a version, feature flags and a | Callback | Called by the core | |---|---| -| `ctr` | When the range is added to a table ([dm-table.c:765][dmt765]) | -| `dtr` | When the table is destroyed ([dm-table.c:197-198][dmt197]) | +| `ctr` | When the range is added to a table ([dm-table.c:749][dmt749]) | +| `dtr` | When the table is destroyed ([dm-table.c:195-196][dmt195]) | | `map` | For each clone of a bio-based I/O; `linear` and `stripe` are called directly ([dm.c:1430-1435][dm1430]) | | `end_io` | When the clone completes ([dm.c:1114-1115][dm1114]) | -| `presuspend`, `postsuspend` | Around a suspend ([dm-table.c:2171-2194][dmt2171]) | -| `preresume`, `resume` | While resuming ([dm-table.c:2195-2221][dmt2195]) | +| `presuspend`, `postsuspend` | Around a suspend ([dm-table.c:2155-2178][dmt2155]) | +| `preresume`, `resume` | While resuming ([dm-table.c:2179-2205][dmt2179]) | `status`, `message`, `iterate_devices` and `io_hints` are also members of the struct ([device-mapper.h:215-221][dmh215]). A target's constructor opens the underlying devices with `dm_get_device()` ([device-mapper.h:185-186][dmh185]). Each range has a `struct dm_target` with its `begin`, `len` and optional `max_io_len` ([device-mapper.h:312-321][dmh312]). @@ -254,8 +254,8 @@ The feature flags that these targets set, from their `target_type` definitions ( | `linear` | ✗ | ✗ | ✗ | [dm-linear.c:202-207][lin202] | | `thin-pool` | ✓ | ✓ | ✓ | [dm-thin.c:4109-4112][thin4109] | | `thin` | ✗ | ✗ | ✗ | [dm-thin.c:4493-4495][thin4493] | -| `cache` | ✗ | ✗ | ✗ | [dm-cache-target.c:3563-3578][cache3563] (no `.features`) | -| `multipath` | ✓ | ✓ | ✗ | [dm-mpath.c:2299-2302][mpath2299] | +| `cache` | ✗ | ✗ | ✗ | [dm-cache-target.c:3556-3571][cache3556] (no `.features`) | +| `multipath` | ✓ | ✓ | ✗ | [dm-mpath.c:2300-2303][mpath2300] | The other flags, for example `DM_TARGET_PASSES_CRYPTO` and `DM_TARGET_NOWAIT`, are listed in [device-mapper.h:234-310][dmh234]. @@ -263,9 +263,9 @@ The other flags, for example `DM_TARGET_PASSES_CRYPTO` and `DM_TARGET_NOWAIT`, a | | `linear` | `thin-pool` and `thin` | `cache` | |---|---|---|---| -| Table line | ` ` ([dm-linear.c:28][lin28]) | pool: ` ` ([dm-thin.c:3274-3277][thin3274]); thin: ` [origin_dev]` ([dm-thin.c:4172][thin4172]) | ` <#feature args> []* <#policy args> []*` ([dm-cache-target.c:2026-2028][cache2026]) | +| Table line | ` ` ([dm-linear.c:28][lin28]) | pool: ` ` ([dm-thin.c:3271-3274][thin3271]); thin: ` [origin_dev]` ([dm-thin.c:4172][thin4172]) | ` <#feature args> []* <#policy args> []*` ([dm-cache-target.c:2025-2027][cache2025]) | | Has a metadata device | ✗ | ✓ | ✓ | -| `map` returns | always `DM_MAPIO_REMAPPED` ([dm-linear.c:96][lin96]) | thin: `REMAPPED` only for a mapped, unshared block that is not held in a cell, `SUBMITTED` otherwise ([dm-thin.c:2734-2811][thin2734]); thin-pool: always `REMAPPED` ([dm-thin.c:3450][thin3450]) | `REMAPPED`, or `SUBMITTED` when the target takes the bio over ([dm-cache-target.c:1675][cache1675], [dm-cache-target.c:1769][cache1769]) | +| `map` returns | always `DM_MAPIO_REMAPPED` ([dm-linear.c:96][lin96]) | thin: `REMAPPED` only for a mapped, unshared block that is not held in a cell, `SUBMITTED` otherwise ([dm-thin.c:2731-2808][thin2731]); thin-pool: always `REMAPPED` ([dm-thin.c:3450][thin3450]) | `REMAPPED`, or `SUBMITTED` when the target takes the bio over ([dm-cache-target.c:1674][cache1674], [dm-cache-target.c:1768][cache1768]) | | Modes | none | pool modes ([below](#running-out-of-space)) | writeback, writethrough, passthrough ([below](#three-io-modes)) | ## linear: the smallest target @@ -300,7 +300,7 @@ Thin provisioning uses two target types ([dm-thin.c:4109-4110][thin4109], [dm-th | | `thin-pool` | `thin` | |---|---|---| | Role | Owns the storage: a metadata device and a data device split into blocks | One virtual device carved out of a pool | -| Table line | ` ` and optional features ([dm-thin.c:3274-3284][thin3274]) | ` [origin_dev]` ([dm-thin.c:4170-4172][thin4172]) | +| Table line | ` ` and optional features ([dm-thin.c:3271-3281][thin3271]) | ` [origin_dev]` ([dm-thin.c:4170-4172][thin4172]) | | Features | Singleton, always writeable, immutable, passes crypto ([dm-thin.c:4111-4112][thin4111]) | Passes crypto ([dm-thin.c:4495][thin4495]) | !!! example "Creating a pool, a thin device and a snapshot, from the kernel documentation" @@ -317,7 +317,7 @@ Thin provisioning uses two target types ([dm-thin.c:4109-4110][thin4109], [dm-th Sources: pool ([thin-provisioning.rst:104-106][thinrst104]), thin device ([thin-provisioning.rst:165-175][thinrst165]), snapshot ([thin-provisioning.rst:192-194][thinrst192]). -The data block size must be at least 64 KB, at most 1 GB, and a multiple of 64 KB ([dm-thin.c:41-46][thin41], [dm-thin.c:3345-3348][thin3345]). According to the commit that added the target, many virtual devices are stored on the same data volume, and snapshots can be taken of snapshots (see [Snapshots](#snapshots)). A pool is managed with messages: `create_thin`, `create_snap`, `delete`, `set_transaction_id`, `reserve_metadata_snap` and `release_metadata_snap` ([dm-thin.c:3855-3871][thin3855]). +The data block size must be at least 64 KB, at most 1 GB, and a multiple of 64 KB ([dm-thin.c:41-46][thin41], [dm-thin.c:3342-3345][thin3342]). According to the commit that added the target, many virtual devices are stored on the same data volume, and snapshots can be taken of snapshots (see [Snapshots](#snapshots)). A pool is managed with messages: `create_thin`, `create_snap`, `delete`, `set_transaction_id`, `reserve_metadata_snap` and `release_metadata_snap` ([dm-thin.c:3855-3871][thin3855]). ### Metadata @@ -337,7 +337,7 @@ Only the superblock has a fixed place, block zero; the other structures are allo ### The path of a bio -`thin_map()` rebases the sector and calls `thin_bio_map()` ([dm-thin.c:4326-4331][thin4326]), which handles the bio when it can and otherwise hands it to the pool's worker thread ([dm-thin.c:2722][thin2722]). To decide, it takes a *cell* on the virtual block (a lock on that block, held by the first bio that reaches it) and looks the block up without issuing metadata I/O ([dm-thin.c:2754-2758][thin2754]). +`thin_map()` rebases the sector and calls `thin_bio_map()` ([dm-thin.c:4326-4331][thin4326]), which handles the bio when it can and otherwise hands it to the pool's worker thread ([dm-thin.c:2719][thin2719]). To decide, it takes a *cell* on the virtual block (a lock on that block, held by the first bio that reaches it) and looks the block up without issuing metadata I/O ([dm-thin.c:2751-2755][thin2751]). ```mermaid flowchart TD @@ -361,13 +361,13 @@ flowchart TD F --> M ``` -A bio can also be held in the cell because another bio already holds it ([dm-thin.c:2755-2756][thin2755]); the diagram leaves that case out. +A bio can also be held in the cell because another bio already holds it ([dm-thin.c:2752-2753][thin2752]); the diagram leaves that case out. The anchors for the diagram: -- Flushes and discards go to the worker ([dm-thin.c:2745-2748][thin2745]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2784-2795][thin2784]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2765-2782][thin2765], [dm-thin.c:2797-2800][thin2797]). -- A write to a shared block breaks the sharing; a read of one is remapped to the shared block ([dm-thin.c:1888-1900][thin1888]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1800-1813][thin1800]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device, or, for a thin device with an external origin, read from the origin ([dm-thin.c:1978-1993][thin1978]). A write allocates a data block ([dm-thin.c:1931][thin1931]), then copies from the origin if there is one ([dm-thin.c:1934-1935][thin1934]), except that a block past the end of the origin is zeroed instead ([dm-thin.c:1415-1426][thin1415]) and the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). +- A write to a shared block breaks the sharing; a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device, or, for a thin device with an external origin, read from the origin ([dm-thin.c:1977-1992][thin1977]). A write allocates a data block ([dm-thin.c:1930][thin1930]), then copies from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that a block past the end of the origin is zeroed instead ([dm-thin.c:1415-1426][thin1415]) and the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk @@ -390,13 +390,13 @@ sequenceDiagram W->>D: other bios are submitted ``` -The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2387-2388][thin2387], [dm-thin.c:33][thin33], [dm-thin.c:2110-2114][thin2110]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2403-2411][thin2403]). +The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). ### Snapshots `create_snap` makes the snapshot's mapping tree by taking another reference to the origin's tree root: "clone the origin, an inc will do" ([dm-thin-metadata.c:1205-1206][tm1205]). It then bumps the pool's time counter and records it as the *snapshotted time* of both devices ([dm-thin-metadata.c:1218-1224][tm1218], [dm-thin-metadata.c:1174-1178][tm1174]). -A block counts as shared when the time stored with it is older than the device's last snapshot ([dm-thin-metadata.c:1500-1509][tm1500], [dm-thin-metadata.c:1521][tm1521]). A new mapping is stored with the pool's current time ([dm-thin-metadata.c:1651][tm1651]). +A block counts as shared when the time stored with it is older than the device's last snapshot ([dm-thin-metadata.c:1497-1506][tm1497], [dm-thin-metadata.c:1518][tm1518]). A new mapping is stored with the pool's current time ([dm-thin-metadata.c:1648][tm1648]). ``` create_snap 1 0 pool time goes from 0 to 1 @@ -412,10 +412,10 @@ A block counts as shared when the time stored with it is older than the device's result device 0: vblock 7 → 40 device 1: vblock 7 → 41 ``` -The numbers are illustrative; the steps are `__create_snap()` ([dm-thin-metadata.c:1205-1224][tm1205]), `break_sharing()` ([dm-thin.c:1800-1813][thin1800], copy skipped for a whole-block write at [dm-thin.c:1338-1339][thin1338]) and the insert in `process_prepared_mapping()` ([dm-thin.c:1009][thin1009]). +The numbers are illustrative; the steps are `__create_snap()` ([dm-thin-metadata.c:1205-1224][tm1205]), `break_sharing()` ([dm-thin.c:1799-1812][thin1799], copy skipped for a whole-block write at [dm-thin.c:1338-1339][thin1338]) and the insert in `process_prepared_mapping()` ([dm-thin.c:1009][thin1009]). !!! warning "Quiesce the origin before taking a snapshot" - `thin_bio_map()` has a window between its lookup and snapshot creation. The comment gives the rule that avoids it: "always quiesce the origin before taking the snap" ([dm-thin.c:2767-2776][thin2767]). The kernel documentation says the same: "you must suspend it before creating the snapshot to avoid corruption. This is NOT enforced at the moment" ([thin-provisioning.rst:186-188][thinrst186]). + `thin_bio_map()` has a window between its lookup and snapshot creation. The comment gives the rule that avoids it: "always quiesce the origin before taking the snap" ([dm-thin.c:2764-2773][thin2764]). The kernel documentation says the same: "you must suspend it before creating the snapshot to avoid corruption. This is NOT enforced at the moment" ([thin-provisioning.rst:186-188][thinrst186]). The commit that added thin provisioning ([`991d9fa02da0`][c991d9fa02da0], Linux 3.2, 2011-10-31) says how it differs from the earlier snapshot implementation: "The previous implementation of snapshots did this by chaining together lookup tables, and so performance was O(depth). This new implementation uses a single data structure so we don't get this degradation with depth." @@ -442,50 +442,50 @@ stateDiagram-v2 | `PM_WRITE` → `PM_OUT_OF_DATA_SPACE` | `alloc_data_block()` finds no free block after a commit, or the allocation returns `-ENOSPC` ([dm-thin.c:1545-1547][thin1545], [dm-thin.c:1553-1554][thin1553]) | | `PM_OUT_OF_DATA_SPACE` → `PM_WRITE` | After a commit, `check_for_data_space()` finds free blocks ([dm-thin.c:1473-1475][thin1473], called from [dm-thin.c:1494-1495][thin1494]) | | → `PM_OUT_OF_METADATA_SPACE` | `check_for_metadata_space()` finds no free metadata block, or cannot read the count, and the pool is not already read-only ([dm-thin.c:1449-1458][thin1449]) | -| → `PM_READ_ONLY` | A metadata operation failed: the transaction is aborted and the mode set ([dm-thin.c:2657-2663][thin2657]) | -| → `PM_FAIL` | Aborting the transaction, or setting the `needs_check` flag, failed ([dm-thin.c:2646-2654][thin2646]) | -| out of `PM_FAIL` | Never: "we never let the pool move out of the old mode" ([dm-thin.c:2563-2568][thin2563]) | -| to `PM_WRITE` when `needs_check` is set | Refused ([dm-thin.c:2551-2561][thin2551]) | +| → `PM_READ_ONLY` | A metadata operation failed: the transaction is aborted and the mode set ([dm-thin.c:2654-2660][thin2654]) | +| → `PM_FAIL` | Aborting the transaction, or setting the `needs_check` flag, failed ([dm-thin.c:2643-2651][thin2643]) | +| out of `PM_FAIL` | Never: "we never let the pool move out of the old mode" ([dm-thin.c:2560-2565][thin2560]) | +| to `PM_WRITE` when `needs_check` is set | Refused ([dm-thin.c:2548-2558][thin2548]) | | `PM_OUT_OF_METADATA_SPACE` → `PM_WRITE` | The pool sets `PM_WRITE` when the metadata device is grown ([dm-thin.c:3537-3538][thin3537]); the source comment says the mode "may switch back to WRITE on metadata resize" ([dm-thin.c:207-209][thin207]) | -| Table reload | `bind_control_target()` sets the mode from the new table's features: `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument ([dm-thin.c:2864-2885][thin2864], [dm-thin.c:2904][thin2904], [dm-thin.c:3178-3179][thin3178]) | +| Table reload | `bind_control_target()` sets the mode from the new table's features: `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument ([dm-thin.c:2861-2882][thin2861], [dm-thin.c:2901][thin2901], [dm-thin.c:3175-3176][thin3175]) | -The diagram shows representative edges. `metadata_operation_failed()` sets `PM_READ_ONLY` whatever the current mode, except that `PM_FAIL` is never left ([dm-thin.c:2657-2663][thin2657], [dm-thin.c:2563-2568][thin2563]), and `commit()` refuses to run only from `PM_OUT_OF_METADATA_SPACE` upward ([dm-thin.c:1487-1488][thin1487]), so a commit can also degrade the pool from `PM_OUT_OF_DATA_SPACE`. +The diagram shows representative edges. `metadata_operation_failed()` sets `PM_READ_ONLY` whatever the current mode, except that `PM_FAIL` is never left ([dm-thin.c:2654-2660][thin2654], [dm-thin.c:2560-2565][thin2560]), and `commit()` refuses to run only from `PM_OUT_OF_METADATA_SPACE` upward ([dm-thin.c:1487-1488][thin1487]), so a commit can also degrade the pool from `PM_OUT_OF_DATA_SPACE`. What each mode does with a bio: | Mode | Source comment | Behaviour | |---|---|---| | `PM_WRITE` | metadata may be changed | Served normally | -| `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only bio path ([dm-thin.c:2605-2608][thin2605]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | -| `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2583-2590][thin2583]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | -| `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write to a shared or unmapped block is unserviceable and fails ([dm-thin.c:2033-2064][thin2033]) | -| `PM_FAIL` | all I/O fails | Every bio fails ([dm-thin.c:2740-2743][thin2740]) | +| `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only bio path ([dm-thin.c:2602-2605][thin2602]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | +| `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2580-2587][thin2580]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | +| `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write to a shared or unmapped block is unserviceable and fails ([dm-thin.c:2032-2063][thin2032]) | +| `PM_FAIL` | all I/O fails | Every bio fails ([dm-thin.c:2737-2740][thin2737]) | -When free data blocks drop to the low water mark the pool raises an event on the device once ([dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2448-2462][dm2448]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2597-2603][thin2597]). +When free data blocks drop to the low water mark the pool raises an event on the device once ([dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). !!! warning "Held bios can fail after a timeout" - By default, bios held in `PM_OUT_OF_DATA_SPACE` wait at most 60 seconds: `no_space_timeout` is a module parameter and a value of 0 arms no timer ([dm-thin.c:34][thin34], [dm-thin.c:4553][thin4553], [dm-thin.c:2612-2613][thin2612]). When it expires with the pool still out of data space, the pool sets `error_if_no_space` and fails the queued bios with `BLK_STS_NOSPC` ([dm-thin.c:2449-2458][thin2449]). + By default, bios held in `PM_OUT_OF_DATA_SPACE` wait at most 60 seconds: `no_space_timeout` is a module parameter and a value of 0 arms no timer ([dm-thin.c:34][thin34], [dm-thin.c:4553][thin4553], [dm-thin.c:2609-2610][thin2609]). When it expires with the pool still out of data space, the pool sets `error_if_no_space` and fails the queued bios with `BLK_STS_NOSPC` ([dm-thin.c:2448-2457][thin2448]). ## cache -The `cache` target puts a fast device in front of a slow one. Its table line is ` `, a feature list and a policy with its arguments ([dm-cache-target.c:2026-2043][cache2026]). The kernel documentation says it "aims to improve performance of a block device (eg, a spindle) by dynamically migrating some of its data to a faster, smaller device (eg, an SSD)" ([cache.rst:11-13][cacherst11]) and that it "reuses the metadata library used in the thin-provisioning library" ([cache.rst:20-21][cacherst20]). +The `cache` target puts a fast device in front of a slow one. Its table line is ` `, a feature list and a policy with its arguments ([dm-cache-target.c:2025-2042][cache2025]). The kernel documentation says it "aims to improve performance of a block device (eg, a spindle) by dynamically migrating some of its data to a faster, smaller device (eg, an SSD)" ([cache.rst:11-13][cacherst11]) and that it "reuses the metadata library used in the thin-provisioning library" ([cache.rst:20-21][cacherst20]). ### Three I/O modes -A block that is already dirty, for example from writeback mode, is still written to the cache only ([dm-cache-target.c:1746-1751][cache1746]); only passthrough requires all blocks to be clean before it can be entered ([dm-cache-target.c:2842-2846][cache2842]). The comments are at [dm-cache-target.c:255-275][cache255]; the arguments that select the mode are parsed at [dm-cache-target.c:2211-2224][cache2211], and writeback is the default ([dm-cache-target.c:2185][cache2185]). +A block that is already dirty, for example from writeback mode, is still written to the cache only ([dm-cache-target.c:1745-1750][cache1745]); only passthrough requires all blocks to be clean before it can be entered ([dm-cache-target.c:2835-2839][cache2835]). The comments are at [dm-cache-target.c:254-274][cache254]; the arguments that select the mode are parsed at [dm-cache-target.c:2210-2223][cache2210], and writeback is the default ([dm-cache-target.c:2184][cache2184]). | Mode | Where a hit goes | Can the cache hold data newer than the origin? | What the source comment says | |---|---|---|---| | writeback | cache | ✓ | "Data is written to cached blocks only. These blocks are marked dirty. If you lose the cache device you will lose data." | -| writethrough | cache; a write to a clean block goes to both devices ([dm-cache-target.c:1746-1751][cache1746]) | ✗ for data written in this mode | "Data is written to both cache and origin. Blocks are never dirty." | -| passthrough | origin; a write also invalidates the cache block ([dm-cache-target.c:1738-1744][cache1738]) | ✗ | "Reads and writes always go to the origin. If a write goes to a cached oblock, then the cache block is invalidated." | +| writethrough | cache; a write to a clean block goes to both devices ([dm-cache-target.c:1745-1750][cache1745]) | ✗ for data written in this mode | "Data is written to both cache and origin. Blocks are never dirty." | +| passthrough | origin; a write also invalidates the cache block ([dm-cache-target.c:1737-1743][cache1737]) | ✗ | "Reads and writes always go to the origin. If a write goes to a cached oblock, then the cache block is invalidated." | !!! warning "Writeback loses data with the cache device" - In writeback mode the cache can hold the only up-to-date copy of a block. The source comment says so directly: "If you lose the cache device you will lose data" ([dm-cache-target.c:257-260][cache257]). + In writeback mode the cache can hold the only up-to-date copy of a block. The source comment says so directly: "If you lose the cache device you will lose data" ([dm-cache-target.c:256-259][cache256]). ### The map path -`cache_map()` sends bios for the partial block at the end of the origin straight to the origin, because those blocks are not cached ([dm-cache-target.c:2683-2692][cache2683]). It defers discards and flush or FUA bios to a worker ([dm-cache-target.c:2694-2697][cache2694], [dm-cache-target.c:1007-1010][cache1007]). Everything else goes to `map_bio()`, which takes a shared lock on the block and asks the policy about it ([dm-cache-target.c:1666-1698][cache1666]). +`cache_map()` sends bios for the partial block at the end of the origin straight to the origin, because those blocks are not cached ([dm-cache-target.c:2676-2685][cache2676]). It defers discards and flush or FUA bios to a worker ([dm-cache-target.c:2687-2690][cache2687], [dm-cache-target.c:1006-1009][cache1006]). Everything else goes to `map_bio()`, which takes a shared lock on the block and asks the policy about it ([dm-cache-target.c:1665-1697][cache1665]). ```mermaid flowchart TD @@ -506,13 +506,13 @@ flowchart TD G -- no --> O3["origin"] ``` -- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1716-1719][cache1716]). In writeback mode, when the policy returns a promotion for the block, a migration is started with the bio instead ([dm-cache-target.c:1691-1696][cache1691]). -- **Hit:** as in the table above ([dm-cache-target.c:1738-1751][cache1738]). -- **FUA:** the bio is issued after the metadata commit ([dm-cache-target.c:1758-1766][cache1758]). +- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1715-1718][cache1715]). In writeback mode, when the policy returns a promotion for the block, a migration is started with the bio instead ([dm-cache-target.c:1690-1695][cache1690]). +- **Hit:** as in the table above ([dm-cache-target.c:1737-1750][cache1737]). +- **FUA:** the bio is issued after the metadata commit ([dm-cache-target.c:1757-1765][cache1757]). ### The policy decides what moves -The core does not decide what to cache. A policy plug-in is asked about each bio, and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1916-1941][cache1916]). +The core does not decide what to cache. A policy plug-in is asked about each bio, and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). ```mermaid flowchart TD @@ -533,15 +533,15 @@ flowchart TD E2 --> H ``` -The anchors: the worker is woken from `map_bio()` when the policy queues work ([dm-cache-target.c:1706-1707][cache1706]), and also by the periodic waker ([dm-cache-target.c:1911][cache1911]); it asks the policy for work in `check_migrations()` ([dm-cache-target.c:1916-1941][cache1916]); `mg_lock_writes()` blocks writes and lets reads continue, and locks reads and writes when the migration carries the bio itself, the bottom branch ([dm-cache-target.c:1410-1418][cache1410], [dm-cache-target.c:1691-1695][cache1691]), which uses `overwrite()` in place of the copy and the lock upgrade ([dm-cache-target.c:1392-1395][cache1392]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1355-1359][cache1355]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1332-1336][cache1332]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1252-1303][cache1252], [dm-cache-target.c:1293-1298][cache1293]); `mg_complete()` clears the dirty bit for a promotion without a bio, a demotion and a writeback, sets it for a promotion that carries a bio and ends that bio, tells the policy and replays the bios that waited ([dm-cache-target.c:1187-1235][cache1187], [dm-cache-target.c:1192-1199][cache1192]). +The anchors: the worker is woken from `map_bio()` when the policy queues work ([dm-cache-target.c:1705-1706][cache1705]), and also by the periodic waker ([dm-cache-target.c:1910][cache1910]); it asks the policy for work in `check_migrations()` ([dm-cache-target.c:1915-1940][cache1915]); `mg_lock_writes()` blocks writes and lets reads continue, and locks reads and writes when the migration carries the bio itself, the bottom branch ([dm-cache-target.c:1409-1417][cache1409], [dm-cache-target.c:1690-1694][cache1690]), which uses `overwrite()` in place of the copy and the lock upgrade ([dm-cache-target.c:1391-1394][cache1391]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1354-1358][cache1354]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1331-1335][cache1331]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1251-1302][cache1251], [dm-cache-target.c:1292-1297][cache1292]); `mg_complete()` clears the dirty bit for a promotion without a bio, a demotion and a writeback, sets it for a promotion that carries a bio and ends that bio, tells the policy and replays the bios that waited ([dm-cache-target.c:1186-1234][cache1186], [dm-cache-target.c:1191-1198][cache1191]). The tree registers four policy names: `smq`, `mq`, `cleaner` and `default` ([dm-cache-policy-smq.c:1885-1939][smq1885]). The first three are created by the same function, `__smq_create()`, with different flag arguments ([dm-cache-policy-smq.c:1858-1880][smq1858]); `default` points at the `smq` type through `.real` ([dm-cache-policy-smq.c:1909-1914][smq1909]). -One shortcut avoids the copy. In writeback mode, a bio to a discarded block or one that writes a whole block is looked up with `policy_lookup_with_work()` ([dm-cache-target.c:1073-1077][cache1073], [dm-cache-target.c:1680-1696][cache1680]). The policy header explains the method: the core "needs the migration immediately though so it knows to do something different with the bio" ([dm-cache-policy.h:60-64][pol60]). The migration then uses `overwrite()` in place of a full copy, falling back to the full copy if the bio is no longer eligible ([dm-cache-target.c:1369-1395][cache1369]). +One shortcut avoids the copy. In writeback mode, a bio to a discarded block or one that writes a whole block is looked up with `policy_lookup_with_work()` ([dm-cache-target.c:1072-1076][cache1072], [dm-cache-target.c:1679-1695][cache1679]). The policy header explains the method: the core "needs the migration immediately though so it knows to do something different with the bio" ([dm-cache-policy.h:60-64][pol60]). The migration then uses `overwrite()` in place of a full copy, falling back to the full copy if the bio is no longer eligible ([dm-cache-target.c:1368-1394][cache1368]). The commit that added the target ([`c6b4fcbad044`][cc6b4fcbad044], "dm: add cache target", Linux 3.9, 2013-03-01) states the design choice: "A plug-in architecture was chosen so that the decisions about which data to migrate and when are delegated to interchangeable tunable policy modules." -Cache uses version 2 of the bio prison, the structure behind the cells described above ([dm-cache-target.c:9][cache9], [dm-cache-target.c:1083][cache1083]); thin provisioning uses version 1 ([dm-thin.c:9][thin9]). Version 2 came in Linux 4.12 ([`742c8fdc31e8`][c742c8fdc31e8], "dm bio prison v2: new interface for the bio prison", 2016-10-21). +Cache uses version 2 of the bio prison, the structure behind the cells described above ([dm-cache-target.c:9][cache9], [dm-cache-target.c:1082][cache1082]); thin provisioning uses version 1 ([dm-thin.c:9][thin9]). Version 2 came in Linux 4.12 ([`742c8fdc31e8`][c742c8fdc31e8], "dm bio prison v2: new interface for the bio prison", 2016-10-21). ## Where it came from @@ -581,256 +581,257 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com - [dm-verity](dm-verity.md) and [dm-crypt](../security/dm-crypt.md): two other targets. - Kernel documentation: [thin-provisioning.rst][thinrst], [cache.rst][cacherst] and the rest of [Documentation/admin-guide/device-mapper/][dmdocs]. -[blk400]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n400 -[blk401]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n401 -[blk402]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n402 -[blk404]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n404 -[blk477]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.4-rc5#n477 -[cache1007]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1007 -[cache1073]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1073 -[cache1083]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1083 -[cache1187]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1187 -[cache1192]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1192 -[cache1252]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1252 -[cache1293]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1293 -[cache1332]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1332 -[cache1355]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1355 -[cache1369]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1369 -[cache1392]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1392 -[cache1410]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1410 -[cache1666]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1666 -[cache1675]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1675 -[cache1680]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1680 -[cache1691]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1691 -[cache1706]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1706 -[cache1716]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1716 -[cache1738]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1738 -[cache1746]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1746 -[cache1758]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1758 -[cache1769]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1769 -[cache1911]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1911 -[cache1916]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n1916 -[cache2026]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2026 -[cache2185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2185 -[cache2211]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2211 -[cache255]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n255 -[cache257]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n257 -[cache2683]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2683 -[cache2694]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2694 -[cache2842]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n2842 -[cache3563]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n3563 -[cache9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.4-rc5#n9 -[cacherst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5 -[cacherst11]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5#n11 -[cacherst20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.4-rc5#n20 -[core189]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n189 -[core35]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n35 -[core60]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n60 -[core78]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n78 -[core97]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.4-rc5#n97 -[dm1047]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1047 -[dm1114]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1114 -[dm1134]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1134 -[dm1147]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1147 -[dm1161]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1161 -[dm1386]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1386 -[dm1414]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1414 -[dm1430]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1430 -[dm1435]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1435 -[dm1437]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1437 -[dm1457]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1457 -[dm1736]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1736 -[dm1749]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1749 -[dm1767]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n1767 -[dm2018]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2018 -[dm2051]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2051 -[dm2057]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2057 -[dm2085]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2085 -[dm2086]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2086 -[dm2094]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2094 -[dm2104]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2104 -[dm2448]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2448 -[dm2534]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2534 -[dm2624]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2624 -[dm2864]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2864 -[dm2898]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2898 -[dm2909]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2909 -[dm2951]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2951 -[dm2996]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n2996 -[dm3004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3004 -[dm3023]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3023 -[dm3031]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3031 -[dm3125]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3125 -[dm3132]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3132 -[dm3134]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3134 -[dm3137]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3137 -[dm3813]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3813 -[dm3825]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n3825 -[dm620]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n620 -[dm626]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n626 -[dm645]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n645 -[dm997]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.4-rc5#n997 -[dmdocs]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/?h=v7.4-rc5 -[dmh173]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n173 -[dmh185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n185 -[dmh198]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n198 -[dmh215]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n215 -[dmh234]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n234 -[dmh254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n254 -[dmh29]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n29 -[dmh312]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n312 -[dmh331]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n331 -[dmh358]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n358 -[dmh63]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n63 -[dmh710]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.4-rc5#n710 -[dmt1145]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1145 -[dmt1521]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1521 -[dmt1581]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1581 -[dmt1586]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1586 -[dmt1589]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1589 -[dmt1593]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n1593 -[dmt197]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n197 -[dmt2171]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n2171 -[dmt2195]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n2195 -[dmt30]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n30 -[dmt397]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n397 -[dmt686]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n686 -[dmt704]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n704 -[dmt719]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n719 -[dmt727]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n727 -[dmt733]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n733 -[dmt754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n754 -[dmt759]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n759 -[dmt765]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n765 -[dmt770]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n770 -[dmt941]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n941 -[dmt981]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n981 -[dmt986]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.4-rc5#n986 -[ioc1274]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1274 -[ioc1280]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1280 -[ioc1284]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1284 -[ioc1311]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1311 -[ioc1331]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1331 -[ioc1363]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1363 -[ioc1617]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1617 -[ioc1639]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1639 -[ioc1649]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1649 -[ioc1666]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1666 -[ioc1687]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1687 -[ioc1702]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1702 -[ioc1985]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n1985 -[ioc2034]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n2034 -[ioc2299]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n2299 -[ioc977]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.4-rc5#n977 -[ioh293]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/dm-ioctl.h?h=v7.4-rc5#n293 -[lin202]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n202 -[lin28]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n28 -[lin3]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n3 -[lin61]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n61 -[lin82]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n82 -[lin96]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.4-rc5#n96 -[linearrst28]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/linear.rst?h=v7.4-rc5#n28 +[blk394]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.3#n394 +[blk395]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.3#n395 +[blk396]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.3#n396 +[blk398]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.3#n398 +[blk469]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v7.3#n469 +[cache1006]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1006 +[cache1072]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1072 +[cache1082]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1082 +[cache1186]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1186 +[cache1191]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1191 +[cache1251]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1251 +[cache1292]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1292 +[cache1331]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1331 +[cache1354]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1354 +[cache1368]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1368 +[cache1391]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1391 +[cache1409]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1409 +[cache1665]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1665 +[cache1674]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1674 +[cache1679]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1679 +[cache1690]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1690 +[cache1705]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1705 +[cache1715]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1715 +[cache1737]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1737 +[cache1745]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1745 +[cache1757]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1757 +[cache1768]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1768 +[cache1910]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1910 +[cache1915]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1915 +[cache2025]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2025 +[cache2184]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2184 +[cache2210]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2210 +[cache254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n254 +[cache256]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n256 +[cache2676]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2676 +[cache2687]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2687 +[cache2835]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2835 +[cache3556]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n3556 +[cache9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n9 +[cacherst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.3 +[cacherst11]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.3#n11 +[cacherst20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/cache.rst?h=v7.3#n20 +[core189]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.3#n189 +[core35]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.3#n35 +[core60]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.3#n60 +[core78]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.3#n78 +[core97]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-core.h?h=v7.3#n97 +[dm1047]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1047 +[dm1114]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1114 +[dm1134]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1134 +[dm1147]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1147 +[dm1161]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1161 +[dm1386]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1386 +[dm1414]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1414 +[dm1430]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1430 +[dm1435]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1435 +[dm1437]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1437 +[dm1457]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1457 +[dm1736]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1736 +[dm1749]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1749 +[dm1767]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1767 +[dm2013]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2013 +[dm2046]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2046 +[dm2052]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2052 +[dm2080]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2080 +[dm2081]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2081 +[dm2089]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2089 +[dm2099]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2099 +[dm2443]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2443 +[dm2529]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2529 +[dm2610]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2610 +[dm2855]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2855 +[dm2889]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2889 +[dm2900]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2900 +[dm2942]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2942 +[dm2987]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2987 +[dm2995]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2995 +[dm3014]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n3014 +[dm3022]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n3022 +[dm3116]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n3116 +[dm3123]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n3123 +[dm3125]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n3125 +[dm3128]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n3128 +[dm3804]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n3804 +[dm3816]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n3816 +[dm620]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n620 +[dm626]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n626 +[dm645]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n645 +[dm997]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n997 +[dmdocs]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/?h=v7.3 +[dmh173]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n173 +[dmh185]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n185 +[dmh198]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n198 +[dmh215]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n215 +[dmh234]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n234 +[dmh254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n254 +[dmh29]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n29 +[dmh312]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n312 +[dmh331]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n331 +[dmh358]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n358 +[dmh63]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n63 +[dmh710]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/device-mapper.h?h=v7.3#n710 +[dmt1129]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1129 +[dmt1505]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1505 +[dmt1565]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1565 +[dmt1570]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1570 +[dmt1573]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1573 +[dmt1577]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1577 +[dmt195]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n195 +[dmt2155]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n2155 +[dmt2179]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n2179 +[dmt30]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n30 +[dmt388]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n388 +[dmt670]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n670 +[dmt688]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n688 +[dmt703]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n703 +[dmt711]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n711 +[dmt717]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n717 +[dmt738]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n738 +[dmt743]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n743 +[dmt749]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n749 +[dmt754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n754 +[dmt925]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n925 +[dmt965]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n965 +[dmt970]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n970 +[ioc1274]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1274 +[ioc1280]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1280 +[ioc1284]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1284 +[ioc1311]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1311 +[ioc1331]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1331 +[ioc1363]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1363 +[ioc1617]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1617 +[ioc1639]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1639 +[ioc1649]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1649 +[ioc1666]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1666 +[ioc1687]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1687 +[ioc1702]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1702 +[ioc1985]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1985 +[ioc2034]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n2034 +[ioc2299]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n2299 +[ioc977]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n977 +[ioh293]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/dm-ioctl.h?h=v7.3#n293 +[lin202]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.3#n202 +[lin28]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.3#n28 +[lin3]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.3#n3 +[lin61]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.3#n61 +[lin82]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.3#n82 +[lin96]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-linear.c?h=v7.3#n96 +[linearrst28]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/linear.rst?h=v7.3#n28 [lwn12734]: https://lwn.net/Articles/12734/ [lwn215058]: https://lwn.net/Articles/215058/ [lwn274292]: https://lwn.net/Articles/274292/ [lwn298882]: https://lwn.net/Articles/298882/ [lwn301919]: https://lwn.net/Articles/301919/ [lwn540996]: https://lwn.net/Articles/540996/ -[mpath1161]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.4-rc5#n1161 -[mpath2299]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.4-rc5#n2299 -[mpath240]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.4-rc5#n240 -[pol21]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy.h?h=v7.4-rc5#n21 -[pol60]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy.h?h=v7.4-rc5#n60 -[rq412]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-rq.c?h=v7.4-rc5#n412 -[smq1858]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.4-rc5#n1858 -[smq1885]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.4-rc5#n1885 -[smq1909]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.4-rc5#n1909 -[tgt18]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.4-rc5#n18 -[tgt46]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.4-rc5#n46 -[tgt51]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.4-rc5#n51 -[thin1004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1004 -[thin1009]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1009 -[thin1335]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1335 -[thin1338]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1338 -[thin1396]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1396 -[thin1415]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1415 -[thin1449]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1449 -[thin1473]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1473 -[thin1487]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1487 -[thin1490]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1490 -[thin1494]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1494 -[thin1501]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1501 -[thin1530]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1530 -[thin1545]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1545 -[thin1553]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1553 -[thin1600]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1600 -[thin1603]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1603 -[thin1614]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1614 -[thin1800]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1800 -[thin1888]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1888 -[thin1931]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1931 -[thin1934]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1934 -[thin1978]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n1978 -[thin203]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n203 -[thin2033]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2033 -[thin207]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n207 -[thin2110]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2110 -[thin2387]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2387 -[thin2403]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2403 -[thin2449]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2449 -[thin2551]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2551 -[thin2563]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2563 -[thin2583]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2583 -[thin2597]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2597 -[thin2605]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2605 -[thin2612]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2612 -[thin2646]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2646 -[thin2657]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2657 -[thin2722]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2722 -[thin2734]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2734 -[thin2740]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2740 -[thin2745]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2745 -[thin2754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2754 -[thin2755]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2755 -[thin2765]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2765 -[thin2767]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2767 -[thin2784]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2784 -[thin2797]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2797 -[thin2864]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2864 -[thin2904]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n2904 -[thin3178]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3178 -[thin3274]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3274 -[thin33]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n33 -[thin3345]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3345 -[thin34]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n34 -[thin3450]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3450 -[thin3537]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3537 -[thin3855]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n3855 -[thin41]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n41 -[thin4109]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4109 -[thin4111]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4111 -[thin4172]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4172 -[thin4326]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4326 -[thin4493]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4493 -[thin4495]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4495 -[thin4553]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n4553 -[thin735]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n735 -[thin756]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n756 -[thin9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n9 -[thin964]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.4-rc5#n964 -[thinrst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5 -[thinrst104]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5#n104 -[thinrst165]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5#n165 -[thinrst186]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5#n186 -[thinrst192]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.4-rc5#n192 -[tm1174]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1174 -[tm1205]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1205 -[tm1218]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1218 -[tm1500]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1500 -[tm1521]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1521 -[tm1651]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n1651 -[tm20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n20 -[tm68]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.4-rc5#n68 +[mdh41]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.h?h=v7.3#n41 +[mpath1159]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.3#n1159 +[mpath2300]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.3#n2300 +[mpath240]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-mpath.c?h=v7.3#n240 +[pol21]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy.h?h=v7.3#n21 +[pol60]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy.h?h=v7.3#n60 +[rq412]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-rq.c?h=v7.3#n412 +[smq1858]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.3#n1858 +[smq1885]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.3#n1885 +[smq1909]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.3#n1909 +[tgt18]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.3#n18 +[tgt46]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.3#n46 +[tgt51]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-target.c?h=v7.3#n51 +[thin1004]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1004 +[thin1009]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1009 +[thin1335]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1335 +[thin1338]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1338 +[thin1396]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1396 +[thin1415]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1415 +[thin1449]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1449 +[thin1473]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1473 +[thin1487]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1487 +[thin1490]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1490 +[thin1494]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1494 +[thin1501]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1501 +[thin1530]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1530 +[thin1545]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1545 +[thin1553]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1553 +[thin1600]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1600 +[thin1603]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1603 +[thin1614]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1614 +[thin1799]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1799 +[thin1887]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1887 +[thin1930]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1930 +[thin1933]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1933 +[thin1977]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1977 +[thin203]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n203 +[thin2032]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2032 +[thin207]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n207 +[thin2109]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2109 +[thin2386]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2386 +[thin2402]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2402 +[thin2448]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2448 +[thin2548]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2548 +[thin2560]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2560 +[thin2580]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2580 +[thin2594]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2594 +[thin2602]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2602 +[thin2609]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2609 +[thin2643]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2643 +[thin2654]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2654 +[thin2719]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2719 +[thin2731]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2731 +[thin2737]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2737 +[thin2742]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2742 +[thin2751]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2751 +[thin2752]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2752 +[thin2762]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2762 +[thin2764]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2764 +[thin2781]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2781 +[thin2794]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2794 +[thin2861]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2861 +[thin2901]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2901 +[thin3175]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3175 +[thin3271]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3271 +[thin33]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n33 +[thin3342]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3342 +[thin34]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n34 +[thin3450]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3450 +[thin3537]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3537 +[thin3855]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3855 +[thin41]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n41 +[thin4109]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4109 +[thin4111]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4111 +[thin4172]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4172 +[thin4326]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4326 +[thin4493]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4493 +[thin4495]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4495 +[thin4553]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4553 +[thin735]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n735 +[thin756]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n756 +[thin9]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n9 +[thin964]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n964 +[thinrst]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.3 +[thinrst104]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.3#n104 +[thinrst165]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.3#n165 +[thinrst186]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.3#n186 +[thinrst192]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/device-mapper/thin-provisioning.rst?h=v7.3#n192 +[tm1174]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n1174 +[tm1205]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n1205 +[tm1218]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n1218 +[tm1497]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n1497 +[tm1518]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n1518 +[tm1648]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n1648 +[tm20]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n20 +[tm68]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n68 [c0fbb4d93b38b]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0fbb4d93b38bce1f8235aacfa37e90ad8f011473 [c1da177e4c3f4]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 [c3241b1d3e0aa]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3241b1d3e0aaafbfcd320f4d71ade629728cc4f4 From d8c0149a30705f9dcd7e152c49bcb1737859b0ca Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Sun, 29 Nov 2026 20:28:11 -0800 Subject: [PATCH 06/20] block: link the kernel version on the device-mapper page to its tag Link "Linux v7.3" in the source note to the v7.3 tree on git.kernel.org. --- docs/block/device-mapper.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index c395197b..5790a44f 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -2,7 +2,7 @@ > How the kernel builds a virtual block device from a table of ranges, and what the linear, thin-provisioning and cache targets do with it -Source links point at Linux v7.3, the tree this page was checked against. Release numbers are mainline releases. Dates are author dates for commits and the dates shown on the page for LWN postings. +Source links point at [Linux v7.3][v73], the tree this page was checked against. Release numbers are mainline releases. Dates are author dates for commits and the dates shown on the page for LWN postings. **Find your way** @@ -843,3 +843,4 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [ccec47e3d4a86]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cec47e3d4a861e1d942b3a580d0bbef2700d2bb2 [ce5863d9ad754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5863d9ad754926e7d3f38b43ac8bd48ef73b097 [ce6ee8c0b7675]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e6ee8c0b767540f59e20da3ced282601db8aa502 +[v73]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/?h=v7.3 From 9ea0b3e5cdcb0e74542159d1ae8eba35a1dd93f5 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Sun, 29 Nov 2026 22:31:14 -0800 Subject: [PATCH 07/20] block: tighten scope of device-mapper page claims Name the conditions under which a cache miss starts a migration, which thin pool modes use the read-only handlers, and where the swap keeps the existing queue limits. Cite the zero-fill path for reads of unmapped thin blocks and describe the 13- and 8-patch LWN postings by their counts. --- docs/block/device-mapper.md | 40 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 5790a44f..73d6c824 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -128,7 +128,7 @@ flowchart LR !!! note "What happens to bios during a suspend (bio-based)" While `DMF_BLOCK_IO_FOR_SUSPEND` is set, `dm_submit_bio()` queues ordinary bios on a list. A `REQ_NOWAIT` bio fails with `bio_wouldblock_error()` and a read-ahead bio fails with `bio_io_error()` ([dm.c:2089-2097][dm2089]). A request-based device stops its request queue instead ([dm.c:3022-3025][dm3022]), and the deferred requests wait in that queue ([dm.c:3128][dm3128]). -**Swap.** `dm_swap_table()` refuses to run unless the device is suspended ([dm.c:2889][dm2889]). Unless it keeps the existing limits (a table with no data devices, or a noflush suspend of an immutable request-based device), it computes the queue limits for the new table ([dm.c:2900-2918][dm2900]); `__bind()` then publishes the table with `rcu_assign_pointer()` and waits for readers of the old one ([dm.c:2529-2534][dm2529]). +**Swap.** `dm_swap_table()` refuses to run unless the device is suspended ([dm.c:2889][dm2889]). Unless it keeps the existing limits (a table with no data devices while a live table exists, or a noflush suspend of an immutable request-based device), it computes the queue limits for the new table ([dm.c:2900-2918][dm2900]); `__bind()` then publishes the table with `rcu_assign_pointer()` and waits for readers of the old one ([dm.c:2529-2534][dm2529]). **Resume.** `__dm_resume()` resumes the targets ([dm.c:3116-3121][dm3116]), restarts the queued bios, and unlocks the filesystem ([dm.c:3123-3133][dm3123]). The comment gives the order's reason: "Flushing deferred I/Os must be done after targets are resumed so that mapping of targets can work correctly" ([dm.c:3125-3128][dm3125]). `dm_wq_work()` replays the queue with `submit_bio_noacct()` ([dm.c:2855-2865][dm2855]). @@ -178,7 +178,7 @@ A bio reaches the device through `dm_submit_bio()`, which takes the live table u ├─ DM_MAPIO_REMAPPED ───┐ core submits the clone to the lower device ├─ DM_MAPIO_SUBMITTED ──┤ target owns the clone │ ▼ - │ (lower device completes the clone) + │ (the clone completes, on the lower device or in the target) │ │ │ ▼ │ clone_endio ──► target->end_io (optional) @@ -213,7 +213,7 @@ What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], va | Return value | Core's action | |---|---| | `DM_MAPIO_REMAPPED` | Submits the clone to the device the target set, with `dm_submit_bio_remap()` | -| `DM_MAPIO_SUBMITTED` | Does nothing more; the target owns the clone and will complete or submit it | +| `DM_MAPIO_SUBMITTED` | The core submits nothing; the target owns the clone and will complete or submit it (the core starts I/O accounting unless the target set `accounts_remapped_io`, [dm.c:1438-1442][dm1438]) | | `DM_MAPIO_REQUEUE` | Frees the clone and records `BLK_STS_DM_REQUEUE` as the I/O's status | | `DM_MAPIO_KILL` | Frees the clone and records `BLK_STS_IOERR` as the I/O's status | @@ -300,7 +300,7 @@ Thin provisioning uses two target types ([dm-thin.c:4109-4110][thin4109], [dm-th | | `thin-pool` | `thin` | |---|---|---| | Role | Owns the storage: a metadata device and a data device split into blocks | One virtual device carved out of a pool | -| Table line | ` ` and optional features ([dm-thin.c:3271-3281][thin3271]) | ` [origin_dev]` ([dm-thin.c:4170-4172][thin4172]) | +| Table line | ` ` and optional features ([dm-thin.c:3271-3281][thin3271]) | ` [origin_dev]` ([dm-thin.c:4172][thin4172]) | | Features | Singleton, always writeable, immutable, passes crypto ([dm-thin.c:4111-4112][thin4111]) | Passes crypto ([dm-thin.c:4495][thin4495]) | !!! example "Creating a pool, a thin device and a snapshot, from the kernel documentation" @@ -348,7 +348,7 @@ flowchart TD C -- "shared, not mapped,
or lookup would block" --> W W -- "discard" --> X["process_discard"] W -- "other bios" --> D{"block state"} - D -- "mapped, not shared" --> R + D -- "mapped, not shared" --> R2["remap_and_issue() from the worker
(thin_bio_map() already
returned DM_MAPIO_SUBMITTED)"] D -- "shared, write" --> S["break_sharing:
allocate a block,
copy unless whole-block write"] D -- "shared, read" --> RR["remap to the shared block"] D -- "not mapped, read" --> Z["zero-fill, or read
from the external origin"] @@ -365,9 +365,9 @@ A bio can also be held in the cell because another bio already holds it ([dm-thi The anchors for the diagram: -- Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). +- Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). - A write to a shared block breaks the sharing; a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device, or, for a thin device with an external origin, read from the origin ([dm-thin.c:1977-1992][thin1977]). A write allocates a data block ([dm-thin.c:1930][thin1930]), then copies from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that a block past the end of the origin is zeroed instead ([dm-thin.c:1415-1426][thin1415]) and the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional read-only `origin_dev` in the table line), read from the origin ([dm-thin.c:1977-1992][thin1977]). A write allocates a data block ([dm-thin.c:1930][thin1930]), then copies from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that a block past the end of the origin is zeroed instead ([dm-thin.c:1415-1426][thin1415]) and the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk @@ -456,12 +456,12 @@ What each mode does with a bio: | Mode | Source comment | Behaviour | |---|---|---| | `PM_WRITE` | metadata may be changed | Served normally | -| `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only bio path ([dm-thin.c:2602-2605][thin2602]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | +| `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only handlers for bios and cells; discards and prepared mappings keep their write-mode handlers ([dm-thin.c:2602-2607][thin2602]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | | `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2580-2587][thin2580]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | | `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write to a shared or unmapped block is unserviceable and fails ([dm-thin.c:2032-2063][thin2032]) | -| `PM_FAIL` | all I/O fails | Every bio fails ([dm-thin.c:2737-2740][thin2737]) | +| `PM_FAIL` | all I/O fails | Every bio fails, except that a thin device in requeue mode ends it with `BLK_STS_DM_REQUEUE` first ([dm-thin.c:2731-2740][thin2731]) | -When free data blocks drop to the low water mark the pool raises an event on the device once ([dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). +When free data blocks drop to the low water mark the pool raises an event on the device once, until the flag is cleared again on resume ([dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). !!! warning "Held bios can fail after a timeout" By default, bios held in `PM_OUT_OF_DATA_SPACE` wait at most 60 seconds: `no_space_timeout` is a module parameter and a value of 0 arms no timer ([dm-thin.c:34][thin34], [dm-thin.c:4553][thin4553], [dm-thin.c:2609-2610][thin2609]). When it expires with the pool still out of data space, the pool sets `error_if_no_space` and fails the queued bios with `BLK_STS_NOSPC` ([dm-thin.c:2448-2457][thin2448]). @@ -472,7 +472,7 @@ The `cache` target puts a fast device in front of a slow one. Its table line is ### Three I/O modes -A block that is already dirty, for example from writeback mode, is still written to the cache only ([dm-cache-target.c:1745-1750][cache1745]); only passthrough requires all blocks to be clean before it can be entered ([dm-cache-target.c:2835-2839][cache2835]). The comments are at [dm-cache-target.c:254-274][cache254]; the arguments that select the mode are parsed at [dm-cache-target.c:2210-2223][cache2210], and writeback is the default ([dm-cache-target.c:2184][cache2184]). +In writethrough mode, a write hit on a block that is already dirty, for example one left by an earlier writeback mode, is written to the cache only ([dm-cache-target.c:1745-1750][cache1745]); only passthrough requires all blocks to be clean before it can be entered ([dm-cache-target.c:2835-2839][cache2835]). The table below summarises the mode comments at [dm-cache-target.c:254-274][cache254]; the arguments that select the mode are parsed at [dm-cache-target.c:2210-2223][cache2210], and writeback is the default ([dm-cache-target.c:2184][cache2184]). | Mode | Where a hit goes | Can the cache hold data newer than the origin? | What the source comment says | |---|---|---|---| @@ -495,7 +495,7 @@ flowchart TD C -- yes --> W["worker"] C -- no --> D{"policy lookup"} D -- miss --> O2["origin"] - D -- "miss, and the policy
returns a promotion" --> MG["start a migration
with this bio"] + D -- "miss, whole-block write
or discarded block, and the
policy returns a promotion" --> MG["start a migration
with this bio"] D -- hit --> E{"mode"} E -- "writeback" --> CA["cache"] E -- "writethrough" --> F{"write to a
clean block?"} @@ -506,13 +506,13 @@ flowchart TD G -- no --> O3["origin"] ``` -- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1715-1718][cache1715]). In writeback mode, when the policy returns a promotion for the block, a migration is started with the bio instead ([dm-cache-target.c:1690-1695][cache1690]). +- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1715-1718][cache1715]), unless it is a duplicate writethrough bio for a block that has been demoted, which is ended ([dm-cache-target.c:1719-1725][cache1719]). In writeback mode, when the bio is for a discarded block or writes a whole block and the policy returns a promotion, a migration is started with the bio instead ([dm-cache-target.c:1690-1695][cache1690]). - **Hit:** as in the table above ([dm-cache-target.c:1737-1750][cache1737]). - **FUA:** the bio is issued after the metadata commit ([dm-cache-target.c:1757-1765][cache1757]). ### The policy decides what moves -The core does not decide what to cache. A policy plug-in is asked about each bio, and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). +The core does not decide what to cache. A policy plug-in is asked about each bio that reaches the lookup (bios past the last whole origin block, discards and flushes take other paths), and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). ```mermaid flowchart TD @@ -528,12 +528,12 @@ flowchart TD H --> K["complete: clear the dirty bit where the code does,
tell the policy, unlock the block, replay held bios"] I --> K J --> K - A -- "writeback mode, and the bio is for a discarded block
or covers a whole block: the policy returns a promotion at once" --> D2["mg_start with the bio:
lock reads and writes"] + A -- "writeback mode, and the bio is for a discarded block
or writes a whole block: the policy returns a promotion at once" --> D2["mg_start with the bio:
lock reads and writes"] D2 --> E2["overwrite(): write the bio
into the cache block"] E2 --> H ``` -The anchors: the worker is woken from `map_bio()` when the policy queues work ([dm-cache-target.c:1705-1706][cache1705]), and also by the periodic waker ([dm-cache-target.c:1910][cache1910]); it asks the policy for work in `check_migrations()` ([dm-cache-target.c:1915-1940][cache1915]); `mg_lock_writes()` blocks writes and lets reads continue, and locks reads and writes when the migration carries the bio itself, the bottom branch ([dm-cache-target.c:1409-1417][cache1409], [dm-cache-target.c:1690-1694][cache1690]), which uses `overwrite()` in place of the copy and the lock upgrade ([dm-cache-target.c:1391-1394][cache1391]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1354-1358][cache1354]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1331-1335][cache1331]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1251-1302][cache1251], [dm-cache-target.c:1292-1297][cache1292]); `mg_complete()` clears the dirty bit for a promotion without a bio, a demotion and a writeback, sets it for a promotion that carries a bio and ends that bio, tells the policy and replays the bios that waited ([dm-cache-target.c:1186-1234][cache1186], [dm-cache-target.c:1191-1198][cache1191]). +The anchors: the worker is woken from `map_bio()` when the policy queues work ([dm-cache-target.c:1705-1706][cache1705]), and also by the periodic waker ([dm-cache-target.c:1910][cache1910]); it asks the policy for work in `check_migrations()` ([dm-cache-target.c:1915-1940][cache1915]); `mg_lock_writes()` blocks writes and lets reads continue, and locks reads and writes when the migration carries the bio itself, the bottom branch ([dm-cache-target.c:1409-1417][cache1409], [dm-cache-target.c:1690-1694][cache1690]), which uses `overwrite()` in place of the copy and the lock upgrade ([dm-cache-target.c:1391-1394][cache1391]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1354-1358][cache1354]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1331-1335][cache1331]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1251-1302][cache1251], [dm-cache-target.c:1292-1297][cache1292]); `mg_complete()` on success clears the dirty bit for a promotion without a bio, a demotion and a writeback, sets it for a promotion that carries a bio and ends that bio, tells the policy and replays the bios that waited ([dm-cache-target.c:1186-1234][cache1186], [dm-cache-target.c:1191-1198][cache1191]). The tree registers four policy names: `smq`, `mq`, `cleaner` and `default` ([dm-cache-policy-smq.c:1885-1939][smq1885]). The first three are created by the same function, `__smq_create()`, with different flag arguments ([dm-cache-policy-smq.c:1858-1880][smq1858]); `default` points at the `smq` type through `.real` ([dm-cache-policy-smq.c:1909-1914][smq1909]). @@ -562,11 +562,11 @@ timeline | 2.6.12 (tag `v2.6.12-rc2`, 2005-04-16, the first commit in the git history) | `dm-linear.c` and `dm-ioctl.c` already exist; `dm-linear.c` carries "Copyright (C) 2001-2003 Sistina Software (UK) Limited." ([dm-linear.c:3][lin3]) | [`1da177e4c3f4`][c1da177e4c3f4] | | 2006-12-19 | RFC for request-based DM: "Hook for I/O mapping is at request_fn after merging and sorting by I/O scheduler, instead of make_request_fn." | [LWN: rqbased-dm][lwn215058] | | 2008-03-19 | The series is reposted for discussion: "Currently, device-mapper (dm) is implemented as a stacking block device at bio level." | [LWN: request stacking and request-based dm-multipath][lwn274292] | -| 2008-09-12, 2008-10-03 | Version 2 (13 patches) and version 3 (8 patches) | [LWN v2][lwn298882], [LWN v3][lwn301919] | +| 2008-09-12, 2008-10-03 | Later postings of the series: 13 patches, then 8 patches | [LWN 13 patches][lwn298882], [LWN 8 patches][lwn301919] | | 2.6.31 (2009-06-22) | Request-based DM is prepared and enabled | [`cec47e3d4a86`][ccec47e3d4a86], [`e6ee8c0b7675`][ce6ee8c0b7675] | | 3.2 (2011-10-31) | Persistent-data library, then thin provisioning | [`3241b1d3e0aa`][c3241b1d3e0aa], [`991d9fa02da0`][c991d9fa02da0] | | 3.9 (2013-03-01) | `cache` target; the documentation was posted on LWN on 2013-03-04 | [`c6b4fcbad044`][cc6b4fcbad044], [LWN: cache.txt][lwn540996] | -| 4.0 (2014-12-17) | Requests are allocated in the target when stacking on blk-mq devices; the commit that follows calls this "the first step toward fully utilizing blk-mq in request-based DM" | [`e5863d9ad754`][ce5863d9ad754] | +| 4.0 (2014-12-17) | Requests are allocated in the target when stacking on blk-mq devices; a later commit, `bfebd1cdb497` in 4.1 (next row), calls this "the first step toward fully utilizing blk-mq in request-based DM" | [`e5863d9ad754`][ce5863d9ad754] | | 4.1 (2015-03-08) | The mapped device's own queue becomes blk-mq: "enables stacking a blk-mq request_queue ontop of the underlying blk-mq device(s)" | [`bfebd1cdb497`][cbfebd1cdb497] | | 4.12 (2016-10-21) | Bio prison v2 | [`742c8fdc31e8`][c742c8fdc31e8] | | 5.18 (2022-02-17) | `dm_submit_bio_remap()` lets a target that submits clones itself have them accounted when it submits them, if it sets `accounts_remapped_io` | [`0fbb4d93b38b`][c0fbb4d93b38b] | @@ -603,6 +603,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [cache1679]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1679 [cache1690]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1690 [cache1705]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1705 +[cache1719]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1719 [cache1715]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1715 [cache1737]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1737 [cache1745]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1745 @@ -653,6 +654,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [dm2529]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2529 [dm2610]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2610 [dm2855]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2855 +[dm1438]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1438 [dm2889]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2889 [dm2900]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2900 [dm2942]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2942 @@ -769,6 +771,7 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin1614]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1614 [thin1799]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1799 [thin1887]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1887 +[thin1923]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1923 [thin1930]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1930 [thin1933]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1933 [thin1977]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1977 @@ -789,7 +792,6 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin2654]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2654 [thin2719]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2719 [thin2731]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2731 -[thin2737]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2737 [thin2742]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2742 [thin2751]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2751 [thin2752]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2752 From 02c88d309f87233e9e264a5b0f291bb93a1207a8 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Sun, 29 Nov 2026 22:34:09 -0800 Subject: [PATCH 08/20] block: cite and scope remaining device-mapper claims --- docs/block/device-mapper.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 73d6c824..ce89ef26 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -367,7 +367,7 @@ The anchors for the diagram: - Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). - A write to a shared block breaks the sharing; a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional read-only `origin_dev` in the table line), read from the origin ([dm-thin.c:1977-1992][thin1977]). A write allocates a data block ([dm-thin.c:1930][thin1930]), then copies from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that a block past the end of the origin is zeroed instead ([dm-thin.c:1415-1426][thin1415]) and the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin ([dm-thin.c:1977-1992][thin1977]). A write allocates a data block ([dm-thin.c:1930][thin1930]), then copies from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that a block past the end of the origin is zeroed instead ([dm-thin.c:1415-1426][thin1415]) and the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk @@ -459,9 +459,9 @@ What each mode does with a bio: | `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only handlers for bios and cells; discards and prepared mappings keep their write-mode handlers ([dm-thin.c:2602-2607][thin2602]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | | `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2580-2587][thin2580]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | | `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write to a shared or unmapped block is unserviceable and fails ([dm-thin.c:2032-2063][thin2032]) | -| `PM_FAIL` | all I/O fails | Every bio fails, except that a thin device in requeue mode ends it with `BLK_STS_DM_REQUEUE` first ([dm-thin.c:2731-2740][thin2731]) | +| `PM_FAIL` | all I/O fails | Every bio fails, except that a thin device in requeue mode ends it with `BLK_STS_DM_REQUEUE` instead ([dm-thin.c:2731-2740][thin2731]) | -When free data blocks drop to the low water mark the pool raises an event on the device once, until the flag is cleared again on resume ([dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). +When free data blocks drop to the low water mark the pool raises an event on the device once, until the flag is cleared again on resume ([dm-thin.c:3636][thin3636]; set at [dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). !!! warning "Held bios can fail after a timeout" By default, bios held in `PM_OUT_OF_DATA_SPACE` wait at most 60 seconds: `no_space_timeout` is a module parameter and a value of 0 arms no timer ([dm-thin.c:34][thin34], [dm-thin.c:4553][thin4553], [dm-thin.c:2609-2610][thin2609]). When it expires with the pool still out of data space, the pool sets `error_if_no_space` and fails the queued bios with `BLK_STS_NOSPC` ([dm-thin.c:2448-2457][thin2448]). @@ -495,7 +495,7 @@ flowchart TD C -- yes --> W["worker"] C -- no --> D{"policy lookup"} D -- miss --> O2["origin"] - D -- "miss, whole-block write
or discarded block, and the
policy returns a promotion" --> MG["start a migration
with this bio"] + D -- "writeback mode, miss, whole-block
write or discarded block, and the
policy returns a promotion" --> MG["start a migration
with this bio"] D -- hit --> E{"mode"} E -- "writeback" --> CA["cache"] E -- "writethrough" --> F{"write to a
clean block?"} @@ -512,7 +512,7 @@ flowchart TD ### The policy decides what moves -The core does not decide what to cache. A policy plug-in is asked about each bio that reaches the lookup (bios past the last whole origin block, discards and flushes take other paths), and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). +The core does not decide what to cache. A policy plug-in is asked about each bio that reaches the lookup (bios past the last whole origin block, discards and flushes take other paths, [dm-cache-target.c:2676-2690][cache2676]), and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). ```mermaid flowchart TD @@ -533,7 +533,7 @@ flowchart TD E2 --> H ``` -The anchors: the worker is woken from `map_bio()` when the policy queues work ([dm-cache-target.c:1705-1706][cache1705]), and also by the periodic waker ([dm-cache-target.c:1910][cache1910]); it asks the policy for work in `check_migrations()` ([dm-cache-target.c:1915-1940][cache1915]); `mg_lock_writes()` blocks writes and lets reads continue, and locks reads and writes when the migration carries the bio itself, the bottom branch ([dm-cache-target.c:1409-1417][cache1409], [dm-cache-target.c:1690-1694][cache1690]), which uses `overwrite()` in place of the copy and the lock upgrade ([dm-cache-target.c:1391-1394][cache1391]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1354-1358][cache1354]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1331-1335][cache1331]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1251-1302][cache1251], [dm-cache-target.c:1292-1297][cache1292]); `mg_complete()` on success clears the dirty bit for a promotion without a bio, a demotion and a writeback, sets it for a promotion that carries a bio and ends that bio, tells the policy and replays the bios that waited ([dm-cache-target.c:1186-1234][cache1186], [dm-cache-target.c:1191-1198][cache1191]). +The anchors: the worker is woken from `map_bio()` when the policy queues work ([dm-cache-target.c:1705-1706][cache1705]), and also by the periodic waker ([dm-cache-target.c:1910][cache1910]); it asks the policy for work in `check_migrations()` ([dm-cache-target.c:1915-1940][cache1915]); `mg_lock_writes()` blocks writes and lets reads continue, and locks reads and writes when the migration carries the bio itself, the bottom branch ([dm-cache-target.c:1409-1417][cache1409], [dm-cache-target.c:1690-1694][cache1690]), which uses `overwrite()` in place of the copy and the lock upgrade ([dm-cache-target.c:1391-1394][cache1391]); `mg_full_copy()` skips the copy in the cases shown ([dm-cache-target.c:1354-1358][cache1354]); `mg_upgrade_lock()` blocks reads and writes ([dm-cache-target.c:1331-1335][cache1331]); `mg_update_metadata()` does the per-operation step, and a demotion commits ([dm-cache-target.c:1251-1302][cache1251], [dm-cache-target.c:1292-1297][cache1292]); `mg_complete()` clears the dirty bit on success for a promotion without a bio, a demotion and a writeback, sets it on success for a promotion that carries a bio, ends that bio, tells the policy and replays the bios that waited ([dm-cache-target.c:1186-1234][cache1186], [dm-cache-target.c:1191-1198][cache1191]). The tree registers four policy names: `smq`, `mq`, `cleaner` and `default` ([dm-cache-policy-smq.c:1885-1939][smq1885]). The first three are created by the same function, `__smq_create()`, with different flag arguments ([dm-cache-policy-smq.c:1858-1880][smq1858]); `default` points at the `smq` type through `.real` ([dm-cache-policy-smq.c:1909-1914][smq1909]). @@ -771,6 +771,9 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [thin1614]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1614 [thin1799]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1799 [thin1887]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1887 +[thin3636]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3636 +[thin4216]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4216 +[cache2676]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2676 [thin1923]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1923 [thin1930]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1930 [thin1933]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1933 From f4b54f4b5decaaadffc0ef032516842910f6e770 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 00:38:51 -0800 Subject: [PATCH 09/20] block: link the original dm-devel postings for the history rows --- docs/block/device-mapper.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index ce89ef26..87048411 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -572,7 +572,14 @@ timeline | 5.18 (2022-02-17) | `dm_submit_bio_remap()` lets a target that submits clones itself have them accounted when it submits them, if it sets `accounts_remapped_io` | [`0fbb4d93b38b`][c0fbb4d93b38b] | | 5.19 (2022-04-12) | Reworked bio splitting and I/O accounting | [`7dd76d1feec7`][c7dd76d1feec7] | -The original list postings for the thin-provisioning (2011) and cache (2013) commits, and for the 2022 `dm_submit_bio_remap()` and bio-splitting patches, are not linked: those commits carry no `Link:` trailer. +The commits for these four changes carry no `Link:` trailer, so each posting below was found in the dm-devel archive by subject and checked against the commit message. Where the commit message was revised after posting, the table says so. Dates are the archive's message dates. + +| Change | Posting on dm-devel | Relation to the commit | +|---|---|---| +| Thin provisioning and persistent data (3.2) | 2011-07-08, "[PATCH 0/3] initial release of dm thin provisioning target" ([cover][lore-thin0]), with the library as [2/3][lore-thin2] and the target as [3/3][lore-thin3] | Posted by Mike Snitzer; the body names Joe Thornber as the author; the commit message is a reworded form of the 3/3 text | +| Cache target (3.9) | 2012-12-13, "[PATCH 8/8] [dm-cache] cache target" ([8/8][lore-cache8]) | The first posting of the code; its message has no description, the commit message adds one | +| `dm_submit_bio_remap()` (5.18) | 2022-02-10, "[PATCH 10/14] dm: add dm_submit_bio_remap interface" ([v1][lore-remap1]); 2022-02-11, "[PATCH v2 11/14]" ([v2][lore-remap2]) | The commit message extends the v2 text (adds the `xchg` and `bio_endio` paragraphs) | +| Bio splitting and I/O accounting (5.19) | 2022-04-17, "[dm-5.19 PATCH 16/21] dm: improve bio splitting and associated IO accounting" ([16/21][lore-split16]) | The body names Ming Lei as the author; the commit message matches the posting | ## Further reading @@ -849,3 +856,10 @@ The original list postings for the thin-provisioning (2011) and cache (2013) com [ce5863d9ad754]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5863d9ad754926e7d3f38b43ac8bd48ef73b097 [ce6ee8c0b7675]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e6ee8c0b767540f59e20da3ced282601db8aa502 [v73]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/?h=v7.3 +[lore-thin0]: https://lore.kernel.org/dm-devel/1310163592-29683-1-git-send-email-snitzer@redhat.com/ +[lore-thin2]: https://lore.kernel.org/dm-devel/1310163592-29683-3-git-send-email-snitzer@redhat.com/ +[lore-thin3]: https://lore.kernel.org/dm-devel/1310163592-29683-4-git-send-email-snitzer@redhat.com/ +[lore-cache8]: https://lore.kernel.org/dm-devel/1355429956-22785-9-git-send-email-ejt@redhat.com/ +[lore-remap1]: https://lore.kernel.org/dm-devel/20220210223832.99412-11-snitzer@redhat.com/ +[lore-remap2]: https://lore.kernel.org/dm-devel/20220211214057.40612-12-snitzer@redhat.com/ +[lore-split16]: https://lore.kernel.org/dm-devel/20220418022733.56168-17-snitzer@kernel.org/ From 667c77d47287434a24cd96473f61fc5ebcb77bd4 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 10:11:13 -0800 Subject: [PATCH 10/20] block: scope device-mapper bio-path, thin and cache statements State that the bio-path steps are for normal I/O, that the thin bio diagram shows the PM_WRITE handlers, that empty flush bios are not provisioned, and which cache writes go to the cache only. Cover the straddling-origin and passthrough cases, the needs_check demotion and the CONFIG_BLK_INLINE_ENCRYPTION condition. --- docs/block/device-mapper.md | 48 ++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 87048411..c2c86505 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -84,7 +84,7 @@ flowchart LR TG["dm_target
begin, len
private"] TT["target_type
ctr, map, end_io, ..."] DD["dm_dev
bdev, mode"] - MD -- "map (__rcu pointer,
read under SRCU)" --> T + MD -- "map (__rcu pointer,
read under SRCU or RCU)" --> T T -- "one per range" --> TG TG -- "type" --> TT T -- "devices list
(via dm_dev_internal)" --> DD @@ -92,7 +92,7 @@ flowchart LR The `mapped_device` holds the table pointer, the disk and the list of bios that arrived during a suspend ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-318][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]); the table's list holds one `dm_dev_internal` per device, which has a reference count and a pointer to its `dm_dev` ([dm.h:41-45][mdh41], [dm-table.c:388-395][dmt388]). -The core keeps its own structures private. The header says that targets "must _not_ deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). +The core keeps its own structures private. The header says that targets "must `_not_` deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). ## The control interface @@ -110,7 +110,7 @@ The table also lists commands to remove and rename a device, to read device and A device with no live table fails the bios submitted to it: `dm_submit_bio()` calls `bio_io_error()` ([dm.c:2081-2085][dm2081]). -Loading a table does not change the live one. `table_load()` creates a table, adds every target to it with `populate_table()` ([dm-ioctl.c:1639-1645][ioc1639]), and stores it as the device's new, inactive map ([dm-ioctl.c:1687-1689][ioc1687]). A second load replaces a staged table that was never resumed ([dm-ioctl.c:1702-1705][ioc1702]). Completing a table decides its type, builds the sector index, builds the crypto profile and allocates the memory pools for clones ([`dm_table_complete()`][dmt1505]). +Loading a table does not change the live one. `table_load()` creates a table, adds every target to it with `populate_table()` ([dm-ioctl.c:1639-1645][ioc1639]), and stores it as the device's new, inactive map ([dm-ioctl.c:1687-1689][ioc1687]). A second load replaces a staged table that was never resumed ([dm-ioctl.c:1702-1705][ioc1702]). Completing a table decides its type, builds the sector index, builds the crypto profile (only when the kernel is built with `CONFIG_BLK_INLINE_ENCRYPTION`; otherwise [that step is a stub][dmt1481]) and allocates the memory pools for clones ([`dm_table_complete()`][dmt1505]). The swap happens on resume. When a table is staged, `do_resume()` suspends the device if it is not already suspended ([dm-ioctl.c:1284-1286][ioc1284]), calls `dm_swap_table()` ([dm-ioctl.c:1311][ioc1311]), and then resumes it ([dm-ioctl.c:1331-1333][ioc1331]). With no staged table it only resumes ([dm-ioctl.c:1274][ioc1274]). @@ -123,7 +123,7 @@ flowchart LR L --> S --> W --> R ``` -**Suspend.** `__dm_suspend()` calls the targets' `presuspend`. If the caller asked for a filesystem freeze and did not ask for no-flush, it then calls `lock_fs()`, which freezes the filesystem on the device ([dm.c:2942][dm2942]) and, per its comment, "flushes I/Os and waits for them to complete" ([dm.c:2987-3001][dm2987], condition at [dm.c:2995][dm2995]; the freeze is skipped when userspace passes `DM_SKIP_LOCKFS_FLAG`, [dm-ioctl.c:1280-1281][ioc1280]). It then sets `DMF_BLOCK_IO_FOR_SUSPEND`, waits with `synchronize_srcu()` for any thread still inside the map path, flushes the device's workqueue, and waits for in-flight I/O to finish ([dm.c:3014-3035][dm3014]). +**Suspend.** `__dm_suspend()` calls the targets' `presuspend`. If the caller asked for a filesystem freeze and did not ask for no-flush, it then calls `lock_fs()`, which freezes the filesystem on the device ([dm.c:2942][dm2942]) and, per its comment, "flushes I/Os and waits for them to complete" ([dm.c:2987-3001][dm2987], condition at [dm.c:2995][dm2995]; the freeze is skipped when userspace passes `DM_SKIP_LOCKFS_FLAG`, checked in the suspend path at [dm-ioctl.c:1224][ioc1224] and in the resume path, which also suspends for a table swap, at [dm-ioctl.c:1280-1281][ioc1280]). It then sets `DMF_BLOCK_IO_FOR_SUSPEND`, waits with `synchronize_srcu()` for any thread still inside the map path, flushes the device's workqueue, and waits for in-flight I/O to finish ([dm.c:3014-3035][dm3014]). !!! note "What happens to bios during a suspend (bio-based)" While `DMF_BLOCK_IO_FOR_SUSPEND` is set, `dm_submit_bio()` queues ordinary bios on a list. A `REQ_NOWAIT` bio fails with `bio_wouldblock_error()` and a read-ahead bio fails with `bio_io_error()` ([dm.c:2089-2097][dm2089]). A request-based device stops its request queue instead ([dm.c:3022-3025][dm3022]), and the deferred requests wait in that queue ([dm.c:3128][dm3128]). @@ -152,7 +152,7 @@ A larger table adds levels above the leaf; `dm_table_find_target()` walks all `t | Feature | Meaning | Where enforced | |---|---|---| -| `DM_TARGET_SINGLETON` | Must be the only target in a table | [dm-table.c:703-709][dmt703] | +| `DM_TARGET_SINGLETON` | Must be the only target in a table | [dm-table.c:703-709][dmt703] (a singleton added after another target), [dm-table.c:677-681][dmt677] (a target added after a singleton) | | `DM_TARGET_ALWAYS_WRITEABLE` | Not allowed in a read-only table | [dm-table.c:711-715][dmt711] | | `DM_TARGET_IMMUTABLE` | Cannot be mixed with other target types in one table | [dm-table.c:717-728][dmt717] | | `DM_TARGET_IMMUTABLE` | Once a device has it, a later table must use the same type, unless it contains a wildcard target | [dm-ioctl.c:1649-1657][ioc1649] | @@ -189,10 +189,12 @@ A bio reaches the device through `dm_submit_bio()`, which takes the live table u └─ KILL / REQUEUE ──► clone freed, status recorded on the I/O ``` +Steps 1 to 4 describe normal reads and writes. A discard, secure-erase or write-zeroes bio takes `__process_abnormal_io()` instead of the clone-and-map steps below ([dm.c:1740-1741][dm1740]), and a flush is sent through `__send_empty_flush()` (see "Flushes and discards" below). + 1. **Clone.** `__split_and_process_bio()` finds the target for the current sector ([dm.c:1736][dm1736]) and limits the length to the target's maximum I/O length and the sectors left ([dm.c:1749][dm1749]). `alloc_tio()` supplies the clone: the first one is embedded in the per-I/O structure `dm_io`, later ones come from `bio_alloc_clone()` ([dm.c:620-626][dm620]). The clone's default device is the mapped device itself, so the target must change it before the bio is issued ([dm.c:645-646][dm645]). 2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2046-2053][dm2046]). 3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). -4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The original bio completes when the count of outstanding clones reaches zero ([dm.c:1047-1055][dm1047]). +4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:588-589][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]). **A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2046-2053][dm2046]): @@ -220,7 +222,7 @@ What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], va !!! warning "`DM_MAPIO_DELAY_REQUEUE` is not a bio-based return value" The value is defined next to the others, but the switch in `__map_bio()` has no case for it and ends in `BUG()` ([dm.c:1457-1459][dm1457]). The request-based path handles it ([dm-rq.c:412][rq412]). -**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios` and `num_secure_erase_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then the flush with data goes straight to that device ([dm.c:2013-2034][dm2013]). +**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios` and `num_secure_erase_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then the flush with data is not split into an empty flush plus data; it is passed as one bio to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2025][dm2025]). ## Bio-based and request-based devices @@ -354,25 +356,25 @@ flowchart TD D -- "not mapped, read" --> Z["zero-fill, or read
from the external origin"] D -- "not mapped, write" --> P["allocate a data block"] P --> Q{"external
origin?"} - Q -- yes --> E["copy from the origin
(not for a whole-block write;
zeroed past the origin's end)"] + Q -- yes --> E["copy from the origin
(not for a whole-block write;
zeroed past the origin's end,
if zeroing is on)"] Q -- no --> F["zero the block unless the
write covers all of it"] S --> M["insert mapping
release held bios"] E --> M F --> M ``` -A bio can also be held in the cell because another bio already holds it ([dm-thin.c:2752-2753][thin2752]); the diagram leaves that case out. +The diagram shows the `PM_WRITE` handlers ([dm-thin.c:2613-2623][thin2613]). In `PM_OUT_OF_DATA_SPACE`, `PM_OUT_OF_METADATA_SPACE` and `PM_READ_ONLY` the pool uses read-only variants of `process_bio` and `process_cell`, and in the two read-only modes `process_discard` does nothing but complete the bio ([dm-thin.c:2583-2585][thin2583]); the modes are described below. Requeue mode and `PM_FAIL` also return early, before the lookup. A bio can also be held in the cell because another bio already holds it ([dm-thin.c:2752-2753][thin2752]); the diagram leaves that case out. The anchors for the diagram: - Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). -- A write to a shared block breaks the sharing; a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin ([dm-thin.c:1977-1992][thin1977]). A write allocates a data block ([dm-thin.c:1930][thin1930]), then copies from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that a block past the end of the origin is zeroed instead ([dm-thin.c:1415-1426][thin1415]) and the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A write to a shared block breaks the sharing (an empty flush bio does not: the condition is a write with data, [dm-thin.c:1887][thin1887]); a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block (an empty flush is remapped without provisioning, [dm-thin.c:1909-1918][thin1909]) ([dm-thin.c:1930][thin1930]), then copies from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]); the zeroing happens only when zeroing is turned on, and for the straddling block only if the copy is shorter than a block ([dm-thin.c:1356-1357][thin1356]); the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk -Changes to the mapping sit in an open metadata transaction until `commit()` calls `dm_pool_commit_metadata()` ([dm-thin.c:1490][thin1490]). A bio with a flush or FUA flag that arrives after its thin device has changed the transaction does not go straight down: `issue()` puts it on a list, and one commit serves all bios on the list ([dm-thin.c:735-738][thin735], [dm-thin.c:756-777][thin756]). The comment on a related path says why: "If the bio has the REQ_FUA flag set we must commit the metadata before signaling its completion" ([dm-thin.c:964-966][thin964]). +Changes to the mapping sit in an open metadata transaction until `commit()` calls `dm_pool_commit_metadata()` ([dm-thin.c:1490][thin1490]). A bio with a flush or FUA flag is checked when it is issued. If its thin device has changed the transaction by then, including a FUA write that itself provisioned a block, it does not go straight down: `issue()` puts it on a list, and one commit serves all bios on the list ([dm-thin.c:735-738][thin735], [dm-thin.c:756-777][thin756]). The comment on a related path says why: "If the bio has the REQ_FUA flag set we must commit the metadata before signaling its completion" ([dm-thin.c:964-966][thin964]). ```mermaid sequenceDiagram @@ -445,9 +447,9 @@ stateDiagram-v2 | → `PM_READ_ONLY` | A metadata operation failed: the transaction is aborted and the mode set ([dm-thin.c:2654-2660][thin2654]) | | → `PM_FAIL` | Aborting the transaction, or setting the `needs_check` flag, failed ([dm-thin.c:2643-2651][thin2643]) | | out of `PM_FAIL` | Never: "we never let the pool move out of the old mode" ([dm-thin.c:2560-2565][thin2560]) | -| to `PM_WRITE` when `needs_check` is set | Refused ([dm-thin.c:2548-2558][thin2548]) | +| to `PM_WRITE` when `needs_check` is set | Refused: from another mode the pool stays where it is, and a pool already in `PM_WRITE` is moved to `PM_READ_ONLY` ([dm-thin.c:2548-2558][thin2548]) | | `PM_OUT_OF_METADATA_SPACE` → `PM_WRITE` | The pool sets `PM_WRITE` when the metadata device is grown ([dm-thin.c:3537-3538][thin3537]); the source comment says the mode "may switch back to WRITE on metadata resize" ([dm-thin.c:207-209][thin207]) | -| Table reload | `bind_control_target()` sets the mode from the new table's features: `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument ([dm-thin.c:2861-2882][thin2861], [dm-thin.c:2901][thin2901], [dm-thin.c:3175-3176][thin3175]) | +| Table reload | For a newly loaded table, `bind_control_target()` asks for the mode in the new table's features, `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument, subject to the `needs_check` and `PM_FAIL` rules above ([dm-thin.c:2861-2882][thin2861], [dm-thin.c:2901][thin2901], [dm-thin.c:3175-3176][thin3175]) | The diagram shows representative edges. `metadata_operation_failed()` sets `PM_READ_ONLY` whatever the current mode, except that `PM_FAIL` is never left ([dm-thin.c:2654-2660][thin2654], [dm-thin.c:2560-2565][thin2560]), and `commit()` refuses to run only from `PM_OUT_OF_METADATA_SPACE` upward ([dm-thin.c:1487-1488][thin1487]), so a commit can also degrade the pool from `PM_OUT_OF_DATA_SPACE`. @@ -477,7 +479,7 @@ In writethrough mode, a write hit on a block that is already dirty, for example | Mode | Where a hit goes | Can the cache hold data newer than the origin? | What the source comment says | |---|---|---|---| | writeback | cache | ✓ | "Data is written to cached blocks only. These blocks are marked dirty. If you lose the cache device you will lose data." | -| writethrough | cache; a write to a clean block goes to both devices ([dm-cache-target.c:1745-1750][cache1745]) | ✗ for data written in this mode | "Data is written to both cache and origin. Blocks are never dirty." | +| writethrough | cache; a write to a clean block goes to both devices ([dm-cache-target.c:1745-1750][cache1745]) | ✗ for a write to a clean block; a write to an already-dirty block goes to the cache only ([dm-cache-target.c:1745-1750][cache1745]) | "Data is written to both cache and origin. Blocks are never dirty." | | passthrough | origin; a write also invalidates the cache block ([dm-cache-target.c:1737-1743][cache1737]) | ✗ | "Reads and writes always go to the origin. If a write goes to a cached oblock, then the cache block is invalidated." | !!! warning "Writeback loses data with the cache device" @@ -512,7 +514,7 @@ flowchart TD ### The policy decides what moves -The core does not decide what to cache. A policy plug-in is asked about each bio that reaches the lookup (bios past the last whole origin block, discards and flushes take other paths, [dm-cache-target.c:2676-2690][cache2676]), and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). +The core does not decide what to cache. A policy plug-in is asked about each bio that reaches the lookup (bios past the last whole origin block, discards and flushes take other paths, [dm-cache-target.c:2676-2690][cache2676]), and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). In passthrough mode the target tells the policy that migrations are not allowed ([dm-cache-target.c:2508-2509][cache2508]), and the `smq` policy then queues no promotions ([dm-cache-policy-smq.c:1254-1255][smq1254]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). ```mermaid flowchart TD @@ -567,7 +569,7 @@ timeline | 3.2 (2011-10-31) | Persistent-data library, then thin provisioning | [`3241b1d3e0aa`][c3241b1d3e0aa], [`991d9fa02da0`][c991d9fa02da0] | | 3.9 (2013-03-01) | `cache` target; the documentation was posted on LWN on 2013-03-04 | [`c6b4fcbad044`][cc6b4fcbad044], [LWN: cache.txt][lwn540996] | | 4.0 (2014-12-17) | Requests are allocated in the target when stacking on blk-mq devices; a later commit, `bfebd1cdb497` in 4.1 (next row), calls this "the first step toward fully utilizing blk-mq in request-based DM" | [`e5863d9ad754`][ce5863d9ad754] | -| 4.1 (2015-03-08) | The mapped device's own queue becomes blk-mq: "enables stacking a blk-mq request_queue ontop of the underlying blk-mq device(s)" | [`bfebd1cdb497`][cbfebd1cdb497] | +| 4.1 (2015-03-08) | The mapped device's own queue can become blk-mq, for tables stacked on blk-mq devices: "enables stacking a blk-mq request_queue ontop of the underlying blk-mq device(s)" | [`bfebd1cdb497`][cbfebd1cdb497] | | 4.12 (2016-10-21) | Bio prison v2 | [`742c8fdc31e8`][c742c8fdc31e8] | | 5.18 (2022-02-17) | `dm_submit_bio_remap()` lets a target that submits clones itself have them accounted when it submits them, if it sets `accounts_remapped_io` | [`0fbb4d93b38b`][c0fbb4d93b38b] | | 5.19 (2022-04-12) | Reworked bio splitting and I/O accounting | [`7dd76d1feec7`][c7dd76d1feec7] | @@ -863,3 +865,15 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [lore-remap1]: https://lore.kernel.org/dm-devel/20220210223832.99412-11-snitzer@redhat.com/ [lore-remap2]: https://lore.kernel.org/dm-devel/20220211214057.40612-12-snitzer@redhat.com/ [lore-split16]: https://lore.kernel.org/dm-devel/20220418022733.56168-17-snitzer@kernel.org/ +[dm1740]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1740 +[dm588]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n588 +[dm2025]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2025 +[ioc1224]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1224 +[dmt677]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n677 +[dmt1481]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1481 +[thin2583]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2583 +[thin2613]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2613 +[thin1909]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1909 +[thin1356]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1356 +[cache2508]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2508 +[smq1254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.3#n1254 From 0de28c2a9e3c41329759b5b2f9d0c710aef2ca69 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 10:13:20 -0800 Subject: [PATCH 11/20] block: correct the abnormal-I/O, flush and thin-origin descriptions Abnormal I/O is still cloned and mapped, by __process_abnormal_io(); fix the reference-count and single-device-test line anchors; scope the thin diagram and the FUA-commit sentence; and separate the straddling and past-the-end origin cases. --- docs/block/device-mapper.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index c2c86505..2bf2bf63 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -189,12 +189,12 @@ A bio reaches the device through `dm_submit_bio()`, which takes the live table u └─ KILL / REQUEUE ──► clone freed, status recorded on the I/O ``` -Steps 1 to 4 describe normal reads and writes. A discard, secure-erase or write-zeroes bio takes `__process_abnormal_io()` instead of the clone-and-map steps below ([dm.c:1740-1741][dm1740]), and a flush is sent through `__send_empty_flush()` (see "Flushes and discards" below). +Steps 1 to 4 describe normal reads and writes. A discard, secure-erase or write-zeroes bio is cloned once per copy the target asked for (`num_discard_bios` and the like) by `__process_abnormal_io()` instead of by the single clone in step 1 ([dm.c:1740-1741][dm1740]), then mapped and completed as in steps 3 and 4 ([dm.c:1524-1530][dm1524]). A flush normally goes through `__send_empty_flush()` (see "Flushes and discards" below). 1. **Clone.** `__split_and_process_bio()` finds the target for the current sector ([dm.c:1736][dm1736]) and limits the length to the target's maximum I/O length and the sectors left ([dm.c:1749][dm1749]). `alloc_tio()` supplies the clone: the first one is embedded in the per-I/O structure `dm_io`, later ones come from `bio_alloc_clone()` ([dm.c:620-626][dm620]). The clone's default device is the mapped device itself, so the target must change it before the bio is issued ([dm.c:645-646][dm645]). 2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2046-2053][dm2046]). 3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). -4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:588-589][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]). +4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]). **A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2046-2053][dm2046]): @@ -222,7 +222,7 @@ What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], va !!! warning "`DM_MAPIO_DELAY_REQUEUE` is not a bio-based return value" The value is defined next to the others, but the switch in `__map_bio()` has no case for it and ends in `BUG()` ([dm.c:1457-1459][dm1457]). The request-based path handles it ([dm-rq.c:412][rq412]). -**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios` and `num_secure_erase_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then the flush with data is not split into an empty flush plus data; it is passed as one bio to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2025][dm2025]). +**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios` and `num_secure_erase_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then it is passed whole to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2024-2026][dm2025]). ## Bio-based and request-based devices @@ -363,18 +363,18 @@ flowchart TD F --> M ``` -The diagram shows the `PM_WRITE` handlers ([dm-thin.c:2613-2623][thin2613]). In `PM_OUT_OF_DATA_SPACE`, `PM_OUT_OF_METADATA_SPACE` and `PM_READ_ONLY` the pool uses read-only variants of `process_bio` and `process_cell`, and in the two read-only modes `process_discard` does nothing but complete the bio ([dm-thin.c:2583-2585][thin2583]); the modes are described below. Requeue mode and `PM_FAIL` also return early, before the lookup. A bio can also be held in the cell because another bio already holds it ([dm-thin.c:2752-2753][thin2752]); the diagram leaves that case out. +The lower half of the diagram, from the pool worker down, shows the `PM_WRITE` handlers ([dm-thin.c:2613-2623][thin2613]); the top half is `thin_bio_map()`, which is the same in every mode except that it returns early in requeue mode (a per-thin-device flag) and in `PM_FAIL` ([dm-thin.c:2731-2740][thin2731]). In `PM_OUT_OF_DATA_SPACE`, `PM_OUT_OF_METADATA_SPACE` and `PM_READ_ONLY` the pool uses read-only variants of `process_bio` and `process_cell`, and in the two read-only modes `process_discard` does nothing but complete the bio ([dm-thin.c:2583-2585][thin2583]); the modes are described below. A bio can also be held in the cell because another bio already holds it ([dm-thin.c:2752-2753][thin2752]); the diagram leaves that case out. The anchors for the diagram: - Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). - A write to a shared block breaks the sharing (an empty flush bio does not: the condition is a write with data, [dm-thin.c:1887][thin1887]); a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block (an empty flush is remapped without provisioning, [dm-thin.c:1909-1918][thin1909]) ([dm-thin.c:1930][thin1930]), then copies from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]); the zeroing happens only when zeroing is turned on, and for the straddling block only if the copy is shorter than a block ([dm-thin.c:1356-1357][thin1356]); the copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]); without an origin it zeroes the block unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1356-1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk -Changes to the mapping sit in an open metadata transaction until `commit()` calls `dm_pool_commit_metadata()` ([dm-thin.c:1490][thin1490]). A bio with a flush or FUA flag is checked when it is issued. If its thin device has changed the transaction by then, including a FUA write that itself provisioned a block, it does not go straight down: `issue()` puts it on a list, and one commit serves all bios on the list ([dm-thin.c:735-738][thin735], [dm-thin.c:756-777][thin756]). The comment on a related path says why: "If the bio has the REQ_FUA flag set we must commit the metadata before signaling its completion" ([dm-thin.c:964-966][thin964]). +Changes to the mapping sit in an open metadata transaction until `commit()` calls `dm_pool_commit_metadata()` ([dm-thin.c:1490][thin1490]). A bio with a flush or FUA flag is checked when it is issued. If its thin device has changed the transaction by then, including a FUA write that provisioned a block and does not cover all of it, it does not go straight down: `issue()` puts it on a list, and one commit serves all bios on the list ([dm-thin.c:735-738][thin735], [dm-thin.c:756-777][thin756]). The comment on a related path says why: "If the bio has the REQ_FUA flag set we must commit the metadata before signaling its completion" ([dm-thin.c:964-966][thin964]). ```mermaid sequenceDiagram @@ -866,8 +866,8 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [lore-remap2]: https://lore.kernel.org/dm-devel/20220211214057.40612-12-snitzer@redhat.com/ [lore-split16]: https://lore.kernel.org/dm-devel/20220418022733.56168-17-snitzer@kernel.org/ [dm1740]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1740 -[dm588]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n588 -[dm2025]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2025 +[dm588]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n590 +[dm2025]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2024 [ioc1224]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1224 [dmt677]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n677 [dmt1481]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1481 @@ -877,3 +877,5 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [thin1356]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1356 [cache2508]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2508 [smq1254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.3#n1254 +[dm1524]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1524 +[thin2731]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2731 From 337b3f8da885c2dec09c49fa18da9dd628b3e654 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 10:39:26 -0800 Subject: [PATCH 12/20] block: cover empty-flush bypass, cache FUA path and thin read-only edge cases in the device-mapper page An empty flush on a table of flush_bypasses_map targets goes straight to the underlying devices; a FUA write without PREFLUSH reaches the cache policy through the worker; whole-block FUA overwrites are completed from a second list after the commit; the read-only pool modes and PM_FAIL are scoped to thin devices and to writes with data. --- docs/block/device-mapper.md | 39 +++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 2bf2bf63..1c523152 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -194,7 +194,7 @@ Steps 1 to 4 describe normal reads and writes. A discard, secure-erase or write- 1. **Clone.** `__split_and_process_bio()` finds the target for the current sector ([dm.c:1736][dm1736]) and limits the length to the target's maximum I/O length and the sectors left ([dm.c:1749][dm1749]). `alloc_tio()` supplies the clone: the first one is embedded in the per-I/O structure `dm_io`, later ones come from `bio_alloc_clone()` ([dm.c:620-626][dm620]). The clone's default device is the mapped device itself, so the target must change it before the bio is issued ([dm.c:645-646][dm645]). 2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2046-2053][dm2046]). 3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). -4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]). +4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]), except for a requeued bio and a flush with data, which are handled as described below. **A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2046-2053][dm2046]): @@ -222,7 +222,7 @@ What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], va !!! warning "`DM_MAPIO_DELAY_REQUEUE` is not a bio-based return value" The value is defined next to the others, but the switch in `__map_bio()` has no case for it and ends in `BUG()` ([dm.c:1457-1459][dm1457]). The request-based path handles it ([dm-rq.c:412][rq412]). -**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios` and `num_secure_erase_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then it is passed whole to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2024-2026][dm2025]). +**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios`, `num_secure_erase_bios` and `num_write_zeroes_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then it is passed whole to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2024-2026][dm2025]). The table-wide `flush_bypasses_map` flag is true only when every target sets it ([dm-table.c:763-764][dmt763]); in that case an *empty* flush ignores `num_flush_bios` and is sent as one clone to each underlying device, with no target attached, so it never reaches the targets' `map` or `end_io` ([dm.c:1571-1593][dm1571]). A target that asks for no copies of a discard, secure-erase or write-zeroes bio makes the bio fail with `BLK_STS_NOTSUPP` ([dm.c:1677-1678][dm1675]). ## Bio-based and request-based devices @@ -240,7 +240,7 @@ A target type is a `struct target_type`: a name, a version, feature flags and a |---|---| | `ctr` | When the range is added to a table ([dm-table.c:749][dmt749]) | | `dtr` | When the table is destroyed ([dm-table.c:195-196][dmt195]) | -| `map` | For each clone of a bio-based I/O; `linear` and `stripe` are called directly ([dm.c:1430-1435][dm1430]) | +| `map` | For each clone of a bio-based I/O that the core maps to this target (not for an empty flush when every target in the table sets `flush_bypasses_map`, see "Flushes and discards"); `linear` and `stripe` are called directly ([dm.c:1430-1435][dm1430]) | | `end_io` | When the clone completes ([dm.c:1114-1115][dm1114]) | | `presuspend`, `postsuspend` | Around a suspend ([dm-table.c:2155-2178][dmt2155]) | | `preresume`, `resume` | While resuming ([dm-table.c:2179-2205][dmt2179]) | @@ -268,7 +268,7 @@ The other flags, for example `DM_TARGET_PASSES_CRYPTO` and `DM_TARGET_NOWAIT`, a | Table line | ` ` ([dm-linear.c:28][lin28]) | pool: ` ` ([dm-thin.c:3271-3274][thin3271]); thin: ` [origin_dev]` ([dm-thin.c:4172][thin4172]) | ` <#feature args> []* <#policy args> []*` ([dm-cache-target.c:2025-2027][cache2025]) | | Has a metadata device | ✗ | ✓ | ✓ | | `map` returns | always `DM_MAPIO_REMAPPED` ([dm-linear.c:96][lin96]) | thin: `REMAPPED` only for a mapped, unshared block that is not held in a cell, `SUBMITTED` otherwise ([dm-thin.c:2731-2808][thin2731]); thin-pool: always `REMAPPED` ([dm-thin.c:3450][thin3450]) | `REMAPPED`, or `SUBMITTED` when the target takes the bio over ([dm-cache-target.c:1674][cache1674], [dm-cache-target.c:1768][cache1768]) | -| Modes | none | pool modes ([below](#running-out-of-space)) | writeback, writethrough, passthrough ([below](#three-io-modes)) | +| Modes | none | pool modes ([below](#running-out-of-space)) | writeback, writethrough, passthrough ([below](#three-io-modes)); it also has metadata modes `CM_WRITE`, `CM_READ_ONLY` and `CM_FAIL` ([dm-cache-target.c:247-252][cache247]) | ## linear: the smallest target @@ -293,7 +293,7 @@ int linear_map(struct dm_target *ti, struct bio *bio) } ``` -*Quoted from [dm-linear.c:82-97][lin82].* It returns `DM_MAPIO_REMAPPED`, so the core submits the clone. The constructor asks for one copy each of flush, discard, secure-erase and write-zeroes bios and sets `flush_bypasses_map` ([dm-linear.c:61-65][lin61]). +*Quoted from [dm-linear.c:82-97][lin82].* It returns `DM_MAPIO_REMAPPED`, so the core submits the clone. The constructor asks for one copy each of flush, discard, secure-erase and write-zeroes bios and sets `flush_bypasses_map` ([dm-linear.c:61-65][lin61]). In a table made only of such targets, an empty flush is therefore sent to the underlying devices without calling `linear_map()` (see "Flushes and discards"). ## thin provisioning @@ -357,7 +357,7 @@ flowchart TD D -- "not mapped, write" --> P["allocate a data block"] P --> Q{"external
origin?"} Q -- yes --> E["copy from the origin
(not for a whole-block write;
zeroed past the origin's end,
if zeroing is on)"] - Q -- no --> F["zero the block unless the
write covers all of it"] + Q -- no --> F["zero the block unless the
write covers all of it
or zeroing is off"] S --> M["insert mapping
release held bios"] E --> M F --> M @@ -369,7 +369,7 @@ The anchors for the diagram: - Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). - A write to a shared block breaks the sharing (an empty flush bio does not: the condition is a write with data, [dm-thin.c:1887][thin1887]); a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1356-1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin when the block lies inside it; a read that straddles the end of the origin is zero-filled and truncated, and one wholly past the end is zero-filled and completed without being issued ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1356-1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk @@ -392,7 +392,7 @@ sequenceDiagram W->>D: other bios are submitted ``` -The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). +The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). A whole-block overwrite with a flush or FUA flag is already on the data device by then and sits on a second list, `deferred_flush_completions`; after the commit it is completed with `bio_endio()`, not submitted ([dm-thin.c:987-989][thin987], [dm-thin.c:2399-2400][thin2399]). ### Snapshots @@ -449,7 +449,7 @@ stateDiagram-v2 | out of `PM_FAIL` | Never: "we never let the pool move out of the old mode" ([dm-thin.c:2560-2565][thin2560]) | | to `PM_WRITE` when `needs_check` is set | Refused: from another mode the pool stays where it is, and a pool already in `PM_WRITE` is moved to `PM_READ_ONLY` ([dm-thin.c:2548-2558][thin2548]) | | `PM_OUT_OF_METADATA_SPACE` → `PM_WRITE` | The pool sets `PM_WRITE` when the metadata device is grown ([dm-thin.c:3537-3538][thin3537]); the source comment says the mode "may switch back to WRITE on metadata resize" ([dm-thin.c:207-209][thin207]) | -| Table reload | For a newly loaded table, `bind_control_target()` asks for the mode in the new table's features, `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument, subject to the `needs_check` and `PM_FAIL` rules above ([dm-thin.c:2861-2882][thin2861], [dm-thin.c:2901][thin2901], [dm-thin.c:3175-3176][thin3175]) | +| Table reload | When a newly loaded table is resumed, `pool_preresume()` calls `bind_control_target()`, which asks for the mode in the new table's features, `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument, subject to the `needs_check` and `PM_FAIL` rules above ([dm-thin.c:2861-2882][thin2861], [dm-thin.c:2901][thin2901], [dm-thin.c:3175-3176][thin3175]) | The diagram shows representative edges. `metadata_operation_failed()` sets `PM_READ_ONLY` whatever the current mode, except that `PM_FAIL` is never left ([dm-thin.c:2654-2660][thin2654], [dm-thin.c:2560-2565][thin2560]), and `commit()` refuses to run only from `PM_OUT_OF_METADATA_SPACE` upward ([dm-thin.c:1487-1488][thin1487]), so a commit can also degrade the pool from `PM_OUT_OF_DATA_SPACE`. @@ -460,8 +460,8 @@ What each mode does with a bio: | `PM_WRITE` | metadata may be changed | Served normally | | `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only handlers for bios and cells; discards and prepared mappings keep their write-mode handlers ([dm-thin.c:2602-2607][thin2602]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | | `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2580-2587][thin2580]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | -| `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write to a shared or unmapped block is unserviceable and fails ([dm-thin.c:2032-2063][thin2032]) | -| `PM_FAIL` | all I/O fails | Every bio fails, except that a thin device in requeue mode ends it with `BLK_STS_DM_REQUEUE` instead ([dm-thin.c:2731-2740][thin2731]) | +| `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write with data to a shared block, and any write to an unmapped block, is unserviceable and fails; an empty flush to a shared block is remapped ([dm-thin.c:2032-2063][thin2032]) | +| `PM_FAIL` | all I/O fails | Every bio to a thin device fails, except that a thin device in requeue mode ends it with `BLK_STS_DM_REQUEUE` instead ([dm-thin.c:2731-2740][thin2731]); bios to the pool device itself are still remapped to the data device in every mode ([dm-thin.c:3438-3450][thin3438]) | When free data blocks drop to the low water mark the pool raises an event on the device once, until the flag is cleared again on resume ([dm-thin.c:3636][thin3636]; set at [dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). @@ -487,7 +487,7 @@ In writethrough mode, a write hit on a block that is already dirty, for example ### The map path -`cache_map()` sends bios for the partial block at the end of the origin straight to the origin, because those blocks are not cached ([dm-cache-target.c:2676-2685][cache2676]). It defers discards and flush or FUA bios to a worker ([dm-cache-target.c:2687-2690][cache2687], [dm-cache-target.c:1006-1009][cache1006]). Everything else goes to `map_bio()`, which takes a shared lock on the block and asks the policy about it ([dm-cache-target.c:1665-1697][cache1665]). +`cache_map()` sends bios for the partial block at the end of the origin straight to the origin, because those blocks are not cached ([dm-cache-target.c:2676-2685][cache2676]). It defers discards and flush or FUA bios to a worker ([dm-cache-target.c:2687-2690][cache2687], [dm-cache-target.c:1006-1009][cache1006]). Of the bios the worker receives, `REQ_PREFLUSH` goes to `process_flush_bio()`, a discard to `process_discard_bio()` and anything else, including a FUA write without `REQ_PREFLUSH`, to `process_bio()` and so to `map_bio()` ([dm-cache-target.c:1865-1873][cache1865]). Every other bio goes to `map_bio()` directly, which takes a shared lock on the block and asks the policy about it ([dm-cache-target.c:1665-1697][cache1665]). ```mermaid flowchart TD @@ -495,6 +495,7 @@ flowchart TD B -- yes --> O1["origin"] B -- no --> C{"discard, flush
or FUA?"} C -- yes --> W["worker"] + W -- "FUA without PREFLUSH" --> D C -- no --> D{"policy lookup"} D -- miss --> O2["origin"] D -- "writeback mode, miss, whole-block
write or discarded block, and the
policy returns a promotion" --> MG["start a migration
with this bio"] @@ -504,7 +505,7 @@ flowchart TD F -- yes --> BOTH["origin and cache"] F -- no --> CA E -- "passthrough" --> G{"write?"} - G -- yes --> INV["invalidate the cache block"] + G -- yes --> INV["invalidate the cache block,
commit, then remap to the origin"] G -- no --> O3["origin"] ``` @@ -563,7 +564,7 @@ timeline | 2002-10-15 | The ioctl interface to device-mapper is posted: "Provide a traditional ioctl based interface to control device-mapper from userland." | [LWN: Device-mapper submission 6/7][lwn12734] | | 2.6.12 (tag `v2.6.12-rc2`, 2005-04-16, the first commit in the git history) | `dm-linear.c` and `dm-ioctl.c` already exist; `dm-linear.c` carries "Copyright (C) 2001-2003 Sistina Software (UK) Limited." ([dm-linear.c:3][lin3]) | [`1da177e4c3f4`][c1da177e4c3f4] | | 2006-12-19 | RFC for request-based DM: "Hook for I/O mapping is at request_fn after merging and sorting by I/O scheduler, instead of make_request_fn." | [LWN: rqbased-dm][lwn215058] | -| 2008-03-19 | The series is reposted for discussion: "Currently, device-mapper (dm) is implemented as a stacking block device at bio level." | [LWN: request stacking and request-based dm-multipath][lwn274292] | +| 2008-03-19 | The series is posted as an RFC: "Currently, device-mapper (dm) is implemented as a stacking block device at bio level." | [LWN: request stacking and request-based dm-multipath][lwn274292] | | 2008-09-12, 2008-10-03 | Later postings of the series: 13 patches, then 8 patches | [LWN 13 patches][lwn298882], [LWN 8 patches][lwn301919] | | 2.6.31 (2009-06-22) | Request-based DM is prepared and enabled | [`cec47e3d4a86`][ccec47e3d4a86], [`e6ee8c0b7675`][ce6ee8c0b7675] | | 3.2 (2011-10-31) | Persistent-data library, then thin provisioning | [`3241b1d3e0aa`][c3241b1d3e0aa], [`991d9fa02da0`][c991d9fa02da0] | @@ -581,7 +582,7 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel | Thin provisioning and persistent data (3.2) | 2011-07-08, "[PATCH 0/3] initial release of dm thin provisioning target" ([cover][lore-thin0]), with the library as [2/3][lore-thin2] and the target as [3/3][lore-thin3] | Posted by Mike Snitzer; the body names Joe Thornber as the author; the commit message is a reworded form of the 3/3 text | | Cache target (3.9) | 2012-12-13, "[PATCH 8/8] [dm-cache] cache target" ([8/8][lore-cache8]) | The first posting of the code; its message has no description, the commit message adds one | | `dm_submit_bio_remap()` (5.18) | 2022-02-10, "[PATCH 10/14] dm: add dm_submit_bio_remap interface" ([v1][lore-remap1]); 2022-02-11, "[PATCH v2 11/14]" ([v2][lore-remap2]) | The commit message extends the v2 text (adds the `xchg` and `bio_endio` paragraphs) | -| Bio splitting and I/O accounting (5.19) | 2022-04-17, "[dm-5.19 PATCH 16/21] dm: improve bio splitting and associated IO accounting" ([16/21][lore-split16]) | The body names Ming Lei as the author; the commit message matches the posting | +| Bio splitting and I/O accounting (5.19) | April 2022, "[dm-5.19 PATCH 16/21] dm: improve bio splitting and associated IO accounting" ([16/21][lore-split16]) | The body names Ming Lei as the author; the commit message matches the posting | ## Further reading @@ -879,3 +880,11 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [smq1254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.3#n1254 [dm1524]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1524 [thin2731]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2731 +[dmt763]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n763 +[dm1571]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1571 +[dm1675]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1677 +[thin3438]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3438 +[thin987]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n987 +[thin2399]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2399 +[cache1865]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1865 +[cache247]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n247 From 9d28273155a054cc8e593cd1085053f90093155c Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 10:42:45 -0800 Subject: [PATCH 13/20] block: scope the device-mapper completion, flush-bypass and thin-origin statements Name the two completion exceptions with their sources, include write-zeroes in the copy counts, say that stripe also sets flush_bypasses_map, restrict the second flush list to writes issued ahead of the mapping, and describe the truncated origin read. --- docs/block/device-mapper.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 1c523152..cec2a34f 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -194,7 +194,7 @@ Steps 1 to 4 describe normal reads and writes. A discard, secure-erase or write- 1. **Clone.** `__split_and_process_bio()` finds the target for the current sector ([dm.c:1736][dm1736]) and limits the length to the target's maximum I/O length and the sectors left ([dm.c:1749][dm1749]). `alloc_tio()` supplies the clone: the first one is embedded in the per-I/O structure `dm_io`, later ones come from `bio_alloc_clone()` ([dm.c:620-626][dm620]). The clone's default device is the mapped device itself, so the target must change it before the bio is issued ([dm.c:645-646][dm645]). 2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2046-2053][dm2046]). 3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). -4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]), except for a requeued bio and a flush with data, which are handled as described below. +4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]), with two exceptions: a flush with data that was split is re-queued without `REQ_PREFLUSH` instead of completing ([dm.c:986-992][dm986]), and a status of `BLK_STS_DM_REQUEUE` is either put on a requeue list or turned into an I/O error depending on the situation ([dm.c:903-947][dm903]). **A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2046-2053][dm2046]): @@ -222,7 +222,7 @@ What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], va !!! warning "`DM_MAPIO_DELAY_REQUEUE` is not a bio-based return value" The value is defined next to the others, but the switch in `__map_bio()` has no case for it and ends in `BUG()` ([dm.c:1457-1459][dm1457]). The request-based path handles it ([dm-rq.c:412][rq412]). -**Flushes and discards.** A target asks for the number of copies of a flush, discard or secure-erase bio it wants, using `num_flush_bios`, `num_discard_bios`, `num_secure_erase_bios` and `num_write_zeroes_bios` ([device-mapper.h:331-343][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then it is passed whole to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2024-2026][dm2025]). The table-wide `flush_bypasses_map` flag is true only when every target sets it ([dm-table.c:763-764][dmt763]); in that case an *empty* flush ignores `num_flush_bios` and is sent as one clone to each underlying device, with no target attached, so it never reaches the targets' `map` or `end_io` ([dm.c:1571-1593][dm1571]). A target that asks for no copies of a discard, secure-erase or write-zeroes bio makes the bio fail with `BLK_STS_NOTSUPP` ([dm.c:1677-1678][dm1675]). +**Flushes and discards.** A target asks for the number of copies of a flush, discard, secure-erase or write-zeroes bio it wants, using `num_flush_bios`, `num_discard_bios`, `num_secure_erase_bios` and `num_write_zeroes_bios` ([device-mapper.h:331-349][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then it is passed whole to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2024-2026][dm2025]). The table-wide `flush_bypasses_map` flag is true only when every target sets it ([dm-table.c:763-764][dmt763]); in that case an *empty* flush ignores `num_flush_bios` and is sent as one clone to each underlying device, with no target attached, so it never reaches the targets' `map` or `end_io` ([dm.c:1571-1593][dm1571]). A target that asks for no copies of a discard, secure-erase or write-zeroes bio makes the bio fail with `BLK_STS_NOTSUPP` ([dm.c:1677-1678][dm1675]). ## Bio-based and request-based devices @@ -241,7 +241,7 @@ A target type is a `struct target_type`: a name, a version, feature flags and a | `ctr` | When the range is added to a table ([dm-table.c:749][dmt749]) | | `dtr` | When the table is destroyed ([dm-table.c:195-196][dmt195]) | | `map` | For each clone of a bio-based I/O that the core maps to this target (not for an empty flush when every target in the table sets `flush_bypasses_map`, see "Flushes and discards"); `linear` and `stripe` are called directly ([dm.c:1430-1435][dm1430]) | -| `end_io` | When the clone completes ([dm.c:1114-1115][dm1114]) | +| `end_io` | When the clone completes, except for the clones of an empty flush in a table where every target sets `flush_bypasses_map`, which have no target attached ([dm.c:1114-1115][dm1114]) | | `presuspend`, `postsuspend` | Around a suspend ([dm-table.c:2155-2178][dmt2155]) | | `preresume`, `resume` | While resuming ([dm-table.c:2179-2205][dmt2179]) | @@ -293,7 +293,7 @@ int linear_map(struct dm_target *ti, struct bio *bio) } ``` -*Quoted from [dm-linear.c:82-97][lin82].* It returns `DM_MAPIO_REMAPPED`, so the core submits the clone. The constructor asks for one copy each of flush, discard, secure-erase and write-zeroes bios and sets `flush_bypasses_map` ([dm-linear.c:61-65][lin61]). In a table made only of such targets, an empty flush is therefore sent to the underlying devices without calling `linear_map()` (see "Flushes and discards"). +*Quoted from [dm-linear.c:82-97][lin82].* It returns `DM_MAPIO_REMAPPED`, so the core submits the clone. The constructor asks for one copy each of flush, discard, secure-erase and write-zeroes bios and sets `flush_bypasses_map` ([dm-linear.c:61-65][lin61]). In a table made only of targets that set `flush_bypasses_map` (`linear` and `stripe` both do), an empty flush is therefore sent to the underlying devices without calling `linear_map()` (see "Flushes and discards"). ## thin provisioning @@ -369,7 +369,7 @@ The anchors for the diagram: - Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). - A write to a shared block breaks the sharing (an empty flush bio does not: the condition is a write with data, [dm-thin.c:1887][thin1887]); a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin when the block lies inside it; a read that straddles the end of the origin is zero-filled and truncated, and one wholly past the end is zero-filled and completed without being issued ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1356-1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin when the read lies wholly inside it; a read that straddles the end of the origin is zero-filled and truncated, and the truncated part is still read from the origin, while one wholly past the end is zero-filled and completed without being issued ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1356-1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk @@ -392,7 +392,7 @@ sequenceDiagram W->>D: other bios are submitted ``` -The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). A whole-block overwrite with a flush or FUA flag is already on the data device by then and sits on a second list, `deferred_flush_completions`; after the commit it is completed with `bio_endio()`, not submitted ([dm-thin.c:987-989][thin987], [dm-thin.c:2399-2400][thin2399]). +The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). A whole-block overwrite with a flush or FUA flag whose write was issued ahead of the mapping (when zeroing is on, or a copy from the origin is skipped) is already on the data device by then and, if the commit is needed, sits on a second list, `deferred_flush_completions`; after the commit it is completed with `bio_endio()`, not submitted ([dm-thin.c:987-989][thin987], [dm-thin.c:2399-2400][thin2399]). ### Snapshots @@ -449,7 +449,7 @@ stateDiagram-v2 | out of `PM_FAIL` | Never: "we never let the pool move out of the old mode" ([dm-thin.c:2560-2565][thin2560]) | | to `PM_WRITE` when `needs_check` is set | Refused: from another mode the pool stays where it is, and a pool already in `PM_WRITE` is moved to `PM_READ_ONLY` ([dm-thin.c:2548-2558][thin2548]) | | `PM_OUT_OF_METADATA_SPACE` → `PM_WRITE` | The pool sets `PM_WRITE` when the metadata device is grown ([dm-thin.c:3537-3538][thin3537]); the source comment says the mode "may switch back to WRITE on metadata resize" ([dm-thin.c:207-209][thin207]) | -| Table reload | When a newly loaded table is resumed, `pool_preresume()` calls `bind_control_target()`, which asks for the mode in the new table's features, `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument, subject to the `needs_check` and `PM_FAIL` rules above ([dm-thin.c:2861-2882][thin2861], [dm-thin.c:2901][thin2901], [dm-thin.c:3175-3176][thin3175]) | +| Table reload | On resume, `pool_preresume()` calls `bind_control_target()` ([dm-thin.c:3573][thin3573]); for a newly loaded table it asks for the mode in the new table's features, `PM_WRITE` by default and `PM_READ_ONLY` with the `read_only` argument, subject to the `needs_check` and `PM_FAIL` rules above ([dm-thin.c:2861-2882][thin2861], [dm-thin.c:2901][thin2901], [dm-thin.c:3175-3176][thin3175]) | The diagram shows representative edges. `metadata_operation_failed()` sets `PM_READ_ONLY` whatever the current mode, except that `PM_FAIL` is never left ([dm-thin.c:2654-2660][thin2654], [dm-thin.c:2560-2565][thin2560]), and `commit()` refuses to run only from `PM_OUT_OF_METADATA_SPACE` upward ([dm-thin.c:1487-1488][thin1487]), so a commit can also degrade the pool from `PM_OUT_OF_DATA_SPACE`. @@ -460,7 +460,7 @@ What each mode does with a bio: | `PM_WRITE` | metadata may be changed | Served normally | | `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only handlers for bios and cells; discards and prepared mappings keep their write-mode handlers ([dm-thin.c:2602-2607][thin2602]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | | `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2580-2587][thin2580]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | -| `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write with data to a shared block, and any write to an unmapped block, is unserviceable and fails; an empty flush to a shared block is remapped ([dm-thin.c:2032-2063][thin2032]) | +| `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write with data to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write with data to a shared block, and any write to an unmapped block, is unserviceable and fails; an empty flush to a shared block is remapped ([dm-thin.c:2032-2063][thin2032]) | | `PM_FAIL` | all I/O fails | Every bio to a thin device fails, except that a thin device in requeue mode ends it with `BLK_STS_DM_REQUEUE` instead ([dm-thin.c:2731-2740][thin2731]); bios to the pool device itself are still remapped to the data device in every mode ([dm-thin.c:3438-3450][thin3438]) | When free data blocks drop to the low water mark the pool raises an event on the device once, until the flag is cleared again on resume ([dm-thin.c:3636][thin3636]; set at [dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). @@ -480,7 +480,7 @@ In writethrough mode, a write hit on a block that is already dirty, for example |---|---|---|---| | writeback | cache | ✓ | "Data is written to cached blocks only. These blocks are marked dirty. If you lose the cache device you will lose data." | | writethrough | cache; a write to a clean block goes to both devices ([dm-cache-target.c:1745-1750][cache1745]) | ✗ for a write to a clean block; a write to an already-dirty block goes to the cache only ([dm-cache-target.c:1745-1750][cache1745]) | "Data is written to both cache and origin. Blocks are never dirty." | -| passthrough | origin; a write also invalidates the cache block ([dm-cache-target.c:1737-1743][cache1737]) | ✗ | "Reads and writes always go to the origin. If a write goes to a cached oblock, then the cache block is invalidated." | +| passthrough | origin; a write also invalidates the cache block, and after the metadata commit the write is remapped to the origin ([dm-cache-target.c:1737-1743][cache1737], [dm-cache-target.c:1522-1555][cache1522]) | ✗ | "Reads and writes always go to the origin. If a write goes to a cached oblock, then the cache block is invalidated." | !!! warning "Writeback loses data with the cache device" In writeback mode the cache can hold the only up-to-date copy of a block. The source comment says so directly: "If you lose the cache device you will lose data" ([dm-cache-target.c:256-259][cache256]). @@ -888,3 +888,7 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [thin2399]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2399 [cache1865]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1865 [cache247]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n247 +[dm986]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n986 +[dm903]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n903 +[thin3573]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3573 +[cache1522]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1522 From 4f80ad864ef0b4ec49dd4514f0c3ebda1daa3cab Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 10:44:46 -0800 Subject: [PATCH 14/20] block: correct the device-mapper requeue, origin-read and flush-list statements Add the polled BLK_STS_AGAIN requeue case, say that the part of an origin-straddling read inside the origin is the part read, and include the break-sharing copy in the writes that reach the second flush list. --- docs/block/device-mapper.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index cec2a34f..849e5ab4 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -194,7 +194,7 @@ Steps 1 to 4 describe normal reads and writes. A discard, secure-erase or write- 1. **Clone.** `__split_and_process_bio()` finds the target for the current sector ([dm.c:1736][dm1736]) and limits the length to the target's maximum I/O length and the sectors left ([dm.c:1749][dm1749]). `alloc_tio()` supplies the clone: the first one is embedded in the per-I/O structure `dm_io`, later ones come from `bio_alloc_clone()` ([dm.c:620-626][dm620]). The clone's default device is the mapped device itself, so the target must change it before the bio is issued ([dm.c:645-646][dm645]). 2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2046-2053][dm2046]). 3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). -4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]), with two exceptions: a flush with data that was split is re-queued without `REQ_PREFLUSH` instead of completing ([dm.c:986-992][dm986]), and a status of `BLK_STS_DM_REQUEUE` is either put on a requeue list or turned into an I/O error depending on the situation ([dm.c:903-947][dm903]). +4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]), with two exceptions: a flush with data that was sent as an empty flush first is re-queued without `REQ_PREFLUSH` instead of completing ([dm.c:986-992][dm986]), and an I/O that ends with `BLK_STS_DM_REQUEUE`, or a polled I/O that ends with `BLK_STS_AGAIN`, is either requeued or, for `BLK_STS_DM_REQUEUE` when none of the requeue conditions holds, failed with an I/O error ([dm.c:903-947][dm903]). **A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2046-2053][dm2046]): @@ -369,7 +369,7 @@ The anchors for the diagram: - Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). - A write to a shared block breaks the sharing (an empty flush bio does not: the condition is a write with data, [dm-thin.c:1887][thin1887]); a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin when the read lies wholly inside it; a read that straddles the end of the origin is zero-filled and truncated, and the truncated part is still read from the origin, while one wholly past the end is zero-filled and completed without being issued ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1356-1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin when the read lies wholly inside it; a read that straddles the end of the origin is zero-filled and truncated, and the part inside the origin is still read from it, while one wholly past the end is zero-filled and completed without being issued ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1356-1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk @@ -392,7 +392,7 @@ sequenceDiagram W->>D: other bios are submitted ``` -The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). A whole-block overwrite with a flush or FUA flag whose write was issued ahead of the mapping (when zeroing is on, or a copy from the origin is skipped) is already on the data device by then and, if the commit is needed, sits on a second list, `deferred_flush_completions`; after the commit it is completed with `bio_endio()`, not submitted ([dm-thin.c:987-989][thin987], [dm-thin.c:2399-2400][thin2399]). +The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). A whole-block overwrite with a flush or FUA flag whose write was issued ahead of the mapping (when zeroing is on, or a copy from the shared block or the external origin is skipped) is already on the data device by then and, if the commit is needed, sits on a second list, `deferred_flush_completions`; after the commit it is completed with `bio_endio()`, not submitted ([dm-thin.c:987-989][thin987], [dm-thin.c:2399-2400][thin2399]). ### Snapshots From 7daf35c95aedb86663ad84516a73e05cfff09c0e Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 10:50:46 -0800 Subject: [PATCH 15/20] block: tighten device-mapper citations and a few statements Cite what the metadata header says about the superblock and space maps, include FUA writes among the bios the thin target defers, anchor the end_io and wildcard rows to the code that shows them, fix two off-by-one line anchors, escape the underscores in a quoted comment, and remove duplicate and mismatched link labels. --- docs/block/device-mapper.md | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 849e5ab4..8d57e620 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -92,7 +92,7 @@ flowchart LR The `mapped_device` holds the table pointer, the disk and the list of bios that arrived during a suspend ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-318][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]); the table's list holds one `dm_dev_internal` per device, which has a reference count and a pointer to its `dm_dev` ([dm.h:41-45][mdh41], [dm-table.c:388-395][dmt388]). -The core keeps its own structures private. The header says that targets "must `_not_` deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). +The core keeps its own structures private. The header says that targets "must \_not\_ deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). ## The control interface @@ -156,7 +156,7 @@ A larger table adds levels above the leaf; `dm_table_find_target()` walks all `t | `DM_TARGET_ALWAYS_WRITEABLE` | Not allowed in a read-only table | [dm-table.c:711-715][dmt711] | | `DM_TARGET_IMMUTABLE` | Cannot be mixed with other target types in one table | [dm-table.c:717-728][dmt717] | | `DM_TARGET_IMMUTABLE` | Once a device has it, a later table must use the same type, unless it contains a wildcard target | [dm-ioctl.c:1649-1657][ioc1649] | -| `DM_TARGET_WILDCARD` | May replace any target, even an immutable one | [device-mapper.h:254-258][dmh254] | +| `DM_TARGET_WILDCARD` | May replace any target, even an immutable one | [device-mapper.h:254-258][dmh254] (definition), [dm-ioctl.c:1650-1652][ioc1650] (the check that lets it replace an immutable target) | ## The I/O path for bio-based devices @@ -194,7 +194,7 @@ Steps 1 to 4 describe normal reads and writes. A discard, secure-erase or write- 1. **Clone.** `__split_and_process_bio()` finds the target for the current sector ([dm.c:1736][dm1736]) and limits the length to the target's maximum I/O length and the sectors left ([dm.c:1749][dm1749]). `alloc_tio()` supplies the clone: the first one is embedded in the per-I/O structure `dm_io`, later ones come from `bio_alloc_clone()` ([dm.c:620-626][dm620]). The clone's default device is the mapped device itself, so the target must change it before the bio is issued ([dm.c:645-646][dm645]). 2. **Split.** A bio that crosses a target boundary is handled in pieces. The part that was not mapped is trimmed and resubmitted with `submit_bio_noacct()`, so that it runs "*after* bios already submitted have been completely processed" ([dm.c:2046-2053][dm2046]). 3. **Map.** `__map_bio()` sets `clone_endio()` as the completion function ([dm.c:1414][dm1414]) and calls the target's `map`; the `linear` and `stripe` targets are called directly, without the function pointer ([dm.c:1430-1435][dm1430]). -4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm588]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]), with two exceptions: a flush with data that was sent as an empty flush first is re-queued without `REQ_PREFLUSH` instead of completing ([dm.c:986-992][dm986]), and an I/O that ends with `BLK_STS_DM_REQUEUE`, or a polled I/O that ends with `BLK_STS_AGAIN`, is either requeued or, for `BLK_STS_DM_REQUEUE` when none of the requeue conditions holds, failed with an I/O error ([dm.c:903-947][dm903]). +4. **Complete.** `clone_endio()` calls the target's optional `end_io` ([dm.c:1114-1115][dm1114]); if that returns `DM_ENDIO_INCOMPLETE` the target keeps the clone ([dm.c:1134-1136][dm1134]), otherwise the core drops a reference on the `dm_io` ([dm.c:1147-1148][dm1147]). The `dm_io` starts with two references, one for submission and one for completion ([dm.c:590-591][dm590]), and the original bio completes when the last reference is dropped ([dm.c:1047-1055][dm1047]), with two exceptions: a flush with data that was sent as an empty flush first is re-queued without `REQ_PREFLUSH` instead of completing ([dm.c:986-992][dm986]), and an I/O that ends with `BLK_STS_DM_REQUEUE`, or a polled I/O that ends with `BLK_STS_AGAIN`, is either requeued or, for `BLK_STS_DM_REQUEUE` when none of the requeue conditions holds, failed with an I/O error ([dm.c:903-947][dm903]). **A bio that crosses a target boundary** is mapped in passes. The length of each clone is limited to the end of its target ([dm.c:1161-1166][dm1161]); the rest of the bio is trimmed and submitted again ([dm.c:2046-2053][dm2046]): @@ -222,7 +222,7 @@ What `map` returns decides what the core does next ([dm.c:1437-1460][dm1437], va !!! warning "`DM_MAPIO_DELAY_REQUEUE` is not a bio-based return value" The value is defined next to the others, but the switch in `__map_bio()` has no case for it and ends in `BUG()` ([dm.c:1457-1459][dm1457]). The request-based path handles it ([dm-rq.c:412][rq412]). -**Flushes and discards.** A target asks for the number of copies of a flush, discard, secure-erase or write-zeroes bio it wants, using `num_flush_bios`, `num_discard_bios`, `num_secure_erase_bios` and `num_write_zeroes_bios` ([device-mapper.h:331-349][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then it is passed whole to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2024-2026][dm2025]). The table-wide `flush_bypasses_map` flag is true only when every target sets it ([dm-table.c:763-764][dmt763]); in that case an *empty* flush ignores `num_flush_bios` and is sent as one clone to each underlying device, with no target attached, so it never reaches the targets' `map` or `end_io` ([dm.c:1571-1593][dm1571]). A target that asks for no copies of a discard, secure-erase or write-zeroes bio makes the bio fail with `BLK_STS_NOTSUPP` ([dm.c:1677-1678][dm1675]). +**Flushes and discards.** A target asks for the number of copies of a flush, discard, secure-erase or write-zeroes bio it wants, using `num_flush_bios`, `num_discard_bios`, `num_secure_erase_bios` and `num_write_zeroes_bios` ([device-mapper.h:331-349][dmh331]). A flush with data is split into an empty flush followed by the data, except when the table has one underlying device and its targets set `flush_bypasses_map`: then it is passed whole to `__split_and_process_bio()`, and the target's `map` is still called ([dm.c:2013-2043][dm2013], single-device test at [dm.c:2024-2026][dm2024]). The table-wide `flush_bypasses_map` flag is true only when every target sets it ([dm-table.c:763-764][dmt763]); in that case an *empty* flush ignores `num_flush_bios` and is sent as one clone to each underlying device, with no target attached, so it never reaches the targets' `map` or `end_io` ([dm.c:1571-1593][dm1571]). A target that asks for no copies of a discard, secure-erase or write-zeroes bio makes the bio fail with `BLK_STS_NOTSUPP` ([dm.c:1677-1678][dm1677]). ## Bio-based and request-based devices @@ -241,7 +241,7 @@ A target type is a `struct target_type`: a name, a version, feature flags and a | `ctr` | When the range is added to a table ([dm-table.c:749][dmt749]) | | `dtr` | When the table is destroyed ([dm-table.c:195-196][dmt195]) | | `map` | For each clone of a bio-based I/O that the core maps to this target (not for an empty flush when every target in the table sets `flush_bypasses_map`, see "Flushes and discards"); `linear` and `stripe` are called directly ([dm.c:1430-1435][dm1430]) | -| `end_io` | When the clone completes, except for the clones of an empty flush in a table where every target sets `flush_bypasses_map`, which have no target attached ([dm.c:1114-1115][dm1114]) | +| `end_io` | When the clone completes, except for the clones of an empty flush in a table where every target sets `flush_bypasses_map`, which have no target attached ([dm.c:1114-1115][dm1114], [dm.c:1097][dm1097], [dm.c:1589][dm1589]) | | `presuspend`, `postsuspend` | Around a suspend ([dm-table.c:2155-2178][dmt2155]) | | `preresume`, `resume` | While resuming ([dm-table.c:2179-2205][dmt2179]) | @@ -268,7 +268,7 @@ The other flags, for example `DM_TARGET_PASSES_CRYPTO` and `DM_TARGET_NOWAIT`, a | Table line | ` ` ([dm-linear.c:28][lin28]) | pool: ` ` ([dm-thin.c:3271-3274][thin3271]); thin: ` [origin_dev]` ([dm-thin.c:4172][thin4172]) | ` <#feature args> []* <#policy args> []*` ([dm-cache-target.c:2025-2027][cache2025]) | | Has a metadata device | ✗ | ✓ | ✓ | | `map` returns | always `DM_MAPIO_REMAPPED` ([dm-linear.c:96][lin96]) | thin: `REMAPPED` only for a mapped, unshared block that is not held in a cell, `SUBMITTED` otherwise ([dm-thin.c:2731-2808][thin2731]); thin-pool: always `REMAPPED` ([dm-thin.c:3450][thin3450]) | `REMAPPED`, or `SUBMITTED` when the target takes the bio over ([dm-cache-target.c:1674][cache1674], [dm-cache-target.c:1768][cache1768]) | -| Modes | none | pool modes ([below](#running-out-of-space)) | writeback, writethrough, passthrough ([below](#three-io-modes)); it also has metadata modes `CM_WRITE`, `CM_READ_ONLY` and `CM_FAIL` ([dm-cache-target.c:247-252][cache247]) | +| Modes | none | pool modes ([below](#running-out-of-space)) | writeback, writethrough, passthrough ([below](#three-io-modes)); it also has metadata modes `CM_WRITE`, `CM_READ_ONLY` and `CM_FAIL` ([dm-cache-target.c:248-252][cache247]) | ## linear: the smallest target @@ -335,7 +335,7 @@ The file header of the metadata code describes the layout ([dm-thin-metadata.c:2 block_time = 24-bit time (low bits) + 40-bit data block (high bits) ``` -Only the superblock has a fixed place, block zero; the other structures are allocated from the device by the space maps, which "allocate space linearly from front to back" ([dm-thin-metadata.c:68-69][tm68]). The superblock is small enough for an atomic write. The btrees and space maps come from the persistent-data library, which was added in the same release as thin provisioning ([`3241b1d3e0aa`][c3241b1d3e0aa], "dm: add persistent data library", Linux 3.2, 2011-10-31). +The header comment puts a superblock in block zero, "taking up fewer than 512 bytes for atomic writes" ([dm-thin-metadata.c:22-23][tm22]), and says the space maps "allocate space linearly from front to back" ([dm-thin-metadata.c:68-69][tm68]). The btrees and space maps come from the persistent-data library, which was added in the same release as thin provisioning ([`3241b1d3e0aa`][c3241b1d3e0aa], "dm: add persistent data library", Linux 3.2, 2011-10-31). ### The path of a bio @@ -367,9 +367,9 @@ The lower half of the diagram, from the pool worker down, shows the `PM_WRITE` h The anchors for the diagram: -- Flushes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). +- Flushes, FUA writes and discards go to the worker ([dm-thin.c:2742-2745][thin2742]). A hit on a mapped, unshared block is remapped ([dm-thin.c:2781-2792][thin2781]). A shared block, or a lookup result of `-ENODATA` or `-EWOULDBLOCK` (`-EWOULDBLOCK`: the lookup would need metadata I/O), goes to the worker ([dm-thin.c:2762-2779][thin2762], [dm-thin.c:2794-2797][thin2794]). - A write to a shared block breaks the sharing (an empty flush bio does not: the condition is a write with data, [dm-thin.c:1887][thin1887]); a read of one is remapped to the shared block ([dm-thin.c:1887-1899][thin1887]). `break_sharing()` allocates a new block and copies the old data into it ([dm-thin.c:1799-1812][thin1799]), and the copy is skipped when the write covers the whole block ([dm-thin.c:1335-1339][thin1335]). -- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin when the read lies wholly inside it; a read that straddles the end of the origin is zero-filled and truncated, and the part inside the origin is still read from it, while one wholly past the end is zero-filled and completed without being issued ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1356-1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). +- A read of an unmapped block is filled with zeroes and completed without touching the data device ([dm-thin.c:1923-1928][thin1923]), or, for a thin device created with an external origin (the optional `origin_dev` in the table line, opened read-only, [dm-thin.c:4216][thin4216]), read from the origin when the read lies wholly inside it; a read that straddles the end of the origin is zero-filled and truncated, and the part inside the origin is still read from it, while one wholly past the end is zero-filled and completed without being issued ([dm-thin.c:1977-1992][thin1977]). A write with data allocates a data block ([dm-thin.c:1930][thin1930]); an empty flush is remapped without provisioning ([dm-thin.c:1909-1918][thin1909]). The new block is then filled by copying from the origin if there is one ([dm-thin.c:1933-1934][thin1933]), except that for a block that straddles the end of the origin only the part inside it is copied, and a block wholly past the end is zeroed instead ([dm-thin.c:1415-1426][thin1415]). For the straddling block the tail is zeroed only when zeroing is turned on ([dm-thin.c:1357][thin1356]), and for a block wholly past the end only when zeroing is turned on and the write does not cover the whole block ([dm-thin.c:1396-1404][thin1396]). The copy is skipped for a whole-block write ([dm-thin.c:1335-1339][thin1335]). Without an origin, the block is zeroed unless the write covers all of it or zeroing is turned off ([dm-thin.c:1396-1404][thin1396]). - `process_prepared_mapping()` inserts the mapping and releases the held bios ([dm-thin.c:1004-1029][thin1004]). ### When metadata reaches disk @@ -392,7 +392,7 @@ sequenceDiagram W->>D: other bios are submitted ``` -The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). A whole-block overwrite with a flush or FUA flag whose write was issued ahead of the mapping (when zeroing is on, or a copy from the shared block or the external origin is skipped) is already on the data device by then and, if the commit is needed, sits on a second list, `deferred_flush_completions`; after the commit it is completed with `bio_endio()`, not submitted ([dm-thin.c:987-989][thin987], [dm-thin.c:2399-2400][thin2399]). +The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). A whole-block overwrite with the FUA flag (a flush with data reaches the target with `REQ_PREFLUSH` already cleared, because the core sends the flush first, [dm.c:986-992][dm986]) whose write was issued ahead of the mapping (when zeroing is on, or a copy from the shared block or the external origin is skipped) is already on the data device by then and, if the commit is needed, sits on a second list, `deferred_flush_completions`; after the commit it is completed with `bio_endio()`, not submitted ([dm-thin.c:987-989][thin987], [dm-thin.c:2399-2400][thin2399]). ### Snapshots @@ -783,7 +783,6 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [thin1887]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1887 [thin3636]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3636 [thin4216]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n4216 -[cache2676]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2676 [thin1923]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1923 [thin1930]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1930 [thin1933]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1933 @@ -867,28 +866,31 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [lore-remap2]: https://lore.kernel.org/dm-devel/20220211214057.40612-12-snitzer@redhat.com/ [lore-split16]: https://lore.kernel.org/dm-devel/20220418022733.56168-17-snitzer@kernel.org/ [dm1740]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1740 -[dm588]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n590 -[dm2025]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2024 +[dm590]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n590 +[dm2024]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n2024 [ioc1224]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1224 [dmt677]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n677 [dmt1481]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n1481 [thin2583]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2583 [thin2613]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2613 [thin1909]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1909 -[thin1356]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1356 +[thin1356]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n1357 [cache2508]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2508 [smq1254]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-policy-smq.c?h=v7.3#n1254 [dm1524]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1524 -[thin2731]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2731 [dmt763]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n763 [dm1571]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1571 -[dm1675]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1677 +[dm1677]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1677 [thin3438]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3438 [thin987]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n987 [thin2399]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n2399 [cache1865]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1865 -[cache247]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n247 +[cache247]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n248 [dm986]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n986 [dm903]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n903 [thin3573]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin.c?h=v7.3#n3573 [cache1522]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1522 +[tm22]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-thin-metadata.c?h=v7.3#n22 +[ioc1650]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1650 +[dm1097]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1097 +[dm1589]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1589 From f4478eadd3fc55a18e99f935351920857970db74 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 10:52:05 -0800 Subject: [PATCH 16/20] block: scope the cache miss, thin diagram and clone statements on the device-mapper page Describe the unreachable-looking writethrough duplicate branch from what the source shows, say that REQ_PREFLUSH bios (not all flush-flagged bios) skip the policy lookup, scope the thin diagram edges and the FUA sequence to writes with data and to the submit path, and note the sector-zero start rule and the clone allocation. --- docs/block/device-mapper.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 8d57e620..7d8c0e07 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -69,7 +69,7 @@ A device is either *bio-based* or *request-based* (see [below](#bio-based-and-re !!! info "Terms used on this page" - **bio**: the block layer's I/O descriptor; see [bio and request structures](bio-request.md). - - **clone**: a copy of a bio made by the core for one target, from `bio_alloc_clone()` ([dm.c:626][dm626]). + - **clone**: a copy of a bio made by the core, usually for one target (the clones of an empty flush in a bypass table have none), made with `bio_alloc_clone()`. The first clone of an I/O is allocated together with its `dm_io` ([dm.c:576][dm576]); later ones are allocated separately ([dm.c:626][dm626]). - **flush and FUA**: `REQ_PREFLUSH` is a "request for cache flush" ([blk_types.h:395][blk395]) and `REQ_FUA` is "forced unit access" ([blk_types.h:394][blk394]). `op_is_flush()` is true for either ([blk_types.h:469-472][blk469]). - **`REQ_NOWAIT` and read-ahead**: `REQ_NOWAIT` means "Don't wait if request will block" ([blk_types.h:398][blk398]); `REQ_RAHEAD` means "read ahead, can fail anytime" ([blk_types.h:396][blk396]). - **SRCU**: a read-side locking scheme whose readers may sleep; see [SRCU](../locking/srcu.md). The core uses it to find out when no thread is still using an old table. @@ -148,7 +148,7 @@ The index keys are the last sector of each range. `dm_table_add_target()` stores A larger table adds levels above the leaf; `dm_table_find_target()` walks all `t->depth` levels, the leaf included ([dm-table.c:1573][dmt1573]). -`dm_table_add_target()` rejects a range that has zero length ([dm-table.c:688-691][dmt688]) and a range that does not start where the previous one ended ([dm-table.c:738-741][dmt738]). A target type's feature flags add further rules: +`dm_table_add_target()` rejects a range that has zero length ([dm-table.c:688-691][dmt688]) and a range that does not start where the previous one ended ([dm-table.c:738-741][dmt738]), and a first range that does not start at sector 0 ([dm-table.c:486-487][dmt486]). A target type's feature flags add further rules: | Feature | Meaning | Where enforced | |---|---|---| @@ -351,10 +351,10 @@ flowchart TD W -- "discard" --> X["process_discard"] W -- "other bios" --> D{"block state"} D -- "mapped, not shared" --> R2["remap_and_issue() from the worker
(thin_bio_map() already
returned DM_MAPIO_SUBMITTED)"] - D -- "shared, write" --> S["break_sharing:
allocate a block,
copy unless whole-block write"] + D -- "shared, write with data" --> S["break_sharing:
allocate a block,
copy unless whole-block write"] D -- "shared, read" --> RR["remap to the shared block"] D -- "not mapped, read" --> Z["zero-fill, or read
from the external origin"] - D -- "not mapped, write" --> P["allocate a data block"] + D -- "not mapped, write with data" --> P["allocate a data block"] P --> Q{"external
origin?"} Q -- yes --> E["copy from the origin
(not for a whole-block write;
zeroed past the origin's end,
if zeroing is on)"] Q -- no --> F["zero the block unless the
write covers all of it
or zeroing is off"] @@ -389,7 +389,7 @@ sequenceDiagram W->>M: process_deferred_bios(): one commit() M-->>W: committed W->>C: REQ_PREFLUSH bios complete now - W->>D: other bios are submitted + W->>D: other bios, including this FUA write, are submitted ``` The pool worker also commits when the transaction has changed and more than `COMMIT_PERIOD` (one second) has passed since the last commit ([dm-thin.c:2386-2387][thin2386], [dm-thin.c:33][thin33], [dm-thin.c:2109-2113][thin2109]). After a commit, a waiting bio that is a `REQ_PREFLUSH` is completed without being sent down, because "The data device was flushed as part of metadata commit"; the others are submitted ([dm-thin.c:2402-2410][thin2402]). A whole-block overwrite with the FUA flag (a flush with data reaches the target with `REQ_PREFLUSH` already cleared, because the core sends the flush first, [dm.c:986-992][dm986]) whose write was issued ahead of the mapping (when zeroing is on, or a copy from the shared block or the external origin is skipped) is already on the data device by then and, if the commit is needed, sits on a second list, `deferred_flush_completions`; after the commit it is completed with `bio_endio()`, not submitted ([dm-thin.c:987-989][thin987], [dm-thin.c:2399-2400][thin2399]). @@ -509,13 +509,13 @@ flowchart TD G -- no --> O3["origin"] ``` -- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1715-1718][cache1715]), unless it is a duplicate writethrough bio for a block that has been demoted, which is ended ([dm-cache-target.c:1719-1725][cache1719]). In writeback mode, when the bio is for a discarded block or writes a whole block and the policy returns a promotion, a migration is started with the bio instead ([dm-cache-target.c:1690-1695][cache1690]). +- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1715-1718][cache1715]), The code also ends a bio whose per-bio request number is not zero, with a comment calling it "a duplicate writethrough io" for a demoted block ([dm-cache-target.c:1716-1725][cache1719]); at v7.3 writethrough duplicates a write with `bio_alloc_clone()` and `bio_chain()` ([dm-cache-target.c:830-845][cache830]), and the target asks for two copies of a flush, which take `process_flush_bio()` instead ([dm-cache-target.c:2435][cache2435], [dm-cache-target.c:1868-1869][cache1868]). In writeback mode, when the bio is for a discarded block or writes a whole block and the policy returns a promotion, a migration is started with the bio instead ([dm-cache-target.c:1690-1695][cache1690]). - **Hit:** as in the table above ([dm-cache-target.c:1737-1750][cache1737]). - **FUA:** the bio is issued after the metadata commit ([dm-cache-target.c:1757-1765][cache1757]). ### The policy decides what moves -The core does not decide what to cache. A policy plug-in is asked about each bio that reaches the lookup (bios past the last whole origin block, discards and flushes take other paths, [dm-cache-target.c:2676-2690][cache2676]), and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). In passthrough mode the target tells the policy that migrations are not allowed ([dm-cache-target.c:2508-2509][cache2508]), and the `smq` policy then queues no promotions ([dm-cache-policy-smq.c:1254-1255][smq1254]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). +The core does not decide what to cache. A policy plug-in is asked about each bio that reaches the lookup (bios past the last whole origin block, discards and `REQ_PREFLUSH` bios take other paths, [dm-cache-target.c:2676-2690][cache2676]), and it can queue *background work* of three kinds: promote, demote and writeback ([dm-cache-policy.h:21-24][pol21]). In passthrough mode the target tells the policy that migrations are not allowed ([dm-cache-target.c:2508-2509][cache2508]), and the `smq` policy then queues no promotions ([dm-cache-policy-smq.c:1254-1255][smq1254]). A worker asks the policy for background work, telling it whether the device is idle, and starts each item as a migration ([dm-cache-target.c:1915-1940][cache1915]). ```mermaid flowchart TD @@ -894,3 +894,8 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [ioc1650]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-ioctl.c?h=v7.3#n1650 [dm1097]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1097 [dm1589]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1589 +[cache830]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n830 +[cache2435]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2435 +[cache1868]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1868 +[dmt486]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n486 +[dm576]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n576 From fb092560d3337a4cbfce53ab30376d46e765862a Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 10:59:17 -0800 Subject: [PATCH 17/20] block: scope the cache FUA and promotion statements and the read-only discard case A FUA write that starts a migration with the bio is ended without the commit step; the promotion edge in the migration diagram is conditional; discards in the read-only pool modes are completed, not remapped; and two line anchors and a stray comma are corrected. --- docs/block/device-mapper.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 7d8c0e07..f118c76d 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -69,7 +69,7 @@ A device is either *bio-based* or *request-based* (see [below](#bio-based-and-re !!! info "Terms used on this page" - **bio**: the block layer's I/O descriptor; see [bio and request structures](bio-request.md). - - **clone**: a copy of a bio made by the core, usually for one target (the clones of an empty flush in a bypass table have none), made with `bio_alloc_clone()`. The first clone of an I/O is allocated together with its `dm_io` ([dm.c:576][dm576]); later ones are allocated separately ([dm.c:626][dm626]). + - **clone**: a copy of a bio made by the core, usually for one target (the clones of an empty flush in a bypass table have none), made with `bio_alloc_clone()`. The first clone of an I/O is allocated together with its `dm_io` ([dm.c:577][dm576]); later ones are allocated separately ([dm.c:626][dm626]). - **flush and FUA**: `REQ_PREFLUSH` is a "request for cache flush" ([blk_types.h:395][blk395]) and `REQ_FUA` is "forced unit access" ([blk_types.h:394][blk394]). `op_is_flush()` is true for either ([blk_types.h:469-472][blk469]). - **`REQ_NOWAIT` and read-ahead**: `REQ_NOWAIT` means "Don't wait if request will block" ([blk_types.h:398][blk398]); `REQ_RAHEAD` means "read ahead, can fail anytime" ([blk_types.h:396][blk396]). - **SRCU**: a read-side locking scheme whose readers may sleep; see [SRCU](../locking/srcu.md). The core uses it to find out when no thread is still using an old table. @@ -460,7 +460,7 @@ What each mode does with a bio: | `PM_WRITE` | metadata may be changed | Served normally | | `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only handlers for bios and cells; discards and prepared mappings keep their write-mode handlers ([dm-thin.c:2602-2607][thin2602]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | | `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2580-2587][thin2580]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | -| `PM_READ_ONLY` | metadata may not be changed | A bio to a mapped block is remapped, except a write with data to a shared block; a read of an unmapped block is zero-filled (or read from the external origin); a write with data to a shared block, and any write to an unmapped block, is unserviceable and fails; an empty flush to a shared block is remapped ([dm-thin.c:2032-2063][thin2032]) | +| `PM_READ_ONLY` | metadata may not be changed | A read or write to a mapped block is remapped, except a write with data to a shared block; a discard is completed without being remapped ([dm-thin.c:2584-2586][thin2583]); a read of an unmapped block is zero-filled (or read from the external origin); a write with data to a shared block, and any write to an unmapped block, is unserviceable and fails; an empty flush to a shared block is remapped ([dm-thin.c:2032-2063][thin2032]) | | `PM_FAIL` | all I/O fails | Every bio to a thin device fails, except that a thin device in requeue mode ends it with `BLK_STS_DM_REQUEUE` instead ([dm-thin.c:2731-2740][thin2731]); bios to the pool device itself are still remapped to the data device in every mode ([dm-thin.c:3438-3450][thin3438]) | When free data blocks drop to the low water mark the pool raises an event on the device once, until the flag is cleared again on resume ([dm-thin.c:3636][thin3636]; set at [dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). @@ -509,9 +509,9 @@ flowchart TD G -- no --> O3["origin"] ``` -- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1715-1718][cache1715]), The code also ends a bio whose per-bio request number is not zero, with a comment calling it "a duplicate writethrough io" for a demoted block ([dm-cache-target.c:1716-1725][cache1719]); at v7.3 writethrough duplicates a write with `bio_alloc_clone()` and `bio_chain()` ([dm-cache-target.c:830-845][cache830]), and the target asks for two copies of a flush, which take `process_flush_bio()` instead ([dm-cache-target.c:2435][cache2435], [dm-cache-target.c:1868-1869][cache1868]). In writeback mode, when the bio is for a discarded block or writes a whole block and the policy returns a promotion, a migration is started with the bio instead ([dm-cache-target.c:1690-1695][cache1690]). +- **Miss:** the bio is remapped to the origin ([dm-cache-target.c:1715-1718][cache1715]). The code also ends a bio whose per-bio request number is not zero, with a comment calling it "a duplicate writethrough io" for a demoted block ([dm-cache-target.c:1716-1725][cache1719]); at v7.3 writethrough duplicates a write with `bio_alloc_clone()` and `bio_chain()` ([dm-cache-target.c:830-845][cache830]), and the target asks for two copies of a flush, which take `process_flush_bio()` instead ([dm-cache-target.c:2435][cache2435], [dm-cache-target.c:1866-1867][cache1868]). In writeback mode, when the bio is for a discarded block or writes a whole block and the policy returns a promotion, a migration is started with the bio instead ([dm-cache-target.c:1690-1695][cache1690]). - **Hit:** as in the table above ([dm-cache-target.c:1737-1750][cache1737]). -- **FUA:** the bio is issued after the metadata commit ([dm-cache-target.c:1757-1765][cache1757]). +- **FUA:** a bio that reaches this point is issued after the metadata commit ([dm-cache-target.c:1757-1765][cache1757]). A FUA write that instead starts a migration with the bio, as in the miss case above, is written to the cache by `overwrite()` and ended by `mg_complete()` once the mapping is inserted, without that commit step ([dm-cache-target.c:1144-1163][cache1144], [dm-cache-target.c:1191-1198][cache1191], [dm-cache-target.c:1252-1263][cache1252]). ### The policy decides what moves @@ -531,7 +531,7 @@ flowchart TD H --> K["complete: clear the dirty bit where the code does,
tell the policy, unlock the block, replay held bios"] I --> K J --> K - A -- "writeback mode, and the bio is for a discarded block
or writes a whole block: the policy returns a promotion at once" --> D2["mg_start with the bio:
lock reads and writes"] + A -- "writeback mode, and the bio is for a discarded block
or writes a whole block: if the policy returns a promotion at once" --> D2["mg_start with the bio:
lock reads and writes"] D2 --> E2["overwrite(): write the bio
into the cache block"] E2 --> H ``` @@ -896,6 +896,8 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [dm1589]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n1589 [cache830]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n830 [cache2435]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n2435 -[cache1868]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1868 +[cache1868]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1866 [dmt486]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-table.c?h=v7.3#n486 -[dm576]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n576 +[dm576]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n577 +[cache1144]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1144 +[cache1252]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1252 From 72d756933cc941003d051214e450960091c000c8 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 11:28:39 -0800 Subject: [PATCH 18/20] block: fix link labels and widen a few device-mapper statements Align two line-range labels with their anchors, describe the deferred-bio list as also holding re-queued I/O, cite the commit behind the thin overview sentence, and make the thin bio-path diagram cover empty flushes and the zeroing condition. --- docs/block/device-mapper.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index f118c76d..a5acf871 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -90,7 +90,7 @@ flowchart LR T -- "devices list
(via dm_dev_internal)" --> DD ``` -The `mapped_device` holds the table pointer, the disk and the list of bios that arrived during a suspend ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-318][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]); the table's list holds one `dm_dev_internal` per device, which has a reference count and a pointer to its `dm_dev` ([dm.h:41-45][mdh41], [dm-table.c:388-395][dmt388]). +The `mapped_device` holds the table pointer, the disk and the list of deferred bios, which holds the bios that arrived during a suspend ([dm.c:669-676][dm669]) and also re-queued I/O ([dm.c:887][dm887]) ([dm-core.h:60][core60], [dm-core.h:78][core78], [dm-core.h:97][core97]). A `dm_table` holds its type, the index, the `highs` and `targets` arrays and the list of devices it uses ([dm-core.h:189-217][core189]). A `dm_target` has its table, its type and a `private` pointer for the target's own state ([device-mapper.h:312-318][dmh312], [device-mapper.h:358][dmh358]); a `dm_dev` is what `dm_get_device()` returns ([device-mapper.h:173-179][dmh173]); the table's list holds one `dm_dev_internal` per device, which has a reference count and a pointer to its `dm_dev` ([dm.h:41-45][mdh41], [dm-table.c:388-395][dmt388]). The core keeps its own structures private. The header says that targets "must \_not\_ deference a mapped_device or dm_table to directly access their members" ([dm-core.h:35-39][core35]). @@ -319,7 +319,7 @@ Thin provisioning uses two target types ([dm-thin.c:4109-4110][thin4109], [dm-th Sources: pool ([thin-provisioning.rst:104-106][thinrst104]), thin device ([thin-provisioning.rst:165-175][thinrst165]), snapshot ([thin-provisioning.rst:192-194][thinrst192]). -The data block size must be at least 64 KB, at most 1 GB, and a multiple of 64 KB ([dm-thin.c:41-46][thin41], [dm-thin.c:3342-3345][thin3342]). According to the commit that added the target, many virtual devices are stored on the same data volume, and snapshots can be taken of snapshots (see [Snapshots](#snapshots)). A pool is managed with messages: `create_thin`, `create_snap`, `delete`, `set_transaction_id`, `reserve_metadata_snap` and `release_metadata_snap` ([dm-thin.c:3855-3871][thin3855]). +The data block size must be at least 64 KB, at most 1 GB, and a multiple of 64 KB ([dm-thin.c:41-46][thin41], [dm-thin.c:3342-3345][thin3342]). According to [the commit that added the target][c991d9fa02da0], many virtual devices are stored on the same data volume, and snapshots can be taken of snapshots (see [Snapshots](#snapshots)). A pool is managed with messages: `create_thin`, `create_snap`, `delete`, `set_transaction_id`, `reserve_metadata_snap` and `release_metadata_snap` ([dm-thin.c:3855-3871][thin3855]). ### Metadata @@ -352,11 +352,12 @@ flowchart TD W -- "other bios" --> D{"block state"} D -- "mapped, not shared" --> R2["remap_and_issue() from the worker
(thin_bio_map() already
returned DM_MAPIO_SUBMITTED)"] D -- "shared, write with data" --> S["break_sharing:
allocate a block,
copy unless whole-block write"] - D -- "shared, read" --> RR["remap to the shared block"] + D -- "shared, read
or empty flush" --> RR["remap to the shared block"] D -- "not mapped, read" --> Z["zero-fill, or read
from the external origin"] D -- "not mapped, write with data" --> P["allocate a data block"] + D -- "not mapped, empty flush" --> RF["remap without provisioning"] P --> Q{"external
origin?"} - Q -- yes --> E["copy from the origin
(not for a whole-block write;
zeroed past the origin's end,
if zeroing is on)"] + Q -- yes --> E["copy from the origin
(not for a whole-block write;
zeroed past the origin's end,
if zeroing is on and the
write is not whole-block)"] Q -- no --> F["zero the block unless the
write covers all of it
or zeroing is off"] S --> M["insert mapping
release held bios"] E --> M @@ -460,7 +461,7 @@ What each mode does with a bio: | `PM_WRITE` | metadata may be changed | Served normally | | `PM_OUT_OF_DATA_SPACE` | metadata may be changed, though data may not be allocated | Uses the read-only handlers for bios and cells; discards and prepared mappings keep their write-mode handlers ([dm-thin.c:2602-2607][thin2602]); a bio that is unserviceable is held on a retry list unless `error_if_no_space` is set ([dm-thin.c:1600-1601][thin1600], [dm-thin.c:1614-1623][thin1614]) | | `PM_OUT_OF_METADATA_SPACE` | like read-only, but may switch back to write on a metadata resize; reported as read-only | Same bio path as `PM_READ_ONLY` ([dm-thin.c:2580-2587][thin2580]); an unserviceable bio fails with an I/O error ([dm-thin.c:1603-1606][thin1603]) | -| `PM_READ_ONLY` | metadata may not be changed | A read or write to a mapped block is remapped, except a write with data to a shared block; a discard is completed without being remapped ([dm-thin.c:2584-2586][thin2583]); a read of an unmapped block is zero-filled (or read from the external origin); a write with data to a shared block, and any write to an unmapped block, is unserviceable and fails; an empty flush to a shared block is remapped ([dm-thin.c:2032-2063][thin2032]) | +| `PM_READ_ONLY` | metadata may not be changed | A read or write to a mapped block is remapped, except a write with data to a shared block; a discard is completed without being remapped ([dm-thin.c:2583-2586][thin2583]); a read of an unmapped block is zero-filled (or read from the external origin); a write with data to a shared block, and any write to an unmapped block, is unserviceable and fails; an empty flush to a shared block is remapped ([dm-thin.c:2032-2063][thin2032]) | | `PM_FAIL` | all I/O fails | Every bio to a thin device fails, except that a thin device in requeue mode ends it with `BLK_STS_DM_REQUEUE` instead ([dm-thin.c:2731-2740][thin2731]); bios to the pool device itself are still remapped to the data device in every mode ([dm-thin.c:3438-3450][thin3438]) | When free data blocks drop to the low water mark the pool raises an event on the device once, until the flag is cleared again on resume ([dm-thin.c:3636][thin3636]; set at [dm-thin.c:1501-1510][thin1501]). An event increments the device's event counter and wakes anything waiting on it ([dm.c:2443-2457][dm2443]). `alloc_data_block()` tries a commit before giving up on an empty pool ([dm-thin.c:1530-1548][thin1530]). A code comment says that a frequently seen `PM_OUT_OF_DATA_SPACE` means the low water mark should be adjusted ([dm-thin.c:2594-2600][thin2594]). @@ -613,7 +614,7 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [cache1679]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1679 [cache1690]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1690 [cache1705]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1705 -[cache1719]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1719 +[cache1719]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1716 [cache1715]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1715 [cache1737]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1737 [cache1745]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1745 @@ -901,3 +902,5 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel [dm576]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n577 [cache1144]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1144 [cache1252]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm-cache-target.c?h=v7.3#n1252 +[dm669]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n669 +[dm887]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/dm.c?h=v7.3#n887 From aefcd90a8c5f0709e9b4a507c90430c05b7e274c Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 11:36:02 -0800 Subject: [PATCH 19/20] block: call the target registry a list of target types --- docs/block/device-mapper.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index a5acf871..5b39ad8d 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -247,7 +247,7 @@ A target type is a `struct target_type`: a name, a version, feature flags and a `status`, `message`, `iterate_devices` and `io_hints` are also members of the struct ([device-mapper.h:215-221][dmh215]). A target's constructor opens the underlying devices with `dm_get_device()` ([device-mapper.h:185-186][dmh185]). Each range has a `struct dm_target` with its `begin`, `len` and optional `max_io_len` ([device-mapper.h:312-321][dmh312]). -Targets are kept in a list under a read-write semaphore ([dm-target.c:18-19][tgt18]). When the named type is missing, the core runs `request_module("dm-%s", name)` and looks again ([dm-target.c:46-49][tgt46], [dm-target.c:51-58][tgt51]). +Target types are kept in a list under a read-write semaphore ([dm-target.c:18-19][tgt18]). When the named type is missing, the core runs `request_module("dm-%s", name)` and looks again ([dm-target.c:46-49][tgt46], [dm-target.c:51-58][tgt51]). The feature flags that these targets set, from their `target_type` definitions (`multipath` is included for comparison): From fea2b2acb26e489275ee4c662509cbf68fd55888 Mon Sep 17 00:00:00 2001 From: Laveesh Bansal Date: Mon, 30 Nov 2026 18:45:01 -0800 Subject: [PATCH 20/20] block: state the dm-devel posting dates and message differences exactly --- docs/block/device-mapper.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/block/device-mapper.md b/docs/block/device-mapper.md index 5b39ad8d..de605a97 100644 --- a/docs/block/device-mapper.md +++ b/docs/block/device-mapper.md @@ -582,8 +582,8 @@ The commits for these four changes carry no `Link:` trailer, so each posting bel |---|---|---| | Thin provisioning and persistent data (3.2) | 2011-07-08, "[PATCH 0/3] initial release of dm thin provisioning target" ([cover][lore-thin0]), with the library as [2/3][lore-thin2] and the target as [3/3][lore-thin3] | Posted by Mike Snitzer; the body names Joe Thornber as the author; the commit message is a reworded form of the 3/3 text | | Cache target (3.9) | 2012-12-13, "[PATCH 8/8] [dm-cache] cache target" ([8/8][lore-cache8]) | The first posting of the code; its message has no description, the commit message adds one | -| `dm_submit_bio_remap()` (5.18) | 2022-02-10, "[PATCH 10/14] dm: add dm_submit_bio_remap interface" ([v1][lore-remap1]); 2022-02-11, "[PATCH v2 11/14]" ([v2][lore-remap2]) | The commit message extends the v2 text (adds the `xchg` and `bio_endio` paragraphs) | -| Bio splitting and I/O accounting (5.19) | April 2022, "[dm-5.19 PATCH 16/21] dm: improve bio splitting and associated IO accounting" ([16/21][lore-split16]) | The body names Ming Lei as the author; the commit message matches the posting | +| `dm_submit_bio_remap()` (5.18) | 2022-02-10, "[PATCH 10/14] dm: add dm_submit_bio_remap interface" ([v1][lore-remap1]); 2022-02-11, "[PATCH v2 11/14]" ([v2][lore-remap2]) | The commit message extends the v2 text: the `xchg()` paragraph gains the explanation of the `__send_duplicate_bios()` race, a `bio_endio` paragraph is added, and the opening sentence now says "Where possible" | +| Bio splitting and I/O accounting (5.19) | 2022-04-17, "[dm-5.19 PATCH 16/21] dm: improve bio splitting and associated IO accounting" ([16/21][lore-split16]) | The body names Ming Lei as the author; the commit message matches the posting | ## Further reading