generic/551: Adjust the size argument for aio-dio-write-verify
[xfstests-dev.git] / tests / generic / 551
index a2a5b51d66e3155c279a19c556b18502936e1616..a0dc9cd7fd11de091ebb662f143bed78ec9da91f 100755 (executable)
@@ -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<num_oper; i++)); do
                size=$(((RANDOM % max_io_size_b + 1) * diosize))
+               total_size=$((total_size + size*2))
+               if [[ $total_size -ge $avail_mem ]]; then
+                       break
+               fi
                off=$((RANDOM % max_io_size_b * diosize))
                oper_list="$oper_list -a size=$size,off=$off"
        done