git » libjio » commit ec7861b

libjio: Submit the file sync before journal_commit()

author Alberto Bertogli
2009-07-12 16:17:21 UTC
committer Alberto Bertogli
2009-07-12 16:17:21 UTC
parent 726ea913c2a10e2a53f0ca02b8e24cdba82c7cae

libjio: Submit the file sync before journal_commit()

In an attempt to reduce journal_commit() fsync() waiting time, we submit
the sync earlier, hoping that at least some of it will be ready by the
time we hit journal_commit().

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

libjio/journal.c +9 -0
libjio/journal.h +1 -0
libjio/trans.c +2 -0

diff --git a/libjio/journal.c b/libjio/journal.c
index b823b5d..589e8f1 100644
--- a/libjio/journal.c
+++ b/libjio/journal.c
@@ -312,6 +312,15 @@ error:
 	return -1;
 }
 
+/** Prepares to commit the operation. Can be omitted. */
+void journal_pre_commit(struct journal_op *jop)
+{
+	/* In an attempt to reduce journal_commit() fsync() waiting time, we
+	 * submit the sync here, hoping that at least some of it will be ready
+	 * by the time we hit journal_commit() */
+	sync_range_submit(jop->fd, 0, 0);
+}
+
 /** Commit the journal operation */
 int journal_commit(struct journal_op *jop)
 {
diff --git a/libjio/journal.h b/libjio/journal.h
index 648fcb9..80060c2 100644
--- a/libjio/journal.h
+++ b/libjio/journal.h
@@ -21,6 +21,7 @@ typedef struct journal_op jop_t;
 struct journal_op *journal_new(struct jfs *fs, unsigned int flags);
 int journal_add_op(struct journal_op *jop, unsigned char *buf, size_t len,
 		off_t offset);
+void journal_pre_commit(struct journal_op *jop);
 int journal_commit(struct journal_op *jop);
 int journal_free(struct journal_op *jop);
 
diff --git a/libjio/trans.c b/libjio/trans.c
index a8b7b88..e738eb5 100644
--- a/libjio/trans.c
+++ b/libjio/trans.c
@@ -231,6 +231,8 @@ ssize_t jtrans_commit(struct jtrans *ts)
 		fiu_exit_on("jio/commit/tf_opdata");
 	}
 
+	journal_pre_commit(jop);
+
 	fiu_exit_on("jio/commit/tf_data");
 
 	if (!(ts->flags & J_NOROLLBACK)) {