On 16.08.19 г. 17:19 ч., Josef Bacik wrote:
> Now that btrfs_space_info_add_old_bytes simply checks if we can make the
> reservation and updates bytes_may_use, there's no reason to have both
> helpers in place. Factor out the ticket wakeup logic into it's own
> helper, make btrfs_space_info_add_old_bytes() update bytes_may_use and
> then call the wakeup helper, and replace all calls to
> btrfs_space_info_add_new_bytes() with the wakeup helper.
>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
Generally looks good and much nicer than before, one small nit below,
when fixed you can add:
Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx>
> ---
> fs/btrfs/extent-tree.c | 4 ++--
> fs/btrfs/space-info.c | 53 +++---------------------------------------
> fs/btrfs/space-info.h | 19 ++++++++++-----
> 3 files changed, 18 insertions(+), 58 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 32f9473c8426..08c6fcfc418d 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2863,8 +2863,8 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
> spin_unlock(&global_rsv->lock);
> /* Add to any tickets we may have */
> if (len)
> - btrfs_space_info_add_new_bytes(fs_info,
> - space_info, len);
> + btrfs_try_to_wakeup_tickets(fs_info,
> + space_info);
> }
> spin_unlock(&space_info->lock);
> }
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index 5f123b36fdcd..8a1c7ada67cb 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -131,9 +131,7 @@ void btrfs_update_space_info(struct btrfs_fs_info *info, u64 flags,
> found->bytes_readonly += bytes_readonly;
> if (total_bytes > 0)
> found->full = 0;
> - btrfs_space_info_add_new_bytes(info, found,
> - total_bytes - bytes_used -
> - bytes_readonly);
> + btrfs_try_to_wakeup_tickets(info, found);
> spin_unlock(&found->lock);
> *space_info = found;
> }
> @@ -229,17 +227,13 @@ static int can_overcommit(struct btrfs_fs_info *fs_info,
> * This is for space we already have accounted in space_info->bytes_may_use, so
> * basically when we're returning space from block_rsv's.
> */
> -void btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info,
> - struct btrfs_space_info *space_info,
> - u64 num_bytes)
> +void btrfs_try_to_wakeup_tickets(struct btrfs_fs_info *fs_info,
> + struct btrfs_space_info *space_info)
> {
> struct list_head *head;
> enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_NO_FLUSH;
>
> - spin_lock(&space_info->lock);
Add an lockdep_assert_held(&space_info->lock);
<snip>