[PATCH blktests v1 17/18] nvme: don't assume namespace id
Daniel Wagner
dwagner at suse.de
Thu Mar 21 03:19:39 PDT 2024
On Thu, Mar 21, 2024 at 10:47:26AM +0100, Daniel Wagner wrote:
--- a/tests/nvme/029
> +++ b/tests/nvme/029
> @@ -53,16 +53,12 @@ test() {
>
> _setup_nvmet
>
> - local nvmedev
> local reset_nr_hugepages=false
>
> _nvmet_target_setup
>
> _nvme_connect_subsys
>
> - nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
> - _check_uuid "${nvmedev}"
> -
> # nvme-cli may fail to allocate linear memory for rather large IO buffers.
> # Increase nr_hugepages to allow nvme-cli to try the linear memory allocation
> # from HugeTLB pool.
> @@ -72,7 +68,7 @@ test() {
> reset_nr_hugepages=true
> fi
>
> - local dev="/dev/${nvmedev}n1"
> + local dev="/dev/$(_find_nvme_ns "${def_subsys_uuid}")"
make check complains here, the declaration and assignment should be a
separate step. I've fixed this up
> +_find_nvme_ns() {
> + local subsys_uuid=$1
> + local uuid
> + local ns
> +
> + for ns in "/sys/block/nvme"* ; do
> + # ignore nvme channel block devices
> + if ! [[ "${ns}" =~ nvme[0-9]+n[0-9]+ ]]; then
> + continue
> + fi
> + [ -e "${ns}/uuid" ] || continue
> + uuid=$(cat "${ns}/uuid")
> + if [[ "${subsys_uuid}" == "${uuid}" ]]; then
> + echo "$(basename ${ns})"
The echo is not necessary, I've dropped it.
More information about the Linux-nvme
mailing list