mirror of
https://github.com/containerd/containerd.git
synced 2026-11-06 05:17:02 +00:00
The mount handler built the device name from the source path, taking the base of the parent directory as a snapshot id. That reads an identity out of a layout only a snapshot directory has. A layer served from a layer content cache is mounted from the cache, whose parent directory is a shard named for the first two characters of the digest. Every blob in a shard then names one device. A second layer in a shard fails to mount. dmverity.Open finds the name taken, VerifyDevice compares the existing device's root hash against the one being mounted, and the mismatch is an error. No layer is served against the wrong root hash, and none of the colliding layers can be mounted. Name the device for the source and the mount point together. Mount closes the device it creates when the mount fails, so the name has to be unique to the mount. Neither half is unique alone: a cache serves one blob to every snapshot of that layer, and a mount point is reused once the mount before it is gone. A device left behind by a crash is reused only for the same blob in the same place, where its root hash still matches. Unmount reads the name back from the mounted source and needs nothing from either. Signed-off-by: Derek McGowan <derek@mcg.dev>