diff options
author | Zhihao Cheng <chengzhihao1@huawei.com> | 2024-11-11 17:08:10 +0800 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2024-11-11 10:32:46 +0100 |
commit | 30e65e7144e9a76db8302a2f34dc21e218901544 (patch) | |
tree | d3013efd2493e89b3fdaf3009eabaa172e81672e /ubifs-utils/fsck.ubifs | |
parent | 83b7477eae174e974237685f83f0fec4fb794892 (diff) |
fsck.ubifs: Commit problem fixing modifications to disk
This is the 13/18 step of fsck. Commit problem fixing modifications
(which are generated from the previous steps) to disk.
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/fsck.ubifs')
-rw-r--r-- | ubifs-utils/fsck.ubifs/fsck.ubifs.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ubifs-utils/fsck.ubifs/fsck.ubifs.c b/ubifs-utils/fsck.ubifs/fsck.ubifs.c index ba1b500..07ed817 100644 --- a/ubifs-utils/fsck.ubifs/fsck.ubifs.c +++ b/ubifs-utils/fsck.ubifs/fsck.ubifs.c @@ -432,6 +432,33 @@ void handle_error(const struct ubifs_info *c, int reason_set) exit_code |= FSCK_ERROR; } +static int commit_fix_modifications(struct ubifs_info *c) +{ + int err; + + if (exit_code & FSCK_NONDESTRUCT) { + log_out(c, "Commit problem fixing modifications"); + + /* + * Force UBIFS to do commit by setting @c->mounting if changes + * happen on disk. Committing is required once before allocating + * new space(subsequent steps may need), because building lpt + * could mark LEB(which holds stale data nodes) as unused, if + * the LEB is overwritten by new data, old data won't be found + * in next fsck run(assume that first fsck run is interrupted by + * the powercut), which could affect the correctness of LEB + * properties after replaying journal in the second fsck run. + */ + c->mounting = 1; + } + err = ubifs_run_commit(c); + + if (exit_code & FSCK_NONDESTRUCT) + c->mounting = 0; + + return err; +} + /* * do_fsck - Check & repair the filesystem. */ @@ -479,9 +506,16 @@ static int do_fsck(void) err = check_and_correct_space(c); kfree(FSCK(c)->used_lebs); destroy_file_tree(c, &FSCK(c)->scanned_files); + if (err) { + exit_code |= FSCK_ERROR; + goto free_disconnected_files_2; + } + + err = commit_fix_modifications(c); if (err) exit_code |= FSCK_ERROR; +free_disconnected_files_2: destroy_file_list(c, &FSCK(c)->disconnected_files); return err; @@ -532,6 +566,7 @@ int main(int argc, char *argv[]) * Step 10: Check and correct files * Step 11: Check whether the TNC is empty * Step 12: Check and correct the space statistics + * Step 13: Commit problem fixing modifications */ err = do_fsck(); if (err && FSCK(c)->try_rebuild) { |