요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
========================
Null block device driver
========================
Overview
========
The null block device (``/dev/nullb*``) is used for benchmarking the various
block-layer implementations. It emulates a block device of X gigabytes in size.
It does not execute any read/write operation, just mark them as complete in
the request queue. The following instances are possible:
Multi-queue block-layer
- Request-based.
- Configurable submission queues per device.
No block-layer (Known as bio-based)
- Bio-based. IO requests are submitted directly to the device driver.
- Directly accepts bio data structure and returns them.
All of them have a completion queue for each core in the system.
Module parameters
=================
queue_mode=[0-2]: Default: 2-Multi-queue
Selects which block-layer the module should instantiate with.
= ============
0 Bio-based
1 Single-queue (deprecated)
2 Multi-queue
= ============
home_node=[0--nr_nodes]: Default: NUMA_NO_NODE
Selects what CPU node the data structures are allocated from.
gb=[Size in GB]: Default: 250GB
The size of the device reported to the system.
bs=[Block size (in bytes)]: Default: 512 bytes
The block size reported to the system.
nr_devices=[Number of devices]: Default: 1
Number of block devices instantiated. They are instantiated as /dev/nullb0,
etc.
irqmode=[0-2]: Default: 1-Soft-irq
The completion mode used for completing IOs to the block-layer.
= ===========================================================================
0 None.
1 Soft-irq. Uses IPI to complete IOs across CPU nodes. Simulates the overhead
when IOs are issued from another CPU node than the home the device is
connected to.
2 Timer: Waits a specific period (completion_nsec) for each IO before
completion.
= ===========================================================================
completion_nsec=[ns]: Default: 10,000ns
Combined with irqmode=2 (timer). The time each completion event must wait.
submit_queues=[1..nr_cpus]: Default: 1
The number of submission queues attached to the device driver. If unset, it
defaults to 1. For multi-queue, it is ignored when use_per_node_hctx module
parameter is 1.
hw_queue_depth=[0..qdepth]: Default: 64
The hardware queue depth of the device.
memory_backed=[0/1]: Default: 0
Whether or not to use a memory buffer to respond to IO requests
= =============================================
0 Transfer no data in response to IO requests
1 Use a memory buffer to respond to IO requests
= =============================================
discard=[0/1]: Default: 0
Support discard operations (requires memory-backed null_blk device).
= =====================================
0 Do not support discard operations
1 Enable support for discard operations
= =====================================
cache_size=[Size in MB]: Default: 0
Cache size in MB for memory-backed device.
mbps=[Maximum bandwidth in MB/s]: Default: 0 (no limit)
Bandwidth limit for device performance.
Multi-queue specific parameters
-------------------------------
use_per_node_hctx=[0/1]: Default: 0
Number of hardware context queues.
= =====================================================================
0 The number of submit queues are set to the value of the submit_queues
parameter.
1 The multi-queue block layer is instantiated with a hardware dispatch
queue for each CPU node in the system.
= =====================================================================
no_sched=[0/1]: Default: 0
Enable/disable the io scheduler.
= ======================================
0 nullb* use default blk-mq io scheduler
1 nullb* doesn't use io scheduler
= ======================================
blocking=[0/1]: Default: 0
Blocking behavior of the request queue.
= ===============================================================
0 Register as a non-blocking blk-mq driver device.
1 Register as a blocking blk-mq driver device, null_blk will set
the BLK_MQ_F_BLOCKING flag, indicating that it sometimes/always
needs to block in its ->queue_rq() function.
= ===============================================================
shared_tags=[0/1]: Default: 0
Sharing tags between devices.
= ================================================================
0 Tag set is not shared.
1 Tag set shared between devices for blk-mq. Only makes sense with
nr_devices > 1, otherwise there's no tag set to share.
= ================================================================
zoned=[0/1]: Default: 0
Device is a random-access or a zoned block device.
= ======================================================================
0 Block device is exposed as a random-access block device.
1 Block device is exposed as a host-managed zoned block device. Requires
CONFIG_BLK_DEV_ZONED.
= ======================================================================
zone_size=[MB]: Default: 256
Per zone size when exposed as a zoned block device. Must be a power of two.
zone_nr_conv=[nr_conv]: Default: 0
The number of conventional zones to create when block device is zoned. If
zone_nr_conv >= nr_zones, it will be reduced to nr_zones - 1.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Null block device driver 개요
1-25이 문서는 `SPDX-License-Identifier: GPL-2.0`으로 배포되는 `Null block device driver` 설명서입니다.
null block device인 `/dev/nullb*`는 여러 block-layer 구현을 benchmark하는 데 사용합니다. X gigabyte 크기의 block device를 emulate하지만 실제 read/write 연산은 수행하지 않고 request queue에서 해당 연산을 완료로 표시하기만 합니다.
사용 가능한 multi-queue block-layer instance는 다음과 같습니다.
- request 기반입니다.
- device마다 submission queue 수를 설정할 수 있습니다.
block-layer를 사용하지 않는 instance는 bio-based 방식으로도 알려져 있으며 다음과 같이 동작합니다.
- IO request를 device driver에 직접 제출합니다.
- `bio` data structure를 직접 받아 그대로 반환합니다.
모든 instance는 system의 각 core마다 completion queue를 하나씩 둡니다.
기본 module parameter
26-50`queue_mode=[0-2]`의 기본값은 `2-Multi-queue`이며 module이 생성할 block-layer를 선택합니다.
| 값 | block-layer mode |
|---|---|
| `0` | Bio-based |
| `1` | Single-queue (deprecated) |
| `2` | Multi-queue |
`home_node=[0--nr_nodes]`의 기본값은 `NUMA_NO_NODE`이며 data structure를 할당할 CPU node를 선택합니다.
`gb=[Size in GB]`의 기본값은 `250GB`이며 system에 보고할 device 크기입니다.
`bs=[Block size (in bytes)]`의 기본값은 `512 bytes`이며 system에 보고할 block size입니다.
`nr_devices=[Number of devices]`의 기본값은 `1`이며 생성할 block device 수입니다. device는 `/dev/nullb0` 등의 이름으로 생성됩니다.
완료 방식과 queue parameter
51-73`irqmode=[0-2]`의 기본값은 `1-Soft-irq`이며 block-layer로 IO를 완료할 때 사용할 completion mode를 선택합니다.
| 값 | completion mode |
|---|---|
| `0` | None. |
| `1` | Soft-irq. IPI를 사용해 CPU node 사이에서 IO를 완료합니다. IO를 발행한 CPU node와 device가 연결된 home CPU node가 다를 때의 overhead를 simulate합니다. |
| `2` | Timer. 각 IO를 완료하기 전에 지정한 `completion_nsec` 기간을 기다립니다. |
`completion_nsec=[ns]`의 기본값은 `10,000ns`입니다. `irqmode=2`인 timer mode와 함께 사용하며 각 completion event가 기다릴 시간입니다.
`submit_queues=[1..nr_cpus]`의 기본값은 `1`이며 device driver에 연결할 submission queue 수입니다. 값을 설정하지 않아도 `1`을 사용합니다. multi-queue에서 `use_per_node_hctx` module parameter가 `1`이면 이 값은 무시됩니다.
`hw_queue_depth=[0..qdepth]`의 기본값은 `64`이며 device의 hardware queue depth입니다.
Memory-backed·discard·성능 parameter
74-95`memory_backed=[0/1]`의 기본값은 `0`이며 IO request에 응답할 때 memory buffer를 사용할지를 선택합니다.
| 값 | 동작 |
|---|---|
| `0` | IO request에 응답할 때 data를 전송하지 않습니다. |
| `1` | IO request에 응답할 때 memory buffer를 사용합니다. |
`discard=[0/1]`의 기본값은 `0`이며 discard operation 지원 여부를 선택합니다. memory-backed `null_blk` device가 필요합니다.
| 값 | 동작 |
|---|---|
| `0` | discard operation을 지원하지 않습니다. |
| `1` | discard operation 지원을 활성화합니다. |
`cache_size=[Size in MB]`의 기본값은 `0`이며 memory-backed device의 cache 크기를 MB 단위로 지정합니다.
`mbps=[Maximum bandwidth in MB/s]`의 기본값은 `0 (no limit)`이며 device 성능의 bandwidth limit를 지정합니다.
Multi-queue 전용 parameter
96-116`use_per_node_hctx=[0/1]`의 기본값은 `0`이며 hardware context queue 수를 결정합니다.
| 값 | hardware context queue 구성 |
|---|---|
| `0` | submit queue 수를 `submit_queues` parameter 값으로 설정합니다. |
| `1` | system의 각 CPU node마다 hardware dispatch queue 하나를 두도록 multi-queue block layer를 생성합니다. |
`no_sched=[0/1]`의 기본값은 `0`이며 IO scheduler를 활성화하거나 비활성화합니다.
| 값 | IO scheduler 동작 |
|---|---|
| `0` | `nullb*`가 기본 blk-mq IO scheduler를 사용합니다. |
| `1` | `nullb*`가 IO scheduler를 사용하지 않습니다. |
Request blocking과 shared tags
117-135`blocking=[0/1]`의 기본값은 `0`이며 request queue의 blocking 동작을 선택합니다.
| 값 | blk-mq driver 등록 방식 |
|---|---|
| `0` | non-blocking blk-mq driver device로 등록합니다. |
| `1` | blocking blk-mq driver device로 등록합니다. `null_blk`는 `BLK_MQ_F_BLOCKING` flag를 설정해 `->queue_rq()` function에서 때때로 또는 항상 block해야 함을 나타냅니다. |
`shared_tags=[0/1]`의 기본값은 `0`이며 device 사이의 tag 공유 여부를 선택합니다.
| 값 | tag set 공유 |
|---|---|
| `0` | tag set을 공유하지 않습니다. |
| `1` | blk-mq device 사이에서 tag set을 공유합니다. 공유할 tag set이 있어야 하므로 `nr_devices > 1`일 때만 의미가 있습니다. |
Zoned block device parameter
136-151`zoned=[0/1]`의 기본값은 `0`이며 device를 random-access block device 또는 zoned block device로 노출할지 선택합니다.
| 값 | 노출되는 block device |
|---|---|
| `0` | random-access block device로 노출합니다. |
| `1` | host-managed zoned block device로 노출합니다. `CONFIG_BLK_DEV_ZONED`가 필요합니다. |
`zone_size=[MB]`의 기본값은 `256`이며 zoned block device로 노출할 때 zone별 크기를 지정합니다. 값은 2의 거듭제곱이어야 합니다.
`zone_nr_conv=[nr_conv]`의 기본값은 `0`이며 block device가 zoned일 때 만들 conventional zone 수입니다. `zone_nr_conv >= nr_zones`이면 `nr_zones - 1`로 줄어듭니다.
요약과 해설
null_blk.rst:1-151`/dev/nullb*`는 실제 storage IO 없이 request를 완료해 block-layer 자체의 overhead와 queue 동작을 측정하는 가상 block device입니다. bio-based와 multi-queue 방식을 선택하고 device 수·크기·queue depth·completion delay를 조정할 수 있습니다.
`memory_backed=1`은 data buffer와 discard 시험을 가능하게 하고, `mbps`는 bandwidth를 제한합니다. multi-queue에서는 CPU node별 hardware context, scheduler 사용, blocking queue와 여러 device의 tag set 공유를 시험할 수 있습니다.
`zoned=1`은 `CONFIG_BLK_DEV_ZONED`가 있는 kernel에서 host-managed zoned device를 만들며 `zone_size`와 conventional zone 수를 설정합니다.