recovery.c (5298d4bfe80f6ae6ae2777bcd1357b0022d98573) recovery.c (e4544b63a7ee49e7fbebf35ece0a6acd3b9617ae)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/recovery.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <asm/unaligned.h>

--- 32 unchanged lines hidden (view full) ---

41 *
42 * 8. CP | dnode(F) | inode(x)
43 * -> If f2fs_iget fails, then goto next to find inode(DF).
44 * But it will fail due to no inode(DF).
45 */
46
47static struct kmem_cache *fsync_entry_slab;
48
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/recovery.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <asm/unaligned.h>

--- 32 unchanged lines hidden (view full) ---

41 *
42 * 8. CP | dnode(F) | inode(x)
43 * -> If f2fs_iget fails, then goto next to find inode(DF).
44 * But it will fail due to no inode(DF).
45 */
46
47static struct kmem_cache *fsync_entry_slab;
48
49#if IS_ENABLED(CONFIG_UNICODE)
49#ifdef CONFIG_UNICODE
50extern struct kmem_cache *f2fs_cf_name_slab;
51#endif
52
53bool f2fs_space_for_roll_forward(struct f2fs_sb_info *sbi)
54{
55 s64 nalloc = percpu_counter_sum_positive(&sbi->alloc_valid_block_count);
56
57 if (sbi->last_valid_block_count + nalloc > sbi->user_block_count)

--- 86 unchanged lines hidden (view full) ---

144 return -EINVAL;
145 fname->hash = get_unaligned((f2fs_hash_t *)
146 &raw_inode->i_name[fname->disk_name.len]);
147 } else if (IS_CASEFOLDED(dir)) {
148 err = f2fs_init_casefolded_name(dir, fname);
149 if (err)
150 return err;
151 f2fs_hash_filename(dir, fname);
50extern struct kmem_cache *f2fs_cf_name_slab;
51#endif
52
53bool f2fs_space_for_roll_forward(struct f2fs_sb_info *sbi)
54{
55 s64 nalloc = percpu_counter_sum_positive(&sbi->alloc_valid_block_count);
56
57 if (sbi->last_valid_block_count + nalloc > sbi->user_block_count)

--- 86 unchanged lines hidden (view full) ---

144 return -EINVAL;
145 fname->hash = get_unaligned((f2fs_hash_t *)
146 &raw_inode->i_name[fname->disk_name.len]);
147 } else if (IS_CASEFOLDED(dir)) {
148 err = f2fs_init_casefolded_name(dir, fname);
149 if (err)
150 return err;
151 f2fs_hash_filename(dir, fname);
152#if IS_ENABLED(CONFIG_UNICODE)
152#ifdef CONFIG_UNICODE
153 /* Case-sensitive match is fine for recovery */
154 kmem_cache_free(f2fs_cf_name_slab, fname->cf_name.name);
155 fname->cf_name.name = NULL;
156#endif
157 } else {
158 f2fs_hash_filename(dir, fname);
159 }
160 return 0;

--- 430 unchanged lines hidden (view full) ---

591 memalloc_retry_wait(GFP_NOFS);
592 goto retry_dn;
593 }
594 goto out;
595 }
596
597 f2fs_wait_on_page_writeback(dn.node_page, NODE, true, true);
598
153 /* Case-sensitive match is fine for recovery */
154 kmem_cache_free(f2fs_cf_name_slab, fname->cf_name.name);
155 fname->cf_name.name = NULL;
156#endif
157 } else {
158 f2fs_hash_filename(dir, fname);
159 }
160 return 0;

--- 430 unchanged lines hidden (view full) ---

591 memalloc_retry_wait(GFP_NOFS);
592 goto retry_dn;
593 }
594 goto out;
595 }
596
597 f2fs_wait_on_page_writeback(dn.node_page, NODE, true, true);
598
599 err = f2fs_get_node_info(sbi, dn.nid, &ni);
599 err = f2fs_get_node_info(sbi, dn.nid, &ni, false);
600 if (err)
601 goto err;
602
603 f2fs_bug_on(sbi, ni.ino != ino_of_node(page));
604
605 if (ofs_of_node(dn.node_page) != ofs_of_node(page)) {
606 f2fs_warn(sbi, "Inconsistent ofs_of_node, ino:%lu, ofs:%u, %u",
607 inode->i_ino, ofs_of_node(dn.node_page),

--- 183 unchanged lines hidden (view full) ---

791 quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
792#endif
793
794 INIT_LIST_HEAD(&inode_list);
795 INIT_LIST_HEAD(&tmp_inode_list);
796 INIT_LIST_HEAD(&dir_list);
797
798 /* prevent checkpoint */
600 if (err)
601 goto err;
602
603 f2fs_bug_on(sbi, ni.ino != ino_of_node(page));
604
605 if (ofs_of_node(dn.node_page) != ofs_of_node(page)) {
606 f2fs_warn(sbi, "Inconsistent ofs_of_node, ino:%lu, ofs:%u, %u",
607 inode->i_ino, ofs_of_node(dn.node_page),

--- 183 unchanged lines hidden (view full) ---

791 quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
792#endif
793
794 INIT_LIST_HEAD(&inode_list);
795 INIT_LIST_HEAD(&tmp_inode_list);
796 INIT_LIST_HEAD(&dir_list);
797
798 /* prevent checkpoint */
799 down_write(&sbi->cp_global_sem);
799 f2fs_down_write(&sbi->cp_global_sem);
800
801 /* step #1: find fsynced inode numbers */
802 err = find_fsync_dnodes(sbi, &inode_list, check_only);
803 if (err || list_empty(&inode_list))
804 goto skip;
805
806 if (check_only) {
807 ret = 1;

--- 32 unchanged lines hidden (view full) ---

840 f2fs_sb_has_blkzoned(sbi)) {
841 err = f2fs_fix_curseg_write_pointer(sbi);
842 ret = err;
843 }
844
845 if (!err)
846 clear_sbi_flag(sbi, SBI_POR_DOING);
847
800
801 /* step #1: find fsynced inode numbers */
802 err = find_fsync_dnodes(sbi, &inode_list, check_only);
803 if (err || list_empty(&inode_list))
804 goto skip;
805
806 if (check_only) {
807 ret = 1;

--- 32 unchanged lines hidden (view full) ---

840 f2fs_sb_has_blkzoned(sbi)) {
841 err = f2fs_fix_curseg_write_pointer(sbi);
842 ret = err;
843 }
844
845 if (!err)
846 clear_sbi_flag(sbi, SBI_POR_DOING);
847
848 up_write(&sbi->cp_global_sem);
848 f2fs_up_write(&sbi->cp_global_sem);
849
850 /* let's drop all the directory inodes for clean checkpoint */
851 destroy_fsync_dnodes(&dir_list, err);
852
853 if (need_writecp) {
854 set_sbi_flag(sbi, SBI_IS_RECOVERED);
855
856 if (!err) {

--- 30 unchanged lines hidden ---
849
850 /* let's drop all the directory inodes for clean checkpoint */
851 destroy_fsync_dnodes(&dir_list, err);
852
853 if (need_writecp) {
854 set_sbi_flag(sbi, SBI_IS_RECOVERED);
855
856 if (!err) {

--- 30 unchanged lines hidden ---