[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240607042615.2069840-92-chengzhihao1@huawei.com>
Date: Fri, 7 Jun 2024 12:25:56 +0800
From: Zhihao Cheng <chengzhihao1@...wei.com>
To: <richard@....at>, <david.oberhollenzer@...ma-star.at>,
<miquel.raynal@...tlin.com>, <yi.zhang@...wei.com>, <xiangyang3@...wei.com>,
<huangxiaojia2@...wei.com>
CC: <linux-mtd@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH mtd-utils 091/110] 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@...wei.com>
---
ubifs-utils/fsck.ubifs/fsck.ubifs.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/ubifs-utils/fsck.ubifs/fsck.ubifs.c b/ubifs-utils/fsck.ubifs/fsck.ubifs.c
index 436831cb..66b9c578 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) {
--
2.13.6
Powered by blists - more mailing lists