# Copyright (C) 2005-2019 Junjiro R. Okajima Basic Aufs Internal Structure Superblock/Inode/Dentry/File Objects ---------------------------------------------------------------------- As like an ordinary filesystem, aufs has its own superblock/inode/dentry/file objects. All these objects have a dynamically allocated array and store the same kind of pointers to the lower filesystem, branch. For example, when you build a union with one readwrite branch and one readonly, mounted /au, /rw and /ro respectively. - /au = /rw + /ro - /ro/fileA exists but /rw/fileA Aufs lookup operation finds /ro/fileA and gets dentry for that. These pointers are stored in a aufs dentry. The array in aufs dentry will be, - [0] = NULL (because /rw/fileA doesn't exist) - [1] = /ro/fileA This style of an array is essentially same to the aufs superblock/inode/dentry/file objects. Because aufs supports manipulating branches, ie. add/delete/change branches dynamically, these objects has its own generation. When branches are changed, the generation in aufs superblock is incremented. And a generation in other object are compared when it is accessed. When a generation in other objects are obsoleted, aufs refreshes the internal array. Superblock ---------------------------------------------------------------------- Additionally aufs superblock has some data for policies to select one among multiple writable branches, XIB files, pseudo-links and kobject. See below in detail. About the policies which supports copy-down a directory, see wbr_policy.txt too. Workqueue ---------------------------------------------------------------------- Aufs sometimes requires privilege access to a branch. For instance, in copy-up/down operation. When a user process is going to make changes to a file which exists in the lower readonly branch only, and the mode of one of ancestor directories may not be writable by a user process. Here aufs copy-up the file with its ancestors and they may require privilege to set its owner/group/mode/etc. This is a typical case of a application character of aufs (see Introduction). Aufs uses workqueue synchronously for this case. It creates its own workqueue. The workqueue is a kernel thread and has privilege. Aufs passes the request to call mkdir or write (for example), and wait for its completion. This approach solves a problem of a signal handler simply. If aufs didn't adopt the workqueue and changed the privilege of the process, then the process may receive the unexpected SIGXFSZ or other signals. Also aufs uses the system global workqueue ("events" kernel thread) too for asynchronous tasks, such like handling inotify/fsnotify, re-creating a whiteout base and etc. This is unrelated to a privilege. Most of aufs operation tries acquiring a rw_semaphore for aufs superblock at the beginning, at the same time waits for the completion of all queued asynchronous tasks.