Re: [PATCH 12/23] btrfs: add flushing states for handling data reservations

David Sterba
2020-08-13T16:28:20Z

On Tue, Jul 21, 2020 at 10:22:23AM -0400, Josef Bacik wrote:
> 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>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> fs/btrfs/ctree.h | 2 ++
> fs/btrfs/space-info.c | 6 ++++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 4e882ae15eea..a181f4959a1d 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -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,

The new states are inserted between a comment that is there for the
FLUSH_ALL state. I'm not sure it's still valid or needs separate
comments and can't tell from looking at other patches in the series.

> BTRFS_RESERVE_FLUSH_ALL,