linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: check free space in block group before searching for a cluster
@ 2011-03-18 19:16 Josef Bacik
  2011-03-21  2:39 ` Li Zefan
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2011-03-18 19:16 UTC (permalink / raw)
  To: linux-btrfs

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>
---
 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 */
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Btrfs: check free space in block group before searching for a cluster
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Li Zefan @ 2011-03-21  2:39 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs

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 */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-21  2:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).