HAMMER 21/many: B-Tree node locking finalization.
commitcb3d57692ded2889455baa0e488441be390047c6
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 18 Jan 2008 07:02:41 +0000 (18 07:02 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 18 Jan 2008 07:02:41 +0000 (18 07:02 +0000)
tree28a3be4423a8cf63f990ffe09700c03e162340bf
parentf47d0241e83aac10f4362cfd323aa5798a4268d8
HAMMER 21/many: B-Tree node locking finalization.

* Implement the final locking scheme for B-Tree nodes.  Use shared locks
  for all searches, upgrade to exclusive locks for modifications.  If
  unable to upgrade fall through with an EDEADLK error code and retry the
  operation after releasing all other locks and blocking on the lock that
  could not be obtained.

  Simple iterations never fail and do not need to handle an EDEADLK error
  code.

  Because EDEADLK can actually occur quite often the error paths for most
  code modules will begin to get some exercise, which is good for code
  stability.

  It is possible to cache cursor positions closer to the desired target
  to reduce re-lookup times but I don't try to do this yet.

* Finalize code for basic (unbalanced) deletions.   Neither leaf nor internal
  nodes are allowed to be empty any more (except at the root of a cluster),
  but recursive deletions may deadlock while going up the tree and leave
  an internal node with a zero'd out element.   The search and iteration
  code now properly detects such elements and finishes off the deletion,
  though a complete cleaning will be left up to the balancing module.

* Remove most instances of recursively instantiated cursors.  There is still
  one left in the directory deletion code.

* Remove all remaining unprotected cursor transitions (where locks had to be
  released to avoid deadlocks).
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_btree.c
sys/vfs/hammer/hammer_cursor.c
sys/vfs/hammer/hammer_cursor.h
sys/vfs/hammer/hammer_inode.c
sys/vfs/hammer/hammer_object.c
sys/vfs/hammer/hammer_ondisk.c
sys/vfs/hammer/hammer_recover.c
sys/vfs/hammer/hammer_spike.c
sys/vfs/hammer/hammer_subs.c
sys/vfs/hammer/hammer_vnops.c