I am using redhat 5.8 with an lvm mirror, created with the following command:
lvcreate -m1 --mirrorlog mirrored -n mirrorvol -L 10G myvg /dev/vdb /dev/vdc
I would like to know, when I write, do I need to wait the write is given to both devices, or just one?
From what i understood lvm mirror is synchronous:
[root@02srv004x9 ~]# dmsetup ls
mpath2 (253, 2)
foo (253, 3)
vgmirror-oracle_BD2_mirrorlogAvol (253, 4)
VolGroup00-LogVol01 (253, 1)
VolGroup00-LogVol00 (253, 0)
vgmirror-oracle_BD2_mirrorlogAvol_mimage_1 (253, 6)
vgmirror-oracle_BD2_mirrorlogAvol_mimage_0 (253, 5)
dmsetup suspend /dev/mapper/vgmirror-oracle_BD2_mirrorlogAvol_mimage_1
Name: vgmirror-oracle_BD2_mirrorlogAvol_mimage_1
State: SUSPENDED
Read Ahead: 256
Tables present: LIVE
Open count: 1
Event number: 0
Major, minor: 253, 6
Number of targets: 1
UUID: LVM-c8xfdstj4tTpfV3LSIYat0wbKXpfb7kDefFId05lIJR2QV1ws7CBfkbC0Oc813d9
Now I have a secondary image in suspend state, and I will try to mount the filesystem:
mount /dev/mapper/vgmirror-oracle_BD2_mirrorlogAvol /mnt
Here the mount command locks, and remains in state D.
If you write, write will happen into the block cache in your ram. From there it will be synced out, when it is optimal.
If you do a
sync
command or anfsync()
system call, it will write out the whole write cache. Next to that, the ext2-3-4 filesystems try to write the write cache nearly as often as it is possible, other filesystems have better heuristics.Journaling filesystem also execute partial syncs regularly.
If a write happens to the mirrorvol, it will passed over two write operations to the logical sub-volumes on vdb and vdc. There is no guarantee they will be actually executed in the same time, except if somebody says them so (which can be periodic write cache sync, journaling or the ext2-3-4 filesystems wonderful sync feature).
Suspension is not for emulating errors in a LVM physical volume. Suspension is to do non-atomic changes which seems atomic for the actual users. During suspension, every command using the given logical volume, will be in D status, but it don't have to do anything with the write caching, it is an LVM feature.
If you want to emulate a hardware error in a mirrored LVM volume, you have to find alternative solutions. The first which I think working if you power off the physical hard disk with SMART.