After the recent change in util-linux [1], the 'blkzone report' command no longer reports numeric values for write pointers when the write pointers are invalid. Instead, it reports the sting 'N/A'. Currently, _get_blkzone_report() assumes that the write pointer values are numeric even when the values are invalid. Then it evaluates 'N/A' as numeric and triggers arithmetic operation failures. To avoid the failures, check zone type and zone condition. If the zone type and condition indicate that the write pointer is invalid, do not use the blkzone report string. Instead, use -1 as the write pointer value to indicate the value is invalid. Link: [1] https://github.com/util-linux/util-linux/commit/b032247f48d8b6a13bf8541eb663c779e448f568 Signed-off-by: Shin'ichiro Kawasaki --- tests/zbd/rc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/zbd/rc b/tests/zbd/rc index 570928b..32a80a7 100644 --- a/tests/zbd/rc +++ b/tests/zbd/rc @@ -141,16 +141,27 @@ _get_blkzone_report() { fi local _IFS=$IFS - local -i loop=0 + local -i loop=0 cond type IFS=$' ,:' while read -r -a _tokens do ZONE_STARTS+=($((_tokens[1]))) ZONE_LENGTHS+=($((_tokens[3]))) ZONE_CAPS+=($((_tokens[cap_idx]))) - ZONE_WPTRS+=($((_tokens[wptr_idx]))) - ZONE_CONDS+=($((${_tokens[conds_idx]%\(*}))) - ZONE_TYPES+=($((${_tokens[type_idx]%\(*}))) + # The latest blkzone reports 'N/A' as write pointers for full + # zones. In that case, do not handle it as numeric. + cond=$((${_tokens[conds_idx]%\(*})) + type=$((${_tokens[type_idx]%\(*})) + if ((type == ZONE_TYPE_CONVENTIONAL || + (cond == ZONE_COND_READ_ONLY || + cond == ZONE_COND_FULL || + cond == ZONE_COND_OFFLINE))); then + ZONE_WPTRS+=(-1) + else + ZONE_WPTRS+=($((_tokens[wptr_idx]))) + fi + ZONE_CONDS+=("${cond}") + ZONE_TYPES+=("${type}") if [[ ${ZONE_TYPES[-1]} -eq ${ZONE_TYPE_CONVENTIONAL} ]]; then (( NR_CONV_ZONES++ )) fi -- 2.53.0