mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 10:10:00 +00:00
fsck.f2fs: detect and recover corrupted quota file
Once quota file is corrupted, kernel will set CP_QUOTA_NEED_FSCK_FLAG into checkpoint pack, this patch makes fsck supporting to detect the flag and try to rebuild corrupted quota file. Signed-off-by: Chao Yu <yuchao0@huawei.com>
This commit is contained in:
parent
7aab50d895
commit
dfede78aa9
@ -2670,7 +2670,8 @@ int fsck_verify(struct f2fs_sb_info *sbi)
|
||||
flush_curseg_sit_entries(sbi);
|
||||
}
|
||||
fix_checkpoint(sbi);
|
||||
} else if (is_set_ckpt_flags(cp, CP_FSCK_FLAG)) {
|
||||
} else if (is_set_ckpt_flags(cp, CP_FSCK_FLAG) ||
|
||||
is_set_ckpt_flags(cp, CP_QUOTA_NEED_FSCK_FLAG)) {
|
||||
write_checkpoint(sbi);
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +162,7 @@ static void add_default_options(void)
|
||||
case CONF_ANDROID:
|
||||
__add_fsck_options();
|
||||
}
|
||||
c.quota_fix = 1;
|
||||
}
|
||||
|
||||
void f2fs_parse_options(int argc, char *argv[])
|
||||
|
11
fsck/mount.c
11
fsck/mount.c
@ -405,6 +405,8 @@ void print_ckpt_info(struct f2fs_sb_info *sbi)
|
||||
void print_cp_state(u32 flag)
|
||||
{
|
||||
MSG(0, "Info: checkpoint state = %x : ", flag);
|
||||
if (flag & CP_QUOTA_NEED_FSCK_FLAG)
|
||||
MSG(0, "%s", " quota_need_fsck");
|
||||
if (flag & CP_LARGE_NAT_BITMAP_FLAG)
|
||||
MSG(0, "%s", " large_nat_bitmap");
|
||||
if (flag & CP_NOCRC_RECOVERY_FLAG)
|
||||
@ -2554,12 +2556,17 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi)
|
||||
|
||||
print_ckpt_info(sbi);
|
||||
|
||||
if (c.quota_fix) {
|
||||
if (get_cp(ckpt_flags) & CP_QUOTA_NEED_FSCK_FLAG)
|
||||
c.fix_on = 1;
|
||||
}
|
||||
|
||||
if (c.auto_fix || c.preen_mode) {
|
||||
u32 flag = get_cp(ckpt_flags);
|
||||
|
||||
if (flag & CP_FSCK_FLAG ||
|
||||
(exist_qf_ino(sb) && (!(flag & CP_UMOUNT_FLAG) ||
|
||||
flag & CP_ERROR_FLAG))) {
|
||||
flag & CP_QUOTA_NEED_FSCK_FLAG ||
|
||||
(exist_qf_ino(sb) && (flag & CP_ERROR_FLAG))) {
|
||||
c.fix_on = 1;
|
||||
} else if (!c.preen_mode) {
|
||||
print_cp_state(flag);
|
||||
|
@ -372,6 +372,7 @@ struct f2fs_configuration {
|
||||
int defset;
|
||||
int bug_on;
|
||||
int auto_fix;
|
||||
int quota_fix;
|
||||
int preen_mode;
|
||||
int ro;
|
||||
int preserve_limits; /* preserve quota limits */
|
||||
@ -642,6 +643,7 @@ struct f2fs_super_block {
|
||||
* For checkpoint
|
||||
*/
|
||||
#define CP_DISABLED_FLAG 0x00001000
|
||||
#define CP_QUOTA_NEED_FSCK_FLAG 0x00000800
|
||||
#define CP_LARGE_NAT_BITMAP_FLAG 0x00000400
|
||||
#define CP_NOCRC_RECOVERY_FLAG 0x00000200
|
||||
#define CP_TRIMMED_FLAG 0x00000100
|
||||
|
Loading…
Reference in New Issue
Block a user