0

I have implemented my own device mapper target and I am able to create a mapped device with dmsetup create command.

The problem is that the sector size for this device becomes the default 512 bytes, and I would like to change it to 4096 bytes similar to dm-verity targets.

For instance, below is the sector size for a dm-verity device, and fdisk reports 4096 bytes:

$sudo fdisk -l /dev/mapper/dmv 
Disk /dev/mapper/dmv: 8 KiB, 8192 bytes, 2 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Below is the sector size for my own target, and fdisk reports 512 bytes:

sudo fdisk -l /dev/mapper/my-target 
Disk /dev/mapper/my-target: 8 KiB, 8192 bytes, 16 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

How can I set the sector size for my own device mapper target? I couldn't find where this is done in libdevmapper or cryptsetup source for the dm-verity case.

Cheers!

Durgod
  • 23
  • 4
  • 1
    I guess you need to do it in a `io_hints` handler for the `struct target_type`. – Ian Abbott Sep 22 '21 at 15:18
  • Thanks for the answer, Ian. I added the io_hints handler for the struct target_type, however, this handler alone wasn't enough. I had to add the iterate_devices handler as well to set the sector size to 4096B. Why iterate_devices is also needed? How and where is this handler used? – Durgod Sep 26 '21 at 23:30

0 Answers0