- if both crc is invalid -> trouble! full resync
- if both valid: continue
--check serial
+- check serial
- if one of the copies is outdated, use the other
- if match we have a valid bitmap
- 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.