Lines 199-205
static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid,
Link Here
|
199 |
need_fix = 1; |
199 |
need_fix = 1; |
200 |
} |
200 |
} |
201 |
} |
201 |
} |
202 |
if (need_fix && !c.ro) { |
202 |
if (need_fix && f2fs_dev_is_writable()) { |
203 |
u64 ssa_blk; |
203 |
u64 ssa_blk; |
204 |
int ret2; |
204 |
int ret2; |
205 |
|
205 |
|
Lines 325-331
static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
Link Here
|
325 |
need_fix = 1; |
325 |
need_fix = 1; |
326 |
} |
326 |
} |
327 |
} |
327 |
} |
328 |
if (need_fix && !c.ro) { |
328 |
if (need_fix && f2fs_dev_is_writable()) { |
329 |
u64 ssa_blk; |
329 |
u64 ssa_blk; |
330 |
int ret2; |
330 |
int ret2; |
331 |
|
331 |
|
Lines 1015-1021
skip_blkcnt_fix:
Link Here
|
1015 |
} |
1015 |
} |
1016 |
|
1016 |
|
1017 |
/* drop extent information to avoid potential wrong access */ |
1017 |
/* drop extent information to avoid potential wrong access */ |
1018 |
if (need_fix && !c.ro) |
1018 |
if (need_fix && f2fs_dev_is_writable()) |
1019 |
node_blk->i.i_ext.len = 0; |
1019 |
node_blk->i.i_ext.len = 0; |
1020 |
|
1020 |
|
1021 |
if ((c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM)) && |
1021 |
if ((c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM)) && |
Lines 1038-1044
skip_blkcnt_fix:
Link Here
|
1038 |
} |
1038 |
} |
1039 |
} |
1039 |
} |
1040 |
|
1040 |
|
1041 |
if (need_fix && !c.ro) { |
1041 |
if (need_fix && f2fs_dev_is_writable()) { |
1042 |
ret = dev_write_block(node_blk, ni->blk_addr); |
1042 |
ret = dev_write_block(node_blk, ni->blk_addr); |
1043 |
ASSERT(ret >= 0); |
1043 |
ASSERT(ret >= 0); |
1044 |
} |
1044 |
} |
Lines 1073-1079
int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
Link Here
|
1073 |
FIX_MSG("[0x%x] dn.addr[%d] = 0", nid, idx); |
1073 |
FIX_MSG("[0x%x] dn.addr[%d] = 0", nid, idx); |
1074 |
} |
1074 |
} |
1075 |
} |
1075 |
} |
1076 |
if (need_fix && !c.ro) { |
1076 |
if (need_fix && f2fs_dev_is_writable()) { |
1077 |
ret = dev_write_block(node_blk, ni->blk_addr); |
1077 |
ret = dev_write_block(node_blk, ni->blk_addr); |
1078 |
ASSERT(ret >= 0); |
1078 |
ASSERT(ret >= 0); |
1079 |
} |
1079 |
} |
Lines 1110-1116
skip:
Link Here
|
1110 |
} |
1110 |
} |
1111 |
} |
1111 |
} |
1112 |
|
1112 |
|
1113 |
if (need_fix && !c.ro) { |
1113 |
if (need_fix && f2fs_dev_is_writable()) { |
1114 |
struct node_info ni; |
1114 |
struct node_info ni; |
1115 |
nid_t nid = le32_to_cpu(node_blk->footer.nid); |
1115 |
nid_t nid = le32_to_cpu(node_blk->footer.nid); |
1116 |
|
1116 |
|
Lines 1152-1158
skip:
Link Here
|
1152 |
} |
1152 |
} |
1153 |
} |
1153 |
} |
1154 |
|
1154 |
|
1155 |
if (need_fix && !c.ro) { |
1155 |
if (need_fix && f2fs_dev_is_writable()) { |
1156 |
struct node_info ni; |
1156 |
struct node_info ni; |
1157 |
nid_t nid = le32_to_cpu(node_blk->footer.nid); |
1157 |
nid_t nid = le32_to_cpu(node_blk->footer.nid); |
1158 |
|
1158 |
|
Lines 1595-1601
int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
Link Here
|
1595 |
de_blk->dentry, de_blk->filename, |
1595 |
de_blk->dentry, de_blk->filename, |
1596 |
NR_DENTRY_IN_BLOCK, last_blk, enc_name); |
1596 |
NR_DENTRY_IN_BLOCK, last_blk, enc_name); |
1597 |
|
1597 |
|
1598 |
if (dentries < 0 && !c.ro) { |
1598 |
if (dentries < 0 && f2fs_dev_is_writable()) { |
1599 |
ret = dev_write_block(de_blk, blk_addr); |
1599 |
ret = dev_write_block(de_blk, blk_addr); |
1600 |
ASSERT(ret >= 0); |
1600 |
ASSERT(ret >= 0); |
1601 |
DBG(1, "[%3d] Dentry Block [0x%x] Fixed hash_codes\n\n", |
1601 |
DBG(1, "[%3d] Dentry Block [0x%x] Fixed hash_codes\n\n", |
Lines 1708-1714
int fsck_chk_orphan_node(struct f2fs_sb_info *sbi)
Link Here
|
1708 |
else if (ret) |
1708 |
else if (ret) |
1709 |
ASSERT_MSG("[0x%x] wrong orphan inode", ino); |
1709 |
ASSERT_MSG("[0x%x] wrong orphan inode", ino); |
1710 |
} |
1710 |
} |
1711 |
if (!c.ro && c.fix_on && |
1711 |
if (f2fs_dev_is_writable() && c.fix_on && |
1712 |
entry_count != new_entry_count) { |
1712 |
entry_count != new_entry_count) { |
1713 |
new_blk->entry_count = cpu_to_le32(new_entry_count); |
1713 |
new_blk->entry_count = cpu_to_le32(new_entry_count); |
1714 |
ret = dev_write_block(new_blk, start_blk + i); |
1714 |
ret = dev_write_block(new_blk, start_blk + i); |
Lines 2719-2725
int fsck_verify(struct f2fs_sb_info *sbi)
Link Here
|
2719 |
} |
2719 |
} |
2720 |
#endif |
2720 |
#endif |
2721 |
/* fix global metadata */ |
2721 |
/* fix global metadata */ |
2722 |
if (force || (c.fix_on && !c.ro)) { |
2722 |
if (force || (c.fix_on && f2fs_dev_is_writable())) { |
2723 |
struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); |
2723 |
struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); |
2724 |
|
2724 |
|
2725 |
if (force || c.bug_on || c.bug_nat_bits) { |
2725 |
if (force || c.bug_on || c.bug_nat_bits) { |