Version 11.1.0
File System Interface and Operating System Support
Data StructuresSource Location
WT_FILE_HANDLE
WT_FILE_SYSTEM
src/include/os.h
src/include/os_fhandle_inline.h
src/include/os_fs_inline.h
src/include/os_fstream_inline.h
src/include/os_windows.h
src/include/posix.h
src/os_common/
src/os_posix/
src/os_win/

Caution: the Architecture Guide is not updated in lockstep with the code base and is not necessarily correct or complete for any specific release.

Support for Multiple Operating Systems

WiredTiger runs on a variety of systems with different interfaces for file system and operating system services. Therefore we have abstract implementations of various OS services, such as threading, clock, etc. We choose which implementation of the abstraction to include at compile time, and the rest of WT code doesn't need to worry about these details. Currently WiredTiger supports POSIX and Windows operating systems through maintaining separate folders for each system. By checking the current machine's operating system, WiredTiger either compiles the os_posix or os_win folder. Additional structures and definitions specific to the operating system are defined in the header files posix.h or os_windows.h.

WiredTiger File System and File Handle Interfaces

WiredTiger provides file system and file handle abstraction layers, or interfaces, to accommodate for a standard set of functionalities across multiple file systems that may not have identical features.

File System Interface

The file system interface handles system calls on the file system namespace such as creation and deletion. WiredTiger defines the file system interface through WT_FILE_SYSTEM, which is initialized when a WiredTiger connection is opened. The interface has a set of function pointers that represent the file system functionalities that WiredTiger supports for a directory. WiredTiger defines POSIX and Windows file system function implementations in os_fs.c.

File Handle Interface

WiredTiger has a file handle interface called WT_FILE_HANDLE which defines a set of function pointers that represent I/O operations for a file. We use this interface as a base class to create file handle implementations specific to the operating system, for example WT_FILE_HANDLE_POSIX or WT_FILE_HANDLE_WINDOWS. These WiredTiger file handle structures are initialized when WT_FILE_SYSTEM::fs_open_file is called.

In WiredTiger, whenever a file is opened a file handle is created to accommodate the state of the file in cache. To prevent multiple file handles being created for a file, WiredTiger uses a hash table to maintain an single file handle for each opened file. A structure called WT_FH is used for accessing each entry in the hash table. Thus WiredTiger checks the hash table via WT_FH for an open file handle.

File System and Handle Customization

WiredTiger provides an API that allows programs to register their own customized file system using the WT_CONNECTION::set_file_system function. Programs need to supply their own file system structure and file handle implementations. See Custom File Systems for an example of how file system and handles are customized.

In-memory support

The in-memory configuration changes WiredTiger to run only in cache with no disk writes and is enabled through the WiredTiger connection configuration string. WiredTiger maintains each file through providing an in memory buffer for each file handle. Both in-memory file system and file handle implementations are found in os_fs_inmemory.c.

File Stream

WiredTiger contains a file stream implementation called WT_FSTREAM. This structure is mainly used for non-critical functionalities such as writing verbose messages or writing to WiredTiger statistics logs.

Multiple System Architecture Support

WiredTiger supports x86_64, i386, mips, ppc, aarch64, s390x, riscv64, loongarch64 and sparc system architectures which are found in gcc.h.