NFS

Zhaoyu Luo bio photo By Zhaoyu Luo

NFS

Why we need NFS?

  • Sharing/collaboration
  • access data from anywhere
  • have many clients -> server scaling problem
  • administration/ security

NFS

  • simple/ fast server crash recovery

Architecture of generic distributed filesystem

translate local read() write() over network so that remote server could understand

NFS protocol

  • stateless: server does not track information about clients, e.g., who they are, what they cache
    • each client request has all info needed to serve request
    • upon failure: client retry
  • File handler:
    • local file handler: <volume ID, inode NO, generation NO>
      • generation NO: in case the server restart, then assgin different inode NO to same object

      read(fh, offset, size) write(fh, data, offset, size) fh := lookup(parent_fh, name)

Filesystem API

open("/foo/bar.txt", O_RDONLY) while foo is root local mounted:

  1. client lookup(root_fh, "bar.txt" in server
    • server return file_descriptor of “bar.txt”

read(fd, ...): send request to server, server read that for client

Failure

  • key: idempotency (performing action N times == perform 1 time)
  • client retry
    • have to be smart about retry

Problem

  • remote is slower than local
    • client cache in memory
  • Visibility: client B has write buffer for writing, so that other clients could not see update of B
    • flush dirty pages from client upon file close
  • Stateless
    • before using a file (maybe in local cache), check if file has been modified (ask server use getattr())
  • Attribute cache
    • trust contents of this cache for period of time (e.g., 3 seconds)