DragonFly BSD


Device Mapper Mirror Target

GSoC 2011 Adam Hoka


Version 2



  1. The Mirror target should implement RAID 1.
  2. Two or more volumes should be able to used within the mirror.
  3. Removal of all but one volume should still produce a working volume.
  4. Online removal of any volumes should keep the mirror working, given that there is still a working volume present.
  5. Failure to any of the disks holding any of the volumes should not lead to data loss or corruption, given that one or more disks holding at least one of the mirrored volumes are still present and healthy.
  6. The Mirror target's interface should be integrated with LVM Tools.
  7. Any meta data stored on disk should be kept consistent across any possible unclean shutdown.

The Write Intent Bitmap


Chunk status is stored in a bitmap data structure. Every chunk has 1 byte of information in the bitmap, a typical chunk size would be 1MB. This way the bitmap is easily addressable. the 2 lower bit of the byte will be used initially for the status. The status could be CLEAN, DIRTY. We can also store a MODIFIED flag, which means that there was a write to that chunk when the volume was out of sync (for faster recovery).


[[header: WIBM][size][primary/secondary][serial][crc32]]

Reading the bitmap

Writing the bitmap

Writing the data

[1] does it kill performance?

RAID1 target design documentation


First I am going to implement a "raid1" target, which doesnt require a log target as the Linux mirror target. I can make a compatible mirror target in the future using this code/target.

Implementation details

Data structures

Every mirror leg (from now on: leg) has a structure which contains any information the target may need during operation. Some of these information should be saved to the disk. The structures are contained in a linked list (TAILQ) to allow flexible removal/addition. The O(n) access time shouldn't be a problem as we don't expect a very large number of legs.