vms_tdb rewrite

Dave Jones JONESD at er6s1.eng.ohio-state.edu
Fri Oct 31 20:09:29 GMT 2003

The zip file http://www.er6.eng.ohio-state.edu/~jonesd/samba/vms_tdb2.zip
contains a replacement for vms_tdb.c/.h.  The single source file vms_tdb.c has
been split into 2 files (vms_tdb2.c and vms_tdb_isam.c) and tdb.h reorganizes
the TDB_CONTEXT structure.

Major changes for the rewrite of VMS TDB file:

  - The TDB_CONTEXT structure was changed to include a function dispatch table
    for and isolate the VMS-specific structures.  One set of functions, defined
    in vms_tdb2.c, handles 'internal' memory-resident tdbs and another set,
    defined in vms_tdb_isam.c handles file-based persistent tdbs.

  - The TDB file now stores format version information in the key name
    field of the primary key's key descriptor.  The original format, indicated
    by a blank on missing description, will be known as version 0 and is 
    still supported by this module.  The new format will known as version 1
    and the description has the form "TDBHASH.1/n" where 'n' in the number of
    bits in the hash mask.  The RMS characteristics have not changed between
    the 2 formats.

  - Version 1 uses a different hash function which includes limiting the
    result value to 'n' bits (default 9).  When using this few bits, the
    gdbm hash used in version 0 does not produce a good distribution for the
    keys used in unexpected.tdb.

  - If tdb_open() must create a new file, the target directory is searched for
    a vms_tdb_default.conf configuration file.  If found, this text file is 
    scanned to determine the number of bits to use in the hash mask.  Each 
    line of the file is either a comment or a line consisting of the filename 
    followed by a space and an integer representing the number of bits.

  - Version 1 deletes entries by truncating the record to 4 bytes (the primary
    key) rather than performing an RMS delete.  A subsequent insert of a record
    with the same key will reuse this deleted entry.  This change avoids the
    problem of the tdb file filling up it's data buckets with RFA's of deleted
    records.  Keeping the deleted records may add some overhead to tdb_traverse
    operations, but this overhead is limited by the relatively small range of
    hash values.

  - The RAB now specifies manual unlocking for the read records rather than
    automatic locking.  In general, the lookup sub-function accumulates the
    locks on all records it reads with that same hash key and then releases 
    them together as a group.  This helps avoid some race conditions when 
    adding a new record.

The new tdb functions seem to pass the tdbtorture test OK.

David L. Jones               |      Phone:    (614) 292-6929
Ohio State University        |      Internet:
140 W. 19th St. Rm. 231a     |               jonesd at er6s1.eng.ohio-state.edu
Columbus, OH 43210           |               vman+ at osu.edu

Disclaimer: I'm looking for marbles all day long.

More information about the samba-vms mailing list