mirror of
https://github.com/containers/podman.git
synced 2025-05-20 16:47:39 +08:00

I was looking into why we have locks in volumes, and I'm fairly convinced they're unnecessary. We don't have a state whose accesses we need to guard with locks and syncs. The only real purpose for the lock was to prevent concurrent removal of the same volume. Looking at the code, concurrent removal ought to be fine with a bit of reordering - one or the other might fail, but we will successfully evict the volume from the state. Also, remove the 'prune' bool from RemoveVolume. None of our other API functions accept it, and it only served to toggle off more verbose error messages. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
23 lines
506 B
Go
23 lines
506 B
Go
package libpod
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// Creates a new volume
|
|
func newVolume(runtime *Runtime) (*Volume, error) {
|
|
volume := new(Volume)
|
|
volume.config = new(VolumeConfig)
|
|
volume.runtime = runtime
|
|
volume.config.Labels = make(map[string]string)
|
|
volume.config.Options = make(map[string]string)
|
|
|
|
return volume, nil
|
|
}
|
|
|
|
// teardownStorage deletes the volume from volumePath
|
|
func (v *Volume) teardownStorage() error {
|
|
return os.RemoveAll(filepath.Join(v.runtime.config.VolumePath, v.Name()))
|
|
}
|