Skip to content

Commit

Permalink
Correct NVMe capacity check in disk_resize.
Browse files Browse the repository at this point in the history
Appears for some device NVM Capacity is not equal to Size multiplied
by sector size, but is a pretty arbitrary value.  Use it directly.
  • Loading branch information
amotin committed Jul 15, 2021
1 parent 3fd4699 commit f19ea9a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/freenas/usr/local/sbin/disk_resize
Expand Up @@ -225,8 +225,8 @@ nvme)
# Make sure we have enough capacity to not fail after delete.
if [ -n "${size}" ]; then
ucap=`nvmecontrol identify ${ctrlr} | awk '/Unallocated NVM Capacity:/ { print $4 }'`
osize=`nvmecontrol identify -n ${nsid} ${ctrlr} | awk '/^Size:/ { print $2}'`
if [ "${size}" -gt $((${ucap} / ${sector} + ${osize})) ]; then
ocap=`nvmecontrol identify -n ${nsid} ${ctrlr} | awk '/^NVM Capacity:/ { print $3}'`
if [ "${size}" -gt $(((${ucap} + ${ocap}) / ${sector})) ]; then
echo "Not enough capacity."
exit 1
fi
Expand Down

0 comments on commit f19ea9a

Please sign in to comment.