Created
May 23, 2013 22:25
-
-
Save tuxillo/5639955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIRFS IMPLEMENTATION DRAFT | |
IN-MEMORY NODES (DIRFS NODES) | |
struct dirfs node have a pointer to their parent, this way there is no need for | |
them to be kept in any data structure (RB-trees, LIST, TAILQ). | |
Every dirfs node keeps a refcnt which indicates how many nodes it is parenting | |
and the node cannot be destroyed as long as it contains references. One of the | |
advantages of having a pointer to the parent is that you can recurse backwards | |
and find out the whole path of a node. For dirfs this is extremely useful as | |
many syscalls rely on them. | |
dirfs nodes are allocated via VOP_NRESOLVE() and free'ed (if possible) via | |
VOP_RECLAIM(). | |
A dirfs node which has an active file descriptor but no opencount references | |
on the vnode it points to will be stored in a TAILQ of "passive fds" so that | |
nresolve can still reactivate it instead of creating a new one. | |
Active dirfs nodes have fds with opencount on the vnode that represents them. | |
dirfs nodes use the inode number of the host file/directory they refer to. A | |
RB-tree keyed by inode number will be available to perform lookups. | |
HARD LINKS | |
Passive cached directory nodes disconnected from their vnode via VOP_RECLAIM | |
would be re-resolved at any time. VOP_NRESOLVE would have to find the node | |
instead of creating a new one. | |
--------------------------------- | |
Scratch pad | |
- RB tree only for active dirfs nodes. file descriptor resolver would trundle up | |
until a fd is found. | |
- dirfs nodes would have a pointer to their parent node. parents should be | |
ref'ed so that they are not ripped off from the dirfs node. | |
- RB tree probably not needed. Only parent pointer per dirfs node and a refcount | |
to the parent. | |
- Parent pointes would be setup in the resolver and torn-down in the reclaim | |
code. Reclaim is more complex then because you can't reclaim a node which | |
still has refcount to the parent. | |
- dirfs nodes should have an inode number which would be the real inode from the | |
real file in the host. | |
- It would be a good idea to lstat(2) on VOP_NRESOLVE() but do not open(2). | |
- Passive fd cache would need to be kept in a TAILQ. Those that have | |
no vp->v_opencount would be placed in this TAILQ. | |
- Active fds would be the ones via VOP_OPEN(). | |
- RB tree for inode_number -> dirfs node lookup. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment