Re: [PATCH 05/10] btrfs-progs: adjust function btrfs_lookup_first_block_group_kernel

Su Yue
2019-12-05T08:20:51Z

On 2019/12/5 3:40 PM, Qu Wenruo wrote:
>
>
> On 2019/12/5 下午12:29, damenly.su@gmail.com wrote:
>> From: Su Yue <Damenly_Su@gmx.com>
>>
>> The are different behavior of btrfs_lookup_first_block_group() and
>> btrfs_lookup_first_block_group_kernel(). Unify the latter' behavior.
>>
>> Signed-off-by: Su Yue <Damenly_Su@gmx.com>
>
> Is it possible to modify the specific callers in btrfs-progs to make
> them use the kernel behavior other than re-inventing some new behavior?
>
In technological viewpoint, absolutely say YES.
But, it requires logic changes in many places (callers, callers of
callers). I did tries and it pained me.
And the theme of the whole patchset is doing simple intuitive data
structure replacing. Touching the logic part is preferable for me in
another set.

Thanks
> Thanks,
> Qu
>
>> ---
>> extent-tree.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/extent-tree.c b/extent-tree.c
>> index 1d8535049eaf..274dfe540b1f 100644
>> --- a/extent-tree.c
>> +++ b/extent-tree.c
>> @@ -243,12 +243,13 @@ static struct btrfs_block_group_cache *block_group_cache_tree_search(
>> }
>>
>> /*
>> - * Return the block group that starts at or after bytenr
>> + * Return the block group that contains @bytenr, otherwise return the next one
>> + * that starts after @bytenr
>> */
>> struct btrfs_block_group_cache *btrfs_lookup_first_block_group_kernel(
>> struct btrfs_fs_info *info, u64 bytenr)
>> {
>> - return block_group_cache_tree_search(info, bytenr, 0);
>> + return block_group_cache_tree_search(info, bytenr, 2);
>> }
>>
>> /*
>>
>