git » libjio » commit c892113

There is no point in open lockfile O_SYNC now that it's not used in jfsck() (see jfsck-ignore_lockfile.patch).

author Alberto Bertogli
2004-04-30 13:11:26 UTC
committer Alberto Bertogli
2007-07-15 12:43:37 UTC
parent 41617337b5f7a55191b670eb76a513c513bd6005

There is no point in open lockfile O_SYNC now that it's not used in jfsck() (see jfsck-ignore_lockfile.patch).

There is no point in open lockfile O_SYNC now that it's not used in jfsck()
(see jfsck-ignore_lockfile.patch).

While at it, also remove the bogus, racy and unneeded access() call before the
open().

This change (the O_SYNC one, the access() is just code cleanup) improves
performance a huge lot because it avoids small writes and seeking all over the
place. For instance, dbench performance with two processes goes from a 2.40
MB/sec to 4.50 MB/sec.

libjio.c +1 -6

diff --git a/libjio.c b/libjio.c
index 84a79bd..17f9eac 100644
--- a/libjio.c
+++ b/libjio.c
@@ -481,12 +481,7 @@ int jopen(struct jfs *fs, const char *name, int flags, int mode, int jflags)
 		return -1;
 	
 	snprintf(jlockfile, PATH_MAX, "%s/%s", jdir, "lock");
-	if (access(jlockfile, F_OK) != 0) {
-		/* file doesn't exists, create it */
-		jfd = open(jlockfile, O_RDWR | O_CREAT | O_SYNC, 0600);
-	} else {
-		jfd = open(jlockfile, O_RDWR | O_SYNC, 0600);
-	}
+	jfd = open(jlockfile, O_RDWR | O_CREAT, 0600);
 	if (jfd < 0)
 		return -1;