]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix a race with shared lookups on UFS. If the the dirhash code reached the
authorjhb <jhb@FreeBSD.org>
Tue, 16 Sep 2008 16:23:56 +0000 (16:23 +0000)
committerjhb <jhb@FreeBSD.org>
Tue, 16 Sep 2008 16:23:56 +0000 (16:23 +0000)
commit020ede1151961fbedcb0cfc78fde6a11aaff2cbc
tree7c30ca8d96a8f5c73c93315e915893b53f0ca049
parent3a8bef861f0b1a62ad9f5e2e87a644b9cb5677ab
Fix a race with shared lookups on UFS.  If the the dirhash code reached the
cap on memory usage, then shared LOOKUP operations could start free'ing
dirhash structures.  Without these fixes, concurrent free's on the same
directory could result in one of the threads blocked on a lock in a dirhash
structure free'd by the other thread.
- Replace the lockmgr lock in the dirhash structure with an sx lock.
- Use a reference count managed with ufsdirhash_hold()/drop() to determine
  when to free the dirhash structures.  The directory i-node holds a
  reference while the dirhash is attached to an i-node.  Code that wishes
  to lock the dirhash while holding a shared vnode lock must first
  acquire a private reference to the dirhash while holding the vnode
  interlock before acquiring the dirhash sx lock.  After acquiring the sx
  lock, it drops the private reference after checking to see if the
  dirhash is still used by the directory i-node.
sys/ufs/ufs/dirhash.h
sys/ufs/ufs/ufs_dirhash.c