[EMAIL PROTECTED] writes:
> We've got the situation where a certain codepath needs two locks in the 
> filesystem space quite regularly (think: rename locking source and target 
> directories), and there's no single golden path how one prevents deadlocks 
> in such situations - have seen both trylock() as well as state-dependent 
> locking protocols (say, lock the alphabetically-lower pathname first, or 
> lock the one with the higher kernel virtual address first). You're right, 
> it's tricky.

All you really need is something that evaluates in the usual staircase
order, and some design-level guarantee that everyone takes the locks
in exactly the same way.

We do this in several other places -- the ill_lock_ills() function
sorts ill_t pointers into descending address order using a bubble
sort, and in strlock() by sorting the struct stdata pointers for mated
streams in descending order.

Using the same here (if it's really needed) should be sufficient.

(Something about trylock just seems inherently evil to me ...)

-- 
James Carlson, Solaris Networking              <[EMAIL PROTECTED]>
Sun Microsystems / 35 Network Drive        71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to