On 1.02.20 г. 0:36 ч., Josef Bacik wrote:
> This was put into place in order to mirror the way data flushing handled
> committing the transaction. Now that we do not loop on committing the
> transaction simply force a transaction commit if we are data.
>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx>
> ---
> fs/btrfs/space-info.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index 3060754a3341..cef14a4d4167 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -412,14 +412,14 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info,
> * will return -ENOSPC.
> */
> static int may_commit_transaction(struct btrfs_fs_info *fs_info,
> - struct btrfs_space_info *space_info,
> - u64 bytes_needed)
> + struct btrfs_space_info *space_info)
> {
> struct reserve_ticket *ticket = NULL;
> struct btrfs_block_rsv *delayed_rsv = &fs_info->delayed_block_rsv;
> struct btrfs_block_rsv *delayed_refs_rsv = &fs_info->delayed_refs_rsv;
> struct btrfs_trans_handle *trans;
> u64 reclaim_bytes = 0;
> + u64 bytes_needed;
> u64 cur_free_bytes = 0;
> bool do_commit = false;
>
> @@ -428,12 +428,10 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
> return -EAGAIN;
>
> /*
> - * If we are data and have passed in U64_MAX we just want to
> - * unconditionally commit the transaction to match the previous data
> - * flushing behavior.
> + * If we are data just force the commit, we aren't likely to do this
> + * over and over again.
> */
I don't think the 2nd part of the comment brings any value hence can be
removed.
> - if ((space_info->flags & BTRFS_BLOCK_GROUP_DATA) &&
> - bytes_needed == U64_MAX) {
> + if (space_info->flags & BTRFS_BLOCK_GROUP_DATA) {
> do_commit = true;
> goto check_pinned;
> }
<snip>