Subject: Re: mount_null: /mnt (/mnt) and /mnt are not distinct paths
To: Bill Sommerfeld <wes@thunk.epilogue.com>
From: Konrad Schroder <perseant@hitl.washington.edu>
List: tech-kern
Date: 07/02/1999 11:57:37
On Wed, 30 Jun 1999, Bill Sommerfeld wrote:

> BSD4.4 VFS is that if Y is a vnode in a subdirectory of X, X must
> always be locked before Y.
> 
> if you have:
> 	mount -t null /mnt  /mnt/xxx/yyy
> 
> Then, given the new pass-through locking scheme implemented by the
> other Bill S., if two processes both try to look up /mnt/xxx/yyy, you
> may deadlock:

Wouldn't this also deadlock if you, e.g., 

	mount -t null /foo /mnt
	mount -t null /foo /mnt/xxx/yyy
?

I don't see a good way to avoid this problem, since the fact that nullfs
can clone parts of the tree somewhere else effectively invalidates the
assumption that the filesystem has a tree structure, which is what you're
relying on by ordering the vnodes as stated.

> 	process A:
> 		lock /mnt
> 		lock /mnt/xxx
> 		unlock /mnt
> 		<blocks doing I/O reading the /mnt/xxx directory>
> 
> 	process B:
> 		lock /mnt
> 		BLOCK waiting for lock on /mnt/xxx held by A
> 
> 	process A:
> 		BLOCK waiting for lock on /mnt/xxx/yyy, AKA /mnt, held
> 			by B

------------------------------------------------------------------------
Konrad Schroder          http://www.hitl.washington.edu/people/perseant/
System Administrator                        perseant@hitl.washington.edu
Human Interface Technology Lab                    Voice: +1.206.616.1478
Box 352142, University of Washington, 98195, USA    FAX: +1.206.543.5380