From: Nikolay Borisov <nborisov@suse.com>
To: Josef Bacik <josef@toxicpanda.com>,
linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 1/8] btrfs: check if free bgs for commit
Date: Mon, 26 Nov 2018 12:45:48 +0200 [thread overview]
Message-ID: <d721b79a-289b-d5fc-6b19-d5a4c9df5f47@suse.com> (raw)
In-Reply-To: <20181121190313.24575-2-josef@toxicpanda.com>
On 21.11.18 г. 21:03 ч., Josef Bacik wrote:
> may_commit_transaction will skip committing the transaction if we don't
> have enough pinned space or if we're trying to find space for a SYSTEM
> chunk. However if we have pending free block groups in this transaction
> we still want to commit as we may be able to allocate a chunk to make
> our reservation. So instead of just returning ENOSPC, check if we have
> free block groups pending, and if so commit the transaction to allow us
> to use that free space.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> Reviewed-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/extent-tree.c | 33 +++++++++++++++++++--------------
> 1 file changed, 19 insertions(+), 14 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 8af68b13fa27..0dca250dc02e 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4843,10 +4843,18 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
> if (!bytes)
> return 0;
>
> - /* See if there is enough pinned space to make this reservation */
> - if (__percpu_counter_compare(&space_info->total_bytes_pinned,
> - bytes,
> - BTRFS_TOTAL_BYTES_PINNED_BATCH) >= 0)
> + trans = btrfs_join_transaction(fs_info->extent_root);
> + if (IS_ERR(trans))
> + return PTR_ERR(trans);
> +
> + /*
> + * See if there is enough pinned space to make this reservation, or if
> + * we have bg's that are going to be freed, allowing us to possibly do a
> + * chunk allocation the next loop through.
> + */
> + if (test_bit(BTRFS_TRANS_HAVE_FREE_BGS, &trans->transaction->flags) ||
> + __percpu_counter_compare(&space_info->total_bytes_pinned, bytes,
> + BTRFS_TOTAL_BYTES_PINNED_BATCH) >= 0)
> goto commit;
>
> /*
> @@ -4854,7 +4862,7 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
> * this reservation.
> */
> if (space_info != delayed_rsv->space_info)
> - return -ENOSPC;
> + goto enospc;
>
> spin_lock(&delayed_rsv->lock);
> reclaim_bytes += delayed_rsv->reserved;
> @@ -4868,17 +4876,14 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info,
> bytes -= reclaim_bytes;
>
> if (__percpu_counter_compare(&space_info->total_bytes_pinned,
> - bytes,
> - BTRFS_TOTAL_BYTES_PINNED_BATCH) < 0) {
> - return -ENOSPC;
> - }
> -
> + bytes,
> + BTRFS_TOTAL_BYTES_PINNED_BATCH) < 0)
> + goto enospc;
> commit:
> - trans = btrfs_join_transaction(fs_info->extent_root);
> - if (IS_ERR(trans))
> - return -ENOSPC;
> -
> return btrfs_commit_transaction(trans);
> +enospc:
> + btrfs_end_transaction(trans);
> + return -ENOSPC;
> }
>
> /*
>
next prev parent reply other threads:[~2018-11-26 10:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 19:03 [PATCH 0/8] Enospc cleanups and fixes Josef Bacik
2018-11-21 19:03 ` [PATCH 1/8] btrfs: check if free bgs for commit Josef Bacik
2018-11-26 10:45 ` Nikolay Borisov [this message]
2018-11-21 19:03 ` [PATCH 2/8] btrfs: dump block_rsv whe dumping space info Josef Bacik
2018-11-21 19:03 ` [PATCH 3/8] btrfs: don't use global rsv for chunk allocation Josef Bacik
2018-11-26 11:25 ` Nikolay Borisov
2018-11-21 19:03 ` [PATCH 4/8] btrfs: add ALLOC_CHUNK_FORCE to the flushing code Josef Bacik
2018-11-26 11:28 ` Nikolay Borisov
2018-11-21 19:03 ` [PATCH 5/8] btrfs: don't enospc all tickets on flush failure Josef Bacik
2018-11-26 12:25 ` Nikolay Borisov
2018-11-27 19:46 ` Josef Bacik
2018-11-28 8:11 ` Nikolay Borisov
2018-11-21 19:03 ` [PATCH 6/8] btrfs: loop in inode_rsv_refill Josef Bacik
2018-11-21 19:03 ` [PATCH 7/8] btrfs: be more explicit about allowed flush states Josef Bacik
2018-11-26 12:41 ` Nikolay Borisov
2018-11-26 12:45 ` Nikolay Borisov
2018-11-21 19:03 ` [PATCH 8/8] btrfs: reserve extra space during evict() Josef Bacik
-- strict thread matches above, loose matches on Subject: below --
2018-12-03 15:24 [PATCH 0/8][V2] Enospc cleanups and fixeS Josef Bacik
2018-12-03 15:24 ` [PATCH 1/8] btrfs: check if free bgs for commit Josef Bacik
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=d721b79a-289b-d5fc-6b19-d5a4c9df5f47@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;
as well as URLs for NNTP newsgroup(s).