btrfs: fix async discard stall
authorPavel Begunkov <asml.silence@gmail.com>
Sun, 6 Dec 2020 15:56:20 +0000 (15:56 +0000)
committerDavid Sterba <dsterba@suse.com>
Fri, 18 Dec 2020 13:59:51 +0000 (14:59 +0100)
commitea9ed87c73e87e044b2c58d658eb4ba5216bc488
tree4fd227578fb8efa2fd0d614ecd4ff70822bc518a
parent675a4fc8f3149e93f35fb5739fd8d4764206ba0b
btrfs: fix async discard stall

Might happen that bg->discard_eligible_time was changed without
rescheduling, so btrfs_discard_workfn() wakes up earlier than that new
time, peek_discard_list() returns NULL, and all work halts and goes to
sleep without further rescheduling even there are block groups to
discard.

It happens pretty often, but not so visible from the userspace because
after some time it usually will be kicked off anyway by someone else
calling btrfs_discard_reschedule_work().

Fix it by continue rescheduling if block group discard lists are not
empty.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/discard.c