Now that we no longer partially fill tickets we need to rework
wake_all_tickets to call btrfs_try_to_wakeup_tickets() in order to see
if any subsequent tickets are able to be satisfied.  If our tickets_id
changes we know something happened and we can keep flushing.

Signed-off-by: Josef Bacik <jo...@toxicpanda.com>
---
 fs/btrfs/space-info.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 8a1c7ada67cb..163400a39e81 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -676,19 +676,22 @@ static inline int need_do_async_reclaim(struct 
btrfs_fs_info *fs_info,
                !test_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state));
 }
 
-static bool wake_all_tickets(struct list_head *head)
+static bool wake_all_tickets(struct btrfs_fs_info *fs_info,
+                            struct btrfs_space_info *space_info)
 {
        struct reserve_ticket *ticket;
+       u64 tickets_id = space_info->tickets_id;
 
-       while (!list_empty(head)) {
-               ticket = list_first_entry(head, struct reserve_ticket, list);
+       while (!list_empty(&space_info->tickets) &&
+              tickets_id == space_info->tickets_id) {
+               ticket = list_first_entry(&space_info->tickets,
+                                         struct reserve_ticket, list);
                list_del_init(&ticket->list);
                ticket->error = -ENOSPC;
                wake_up(&ticket->wait);
-               if (ticket->bytes != ticket->orig_bytes)
-                       return true;
+               btrfs_try_to_wakeup_tickets(fs_info, space_info);
        }
-       return false;
+       return (tickets_id != space_info->tickets_id);
 }
 
 /*
@@ -756,7 +759,7 @@ static void btrfs_async_reclaim_metadata_space(struct 
work_struct *work)
                if (flush_state > COMMIT_TRANS) {
                        commit_cycles++;
                        if (commit_cycles > 2) {
-                               if (wake_all_tickets(&space_info->tickets)) {
+                               if (wake_all_tickets(fs_info, space_info)) {
                                        flush_state = FLUSH_DELAYED_ITEMS_NR;
                                        commit_cycles--;
                                } else {
-- 
2.21.0

Reply via email to