mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +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 -
|
Version 1.02.110 -
|
||||||
======================================
|
======================================
|
||||||
|
Add support for recognition and deactivation of MD devices to blkdeactivate.
|
||||||
Move target status functions out of libdm-deptree.
|
Move target status functions out of libdm-deptree.
|
||||||
Correct use of max_write_behind parameter when generating raid target line.
|
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.
|
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
|
blkdeactivate utility deactivates block devices. If a device
|
||||||
is mounted, the utility can unmount it automatically before
|
is mounted, the utility can unmount it automatically before
|
||||||
trying to deactivate. The utility currently supports
|
trying to deactivate. The utility currently supports
|
||||||
device-mapper devices, including LVM volumes.
|
device-mapper devices (DM), including LVM volumes and
|
||||||
LVM volumes are handled directly using the \fBlvm\fP(8) command.
|
software RAID MD devices. LVM volumes are handled directly
|
||||||
Other device-mapper based devices are handled using the
|
using the \fBlvm\fP(8) command, the rest of device-mapper
|
||||||
\fBdmsetup\fP(8) command.
|
based devices are handled using the \fBdmsetup\fP(8) command.
|
||||||
|
MD devices are handled using the \fBmdadm\fP(8) command.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.BR \-d ", " \-\-dmoption \ \fIdm_options\fP
|
.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 dmsetup (8),
|
||||||
.BR lsblk (8),
|
.BR lsblk (8),
|
||||||
.BR lvm (8),
|
.BR lvm (8),
|
||||||
|
.BR mdadm (8),
|
||||||
.BR umount (8)
|
.BR umount (8)
|
||||||
|
@ -37,6 +37,7 @@ SYS_BLK_DIR='/sys/block'
|
|||||||
UMOUNT="/bin/umount"
|
UMOUNT="/bin/umount"
|
||||||
DMSETUP="@sbindir@/dmsetup"
|
DMSETUP="@sbindir@/dmsetup"
|
||||||
LVM="@sbindir@/lvm"
|
LVM="@sbindir@/lvm"
|
||||||
|
MDADM="@sbindir@/mdadm"
|
||||||
|
|
||||||
if $UMOUNT --help | grep -- "--all-targets" >$DEV_DIR/null; then
|
if $UMOUNT --help | grep -- "--all-targets" >$DEV_DIR/null; then
|
||||||
UMOUNT_OPTS="--all-targets "
|
UMOUNT_OPTS="--all-targets "
|
||||||
@ -47,6 +48,7 @@ else
|
|||||||
fi
|
fi
|
||||||
DMSETUP_OPTS=""
|
DMSETUP_OPTS=""
|
||||||
LVM_OPTS=""
|
LVM_OPTS=""
|
||||||
|
MDADM_OPTS=""
|
||||||
|
|
||||||
LSBLK="/bin/lsblk -r --noheadings -o TYPE,KNAME,NAME,MOUNTPOINT"
|
LSBLK="/bin/lsblk -r --noheadings -o TYPE,KNAME,NAME,MOUNTPOINT"
|
||||||
LSBLK_VARS="local devtype local kname local name local mnt"
|
LSBLK_VARS="local devtype local kname local name local mnt"
|
||||||
@ -259,6 +261,28 @@ deactivate_lvm () {
|
|||||||
fi
|
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 () {
|
deactivate () {
|
||||||
######################################################################
|
######################################################################
|
||||||
# DEACTIVATION HOOKS FOR NEW DEVICE TYPES GO HERE! #
|
# DEACTIVATION HOOKS FOR NEW DEVICE TYPES GO HERE! #
|
||||||
@ -277,6 +301,8 @@ deactivate () {
|
|||||||
deactivate_lvm
|
deactivate_lvm
|
||||||
elif test "${kname:0:3}" = "dm-"; then
|
elif test "${kname:0:3}" = "dm-"; then
|
||||||
deactivate_dm
|
deactivate_dm
|
||||||
|
elif test "${kname:0:2}" = "md"; then
|
||||||
|
deactivate_md
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,6 +418,7 @@ set_env() {
|
|||||||
UMOUNT_OPTS+="-v"
|
UMOUNT_OPTS+="-v"
|
||||||
DMSETUP_OPTS+="-vvvv"
|
DMSETUP_OPTS+="-vvvv"
|
||||||
LVM_OPTS+="-vvvv"
|
LVM_OPTS+="-vvvv"
|
||||||
|
MDADM_OPTS+="-vv"
|
||||||
else
|
else
|
||||||
OUT="1>$DEV_DIR/null"
|
OUT="1>$DEV_DIR/null"
|
||||||
fi
|
fi
|
||||||
@ -401,6 +428,12 @@ set_env() {
|
|||||||
else
|
else
|
||||||
LVM_AVAILABLE=0
|
LVM_AVAILABLE=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test -f $MDADM; then
|
||||||
|
MDADM_AVAILABLE=1
|
||||||
|
else
|
||||||
|
MDADM_AVAILABLE=0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
while test $# -ne 0; do
|
while test $# -ne 0; do
|
||||||
|
Loading…
Reference in New Issue
Block a user