1 From 577055560d55b388d479ef398ffd839792dc1996 Mon Sep 17 00:00:00 2001
2 From: Scott Little <scott.little@windriver.com>
3 Date: Mon, 2 Oct 2017 15:12:54 -0400
4 Subject: [PATCH 06/13] WRS: Patch1110: lvm_vg_activation.patch
7 heartbeat/LVM | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
8 1 file changed, 116 insertions(+), 1 deletion(-)
10 diff --git a/heartbeat/LVM b/heartbeat/LVM
11 index b0ca87a..38092f9 100755
14 @@ -222,6 +222,81 @@ LVM_status() {
18 +# Activate one volume explicitly.
21 + ocf_run lvchange $1 /dev/${2}/$3
22 + if [ $? -eq 0 ] ; then
23 + ocf_log info "Succesfully activated $LV."
25 + ocf_log err "Problem activating $LV."
30 +# Kick off parallel activation of all volumes
32 +activate_all_volumes() {
37 + # Get the list of volumes, without the first line which is column headings.
38 + VOLS=`lvs $VG |tail -n +2`
40 + while read -r LINE; do
41 + # Convert the line into an array.
44 + # First array element is the volume/snapshot name.
47 + # Third array element is the attributes.
48 + ATTR=${LINE_ARRAY[2]}
50 + # Fifth character in the attributes is "a" if it's active.
52 + if [ "$ACTIVE" == "a" ]; then
53 + ocf_log info "$LV is already active."
57 + SNAPSHOT_ORIGIN=${LINE_ARRAY[4]}
58 + if [ "$SNAPSHOT_ORIGIN" != "" ] ; then
59 + # If this is a snapshot, don't activate it.
63 + ( activate_volume "$*" $VG $LV ) &
68 +# Scan for inactive volumes and log any that are found.
70 +log_inactive_volumes() {
71 + # Get the list of volumes, without the first line which is column headings.
72 + VOLS=`lvs $1 |tail -n +2`
74 + while read -r LINE; do
75 + # Convert the line into an array.
78 + # First array element is the volume/snapshot name.
81 + # Third array element is the attributes.
82 + ATTR=${LINE_ARRAY[2]}
84 + # Fifth character in the attributes is "a" if it's active.
86 + if [ "$ACTIVE" != "a" ]; then
87 + ocf_log err "Volume $LV is not active after expiry of timeout."
96 @@ -241,10 +316,50 @@ LVM_start() {
100 + # Kick off activation of all volumes. If it doesn't complete within
101 + # the timeout period, then we'll log the not-yet-activated volumes and
103 lvm_pre_activate || exit
104 - ocf_run vgchange $vgchange_activate_options $vg
105 + (ocf_run vgchange $vgchange_activate_options $1) & PID=$!
108 + # Check every second for up to TIMEOUT seconds whether the vgchange has
113 + PARALLEL_ACTIVATE_DELAY=10
114 + PARALLEL_ACTIVATE_DONE=false
115 + while [ $SECONDS -lt $TIMEOUT ] ; do
116 + kill -0 $PID &> /dev/null
117 + if [ $? -eq 1 ] ; then
118 + # process with pid of $PID doesn't exist, vgchange command completed
122 + if [ $SECONDS -ge $PARALLEL_ACTIVATE_DELAY ] && \
123 + [ "$PARALLEL_ACTIVATE_DONE" != true ] && \
124 + [ "$1" == "cinder-volumes" ] ; then
125 + # This will kick off parallel activation of all LVs in the VG.
126 + # The delay is to ensure the VG is activated first.
127 + PARALLEL_ACTIVATE_DONE=true
128 + ocf_log info Explicitly activating all volumes in $1 with: $vgchange_activate_options
129 + activate_all_volumes $1 $vgchange_activate_options
134 + if [ "$TIMED_OUT" = true ] ; then
135 + ocf_log err "Timed out running ocf_run vgchange $vgchange_activate_options $1"
136 + log_inactive_volumes $1
138 + # Child process completed, get its status.
140 + if [ $? -ne 0 ] ; then
141 + return $OCF_ERR_GENERIC
145 if LVM_status $vg; then
146 : OK Volume $vg activated just fine!