Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZTS: Remove non-standard awk hex numbers usage #16892

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions tests/zfs-tests/include/blkdev.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -556,27 +556,15 @@ function list_file_blocks # input_file
# 512B blocks for ease of use with dd.
#
typeset level vdev path offset length
if awk -n '' 2>/dev/null; then
# gawk needs -n to decode hex
AWK='awk -n'
else
AWK='awk'
fi
sync_all_pools true
zdb -dddddd $ds $objnum | $AWK -v pad=$((4<<20)) -v bs=512 '
zdb -dddddd $ds $objnum | awk '
/^$/ { looking = 0 }
looking {
level = $2
field = 3
while (split($field, dva, ":") == 3) {
# top level vdev id
vdev = int(dva[1])
# offset + 4M label/boot pad in 512B blocks
offset = (int("0x"dva[2]) + pad) / bs
# length in 512B blocks
len = int("0x"dva[3]) / bs

print level, vdev, offset, len
print level, int(dva[1]), "0x"dva[2], "0x"dva[3]

++field
}
Expand All @@ -585,7 +573,8 @@ function list_file_blocks # input_file
' | \
while read level vdev offset length; do
for path in ${VDEV_MAP[$vdev][@]}; do
echo "$level $path $offset $length"
echo "$level $path $(( ($offset + (4<<20)) / 512 ))" \
"$(( $length / 512 ))"
done
done 2>/dev/null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,16 @@ log_must zpool export $TESTPOOL1
log_must set_tunable64 METASLAB_DEBUG_LOAD 1
log_note "Starting zpool import in background at" $(date +'%H:%M:%S')
zpool import -d $DEVICE_DIR -f $guid &
pid=$!

#
# capture progress until import is finished
#
log_note waiting for pid $pid to exit
kstat import_progress
while [[ -d /proc/"$pid" ]]; do
while [[ -n $(jobs) ]]; do
line=$(kstat import_progress | grep -v pool_guid)
if [[ -n $line ]]; then
echo $line
fi
if [[ -f /$TESTPOOL1/fs/00 ]]; then
break;
fi
sleep 0.0001
done
log_note "zpool import completed at" $(date +'%H:%M:%S')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function cleanup
log_onexit cleanup

log_must zfs create -o recsize=8k $sendfs
log_must dd if=/dev/urandom of=/$sendfs/file bs=1024k count=2048
log_must dd if=/dev/urandom of=/$sendfs/file bs=1024k count=1024
log_must zfs snapshot $sendfs@init
log_must zfs clone $sendfs@init $clone
log_must stride_dd -i /dev/urandom -o /$clone/file -b 8192 -s 2 -c 7226
Expand Down
Loading