mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
rbd: prevent re-use of destroyed resources
When an `.Destroy()` is called on an rbdImage (or rbdVolume or rbdSnapshot), the IOContext, Connection and other attributes are invalid. When using a destroyed resource that points to an object that was allocated through librbd, the process most likely ends with a panic. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
f1379e4cc4
commit
8c252d58ea
@ -390,15 +390,19 @@ func (ri *rbdImage) Connect(cr *util.Credentials) error {
|
||||
func (ri *rbdImage) Destroy(ctx context.Context) {
|
||||
if ri.ioctx != nil {
|
||||
ri.ioctx.Destroy()
|
||||
ri.ioctx = nil
|
||||
}
|
||||
if ri.conn != nil {
|
||||
ri.conn.Destroy()
|
||||
ri.conn = nil
|
||||
}
|
||||
if ri.isBlockEncrypted() {
|
||||
ri.blockEncryption.Destroy()
|
||||
ri.blockEncryption = nil
|
||||
}
|
||||
if ri.isFileEncrypted() {
|
||||
ri.fileEncryption.Destroy()
|
||||
ri.fileEncryption = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user