Re: [PATCH v2 2/3] btrfs-progs: dir-item: Don't do extra filetype validaction check for btrfs_match_dir_item_name

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

 




On 2018年01月19日 15:39, Su Yue wrote:
> 
> 
> On 01/19/2018 03:25 PM, Qu Wenruo wrote:
>> btrfs_match_dir_item_name() will check if its filetype is valid before
>> doing search, this makes btrfs-progs unable to locate and remove invalid
>> dir_index for btrfs_unlink().
>>
>> This function only affects btrfs_link() and btrfs_unlink() in upper
>> layer, and normal check can find invalid filetype by itself.
>>
> Lowmem mode can't handles wrong filetype well now.
> I'm working on it. And this change is okay for me.

I think you mean *original* mode can't handle it.

As v4.14.1 lowmem mode can detect such problem without problem:
-------
checking fs roots
ERROR: root 5 INODE_ITEM[258] index 2 name file1 filetype 34 mismath
ERROR: root 5 DIR INDEX[257 2] missing name file1 filetype 1
ERROR: errors found in fs roots
found 131072 bytes used, error(s) found
-------

And patch 1/3 will handle the repair, so it shouldn't be a problem for
lowmem.

Thanks,
Qu
> 
> Reviewed-by: Su Yue <suy.fnst@xxxxxxxxxxxxxx>
> 
>> So remove the filetype check is completely safe in this case, and will
>> enhance btrfs_unlink() to remove invalid dir_index/dir_item for repair.
>>
>> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
>> ---
>>   dir-item.c | 6 ------
>>   1 file changed, 6 deletions(-)
>>
>> diff --git a/dir-item.c b/dir-item.c
>> index 462546c0eaf4..e0a0ab4d7a5d 100644
>> --- a/dir-item.c
>> +++ b/dir-item.c
>> @@ -294,12 +294,6 @@ static int verify_dir_item(struct btrfs_root *root,
>>       u16 namelen = BTRFS_NAME_LEN;
>>       u8 type = btrfs_dir_type(leaf, dir_item);
>>   -    if (type >= BTRFS_FT_MAX) {
>> -        fprintf(stderr, "invalid dir item type: %d\n",
>> -               (int)type);
>> -        return 1;
>> -    }
>> -
>>       if (type == BTRFS_FT_XATTR)
>>           namelen = XATTR_NAME_MAX;
>>  
> 
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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