Re: [PATCH 1/2] btrfs-progs: add comments of block group lookup functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2019/11/11 下午5:49, Su Yue wrote:
> 
> 
> On 2019/11/11 5:28 PM, Qu Wenruo wrote:
>>
>>
>> On 2019/11/11 下午4:42, damenly.su@xxxxxxxxx wrote:
>>> From: Su Yue <Damenly_Su@xxxxxxx>
>>>
>>> The progs side function btrfs_lookup_first_block_group() calls
>>> find_first_extent_bit() to find block group which contains bytenr
>>> or after the bytenr. This behavior differs from kernel code, so
>>> add the comments.
>>>
>>> Add the coments of btrfs_lookup_block_group() too, this one works
>>> like kernel side.
>>>
>>> Signed-off-by: Su Yue <Damenly_Su@xxxxxxx>
>>> ---
>>>   extent-tree.c | 6 ++++++
>>>   1 file changed, 6 insertions(+)
>>>
>>> diff --git a/extent-tree.c b/extent-tree.c
>>> index d67e4098351f..f690ae999f37 100644
>>> --- a/extent-tree.c
>>> +++ b/extent-tree.c
>>> @@ -164,6 +164,9 @@ err:
>>>       return 0;
>>>   }
>>>
>>> +/*
>>> + * Return the block group that contains or after bytenr
>>> + */
>>
>> What about "Return the block group thart starts at or after @bytenr" ?
>>
> 
> That's what documented in kernel already.
> The thing I try to express is "contains".
> For such a block group marked as B[n, m).
> btrfs_lookup_first_block_group(x) (x > n && x < m). Kernel code will
> return the block group next to B. However, progs side will return the
> block group B.

"Contains" indeed covers your example.
But the "after @bytenr" part looks strange to me.

Did you mean if @bytenr is not covered by any block group, then the next
block group starts after @bytenr is returned?

Then the comment is good.

Thanks,
Qu

> 
> Thanks.
>> Thanks,
>> Qu
>>
>>>   struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct
>>>                                  btrfs_fs_info *info,
>>>                                  u64 bytenr)
>>> @@ -193,6 +196,9 @@ struct btrfs_block_group_cache
>>> *btrfs_lookup_first_block_group(struct
>>>       return block_group;
>>>   }
>>>
>>> +/*
>>> + * Return the block group that contains the given bytenr
>>> + */
>>>   struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
>>>                                btrfs_fs_info *info,
>>>                                u64 bytenr)
>>>
>>

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux