diff --git a/common/rc b/common/rc index 4688f236..6943f19f 100644 --- a/common/rc +++ b/common/rc @@ -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 [optional blocksize] _scratch_mkfs_sized() diff --git a/tests/generic/551 b/tests/generic/551 index a2a5b51d..a0dc9cd7 100755 --- a/tests/generic/551 +++ b/tests/generic/551 @@ -55,12 +55,18 @@ do_test() local size local off local truncsize + local total_size=0 + local avail_mem=`_available_memory_bytes` # the number of AIO write operation num_oper=$((RANDOM % 64 + 1)) for ((i=0; i