git » libjio » commit 3bcefbe

Only call posix_fadvise() if we know we're going to read the data.

author Alberto Bertogli
2009-04-03 04:08:15 UTC
committer Alberto Bertogli
2009-04-03 04:08:15 UTC
parent 80a902981843f3579fcb36d4123c5f00d42ce6d4

Only call posix_fadvise() if we know we're going to read the data.

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

libjio/trans.c +5 -3

diff --git a/libjio/trans.c b/libjio/trans.c
index 6fb6885..95ecfad 100644
--- a/libjio/trans.c
+++ b/libjio/trans.c
@@ -204,9 +204,11 @@ int jtrans_add(struct jtrans *ts, const void *buf, size_t count, off_t offset)
 	jop->pdata = NULL;
 	jop->locked = 0;
 
-	/* it's highly likely that jtrans_commit() will want to read the
-	 * current data, so we tell the kernel about that */
-	posix_fadvise(ts->fs->fd, offset, count, POSIX_FADV_WILLNEED);
+	if (!(ts->flags & J_NOROLLBACK)) {
+		/* jtrans_commit() will want to read the current data, so we
+		 * tell the kernel about that */
+		posix_fadvise(ts->fs->fd, offset, count, POSIX_FADV_WILLNEED);
+	}
 
 	return 1;
 }