git » libjio » commit 726ea91

libjio: Read previous operation before doing a journal_commit()

author Alberto Bertogli
2009-07-12 16:05:00 UTC
committer Alberto Bertogli
2009-07-12 16:05:00 UTC
parent c205c0d3a46e7a420a9ac2a187220e1959c7b226

libjio: Read previous operation before doing a journal_commit()

That way we give the kernel a chance to send the previous
journal_add_op()s to the disk, reducing the time spent waiting in
journal_commit()'s fdatasync().

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

libjio/trans.c +8 -8

diff --git a/libjio/trans.c b/libjio/trans.c
index 1d5c1ba..a8b7b88 100644
--- a/libjio/trans.c
+++ b/libjio/trans.c
@@ -223,14 +223,6 @@ ssize_t jtrans_commit(struct jtrans *ts)
 	if (jop == NULL)
 		goto unlock_exit;
 
-	if (!(ts->flags & J_NOROLLBACK)) {
-		for (op = ts->op; op != NULL; op = op->next) {
-			 r = operation_read_prev(ts, op);
-			 if (r < 0)
-				 goto unlink_exit;
-		}
-	}
-
 	for (op = ts->op; op != NULL; op = op->next) {
 		r = journal_add_op(jop, op->buf, op->len, op->offset);
 		if (r != 0)
@@ -241,6 +233,14 @@ ssize_t jtrans_commit(struct jtrans *ts)
 
 	fiu_exit_on("jio/commit/tf_data");
 
+	if (!(ts->flags & J_NOROLLBACK)) {
+		for (op = ts->op; op != NULL; op = op->next) {
+			 r = operation_read_prev(ts, op);
+			 if (r < 0)
+				 goto unlink_exit;
+		}
+	}
+
 	r = journal_commit(jop);
 	if (r < 0)
 		goto unlink_exit;