This document describes MinIO's storage layer implementation, which handles low-level disk I/O operations and metadata persistence. The storage layer provides an abstraction over physical disks, manages the xl.meta metadata file format, and handles both local and remote disk access.
Related Pages:
MinIO defines a StorageAPI interface that abstracts disk operations. This interface has two primary implementations:
Sources: cmd/storage-interface.go28-133 cmd/xl-storage.go97-130 cmd/xl-storage-disk-id-check.go84-101 cmd/storage-rest-client.go162-169 cmd/storage-rest-server.go55-57
The StorageAPI interface defines fundamental disk operations:
| Operation Category | Key Methods | Purpose |
|---|---|---|
| Volume Management | MakeVol, MakeVolBulk, ListVols, StatVol, DeleteVol | Bucket-level operations |
| File Operations | WriteAll, ReadVersion, ReadXL, AppendFile | Read/write file data |
| Metadata Operations | WriteMetadata, UpdateMetadata, ReadVersion | Manage xl.meta files |
| Rename Operations | RenameData, RenameFile, RenamePart | Atomic file movement |
| Deletion | DeleteVersion, DeleteVersions, Delete | Remove files/versions |
| Information | DiskInfo, NSScanner | Disk stats and scanning |
Sources: cmd/storage-interface.go28-133
The xlStorage struct implements local disk operations. It manages a single disk's file system operations, tracks disk health, and enforces consistency checks.
Sources: cmd/xl-storage.go97-130
Disk Initialization:
format.json file at .minio.sys/format.jsonDirect I/O Support:
O_DIRECT flag when supported by filesystem (oDirect field)checkODirectDiskSupport() methodDisk ID Validation:
xlStorageDiskIDCheck wrapper validates disk ID on every operationerrDiskNotFound if disk ID mismatch detectedSources: cmd/xl-storage.go217-364 cmd/xl-storage.go455-487 cmd/xl-storage-disk-id-check.go84-101
MinIO implements several write strategies based on object size and operation type:
Write Operation Flow:
Sources: cmd/xl-storage.go56-73 cmd/xl-storage.go1686-1838
For objects smaller than smallFileThreshold (128 KiB), data is stored inline within the xl.meta file:
smallFileThreshold = 128 * humanize.KiByte
This optimization reduces disk I/O by eliminating separate data file reads for small objects.
Sources: cmd/xl-storage.go56-73
The WriteAll() method handles complete file writes:
.minio.sys/tmp/<uuid> firstO_DIRECT for large writes when availablexl.meta with checksums and versioning infoSources: cmd/xl-storage.go1686-1838
The RenameData() method performs atomic data movement with metadata updates:
xl.meta with updated informationSources: cmd/xl-storage.go1840-2028
Read Operation Types:
Sources: cmd/xl-storage.go1455-1577 cmd/xl-storage.go1579-1625 cmd/xl-storage.go1288-1354
Reads a specific object version's metadata and optionally inline data:
xl.meta file from diskgetFileInfo()FileInfo with version-specific metadataopts.ReadData is trueSources: cmd/xl-storage.go1455-1577
Optimized method for reading the latest version metadata:
RawFileInfo (raw bytes) instead of parsed FileInfoSources: cmd/xl-storage.go1579-1625
Delete Operation Strategies:
| Method | Use Case | Behavior |
|---|---|---|
DeleteVersion() | Delete specific version | Removes version from xl.meta, deletes data if last version |
DeleteVersions() | Batch delete | Processes multiple versions efficiently |
Delete() | Recursive delete | Moves to trash, optionally immediate purge |
Trash Mechanism:
Files are moved to .minio.sys/tmp/.trash/<uuid> before deletion:
cleanupTrashImmediateCallers()Sources: cmd/xl-storage.go1186-1201 cmd/xl-storage.go1203-1286 cmd/xl-storage.go1232-1286
The xl.meta file is MinIO's core metadata format. Each object version has an xl.meta file containing all metadata, checksums, and optionally inline data.
<bucket>/<object>/xl.meta
For versioned objects:
<bucket>/<object>/xl.meta (contains all versions)
Sources: cmd/xl-storage.go68-72
xl.meta Format V2:
Sources: cmd/storage-datatypes.go57-154 cmd/xl-storage.go490-527
The FileInfo struct represents parsed xl.meta data:
Key Fields:
DataBlocks, ParityBlocks, BlockSize, DistributionSources: cmd/storage-datatypes.go94-154
Writing Metadata:
FileInfo to msgpack format<path>/xl.metaxl.metaUpdating Metadata:
xl.metaSources: cmd/xl-storage.go2030-2104 cmd/xl-storage.go2140-2227
For distributed deployments, MinIO uses a storage REST protocol to access disks on remote nodes.
Sources: cmd/storage-rest-client.go162-169 cmd/storage-rest-server.go55-57
MinIO uses the Grid framework for high-performance RPC:
| Handler | Type | Purpose |
|---|---|---|
storageReadVersionRPC | Single | Read version metadata |
storageReadXLRPC | Single | Read raw xl.meta |
storageWriteAllRPC | Single | Write complete file |
storageRenameDataRPC | Single | Rename with metadata |
storageDeleteVersionRPC | Single | Delete version |
storageListDirRPC | Stream | List directory contents |
storageNSScannerRPC | Stream | Scan namespace for usage |
Sources: cmd/storage-rest-server.go60-77
Example: Remote ReadVersion
Sources: cmd/storage-rest-client.go333-351 cmd/storage-rest-server.go236-245
Every remote operation includes disk ID validation:
diskID in RPC parameterscheckID(diskID)format.jsonerrDiskNotFound if mismatchSources: cmd/storage-rest-server.go211-228
The xlStorageDiskIDCheck wrapper tracks disk health and metrics:
Sources: cmd/xl-storage-disk-id-check.go84-101 cmd/xl-storage-disk-id-check.go103-127
Provides comprehensive disk information:
Sources: cmd/storage-datatypes.go64-84
Tracks performance per operation type:
Operation Types Tracked:
storageMetricReadVersionstorageMetricWriteAllstorageMetricDeleteVersionstorageMetricRenameDataSources: cmd/xl-storage-disk-id-check.go45-81 cmd/storage-datatypes.go85-92
Each disk maintains a healing tracker file at .minio.sys/buckets/.healing.bin:
Sources: cmd/xl-storage.go431-450
The storage layer provides a clean abstraction over disk operations with the following key characteristics:
Design Principles:
StorageAPI interface supports both local and remote disksKey Components:
xlStorage: Local disk implementationxlStorageDiskIDCheck: Validation and metrics wrapperstorageRESTClient/Server: Remote disk access via Grid RPCxl.meta: Versioned metadata format with inline data supportIntegration Points:
StorageAPI for data/parity shard operationsReadXL() and ReadVersion()Refresh this wiki