diff mbox series

[v2,3/7] btrfs-progs: lowmem check: find dir_item by di_key in check_dir_item()

Message ID 20180912204924.10089-4-suy.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: lowmem: bug fixes and inode_extref repair | expand

Commit Message

Su Yue Sept. 12, 2018, 8:49 p.m. UTC
From: Su Yue <suy.fnst@cn.fujitsu.com>

In check_dir_item, we are going to search corresponding
dir_item/index.

Commit 564901eac7a4 ("btrfs-progs: check: introduce
print_dir_item_err()") Changed argument name from key to di_key but
forgot to change the key name for dir_item search.
So @key shouldn't be used here. It should be @di_key.

Fixes: 564901eac7a4 ("btrfs-progs: check: introduce print_dir_item_err()")
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 check/mode-lowmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Qu Wenruo Sept. 13, 2018, 11:33 p.m. UTC | #1
On 2018/9/13 上午4:49, damenly.su@gmail.com wrote:
> From: Su Yue <suy.fnst@cn.fujitsu.com>
> 
> In check_dir_item, we are going to search corresponding
> dir_item/index.
> 
> Commit 564901eac7a4 ("btrfs-progs: check: introduce
> print_dir_item_err()") Changed argument name from key to di_key but
> forgot to change the key name for dir_item search.
> So @key shouldn't be used here. It should be @di_key.
> 
> Fixes: 564901eac7a4 ("btrfs-progs: check: introduce print_dir_item_err()")

Which also forgot to modify comment about parameters.

> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
>  check/mode-lowmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
> index 1bce44f5658a..89a304bbdd69 100644
> --- a/check/mode-lowmem.c
> +++ b/check/mode-lowmem.c
> @@ -1658,7 +1658,7 @@ begin:
>  
>  		/* check relative INDEX/ITEM */
>  		key.objectid = di_key->objectid;
> -		if (key.type == BTRFS_DIR_ITEM_KEY) {
> +		if (di_key->type == BTRFS_DIR_ITEM_KEY) {

To avoid such problem, I recommend to rename @key to @search_key, and
move the declaration inside the while loop.

Thanks,
Qu

>  			key.type = BTRFS_DIR_INDEX_KEY;
>  			key.offset = index;
>  		} else {
>
Su Yue Sept. 14, 2018, 12:57 a.m. UTC | #2
On 09/14/2018 07:33 AM, Qu Wenruo wrote:
> 
> 
> On 2018/9/13 上午4:49, damenly.su@gmail.com wrote:
>> From: Su Yue <suy.fnst@cn.fujitsu.com>
>>
>> In check_dir_item, we are going to search corresponding
>> dir_item/index.
>>
>> Commit 564901eac7a4 ("btrfs-progs: check: introduce
>> print_dir_item_err()") Changed argument name from key to di_key but
>> forgot to change the key name for dir_item search.
>> So @key shouldn't be used here. It should be @di_key.
>>
>> Fixes: 564901eac7a4 ("btrfs-progs: check: introduce print_dir_item_err()")
> 
> Which also forgot to modify comment about parameters.
Oh....Noticed
> 
>> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
>> ---
>>   check/mode-lowmem.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
>> index 1bce44f5658a..89a304bbdd69 100644
>> --- a/check/mode-lowmem.c
>> +++ b/check/mode-lowmem.c
>> @@ -1658,7 +1658,7 @@ begin:
>>   
>>   		/* check relative INDEX/ITEM */
>>   		key.objectid = di_key->objectid;
>> -		if (key.type == BTRFS_DIR_ITEM_KEY) {
>> +		if (di_key->type == BTRFS_DIR_ITEM_KEY) {
> 
> To avoid such problem, I recommend to rename @key to @search_key, and
> move the declaration inside the while loop.
> 
Nice suggestion. Will do it in next version.

Thanks,
Su
> Thanks,
> Qu
> 
>>   			key.type = BTRFS_DIR_INDEX_KEY;
>>   			key.offset = index;
>>   		} else {
>>
> 
>
diff mbox series

Patch

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 1bce44f5658a..89a304bbdd69 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -1658,7 +1658,7 @@  begin:
 
 		/* check relative INDEX/ITEM */
 		key.objectid = di_key->objectid;
-		if (key.type == BTRFS_DIR_ITEM_KEY) {
+		if (di_key->type == BTRFS_DIR_ITEM_KEY) {
 			key.type = BTRFS_DIR_INDEX_KEY;
 			key.offset = index;
 		} else {