Subject: Re: Proposal: File system suspension - prerequisite for snapshots
To: None <tech-kern@netbsd.org>
From: Stephan Uphoff <ups@stups.com>
List: tech-kern
Date: 08/13/2003 23:12:37
Hi,

Juergen Hannken-Illjes wrote:
> It is not possible to put this gating into the VFS_ calls as they are often
> called with locked vnodes and the suspend request may deadlock.
> For the same reason this gating cannot reside below the VFS_ level.

Wouldn't this be the ideal time to convert the VFS layer to file system
internal locking ;-) ?

However I think that it is possible even with the current VFS locking style to 
to put the suspend functionality inside a file system (gating below the VFS_ level).

Here is the general idea:

1) Threads not holding any vnode lock can be blocked in VOP_LOCK, VFS_ROOT 
   or VFS_FHTOVP when they want to acquire their first vnode lock.  
  (Excluding file system internal calls to VOP_LOCK all callers will not own any vnode locks)

2) Threads holding a vnode lock will either:
	a) release the lock eventually without acquire new locks
	b) may call VOP_LOOKUP multiple times perhaps followed by VOP_CREATE, VOP_MKNOD,
           ... to lock additional or other vnodes.
           However there is a limit on the number of VOP_LOOKUP operations and the thread will
           drop all vnode locks eventually.

Stopping system call access to a file system could be done by blocking threads to acquire 
their first vnode lock (1) followed by waiting for all vnodes to be released (2).

Unfortunately processes that have files mapped in their process space can still modify the
data.
Additionally  VOP_BMAP, VOP_STRATEGY, VOP_GETPAGES, VOP_PUTPAGES can be called at any time.


Stephan