diff options
author | Jonathan Brassow <jbrassow@redhat.com> | 2013-04-15 13:59:46 -0500 |
---|---|---|
committer | Jonathan Brassow <jbrassow@redhat.com> | 2013-04-15 13:59:46 -0500 |
commit | 2e0740f7ef420c7b981bc67cb606d180701b8c1d (patch) | |
tree | 830d8fef50a2b9fc45b5ffb9b8d844d1750ec96c /test/shell/lvchange-raid.sh | |
parent | dce8d06af7e5a14a1507bea0e64e6cc27556cbc7 (diff) | |
download | lvm2-2e0740f7ef420c7b981bc67cb606d180701b8c1d.tar.gz |
RAID: Add writemostly/writebehind support for RAID1
'lvchange' is used to alter a RAID 1 logical volume's write-mostly and
write-behind characteristics. The '--writemostly' parameter takes a
PV as an argument with an optional trailing character to specify whether
to set ('y'), unset ('n'), or toggle ('t') the value. If no trailing
character is given, it will set the flag.
Synopsis:
lvchange [--writemostly <PV>:{t|y|n}] [--writebehind <count>] vg/lv
Example:
lvchange --writemostly /dev/sdb1:y --writebehind 512 vg/raid1_lv
The last character in the 'lv_attr' field is used to show whether a device
has the WriteMostly flag set. It is signified with a 'w'. If the device
has failed, the 'p'artial flag has priority.
Example ("nosync" raid1 with mismatch_cnt and writemostly):
[~]# lvs -a --segment vg
LV VG Attr #Str Type SSize
raid1 vg Rwi---r-m 2 raid1 500.00m
[raid1_rimage_0] vg Iwi---r-- 1 linear 500.00m
[raid1_rimage_1] vg Iwi---r-w 1 linear 500.00m
[raid1_rmeta_0] vg ewi---r-- 1 linear 4.00m
[raid1_rmeta_1] vg ewi---r-- 1 linear 4.00m
Example (raid1 with mismatch_cnt, writemostly - but failed drive):
[~]# lvs -a --segment vg
LV VG Attr #Str Type SSize
raid1 vg rwi---r-p 2 raid1 500.00m
[raid1_rimage_0] vg Iwi---r-- 1 linear 500.00m
[raid1_rimage_1] vg Iwi---r-p 1 linear 500.00m
[raid1_rmeta_0] vg ewi---r-- 1 linear 4.00m
[raid1_rmeta_1] vg ewi---r-p 1 linear 4.00m
A new reportable field has been added for writebehind as well. If
write-behind has not been set or the LV is not RAID1, the field will
be blank.
Example (writebehind is set):
[~]# lvs -a -o name,attr,writebehind vg
LV Attr WBehind
lv rwi-a-r-- 512
[lv_rimage_0] iwi-aor-w
[lv_rimage_1] iwi-aor--
[lv_rmeta_0] ewi-aor--
[lv_rmeta_1] ewi-aor--
Example (writebehind is not set):
[~]# lvs -a -o name,attr,writebehind vg
LV Attr WBehind
lv rwi-a-r--
[lv_rimage_0] iwi-aor-w
[lv_rimage_1] iwi-aor--
[lv_rmeta_0] ewi-aor--
[lv_rmeta_1] ewi-aor--
Diffstat (limited to 'test/shell/lvchange-raid.sh')
-rw-r--r-- | test/shell/lvchange-raid.sh | 99 |
1 files changed, 97 insertions, 2 deletions
diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh index a1c9540c4..0ef00b36b 100644 --- a/test/shell/lvchange-raid.sh +++ b/test/shell/lvchange-raid.sh @@ -14,11 +14,102 @@ . lib/test -# dm-raid v1.5.0+ contains RAID scrubbing support -aux target_at_least dm-raid 1 5 0 || skip +# dm-raid v1.4.1+ contains RAID10 support +aux target_at_least dm-raid 1 4 1 || skip aux prepare_vg 5 +# run_writemostly_check <VG> <LV> +run_writemostly_check() { + d0=`lvs -a --noheadings -o devices $1/${2}_rimage_0 | sed s/\(.\)//` + d0=$(sed s/^[[:space:]]*// <<< "$d0") + d1=`lvs -a --noheadings -o devices $1/${2}_rimage_1 | sed s/\(.\)//` + d1=$(sed s/^[[:space:]]*// <<< "$d1") + + # No writemostly flag should be there yet. + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*-$' + lvs -a --noheadings -o lv_attr $1/${2}_rimage_1 | grep '.*-$' + + if [ `lvs --noheadings -o segtype $1/$2` != "raid1" ]; then + not lvchange --writemostly $d0 $1/$2 + return + fi + + # Set the flag + lvchange --writemostly $d0 $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*w$' + + # Running again should leave it set (not toggle) + lvchange --writemostly $d0 $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*w$' + + # Running again with ':y' should leave it set + lvchange --writemostly $d0:y $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*w$' + + # ':n' should unset it + lvchange --writemostly $d0:n $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*-$' + + # ':n' again should leave it unset + lvchange --writemostly $d0:n $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*-$' + + # ':t' toggle to set + lvchange --writemostly $d0:t $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*w$' + + # ':t' toggle to unset + lvchange --writemostly $d0:t $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*-$' + + # ':y' to set + lvchange --writemostly $d0:y $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*w$' + + # Toggle both at once + lvchange --writemostly $d0:t --writemostly $d1:t $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*-$' + lvs -a --noheadings -o lv_attr $1/${2}_rimage_1 | grep '.*w$' + + # Toggle both at once again + lvchange --writemostly $d0:t --writemostly $d1:t $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*w$' + lvs -a --noheadings -o lv_attr $1/${2}_rimage_1 | grep '.*-$' + + # Toggle one, unset the other + lvchange --writemostly $d0:n --writemostly $d1:t $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*-$' + lvs -a --noheadings -o lv_attr $1/${2}_rimage_1 | grep '.*w$' + + # Toggle one, set the other + lvchange --writemostly $d0:y --writemostly $d1:t $1/$2 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*w$' + lvs -a --noheadings -o lv_attr $1/${2}_rimage_1 | grep '.*-$' + + # Partial flag supercedes writemostly flag + aux disable_dev $d0 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*p$' + aux enable_dev $d0 + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*w$' + + # Catch Bad writebehind values + not lvchange --writebehind "invalid" $1/$2 + not lvchange --writebehind -256 $1/$2 + + # Set writebehind + [ ! `lvs --noheadings -o writebehind $1/$2` ] + lvchange --writebehind 512 $1/$2 + [ `lvs --noheadings -o writebehind $1/$2` -eq 512 ] + + # Converting to linear should clear flags and writebehind + lvconvert -m 0 $1/$2 $d1 + lvconvert --type raid1 -m 1 $1/$2 $d1 + [ ! `lvs --noheadings -o writebehind $1/$2` ] + lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*-$' + lvs -a --noheadings -o lv_attr $1/${2}_rimage_1 | grep '.*-$' +} + # run_syncaction_check <VG> <LV> run_syncaction_check() { local device @@ -109,6 +200,10 @@ run_refresh_check() { } run_checks() { + if aux target_at_least dm-raid 1 1 0; then + run_writemostly_check $1 $2 + fi + if aux target_at_least dm-raid 1 5 0; then run_syncaction_check $1 $2 fi |