Skip to content

Commit 7ea984b

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: do in batch synchronously readahead during GC
In order to enhance performance, we try to readahead node page during GC, but before loading node page we should get block address of node page which is stored in NAT table, so synchronously read of single NAT page block our readahead flow. f2fs_submit_page_bio: dev = (251,0), ino = 2, page_index = 0xa1e, oldaddr = 0xa1e, newaddr = 0xa1e, rw = READ_SYNC(MP), type = META f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x35e9, oldaddr = 0x72d7a, newaddr = 0x72d7a, rw = READAHEAD ^H, type = NODE f2fs_submit_page_bio: dev = (251,0), ino = 2, page_index = 0xc1f, oldaddr = 0xc1f, newaddr = 0xc1f, rw = READ_SYNC(MP), type = META f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x389d, oldaddr = 0x72d7d, newaddr = 0x72d7d, rw = READAHEAD ^H, type = NODE f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x3a82, oldaddr = 0x72d7f, newaddr = 0x72d7f, rw = READAHEAD ^H, type = NODE f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x3bfa, oldaddr = 0x72d86, newaddr = 0x72d86, rw = READAHEAD ^H, type = NODE This patch adds one phase that do readahead NAT pages in batch before readahead node page for more effeciently. f2fs_submit_page_bio: dev = (251,0), ino = 2, page_index = 0x1952, oldaddr = 0x1952, newaddr = 0x1952, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc34, oldaddr = 0xc34, newaddr = 0xc34, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xa33, oldaddr = 0xa33, newaddr = 0xa33, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc30, oldaddr = 0xc30, newaddr = 0xc30, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc32, oldaddr = 0xc32, newaddr = 0xc32, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc26, oldaddr = 0xc26, newaddr = 0xc26, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xa2b, oldaddr = 0xa2b, newaddr = 0xa2b, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc23, oldaddr = 0xc23, newaddr = 0xc23, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc24, oldaddr = 0xc24, newaddr = 0xc24, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xa10, oldaddr = 0xa10, newaddr = 0xa10, rw = READ_SYNC(MP), type = META f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc2c, oldaddr = 0xc2c, newaddr = 0xc2c, rw = READ_SYNC(MP), type = META f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5db7, oldaddr = 0x6be00, newaddr = 0x6be00, rw = READAHEAD ^H, type = NODE f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5db9, oldaddr = 0x6be17, newaddr = 0x6be17, rw = READAHEAD ^H, type = NODE f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5dbc, oldaddr = 0x6be1a, newaddr = 0x6be1a, rw = READAHEAD ^H, type = NODE f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5dc3, oldaddr = 0x6be20, newaddr = 0x6be20, rw = READAHEAD ^H, type = NODE f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5dc7, oldaddr = 0x6be24, newaddr = 0x6be24, rw = READAHEAD ^H, type = NODE f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5dc9, oldaddr = 0x6be25, newaddr = 0x6be25, rw = READAHEAD ^H, type = NODE Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 74fa5f3 commit 7ea984b

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

fs/f2fs/gc.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,10 @@ static int check_valid_map(struct f2fs_sb_info *sbi,
423423
static void gc_node_segment(struct f2fs_sb_info *sbi,
424424
struct f2fs_summary *sum, unsigned int segno, int gc_type)
425425
{
426-
bool initial = true;
427426
struct f2fs_summary *entry;
428427
block_t start_addr;
429428
int off;
429+
int phase = 0;
430430

431431
start_addr = START_BLOCK(sbi, segno);
432432

@@ -445,10 +445,18 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
445445
if (check_valid_map(sbi, segno, off) == 0)
446446
continue;
447447

448-
if (initial) {
448+
if (phase == 0) {
449+
ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), 1,
450+
META_NAT, true);
451+
continue;
452+
}
453+
454+
if (phase == 1) {
449455
ra_node_page(sbi, nid);
450456
continue;
451457
}
458+
459+
/* phase == 2 */
452460
node_page = get_node_page(sbi, nid);
453461
if (IS_ERR(node_page))
454462
continue;
@@ -469,10 +477,8 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
469477
stat_inc_node_blk_count(sbi, 1, gc_type);
470478
}
471479

472-
if (initial) {
473-
initial = false;
480+
if (++phase < 3)
474481
goto next_step;
475-
}
476482
}
477483

478484
/*
@@ -706,6 +712,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
706712
struct node_info dni; /* dnode info for the data */
707713
unsigned int ofs_in_node, nofs;
708714
block_t start_bidx;
715+
nid_t nid = le32_to_cpu(entry->nid);
709716

710717
/* stop BG_GC if there is not enough free sections. */
711718
if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0))
@@ -715,22 +722,28 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
715722
continue;
716723

717724
if (phase == 0) {
718-
ra_node_page(sbi, le32_to_cpu(entry->nid));
725+
ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), 1,
726+
META_NAT, true);
727+
continue;
728+
}
729+
730+
if (phase == 1) {
731+
ra_node_page(sbi, nid);
719732
continue;
720733
}
721734

722735
/* Get an inode by ino with checking validity */
723736
if (!is_alive(sbi, entry, &dni, start_addr + off, &nofs))
724737
continue;
725738

726-
if (phase == 1) {
739+
if (phase == 2) {
727740
ra_node_page(sbi, dni.ino);
728741
continue;
729742
}
730743

731744
ofs_in_node = le16_to_cpu(entry->ofs_in_node);
732745

733-
if (phase == 2) {
746+
if (phase == 3) {
734747
inode = f2fs_iget(sb, dni.ino);
735748
if (IS_ERR(inode) || is_bad_inode(inode))
736749
continue;
@@ -756,7 +769,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
756769
continue;
757770
}
758771

759-
/* phase 3 */
772+
/* phase 4 */
760773
inode = find_gc_inode(gc_list, dni.ino);
761774
if (inode) {
762775
struct f2fs_inode_info *fi = F2FS_I(inode);
@@ -789,7 +802,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
789802
}
790803
}
791804

792-
if (++phase < 4)
805+
if (++phase < 5)
793806
goto next_step;
794807
}
795808

0 commit comments

Comments
 (0)