author | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-10-10 19:43:41 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-10-10 19:45:19 UTC |
parent | bbfa7b7d288ae0cef484753c7c9673923433fada |
libjio/journal.c | +7 | -1 |
libjio/journal.h | +2 | -1 |
diff --git a/libjio/journal.c b/libjio/journal.c index e2a4889..28ab8f3 100644 --- a/libjio/journal.c +++ b/libjio/journal.c @@ -331,7 +331,6 @@ error: } -static unsigned char empty_blk[BSZ]; /** Save a single operation in the journal file */ int journal_add_op(struct journal_op *jop, unsigned char *buf, size_t len, @@ -340,6 +339,13 @@ int journal_add_op(struct journal_op *jop, unsigned char *buf, size_t len, ssize_t rv; struct on_disk_ophdr ophdr; struct iovec iov[3]; + static unsigned char *empty_blk = NULL; + + if (empty_blk == NULL) { + empty_blk = malloc(BSZ); + if (empty_blk == NULL) + goto error; + } /* start at 4k boundary */ off_t curpos = lseek(jop->fd, 0, SEEK_CUR); diff --git a/libjio/journal.h b/libjio/journal.h index 57eff46..98f7d76 100644 --- a/libjio/journal.h +++ b/libjio/journal.h @@ -3,10 +3,11 @@ #define _JOURNAL_H #include <stdint.h> +#include <unistd.h> /* sysconf() */ #include "libjio.h" /* filesystem block size */ -#define BSZ 4096 +#define BSZ sysconf(_SC_PAGESIZE) struct journal_op { int id;