]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/private.h
tdb2: direct access during transactions.
[ccan] / ccan / tdb2 / private.h
index e29bda96cb60d3709619d12364ac196f5cc7a4d3..01172732980689ba3dd62a699ded3b38580ad9a9 100644 (file)
@@ -290,6 +290,15 @@ struct tdb_lock_type {
        uint32_t ltype;
 };
 
+/* This is only needed for tdb_access_commit, but used everywhere to
+ * simplify. */
+struct tdb_access_hdr {
+       struct tdb_access_hdr *next;
+       tdb_off_t off;
+       tdb_len_t len;
+       bool convert;
+};
+
 struct tdb_context {
        /* Filename of the database. */
        const char *name;
@@ -344,6 +353,9 @@ struct tdb_context {
 
        struct tdb_attribute_stats *stats;
 
+       /* Direct access information */
+       struct tdb_access_hdr *access;
+
        /* Single list of all TDBs, to avoid multiple opens. */
        struct tdb_context *next;
        dev_t device;   
@@ -355,7 +367,7 @@ struct tdb_methods {
        int (*write)(struct tdb_context *, tdb_off_t, const void *, tdb_len_t);
        int (*oob)(struct tdb_context *, tdb_off_t, bool);
        int (*expand_file)(struct tdb_context *, tdb_len_t);
-       void *(*direct)(struct tdb_context *, tdb_off_t, size_t);
+       void *(*direct)(struct tdb_context *, tdb_off_t, size_t, bool);
 };
 
 /*
@@ -435,9 +447,6 @@ const void *tdb_access_read(struct tdb_context *tdb,
 void *tdb_access_write(struct tdb_context *tdb,
                       tdb_off_t off, tdb_len_t len, bool convert);
 
-/* Is this pointer direct?  (Otherwise it's malloced) */
-bool is_direct(const struct tdb_context *tdb, const void *p);
-
 /* Release result of tdb_access_read/write. */
 void tdb_access_release(struct tdb_context *tdb, const void *p);
 /* Commit result of tdb_acces_write. */