criu

FSNotify (Inotify and Fanotify)

CRIU supports checkpointing and restoring inotify and fanotify instances. These mechanisms allow applications to monitor filesystem events (like file creation, modification, or deletion).

The Challenges of FSNotify C/R

Restoring an fsnotify instance is inherently difficult because the kernel does not provide a direct way to retrieve the original path of a watched object (the “watchee”). Furthermore, the event queues themselves pose consistency risks.

1. Identifying the Watchee

When an application adds a watch (via inotify_add_watch), the kernel associates the watch with an inode, but it does not store the path used to create it. To restore the watch, CRIU must find a valid path to that specific inode.

2. Event Queue Consistency

If there are pending events in the fsnotify queue at the time of the dump, CRIU cannot currently “peek” at them or safely migrate them.

3. Ghost Files and Circular Dependencies

A “ghost file” is a file that was deleted by the application but is still held open. During restoration, CRIU must recreate these files. This action itself generates notify events, potentially confusing applications that monitor the directories where these ghost files are temporarily placed.

Support for Fanotify

CRIU also supports fanotify, including:

Current Strategy: “Chopping the Knot”

Due to the complexity of perfectly migrating event queues, CRIU’s current strategy is:

  1. Warn and Drop: Acknowledge that pending events are lost.
  2. Restore the Watches: Ensure the application continues to receive new events after restoration.
  3. Namespace Integration: Correctly map mount-level fanotify marks within their respective mount namespaces.

See also