fsx: fix infinite/too long loops when generating ranges for clone operations
authorFilipe Manana <fdmanana@suse.com>
Mon, 20 Apr 2020 17:09:05 +0000 (18:09 +0100)
committerEryu Guan <guaneryu@gmail.com>
Sun, 10 May 2020 12:33:43 +0000 (20:33 +0800)
commitc8b5a737509b386790ca712b175229dc77863747
tree227879070e7b9421ece576400c519b74736cf283
parent15898a13d6d290740329455e6248722f5c5c6288
fsx: fix infinite/too long loops when generating ranges for clone operations

While running generic/457 I've had fsx taking a lot of CPU time and not
making any progress for over an hour. Attaching gdb to the fsx process
revealed that fsx was in the loop that generates the ranges for a clone
operation, in particular the loop seemed to never end because the range
defined by 'offset2' kept overlapping with the range defined by 'offset'.
So far this happened two times in one of my test VMs with generic/457.

Fix this by breaking out of the loop after trying 30 times, like we
currently do for dedupe operations, which results in logging the operation
as skipped.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
ltp/fsx.c