VFS locking questions

Ulf Lilleengen lulf at stud.ntnu.no
Fri Aug 3 12:30:06 PDT 2007


I have a couple of questions regarding VFS, since I'm trying to SMPify the
fdescfs code in an effort to get some experience with VFS and freebsd locking...

What is really LK_INTERLOCK? When should it be used? When should one acquire it
(with VI_LOCK i assume), and what are the "semantics"?  

Let's say I have a function that should return a locked vnode. I lock the
hash-table with a regular mutex. Then, when I traverse the list, I check if the
entry is what I look for. If it is, I call VI_LOCK() on the vnode, use vget to
increment refcount, and then use vn_lock(vp, LK_EXCLUSIVE...) to lock the vnode
before the function returns. Is this correct behaviour? 

The LK_INTERLOCK bothers me a bit, because I'm not 100% sure on how it works.

Ulf Lilleengen

More information about the freebsd-hackers mailing list