Cloud Storage FUSE
repository·master·Indexed 25 days ago
https://github.com/googlecloudplatform/gcsfuseAn open-source FUSE adapter that enables mounting Google Cloud Storage buckets as local file systems. It is optimized for high-performance workloads, such as machine learning, through features like streaming writes, parallel downloads, and local file caching. The repository includes performance metrics scripts for GKE machine type tests, Orbax benchmarks, and listing operation benchmarks.
What's inside gcsfuse
- Cloud Storage FUSE is an open source FUSE adapter that allows you to mount and access Google Cloud Storage (GCS) buckets as if they were local file systems. It is particularly useful for workloads like machine learning that require access to large datasets stored in the cloud via standard file system APIs.
Understand the SCC Cache Directory Structure
masterThe tool expects a specific subdirectory named
gcsfuse-shared-chunk-cachewithin your provided-cache-dir. It automatically detects this structure, which uses SHA256-based hashing for organization.Structure Format:
<cache-dir>/gcsfuse-shared-chunk-cache/<2-char>/<2-char>/<full-hash>/<start>_<end>.binNote: This is distinct from the standard GCSFuse file cache, which uses the
gcsfuse-file-cachesubdirectory.How the SCC Garbage Collector works
masterThe tool uses a two-phase eviction process to ensure that concurrent reads of chunked files are not disrupted: files are renamed to
.bakduring the current run and are only physically deleted during the next run.Execution Workflow:
- Cleans up leftover
.bakfiles from previous runs. - Scans the cache directory for
.binfiles, collecting theiratimeand size. - If the total size is below the
-target-size-mb, the tool exits. - Sorts files by
atimeand selects the oldest files for expiration. - Renames selected files to
.bak. - Removes
.tmpfiles older than 1 hour. - Cleans up empty directories.
- Cleans up leftover
Configure Storage Control Client for HNS
masterThe Storage Control Client is used for Hierarchical Namespace (HNS) folder operations. It handles operations such asGetStorageLayout,CreateFolder,DeleteFolder,GetFolder, andRenameFolder. It usesGetStorageLayoutto determine the bucket type and applies default retry logic.File System Requirements for SCC Garbage Collector
masterThe garbage collector requires a file system (such as NFS or most POSIX-compliant systems) that supports:
- Atomic rename: Used to safely expire cache files by renaming
.binto.bakwithout disrupting concurrent reads. - Access time (atime) tracking: The LRU eviction algorithm relies on file access times to identify the least recently used chunks.
- Atomic rename: Used to safely expire cache files by renaming
Handle Cloud Storage name conflicts (foo vs foo/)
masterCloud Storage allows an object named
fooand an object namedfoo/to exist simultaneously. Because traditional Linux filesystems do not allow this, Cloud Storage FUSE resolves the conflict by renaming the file/symlink tofoo(whereis the U+000A line feed character).When a conflict occurs:
- The directory
foowill appear in listings. - The file or symlink will appear as `foo
`.
- Cloud Storage FUSE uses the line feed character because it is illegal in GCS object names, ensuring the mapping is unambiguous.
- The directory
Understand Cloud Storage FUSE limitations
masterCloud Storage FUSE does not support all standard POSIX filesystem features. Key limitations include:
- Directory Renaming: Only supported atomically in Hierarchical Namespace Buckets. In Flat buckets, it is unsupported unless
--rename-dir-limitis used (see guide). - Permissions/Ownership: File and directory permissions and ownership cannot be changed.
- Timestamps:
- Modification times (mtime) are tracked for files, but not for directories.
- Other timestamps like
ctimeandatimeare not tracked. Requests to change them will appear to succeed, but the results are unspecified.
- Directory Renaming: Only supported atomically in Hierarchical Namespace Buckets. In Flat buckets, it is unsupported unless
Configure GCSFuse-Level Control Client Retries
masterGCSFuse implements custom retry logic for Folder APIs and
GetStorageLayoutcalls to mitigate stall issues. This is applied to all buckets forGetStorageLayoutand to all control client operations for rapid buckets.Default parameters:
- Retry Deadline:
30 seconds - Total Budget:
5 minutes - Initial Backoff:
1 second
This strategy uses exponential backoff with jitter and includes stall detection with a deadline per attempt.
- Retry Deadline:
Unsupported path names in GCS
masterCertain path segments like
//,/./, or/../are valid object names in Google Cloud Storage but are not supported by the Linux filesystem. From v3.6.0 onwards, Cloud Storage FUSE handles these as follows:- Listing: These objects are hidden from file listings to prevent system errors or crashes.
- Rename/Delete: Directory-level operations (like deleting a parent directory) still apply to all contained objects, ensuring that these unsupported objects are not orphaned or left behind.
Understand Write/Read consistency guarantees
masterCloud Storage FUSE provides close-to-open and fsync-to-open consistency.
- Close/fsync: Once a file is closed or synced, a new generation of the object is created in Cloud Storage (provided the object hasn't changed since it was last observed).
- Open: An
opencall guarantees to observe a generation at least as recent as all generations created before theopenwas called.
Example of Conflict
- Machine A and B both open a file containing 'ABC'.
- Machine A modifies it to 'ABC-123' and closes/syncs it. The cloud now has 'ABC-123'.
- Machine B (still holding the old version) modifies its local copy to 'ABC-XYZ' and tries to close/sync.
- Because Machine A's write won, Machine B's file descriptor will receive an
ESTALEerror to prevent silent data loss.
Handle concurrency and avoid ESTALE errors
masterCloud Storage FUSE supports concurrent reads and writes to different objects in the same bucket. Concurrent writes to the same object from the same mount behave like a native file system.
Warning: Multiple Mounts When different mounts (e.g., different machines) attempt to write to the same object, the first mount to flush its changes wins. Other mounts that have not updated their local file descriptors will encounter a
syscall.ESTALEerror when attempting to save edits due to precondition checks.Best Practice To ensure data consistency and avoid
ESTALEerrors, do not allow multiple sources to modify the same object simultaneously.Cloud Storage FUSE v3: Automatic Optimization
masterCloud Storage FUSE v3 automatically optimizes its configuration when running on specific high-performance Google Cloud machine types. This maximizes performance for demanding workloads by effectively utilizing the machine's capabilities.
Note: Any values manually set at the time of mount will override these automatic defaults.