1#!/bin/sh 2 3# Helpers for exercising GEOM classes on top of a gzoned provider. Source this 4# in addition to geom_subr.sh. 5 6# Create a vnode-backed md large enough for four 256m zones. gzoned reserves 7# space at the end of the provider for its metadata block and zone table, so an 8# exact multiple of the zone size (1024m) would lose a zone. 9zoned_backing_md() 10{ 11 atf_check truncate -s 1025m backing_file 12 attach_md md -t vnode -f backing_file 13} 14 15# Set up a gzoned provider on a fresh backing md. Any argument is passed to 16# gzoned create as its conventional zone specification. 17zoned_attach_md() 18{ 19 local conv=$1 20 21 zoned_backing_md 22 atf_check gzoned create -s 256m ${conv:+-c ${conv}} ${md} 23} 24 25# Number of zones on $1 matching the report option $2, e.g. "nonwp". 26zoned_zone_count() 27{ 28 zonectl -d $1 -c rz -o $2 -P summary | awk '/zones,/ {print $1}' 29} 30 31# Write pointer LBA of the zone containing LBA $2 on $1. 32zoned_zone_wp() 33{ 34 zonectl -d $1 -c rz -l $2 -P script | \ 35 awk -F',' 'NR == 1 {gsub(/ /, "", $3); print $3}' 36} 37 38# Start LBA of zone number $2 on $1. 39zoned_zone_start() 40{ 41 zonectl -d $1 -c rz -P script | \ 42 awk -F',' -v n=$(($2 + 1)) 'NR == n {gsub(/ /, "", $1); print $1}' 43} 44