Skip to contentSkip to conversation

f2fs: check blkaddr more accuratly before issue a bio

PATCH Chao Yu 1 participant 1 message Feb 27, 2018 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 42B685BFA705F94C860C6DD0752F05654833BB7F@DGGEMA503-MBX.china.huawei.com

Chao Yu

author
#2 lore raw
Quoted 26 lines · heyunlei
Quoted 26 lines

-----Original Message-----
From: heyunlei
Sent: Monday, February 26, 2018 8:07 PM
To: [email protected]; [email protected]; 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.

---
fs/f2fs/data.c | 6 ++++--
fs/f2fs/segment.h | 9 +++++++--

2 files changed, 11 insertions(+), 4 deletions(-)
fs/f2fs/data.c +0 -0
index 62ead5e..5dc93bc 100644
@@ -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;
 
Quoted 7 lines

fs/f2fs/data.c int f2fs_submit_page_bio(struct f2fs_io_info *fio) · line 387

Quoted 2 lines
fs/f2fs/data.c +2 -0
+	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,

Quoted 38 lines

For I came across a broken partition, whose sit area is covered by a log file data.

Quoted 35 lines
fs/f2fs/data.c +2 -2
 	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;
 
fs/f2fs/segment.h +7 -2
index f11c4bc..45c4e8d 100644
@@ -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));
 }
 
Quoted 6 lines
Quoted 2 lines

--
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