All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: bo.li.liu@oracle.com, Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.cz,
	David Sterba <dsterba@suse.com>
Subject: Re: [PATCH v3 21/22] btrfs-progs: convert: Strictly avoid meta or system chunk allocation
Date: Sun, 29 May 2016 19:05:44 +0800	[thread overview]
Message-ID: <1c5ba73e-798b-c5dc-e539-1886cce324cf@gmx.com> (raw)
In-Reply-To: <20160528033028.GD31255@localhost.localdomain>



On 05/28/2016 11:30 AM, Liu Bo wrote:
> On Fri, Jan 29, 2016 at 01:03:31PM +0800, Qu Wenruo wrote:
>> Before this patch, btrfs-convert only rely on large enough initial
>> system/metadata chunk size to ensure no newer system/meta chunk will be
>> created.
>>
>> But that's not safe enough. So add two new members in fs_info,
>> avoid_sys/meta_chunk_alloc flags to prevent any newer system or meta
>> chunks to be created before init_btrfs_v2().
>>
>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
>> Signed-off-by: David Sterba <dsterba@suse.com>
>> ---
>>  btrfs-convert.c |  9 +++++++++
>>  ctree.h         |  3 +++
>>  extent-tree.c   | 10 ++++++++++
>>  3 files changed, 22 insertions(+)
>>
>> diff --git a/btrfs-convert.c b/btrfs-convert.c
>> index efa3b02..333f413 100644
>> --- a/btrfs-convert.c
>> +++ b/btrfs-convert.c
>> @@ -2322,6 +2322,13 @@ static int init_btrfs_v2(struct btrfs_mkfs_config *cfg, struct btrfs_root *root,
>>  	struct btrfs_fs_info *fs_info = root->fs_info;
>>  	int ret;
>>
>> +	/*
>> +	 * Don't alloc any metadata/system chunk, as we don't want
>> +	 * any meta/sys chunk allcated before all data chunks are inserted.
>> +	 * Or we screw up the chunk layout just like the old implement.
>> +	 */
>
> I don't get this, with this patch set, we can allocate data from DATA chunk,
> allocate metadata from METADATA chunk, but then we're not allowed to allocate new chunks?
>
> Thanks,

For new convert, we are going through the following steps:
1) Create initial meta/sys chunks into unused space, manually
2) Open fs
3) Insert data chunks to covert all ext* used data
4) Do per inode copying

The whole patchset rely on a key assumption: All data chunks are already 
allocated to cover all ext* used data, so new chunk/extent allocation 
can follow the normal routine.

Before that, only chunks created in step 1) is completely safe, and new 
chunk allocation before step 3) are all unsafe, as the key assumption is 
not met yet.

So, unitl step 3), we must not allocate any new data/metadata chunks.

Thanks,
Qu
>
> -liubo
>> +	fs_info->avoid_sys_chunk_alloc = 1;
>> +	fs_info->avoid_meta_chunk_alloc = 1;
>>  	trans = btrfs_start_transaction(root, 1);
>>  	BUG_ON(!trans);
>>  	ret = btrfs_fix_block_accounting(trans, root);
>> @@ -2359,6 +2366,8 @@ static int init_btrfs_v2(struct btrfs_mkfs_config *cfg, struct btrfs_root *root,
>>  		goto err;
>>
>>  	ret = btrfs_commit_transaction(trans, root);
>> +	fs_info->avoid_sys_chunk_alloc = 0;
>> +	fs_info->avoid_meta_chunk_alloc = 0;
>>  err:
>>  	return ret;
>>  }
>> diff --git a/ctree.h b/ctree.h
>> index 1443746..187bd27 100644
>> --- a/ctree.h
>> +++ b/ctree.h
>> @@ -1030,6 +1030,9 @@ struct btrfs_fs_info {
>>  	unsigned int quota_enabled:1;
>>  	unsigned int suppress_check_block_errors:1;
>>  	unsigned int ignore_fsid_mismatch:1;
>> +	unsigned int avoid_meta_chunk_alloc:1;
>> +	unsigned int avoid_sys_chunk_alloc:1;
>> +
>>
>>  	int (*free_extent_hook)(struct btrfs_trans_handle *trans,
>>  				struct btrfs_root *root,
>> diff --git a/extent-tree.c b/extent-tree.c
>> index 93b1945..e7c61b1 100644
>> --- a/extent-tree.c
>> +++ b/extent-tree.c
>> @@ -1904,6 +1904,16 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
>>  	    thresh)
>>  		return 0;
>>
>> +	/*
>> +	 * Avoid allocating given chunk type
>> +	 */
>> +	if (extent_root->fs_info->avoid_meta_chunk_alloc &&
>> +	    (flags & BTRFS_BLOCK_GROUP_METADATA))
>> +		return 0;
>> +	if (extent_root->fs_info->avoid_sys_chunk_alloc &&
>> +	    (flags & BTRFS_BLOCK_GROUP_SYSTEM))
>> +		return 0;
>> +
>>  	ret = btrfs_alloc_chunk(trans, extent_root, &start, &num_bytes,
>>  	                        space_info->flags);
>>  	if (ret == -ENOSPC) {
>> --
>> 2.7.0
>>
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  reply	other threads:[~2016-05-29 11:06 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29  5:03 [PATCH v3 00/22] Btrfs-convert rework to support separate chunk type Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 01/22] btrfs-progs: convert: Introduce functions to read used space Qu Wenruo
2016-04-04 13:35   ` David Sterba
2016-04-05  1:35     ` Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 02/22] btrfs-progs: convert: Introduce new function to remove reserved ranges Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 03/22] btrfs-progs: convert: Introduce function to calculate the available space Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 04/22] btrfs-progs: utils: Introduce new function for convert Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 05/22] btrfs-progs: Introduce function to setup temporary superblock Qu Wenruo
2016-05-28  3:04   ` Liu Bo
2016-05-29 10:52     ` Qu Wenruo
2016-06-02 16:41       ` David Sterba
2016-01-29  5:03 ` [PATCH v3 06/22] btrfs-progs: Introduce function to setup temporary tree root Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 07/22] btrfs-progs: Introduce function to setup temporary chunk root Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 08/22] btrfs-progs: Introduce function to initialize device tree Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 09/22] btrfs-progs: Introduce function to initialize fs tree Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 10/22] btrfs-progs: Introduce function to initialize csum tree Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 11/22] btrfs-progs: Introduce function to setup temporary extent tree Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 12/22] btrfs-progs: Introduce function to create convert data chunks Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 13/22] btrfs-progs: extent-tree: Introduce function to find the first overlap extent Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 14/22] btrfs-progs: extent-tree: Enhance btrfs_record_file_extent Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 15/22] btrfs-progs: convert: Introduce new function to create converted image Qu Wenruo
2016-05-28  3:14   ` Liu Bo
2016-01-29  5:03 ` [PATCH v3 16/22] btrfs-progs: convert: Introduce function to migrate reserved ranges Qu Wenruo
2016-05-28  3:16   ` Liu Bo
2016-05-29 11:07     ` Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 17/22] btrfs-progs: convert: Enhance record_file_blocks to handle " Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 18/22] btrfs-progs: convert: Introduce init_btrfs_v2 function Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 19/22] btrfs-progs: Introduce do_convert_v2 function Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 20/22] btrfs-progs: Convert: Add support for rollback new convert behavior Qu Wenruo
2016-01-29  5:03 ` [PATCH v3 21/22] btrfs-progs: convert: Strictly avoid meta or system chunk allocation Qu Wenruo
2016-05-28  3:30   ` Liu Bo
2016-05-29 11:05     ` Qu Wenruo [this message]
2016-01-29  5:03 ` [PATCH v3 22/22] btrfs-progs: Cleanup old btrfs-convert Qu Wenruo
2016-02-11 17:37 ` [PATCH v3 00/22] Btrfs-convert rework to support separate chunk type David Sterba

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=1c5ba73e-798b-c5dc-e539-1886cce324cf@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=bo.li.liu@oracle.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo@cn.fujitsu.com \
    /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.