author | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-07-10 20:25:26 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2009-07-11 03:34:12 UTC |
parent | c02fcd2fada1b802d15645287de6161091d91790 |
UPGRADING | +2 | -1 |
bindings/python/libjio.c | +3 | -2 |
doc/guide.rst | +1 | -1 |
libjio/check.c | +1 | -1 |
libjio/libjio.3 | +1 | -1 |
libjio/libjio.h | +5 | -1 |
libjio/trans.c | +3 | -3 |
libjio/unix.c | +3 | -3 |
samples/full.c | +1 | -1 |
samples/jio3.c | +1 | -1 |
diff --git a/UPGRADING b/UPGRADING index 759a658..e4ea26d 100644 --- a/UPGRADING +++ b/UPGRADING @@ -6,10 +6,11 @@ You should always clean all your files before upgrading. While I don't expect the transaction on-disk format to change, it's a good practise and it doesn't take much effort. When it's mandatory, it will be noted. --> 0.51 (On-disk format change) +-> 0.51 - The way transactions are stored on disk has changed. It is mandatory that you jfsck all your files before upgrading. Hopefully this will be the last backwards-incompatible format change before 1.0. + - jtrans_new() now takes an additional flags parameter. -> 0.50 (Big API change) - Structures are now opaque types: diff --git a/bindings/python/libjio.c b/bindings/python/libjio.c index bd44992..ffb2014 100644 --- a/bindings/python/libjio.c +++ b/bindings/python/libjio.c @@ -385,8 +385,9 @@ It's a wrapper to jtrans_new().\n"); static PyObject *jf_new_trans(jfile_object *fp, PyObject *args) { jtrans_object *tp; + unsigned int flags = 0; - if (!PyArg_ParseTuple(args, ":new_trans")) + if (!PyArg_ParseTuple(args, "|I:new_trans", &flags)) return NULL; #ifdef PYTHON3 @@ -397,7 +398,7 @@ static PyObject *jf_new_trans(jfile_object *fp, PyObject *args) if (tp == NULL) return NULL; - tp->ts = jtrans_new(fp->fs); + tp->ts = jtrans_new(fp->fs, flags); if(tp->ts == NULL) { return PyErr_NoMemory(); } diff --git a/doc/guide.rst b/doc/guide.rst index 5202ff2..aeff7bb 100644 --- a/doc/guide.rst +++ b/doc/guide.rst @@ -92,7 +92,7 @@ are ignored for simplicity):: file = jopen("filename", O_RDWR | O_CREAT, 0600, 0); - trans = jtrans_new(file); + trans = jtrans_new(file, 0); jtrans_add(trans, buf, strlen(buf), 0); jtrans_commit(trans); jtrans_free(trans); diff --git a/libjio/check.c b/libjio/check.c index c39ce49..66c7314 100644 --- a/libjio/check.c +++ b/libjio/check.c @@ -199,7 +199,7 @@ enum jfsck_return jfsck(const char *name, const char *jdir, /* verify (and possibly fix) all the transactions */ for (i = 1; i <= maxtid; i++) { - curts = jtrans_new(&fs); + curts = jtrans_new(&fs, 0); if (curts == NULL) { ret = J_ENOMEM; goto exit; diff --git a/libjio/libjio.3 b/libjio/libjio.3 index 4de5881..3fc369d 100644 --- a/libjio/libjio.3 +++ b/libjio/libjio.3 @@ -21,7 +21,7 @@ libjio - A library for Journaled I/O .BI "off_t jlseek(jfs_t *" fs ", off_t " offset ", int " whence ");" .BI "int jclose(jfs_t *" fs ");" -.BI "jtrans_t *jtrans_new(jfs_t *" fs ");" +.BI "jtrans_t *jtrans_new(jfs_t *" fs ", unsigned int " flags ");" .BI "int jtrans_commit(jtrans_t *" ts ");" .BI "int jtrans_add(jtrans_t *" ts ", const void *" buf "," .BI " size_t " count ", off_t " offset ");" diff --git a/libjio/libjio.h b/libjio/libjio.h index 4421d25..9fba9ba 100644 --- a/libjio/libjio.h +++ b/libjio/libjio.h @@ -136,13 +136,17 @@ int jclose(jfs_t *fs); int jsync(jfs_t *fs); /** Create a new transaction. + * + * Note that the final flags to use in the transaction will be the result of + * ORing the flags parameter with fs' flags. * * @param fs open file the transaction will apply to + * @param flags transaction flags * @returns a new transaction (must be freed using jtrans_free()) * @see jtrans_free() * @ingroup basic */ -jtrans_t *jtrans_new(jfs_t *fs); +jtrans_t *jtrans_new(jfs_t *fs, unsigned int flags); /** Add an operation to a transaction. * diff --git a/libjio/trans.c b/libjio/trans.c index 4a4474e..c42bc9f 100644 --- a/libjio/trans.c +++ b/libjio/trans.c @@ -28,7 +28,7 @@ */ /* Initialize a transaction structure */ -struct jtrans *jtrans_new(struct jfs *fs) +struct jtrans *jtrans_new(struct jfs *fs, unsigned int flags) { pthread_mutexattr_t attr; struct jtrans *ts; @@ -39,7 +39,7 @@ struct jtrans *jtrans_new(struct jfs *fs) ts->fs = fs; ts->id = 0; - ts->flags = fs->flags; + ts->flags = fs->flags | flags; ts->op = NULL; ts->numops = 0; ts->len = 0; @@ -318,7 +318,7 @@ ssize_t jtrans_rollback(struct jtrans *ts) struct jtrans *newts; struct joper *op, *curop, *lop; - newts = jtrans_new(ts->fs); + newts = jtrans_new(ts->fs, 0); newts->flags = ts->flags; newts->numops = ts->numops; diff --git a/libjio/unix.c b/libjio/unix.c index 1a67847..c8d9461 100644 --- a/libjio/unix.c +++ b/libjio/unix.c @@ -87,7 +87,7 @@ ssize_t jwrite(struct jfs *fs, const void *buf, size_t count) off_t pos; struct jtrans *ts; - ts = jtrans_new(fs); + ts = jtrans_new(fs, 0); if (ts == NULL) return -1; @@ -124,7 +124,7 @@ ssize_t jpwrite(struct jfs *fs, const void *buf, size_t count, off_t offset) int rv; struct jtrans *ts; - ts = jtrans_new(fs); + ts = jtrans_new(fs, 0); if (ts == NULL) return -1; @@ -148,7 +148,7 @@ ssize_t jwritev(struct jfs *fs, const struct iovec *vector, int count) off_t ipos, t; struct jtrans *ts; - ts = jtrans_new(fs); + ts = jtrans_new(fs, 0); if (ts == NULL) return -1; diff --git a/samples/full.c b/samples/full.c index dd621b3..701a155 100644 --- a/samples/full.c +++ b/samples/full.c @@ -27,7 +27,7 @@ int main(void) } /* write two "Hello world"s next to each other */ - trans = jtrans_new(file); + trans = jtrans_new(file, 0); jtrans_add(trans, TEXT, strlen(TEXT), 0); jtrans_add(trans, TEXT, strlen(TEXT), strlen(TEXT)); r = jtrans_commit(trans); diff --git a/samples/jio3.c b/samples/jio3.c index c71c727..6731cd5 100644 --- a/samples/jio3.c +++ b/samples/jio3.c @@ -19,7 +19,7 @@ int main(int argc, char **argv) if (fs == NULL) perror("jopen()"); - ts = jtrans_new(fs); + ts = jtrans_new(fs, 0); if (ts == NULL) perror("jtrans_new()");