Difference between revisions of "VFS"

From OpenZFS on OS X
Jump to: navigation, search
m
m
 
(11 intermediate revisions by one user not shown)
Line 3: Line 3:
 
{| style="color:green;background-color:#ffffcc;" border="1" cellpadding="20" cellspacing="0"
 
{| style="color:green;background-color:#ffffcc;" border="1" cellpadding="20" cellspacing="0"
 
!align="right" |Short-term holds
 
!align="right" |Short-term holds
 +
|vnode->name
 +
|incr
 +
|decr
 +
|'''Long-term holds'''
 
|vnode->name
 
|vnode->name
 
|incr
 
|incr
Line 11: Line 15:
 
|vnode_get*
 
|vnode_get*
 
|vnode_put
 
|vnode_put
 +
|'''OSX:'''
 +
|usecount
 +
|vnode_ref
 +
|vnode_rele
 +
|-
 +
!align="right" |IllumOS:
 +
|v_count
 +
|VN_HOLD
 +
|VN_RELE
 +
|'''IllumOS:'''
 +
|?
 +
|?
 +
|?
 
|-
 
|-
 
!align="right" |FreeBSD:
 
!align="right" |FreeBSD:
Line 16: Line 33:
 
|vget
 
|vget
 
|vrele/vput
 
|vrele/vput
 +
|'''FreeBSD:'''
 +
|holdcount
 +
|vn_lock
 +
|VOP_UNLOCK
 
|}
 
|}
 +
 +
The call vput in FreeBSD, means vn_unlock AND vrele.
 +
 +
OSX:
 +
 +
When calling vnode_create(), the created vnode will have a iocount++ set. When you are finished with it, someone will call vnode_put()
 +
 +
 +
vnop_lookup is given a name, and if found, should call vnode_create, and return a vnode with iocount+1.
 +
vfs_root will return the rootvp, with iocount+1
 +
 +
All other vnops that take a vnode as input, will generally do
 +
 +
vnode_get(vp)
 +
VNOP_GETATTR(vp)
 +
node_put(vp)
 +
 +
So in most of your vnops, you do not call vnode_put, as that is handled by the caller (VFS). (list all vnops where this is true here)
 +
 +
If your code calls vnop_lookup, or vfs_root, they return a vnode with iocount+1, so you should call vnode_put() when you are done with the vnode.
 +
 +
 +
=== Differences ===
 +
 +
'''VNOP_ROOT''' on OSX will hold iocount. On FreeBSD will hold usecount as well as vn_lock (holdcount)

Latest revision as of 07:14, 2 May 2014

VFS[edit]

Short-term holds vnode->name incr decr Long-term holds vnode->name incr decr
OSX: iocount vnode_get* vnode_put OSX: usecount vnode_ref vnode_rele
IllumOS: v_count VN_HOLD VN_RELE IllumOS: ? ? ?
FreeBSD: usecount vget vrele/vput FreeBSD: holdcount vn_lock VOP_UNLOCK

The call vput in FreeBSD, means vn_unlock AND vrele.

OSX:

When calling vnode_create(), the created vnode will have a iocount++ set. When you are finished with it, someone will call vnode_put()


vnop_lookup is given a name, and if found, should call vnode_create, and return a vnode with iocount+1. vfs_root will return the rootvp, with iocount+1

All other vnops that take a vnode as input, will generally do

vnode_get(vp)
VNOP_GETATTR(vp)
node_put(vp)

So in most of your vnops, you do not call vnode_put, as that is handled by the caller (VFS). (list all vnops where this is true here)

If your code calls vnop_lookup, or vfs_root, they return a vnode with iocount+1, so you should call vnode_put() when you are done with the vnode.


Differences[edit]

VNOP_ROOT on OSX will hold iocount. On FreeBSD will hold usecount as well as vn_lock (holdcount)