On 1.02.20 г. 0:36 ч., Josef Bacik wrote:
> Now that we have the data ticketing stuff in place, move normal data
> reservations to use an async reclaim helper to satisfy tickets. Before
> we could have multiple tasks race in and both allocate chunks, resulting
> in more data chunks than we would necessarily need. Serializing these
> allocations and making a single thread responsible for flushing will
> only allocate chunks as needed, as well as cut down on transaction
> commits and other flush related activities.
>
> Priority reservations will still work as they have before, simply
> trying to allocate a chunk until they can make their reservation.
>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx> but look below for one
minor nit.
> ---
> fs/btrfs/ctree.h | 3 +-
> fs/btrfs/disk-io.c | 2 +-
> fs/btrfs/space-info.c | 123 ++++++++++++++++++++++++++++++------------
> 3 files changed, 91 insertions(+), 37 deletions(-)
>
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 865b24a1759e..709823a23c62 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -493,7 +493,7 @@ enum btrfs_orphan_cleanup_state {
> ORPHAN_CLEANUP_DONE = 2,
> };
>
> -void btrfs_init_async_reclaim_work(struct work_struct *work);
> +void btrfs_init_async_reclaim_work(struct btrfs_fs_info *fs_info);
nit: This doesn't bring much value apart from introducing yet another
function, I'd rather have the 2 INIT_WORK calls open coded in init_fs_info.
>
> /* fs_info */
> struct reloc_control;
> @@ -917,6 +917,7 @@ struct btrfs_fs_info {
>
> /* Used to reclaim the metadata space in the background. */
> struct work_struct async_reclaim_work;
> + struct work_struct async_data_reclaim_work;
>
> spinlock_t unused_bgs_lock;
> struct list_head unused_bgs;
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 56d0a24aec74..825242f5c3f7 100644