Skip to content

Instantly share code, notes, and snippets.

@jki127
Last active November 6, 2018 22:12
Show Gist options
  • Save jki127/6d4bce3e8904a40510a1ad1eda73096a to your computer and use it in GitHub Desktop.
Save jki127/6d4bce3e8904a40510a1ad1eda73096a to your computer and use it in GitHub Desktop.

File Systems - DistSys Lecture - Oct 11, 2018

Files are a squence of bytes

File Attributes:

  • permissions
  • name
  • owner
  • timestamp

Layers

  • disk (SSD nowadays)
  • driver
  • file system interface (vfs on Unix)
  • kernel
  • OS
  • standard library
  • application

Types of filesytems

  • FAT32
  • NTFS
  • ext4
  • HFS+
  • APFS

Distributed File System

Layers

  • disk (SSD nowadays)
  • driver
  • file system interface (vfs on Unix)
  • network
  • socket
  • disk

A distributed file system should be:

  • Fast
  • Reliable
  • Concurrency-safe (handle race conditions)
  • maintaining State

The State keeps track of:

  • file descriptors
  • the file pointer: the location where a process left off in a open file
  • buffer

Stateless Servers?

  • Idempotent: we get the same result no matter how many times we try something

Network File System (NFS)

  • UFIDs (Unique File ID) are like inodes
    • anytime a client requests a file from a server, it returns the file’s UFID

The NFS Layer maps file descriptions to UFIDs

The NFS Layer maps file descriptions to UFIDs

Reading a file

Local Linux System

fd = open("filepath")
read(fd, buf, 1024)
read(fd, buf, 1024)
close(fd) // nothing to do on server

NFS System

ufid = LOOKUP("filepath")
READ(ufid, buf, 1024, 0) // last argument is offset
READ(ufid, buf, 1024, 1)

Writing a file

Local Linux System

fd = open("filepath")
write(fd, buf, 1024)
write(fd, buf, 1024)
close(fd) // nothing to do on server

store all the write calls and when the file is closed sending the server one aggragated nfs WRITE call

NFS System

ufid = LOOKUP("filepath")
WRITE(ufid, buf, 2048) 
  • What if the server is dead while we’re trying to write to the server?
    • When close(fd) is called, NFS keeps trying to write/close over and over again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment