[PATCH 0/6] null_blk: allow REQ_OP_WRITE_ZEROES and cleanup
From: Chaitanya Kulkarni
Date: Tue Oct 04 2022 - 23:18:03 EST
Hi,
In order to test the non-trivial I/O path in the block layer for
REQ_OP_WRITE_ZEROES allow write-zeroes on null_blk so we can write
testcases with and without non-memory backed mode followed by
few cleanup patches.
Below is the test report with ext2/ext4 mkfs and a blktest
waiting to get upstream for this patch-series.
-ck
Chaitanya Kulkarni (6):
null_blk: allow write zeores on non-membacked
null_blk: allow write zeores on membacked
null_blk: code cleaup
null_blk: initialize cmd->bio in __alloc_cmd()
null_blk: don't use magic numbers in the code
null_blk: remove extra space in switch condition
drivers/block/null_blk/main.c | 131 ++++++++++++++++++++++--------
drivers/block/null_blk/null_blk.h | 1 +
2 files changed, 97 insertions(+), 35 deletions(-)
1. Write Zeroes test with ext2/ext3 for memory backed :-
linux-block (for-next) # mkfs.ext2 /dev/nullb0
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 76037c2c-9c32-4ac6-b1d6-d1f62e6071ad
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
linux-block (for-next) # mount /dev/nullb0 /mnt/
backend/ data/ nullb0/ nvme1n1/ test/
linux-block (for-next) # mount /dev/nullb0 /mnt/nullb0/
linux-block (for-next) # dmesg -c
[18833.072830] null_blk: null_handle_write_zeroes 1225 2097024 128
[18833.072963] null_blk: null_handle_write_zeroes 1225 536 4096
[18833.073439] null_blk: null_handle_write_zeroes 1225 262680 4096
[18833.073845] null_blk: null_handle_write_zeroes 1225 524304 4096
[18833.074202] null_blk: null_handle_write_zeroes 1225 786968 4096
[18833.074581] null_blk: null_handle_write_zeroes 1225 1048592 4096
[18833.074951] null_blk: null_handle_write_zeroes 1225 1311256 4096
[18833.075381] null_blk: null_handle_write_zeroes 1225 1572880 4096
[18833.075748] null_blk: null_handle_write_zeroes 1225 1835544 4096
[18833.076164] null_blk: null_handle_write_zeroes 1225 4672 8
[18844.752019] EXT4-fs (nullb0): mounting ext2 file system using the ext4 subsystem
[18844.752487] EXT4-fs (nullb0): mounted filesystem without journal. Quota mode: none.
linux-block (for-next) #
linux-block (for-next) # mkfs.ext4 /dev/nullb0
mke2fs 1.45.6 (20-Mar-2020)
/dev/nullb0 contains a ext2 file system
last mounted on Mon Oct 3 18:28:05 2022
Proceed anyway? (y,N) y
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: a4c66d5f-bda9-4f58-aa03-911b87bb5c7d
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
linux-block (for-next) # mount /dev/nullb0 /mnt/nullb0/
linux-block (for-next) # dmesg -c
[18882.721160] EXT4-fs (nullb0): unmounting filesystem.
[18888.687070] null_blk: null_handle_write_zeroes 1225 2097024 128
[18888.687159] null_blk: null_handle_write_zeroes 1225 1160 8
[18888.687309] null_blk: null_handle_write_zeroes 1225 33968 8
[18888.687839] null_blk: null_handle_write_zeroes 1225 1048576 65536
[18892.105964] EXT4-fs (nullb0): mounted filesystem with ordered data mode. Quota mode: none.
linux-block (for-next) #
2. Test blkdiscard with -z for different block sizes :-
linux-block (for-next) # ./zeroout.sh
#################### BLKISZ 512 #####################
config/nullb/nullb0
├── badblocks
├── blocking
├── blocksize
├── cache_size
├── completion_nsec
├── discard
├── home_node
├── hw_queue_depth
├── index
├── irqmode
├── max_sectors
├── mbps
├── memory_backed
├── no_sched
├── poll_queues
├── power
├── queue_mode
├── shared_tag_bitmap
├── size
├── submit_queues
├── use_per_node_hctx
├── virt_boundary
├── write_zeroes
├── zone_capacity
├── zoned
├── zone_max_active
├── zone_max_open
├── zone_nr_conv
└── zone_size
0 directories, 29 files
ODD:-
19+1 records in
19+1 records out
10002 bytes (10 kB, 9.8 KiB) copied, 0.000521991 s, 19.2 MB/s
0000000 a a a a a a a a a a a a a a a a
0000016
0000512 a a a a a a a a a a a a a a a a
0000528
0001024 a a a a a a a a a a a a a a a a
0001040
0001536 a a a a a a a a a a a a a a a a
0001552
0002048 a a a a a a a a a a a a a a a a
0002064
0002560 a a a a a a a a a a a a a a a a
0002576
0003072 a a a a a a a a a a a a a a a a
0003088
0003584 a a a a a a a a a a a a a a a a
0003600
0004096 a a a a a a a a a a a a a a a a
0004112
0004608 a a a a a a a a a a a a a a a a
0004624
------------------------------------------------------
0000000 a a a a a a a a a a a a a a a a
0000016
0000512 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000528
0001024 a a a a a a a a a a a a a a a a
0001040
0001536 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0001552
0002048 a a a a a a a a a a a a a a a a
0002064
0002560 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0002576
0003072 a a a a a a a a a a a a a a a a
0003088
0003584 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0003600
0004096 a a a a a a a a a a a a a a a a
0004112
0004608 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0004624
------------------------------------------------------
EVEN:-
19+1 records in
19+1 records out
10002 bytes (10 kB, 9.8 KiB) copied, 0.000376636 s, 26.6 MB/s
0000000 a a a a a a a a a a a a a a a a
0000016
0000512 a a a a a a a a a a a a a a a a
0000528
0001024 a a a a a a a a a a a a a a a a
0001040
0001536 a a a a a a a a a a a a a a a a
0001552
0002048 a a a a a a a a a a a a a a a a
0002064
0002560 a a a a a a a a a a a a a a a a
0002576
0003072 a a a a a a a a a a a a a a a a
0003088
0003584 a a a a a a a a a a a a a a a a
0003600
0004096 a a a a a a a a a a a a a a a a
0004112
0004608 a a a a a a a a a a a a a a a a
0004624
------------------------------------------------------
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000016
0000512 a a a a a a a a a a a a a a a a
0000528
0001024 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0001040
0001536 a a a a a a a a a a a a a a a a
0001552
0002048 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0002064
0002560 a a a a a a a a a a a a a a a a
0002576
0003072 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0003088
0003584 a a a a a a a a a a a a a a a a
0003600
0004096 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0004112
0004608 a a a a a a a a a a a a a a a a
0004624
------------------------------------------------------
#################### BLKISZ 1024 #####################
config/nullb/nullb0
├── badblocks
├── blocking
├── blocksize
├── cache_size
├── completion_nsec
├── discard
├── home_node
├── hw_queue_depth
├── index
├── irqmode
├── max_sectors
├── mbps
├── memory_backed
├── no_sched
├── poll_queues
├── power
├── queue_mode
├── shared_tag_bitmap
├── size
├── submit_queues
├── use_per_node_hctx
├── virt_boundary
├── write_zeroes
├── zone_capacity
├── zoned
├── zone_max_active
├── zone_max_open
├── zone_nr_conv
└── zone_size
0 directories, 29 files
ODD:-
9+1 records in
9+1 records out
10002 bytes (10 kB, 9.8 KiB) copied, 0.00040033 s, 25.0 MB/s
0000000 a a a a a a a a a a a a a a a a
0000016
0001024 a a a a a a a a a a a a a a a a
0001040
0002048 a a a a a a a a a a a a a a a a
0002064
0003072 a a a a a a a a a a a a a a a a
0003088
0004096 a a a a a a a a a a a a a a a a
0004112
0005120 a a a a a a a a a a a a a a a a
0005136
0006144 a a a a a a a a a a a a a a a a
0006160
0007168 a a a a a a a a a a a a a a a a
0007184
0008192 a a a a a a a a a a a a a a a a
0008208
0009216 a a a a a a a a a a a a a a a a
0009232
------------------------------------------------------
0000000 a a a a a a a a a a a a a a a a
0000016
0001024 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0001040
0002048 a a a a a a a a a a a a a a a a
0002064
0003072 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0003088
0004096 a a a a a a a a a a a a a a a a
0004112
0005120 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0005136
0006144 a a a a a a a a a a a a a a a a
0006160
0007168 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0007184
0008192 a a a a a a a a a a a a a a a a
0008208
0009216 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0009232
------------------------------------------------------
EVEN:-
9+1 records in
9+1 records out
10002 bytes (10 kB, 9.8 KiB) copied, 0.000325488 s, 30.7 MB/s
0000000 a a a a a a a a a a a a a a a a
0000016
0001024 a a a a a a a a a a a a a a a a
0001040
0002048 a a a a a a a a a a a a a a a a
0002064
0003072 a a a a a a a a a a a a a a a a
0003088
0004096 a a a a a a a a a a a a a a a a
0004112
0005120 a a a a a a a a a a a a a a a a
0005136
0006144 a a a a a a a a a a a a a a a a
0006160
0007168 a a a a a a a a a a a a a a a a
0007184
0008192 a a a a a a a a a a a a a a a a
0008208
0009216 a a a a a a a a a a a a a a a a
0009232
------------------------------------------------------
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000016
0001024 a a a a a a a a a a a a a a a a
0001040
0002048 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0002064
0003072 a a a a a a a a a a a a a a a a
0003088
0004096 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0004112
0005120 a a a a a a a a a a a a a a a a
0005136
0006144 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0006160
0007168 a a a a a a a a a a a a a a a a
0007184
0008192 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0008208
0009216 a a a a a a a a a a a a a a a a
0009232
------------------------------------------------------
#################### BLKISZ 2048 #####################
config/nullb/nullb0
├── badblocks
├── blocking
├── blocksize
├── cache_size
├── completion_nsec
├── discard
├── home_node
├── hw_queue_depth
├── index
├── irqmode
├── max_sectors
├── mbps
├── memory_backed
├── no_sched
├── poll_queues
├── power
├── queue_mode
├── shared_tag_bitmap
├── size
├── submit_queues
├── use_per_node_hctx
├── virt_boundary
├── write_zeroes
├── zone_capacity
├── zoned
├── zone_max_active
├── zone_max_open
├── zone_nr_conv
└── zone_size
0 directories, 29 files
ODD:-
4+1 records in
4+1 records out
10002 bytes (10 kB, 9.8 KiB) copied, 0.000367949 s, 27.2 MB/s
0000000 a a a a a a a a a a a a a a a a
0000016
0002048 a a a a a a a a a a a a a a a a
0002064
0004096 a a a a a a a a a a a a a a a a
0004112
0006144 a a a a a a a a a a a a a a a a
0006160
0008192 a a a a a a a a a a a a a a a a
0008208
0010240 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0010256
0012288 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0012304
0014336 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0014352
0016384 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0016400
0018432 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0018448
------------------------------------------------------
0000000 a a a a a a a a a a a a a a a a
0000016
0002048 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0002064
0004096 a a a a a a a a a a a a a a a a
0004112
0006144 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0006160
0008192 a a a a a a a a a a a a a a a a
0008208
0010240 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0010256
0012288 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0012304
0014336 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0014352
0016384 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0016400
0018432 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0018448
------------------------------------------------------
EVEN:-
4+1 records in
4+1 records out
10002 bytes (10 kB, 9.8 KiB) copied, 0.000310981 s, 32.2 MB/s
0000000 a a a a a a a a a a a a a a a a
0000016
0002048 a a a a a a a a a a a a a a a a
0002064
0004096 a a a a a a a a a a a a a a a a
0004112
0006144 a a a a a a a a a a a a a a a a
0006160
0008192 a a a a a a a a a a a a a a a a
0008208
0010240 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0010256
0012288 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0012304
0014336 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0014352
0016384 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0016400
0018432 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0018448
------------------------------------------------------
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000016
0002048 a a a a a a a a a a a a a a a a
0002064
0004096 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0004112
0006144 a a a a a a a a a a a a a a a a
0006160
0008192 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0008208
0010240 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0010256
0012288 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0012304
0014336 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0014352
0016384 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0016400
0018432 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0018448
------------------------------------------------------
#################### BLKISZ 4096 #####################
config/nullb/nullb0
├── badblocks
├── blocking
├── blocksize
├── cache_size
├── completion_nsec
├── discard
├── home_node
├── hw_queue_depth
├── index
├── irqmode
├── max_sectors
├── mbps
├── memory_backed
├── no_sched
├── poll_queues
├── power
├── queue_mode
├── shared_tag_bitmap
├── size
├── submit_queues
├── use_per_node_hctx
├── virt_boundary
├── write_zeroes
├── zone_capacity
├── zoned
├── zone_max_active
├── zone_max_open
├── zone_nr_conv
└── zone_size
0 directories, 29 files
ODD:-
2+1 records in
2+1 records out
10002 bytes (10 kB, 9.8 KiB) copied, 0.00028502 s, 35.1 MB/s
0000000 a a a a a a a a a a a a a a a a
0000016
0004096 a a a a a a a a a a a a a a a a
0004112
0008192 a a a a a a a a a a a a a a a a
0008208
0012288 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0012304
0016384 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0016400
0020480 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0020496
0024576 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0024592
0028672 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0028688
0032768 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0032784
0036864 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0036880
------------------------------------------------------
0000000 a a a a a a a a a a a a a a a a
0000016
0004096 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0004112
0008192 a a a a a a a a a a a a a a a a
0008208
0012288 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0012304
0016384 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0016400
0020480 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0020496
0024576 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0024592
0028672 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0028688
0032768 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0032784
0036864 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0036880
------------------------------------------------------
EVEN:-
2+1 records in
2+1 records out
10002 bytes (10 kB, 9.8 KiB) copied, 0.00024765 s, 40.4 MB/s
0000000 a a a a a a a a a a a a a a a a
0000016
0004096 a a a a a a a a a a a a a a a a
0004112
0008192 a a a a a a a a a a a a a a a a
0008208
0012288 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0012304
0016384 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0016400
0020480 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0020496
0024576 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0024592
0028672 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0028688
0032768 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0032784
0036864 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0036880
------------------------------------------------------
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000016
0004096 a a a a a a a a a a a a a a a a
0004112
0008192 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0008208
0012288 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0012304
0016384 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0016400
0020480 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0020496
0024576 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0024592
0028672 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0028688
0032768 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0032784
0036864 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0036880
------------------------------------------------------