Subject: Re: how to bring a mounted filesystem to an almost clean state?
To: Christian Limpach <chris@pin.lu>
From: Stephan Uphoff <ups@stups.com>
List: tech-kern
Date: 02/14/2003 22:09:11
Christian Limpach wrote:
> Quoting Stephan Uphoff <ups@stups.com>:
> > Christian Limpach wrote:
> > > I'm going to try to vn_lock all the vnodes on the filesystem 
> > > and then sync.  
> > 
> > How would you obey the locking order to avoid deadlocks ?
> 
> do you mean that the sync will also need to lock those vnodes?  Maybe I could 
> have the sync routine keep the locks it acquires?  I haven't really thought 
> this through and I'm not too familiar with these issues (yet).  What I want 
> to do (block all modifying access to the filesystem) seems to be achieved by 
> blocking vn_write's on the filesystem and at a first glance locking the vnode 
> seemed to accomplish this.

If you want to hold two or more locks and avoid deadlocks you have to always
acquire locks in a certain order =  the locking order
 
Locking order for vnodes is parent directory first then child second.

There is no "reasonable" way to just lock a list of random vnodes.