Lines Matching +full:device +full:- +full:level

20 # Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
30 ls /sys/block/${disk}/device/scsi_device | cut -d : -f 1
43 if [[ -z $hostnum ]]; then
45 log_must eval "echo '- - -' > $host/scan"
50 "echo '- - -' > /sys/class/scsi_host/host$hostnum/scan"
58 # arguments to typically be a block device pathname. This is useful when
59 # checking waiting on a specific device to settle rather than triggering
64 # strangeness in a malfunctioning device that isn't related to the devices
77 typeset elapsed=$((SECONDS - start))
81 if [[ ${#@} -eq 0 ]]; then
89 typeset -i i
94 if ! [[ -e $dev ]]; then
107 # Check if the given device is physical device
109 function is_physical_device #device
111 typeset device=${1#$DEV_DSKDIR/}
112 device=${device#$DEV_RDSKDIR/}
115 is_disk_device "$DEV_DSKDIR/$device" && \
116 [ -f /sys/module/loop/parameters/max_part ]
118 is_disk_device "$DEV_DSKDIR/$device" && \
119 echo $device | grep -qE \
120 -e '^a?da[0-9]+$' \
121 -e '^md[0-9]+$' \
122 -e '^mfid[0-9]+$' \
123 -e '^nda[0-9]+$' \
124 -e '^nvd[0-9]+$' \
125 -e '^vtbd[0-9]+$'
127 echo $device | grep -qE "^c[0-F]+([td][0-F]+)+$"
132 # Check if the given device is a real device (ie SCSI device)
137 [[ -z $disk ]] && log_fail "No argument for disk given."
140 lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \
141 grep -q disk
146 # Check if the given device is a loop device
151 [[ -z $disk ]] && log_fail "No argument for disk given."
154 lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \
155 grep -q loop
161 # Check if the given device is a multipath device and if there is a symbolic
162 # link to a device mapper and to a disk
166 # Check if the given device is a gmultipath device.
174 [[ -z $disk ]] && log_fail "No argument for disk given."
177 if lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \
178 grep -q mpath; then
191 # Check if the given path is the appropriate sort of device special node.
199 test -c $path
201 test -b $path
206 # on whether the device is a real, multipath, or loop device.
213 typeset -i i=0
235 # checks first disk to determine device directory
238 # multipath device = /dev/mapper (linux)
243 typeset -i i=0
263 # Get the directory path of given device
265 function get_device_dir #device
267 typeset device=$1
269 if ! is_freebsd && ! is_physical_device $device; then
270 if [[ $device != "/" ]]; then
271 device=${device%/*}
273 if is_disk_device "$DEV_DSKDIR/$device"; then
274 device="$DEV_DSKDIR"
276 echo $device
285 function get_persistent_disk_name #device
287 typeset device=$1
290 if is_real_device $device; then
291 udevadm info -q all -n $DEV_DSKDIR/$device \
292 | awk '/disk\/by-id/ {print $2; exit}' | cut -d/ -f3-
293 elif is_mpath_device $device; then
294 udevadm info -q all -n $DEV_DSKDIR/$device \
295 | awk '/disk\/by-id\/dm-uuid/ {print $2; exit}' \
296 | cut -d/ -f3
298 echo $device
301 echo $device
318 [[ -z $disk ]] || [[ -z $state ]] && \
323 dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)"
325 while [[ -n $dep ]]; do
327 if lsscsi | grep -qF $dep; then
329 dep_dir+="/slaves/${dep}/device"
334 if lsscsi | grep -qF $dep; then
342 if lsscsi | grep -qF $disk; then
343 dev_state="/sys/block/$disk/device/state"
344 dev_delete="/sys/block/$disk/device/delete"
347 if lsscsi | grep -qF $disk; then
358 dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)"
360 if lsscsi | grep -qF $dep; then
365 typeset -i retries=0
366 while ! lsscsi | grep -qF $disk; do
416 [[ -z $devsize ]] || [[ -z $hosts ]] || [[ -z $tgts ]] || \
417 [[ -z $luns ]] || [[ -z $blksz ]] && \
437 modprobe -n scsi_debug ||
439 if lsmod | grep -q scsi_debug; then
446 if ! lsscsi | grep -q scsi_debug; then
458 log_must_retry "in use" 5 modprobe -r scsi_debug
462 # Get scsi_debug device name.
463 # Returns basename of scsi_debug device (for example "sdb").
468 val=$(lsscsi | awk '/scsi_debug/ {print $6; exit}' | cut -d/ -f3)
471 if [ "$val" != "-" ] ; then
490 zpool status -P $testpool | awk -v d="$devdir" '$1 ~ d {sub(d "/", ""); printf("%s ", $1)}'
496 # Write to standard out giving the level, device name, offset and length
499 # device is listed, as the levels, blocks and offsets will be the same
501 # or non-redundant pools, not raidz.
510 [[ -f $input_file ]] || log_fail "Couldn't find $input_file"
512 typeset ds="$(zfs list -H -o name $input_file)"
520 # The vdev bits in a DVA refer to the top level vdev id.
523 eval $(zdb -C $pool | awk '
524 BEGIN { printf "typeset -a VDEV_MAP;" }
527 match(s, /\[[0-9]*\]/)
531 # left a top level vdev
539 # entering a top level vdev
542 printf "typeset -a VDEV_MAP%s;", id
545 # entering a nested vdev (e.g. child of a top level mirror)
551 # The awk below parses the output of zdb, printing out the level
558 typeset level vdev path offset length
560 zdb -dddddd $ds $objnum | awk '
563 level = $2
567 print level, int(dva[1]), "0x"dva[2], "0x"dva[3]
574 while read level vdev offset length; do
576 echo "$level $path $(( ($offset + (4<<20)) / 512 ))" \
585 typeset corrupt_level="L${2:-0}"
586 typeset level path offset length
588 [[ -f $input_file ]] || log_fail "Couldn't find $input_file"
591 # Temporarily allow corrupting an inuse device.
592 debugflags=$(sysctl -n kern.geom.debugflags)
597 while read level path offset length; do
598 if [[ $level = $corrupt_level ]]; then
616 typeset -a offsets=("$((128*1024 - 32))" \
617 "$(($label_size + (128*1024 - 32)))" \
618 "$(($vdev_size - $label_size - (128*1024 + 32)))" \
619 "$(($vdev_size - (128*1024 + 32)))")