@@ -423,10 +423,10 @@ static int check_valid_map(struct f2fs_sb_info *sbi,
423
423
static void gc_node_segment (struct f2fs_sb_info * sbi ,
424
424
struct f2fs_summary * sum , unsigned int segno , int gc_type )
425
425
{
426
- bool initial = true;
427
426
struct f2fs_summary * entry ;
428
427
block_t start_addr ;
429
428
int off ;
429
+ int phase = 0 ;
430
430
431
431
start_addr = START_BLOCK (sbi , segno );
432
432
@@ -445,10 +445,18 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
445
445
if (check_valid_map (sbi , segno , off ) == 0 )
446
446
continue ;
447
447
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 ) {
449
455
ra_node_page (sbi , nid );
450
456
continue ;
451
457
}
458
+
459
+ /* phase == 2 */
452
460
node_page = get_node_page (sbi , nid );
453
461
if (IS_ERR (node_page ))
454
462
continue ;
@@ -469,10 +477,8 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
469
477
stat_inc_node_blk_count (sbi , 1 , gc_type );
470
478
}
471
479
472
- if (initial ) {
473
- initial = false;
480
+ if (++ phase < 3 )
474
481
goto next_step ;
475
- }
476
482
}
477
483
478
484
/*
@@ -706,6 +712,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
706
712
struct node_info dni ; /* dnode info for the data */
707
713
unsigned int ofs_in_node , nofs ;
708
714
block_t start_bidx ;
715
+ nid_t nid = le32_to_cpu (entry -> nid );
709
716
710
717
/* stop BG_GC if there is not enough free sections. */
711
718
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,
715
722
continue ;
716
723
717
724
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 );
719
732
continue ;
720
733
}
721
734
722
735
/* Get an inode by ino with checking validity */
723
736
if (!is_alive (sbi , entry , & dni , start_addr + off , & nofs ))
724
737
continue ;
725
738
726
- if (phase == 1 ) {
739
+ if (phase == 2 ) {
727
740
ra_node_page (sbi , dni .ino );
728
741
continue ;
729
742
}
730
743
731
744
ofs_in_node = le16_to_cpu (entry -> ofs_in_node );
732
745
733
- if (phase == 2 ) {
746
+ if (phase == 3 ) {
734
747
inode = f2fs_iget (sb , dni .ino );
735
748
if (IS_ERR (inode ) || is_bad_inode (inode ))
736
749
continue ;
@@ -756,7 +769,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
756
769
continue ;
757
770
}
758
771
759
- /* phase 3 */
772
+ /* phase 4 */
760
773
inode = find_gc_inode (gc_list , dni .ino );
761
774
if (inode ) {
762
775
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,
789
802
}
790
803
}
791
804
792
- if (++ phase < 4 )
805
+ if (++ phase < 5 )
793
806
goto next_step ;
794
807
}
795
808
0 commit comments