Merge pull request #36114 from Microsoft/jjh/fixdeadlock-lcowdriver-hotremove
LCOW: Graphdriver fix deadlock in hotRemoveVHDs
This commit is contained in:
commit
03a1df9536
|
@ -208,7 +208,7 @@ func (svm *serviceVM) hotAddVHDsAtStart(mvds ...hcsshim.MappedVirtualDisk) error
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := svm.config.HotAddVhd(mvd.HostPath, mvd.ContainerPath, mvd.ReadOnly, !mvd.AttachOnly); err != nil {
|
if err := svm.config.HotAddVhd(mvd.HostPath, mvd.ContainerPath, mvd.ReadOnly, !mvd.AttachOnly); err != nil {
|
||||||
svm.hotRemoveVHDsAtStart(mvds[:i]...)
|
svm.hotRemoveVHDsNoLock(mvds[:i]...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
svm.attachedVHDs[mvd.HostPath] = 1
|
svm.attachedVHDs[mvd.HostPath] = 1
|
||||||
|
@ -217,17 +217,19 @@ func (svm *serviceVM) hotAddVHDsAtStart(mvds ...hcsshim.MappedVirtualDisk) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// hotRemoveVHDs waits for the service vm to start and then removes the vhds.
|
// hotRemoveVHDs waits for the service vm to start and then removes the vhds.
|
||||||
|
// The service VM must not be locked when calling this function.
|
||||||
func (svm *serviceVM) hotRemoveVHDs(mvds ...hcsshim.MappedVirtualDisk) error {
|
func (svm *serviceVM) hotRemoveVHDs(mvds ...hcsshim.MappedVirtualDisk) error {
|
||||||
if err := svm.getStartError(); err != nil {
|
if err := svm.getStartError(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return svm.hotRemoveVHDsAtStart(mvds...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// hotRemoveVHDsAtStart works the same way as hotRemoveVHDs but does not wait for the VM to start.
|
|
||||||
func (svm *serviceVM) hotRemoveVHDsAtStart(mvds ...hcsshim.MappedVirtualDisk) error {
|
|
||||||
svm.Lock()
|
svm.Lock()
|
||||||
defer svm.Unlock()
|
defer svm.Unlock()
|
||||||
|
return svm.hotRemoveVHDsNoLock(mvds...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// hotRemoveVHDsNoLock removes VHDs from a service VM. When calling this function,
|
||||||
|
// the contract is the service VM lock must be held.
|
||||||
|
func (svm *serviceVM) hotRemoveVHDsNoLock(mvds ...hcsshim.MappedVirtualDisk) error {
|
||||||
var retErr error
|
var retErr error
|
||||||
for _, mvd := range mvds {
|
for _, mvd := range mvds {
|
||||||
if _, ok := svm.attachedVHDs[mvd.HostPath]; !ok {
|
if _, ok := svm.attachedVHDs[mvd.HostPath]; !ok {
|
||||||
|
|
Loading…
Reference in New Issue