trim: determine if a device uses nvme transport with lsblk (Closes: #990745)
Thanks to Miao Wang for get_transp() function (cherry picked from debian-upstream[0] commit 1f5433b15e4f7c823983bb90390c4b023f3d1948) [0] https://salsa.debian.org/zfsonlinux-team/zfs Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
parent
8f586181c6
commit
68b54bb663
@ -26,14 +26,33 @@ trim_if_not_already_trimming () {
|
||||
fi
|
||||
}
|
||||
|
||||
get_transp () {
|
||||
local dev="$1"
|
||||
local par_dev="$dev"
|
||||
local pd
|
||||
while true; do
|
||||
pd=$(lsblk -dnr -o PKNAME "$par_dev")
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return $?
|
||||
fi
|
||||
if [ -z "$pd" ]; then
|
||||
break
|
||||
else
|
||||
par_dev="/dev/$pd"
|
||||
fi
|
||||
done
|
||||
lsblk -dnr -o TRAN "$par_dev"
|
||||
}
|
||||
|
||||
zpool_is_nvme_only () {
|
||||
zpool=$1
|
||||
# get a list of devices attached to the specified zpool
|
||||
zpool list -vHPL "${zpool}" |
|
||||
awk -F'\t' '$2 ~ /^\/dev\// {
|
||||
if($2 !~ /^\/dev\/nvme/)
|
||||
exit 1
|
||||
}'
|
||||
for x in $(zpool list -vHPL "${zpool}" |\
|
||||
awk -F'\t' '{if($2 ~ /^\/dev\//) print $2}'); do
|
||||
if [ "$(get_transp $x)" != "nvme" ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# TRIM all healthy pools that are not already trimming as per their configs.
|
||||
|
Loading…
Reference in New Issue
Block a user