All of lore.kernel.org
 help / color / mirror / Atom feed
From: liubo <liubo2009@cn.fujitsu.com>
To: Arne Jansen <sensille@gmx.net>
Cc: chris.mason@oracle.com, linux-btrfs@vger.kernel.org, josef@redhat.com
Subject: Re: [PATCH] btrfs progs: fix extra metadata chunk allocation in --mixed case
Date: Fri, 06 May 2011 09:05:28 +0800	[thread overview]
Message-ID: <4DC34958.8010301@cn.fujitsu.com> (raw)
In-Reply-To: <1304604972-31585-1-git-send-email-sensille@gmx.net>

On 05/05/2011 10:16 PM, Arne Jansen wrote:
> When creating a mixed fs with mkfs, an extra metadata chunk got allocated.
> This is because btrfs_reserve_extent calls do_chunk_alloc for METADATA,
> which in turn wasn't able to find the proper space_info, as __find_space_info
> did a hard compare of the flags. It is now sufficient for the space_info to
> include the proper flag. This reflects the change done to the kernel code
> to support mixed chunks.
> Also for a subsequent chunk allocation (which should not be hit in the mkfs
> case), the chunk is now created with the flags from the space_info instead
> of the requested flags. A better solution would be to pull the full changeset
> for the mixed case from the kernel into the user mode (or, even better, share
> the code)
> 
> The additional chunk probably confused block_rsv calculation, which in turn
> led to severeal ENOSPC Oopses.
> 

Good catch!

Reviewed-by: Liu Bo <liubo2009@cn.fujitsu.com>

> Signed-off-by: Arne Jansen <sensille@gmx.net>
> ---
>  extent-tree.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/extent-tree.c b/extent-tree.c
> index b2f9bb2..c6c77c6 100644
> --- a/extent-tree.c
> +++ b/extent-tree.c
> @@ -1735,7 +1735,7 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,
>  	struct btrfs_space_info *found;
>  	list_for_each(cur, head) {
>  		found = list_entry(cur, struct btrfs_space_info, list);
> -		if (found->flags == flags)
> +		if (found->flags & flags)
>  			return found;
>  	}
>  	return NULL;
> @@ -1812,7 +1812,8 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
>  	    thresh)
>  		return 0;
>  
> -	ret = btrfs_alloc_chunk(trans, extent_root, &start, &num_bytes, flags);
> +	ret = btrfs_alloc_chunk(trans, extent_root, &start, &num_bytes,
> +	                        space_info->flags);
>  	if (ret == -ENOSPC) {
>  		space_info->full = 1;
>  		return 0;
> @@ -1820,7 +1821,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
>  
>  	BUG_ON(ret);
>  
> -	ret = btrfs_make_block_group(trans, extent_root, 0, flags,
> +	ret = btrfs_make_block_group(trans, extent_root, 0, space_info->flags,
>  		     BTRFS_FIRST_CHUNK_TREE_OBJECTID, start, num_bytes);
>  	BUG_ON(ret);
>  	return 0;


  reply	other threads:[~2011-05-06  1:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05 14:16 [PATCH] btrfs progs: fix extra metadata chunk allocation in --mixed case Arne Jansen
2011-05-06  1:05 ` liubo [this message]
2011-05-06 20:39 ` Sergei Trofimovich

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=4DC34958.8010301@cn.fujitsu.com \
    --to=liubo2009@cn.fujitsu.com \
    --cc=chris.mason@oracle.com \
    --cc=josef@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sensille@gmx.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.