dmmirror
Device Mapper Mirror Target
GSoC 2011 Adam Hoka
Specification
Version 2
Definitions
- DM: Device Mapper (see: http://sources.redhat.com/dm/)
- Volume: a DM's idea of the whole or the a part of a disk's storage area
Requirements
- The Mirror target should implement RAID 1.
- Two or more volumes should be able to used within the mirror.
- Removal of all but one volume should still produce a working volume.
- Online removal of any volumes should keep the mirror working, given that there is still a working volume present.
- 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.
- The Mirror target's interface should be integrated with LVM Tools.
- Any meta data stored on disk should be kept consistent across any possible unclean shutdown.
The Write Intent Bitmap
Description
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).
Layout
[[header: WIBM][size][primary/secondary][serial][crc32]]
Reading the bitmap
- read both bitmaps
- validate signature (TODO Maybe only on first read?)
check crc
- if any crc is invalid -> use the other (TODO, what if serial is different?)
- if both crc is invalid -> trouble! full resync
- if both valid: continue
check serial
- if one of the copies is outdated, use the other
- if match we have a valid bitmap
Writing the bitmap
- modify bitmap in memory (bump serial, 1 if overflow)
- write first copy, mark as primary
- flushing would be a good idea here! [1]
- write second copy, mark as secondary
- flushing would be a good idea here! [1]
Writing the data
- set the dirty flag in the bitmap
- also set the MODIFIED flag if we run in degraded mode
- write the actual data
- remove the dirty bit from the bitmap
[1] does it kill performance?
RAID1 target design documentation
Rationale
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.