Vnode

Vnode(virtual node)是 VFS 用來代表 active file / directory 的 kernel object。它讓 VFS 用同一種 identity 操作 local file、remote NFS file、directory、pseudo object 等。

角色

  • VFS 用 vnode 表示正在 open、cached、或 path traversal 中的 node。
  • Vnode 指向 file-system-specific data:local inode、NFS file handle、pseudo object 等。
  • Vnode 連到 operation table,讓 VFS 呼叫正確 implementation。

Vnode vs inode

inode 通常是某些 UNIX-like local file systems 內的 metadata object,identity 多半只在該 file system 內唯一。Vnode 是 VFS-level abstraction,可包住 inode,也可包住 remote file handle 或 pseudo file object。

為何 remote FS 需要它

Remote file system 需要 client / server 都能識別「同一個 file」。NFS mount protocol 回傳 file handle,後續 RPC 用它定位 remote object;client VFS 可把 file handle 包成 vnode,讓 local syscall path 不必理解每個 remote protocol。

Remote vnodes 需要 revalidation / invalidation,避免 client cache 留下 stale data 或錯誤 lookup。