btrfs: add flushing states for handling data reservations
authorJosef Bacik <josef@toxicpanda.com>
Tue, 21 Jul 2020 14:22:23 +0000 (10:22 -0400)
committerDavid Sterba <dsterba@suse.com>
Wed, 7 Oct 2020 10:06:52 +0000 (12:06 +0200)
Currently the way we do data reservations is by seeing if we have enough
space in our space_info.  If we do not and we're a normal inode we'll

1) Attempt to force a chunk allocation until we can't anymore.
2) If that fails we'll flush delalloc, then commit the transaction, then
   run the delayed iputs.

If we are a free space inode we're only allowed to force a chunk
allocation.  In order to use the normal flushing mechanism we need to
encode this into a flush state array for normal inodes.  Since both will
start with allocating chunks until the space info is full there is no
need to add this as a flush state, this will be handled specially.

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>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/space-info.c

index e2ec4f0..098f006 100644 (file)
@@ -2592,6 +2592,8 @@ enum btrfs_reserve_flush_enum {
         *
         * Can be interruped by fatal signal.
         */
+       BTRFS_RESERVE_FLUSH_DATA,
+       BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE,
        BTRFS_RESERVE_FLUSH_ALL,
 
        /*
index 6a9bc5c..980b6f6 100644 (file)
@@ -1017,6 +1017,12 @@ static const enum btrfs_flush_state evict_flush_states[] = {
        COMMIT_TRANS,
 };
 
+static const enum btrfs_flush_state data_flush_states[] = {
+       FLUSH_DELALLOC_WAIT,
+       COMMIT_TRANS,
+       RUN_DELAYED_IPUTS,
+};
+
 static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
                                struct btrfs_space_info *space_info,
                                struct reserve_ticket *ticket,