portage.repository.storage.hardlink_rcu module¶
- class portage.repository.storage.hardlink_rcu.HardlinkRcuRepoStorage(repo, spawn_kwargs)¶
Bases:
portage.repository.storage.interface.RepoStorageInterface
Enable read-copy-update (RCU) behavior for sync operations. The current latest immutable version of a repository will be reference by a symlink found where the repository would normally be located. Repository consumers should resolve the cannonical path of this symlink before attempt to access the repository, and all operations should be read-only, since the repository is considered immutable. Updates occur by atomic replacement of the symlink, which causes new consumers to use the new immutable version, while any earlier consumers continue to use the cannonical path that was resolved earlier.
Performance is better than HardlinkQuarantineRepoStorage, since commit involves atomic replacement of a symlink. Since the symlink usage would require special handling for scenarios involving bind mounts and chroots, this module is not enabled by default.
repos.conf parameters:
sync-rcu-store-dir
Directory path reserved for sync-rcu storage. This directory must have a unique value for each repository (do not set it in the DEFAULT section). This directory must not contain any other files or directories aside from those that are created automatically when sync-rcu is enabled.
sync-rcu-spare-snapshots = 1
Number of spare snapshots for sync-rcu to retain with expired ttl. This protects the previous latest snapshot from being removed immediately after a new version becomes available, since it might still be used by running processes.
sync-rcu-ttl-days = 7
Number of days for sync-rcu to retain previous immutable snapshots of a repository. After the ttl of a particular snapshot has expired, it will be remove automatically (the latest snapshot is exempt, and sync-rcu-spare-snapshots configures the number of previous snapshots that are exempt). If the ttl is set too low, then a snapshot could expire while it is in use by a running process.
- async _check_call(cmd, privileged=False)¶
Run cmd and raise RepoStorageException on failure.
- Parameters
cmd (list) – command to executre
privileged (bool) – run with maximum privileges
- async _migrate(update_location)¶
When repo.user_location is a normal directory, migrate it to storage so that it can be replaced with a symlink. After migration, commit the content as the latest snapshot.
- async abort_update()¶
Delete the current update directory. If there was not an update in progress, or it has already been committed, then this has no effect.
- async commit_update()¶
Commit the current update directory, so that is becomes the latest immutable snapshot.
- property current_update¶
Get the current update directory which would have been returned from the most recent call to the init_update method. This raises RepoStorageException if the init_update method has not been called.
- Return type
str
- Returns
path of directory to update
- async garbage_collection()¶
Remove expired snapshots.
- async init_update()¶
Create an update directory as a destination to sync updates to. The directory will be populated with files from the previous immutable snapshot, if available. Note that this directory may contain hardlinks that reference files in the previous immutable snapshot, so these files should not be modified (tools like rsync and git normally break hardlinks when files need to be modified).
- Return type
str
- Returns
path of directory to update, populated with files from the previous snapshot if available