git » libjio » commit eb542d6

Make jfsck() rewrite the lockfile to save the new maximum transaction ID. Otherwise, when we try to rollback, we could step over some transaction file we want to recover, or face a corrupt lockfile.

author Alberto Bertogli
2004-05-05 18:08:22 UTC
committer Alberto Bertogli
2007-07-15 12:44:27 UTC
parent 041ce8cb7b0b4deb9559ce97e30937f660e4e725

Make jfsck() rewrite the lockfile to save the new maximum transaction ID. Otherwise, when we try to rollback, we could step over some transaction file we want to recover, or face a corrupt lockfile.

Make jfsck() rewrite the lockfile to save the new maximum transaction ID.
Otherwise, when we try to rollback, we could step over some transaction file
we want to recover, or face a corrupt lockfile.

libjio.c +7 -0

diff --git a/libjio.c b/libjio.c
index e6f88fc..4cc25ae 100644
--- a/libjio.c
+++ b/libjio.c
@@ -735,6 +735,13 @@ int jfsck(const char *name, struct jfsck_result *res)
 	}
 	closedir(dir);
 
+	/* rewrite the lockfile, writing the new maxtid on it, so that when we
+	 * rollback a transaction it doesn't step over existing ones */
+	rv = spwrite(fs.jfd, &maxtid, sizeof(maxtid), 0);
+	if (rv != sizeof(maxtid)) {
+		return J_ENOMEM;
+	}
+
 	/* we loop all the way up to the max transaction id */
 	for (i = 1; i <= maxtid; i++) {
 		curts = malloc(sizeof(struct jtrans));