local keep_alive_tmo=""
local reconnect_delay=""
local ctrl_loss_tmo=""
+ local no_wait=false
+ local i
while [[ $# -gt 0 ]]; do
case $1 in
ctrl_loss_tmo="$2"
shift 2
;;
+ --no-wait)
+ no_wait=true
+ shift 1
+ ;;
*)
positional_args+=("$1")
shift
fi
nvme connect "${ARGS[@]}" 2> /dev/null
+
+ # Wait until device file and uuid/wwid sysfs attributes get ready for
+ # all namespaces.
+ if [[ ${no_wait} = false ]]; then
+ udevadm settle
+ for ((i = 0; i < 10; i++)); do
+ _nvme_ns_ready "${subsysnqn}" && return
+ sleep .1
+ done
+ fi
+}
+
+_nvme_ns_ready() {
+ local subsysnqn="${1}"
+ local ns_path ns_id dev
+ local cfs_path="${NVMET_CFS}/subsystems/$subsysnqn"
+
+ dev=$(_find_nvme_dev "$subsysnqn")
+ for ns_path in "${cfs_path}/namespaces/"*; do
+ ns_id=${ns_path##*/}
+ if [[ ! -b /dev/${dev}n${ns_id} ||
+ ! -e /sys/block/${dev}n${ns_id}/uuid ||
+ ! -e /sys/block/${dev}n${ns_id}/wwid ]]; then
+ return 1
+ fi
+ done
+ return 0
}
_nvme_discover() {
subsysnqn="$(cat "/sys/class/nvme/${dev}/subsysnqn")"
if [[ "$subsysnqn" == "$subsys" ]]; then
echo "$dev"
- for ((i = 0; i < 10; i++)); do
- if [[ -e /sys/block/$dev/uuid &&
- -e /sys/block/$dev/wwid ]]; then
- return
- fi
- sleep .1
- done
fi
done
}
local trtype=$1
local subsys_name=$2
- _nvme_connect_subsys "${trtype}" "${subsys_name}" || return
+ _nvme_connect_subsys "${trtype}" "${subsys_name}" --no-wait || return
nsdev=$(_find_nvme_passthru_loop_dev "${subsys_name}")
# The following tests can race with the creation