checkpoint.c (1601839e9e5bd5726d744c9c5919f87dc808bbcc) | checkpoint.c (caf0047e7e1e60a7ad1d655d3b81b32e2dfb6095) |
---|---|
1/* 2 * fs/f2fs/checkpoint.c 3 * 4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 * http://www.samsung.com/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 176 unchanged lines hidden (view full) --- 185 186static int f2fs_write_meta_page(struct page *page, 187 struct writeback_control *wbc) 188{ 189 struct f2fs_sb_info *sbi = F2FS_P_SB(page); 190 191 trace_f2fs_writepage(page, META); 192 | 1/* 2 * fs/f2fs/checkpoint.c 3 * 4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 * http://www.samsung.com/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 176 unchanged lines hidden (view full) --- 185 186static int f2fs_write_meta_page(struct page *page, 187 struct writeback_control *wbc) 188{ 189 struct f2fs_sb_info *sbi = F2FS_P_SB(page); 190 191 trace_f2fs_writepage(page, META); 192 |
193 if (unlikely(sbi->por_doing)) | 193 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) |
194 goto redirty_out; 195 if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0)) 196 goto redirty_out; 197 if (unlikely(f2fs_cp_error(sbi))) 198 goto redirty_out; 199 200 f2fs_wait_on_page_writeback(page, META); 201 write_meta_page(sbi, page); --- 278 unchanged lines hidden (view full) --- 480 481void recover_orphan_inodes(struct f2fs_sb_info *sbi) 482{ 483 block_t start_blk, orphan_blkaddr, i, j; 484 485 if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG)) 486 return; 487 | 194 goto redirty_out; 195 if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0)) 196 goto redirty_out; 197 if (unlikely(f2fs_cp_error(sbi))) 198 goto redirty_out; 199 200 f2fs_wait_on_page_writeback(page, META); 201 write_meta_page(sbi, page); --- 278 unchanged lines hidden (view full) --- 480 481void recover_orphan_inodes(struct f2fs_sb_info *sbi) 482{ 483 block_t start_blk, orphan_blkaddr, i, j; 484 485 if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG)) 486 return; 487 |
488 sbi->por_doing = true; | 488 set_sbi_flag(sbi, SBI_POR_DOING); |
489 490 start_blk = __start_cp_addr(sbi) + 1 + 491 le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload); 492 orphan_blkaddr = __start_sum_addr(sbi) - 1; 493 494 ra_meta_pages(sbi, start_blk, orphan_blkaddr, META_CP); 495 496 for (i = 0; i < orphan_blkaddr; i++) { --- 4 unchanged lines hidden (view full) --- 501 for (j = 0; j < le32_to_cpu(orphan_blk->entry_count); j++) { 502 nid_t ino = le32_to_cpu(orphan_blk->ino[j]); 503 recover_orphan_inode(sbi, ino); 504 } 505 f2fs_put_page(page, 1); 506 } 507 /* clear Orphan Flag */ 508 clear_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG); | 489 490 start_blk = __start_cp_addr(sbi) + 1 + 491 le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload); 492 orphan_blkaddr = __start_sum_addr(sbi) - 1; 493 494 ra_meta_pages(sbi, start_blk, orphan_blkaddr, META_CP); 495 496 for (i = 0; i < orphan_blkaddr; i++) { --- 4 unchanged lines hidden (view full) --- 501 for (j = 0; j < le32_to_cpu(orphan_blk->entry_count); j++) { 502 nid_t ino = le32_to_cpu(orphan_blk->ino[j]); 503 recover_orphan_inode(sbi, ino); 504 } 505 f2fs_put_page(page, 1); 506 } 507 /* clear Orphan Flag */ 508 clear_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG); |
509 sbi->por_doing = false; | 509 clear_sbi_flag(sbi, SBI_POR_DOING); |
510 return; 511} 512 513static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk) 514{ 515 struct list_head *head; 516 struct f2fs_orphan_block *orphan_blk = NULL; 517 unsigned int nentries = 0; --- 450 unchanged lines hidden (view full) --- 968 orphan_blocks); 969 } 970 971 if (orphan_num) 972 set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); 973 else 974 clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); 975 | 510 return; 511} 512 513static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk) 514{ 515 struct list_head *head; 516 struct f2fs_orphan_block *orphan_blk = NULL; 517 unsigned int nentries = 0; --- 450 unchanged lines hidden (view full) --- 968 orphan_blocks); 969 } 970 971 if (orphan_num) 972 set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); 973 else 974 clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); 975 |
976 if (sbi->need_fsck) | 976 if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) |
977 set_ckpt_flags(ckpt, CP_FSCK_FLAG); 978 979 /* update SIT/NAT bitmap */ 980 get_sit_bitmap(sbi, __bitmap_ptr(sbi, SIT_BITMAP)); 981 get_nat_bitmap(sbi, __bitmap_ptr(sbi, NAT_BITMAP)); 982 983 crc32 = f2fs_crc32(ckpt, le32_to_cpu(ckpt->checksum_offset)); 984 *((__le32 *)((unsigned char *)ckpt + --- 57 unchanged lines hidden (view full) --- 1042 wait_on_all_pages_writeback(sbi); 1043 1044 release_dirty_inode(sbi); 1045 1046 if (unlikely(f2fs_cp_error(sbi))) 1047 return; 1048 1049 clear_prefree_segments(sbi); | 977 set_ckpt_flags(ckpt, CP_FSCK_FLAG); 978 979 /* update SIT/NAT bitmap */ 980 get_sit_bitmap(sbi, __bitmap_ptr(sbi, SIT_BITMAP)); 981 get_nat_bitmap(sbi, __bitmap_ptr(sbi, NAT_BITMAP)); 982 983 crc32 = f2fs_crc32(ckpt, le32_to_cpu(ckpt->checksum_offset)); 984 *((__le32 *)((unsigned char *)ckpt + --- 57 unchanged lines hidden (view full) --- 1042 wait_on_all_pages_writeback(sbi); 1043 1044 release_dirty_inode(sbi); 1045 1046 if (unlikely(f2fs_cp_error(sbi))) 1047 return; 1048 1049 clear_prefree_segments(sbi); |
1050 F2FS_RESET_SB_DIRT(sbi); | 1050 clear_sbi_flag(sbi, SBI_IS_DIRTY); |
1051} 1052 1053/* 1054 * We guarantee that this checkpoint procedure will not fail. 1055 */ 1056void write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) 1057{ 1058 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 1059 unsigned long long ckpt_ver; 1060 1061 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "start block_ops"); 1062 1063 mutex_lock(&sbi->cp_mutex); 1064 | 1051} 1052 1053/* 1054 * We guarantee that this checkpoint procedure will not fail. 1055 */ 1056void write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) 1057{ 1058 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 1059 unsigned long long ckpt_ver; 1060 1061 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "start block_ops"); 1062 1063 mutex_lock(&sbi->cp_mutex); 1064 |
1065 if (!sbi->s_dirty && | 1065 if (!is_sbi_flag_set(sbi, SBI_IS_DIRTY) && |
1066 cpc->reason != CP_DISCARD && cpc->reason != CP_UMOUNT) 1067 goto out; 1068 if (unlikely(f2fs_cp_error(sbi))) 1069 goto out; 1070 if (block_operations(sbi)) 1071 goto out; 1072 1073 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish block_ops"); --- 70 unchanged lines hidden --- | 1066 cpc->reason != CP_DISCARD && cpc->reason != CP_UMOUNT) 1067 goto out; 1068 if (unlikely(f2fs_cp_error(sbi))) 1069 goto out; 1070 if (block_operations(sbi)) 1071 goto out; 1072 1073 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish block_ops"); --- 70 unchanged lines hidden --- |