mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
blkdeactivate: recognize and deactivate MD devices too
This commit is contained in:
parent
df59db6048
commit
5f7a94a03e
@ -1,5 +1,6 @@
|
||||
Version 1.02.110 -
|
||||
======================================
|
||||
Add support for recognition and deactivation of MD devices to blkdeactivate.
|
||||
Move target status functions out of libdm-deptree.
|
||||
Correct use of max_write_behind parameter when generating raid target line.
|
||||
Fix dm-event systemd service to make sure it is executed before mounting.
|
||||
|
@ -14,10 +14,11 @@ blkdeactivate \(em utility to deactivate block devices
|
||||
blkdeactivate utility deactivates block devices. If a device
|
||||
is mounted, the utility can unmount it automatically before
|
||||
trying to deactivate. The utility currently supports
|
||||
device-mapper devices, including LVM volumes.
|
||||
LVM volumes are handled directly using the \fBlvm\fP(8) command.
|
||||
Other device-mapper based devices are handled using the
|
||||
\fBdmsetup\fP(8) command.
|
||||
device-mapper devices (DM), including LVM volumes and
|
||||
software RAID MD devices. LVM volumes are handled directly
|
||||
using the \fBlvm\fP(8) command, the rest of device-mapper
|
||||
based devices are handled using the \fBdmsetup\fP(8) command.
|
||||
MD devices are handled using the \fBmdadm\fP(8) command.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-d ", " \-\-dmoption \ \fIdm_options\fP
|
||||
@ -88,4 +89,5 @@ of device-mapper devices in case the deactivation fails and force removal.
|
||||
.BR dmsetup (8),
|
||||
.BR lsblk (8),
|
||||
.BR lvm (8),
|
||||
.BR mdadm (8),
|
||||
.BR umount (8)
|
||||
|
@ -37,6 +37,7 @@ SYS_BLK_DIR='/sys/block'
|
||||
UMOUNT="/bin/umount"
|
||||
DMSETUP="@sbindir@/dmsetup"
|
||||
LVM="@sbindir@/lvm"
|
||||
MDADM="@sbindir@/mdadm"
|
||||
|
||||
if $UMOUNT --help | grep -- "--all-targets" >$DEV_DIR/null; then
|
||||
UMOUNT_OPTS="--all-targets "
|
||||
@ -47,6 +48,7 @@ else
|
||||
fi
|
||||
DMSETUP_OPTS=""
|
||||
LVM_OPTS=""
|
||||
MDADM_OPTS=""
|
||||
|
||||
LSBLK="/bin/lsblk -r --noheadings -o TYPE,KNAME,NAME,MOUNTPOINT"
|
||||
LSBLK_VARS="local devtype local kname local name local mnt"
|
||||
@ -259,6 +261,28 @@ deactivate_lvm () {
|
||||
fi
|
||||
}
|
||||
|
||||
deactivate_md () {
|
||||
local name=$(printf $name)
|
||||
test -b "$DEV_DIR/$name" || return 0
|
||||
test -z ${SKIP_DEVICE_LIST["$kname"]} || return 1
|
||||
|
||||
# Skip MD device deactivation if MD tools missing.
|
||||
test $MDADM_AVAILABLE -eq 0 && {
|
||||
add_device_to_skip_list
|
||||
return 1
|
||||
}
|
||||
|
||||
deactivate_holders "$DEV_DIR/$name" || return 1
|
||||
|
||||
echo -n " [MD]: deactivating $devtype device $kname... "
|
||||
if eval $MDADM $MDADM_OPTS -S "$name" $OUT $ERR; then
|
||||
echo "done"
|
||||
else
|
||||
echo "skipping"
|
||||
add_device_to_skip_list
|
||||
fi
|
||||
}
|
||||
|
||||
deactivate () {
|
||||
######################################################################
|
||||
# DEACTIVATION HOOKS FOR NEW DEVICE TYPES GO HERE! #
|
||||
@ -277,6 +301,8 @@ deactivate () {
|
||||
deactivate_lvm
|
||||
elif test "${kname:0:3}" = "dm-"; then
|
||||
deactivate_dm
|
||||
elif test "${kname:0:2}" = "md"; then
|
||||
deactivate_md
|
||||
fi
|
||||
}
|
||||
|
||||
@ -392,6 +418,7 @@ set_env() {
|
||||
UMOUNT_OPTS+="-v"
|
||||
DMSETUP_OPTS+="-vvvv"
|
||||
LVM_OPTS+="-vvvv"
|
||||
MDADM_OPTS+="-vv"
|
||||
else
|
||||
OUT="1>$DEV_DIR/null"
|
||||
fi
|
||||
@ -401,6 +428,12 @@ set_env() {
|
||||
else
|
||||
LVM_AVAILABLE=0
|
||||
fi
|
||||
|
||||
if test -f $MDADM; then
|
||||
MDADM_AVAILABLE=1
|
||||
else
|
||||
MDADM_AVAILABLE=0
|
||||
fi
|
||||
}
|
||||
|
||||
while test $# -ne 0; do
|
||||
|
Loading…
Reference in New Issue
Block a user