Commit 3fa06d7b authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: readahead contiguous current summary blocks in checkpoint

Let's add readahead code for reading contiguous compact/normal summary blocks
in checkpoint, then we will gain better performance in mount procedure.

Changes from v1
  o remove inappropriate 'unlikely' in npages_for_summary_flush.
Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 5df1f1da
...@@ -922,7 +922,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -922,7 +922,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
ckpt->next_free_nid = cpu_to_le32(last_nid); ckpt->next_free_nid = cpu_to_le32(last_nid);
/* 2 cp + n data seg summary + orphan inode blocks */ /* 2 cp + n data seg summary + orphan inode blocks */
data_sum_blocks = npages_for_summary_flush(sbi); data_sum_blocks = npages_for_summary_flush(sbi, false);
if (data_sum_blocks < NR_CURSEG_DATA_TYPE) if (data_sum_blocks < NR_CURSEG_DATA_TYPE)
set_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG); set_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG);
else else
......
...@@ -1408,7 +1408,7 @@ void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t); ...@@ -1408,7 +1408,7 @@ void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t);
void clear_prefree_segments(struct f2fs_sb_info *); void clear_prefree_segments(struct f2fs_sb_info *);
void release_discard_addrs(struct f2fs_sb_info *); void release_discard_addrs(struct f2fs_sb_info *);
void discard_next_dnode(struct f2fs_sb_info *, block_t); void discard_next_dnode(struct f2fs_sb_info *, block_t);
int npages_for_summary_flush(struct f2fs_sb_info *); int npages_for_summary_flush(struct f2fs_sb_info *, bool);
void allocate_new_segments(struct f2fs_sb_info *); void allocate_new_segments(struct f2fs_sb_info *);
int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *); int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *);
struct page *get_sum_page(struct f2fs_sb_info *, unsigned int); struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
......
...@@ -725,7 +725,7 @@ static void __add_sum_entry(struct f2fs_sb_info *sbi, int type, ...@@ -725,7 +725,7 @@ static void __add_sum_entry(struct f2fs_sb_info *sbi, int type,
/* /*
* Calculate the number of current summary pages for writing * Calculate the number of current summary pages for writing
*/ */
int npages_for_summary_flush(struct f2fs_sb_info *sbi) int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra)
{ {
int valid_sum_count = 0; int valid_sum_count = 0;
int i, sum_in_page; int i, sum_in_page;
...@@ -733,8 +733,13 @@ int npages_for_summary_flush(struct f2fs_sb_info *sbi) ...@@ -733,8 +733,13 @@ int npages_for_summary_flush(struct f2fs_sb_info *sbi)
for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
if (sbi->ckpt->alloc_type[i] == SSR) if (sbi->ckpt->alloc_type[i] == SSR)
valid_sum_count += sbi->blocks_per_seg; valid_sum_count += sbi->blocks_per_seg;
else else {
valid_sum_count += curseg_blkoff(sbi, i); if (for_ra)
valid_sum_count += le16_to_cpu(
F2FS_CKPT(sbi)->cur_data_blkoff[i]);
else
valid_sum_count += curseg_blkoff(sbi, i);
}
} }
sum_in_page = (PAGE_CACHE_SIZE - 2 * SUM_JOURNAL_SIZE - sum_in_page = (PAGE_CACHE_SIZE - 2 * SUM_JOURNAL_SIZE -
...@@ -1440,12 +1445,22 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi) ...@@ -1440,12 +1445,22 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi)
int err; int err;
if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_COMPACT_SUM_FLAG)) { if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_COMPACT_SUM_FLAG)) {
int npages = npages_for_summary_flush(sbi, true);
if (npages >= 2)
ra_meta_pages(sbi, start_sum_block(sbi), npages,
META_CP);
/* restore for compacted data summary */ /* restore for compacted data summary */
if (read_compacted_summaries(sbi)) if (read_compacted_summaries(sbi))
return -EINVAL; return -EINVAL;
type = CURSEG_HOT_NODE; type = CURSEG_HOT_NODE;
} }
if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG))
ra_meta_pages(sbi, sum_blk_addr(sbi, NR_CURSEG_TYPE, type),
NR_CURSEG_TYPE - type, META_CP);
for (; type <= CURSEG_COLD_NODE; type++) { for (; type <= CURSEG_COLD_NODE; type++) {
err = read_normal_summaries(sbi, type); err = read_normal_summaries(sbi, type);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment