From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH zfsonlinux 2/6] trim: determine if a device uses nvme transport with lsblk (Closes: #990745)
Date: Tue, 4 Oct 2022 15:47:59 +0200 [thread overview]
Message-ID: <20221004134803.3605742-3-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20221004134803.3605742-1-s.ivanov@proxmox.com>
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>
---
.../zfsutils-linux/usr/lib/zfs-linux/trim | 29 +++++++++++++++----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/debian/tree/zfsutils-linux/usr/lib/zfs-linux/trim b/debian/tree/zfsutils-linux/usr/lib/zfs-linux/trim
index 5b6305b0..91d00bb0 100755
--- a/debian/tree/zfsutils-linux/usr/lib/zfs-linux/trim
+++ b/debian/tree/zfsutils-linux/usr/lib/zfs-linux/trim
@@ -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.
--
2.30.2
next prev parent reply other threads:[~2022-10-04 13:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 13:47 [pve-devel] [PATCH zfsonlinux 0/6] update to ZFS 2.1.6 Stoiko Ivanov
2022-10-04 13:47 ` [pve-devel] [PATCH zfsonlinux 1/6] update zfs submodule to 2.1.6 and refresh patches Stoiko Ivanov
2022-10-04 13:47 ` Stoiko Ivanov [this message]
2022-10-04 13:48 ` [pve-devel] [PATCH zfsonlinux 3/6] Symlink zfs, zpool to /bin/ for non-root usage. (Closes: #979437) Stoiko Ivanov
2022-10-04 13:48 ` [pve-devel] [PATCH zfsonlinux 4/6] Symlink zpool_influxdb to /bin. (Closes: #1001446) Stoiko Ivanov
2022-10-04 13:48 ` [pve-devel] [PATCH zfsonlinux 5/6] debian/lintian-overrides: future-proof Stoiko Ivanov
2022-10-04 13:48 ` [pve-devel] [PATCH zfsonlinux 6/6] debian/zfs-initramfs.lintian-overrides add overrides file Stoiko Ivanov
2022-10-04 14:21 ` [pve-devel] applied-series: [PATCH zfsonlinux 0/6] update to ZFS 2.1.6 Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221004134803.3605742-3-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox