From: Li Zefan <lizf@cn.fujitsu.com>
To: Josef Bacik <josef@redhat.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: check free space in block group before searching for a cluster
Date: Mon, 21 Mar 2011 10:39:00 +0800 [thread overview]
Message-ID: <4D86BA44.1040004@cn.fujitsu.com> (raw)
In-Reply-To: <1300475786-1836-1-git-send-email-josef@redhat.com>
Josef Bacik wrote:
> The free space cluster stuff is heavy duty, so there is no sense in going
> through the entire song and dance if there isn't enough space in the block group
> to begin with. Thanks,
>
> Signed-off-by: Josef Bacik <josef@redhat.com>
Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
> fs/btrfs/free-space-cache.c | 10 ++++++++++
> 1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 0282033..f631df8 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -1999,6 +1999,16 @@ int btrfs_find_space_cluster(struct btrfs_trans_handle *trans,
> min_bytes = max(bytes, (bytes + empty_size) >> 2);
>
> spin_lock(&block_group->tree_lock);
> +
> + /*
> + * If we know we don't have enough space to make a cluster don't even
> + * bother doing all the work to try and find one.
> + */
> + if (block_group->free_space < min_bytes) {
> + spin_unlock(&block_group->tree_lock);
> + return -ENOSPC;
> + }
> +
> spin_lock(&cluster->lock);
>
> /* someone already found a cluster, hooray */
prev parent reply other threads:[~2011-03-21 2:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-18 19:16 [PATCH] Btrfs: check free space in block group before searching for a cluster Josef Bacik
2011-03-21 2:39 ` Li Zefan [this message]
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=4D86BA44.1040004@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=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).