Interview Practice
Read aloud is unavailable in this browser. Reading preferences still work.

Chubby

File, Directories, and Handles

Let's explore how Chubby works with files, directories, and handles.

1 min read

Chubby file system interface is basically a tree of files and directories, where each directory contains a list of child files and directories. Each file or directory is called a node.

Chubby file system
Chubby file system

Nodes

  • Any node can act as an advisory reader/writer lock.
  • Nodes may either be ephemeral or permanent.
  • Ephemeral files are used as temporary files, and act as an indicator to others that a client is alive.
  • Ephemeral files are also deleted if no client has them open.
  • Ephemeral directories are also deleted if they are empty.
  • Any node can be explicitly deleted.

Metadata

Metadata for each node includes Access Control Lists (ACLs), four monotonically increasing 64-bit numbers, and a checksum.

ACLs are used to control reading, writing, and changing the ACL names for the node.

  • Node inherits the ACL names of its parent directory on creation.
  • ACLs themselves are files located in an ACL directory, which is a well-known part of the cell’s local namespace.
  • Users are authenticated by a mechanism built into the RPC system.

Monotonically increasing 64-bit numbers: These numbers allow clients to detect changes easily.

  • An instance number: This is greater than the instance number of any previous node with the same name.
  • A content generation number (files only): This is incremented every time a file’s contents are written.
  • A lock generation number: This is incremented when the node’s lock transitions from free to held.
  • An ACL generation number: This is incremented when the node’s ACL names are written.

Checksum: Chubby exposes a 64-bit file-content checksum so clients may tell whether files differ.

Handles

Clients open nodes to obtain handles (that are analogous to UNIX file descriptors). Handles include:

  • Check digits: Prevent clients from creating or guessing handles, so full access control checks are performed only when handles are created.
  • A sequence number: Enables a master to tell whether a handle was generated by it or by a previous master.
  • Mode information (provided at open time): Enables the master to recreate its state if an old handle is presented to a newly restarted leader.
Save a specific section