aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFiles
2021-03-21Enable automatic cache size by default.newcacheSergey Poznyakoff8
This provides for the optimal performance. Additional GDBM_XVERIFY flag can be used when opening the database to request extended database verification (entire avail stack will be checked). * src/bucket.c (cache_lookup): Handle cache_size == GDBM_CACHE_AUTO. (_gdbm_cache_init): Likewise. * src/gdbm.h.in (GDBM_XVERIFY): New flag to gdbm_open. (GDBM_CACHE_AUTO): New constant. Define error constants within enum. Fix definition of GDBM_BAD_HASH_ENTRY. * src/gdbmclose.c: Fix misleading comment. * src/gdbmconst.h: Define DEFAULT_CACHESIZE to be GDBM_CACHE_AUTO. * src/gdbmopen.c (gdbm_fd_open): Call gdbm_avail_verify if the GDBM_XVERIFY flag is set. * doc/gdbm.texi: Update. * doc/gdbm.3: Update.
2021-03-20More optimizations in cache treeSergey Poznyakoff4
* src/bucket.c (gdbm_dir_entry_valid_p): Inline (cache_lookup): Keep track of cache hits. (_gdbm_get_bucket): Check the cache_entry first. (gdbm_get_cache_stats): Change signature. Return the per-db number of cache hits as well. * src/cachetree.c: Inline static functions. (_gdbm_cache_tree_lookup): Avoid extra level of indirection (nodeptr) at the expense of one additional comparison. * src/gdbm.h.in (gdbm_get_cache_stats): Change signature. * src/gdbmdefs.h (gdbm_file_info) <cache_hits>: New member.
2021-03-17Fix memory leak in gdbmtool "next" command.Sergey Poznyakoff2
* src/gdbmtool.c (nextkey_handler): Always free the previous key buffer.
2021-03-17New functions for traversing the available space stackSergey Poznyakoff8
* src/Makefile.am: Add avail.c * src/avail.c: New file. * src/gdbm.h.in (gdbm_avail_verify): New proto. * src/gdbmdefs.h (GDBM_HEADER_AVAIL_SIZE): New macro. * src/gdbmopen.c (gdbm_avail_table_valid_p) (gdbm_avail_block_validate) (gdbm_bucket_avail_table_validate): Move to avail.c * src/gdbmtool.c (_gdbm_avail_list_size) (_gdbm_print_avail_list): Rewrite using gdbm_avail_traverse. * src/proto.h (gdbm_avail_traverse): New proto. * src/systems.h: Include stddef.h.
2021-03-17Follow-up fixes to fd5cf245ea.Sergey Poznyakoff4
These address https://puszcza.gnu.org.ua/bugs/?503 * src/gdbmdefs.h (gdbm_avail_block_valid_p): Remove. * src/gdbmopen.c (gdbm_avail_block_validate): Use inline conditional instead of gdbm_avail_block_valid_p. (gdbm_fd_open): Revert to reading master avail_block in two passes (as was before fd5cf245ea). (validate_header): Add back master avail block consistency check. * src/gdbmtool.c (_gdbm_avail_list_size): Use _gdbm_avail_block_read. * src/recover.c (_gdbm_finish_transfer): Reset dbf->file_size.
2021-03-16Verify if key/pair ends at a valid offset before attempting to read it.Sergey Poznyakoff6
This fixes https://puszcza.gnu.org.ua/bugs/index.php?502. * src/findkey.c (gdbm_bucket_element_valid_p): Verify also if the key/data pair ends at a valid file offset. (_gdbm_read_entry): Set up the cache data only on success. * src/gdbmdefs.h (gdbm_bucket_element_valid_p): Remove declaration. (gdbm_file_info): New member 'file_size' keeps the recently retrieved value of the file size. It is invalidated wherever data is written to the database. * src/fullio.c (_gdbm_full_write,_gdbm_file_extend): Invalidate dbf->file_size. * src/gdbmopen.c (gdbm_fd_open): Initialize file_size to -1. (_gdbm_file_size): New function. * src/mmap.c (_gdbm_file_size): Remove. * src/proto.h (_gdbm_file_size): New proto.
2021-03-16Improve reading and validation of available blocks (avail_block).Sergey Poznyakoff5
Fixes http://puszcza.gnu.org.ua/bugs/?501. * src/falloc.c (_gdbm_avail_block_read): New function. (pop_avail_block): Use _gdbm_avail_block_read. * src/gdbmdefs.h: Fix typo in the comment. * src/gdbmopen.c (gdbm_avail_block_validate): Take size of the avail block in bytes as the third argument. All uses changed. (PARTIAL_HEADER_SIZE) (HEADER_AVAIL_SIZE): New macros. (_gdbm_validate_header): Validate the avail block as well. (validate_header): Don't validate the avail block fields here. (gdbm_fd_open): Read partial header up to the avail field, then read entire avail block using _gdbm_avail_block_read. * src/gdbmtool.c (_gdbm_print_avail_list): Fix avail block calculation (one extra entry was assumed). Use _gdbm_avail_block_read to obtain and validate block. * src/proto.h (_gdbm_avail_block_read): New proto. (gdbm_avail_block_validate): Change signature.
2021-03-16Fix memory leak in gdbm_recoverSergey Poznyakoff1
* src/recover.c (_gdbm_finish_transfer): Free the cache.
2021-03-16Fix bug #499Sergey Poznyakoff3
See http://puszcza.gnu.org.ua/bugs/?499 * src/gdbm.h.in (GDBM_BAD_HASH_ENTRY): New error code. * src/gdbmseq.c (get_next_key): Verify the computed hash and bucket address for the obtained key. * src/gdbmerrno.c (gdbm_errlist): Add error message for GDBM_BAD_HASH_ENTRY.
2021-01-09Merge branch 'master' into newcacheSergey Poznyakoff6
2021-01-09Minor changesSergey Poznyakoff3
* src/hash.c (_gdbm_hash): Suppress address sanitizer errors. * src/proto.h (gdbm_file_sync): Add missing return. * src/lex.l (input_context_pop): Delete current buffer when tos is reached.
2021-01-08Reword some messages and add translator comments.Sergey Poznyakoff3
* src/gdbmtool.c: Avoid duplicating the GDBM_BAD_AVAIL message. Add translator comments. * src/gdbmerrno.c: Add translator comments. * src/util.c: Likewise.
2021-01-02Update copyright yearsSergey Poznyakoff145
2021-01-02Update copyright yearsSergey Poznyakoff143
2020-12-24Merge branch 'master' into newcacheSergey Poznyakoff19
2020-12-24Fix the use of unprefixed dnl in configure.acSergey Poznyakoff1
2020-12-23Version 1.19v1.19Sergey Poznyakoff3
2020-12-23Update the docsSergey Poznyakoff9
* doc/Makefile.am: Use gendocs.pl to generate web version of the manual. * doc/gdbm.texi: Update. * doc/gendocs.pl: New file. * doc/otherdoc.texi.in: New file. * doc/.gitignore: Ignore otherdoc.texi. * doc/webdoc.init: New file. * doc/gendocs.sh: Remove. * doc/gendocs_template: Remove. * doc/html.init: Remove.
2020-12-23Update copyright yearsSergey Poznyakoff143
2020-12-23Remove duplicate global declarationsSergey Poznyakoff3
* src/gdbm_dump.c: Add missing I18N. * src/gdbm_load.c: Likewise. * src/parseopt.c (parseopt_program_doc) (parseopt_program_args): Remove duplicate declarations.
2020-10-31Recover from ENOMEM in cache_lookupSergey Poznyakoff1
* src/bucket.c (cache_lookup): Try to recover from ENOMEM by freeing the least recently used cache entry.
2020-10-29Minor changes.Sergey Poznyakoff3
* src/bucket.c (_gdbm_cache_init): Minimum cache capacity is 1. * src/cachetree.c (_gdbm_cache_tree_lookup): Fix the description. (_gdbm_cache_tree_destroy): Speed up the tree traversal. * src/gdbmsetopt.c (setopt_gdbm_setcachesize): Don't enforce minimal cache capacity.
2020-10-09Implement tagged structure initializers.Sergey Poznyakoff6
* NEWS: Document changes. * doc/gdbm.texi: Document changes. * src/datconv.c (datum_scan_tag): Implement tagged structure initialization. * src/gdbmtool.c (kvlist_free): Made extern. (kvlist_find): New function. * src/gdbmtool.h (kvlist_find, kvlist_free) (dsegm_list_find): New protos. (dsegm_free_list): Rename to dsegm_list_free. All uses changed. * src/gram.y: Forbid duplicate tags in kvlist.
2020-10-08Bugfixes.Sergey Poznyakoff2
* doc/gdbm.texi: Fix the description of a sample content structure. * src/datconv.c (datum_scan_notag): Proceed to the next kvpair only for segments of the FDEF_FLD type.
2020-03-15Implement the gdbm_bucket_count function.Sergey Poznyakoff4
* src/gdbmcount.c (gdbm_bucket_count): New function. * src/gdbm.h.in (gdbm_bucket_count): New proto. * doc/gdbm.texi: Document gdbm_bucket_count. * src/gdbmtool.c (bucket_count): Reimplement via gdbm_bucket_count.
2020-01-27Update copyright yearsSergey Poznyakoff144
2020-01-27Minor changesSergey Poznyakoff2
* src/cachetree.c (_gdbm_node_set_elem): Remove function. * src/findkey.c: Finalize efaefe4c.
2019-11-16Simplify memory allocationSergey Poznyakoff2
* src/gdbmdefs.h (cache_elem): Place one hash_bucket element at the end of the structure so it can be allocated along with it. * src/bucket.c (cache_elem_new): Allocate enough space for cache_elem and dbf->header->bucket_size hash bucket within.
2019-11-13Move cache element allocation to bucket.c.Sergey Poznyakoff5
* src/bucket.c (_gdbm_cache_elem_new): Rename to cache_elem_new. Make static. (cache_lookup): Allocate new elem if _gdbm_cache_tree_lookup returned node_new. * src/cachetree.c (cache_tree): Remove dbf. (_gdbm_cache_tree_delete): Use node->adr. (cache_tree_lookup): Rename to _gdbm_cache_tree_lookup. Change signature. Return pointer to the (found or inserted) node. Don't allocate elem, this is responsibility of the caller. (_gdbm_cache_tree_alloc): Change signature. * src/gdbmdefs.h (cache_node): New definition (from cachetree.c) * src/proto.h: Fix protos.
2019-11-13Namespace cleanupSergey Poznyakoff3
* src/proto.h (_gdbm_cache_tree_delete): Remove. (_gdbm_rbt_remove_node): Rename to _gdbm_cache_tree_delete. All uses changed
2019-11-13Don't cache data pagesSergey Poznyakoff1
* src/findkey.c (_gdbm_read_entry): Revert dc176a5c
2019-11-12Rewrite bucket cacheSergey Poznyakoff16
The new bucket cache uses the least recently used replacement policy (instead of the least recently read, implemented previously). It also allows for quick bucket lookups by the corresponding disk address. To this effect the cache entries form a red-black tree sorted by bucket address. Additionally, data buckets are also cached. * README: Describe the new branch. * src/bucket.c: Rewrite cache support. * src/cachetree.c: New file. * src/Makefile.am: Add new file. * src/findkey.c (_gdbm_read_entry): Use _gdbm_fetch_data. This ensures data pages are cached as well as buckets. * src/gdbm.h.in (GDBM_BUCKET_CACHE_CORRUPTED): New error code. (gdbm_cache_stat): New struct. (gdbm_get_cache_stats): New proto. * src/gdbmclose.c (gdbm_close): Call _gdbm_cache_free to dispose of the cache. * src/gdbmdefs.h (cache_elem_color): New data type. (cache_elem): New members: ca_left, ca_right, ca_node, and ca_hits. (cache_tree): New typedef. (gdbm_file_info): Remove bucket_cache and last_read. New fields: cache_num, cache_tree, cache_mru, cache_lru, cache_avail, cache_access_count. * src/gdbmerrno.c: Handle GDBM_BUCKET_CACHE_CORRUPTED. * src/gdbmopen.c (gdbm_fd_open): Change cache initialization. (_gdbm_init_cache, _gdbm_cache_entry_invalidate: Remove. * src/gdbmsetopt.c (setopt_gdbm_setcachesize): Cache can be re-initialized on the fly. * src/gdbmtool.c: Change bucket printing routines. * src/proto.h (_gdbm_read_bucket_at): Remove. (_gdbm_fetch_data,_gdbm_cache_init,_gdbm_cache_free) (_gdbm_cache_flush,_gdbm_cache_elem_new) (_gdbm_cache_tree_alloc,_gdbm_cache_tree_destroy) (_gdbm_cache_tree_delete,_gdbm_rbt_remove_node) (_gdbm_cache_tree_lookup): New protos. (_gdbm_init_cache,_gdbm_cache_entry_invalidate): Remove. * src/recover.c (_gdbm_finish_transfer): Adapt to the new cache structure. * src/update.c: Likewise. * tests/setopt00.at: Fix second GDBM_SETCACHESIZE test.
2019-10-29Pre-read the memory mapped regions on systems that support itSergey Poznyakoff1
* src/mmap.c (GDBM_MMAP_FLAGS): Define to MAP_POPULATE or MAP_PREFAULT_READ, if available. (_gdbm_internal_remap): Use GDBM_MMAP_FLAGS.
2019-10-29Minor changesSergey Poznyakoff4
* src/gdbmconst.h: Don't redefine SIZE_T_MAX * src/gdbmtool.c: Likewise. Include <termios.h>, instead of <sys/termios.h> * configure.ac: Don't check for termios.h * tests/closerr.c: Minor fixes.
2019-04-08Update copyright yearsSergey Poznyakoff143
2019-04-08Preserve locking type during database reorganizationSergey Poznyakoff1
* src/recover.c (_gdbm_finish_transfer): Preserve locking type.
2018-11-27Fix typo in the manpage.Sergey Poznyakoff1
2018-10-27Version 1.18.1v1.18.1Sergey Poznyakoff2
2018-10-18Restore backward compatibility with older databasesSergey Poznyakoff1
* src/gdbmopen.c (validate_header): Silently accept databases with next_block pointing beyond end of file.
2018-10-18Attempt recovery in case of invalid next_block header fieldSergey Poznyakoff4
* src/gdbmopen.c (validate_header): Return GDBM_NEED_RECOVERY if next_block is invalid. (_gdbm_validate_header): New function. (gdbm_fd_open): Set need_recovery depending on return from validate_header. (gdbm_open): Bail out on invalid value of GDBM_OPENMASK bits. * src/proto.h (_gdbm_validate_header): New proto. * src/recover.c (check_db): Re-validate the header. * src/gdbmtool.c (export_handler): Fix option processing.
2018-08-31Various bugfixes.Sergey Poznyakoff12
* compat/dbmopen.c (ndbm_open_dir_file0): Ignore ENOENT. * src/falloc.c (push_avail_block): Free temporary storage no matter what return status. * src/gdbm.h.in (GDBM_FILE_TRUNCATE_ERROR): New error code. * src/gdbmdump.c (_gdbm_dump_ascii): Initialize rc. * src/gdbmerrno.c: Handle new error.code * src/gdbmload.c (gdbm_load_bdb_dump): Initialize rc * src/gdbmopen.c (_gdbm_ftruncate): New function. (gdbm_fd_open): Use _gdbm_ftruncate. Check its return. * src/gdbmseq.c (gdbm_firstkey): Initialize dsize * src/gdbmtool.c (command_generator): Check if cmd is NULL. (shouldn't happen, but anyways). * src/mmap.c (_gdbm_mapped_lseek): Check for vailidity of the 'whence' parameter. * src/systems.h (TRUNCATE): Remove macro. * src/util.c (vgetyn): Remove unnecessary assignment.
2018-08-21Version 1.18v1.18Sergey Poznyakoff2
2018-08-19Fix directory entry validation.Sergey Poznyakoff1
Bug reported by Miroslav Lichvar and Marek Skalický * src/bucket.c (gdbm_dir_entry_valid_p): Fix lower limit for the allowed bucket address. Initial allocation of second block for the directory can be eventually returned to the available list when the directory is expanded during bucket splitting.
2018-08-12BugfixSergey Poznyakoff3
* src/gdbmdump.c (_gdbm_dump_ascii): Clear the GDBM_ITEM_NOT_FOUND error. * src/gdbmexp.c (gdbm_export_to_file): Likewise. * NEWS: Update.
2018-08-03BugfixSergey Poznyakoff1
* src/gdbmopen.c (gdbm_avail_table_valid_p): Fix improper use of the GDBM_DEBUG macro.
2018-07-31BugfixSergey Poznyakoff1
* src/gdbmsync.c (gdbm_sync): Always return a meaningful value
2018-07-30Version 1.17v1.17Sergey Poznyakoff2
2018-07-02BugfixesSergey Poznyakoff2
* src/recover.c (backup_name): Fix memory overwrite. * src/gdbmtool.c (recover_handler): New option "force".
2018-07-01Change return value of gdbm_close and gdbm_syncSergey Poznyakoff20
* src/gdbm.h.in (gdbm_close, gdbm_sync): Return int (GDBM_FILE_CLOSE_ERROR, GDBM_FILE_SYNC_ERROR): New error codes. * src/gdbmclose.c (gdbm_close): Return 0 on success, -1 on failure. Set gdbm_errno and errno. * src/gdbmsync.c (gdbm_sync): Likewise. * src/gdbmerrno.c: Handle new error codes. * src/mmap.c (_gdbm_mapped_sync): Set gdbm_errno. * src/proto.h (gdbm_file_sync): Set gdbm_errno. * doc/gdbm.3: Document changes. * doc/gdbm.texi: Document changes. * NEWS: Document changes. * configure.ac: Set patchlevel. * tests/Makefile.am: Add new test. * tests/testsuite.at: Add new test. * tests/closerr.at: New test case. * tests/closerr.c: New test program. * tests/gtdel.c: Check gdbm_close return. * tests/gtdump.c: Likewise. * tests/gtfetch.c: Likewise. * tests/gtload.c: Likewise. * tests/gtopt.c: Likewise. * tests/gtrecover.c: Likewise.
2018-06-27Version 1.16v1.16Sergey Poznyakoff3

Return to:

Send suggestions and report system problems to the System administrator.