generic/551: Adjust the size argument for aio-dio-write-verify

generic/551 sometimes fails because it's killed by OOM killer.
That is because aio-dio-write-verify, which is called by
generic/551, tries to allocate memory even though the total
allocation size exceeds the available memory.

aio-dio-write-verify allocates memory according to the 'size'
argument, and generic/551 passes the argument.

Stop adding the argument when the total size is exceeds
the available memory.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Masayoshi Mizuma
2019-11-18 12:40:37 -05:00
committed by Eryu Guan
parent 6b04ed0545
commit 9a09e4ec72
2 changed files with 17 additions and 0 deletions
+11
View File
@@ -910,6 +910,17 @@ _free_memory_bytes()
free -b | grep ^Mem | awk '{print $4}'
}
_available_memory_bytes()
{
nf=`free -b | grep ^Mem | awk '{print NF}'`
if [[ nf -lt 7 ]]; then
# Doesn't have available field. Fallback.
_free_memory_bytes
else
free -b | grep ^Mem | awk '{print $7}'
fi
}
# Create fs of certain size on scratch device
# _scratch_mkfs_sized <size in bytes> [optional blocksize]
_scratch_mkfs_sized()