Hi, I''m reading the mkfs code, and confused by its -A option. From its comments, the value specified by -A should be regarded as the start of the filesystem. But mkfs will always zero some area at the beginning of the first dev, regardless -r specified or not. My question is: Why mkfs zeros the beginning of the first dev? Is that expected? And any use case for -A option? thanks, -- 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
On 2012年10月23日 01:49, Alex Lyakas wrote:> Wang, > I would say that zeroing is done to prevent from seeing some other superblock (besides btrfs) there.That make sense.> > Alex. > >But I still confused by the -A option? In mkfs, we always write the sb info into BTRFS_SUPER_INFO_OFFSET. From the -A comment, I think btrfs would be places after the -A value. What would happen if we specify a -A value larger than it? Thanks, Sheng-Hui -- 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
Hi Wang, if you just look at the code in find_free_dev_extent(): u64 search_start = 0; ... search_start = max((u64)1024 * 1024, search_start); if (root->fs_info->alloc_start + num_bytes <= device->total_bytes) search_start = max(root->fs_info->alloc_start, search_start); ... key.objectid = device->devid; key.offset = search_start; key.type = BTRFS_DEV_EXTENT_KEY; You see that it will search for DEV_EXTENTs (when allocating chunks) that begin after the value you specified. So it will not use some space at the beginning of the device for allocations. Same behavior in the kernel can be caused by using "alloc_start=X" mount option. What is the purpose of this I don''t know, but what it does looks pretty clear. The (first copy of the) superblock, though, is always written to BTRFS_SUPER_INFO_OFFSET, as you mentioned. Alex. On Wed, Oct 24, 2012 at 2:48 AM, Wang Sheng-Hui <shhuiw@gmail.com> wrote:> On 2012年10月23日 01:49, Alex Lyakas wrote: > >> Wang, >> I would say that zeroing is done to prevent from seeing some other superblock (besides btrfs) there. > > > That make sense. > >> >> Alex. >> >> > > > But I still confused by the -A option? > > In mkfs, we always write the sb info into BTRFS_SUPER_INFO_OFFSET. > From the -A comment, I think btrfs would be places after the -A value. > What would happen if we specify a -A value larger than it? > > > Thanks, > Sheng-Hui-- 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
On 2012年10月24日 17:44, Alex Lyakas wrote:> Hi Wang, > if you just look at the code in find_free_dev_extent(): > u64 search_start = 0; > ... > search_start = max((u64)1024 * 1024, search_start); > if (root->fs_info->alloc_start + num_bytes <= device->total_bytes) > search_start = max(root->fs_info->alloc_start, search_start); > ... > key.objectid = device->devid; > key.offset = search_start; > key.type = BTRFS_DEV_EXTENT_KEY; > > You see that it will search for DEV_EXTENTs (when allocating chunks) > that begin after the value you specified. So it will not use some > space at the beginning of the device for allocations. Same behavior in > the kernel can be caused by using "alloc_start=X" mount option. > What is the purpose of this I don''t know, but what it does looks pretty clear. > The (first copy of the) superblock, though, is always written to > BTRFS_SUPER_INFO_OFFSET, as you mentioned. > > Alex. > >Thanks, Alex.> > > On Wed, Oct 24, 2012 at 2:48 AM, Wang Sheng-Hui <shhuiw@gmail.com> wrote: >> On 2012年10月23日 01:49, Alex Lyakas wrote: >> >>> Wang, >>> I would say that zeroing is done to prevent from seeing some other superblock (besides btrfs) there. >> >> >> That make sense. >> >>> >>> Alex. >>> >>> >> >> >> But I still confused by the -A option? >> >> In mkfs, we always write the sb info into BTRFS_SUPER_INFO_OFFSET. >> From the -A comment, I think btrfs would be places after the -A value. >> What would happen if we specify a -A value larger than it? >> >> >> Thanks, >> Sheng-Hui-- 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