On 2018/2/26 20:31, heyunlei wrote:
> 
> 
>> -----Original Message-----
>> From: heyunlei
>> Sent: Monday, February 26, 2018 8:07 PM
>> To: jaeg...@kernel.org; linux-f2fs-devel@lists.sourceforge.net; Yuchao (T)
>> Cc: Jianing (Euler); Wangbintian; heyunlei
>> Subject: [f2fs-dev][PATCH] f2fs: check blkaddr more accuratly before issue a 
>> bio
>>
>> This patch check blkaddr more accuratly before issue a
>> write or read bio.
>>
>> Signed-off-by: Yunlei He <heyun...@huawei.com>
>> ---
>> fs/f2fs/data.c    | 6 ++++--
>> fs/f2fs/segment.h | 9 +++++++--
>> 2 files changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>> index 62ead5e..5dc93bc 100644
>> --- a/fs/f2fs/data.c
>> +++ b/fs/f2fs/data.c
>> @@ -383,6 +383,8 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
>>      struct page *page = fio->encrypted_page ?
>>                      fio->encrypted_page : fio->page;
>>
>> +    verify_block_addr(fio->sbi, fio->new_blkaddr,
>> +                                    PAGE_TYPE_OF_BIO(fio->type));
> 
> 
> I'm sorry that read io will check fail during recovery or restore summary.
> 
> Could we check read io by previous method, write io with new method?

Hmm.. for META_POR or migration of encrypted pages pathes, we can add a
parameter (.use_meta?) in fio structure to indicate that current user will
borrow meta inode's mapping to issue read/write IO into main area, and then in
verify_block_addr we can check blkaddr as node's or data's one. How do you 
think?

Thanks,

> For I came across a broken partition, whose sit area is covered by a log file
> data.
> 
>>      trace_f2fs_submit_page_bio(page, fio);
>>      f2fs_trace_ios(fio, 0);
>>
>> @@ -428,8 +430,8 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
>>      }
>>
>>      if (fio->old_blkaddr != NEW_ADDR)
>> -            verify_block_addr(sbi, fio->old_blkaddr);
>> -    verify_block_addr(sbi, fio->new_blkaddr);
>> +            verify_block_addr(sbi, fio->old_blkaddr, btype);
>> +    verify_block_addr(sbi, fio->new_blkaddr, btype);
>>
>>      bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
>>
>> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
>> index f11c4bc..45c4e8d 100644
>> --- a/fs/f2fs/segment.h
>> +++ b/fs/f2fs/segment.h
>> @@ -630,9 +630,14 @@ static inline void check_seg_range(struct f2fs_sb_info 
>> *sbi, unsigned int segno)
>>      f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
>> }
>>
>> -static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t 
>> blk_addr)
>> +static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t 
>> blk_addr,
>> +                                                            enum page_type 
>> btype)
>> {
>> -    BUG_ON(blk_addr < SEG0_BLKADDR(sbi)
>> +    if (btype == META)
>> +            BUG_ON(blk_addr < SEG0_BLKADDR(sbi)
>> +                    || blk_addr >= MAIN_BLKADDR(sbi));
>> +    else
>> +            BUG_ON(blk_addr < MAIN_BLKADDR(sbi)
>>                      || blk_addr >= MAX_BLKADDR(sbi));
>> }
>>
>> --
>> 2.7.4
> 
> 
> .
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to