Pathname lookup – The Linux Kernel documentation
The Linux Kernel documentation discusses the storage and lifetime of cached symlinks. It explains how symlinks are typically stored in either the inode or the page cache, and the mechanisms used for safe access to these cached entries. The article also details the complexities involved when symlinks are stored in different locations and the implications for pathname lookup.
- ▪Symlinks are cached by Linux to avoid repeated access to external storage.
- ▪They are typically stored in the inode or the page cache, depending on the filesystem's choice.
- ▪The pathname lookup code must ensure stable references to cached symlinks, especially when they are not stored in the inode.
Opening excerpt (first ~120 words) tap to expand
Storage and lifetime of cached symlinks¶ Like other filesystem resources, such as inodes and directory entries, symlinks are cached by Linux to avoid repeated costly access to external storage. It is particularly important for RCU-walk to be able to find and temporarily hold onto these cached entries, so that it doesn’t need to drop down into REF-walk. While each filesystem is free to make its own choice, symlinks are typically stored in one of two places. Short symlinks are often stored directly in the inode. When a filesystem allocates a struct inode it typically allocates extra space to store private data (a common object-oriented design pattern in the kernel). This will sometimes include space for a symlink.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Kernel.