Stateless NFS Server

Stateless NFS server 指 NFS Version 3 server 不保存每個 client 的 open-file state;每個 RPC request 都帶足完成操作所需 context。目標是 crash recovery 簡單。

不保存哪些 correctness-critical state

  • client 是否 open 過某 file;
  • client current file offset;
  • per-client session / open file table;
  • volatile write context。

因此 NFS v3 沒有 open / close;read / write 直接帶 file handle、absolute offset、count / data、credentials、可能的 duplicate-detection info。

Recovery intuition

Server reboot 後沒有 open table 要重建。Client 可重送 request;若 operation idempotent 或 duplicate 可偵測,重送不會破壞結果。Mount protocol 的 mount list 可作 administrative hint,但不是 read/write correctness 的核心。

Costs

  • Security 較弱:若 authentication 弱,forged credential / handle 風險高。
  • Locking 弱:strong locking 需要 state,NFS v3 通常靠外部 lock service。
  • 每次 RPC 帶完整 context,message 較重。
  • Synchronous writes 到 stable storage 使 write performance 受限。

Version note

不要把 stateless 當成所有 NFS 的性質。NFS Version 4 引入 stateful mechanisms 來改善 security、locking、performance、delegation。