# dm-unstriped: bounded address arithmetic

This is a constructed integer model, not a kernel experiment, hardware benchmark,
or recovery recipe. No block device is opened. Assumes the target begins at sector
zero and uses exact BigInt values in 512-byte address units.

Run from this directory with Node.js:

```sh
node --test model.test.mjs
```

For N members, C-sector chunks, selected member i, backing offset O and view
sector x, the mapped sector is:

    O + N*C*floor(x/C) + i*C + (x mod C)

Require 0 <= i < N, positive N/C/length, length divisible by C, and enough backing
sectors for the entire expanded mapping. The model deliberately rejects invalid
indices even where the pinned kernel parser accepts them. It does not validate
kernel sector_t limits, device alignment, operation flags, queue restrictions,
target stacking or hardware layouts.

Example: N=4, C=256, i=2, O=0 and length=512 map view sectors 0,255,256,511 to
512,767,1536,1791. At least 1792 backing sectors are needed for this selected view.
Independent enumeration tests compare complete constructed stripes with each
member view, including non-power-of-two geometry and values beyond Number's exact
integer range. Passing tests do not establish kernel-table acceptance.

## Primary evidence

Reviewed 2026-12-01, Linux v6.12 commit adc218676eef25575469234709c2d87185ca223a:

- [Documentation](https://github.com/torvalds/linux/blob/adc218676eef25575469234709c2d87185ca223a/Documentation/admin-guide/device-mapper/unstriped.rst)
- [Constructor and mapper](https://github.com/torvalds/linux/blob/adc218676eef25575469234709c2d87185ca223a/drivers/md/dm-unstripe.c)
- [512-byte sector units](https://github.com/torvalds/linux/blob/adc218676eef25575469234709c2d87185ca223a/include/linux/blk_types.h)

The guide's loop example uses length 1 with chunk 256. The source requires length
to be divisible by chunk size. The mapper also uses the incoming bio sector
without subtracting the target start. These are static version-specific source
observations, not executed kernel behavior or a claim about newer versions.

Original explanatory model and tests: Hesela. No upstream kernel code is copied.
See the [definition](https://hesela.dev/terms/dm-unstriped/) and
[RAID overview](https://hesela.com/tech/raid/) for context.

## Later correction: target origin

[Commit 83c10e8dd436](https://github.com/torvalds/linux/blob/83c10e8dd43628d0bf86486616556cd749a3c310/drivers/md/dm-unstripe.c)
uses dm_target_offset before mapping. Thus x is relative to the target, not an
absolute incoming sector. With target start 1024, N=2, C=128, i=1 and O=0,
incoming sector 1024 corresponds to x=0 and maps to 128. Feeding 1024 directly
into the old arithmetic gives 2176. The test demonstrates this coordinate error
without performing I/O or emulating a kernel.

The correction does not change the member-index or length-divisibility checks.
This comparison identifies two exact source states; it does not establish which
distribution kernels carry the fix. The public mapSector API remains explicitly
zero-origin and does not accept a targetStart field.
