# aliez22/imrsim architecture

> Architecture diagram of the GitHub repository aliez22/imrsim, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aliez22/imrsim
- Repository: https://github.com/aliez22/imrsim

## Overview

IMRSim is a Linux Device Mapper block-device simulator for interlaced magnetic recording. Users create a mapped device over a CMR block device, then issue ordinary I/O or use the command-line utility to inspect and configure it. The kernel target owns request handling, staged track allocation, read-modify-write behavior, zone state, statistics, error reporting, and ioctl dispatch. README-described visualization is included as a capability, but no implementation path or wiring is shown in the supplied excerpts. Kernel internals share one source file; edges reflect only visible calls or explicit README statements.

Main entry points: [`imrsim_kmod/dm-imrsim.c`](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c) (Device Mapper target), [`imrsim_util/imrsim_util.c`](https://github.com/aliez22/imrsim/blob/main/imrsim_util/imrsim_util.c) (Control utility), [`imrsim_kmod/imrsim_ioctl.h`](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/imrsim_ioctl.h) (Ioctl definitions), [`imrsim_kmod/imrsim_types.h`](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/imrsim_types.h) (Shared IMR types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_util["Control utility<br/>[imrsim_util.c]"]
  node_format["Device formatter<br/>[imr_format.sh]"]
end

subgraph group_kernel["Kernel simulator"]
  node_target["Device Mapper target<br/>[dm-imrsim.c]"]
  node_ioctl["Ioctl interface<br/>[dm-imrsim.c]"]
  node_rmw["RMW processing<br/>[dm-imrsim.c]"]
  node_types["Shared IMR types<br/>[imrsim_types.h]"]
  node_ioctl_defs["Ioctl definitions<br/>[imrsim_ioctl.h]"]
end

subgraph group_domain["IMR domain"]
  node_allocation["Stage allocation<br/>[dm-imrsim.c]"]
  node_zone["Zone management<br/>[dm-imrsim.c]"]
  node_stats["Statistics<br/>[dm-imrsim.c]"]
  node_config["Device configuration<br/>[dm-imrsim.c]"]
  node_errors["Error reporting<br/>[dm-imrsim.c]"]
  node_visual["I/O visualization"]
end

node_user(("User"))
node_fio_fs(("I/O clients"))
node_backing[("CMR block device")]

node_user -->|"formats device"| node_format
node_user -->|"runs commands"| node_util
node_user -->|"creates mapped device"| node_target
node_fio_fs -->|"issues block I/O"| node_target
node_target -->|"simulates over"| node_backing
node_target -->|"handles requests"| node_rmw
node_target -->|"allocates tracks"| node_allocation
node_target -->|"checks zone rules"| node_zone
node_target -->|"dispatches ioctls"| node_ioctl
node_util -->|"issues ioctls"| node_ioctl
node_ioctl -->|"queries and resets"| node_zone
node_ioctl -->|"gets and resets"| node_stats
node_ioctl -->|"gets and sets"| node_config
node_ioctl -->|"controls logging"| node_errors
node_types -->|"defines state"| node_target
node_ioctl_defs -->|"defines commands"| node_target
node_ioctl_defs -->|"shares command codes"| node_util
node_visual -.->|"visualizes processing"| node_target

click node_util "https://github.com/aliez22/imrsim/blob/main/imrsim_util/imrsim_util.c"
click node_format "https://github.com/aliez22/imrsim/blob/main/imrsim_util/imr_format.sh"
click node_target "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c"
click node_ioctl "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c"
click node_rmw "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c"
click node_allocation "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c"
click node_zone "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c"
click node_stats "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c"
click node_config "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c"
click node_errors "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c"
click node_visual "https://github.com/aliez22/imrsim/tree/main/imrsim_kmod"
click node_types "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/imrsim_types.h"
click node_ioctl_defs "https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/imrsim_ioctl.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_util,node_format,node_user,node_fio_fs toneBlue
class node_target,node_ioctl,node_rmw,node_types,node_ioctl_defs,node_backing toneAmber
class node_allocation,node_zone,node_stats,node_config,node_errors,node_visual toneMint
```

## Components

### User interface

- [Control utility](https://github.com/aliez22/imrsim/blob/main/imrsim_util/imrsim_util.c): `imrsim_util/imrsim_util.c`
- [Device formatter](https://github.com/aliez22/imrsim/blob/main/imrsim_util/imr_format.sh): `imrsim_util/imr_format.sh`

### Kernel simulator

- [Device Mapper target](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c): `imrsim_kmod/dm-imrsim.c`
- [Ioctl interface](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c): `imrsim_kmod/dm-imrsim.c`
- [RMW processing](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c): `imrsim_kmod/dm-imrsim.c`
- [Shared IMR types](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/imrsim_types.h): `imrsim_kmod/imrsim_types.h`
- [Ioctl definitions](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/imrsim_ioctl.h): `imrsim_kmod/imrsim_ioctl.h`

### IMR domain

- [Stage allocation](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c): `imrsim_kmod/dm-imrsim.c`
- [Zone management](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c): `imrsim_kmod/dm-imrsim.c`
- [Statistics](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c): `imrsim_kmod/dm-imrsim.c`
- [Device configuration](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c): `imrsim_kmod/dm-imrsim.c`
- [Error reporting](https://github.com/aliez22/imrsim/blob/main/imrsim_kmod/dm-imrsim.c): `imrsim_kmod/dm-imrsim.c`
- [I/O visualization](https://github.com/aliez22/imrsim/tree/main/imrsim_kmod): `imrsim_kmod`

### Other components

- **User**
- **I/O clients**
- **CMR block device**

## Connections

- User → Device formatter: formats device (evidence: `README.md`)
- User → Control utility: runs commands (evidence: `README.md`)
- User → Device Mapper target: creates mapped device (evidence: `README.md`)
- I/O clients → Device Mapper target: issues block I/O (evidence: `README.md`)
- Device Mapper target → CMR block device: simulates over (evidence: `README.md`)
- Device Mapper target → RMW processing: handles requests (evidence: `imrsim_kmod/dm-imrsim.c`)
- Device Mapper target → Stage allocation: allocates tracks (evidence: `imrsim_kmod/dm-imrsim.c`)
- Device Mapper target → Zone management: checks zone rules (evidence: `imrsim_kmod/dm-imrsim.c`)
- Device Mapper target → Ioctl interface: dispatches ioctls (evidence: `imrsim_kmod/dm-imrsim.c`)
- Control utility → Ioctl interface: issues ioctls (evidence: `imrsim_util/imrsim_util.c`)
- Ioctl interface → Zone management: queries and resets (evidence: `imrsim_kmod/dm-imrsim.c`)
- Ioctl interface → Statistics: gets and resets (evidence: `imrsim_kmod/dm-imrsim.c`)
- Ioctl interface → Device configuration: gets and sets (evidence: `imrsim_kmod/dm-imrsim.c`)
- Ioctl interface → Error reporting: controls logging (evidence: `imrsim_kmod/dm-imrsim.c`)
- Shared IMR types → Device Mapper target: defines state (evidence: `imrsim_kmod/dm-imrsim.c`)
- Ioctl definitions → Device Mapper target: defines commands (evidence: `imrsim_kmod/dm-imrsim.c`)
- Ioctl definitions → Control utility: shares command codes (evidence: `imrsim_util/imrsim_util.c`)
- I/O visualization → Device Mapper target: visualizes processing (evidence: `README.md`)
