]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: call btrfs_try_granting_tickets when reserving space
authorJosef Bacik <josef@toxicpanda.com>
Tue, 21 Jul 2020 14:22:19 +0000 (10:22 -0400)
committerDavid Sterba <dsterba@suse.com>
Wed, 7 Oct 2020 10:06:51 +0000 (12:06 +0200)
If we have compression on we could free up more space than we reserved,
and thus be able to make a space reservation.  Add the call for this
scenario.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Tested-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c

index bc95f5f963fb1e37269faa86907e3ff0996d8557..c9d7465501a4759954b811eb13407f8dee116291 100644 (file)
@@ -2961,6 +2961,13 @@ int btrfs_add_reserved_bytes(struct btrfs_block_group *cache,
                                                      space_info, -ram_bytes);
                if (delalloc)
                        cache->delalloc_bytes += num_bytes;
+
+               /*
+                * Compression can use less space than we reserved, so wake
+                * tickets if that happens
+                */
+               if (num_bytes < ram_bytes)
+                       btrfs_try_granting_tickets(cache->fs_info, space_info);
        }
        spin_unlock(&cache->lock);
        spin_unlock(&space_info->lock);