Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Josef Bacik <josef@toxicpanda.com>,
	kernel-team@fb.com, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 7/9] btrfs: fix may_commit_transaction to deal with no partial filling
Date: Fri, 23 Aug 2019 11:18:05 +0300	[thread overview]
Message-ID: <33cf9dd2-0c53-a053-5c5c-b00b75b3f661@suse.com> (raw)
In-Reply-To: <20190822191102.13732-8-josef@toxicpanda.com>



On 22.08.19 г. 22:11 ч., Josef Bacik wrote:
> Now that we aren't partially filling tickets we may have some slack
> space left in the space_info.  We need to account for this in
> may_commit_transaction, otherwise we may choose to not commit the
> transaction despite it actually having enough space to satisfy our
> ticket.
> 
> Calculate the free space we have in the space_info, if any, and subtract
> this from the ticket we have and use that amount to determine if we will
> need to commit to reclaim enough space.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/space-info.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index dd4adfa75a71..cec6db0c41cc 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -473,12 +473,19 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
>  	struct btrfs_trans_handle *trans;
>  	u64 bytes_needed;
>  	u64 reclaim_bytes = 0;
> +	u64 cur_free_bytes = 0;
>  
>  	trans = (struct btrfs_trans_handle *)current->journal_info;
>  	if (trans)
>  		return -EAGAIN;
>  
>  	spin_lock(&space_info->lock);
> +	cur_free_bytes = btrfs_space_info_used(space_info, true);
> +	if (cur_free_bytes < space_info->total_bytes)
> +		cur_free_bytes = space_info->total_bytes - cur_free_bytes;
> +	else
> +		cur_free_bytes = 0;
> +
>  	if (!list_empty(&space_info->priority_tickets))
>  		ticket = list_first_entry(&space_info->priority_tickets,
>  					  struct reserve_ticket, list);
> @@ -486,6 +493,11 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
>  		ticket = list_first_entry(&space_info->tickets,
>  					  struct reserve_ticket, list);
>  	bytes_needed = (ticket) ? ticket->bytes : 0;
> +
> +	if (bytes_needed > cur_free_bytes)
> +		bytes_needed -= cur_free_bytes;
> +	else
> +		bytes_needed = 0;
>  	spin_unlock(&space_info->lock);
>  
>  	if (!bytes_needed)
> 

  reply	other threads:[~2019-08-23  8:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 19:10 [PATCH 0/9][v3] Rework reserve ticket handling Josef Bacik
2019-08-22 19:10 ` [PATCH 1/9] btrfs: do not allow reservations if we have pending tickets Josef Bacik
2019-08-23  7:33   ` Nikolay Borisov
2019-08-22 19:10 ` [PATCH 2/9] btrfs: roll tracepoint into btrfs_space_info_update helper Josef Bacik
2019-08-23 12:12   ` David Sterba
2019-08-22 19:10 ` [PATCH 3/9] btrfs: add space reservation tracepoint for reserved bytes Josef Bacik
2019-08-23 12:17   ` David Sterba
2019-08-22 19:10 ` [PATCH 4/9] btrfs: rework btrfs_space_info_add_old_bytes Josef Bacik
2019-08-23  7:48   ` Nikolay Borisov
2019-08-23 12:30     ` David Sterba
2019-08-28 15:15   ` [PATCH][v2] btrfs: stop partially refilling tickets when releasing space Josef Bacik
2019-08-22 19:10 ` [PATCH 5/9] btrfs: refactor the ticket wakeup code Josef Bacik
2019-08-22 19:10 ` [PATCH 6/9] btrfs: rework wake_all_tickets Josef Bacik
2019-08-23  8:17   ` Nikolay Borisov
2019-08-27 13:04     ` David Sterba
2019-08-28 15:12   ` [PATCH][v2] " Josef Bacik
2019-08-22 19:11 ` [PATCH 7/9] btrfs: fix may_commit_transaction to deal with no partial filling Josef Bacik
2019-08-23  8:18   ` Nikolay Borisov [this message]
2019-08-22 19:11 ` [PATCH 8/9] btrfs: remove orig_bytes from reserve_ticket Josef Bacik
2019-08-22 19:11 ` [PATCH 9/9] btrfs: rename btrfs_space_info_add_old_bytes Josef Bacik
2019-08-23  8:18   ` Nikolay Borisov
2019-08-23 12:55 ` [PATCH 0/9][v3] Rework reserve ticket handling David Sterba
2019-08-28 18:02   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33cf9dd2-0c53-a053-5c5c-b00b75b3f661@suse.com \
    --to=nborisov@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox