提交 d653788a 编写于 作者: G Gu Zheng 提交者: Jaegeuk Kim

f2fs: optimize restore_node_summary slightly

Previously, we ra_sum_pages to pre-read contiguous pages as more
as possible, and if we fail to alloc more pages, an ENOMEM error
will be reported upstream, even though we have alloced some pages
yet. In fact, we can use the available pages to do the job partly,
and continue the rest in the following circle. Only reporting ENOMEM
upstream if we really can not alloc any available page.

And another fix is ignoring dealing with the following pages if an
EIO occurs when reading page from page_list.
Signed-off-by: NGu Zheng <guz.fnst@cn.fujitsu.com>
Reviewed-by: NChao Yu <chao2.yu@samsung.com>
[Jaegeuk Kim: modify the flow for better neat code]
Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
上级 46c04366
...@@ -1588,15 +1588,8 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages, ...@@ -1588,15 +1588,8 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,
for (; page_idx < start + nrpages; page_idx++) { for (; page_idx < start + nrpages; page_idx++) {
/* alloc temporal page for read node summary info*/ /* alloc temporal page for read node summary info*/
page = alloc_page(GFP_F2FS_ZERO); page = alloc_page(GFP_F2FS_ZERO);
if (!page) { if (!page)
struct page *tmp; break;
list_for_each_entry_safe(page, tmp, pages, lru) {
list_del(&page->lru);
unlock_page(page);
__free_pages(page, 0);
}
return -ENOMEM;
}
lock_page(page); lock_page(page);
page->index = page_idx; page->index = page_idx;
...@@ -1607,7 +1600,8 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages, ...@@ -1607,7 +1600,8 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,
f2fs_submit_page_mbio(sbi, page, page->index, &fio); f2fs_submit_page_mbio(sbi, page, page->index, &fio);
f2fs_submit_merged_bio(sbi, META, READ); f2fs_submit_merged_bio(sbi, META, READ);
return 0;
return page_idx - start;
} }
int restore_node_summary(struct f2fs_sb_info *sbi, int restore_node_summary(struct f2fs_sb_info *sbi,
...@@ -1626,15 +1620,17 @@ int restore_node_summary(struct f2fs_sb_info *sbi, ...@@ -1626,15 +1620,17 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
addr = START_BLOCK(sbi, segno); addr = START_BLOCK(sbi, segno);
sum_entry = &sum->entries[0]; sum_entry = &sum->entries[0];
for (i = 0; i < last_offset; i += nrpages, addr += nrpages) { for (i = 0; !err && i < last_offset; i += nrpages, addr += nrpages) {
nrpages = min(last_offset - i, bio_blocks); nrpages = min(last_offset - i, bio_blocks);
/* read ahead node pages */ /* read ahead node pages */
err = ra_sum_pages(sbi, &page_list, addr, nrpages); nrpages = ra_sum_pages(sbi, &page_list, addr, nrpages);
if (err) if (!nrpages)
return err; return -ENOMEM;
list_for_each_entry_safe(page, tmp, &page_list, lru) { list_for_each_entry_safe(page, tmp, &page_list, lru) {
if (err)
goto skip;
lock_page(page); lock_page(page);
if (unlikely(!PageUptodate(page))) { if (unlikely(!PageUptodate(page))) {
...@@ -1646,9 +1642,9 @@ int restore_node_summary(struct f2fs_sb_info *sbi, ...@@ -1646,9 +1642,9 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
sum_entry->ofs_in_node = 0; sum_entry->ofs_in_node = 0;
sum_entry++; sum_entry++;
} }
list_del(&page->lru);
unlock_page(page); unlock_page(page);
skip:
list_del(&page->lru);
__free_pages(page, 0); __free_pages(page, 0);
} }
} }
......
...@@ -1160,9 +1160,12 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) ...@@ -1160,9 +1160,12 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type)
ns->ofs_in_node = 0; ns->ofs_in_node = 0;
} }
} else { } else {
if (restore_node_summary(sbi, segno, sum)) { int err;
err = restore_node_summary(sbi, segno, sum);
if (err) {
f2fs_put_page(new, 1); f2fs_put_page(new, 1);
return -EINVAL; return err;
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册