From: Josef Bacik <josef@redhat.com>
To: Josef Bacik <josef@redhat.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/4] Btrfs: don't allocate chunks as aggressively
Date: Mon, 18 Oct 2010 17:13:14 -0400 [thread overview]
Message-ID: <20101018211313.GA2539@localhost.localdomain> (raw)
In-Reply-To: <1287178115-18229-4-git-send-email-josef@redhat.com>
On Fri, Oct 15, 2010 at 05:28:34PM -0400, Josef Bacik wrote:
> Because the ENOSPC code over reserves super aggressively we end up allocating
> chunks way more often than we should. For example with my fs_mark tests on a
> 2gb fs I can end up reserved 1gb just for metadata, when only 34mb of that is
> being used. So instead check to see if the amount of space actually used is
> less than 30% of the total space, and if so don't allocate a chunk.
>
> Signed-off-by: Josef Bacik <josef@redhat.com>
> ---
> fs/btrfs/extent-tree.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 14a52dd..265d8e0 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3224,7 +3224,8 @@ static void force_metadata_allocation(struct btrfs_fs_info *info)
> rcu_read_unlock();
> }
>
> -static int should_alloc_chunk(struct btrfs_space_info *sinfo,
> +static int should_alloc_chunk(struct btrfs_fs_info *info,
> + struct btrfs_space_info *sinfo,
> u64 alloc_bytes)
> {
> u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly;
> @@ -3237,6 +3238,9 @@ static int should_alloc_chunk(struct btrfs_space_info *sinfo,
> alloc_bytes < div_factor(num_bytes, 8))
> return 0;
>
> + if (sinfo->bytes_used < div_factor(num_bytes, 3))
> + return 0;
> +
> return 1;
> }
>
> @@ -3268,7 +3272,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
> goto out;
> }
>
> - if (!force && !should_alloc_chunk(space_info, alloc_bytes)) {
> + if (!force && !should_alloc_chunk(fs_info, space_info, alloc_bytes)) {
> spin_unlock(&space_info->lock);
> goto out;
> }
> @@ -3317,7 +3321,8 @@ static int maybe_allocate_chunk(struct btrfs_trans_handle *trans,
> return 0;
>
> spin_lock(&sinfo->lock);
> - ret = should_alloc_chunk(sinfo, num_bytes + 2 * 1024 * 1024);
> + ret = should_alloc_chunk(root->fs_info, sinfo,
> + num_bytes + 2 * 1024 * 1024);
> spin_unlock(&sinfo->lock);
> if (!ret)
> return 0;
> --
> 1.6.6.1
>
Self-NAK on this one, it seems to cause a few problems with -m single and
smaller fs's, so just drop it. It only creates too much overhead on really
small fs's anyway, and if you no likey that overhead, use mixed block groups :).
Thanks,
Josef
next prev parent reply other threads:[~2010-10-18 21:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-15 21:28 [PATCH 0/4] Btrfs: fix ENOSPC regressions Josef Bacik
2010-10-15 21:28 ` [PATCH 1/4] Btrfs: fix reservation code for mixed block groups Josef Bacik
2010-10-15 21:28 ` [PATCH 2/4] Btrfs: re-work delalloc flushing Josef Bacik
2010-10-22 18:45 ` [PATCH] Btrfs: re-work delalloc flushing V2 Josef Bacik
2010-10-15 21:28 ` [PATCH 3/4] Btrfs: don't allocate chunks as aggressively Josef Bacik
2010-10-18 21:13 ` Josef Bacik [this message]
2010-10-19 1:02 ` [PATCH] Btrfs: don't allocate chunks as aggressively V2 Josef Bacik
2010-10-15 21:28 ` [PATCH 4/4] Btrfs: rework how we reserve metadata bytes Josef Bacik
2010-10-22 18:50 ` [PATCH] Btrfs: rework how we reserve metadata bytes V2 Josef Bacik
2010-10-15 21:35 ` [PATCH 0/4] Btrfs: fix ENOSPC regressions Christoph Hellwig
2010-10-15 21:37 ` 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=20101018211313.GA2539@localhost.localdomain \
--to=josef@redhat.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).