mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
blkdeactivate: add blkdeactivate -r wait option to wait for MD resync/recovery/reshape
The new blkdeactivate -r|mdraidoption wait causes blkdeactivate to wait for any resync/recovery/reshape that is currently in progress before deactivating the device. If this option is used, blkdeactivate calls mdadm -W|--wait before mdadm -S|--stop.
This commit is contained in:
parent
7fa0d52262
commit
95087c8f96
@ -1,5 +1,6 @@
|
||||
Version 1.02.144 -
|
||||
======================================
|
||||
Add blkdeactivate -r wait option to wait for MD resync/recovery/reshape.
|
||||
Fix blkdeactivate regression with failing DM/MD devs deactivation (1.02.142).
|
||||
Fix typo in blkdeactivate's '--{dm,lvm,mpath}options' option name.
|
||||
Correct return value testing when get reserved values for reporting.
|
||||
|
@ -8,6 +8,7 @@ blkdeactivate \(em utility to deactivate block devices
|
||||
.RB [ -h ]
|
||||
.RB [ -l \ \fIlvm_options\fP ]
|
||||
.RB [ -m \ \fImpath_options\fP ]
|
||||
.RB [ -r \ \fImdraid_options\fP ]
|
||||
.RB [ -u ]
|
||||
.RB [ -v ]
|
||||
.RI [ device ]
|
||||
@ -62,6 +63,14 @@ all the paths are unavailable for any underlying device-mapper multipath
|
||||
device.
|
||||
.RE
|
||||
.TP
|
||||
.BR -r ", " --mdraidoption \ \fImdraid_options\fP
|
||||
Comma-separated list of MD RAID specific options:
|
||||
.RS
|
||||
.IP \fIwait\fP
|
||||
Wait MD device's resync, recovery or reshape action to complete
|
||||
before deactivation.
|
||||
.RE
|
||||
.TP
|
||||
.BR -u ", " --umount
|
||||
Unmount a mounted device before trying to deactivate it.
|
||||
Without this option used, a device that is mounted is not deactivated.
|
||||
|
@ -71,6 +71,9 @@ LVM_DO_WHOLE_VG=0
|
||||
# Do not retry LV deactivation by default.
|
||||
LVM_CONFIG="activation{retry_deactivation=0}"
|
||||
|
||||
# Do not wait for MD RAID device resync, recovery or reshape.
|
||||
MDRAID_DO_WAIT=0
|
||||
|
||||
# Do not disable queueing if set on multipath devices.
|
||||
MPATHD_DO_DISABLEQUEUEING=0
|
||||
|
||||
@ -113,13 +116,14 @@ usage() {
|
||||
echo " If devices are specified, deactivate only supplied devices and their holders."
|
||||
echo
|
||||
echo " Options:"
|
||||
echo " -e | --errors Show errors reported from tools"
|
||||
echo " -h | --help Show this help message"
|
||||
echo " -d | --dmoptions DM_OPTIONS Comma separated DM specific options"
|
||||
echo " -l | --lvmoptions LVM_OPTIONS Comma separated LVM specific options"
|
||||
echo " -m | --mpathoptions MPATH_OPTIONS Comma separated DM-multipath specific options"
|
||||
echo " -u | --umount Unmount the device if mounted"
|
||||
echo " -v | --verbose Verbose mode (also implies -e)"
|
||||
echo " -e | --errors Show errors reported from tools"
|
||||
echo " -h | --help Show this help message"
|
||||
echo " -d | --dmoptions DM_OPTIONS Comma separated DM specific options"
|
||||
echo " -l | --lvmoptions LVM_OPTIONS Comma separated LVM specific options"
|
||||
echo " -m | --mpathoptions MPATH_OPTIONS Comma separated DM-multipath specific options"
|
||||
echo " -r | --mdraidoptions MDRAID_OPTIONS Comma separated MD RAID specific options"
|
||||
echo " -u | --umount Unmount the device if mounted"
|
||||
echo " -v | --verbose Verbose mode (also implies -e)"
|
||||
echo
|
||||
echo " Device specific options:"
|
||||
echo " DM_OPTIONS:"
|
||||
@ -128,6 +132,8 @@ usage() {
|
||||
echo " LVM_OPTIONS:"
|
||||
echo " retry retry removal several times in case of failure"
|
||||
echo " wholevg deactivate the whole VG when processing an LV"
|
||||
echo " MDRAID_OPTIONS:"
|
||||
echo " wait wait for resync, recovery or reshape to complete first"
|
||||
echo " MPATH_OPTIONS:"
|
||||
echo " disablequeueing disable queueing on all DM-multipath devices first"
|
||||
|
||||
@ -275,6 +281,7 @@ deactivate_lvm () {
|
||||
|
||||
deactivate_md () {
|
||||
local name=$(printf "%s" "$name")
|
||||
local sync_action
|
||||
test -b "$DEV_DIR/$name" || return 0
|
||||
test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
|
||||
|
||||
@ -287,6 +294,19 @@ deactivate_md () {
|
||||
deactivate_holders "$DEV_DIR/$name" || return 1
|
||||
|
||||
echo -n " [MD]: deactivating $devtype device $kname... "
|
||||
|
||||
test "$MDRAID_DO_WAIT" -eq 1 && {
|
||||
sync_action="$(cat $SYS_BLK_DIR/$kname/md/sync_action)"
|
||||
test "$sync_action" != "idle" && {
|
||||
echo -n "$sync_action action in progress... "
|
||||
if eval "$MDADM" $MDADM_OPTS -W "$DEV_DIR/$kname" "$OUT" "$ERR"; then
|
||||
echo -n "complete... "
|
||||
else
|
||||
test $? -ne 1 && echo -n "failed to wait for $sync_action action... "
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
if eval "$MDADM" $MDADM_OPTS -S "$name" "$OUT" "$ERR"; then
|
||||
echo "done"
|
||||
else
|
||||
@ -427,6 +447,20 @@ get_lvmopts() {
|
||||
IFS=$ORIG_IFS
|
||||
}
|
||||
|
||||
get_mdraidopts() {
|
||||
ORIG_IFS=$IFS; IFS=','
|
||||
|
||||
for opt in $1; do
|
||||
case "$opt" in
|
||||
"") ;;
|
||||
"wait") MDRAID_DO_WAIT=1 ;;
|
||||
*) echo "$opt: unknown MD RAID option"
|
||||
esac
|
||||
done
|
||||
|
||||
IFS=$ORIG_IFS
|
||||
}
|
||||
|
||||
get_mpathopts() {
|
||||
ORIG_IFS=$IFS; IFS=','
|
||||
|
||||
@ -489,6 +523,7 @@ while test $# -ne 0; do
|
||||
"-d"|"--dmoptions") get_dmopts "$2" ; shift ;;
|
||||
"-l"|"--lvmoptions") get_lvmopts "$2" ; shift ;;
|
||||
"-m"|"--mpathoptions") get_mpathopts "$2" ; shift ;;
|
||||
"-r"|"--mdraidoptions") get_mdraidopts "$2"; shift ;;
|
||||
"-u"|"--umount") DO_UMOUNT=1 ;;
|
||||
"-v"|"--verbose") VERBOSE=1 ; ERRORS=1 ;;
|
||||
"-vv") VERBOSE=1 ; ERRORS=1 ; set -x ;;
|
||||
|
Loading…
Reference in New Issue
Block a user