Skip to content
Browse files

LVM agents: Handle RAID logical volumes.

This commit addresses rhbz824153.  Specifically, it enables the use
of RAID logical volumes in HA-LVM when using the "tagging" (i.e.
not "clvm") method.

One of the advantages of using RAID LVs is that they can handle
transient failures.  If a device goes down in the RAID LV and comes
back later, it can be reintegrated into the array by simply restarting
(or relocating) the service.  Only those portions of the disk that
have changed will be resync'ed - allowing for faster recovery times.
  • Loading branch information...
1 parent 5419c92 commit f8a488e3977a3104ac50628e709131b99f0c4bcf @jbrassow committed
Showing with 46 additions and 0 deletions.
  1. +33 −0 rgmanager/src/resources/lvm_by_lv.sh
  2. +13 −0 rgmanager/src/resources/lvm_by_vg.sh
View
33 rgmanager/src/resources/lvm_by_lv.sh
@@ -29,6 +29,27 @@ lv_verify()
return $OCF_SUCCESS
}
+restore_transient_failed_pvs()
+{
+ local a=0
+ local -a results
+
+ results=(`pvs -o name,vg_name,attr --noheadings | grep $OCF_RESKEY_vg_name | grep -v 'unknown device'`)
+ while [ ! -z "${results[$a]}" ] ; do
+ if [[ ${results[$(($a + 2))]} =~ ..m ]] &&
+ [ $OCF_RESKEY_vg_name == ${results[$(($a + 1))]} ]; then
+ ocf_log notice "Attempting to restore missing PV, ${results[$a]} in $OCF_RESKEY_vg_name"
+ vgextend --restoremissing $OCF_RESKEY_vg_name ${results[$a]}
+ if [ $? -ne 0 ]; then
+ ocf_log notice "Failed to restore ${results[$a]}"
+ else
+ ocf_log notice " ${results[$a]} restored"
+ fi
+ fi
+ a=$(($a + 3))
+ done
+}
+
# lv_exec_resilient
#
# Sometimes, devices can come back. Their metadata will conflict
@@ -91,6 +112,11 @@ lv_activate_resilient()
if [ $action != "start" ]; then
op="-an"
+ elif [[ "$(lvs -o attr --noheadings $lv_path)" =~ r.......p ]] ||
+ [[ "$(lvs -o attr --noheadings $lv_path)" =~ R.......p ]]; then
+ # We can activate partial RAID LVs and run just fine.
+ ocf_log notice "Attempting activation of partial RAID LV, $lv_path"
+ op="-ay --partial"
fi
if ! lv_exec_resilient "lvchange $op $lv_path" ; then
@@ -317,6 +343,13 @@ lv_activate()
fi
fi
+ # If this is a partial VG, attempt to
+ # restore any transiently failed PVs
+ if [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ ...p ]]; then
+ ocf_log err "Volume group \"$OCF_RESKEY_vg_name\" has PVs marked as missing"
+ restore_transient_failed_pvs
+ fi
+
if ! lv_activate_and_tag $1 $my_name $lv_path; then
ocf_log err "Failed to $1 $lv_path"
View
13 rgmanager/src/resources/lvm_by_vg.sh
@@ -367,6 +367,19 @@ function vg_start_single
##
function vg_start
{
+ local a=0
+ local results
+
+ results=(`lvs -o name,attr --noheadings $OCF_RESKEY_vg_name 2> /dev/null`)
+ while [ ! -z ${results[$a]} ]; do
+ if [[ ! ${results[$(($a + 1))]} =~ ^r ]] ||
+ [[ ! ${results[$(($a + 1))]} =~ ^R ]]; then
+ ocf_log err "RAID LVs are not supported without an 'lv_name' specification"
+ return $OCF_ERR_GENERIC
+ fi
+ a=$(($a + 2))
+ done
+
if [[ "$(vgs -o attr --noheadings $OCF_RESKEY_vg_name)" =~ .....c ]]; then
vg_start_clustered
else

0 comments on commit f8a488e

Please sign in to comment.
Something went wrong with that request. Please try again.