Skip to content

Commit 8c40fa1

Browse files
committed
zbd/rc: do not use invalid write pointer values by blkzone report
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] util-linux/util-linux@b032247 Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent f14914d commit 8c40fa1

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

  • tests/zbd

tests/zbd/rc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,27 @@ _get_blkzone_report() {
141141
fi
142142

143143
local _IFS=$IFS
144-
local -i loop=0
144+
local -i loop=0 cond type
145145
IFS=$' ,:'
146146
while read -r -a _tokens
147147
do
148148
ZONE_STARTS+=($((_tokens[1])))
149149
ZONE_LENGTHS+=($((_tokens[3])))
150150
ZONE_CAPS+=($((_tokens[cap_idx])))
151-
ZONE_WPTRS+=($((_tokens[wptr_idx])))
152-
ZONE_CONDS+=($((${_tokens[conds_idx]%\(*})))
153-
ZONE_TYPES+=($((${_tokens[type_idx]%\(*})))
151+
# The latest blkzone reports 'N/A' when write pointers are
152+
# invalid. In that case, do not handle them as numeric.
153+
cond=$((${_tokens[conds_idx]%\(*}))
154+
type=$((${_tokens[type_idx]%\(*}))
155+
if ((type == ZONE_TYPE_CONVENTIONAL ||
156+
(cond == ZONE_COND_READ_ONLY ||
157+
cond == ZONE_COND_FULL ||
158+
cond == ZONE_COND_OFFLINE))); then
159+
ZONE_WPTRS+=(-1)
160+
else
161+
ZONE_WPTRS+=($((_tokens[wptr_idx])))
162+
fi
163+
ZONE_CONDS+=("${cond}")
164+
ZONE_TYPES+=("${type}")
154165
if [[ ${ZONE_TYPES[-1]} -eq ${ZONE_TYPE_CONVENTIONAL} ]]; then
155166
(( NR_CONV_ZONES++ ))
156167
fi

0 commit comments

Comments
 (0)