HAMMER 21/many: B-Tree node locking finalization.
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 18 Jan 2008 07:02:41 +0000 (07:02 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 18 Jan 2008 07:02:41 +0000 (07:02 +0000)
commit6a37e7e4b492073cdb3c293d5a142462d05342eb
treed2f07bac4f310b58962d4221103b29d85dc8b613
parent5d9bf1c10b31c75e5527eb8922b322ff6dbe1d68
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