From 726ea913c2a10e2a53f0ca02b8e24cdba82c7cae Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Sun, 12 Jul 2009 13:05:00 -0300
Subject: [PATCH 16/74] 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 |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

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;
-- 
1.6.2.2.646.gb214

