What problem does fr1 solve? It is intended for the situation when network block devices comprise some of the components of the mirror. See ENBD for such a networked block device, and linux kernel NBD. In that setting, resyncs of the whole device are both costly in terms of the time spent doing the resync and increased frequency of occurrence, because of the relative commonness of network brownouts as compared to whole disk failures.
How does it work? The driver keeps a bitmap of pending writes in memory, and writes only those marked there to the mirror component when it comes back on line. The bitmap is created pagewise on demand, so it's not expensive on memory. A terabyte sized device with blocks of 4K will cost max 32MB of memory for the bitmap and probably will never use as much as one percent of that maximum. The driver is tolerant wrt memory faults - it'll still work if you run out of memory, just with less precision.
What kernels is it for? The code was developed and tested for the 2.4 kernels, and has just been ported to the 2.6 kernels (fr1-2.15b). See the patches directory in the archive for details of the latter.
cd /tmp; tar xzvf fr1-2.0.tgz; cd fr1-2.0or similar. Substitute /tmp by the directory where you plan on doing the compiling, and substitute "2.0" by the actual version number on the archive.
patch -b -p1 < /tmp/fr1-2.0/patches/linux-2.6.blah.patch
Next, you use raidtools (or mdadm). The following
instructions are for raidtools.
raiddev /dev/md0That was for a two-way mirror with two loop devices as components.
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
persistent-superblock 0
chunk-size 4
device /dev/loop0
raid-disk 0
device /dev/loop1
raid-disk 1
mkraid --dangerous-no-resync --force /dev/md0I don't see the point of NOT using --dangerous-no-resync. You can always do the sync a moment or two afterwards.
At this point you can "cat /proc/mdstat" and see how things look. Here is how they should look for the raidstat configuration detailed above.
Personalities : [raid1]
read_ahead 4 sectors
md0 : active raid1 [dev 07:00][0] [dev 07:01][1]
1024 blocks
For example, to fault one mirror component:
raidsetfaulty /dev/md0 /dev/loop1After this, the output from /proc/mdstat will show a failed component. It won't be written to or read:
Personalities : [raid1]Then to put the "failed" component back on line:
read_ahead 4 sectors
fr10 : active fr1 [dev 07:00][0] [dev 07:01][1](F)
1024 blocks
raidhotadd /dev/md0 /dev/loop1and the situation will return to normal, immediately. Only a few dirtied blocks will have been written to the newly added device.
Personalities : [raid1]If you want to take the "failed" component fully offline, then you must follow the raidsetfaulty with a
read_ahead 4 sectors
md0 : active fr1 [dev 07:00][0] [dev 07:01][1]
1024 blocks
raidhotremove /dev/md0 /dev/loop1After this, you can still put the component back with raidhotadd, but the background resync will be total. You really want to avoid that.
Oh yes. You can now mkfs on the device, mount it, write files to it, etc. To stop (and deconfigure) the device, do
raidstop /dev/md0No, I don't know what raidstart is supposed to do on a non-persistent array. It doesn't do anything on fr1.
If you fault one device, then write to the device, then hotadd the faulted device back in, you should be able to see from the kernel messages (use "dmesg") that the resync is intelligent. Here's some dmesg output:
raid1 resync starts on device 0 component 1 for 1024 blocksThis resync only copied across blocks 0-9, and skipped the rest.
raid1 resynced dirty blocks 0-9
raid1 resync skipped clean blocks 10-1023
raid1 resync terminates with 0 errs on device 0 component 1
raid1 hotadd component 7.1[1] to device 0
While the resync is happening, /proc/mdstat will show progress, like so:
Personalities : [raid1]
read_ahead 4 sectors
md0 : active fr1 [dev 07:00][0] [dev 07:01][1](F)
1024 blocks
[=======>.............] resync=35.5% (364/1024)