mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Various ZED fixes
* Teach ZED to handle spares usingi the configured ashift: if the zpool 'ashift' property is set then ZED should use its value when kicking in a hotspare; with this change 512e disks can be used as spares for VDEVs that were created with ashift=9, even if ZFS natively detects them as 4K block devices. * Introduce an additional auto_spare test case which verifies that in the face of multiple device failures an appropiate number of spares are kicked in. * Fix zed_stop() in "libtest.shlib" which did not correctly wait the target pid. * Fix ZED crashing on startup caused by a race condition in libzfs when used in multi-threaded context. * Convert ZED over to using the tpool library which is already present in the Illumos FMA code. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes #2562 Closes #6858
This commit is contained in:
@@ -353,16 +353,35 @@ function insert_disk #disk scsi_host
|
||||
|
||||
#
|
||||
# Load scsi_debug module with specified parameters
|
||||
# $blksz can be either one of: < 512b | 512e | 4Kn >
|
||||
#
|
||||
function load_scsi_debug # dev_size_mb add_host num_tgts max_luns
|
||||
function load_scsi_debug # dev_size_mb add_host num_tgts max_luns blksz
|
||||
{
|
||||
typeset devsize=$1
|
||||
typeset hosts=$2
|
||||
typeset tgts=$3
|
||||
typeset luns=$4
|
||||
typeset blksz=$5
|
||||
|
||||
[[ -z $devsize ]] || [[ -z $hosts ]] || [[ -z $tgts ]] || \
|
||||
[[ -z $luns ]] && log_fail "Arguments invalid or missing"
|
||||
[[ -z $luns ]] || [[ -z $blksz ]] && \
|
||||
log_fail "Arguments invalid or missing"
|
||||
|
||||
case "$5" in
|
||||
'512b')
|
||||
typeset sector=512
|
||||
typeset blkexp=0
|
||||
;;
|
||||
'512e')
|
||||
typeset sector=512
|
||||
typeset blkexp=3
|
||||
;;
|
||||
'4Kn')
|
||||
typeset sector=4096
|
||||
typeset blkexp=0
|
||||
;;
|
||||
*) log_fail "Unsupported blksz value: $5" ;;
|
||||
esac
|
||||
|
||||
if is_linux; then
|
||||
modprobe -n scsi_debug
|
||||
@@ -375,7 +394,8 @@ function load_scsi_debug # dev_size_mb add_host num_tgts max_luns
|
||||
log_fail "scsi_debug module already installed"
|
||||
else
|
||||
log_must modprobe scsi_debug dev_size_mb=$devsize \
|
||||
add_host=$hosts num_tgts=$tgts max_luns=$luns
|
||||
add_host=$hosts num_tgts=$tgts max_luns=$luns \
|
||||
sector_size=$sector physblk_exp=$blkexp
|
||||
block_device_wait
|
||||
lsscsi | egrep scsi_debug > /dev/null
|
||||
if (($? == 1)); then
|
||||
@@ -385,6 +405,16 @@ function load_scsi_debug # dev_size_mb add_host num_tgts max_luns
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Unload scsi_debug module, if needed.
|
||||
#
|
||||
function unload_scsi_debug
|
||||
{
|
||||
if lsmod | grep scsi_debug >/dev/null; then
|
||||
log_must modprobe -r scsi_debug
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Get scsi_debug device name.
|
||||
# Returns basename of scsi_debug device (for example "sdb").
|
||||
|
||||
@@ -3158,13 +3158,25 @@ function zed_stop
|
||||
if [[ -f ${ZEDLET_DIR}/zed.pid ]]; then
|
||||
zedpid=$(cat ${ZEDLET_DIR}/zed.pid)
|
||||
kill $zedpid
|
||||
wait $zedpid
|
||||
while ps -p $zedpid > /dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
rm -f ${ZEDLET_DIR}/zed.pid
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Drain all zevents
|
||||
#
|
||||
function zed_events_drain
|
||||
{
|
||||
while [ $(zpool events -H | wc -l) -ne 0 ]; do
|
||||
sleep 1
|
||||
zpool events -c >/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Check is provided device is being active used as a swap device.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user