summaryrefslogtreecommitdiff
path: root/lib/tdb2/private.h
AgeCommit message (Collapse)AuthorFilesLines
2011-09-14tdb2: unify tdb1_open into tdb_openRusty Russell1-0/+18
Finally, we gut tdb1_open() to the tdb1-specific parts, and call it from tdb_open if they specify the TDB_VERSION1 flag or the version is a TDB1. We also unify tdb_close(), based on the TDB_VERSION1 flag. Note that tdb_open(TDB_VERSION1) will fail on an existing tdb if it's a TDB2. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit c8c3b3568677e8b0105f84e4ab068c580faf4591)
2011-09-14tdb2: make jenkins_hash function non-static, rename to tdb_jenkins_hash.Rusty Russell1-0/+3
We're going to need access to it from tdb1_open, so expose it now. It's better in hash.c anyway. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit c8f6f8c2dea76042f74c02eff048847e62adcca6)
2011-09-14tdb2: merge tdb1_context into tdb_context.Rusty Russell1-62/+99
Finally, we split out the tdb2-specific parts of tdb_context, and put them into a "tdb2" sub-struct; the tdb1 parts go into a "tdb1" sub-struct. We get rido of tdb1_context and use tdb_context everywhere. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit bbeb528e74c0e234e1f724ac8d54be404cfc6f9a)
2011-09-14tdb2: Make TDB1 use the same tdb_hash() wrapper as TDB2Rusty Russell1-3/+3
This means converting the tdb1 inbuilt hash functions to the tdb2-style, so they return 64 bit. We truncate to 32 bit everywhere but in tdb_check() which needs to do so explicitly. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 3e46dde21261966941469a6c75e1b45cd2d26324)
2011-09-14tdb2: make tdb1 use same low-level lock functions.Rusty Russell1-1/+20
This means they will use the TDB_ATTRIBUTE_FLOCK functions, and get automatic reopen support. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit fbad02b680b6cbc33ae305ae1cbcdead4eedc7b1)
2011-09-14tdb2: Make tdb1 use the tdb_file structure.Rusty Russell1-2/+3
Because tdb2 allows multiple opens of the same TDB, we separate out the file information from the struct tdb_context. Do the same for tdb1. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 60210a73ec08a7b34ba637ad19e6749cf6dc1952)
2011-09-14tdb2: make TDB1 code use tdb2's TDB_ERROR and tdb_logerr()Rusty Russell1-3/+3
To do this, we make sure that the first few fields of tdb1_context and tdb_context are the same. This sweep also fixes up a few paths where we weren't setting tdb->ecode before our old logging function. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 919937354a331bb964564a11b5a5b80403ff8db9)
2011-09-14tdb2: rearrange tdb_context layout so tdb1_context can matchRusty Russell1-16/+16
By moving all the parts of struct tdb_context which logging and locking use to the beginning of the structure, we can make tdb1_context match, and thus pass that directly to the tdb_logerr() function, and later the locking functions. This is only necessary until we unify tdb1_context and tdb_context. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 0fd5be2955f8e6487c0f4ab711e2a6958bb8f412)
2011-09-14tdb2: keep link of every non-internal tdb.Rusty Russell1-3/+3
Instead of a per-file linked list, use a per-tdb list. This is needed for tdb_foreach(). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 2414f261918b4fb8a549dd385dba32118e37bf85)
2011-09-14tdb2: save openhook, allow tdb_get_attribute() on it.Rusty Russell1-0/+4
This makes it easy to call it again after a fork(), such as for re-establishing the CLEAR_IF_FIRST files locks. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 937d0babe99dcd315040a9e48430140e63e4a7df)
2011-09-14tdb2: add TDB_RDONLY flag, allow setting/unsetting it.Rusty Russell1-3/+0
You can only unset it if the TDB was originally opened O_RDWR. Also, cleaned up error handling in tdb_allrecord_lock() so we only get one log message on a r/o database. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit b87e14495d5b07e1b247218a72329f10ecb3da7f)
2011-09-14tdb2: save open_flags instead of mmap_flags.Rusty Russell1-2/+2
It's more consistent with what tdb1 does, and slightly more encapsulated. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 6b7c3c840eafbec211b9f58751c5ff754302a68e)
2011-09-14tdb2: Hand error code to logging function.Rusty Russell1-0/+1
Since we've deprecated tdb_error() function (and it didn't work right from inside the logging function anyway, since we didn't set tdb->ecode yet) we need to hand it to the log function. (Imported from CCAN commit 6e3d9e8a66bf8b45150500f176452ee8e9ee9927) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14tdb2: move transaction lockRusty Russell1-2/+2
Make it the same offset as TDB1. This isn't strictly necessary, but it would allow for total unification later, since TDB1 and TDB2's transaction code is otherwise completely compatible. (Imported from CCAN commit de432e8f857ce23bccde7c6ffa3e7e21456df18b) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14tdb2: fix tdb_lock offset.Rusty Russell1-1/+1
It can be 64 bits, for huge databases. (Imported from CCAN commit 736c033322079baf754261d82b6a83de53b2bb4e) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-09-14tdb2: Fix to always use 64-bit offset definitionRusty Russell1-7/+1
We use off_t in the tdb2 interface (for tdb_attribute_flock); we need to make sure that all callers agree on the size. This also causes a problem in the tests: it's not enough to include config.h first, we need the _FILE_OFFSET_BITS define from private.h. Otherwise, we can disagree about the definitions of F_SETLK, F_SETLKW and off_t, causing strange problems. (Imported from CCAN commit baa17ee2d5e01a32030f19e566007417d72b4b6e) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20tdb2: minor changes to SAMBIFY it.Rusty Russell1-4/+14
This is a bit messy, but it works. Kept as a separate patch so it's easier to merge back and forth with CCAN's tdb2. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-20tdb2: add lib/tdb2 (from CCAN init-1161-g661d41f)Rusty Russell1-0/+614
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>