OSDN Git Service

btrfs: run btrfs_try_granting_tickets if a priority ticket fails
authorJosef Bacik <josef@toxicpanda.com>
Fri, 13 Mar 2020 19:58:09 +0000 (15:58 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 May 2020 09:25:23 +0000 (11:25 +0200)
commit42a72cb75374634ef714514b4742a8844391fd9e
tree17eedf40d5d3299db2d71a5db465d7821c1feb57
parent666daa9f977d46010e2597a3b4f6524ba4d28129
btrfs: run btrfs_try_granting_tickets if a priority ticket fails

With normal tickets we could have a large reservation at the front of
the list that is unable to be satisfied, but a smaller ticket later on
that can be satisfied.  The way we handle this is to run
btrfs_try_granting_tickets() in maybe_fail_all_tickets().

However no such protection exists for priority tickets.  Fix this by
handling it in handle_reserve_ticket().  If we've returned after
attempting to flush space in a priority related way, we'll still be on
the priority list and need to be removed.

We rely on the flushing to free up space and wake the ticket, but if
there is not enough space to reclaim _but_ there's enough space in the
space_info to handle subsequent reservations then we would have gotten
an ENOSPC erroneously.

Address this by catching where we are still on the list, meaning we were
a priority ticket, and removing ourselves and then running
btrfs_try_granting_tickets().  This will handle this particular corner
case.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Tested-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/space-info.c